Files
phanpy-cz/assets/year-in-posts-DZVzhOlC.js
2026-02-07 19:49:28 +01:00

3 lines
70 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{K as ti,l as Yt,I as ge,b as Fe,V as ei,a as Ee,Z as ii,d as G,a3 as ni,A as zt,m as mt,y as ft,u as a,k as lt,Y as si,B as Me,T as Wt,$ as ri}from"./pwa-viewport-7HQOd5MC.js";import{F as Gt,ag as oi,d as li,s as le,p as Ct,x as hi,L as ht,I as J,i as ci,e as ui,r as ai,j as fi,n as Ae,G as Le,Y as di}from"./ScheduledAtField-B9b7q7O5.js";import{i as gi,N as pi}from"./main-BIy8J6P1.js";import"./ICONS-C5h6VnP9.js";var A;function W(t,i,e){const s=typeof e,n=typeof t;if(s!=="undefined"){if(n!=="undefined"){if(e){if(n==="function"&&s===n)return function(l){return t(e(l))};if(i=t.constructor,i===e.constructor){if(i===Array)return e.concat(t);if(i===Map){var r=new Map(e);for(var o of t)r.set(o[0],o[1]);return r}if(i===Set){o=new Set(e);for(r of t.values())o.add(r);return o}}}return t}return e}return n==="undefined"?i:t}function At(t,i){return typeof t>"u"?i:t}function L(){return Object.create(null)}function X(t){return typeof t=="string"}function Bt(t){return typeof t=="object"}function Nt(t,i){if(X(i))t=t[i];else for(let e=0;t&&e<i.length;e++)t=t[i[e]];return t}const mi=/[^\p{L}\p{N}]+/u,yi=/(\d{3})/g,wi=/(\D)(\d{3})/g,vi=/(\d{3})(\D)/g,Ie=/[\u0300-\u036f]/g;function Dt(t={}){if(!this||this.constructor!==Dt)return new Dt(...arguments);if(arguments.length)for(t=0;t<arguments.length;t++)this.assign(arguments[t]);else this.assign(t)}A=Dt.prototype;A.assign=function(t){this.normalize=W(t.normalize,!0,this.normalize);let i=t.include,e=i||t.exclude||t.split,s;if(e||e===""){if(typeof e=="object"&&e.constructor!==RegExp){let n="";s=!i,i||(n+="\\p{Z}"),e.letter&&(n+="\\p{L}"),e.number&&(n+="\\p{N}",s=!!i),e.symbol&&(n+="\\p{S}"),e.punctuation&&(n+="\\p{P}"),e.control&&(n+="\\p{C}"),(e=e.char)&&(n+=typeof e=="object"?e.join(""):e);try{this.split=new RegExp("["+(i?"^":"")+n+"]+","u")}catch{this.split=/\s+/}}else this.split=e,s=e===!1||"a1a".split(e).length<2;this.numeric=W(t.numeric,s)}else{try{this.split=W(this.split,mi)}catch{this.split=/\s+/}this.numeric=W(t.numeric,W(this.numeric,!0))}if(this.prepare=W(t.prepare,null,this.prepare),this.finalize=W(t.finalize,null,this.finalize),e=t.filter,this.filter=typeof e=="function"?e:W(e&&new Set(e),null,this.filter),this.dedupe=W(t.dedupe,!0,this.dedupe),this.matcher=W((e=t.matcher)&&new Map(e),null,this.matcher),this.mapper=W((e=t.mapper)&&new Map(e),null,this.mapper),this.stemmer=W((e=t.stemmer)&&new Map(e),null,this.stemmer),this.replacer=W(t.replacer,null,this.replacer),this.minlength=W(t.minlength,1,this.minlength),this.maxlength=W(t.maxlength,1024,this.maxlength),this.rtl=W(t.rtl,!1,this.rtl),(this.cache=e=W(t.cache,!0,this.cache))&&(this.F=null,this.L=typeof e=="number"?e:2e5,this.B=new Map,this.D=new Map,this.I=this.H=128),this.h="",this.J=null,this.A="",this.K=null,this.matcher)for(const n of this.matcher.keys())this.h+=(this.h?"|":"")+n;if(this.stemmer)for(const n of this.stemmer.keys())this.A+=(this.A?"|":"")+n;return this};A.addStemmer=function(t,i){return this.stemmer||(this.stemmer=new Map),this.stemmer.set(t,i),this.A+=(this.A?"|":"")+t,this.K=null,this.cache&&wt(this),this};A.addFilter=function(t){return typeof t=="function"?this.filter=t:(this.filter||(this.filter=new Set),this.filter.add(t)),this.cache&&wt(this),this};A.addMapper=function(t,i){return typeof t=="object"?this.addReplacer(t,i):t.length>1?this.addMatcher(t,i):(this.mapper||(this.mapper=new Map),this.mapper.set(t,i),this.cache&&wt(this),this)};A.addMatcher=function(t,i){return typeof t=="object"?this.addReplacer(t,i):t.length<2&&(this.dedupe||this.mapper)?this.addMapper(t,i):(this.matcher||(this.matcher=new Map),this.matcher.set(t,i),this.h+=(this.h?"|":"")+t,this.J=null,this.cache&&wt(this),this)};A.addReplacer=function(t,i){return typeof t=="string"?this.addMatcher(t,i):(this.replacer||(this.replacer=[]),this.replacer.push(t,i),this.cache&&wt(this),this)};A.encode=function(t,i){if(this.cache&&t.length<=this.H)if(this.F){if(this.B.has(t))return this.B.get(t)}else this.F=setTimeout(wt,50,this);this.normalize&&(typeof this.normalize=="function"?t=this.normalize(t):t=Ie?t.normalize("NFKD").replace(Ie,"").toLowerCase():t.toLowerCase()),this.prepare&&(t=this.prepare(t)),this.numeric&&t.length>3&&(t=t.replace(wi,"$1 $2").replace(vi,"$1 $2").replace(yi,"$1 "));const e=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let s=[],n=L(),r,o,l=this.split||this.split===""?t.split(this.split):[t];for(let c=0,u,d;c<l.length;c++)if((u=d=l[c])&&!(u.length<this.minlength||u.length>this.maxlength)){if(i){if(n[u])continue;n[u]=1}else{if(r===u)continue;r=u}if(e)s.push(u);else if(!this.filter||(typeof this.filter=="function"?this.filter(u):!this.filter.has(u))){if(this.cache&&u.length<=this.I)if(this.F){var h=this.D.get(u);if(h||h===""){h&&s.push(h);continue}}else this.F=setTimeout(wt,50,this);if(this.stemmer){this.K||(this.K=new RegExp("(?!^)("+this.A+")$"));let w;for(;w!==u&&u.length>2;)w=u,u=u.replace(this.K,g=>this.stemmer.get(g))}if(u&&(this.mapper||this.dedupe&&u.length>1)){h="";for(let w=0,g="",m,f;w<u.length;w++)m=u.charAt(w),m===g&&this.dedupe||((f=this.mapper&&this.mapper.get(m))||f===""?f===g&&this.dedupe||!(g=f)||(h+=f):h+=g=m);u=h}if(this.matcher&&u.length>1&&(this.J||(this.J=new RegExp("("+this.h+")","g")),u=u.replace(this.J,w=>this.matcher.get(w))),u&&this.replacer)for(h=0;u&&h<this.replacer.length;h+=2)u=u.replace(this.replacer[h],this.replacer[h+1]);if(this.cache&&d.length<=this.I&&(this.D.set(d,u),this.D.size>this.L&&(this.D.clear(),this.I=this.I/1.1|0)),u){if(u!==d)if(i){if(n[u])continue;n[u]=1}else{if(o===u)continue;o=u}s.push(u)}}}return this.finalize&&(s=this.finalize(s)||s),this.cache&&t.length<=this.H&&(this.B.set(t,s),this.B.size>this.L&&(this.B.clear(),this.H=this.H/1.1|0)),s};function wt(t){t.F=null,t.B.clear(),t.D.clear()}function pe(t,i,e){e||(i||typeof t!="object"?typeof i=="object"&&(e=i,i=0):e=t),e&&(t=e.query||t,i=e.limit||i);let s=""+(i||0);e&&(s+=(e.offset||0)+!!e.context+!!e.suggest+(e.resolve!==!1)+(e.resolution||this.resolution)+(e.boost||0)),t=(""+t).toLowerCase(),this.cache||(this.cache=new xt);let n=this.cache.get(t+s);if(!n){const r=e&&e.cache;r&&(e.cache=!1),n=this.search(t,i,e),r&&(e.cache=r),this.cache.set(t+s,n)}return n}function xt(t){this.limit=t&&t!==!0?t:1e3,this.cache=new Map,this.h=""}xt.prototype.set=function(t,i){this.cache.set(this.h=t,i),this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};xt.prototype.get=function(t){const i=this.cache.get(t);return i&&this.h!==t&&(this.cache.delete(t),this.cache.set(this.h=t,i)),i};xt.prototype.remove=function(t){for(const i of this.cache){const e=i[0];i[1].includes(t)&&this.cache.delete(e)}};xt.prototype.clear=function(){this.cache.clear(),this.h=""};const $e={normalize:!1,numeric:!1,dedupe:!1},Ht={},he=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]),Ce=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Pe=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"],De={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,ß:2,d:3,t:3,l:4,m:5,n:5,r:6};var me={Exact:$e,Default:Ht,Normalize:Ht,LatinBalance:{mapper:he},LatinAdvanced:{mapper:he,matcher:Ce,replacer:Pe},LatinExtra:{mapper:he,replacer:Pe.concat([/(?!^)[aeo]/g,""]),matcher:Ce},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(t){for(let e=0;e<t.length;e++){var i=t[e];let s=i.charAt(0),n=De[s];for(let r=1,o;r<i.length&&(o=i.charAt(r),o==="h"||o==="w"||!(o=De[o])||o===n||(s+=o,n=o,s.length!==4));r++);t[e]=s}}},CJK:{split:""},LatinExact:$e,LatinDefault:Ht,LatinSimple:Ht};function je(t,i,e,s){let n=[];for(let r=0,o;r<t.index.length;r++)if(o=t.index[r],i>=o.length)i-=o.length;else{i=o[s?"splice":"slice"](i,e);const l=i.length;if(l&&(n=n.length?n.concat(i):i,e-=l,s&&(t.length-=l),!e))break;i=0}return n}function jt(t){if(!this||this.constructor!==jt)return new jt(t);this.index=t?[t]:[],this.length=t?t.length:0;const i=this;return new Proxy([],{get(e,s){if(s==="length")return i.length;if(s==="push")return function(n){i.index[i.index.length-1].push(n),i.length++};if(s==="pop")return function(){if(i.length)return i.length--,i.index[i.index.length-1].pop()};if(s==="indexOf")return function(n){let r=0;for(let o=0,l,h;o<i.index.length;o++){if(l=i.index[o],h=l.indexOf(n),h>=0)return r+h;r+=l.length}return-1};if(s==="includes")return function(n){for(let r=0;r<i.index.length;r++)if(i.index[r].includes(n))return!0;return!1};if(s==="slice")return function(n,r){return je(i,n||0,r||i.length,!1)};if(s==="splice")return function(n,r){return je(i,n||0,r||i.length,!0)};if(s==="constructor")return Array;if(typeof s!="symbol")return(e=i.index[s/2**31|0])&&e[s]},set(e,s,n){return e=s/2**31|0,(i.index[e]||(i.index[e]=[]))[s]=n,i.length++,!0}})}jt.prototype.clear=function(){this.index.length=0};jt.prototype.push=function(){};function tt(t=8){if(!this||this.constructor!==tt)return new tt(t);this.index=L(),this.h=[],this.size=0,t>32?(this.B=We,this.A=BigInt(t)):(this.B=Ke,this.A=t)}tt.prototype.get=function(t){const i=this.index[this.B(t)];return i&&i.get(t)};tt.prototype.set=function(t,i){var e=this.B(t);let s=this.index[e];s?(e=s.size,s.set(t,i),(e-=s.size)&&this.size++):(this.index[e]=s=new Map([[t,i]]),this.h.push(s),this.size++)};function et(t=8){if(!this||this.constructor!==et)return new et(t);this.index=L(),this.h=[],this.size=0,t>32?(this.B=We,this.A=BigInt(t)):(this.B=Ke,this.A=t)}et.prototype.add=function(t){var i=this.B(t);let e=this.index[i];e?(i=e.size,e.add(t),(i-=e.size)&&this.size++):(this.index[i]=e=new Set([t]),this.h.push(e),this.size++)};A=tt.prototype;A.has=et.prototype.has=function(t){const i=this.index[this.B(t)];return i&&i.has(t)};A.delete=et.prototype.delete=function(t){const i=this.index[this.B(t)];i&&i.delete(t)&&this.size--};A.clear=et.prototype.clear=function(){this.index=L(),this.h=[],this.size=0};A.values=et.prototype.values=function*(){for(let t=0;t<this.h.length;t++)for(let i of this.h[t].values())yield i};A.keys=et.prototype.keys=function*(){for(let t=0;t<this.h.length;t++)for(let i of this.h[t].keys())yield i};A.entries=et.prototype.entries=function*(){for(let t=0;t<this.h.length;t++)for(let i of this.h[t].entries())yield i};function Ke(t){let i=2**this.A-1;if(typeof t=="number")return t&i;let e=0,s=this.A+1;for(let n=0;n<t.length;n++)e=(e*s^t.charCodeAt(n))&i;return this.A===32?e+2**31:e}function We(t){let i=BigInt(2)**this.A-BigInt(1);var e=typeof t;if(e==="bigint")return t&i;if(e==="number")return BigInt(t)&i;e=BigInt(0);let s=this.A+BigInt(1);for(let n=0;n<t.length;n++)e=(e*s^BigInt(t.charCodeAt(n)))&i;return e}let It,Ot;async function bi(t){t=t.data;var i=t.task;const e=t.id;let s=t.args;if(i==="init")Ot=t.options||{},(i=t.factory)?(Function("return "+i)()(self),It=new self.FlexSearch.Index(Ot),delete self.FlexSearch):It=new it(Ot),postMessage({id:e});else{let n;i==="export"&&(s[1]?(s[0]=Ot.export,s[2]=0,s[3]=1):s=null),i==="import"?s[0]&&(t=await Ot.import.call(It,s[0]),It.import(s[0],t)):((n=s&&It[i].apply(It,s))&&n.then&&(n=await n),n&&n.await&&(n=await n.await),i==="search"&&n.result&&(n=n.result)),postMessage(i==="search"?{id:e,msg:n}:{id:e})}}function ye(t){$t.call(t,"add"),$t.call(t,"append"),$t.call(t,"search"),$t.call(t,"update"),$t.call(t,"remove"),$t.call(t,"searchCache")}let ue,Te,Zt;function xi(){ue=Zt=0}function $t(t){this[t+"Async"]=function(){const i=arguments;var e=i[i.length-1];let s;if(typeof e=="function"&&(s=e,delete i[i.length-1]),ue?Zt||(Zt=Date.now()-Te>=this.priority*this.priority*3):(ue=setTimeout(xi,0),Te=Date.now()),Zt){const r=this;return new Promise(o=>{setTimeout(function(){o(r[t+"Async"].apply(r,i))},0)})}const n=this[t].apply(this,i);return e=n.then?n:new Promise(r=>r(n)),s&&e.then(s),e}}let dt=0;function vt(t={},i){function e(l){function h(c){c=c.data||c;const u=c.id,d=u&&r.h[u];d&&(d(c.msg),delete r.h[u])}if(this.worker=l,this.h=L(),this.worker)return n?this.worker.on("message",h):this.worker.onmessage=h,t.config?new Promise(function(c){dt>1e9&&(dt=0),r.h[++dt]=function(){c(r)},r.worker.postMessage({id:dt,task:"init",factory:s,options:t})}):(this.priority=t.priority||4,this.encoder=i||null,this.worker.postMessage({task:"init",factory:s,options:t}),this)}if(!this||this.constructor!==vt)return new vt(t);let s=typeof self<"u"?self._factory:typeof window<"u"?window._factory:null;s&&(s=s.toString());const n=typeof window>"u",r=this,o=ki(s,n,t.worker);return o.then?o.then(function(l){return e.call(r,l)}):e.call(this,o)}gt("add");gt("append");gt("search");gt("update");gt("remove");gt("clear");gt("export");gt("import");vt.prototype.searchCache=pe;ye(vt.prototype);function gt(t){vt.prototype[t]=function(){const i=this,e=[].slice.call(arguments);var s=e[e.length-1];let n;return typeof s=="function"&&(n=s,e.pop()),s=new Promise(function(r){t==="export"&&typeof e[0]=="function"&&(e[0]=null),dt>1e9&&(dt=0),i.h[++dt]=r,i.worker.postMessage({task:t,id:dt,args:e})}),n?(s.then(n),this):s}}function ki(t,i,e){return i?typeof module<"u"?new(require("worker_threads")).Worker(__dirname+"/worker/node.js"):ti(()=>import("./__vite-browser-external-D7Ct-6yo.js").then(s=>s._),[],import.meta.url).then(function(s){return new s.Worker(import.meta.dirname+"/node/node.mjs")}):t?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+bi.toString()],{type:"text/javascript"}))):new window.Worker(typeof e=="string"?e:import.meta.url.replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js","module/worker/worker.js").replace("flexsearch.bundle.module.min.mjs","module/worker/worker.js"),{type:"module"})}bt.prototype.add=function(t,i,e){if(Bt(t)&&(i=t,t=Nt(i,this.key)),i&&(t||t===0)){if(!e&&this.reg.has(t))return this.update(t,i);for(let l=0,h;l<this.field.length;l++){h=this.B[l];var s=this.index.get(this.field[l]);if(typeof h=="function"){var n=h(i);n&&s.add(t,n,e,!0)}else n=h.G,(!n||n(i))&&(h.constructor===String?h=[""+h]:X(h)&&(h=[h]),fe(i,h,this.D,0,s,t,h[0],e))}if(this.tag)for(s=0;s<this.A.length;s++){var r=this.A[s];n=this.tag.get(this.F[s]);let l=L();if(typeof r=="function"){if(r=r(i),!r)continue}else{var o=r.G;if(o&&!o(i))continue;r.constructor===String&&(r=""+r),r=Nt(i,r)}if(n&&r){X(r)&&(r=[r]);for(let h=0,c,u;h<r.length;h++)if(c=r[h],!l[c]&&(l[c]=1,(o=n.get(c))?u=o:n.set(c,u=[]),!e||!u.includes(t))){if(u.length===2**31-1){if(o=new jt(u),this.fastupdate)for(let d of this.reg.values())d.includes(u)&&(d[d.indexOf(u)]=o);n.set(c,u=o)}u.push(t),this.fastupdate&&((o=this.reg.get(t))?o.push(u):this.reg.set(t,[u]))}}}if(this.store&&(!e||!this.store.has(t))){let l;if(this.h){l=L();for(let h=0,c;h<this.h.length;h++){if(c=this.h[h],(e=c.G)&&!e(i))continue;let u;if(typeof c=="function"){if(u=c(i),!u)continue;c=[c.O]}else if(X(c)||c.constructor===String){l[c]=i[c];continue}ae(i,l,c,0,c[0],u)}}this.store.set(t,l||i)}this.worker&&(this.fastupdate||this.reg.add(t))}return this};function ae(t,i,e,s,n,r){if(t=t[n],s===e.length-1)i[n]=r||t;else if(t)if(t.constructor===Array)for(i=i[n]=Array(t.length),n=0;n<t.length;n++)ae(t,i,e,s,n);else i=i[n]||(i[n]=L()),n=e[++s],ae(t,i,e,s,n)}function fe(t,i,e,s,n,r,o,l){if(t=t[o])if(s===i.length-1){if(t.constructor===Array){if(e[s]){for(i=0;i<t.length;i++)n.add(r,t[i],!0,!0);return}t=t.join(" ")}n.add(r,t,l,!0)}else if(t.constructor===Array)for(o=0;o<t.length;o++)fe(t,i,e,s,n,r,o,l);else o=i[++s],fe(t,i,e,s,n,r,o,l)}function we(t,i,e,s){if(!t.length)return t;if(t.length===1)return t=t[0],t=e||t.length>i?t.slice(e,e+i):t,s?Pt.call(this,t):t;let n=[];for(let r=0,o,l;r<t.length;r++)if((o=t[r])&&(l=o.length)){if(e){if(e>=l){e-=l;continue}o=o.slice(e,e+i),l=o.length,e=0}if(l>i&&(o=o.slice(0,i),l=i),!n.length&&l>=i)return s?Pt.call(this,o):o;if(n.push(o),i-=l,!i)break}return n=n.length>1?[].concat.apply([],n):n[0],s?Pt.call(this,n):n}function se(t,i,e,s){var n=s[0];if(n[0]&&n[0].query)return t[i].apply(t,n);if(!(i!=="and"&&i!=="not"||t.result.length||t.await||n.suggest))return s.length>1&&(n=s[s.length-1]),(s=n.resolve)?t.await||t.result:t;let r=[],o=0,l=0,h,c,u,d,w;for(i=0;i<s.length;i++)if(n=s[i]){var g=void 0;if(n.constructor===B)g=n.await||n.result;else if(n.then||n.constructor===Array)g=n;else{o=n.limit||0,l=n.offset||0,u=n.suggest,c=n.resolve,h=((d=n.highlight||t.highlight)||n.enrich)&&c,g=n.queue;let m=n.async||g,f=n.index,p=n.query;if(f?t.index||(t.index=f):f=t.index,p||n.tag){const x=n.field||n.pluck;if(x&&(!p||t.query&&!d||(t.query=p,t.field=x,t.highlight=d),f=f.index.get(x)),g&&(w||t.await)){w=1;let v;const S=t.C.length,I=new Promise(function(D){v=D});(function(D,C){I.h=function(){C.index=null,C.resolve=!1;let $=m?D.searchAsync(C):D.search(C);return $.then?$.then(function(k){return t.C[S]=k=k.result||k,v(k),k}):($=$.result||$,v($),$)}})(f,Object.assign({},n)),t.C.push(I),r[i]=I;continue}else n.resolve=!1,n.index=null,g=m?f.searchAsync(n):f.search(n),n.resolve=c,n.index=f}else if(n.and)g=Ut(n,"and",f);else if(n.or)g=Ut(n,"or",f);else if(n.not)g=Ut(n,"not",f);else if(n.xor)g=Ut(n,"xor",f);else continue}g.await?(w=1,g=g.await):g.then?(w=1,g=g.then(function(m){return m.result||m})):g=g.result||g,r[i]=g}if(w&&!t.await&&(t.await=new Promise(function(m){t.return=m})),w){const m=Promise.all(r).then(function(f){for(let p=0;p<t.C.length;p++)if(t.C[p]===m){t.C[p]=function(){return e.call(t,f,o,l,h,c,u,d)};break}ve(t)});t.C.push(m)}else if(t.await)t.C.push(function(){return e.call(t,r,o,l,h,c,u,d)});else return e.call(t,r,o,l,h,c,u,d);return c?t.await||t.result:t}function Ut(t,i,e){t=t[i];const s=t[0]||t;return s.index||(s.index=e),e=new B(s),t.length>1&&(e=e[i].apply(e,t.slice(1))),e}B.prototype.or=function(){return se(this,"or",Si,arguments)};function Si(t,i,e,s,n,r,o){return t.length&&(this.result.length&&t.push(this.result),t.length<2?this.result=t[0]:(this.result=He(t,i,e,!1,this.h),e=0)),n&&(this.await=null),n?this.resolve(i,e,s,o):this}B.prototype.and=function(){return se(this,"and",Mi,arguments)};function Mi(t,i,e,s,n,r,o){if(!r&&!this.result.length)return n?this.result:this;let l;if(t.length)if(this.result.length&&t.unshift(this.result),t.length<2)this.result=t[0];else{let h=0;for(let c=0,u,d;c<t.length;c++)if((u=t[c])&&(d=u.length))h<d&&(h=d);else if(!r){h=0;break}h?(this.result=Xt(t,h,i,e,r,this.h,n),l=!0):this.result=[]}else r||(this.result=t);return n&&(this.await=null),n?this.resolve(i,e,s,o,l):this}B.prototype.xor=function(){return se(this,"xor",Ai,arguments)};function Ai(t,i,e,s,n,r,o){if(t.length)if(this.result.length&&t.unshift(this.result),t.length<2)this.result=t[0];else{t:{r=e;var l=this.h;const h=[],c=L();let u=0;for(let d=0,w;d<t.length;d++)if(w=t[d]){u<w.length&&(u=w.length);for(let g=0,m;g<w.length;g++)if(m=w[g])for(let f=0,p;f<m.length;f++)p=m[f],c[p]=c[p]?2:1}for(let d=0,w,g=0;d<u;d++)for(let m=0,f;m<t.length;m++)if((f=t[m])&&(w=f[d])){for(let p=0,x;p<w.length;p++)if(x=w[p],c[x]===1)if(r)r--;else if(n){if(h.push(x),h.length===i){t=h;break t}}else{const v=d+(m?l:0);if(h[v]||(h[v]=[]),h[v].push(x),++g===i){t=h;break t}}}t=h}this.result=t,l=!0}else r||(this.result=t);return n&&(this.await=null),n?this.resolve(i,e,s,o,l):this}B.prototype.not=function(){return se(this,"not",Ii,arguments)};function Ii(t,i,e,s,n,r,o){if(!r&&!this.result.length)return n?this.result:this;if(t.length&&this.result.length){t:{r=e;var l=[];t=new Set(t.flat().flat());for(let h=0,c,u=0;h<this.result.length;h++)if(c=this.result[h]){for(let d=0,w;d<c.length;d++)if(w=c[d],!t.has(w)){if(r)r--;else if(n){if(l.push(w),l.length===i){t=l;break t}}else if(l[h]||(l[h]=[]),l[h].push(w),++u===i){t=l;break t}}}t=l}this.result=t,l=!0}return n&&(this.await=null),n?this.resolve(i,e,s,o,l):this}function qt(t,i,e,s,n){let r,o,l;typeof n=="string"?(r=n,n=""):r=n.template,o=r.indexOf("$1"),l=r.substring(o+2),o=r.substring(0,o);let h=n&&n.boundary,c=!n||n.clip!==!1,u=n&&n.merge&&l&&o&&new RegExp(l+" "+o,"g");n=n&&n.ellipsis;var d=0;if(typeof n=="object"){var w=n.template;d=w.length-2,n=n.pattern}typeof n!="string"&&(n=n===!1?"":"..."),d&&(n=w.replace("$1",n)),w=n.length-d;let g,m;typeof h=="object"&&(g=h.before,g===0&&(g=-1),m=h.after,m===0&&(m=-1),h=h.total||9e5),d=new Map;for(let Tt=0,nt,Lt,ct;Tt<i.length;Tt++){let ut;if(s)ut=i,ct=s;else{var f=i[Tt];if(ct=f.field,!ct)continue;ut=f.result}Lt=e.get(ct),nt=Lt.encoder,f=d.get(nt),typeof f!="string"&&(f=nt.encode(t),d.set(nt,f));for(let q=0;q<ut.length;q++){var p=ut[q].doc;if(!p||(p=Nt(p,ct),!p))continue;var x=p.trim().split(/\s+/);if(!x.length)continue;p="";var v=[];let at=[];for(var S=-1,I=-1,D=0,C=0;C<x.length;C++){var $=x[C],k=nt.encode($);k=k.length>1?k.join(" "):k[0];let P;if(k&&$){for(var T=$.length,R=(nt.split?$.replace(nt.split,""):$).length-k.length,_="",N=0,K=0;K<f.length;K++){var H=f[K];if(H){var F=H.length;F+=R<0?0:R,N&&F<=N||(H=k.indexOf(H),H>-1&&(_=(H?$.substring(0,H):"")+o+$.substring(H,H+F)+l+(H+F<T?$.substring(H+F):""),N=F,P=!0))}}_&&(h&&(S<0&&(S=p.length+(p?1:0)),I=p.length+(p?1:0)+_.length,D+=T,at.push(v.length),v.push({match:_})),p+=(p?" ":"")+_)}if(!P)$=x[C],p+=(p?" ":"")+$,h&&v.push({text:$});else if(h&&D>=h)break}if(D=at.length*(r.length-2),g||m||h&&p.length-D>h)if(D=h+D-w*2,C=I-S,g>0&&(C+=g),m>0&&(C+=m),C<=D)x=g?S-(g>0?g:0):S-((D-C)/2|0),v=m?I+(m>0?m:0):x+D,c||(x>0&&p.charAt(x)!==" "&&p.charAt(x-1)!==" "&&(x=p.indexOf(" ",x),x<0&&(x=0)),v<p.length&&p.charAt(v-1)!==" "&&p.charAt(v)!==" "&&(v=p.lastIndexOf(" ",v),v<I?v=I:++v)),p=(x?n:"")+p.substring(x,v)+(v<p.length?n:"");else{for(I=[],S={},D={},C={},$={},k={},_=R=T=0,K=N=1;;){var Z=void 0;for(let P=0,Y;P<at.length;P++){if(Y=at[P],_)if(R!==_){if(C[P+1])continue;if(Y+=_,S[Y]){T-=w,D[P+1]=1,C[P+1]=1;continue}if(Y>=v.length-1){if(Y>=v.length){C[P+1]=1,Y>=x.length&&(D[P+1]=1);continue}T-=w}if(p=v[Y].text,F=m&&k[P])if(F>0){if(p.length>F)if(C[P+1]=1,c)p=p.substring(0,F);else continue;(F-=p.length)||(F=-1),k[P]=F}else{C[P+1]=1;continue}if(T+p.length+1<=h)p=" "+p,I[P]+=p;else if(c)Z=h-T-1,Z>0&&(p=" "+p.substring(0,Z),I[P]+=p),C[P+1]=1;else{C[P+1]=1;continue}}else{if(C[P])continue;if(Y-=R,S[Y]){T-=w,C[P]=1,D[P]=1;continue}if(Y<=0){if(Y<0){C[P]=1,D[P]=1;continue}T-=w}if(p=v[Y].text,F=g&&$[P])if(F>0){if(p.length>F)if(C[P]=1,c)p=p.substring(p.length-F);else continue;(F-=p.length)||(F=-1),$[P]=F}else{C[P]=1;continue}if(T+p.length+1<=h)p+=" ",I[P]=p+I[P];else if(c)Z=p.length+1-(h-T),Z>=0&&Z<p.length&&(p=p.substring(Z)+" ",I[P]=p+I[P]),C[P]=1;else{C[P]=1;continue}}else{p=v[Y].match,g&&($[P]=g),m&&(k[P]=m),P&&T++;let kt;if(Y?!P&&w&&(T+=w):(D[P]=1,C[P]=1),Y>=x.length-1||Y<v.length-1&&v[Y+1].match?kt=1:w&&(T+=w),T-=r.length-2,!P||T+p.length<=h)I[P]=p;else{Z=N=K=D[P]=0;break}kt&&(D[P+1]=1,C[P+1]=1)}T+=p.length,Z=S[Y]=1}if(Z)R===_?_++:R++;else{if(R===_?N=0:K=0,!N&&!K)break;N?(R++,_=R):_++}}p="";for(let P=0,Y;P<I.length;P++)Y=(D[P]?P?" ":"":(P&&!n?" ":"")+n)+I[P],p+=Y;n&&!D[I.length]&&(p+=n)}u&&(p=p.replace(u," ")),ut[q].highlight=p}if(s)break}return i}function B(t,i){if(!this||this.constructor!==B)return new B(t,i);let e=0,s,n,r,o,l,h;if(t&&t.index){const c=t;if(i=c.index,e=c.boost||0,n=c.query){r=c.field||c.pluck,o=c.highlight;const u=c.resolve;t=c.async||c.queue,c.resolve=!1,c.index=null,t=t?i.searchAsync(c):i.search(c),c.resolve=u,c.index=i,t=t.result||t}else t=[]}if(t&&t.then){const c=this;t=t.then(function(u){c.C[0]=c.result=u.result||u,ve(c)}),s=[t],t=[],l=new Promise(function(u){h=u})}this.index=i||null,this.result=t||[],this.h=e,this.C=s||[],this.await=l||null,this.return=h||null,this.highlight=o||null,this.query=n||"",this.field=r||""}A=B.prototype;A.limit=function(t){if(this.await){const i=this;this.C.push(function(){return i.limit(t).result})}else if(this.result.length){const i=[];for(let e=0,s;e<this.result.length;e++)if(s=this.result[e])if(s.length<=t){if(i[e]=s,t-=s.length,!t)break}else{i[e]=s.slice(0,t);break}this.result=i}return this};A.offset=function(t){if(this.await){const i=this;this.C.push(function(){return i.offset(t).result})}else if(this.result.length){const i=[];for(let e=0,s;e<this.result.length;e++)(s=this.result[e])&&(s.length<=t?t-=s.length:(i[e]=s.slice(t),t=0));this.result=i}return this};A.boost=function(t){if(this.await){const i=this;this.C.push(function(){return i.boost(t).result})}else this.h+=t;return this};function ve(t,i){let e=t.result;var s=t.await;t.await=null;for(let n=0,r;n<t.C.length;n++)if(r=t.C[n]){if(typeof r=="function")e=r(),t.C[n]=e=e.result||e,n--;else if(r.h)e=r.h(),t.C[n]=e=e.result||e,n--;else if(r.then)return t.await=s}return s=t.return,t.C=[],t.return=null,i||s(e),e}A.resolve=function(t,i,e,s,n){let r=this.await?ve(this,!0):this.result;if(r.then){const o=this;return r.then(function(){return o.resolve(t,i,e,s,n)})}return r.length&&(typeof t=="object"?(s=t.highlight||this.highlight,e=!!s||t.enrich,i=t.offset,t=t.limit):(s=s||this.highlight,e=!!s||e),r=n?e?Pt.call(this.index,r):r:we.call(this.index,r,t||100,i,e)),this.finalize(r,s)};A.finalize=function(t,i){if(t.then){const s=this;return t.then(function(n){return s.finalize(n,i)})}i&&t.length&&this.query&&(t=qt(this.query,t,this.index.index,this.field,i));const e=this.return;return this.highlight=this.index=this.result=this.C=this.await=this.return=null,this.query=this.field="",e&&e(t),t};function Xt(t,i,e,s,n,r,o){const l=t.length;let h=[],c,u;c=L();for(let d=0,w,g,m,f;d<i;d++)for(let p=0;p<l;p++)if(m=t[p],d<m.length&&(w=m[d]))for(let x=0;x<w.length;x++){if(g=w[x],(u=c[g])?c[g]++:(u=0,c[g]=1),f=h[u]||(h[u]=[]),!o){let v=d+(p||!n?0:r||0);f=f[v]||(f[v]=[])}if(f.push(g),o&&e&&u===l-1&&f.length-s===e)return s?f.slice(s):f}if(t=h.length)if(n)h=h.length>1?He(h,e,s,o,r):(h=h[0])&&e&&h.length>e||s?h.slice(s,e+s):h;else{if(t<l)return[];if(h=h[t-1],e||s)if(o)(h.length>e||s)&&(h=h.slice(s,e+s));else{n=[];for(let d=0,w;d<h.length;d++)if(w=h[d]){if(s&&w.length>s)s-=w.length;else if((e&&w.length>e||s)&&(w=w.slice(s,e+s),e-=w.length,s&&(s-=w.length)),n.push(w),!e)break}h=n}}return h}function He(t,i,e,s,n){const r=[],o=L();let l;var h=t.length;let c;if(s){for(n=h-1;n>=0;n--)if(c=(s=t[n])&&s.length){for(h=0;h<c;h++)if(l=s[h],!o[l]){if(o[l]=1,e)e--;else if(r.push(l),r.length===i)return r}}}else for(let u=h-1,d,w=0;u>=0;u--){d=t[u];for(let g=0;g<d.length;g++)if(c=(s=d[g])&&s.length){for(let m=0;m<c;m++)if(l=s[m],!o[l])if(o[l]=1,e)e--;else{let f=(g+(u<h-1&&n||0))/(u+1)|0;if((r[f]||(r[f]=[])).push(l),++w===i)return r}}}return r}function $i(t,i,e,s,n){const r=L(),o=[];for(let l=0,h;l<i.length;l++){h=i[l];for(let c=0;c<h.length;c++)r[h[c]]=1}if(n){for(let l=0,h;l<t.length;l++)if(h=t[l],r[h]){if(s)s--;else if(o.push(h),r[h]=0,e&&--e===0)break}}else for(let l=0,h,c;l<t.result.length;l++)for(h=t.result[l],i=0;i<h.length;i++)c=h[i],r[c]&&((o[l]||(o[l]=[])).push(c),r[c]=0);return o}L();bt.prototype.search=function(t,i,e,s){e||(!i&&Bt(t)?(e=t,t=""):Bt(i)&&(e=i,i=0));let n=[];var r=[];let o,l,h,c,u,d,w=0,g=!0,m;if(e){e.constructor===Array&&(e={index:e}),t=e.query||t,o=e.pluck,l=e.merge,c=e.boost,d=o||e.field||(d=e.index)&&(d.index?null:d);var f=this.tag&&e.tag;h=e.suggest,g=e.resolve!==!1,u=e.cache,m=g&&this.store&&e.highlight;var p=!!m||g&&this.store&&e.enrich;i=e.limit||i;var x=e.offset||0;if(i||(i=g?100:0),f&&(!this.db||!s)){f.constructor!==Array&&(f=[f]);var v=[];for(let $=0,k;$<f.length;$++)if(k=f[$],k.field&&k.tag){var S=k.tag;if(S.constructor===Array)for(var I=0;I<S.length;I++)v.push(k.field,S[I]);else v.push(k.field,S)}else{S=Object.keys(k);for(let T=0,R,_;T<S.length;T++)if(R=S[T],_=k[R],_.constructor===Array)for(I=0;I<_.length;I++)v.push(R,_[I]);else v.push(R,_)}if(f=v,!t){if(r=[],v.length)for(f=0;f<v.length;f+=2){if(this.db){if(s=this.index.get(v[f]),!s)continue;r.push(s=s.db.tag(v[f+1],i,x,p))}else s=Ci.call(this,v[f],v[f+1],i,x,p);n.push(g?{field:v[f],tag:v[f+1],result:s}:[s])}if(r.length){const $=this;return Promise.all(r).then(function(k){for(let T=0;T<k.length;T++)g?n[T].result=k[T]:n[T]=k[T];return g?n:new B(n.length>1?Xt(n,1,0,0,h,c):n[0],$)})}return g?n:new B(n.length>1?Xt(n,1,0,0,h,c):n[0],this)}}g||o||!(d=d||this.field)||(X(d)?o=d:(d.constructor===Array&&d.length===1&&(d=d[0]),o=d.field||d.index)),d&&d.constructor!==Array&&(d=[d])}d||(d=this.field);let D;v=(this.worker||this.db)&&!s&&[];for(let $=0,k,T,R;$<d.length;$++){if(T=d[$],this.db&&this.tag&&!this.B[$])continue;let _;if(X(T)||(_=T,T=_.field,t=_.query||t,i=At(_.limit,i),x=At(_.offset,x),h=At(_.suggest,h),m=g&&this.store&&At(_.highlight,m),p=!!m||g&&this.store&&At(_.enrich,p),u=At(_.cache,u)),s)k=s[$];else{S=_||e||{},I=S.enrich;var C=this.index.get(T);if(f&&(this.db&&(S.tag=f,S.field=d,D=C.db.support_tag_search),!D&&I&&(S.enrich=!1),D||(S.limit=0,S.offset=0)),k=u?C.searchCache(t,f&&!D?0:i,S):C.search(t,f&&!D?0:i,S),f&&!D&&(S.limit=i,S.offset=x),I&&(S.enrich=I),v){v[$]=k;continue}}if(R=(k=k.result||k)&&k.length,f&&R){if(S=[],I=0,this.db&&s){if(!D)for(C=d.length;C<s.length;C++){let N=s[C];if(N&&N.length)I++,S.push(N);else if(!h)return g?n:new B(n,this)}}else for(let N=0,K,H;N<f.length;N+=2){if(K=this.tag.get(f[N]),!K){if(h)continue;return g?n:new B(n,this)}if(H=(K=K&&K.get(f[N+1]))&&K.length)I++,S.push(K);else if(!h)return g?n:new B(n,this)}if(I){if(k=$i(k,S,i,x,g),R=k.length,!R&&!h)return g?k:new B(k,this);I--}}if(R)r[w]=T,n.push(k),w++;else if(d.length===1)return g?n:new B(n,this)}if(v){if(this.db&&f&&f.length&&!D)for(p=0;p<f.length;p+=2){if(r=this.index.get(f[p]),!r){if(h)continue;return g?n:new B(n,this)}v.push(r.db.tag(f[p+1],i,x,!1))}const $=this;return Promise.all(v).then(function(k){return e&&(e.resolve=g),k.length&&(k=$.search(t,i,e,k)),k})}if(!w)return g?n:new B(n,this);if(o&&(!p||!this.store))return n=n[0],g?n:new B(n,this);for(v=[],x=0;x<r.length;x++){if(f=n[x],p&&f.length&&typeof f[0].doc>"u"&&(this.db?v.push(f=this.index.get(this.field[0]).db.enrich(f)):f=Pt.call(this,f)),o)return g?m?qt(t,f,this.index,o,m):f:new B(f,this);n[x]={field:r[x],result:f}}if(p&&this.db&&v.length){const $=this;return Promise.all(v).then(function(k){for(let T=0;T<k.length;T++)n[T].result=k[T];return m&&(n=qt(t,n,$.index,o,m)),l?_e(n):n})}return m&&(n=qt(t,n,this.index,o,m)),l?_e(n):n};function _e(t){const i=[],e=L(),s=L();for(let n=0,r,o,l,h,c,u,d;n<t.length;n++){r=t[n],o=r.field,l=r.result;for(let w=0;w<l.length;w++)c=l[w],typeof c!="object"?c={id:h=c}:h=c.id,(u=e[h])?u.push(o):(c.field=e[h]=[o],i.push(c)),(d=c.highlight)&&(u=s[h],u||(s[h]=u={},c.highlight=u),u[o]=d)}return i}function Ci(t,i,e,s,n){return t=this.tag.get(t),t?(t=t.get(i),t?(i=t.length-s,i>0&&((e&&i>e||s)&&(t=t.slice(s,s+e)),n&&(t=Pt.call(this,t))),t):[]):[]}function Pt(t){if(!this||!this.store)return t;if(this.db)return this.index.get(this.field[0]).db.enrich(t);const i=Array(t.length);for(let e=0,s;e<t.length;e++)s=t[e],i[e]={id:s,doc:this.store.get(s)};return i}function bt(t){if(!this||this.constructor!==bt)return new bt(t);const i=t.document||t.doc||t;let e,s;if(this.B=[],this.field=[],this.D=[],this.key=(e=i.key||i.id)&&te(e,this.D)||"id",(s=t.keystore||0)&&(this.keystore=s),this.fastupdate=!!t.fastupdate,this.reg=!this.fastupdate||t.worker||t.db?s?new et(s):new Set:s?new tt(s):new Map,this.h=(e=i.store||null)&&e&&e!==!0&&[],this.store=e?s?new tt(s):new Map:null,this.cache=(e=t.cache||null)&&new xt(e),t.cache=!1,this.worker=t.worker||!1,this.priority=t.priority||4,this.index=Pi.call(this,t,i),this.tag=null,(e=i.tag)&&(typeof e=="string"&&(e=[e]),e.length)){this.tag=new Map,this.A=[],this.F=[];for(let n=0,r,o;n<e.length;n++){if(r=e[n],o=r.field||r,!o)throw Error("The tag field from the document descriptor is undefined.");r.custom?this.A[n]=r.custom:(this.A[n]=te(o,this.D),r.filter&&(typeof this.A[n]=="string"&&(this.A[n]=new String(this.A[n])),this.A[n].G=r.filter)),this.F[n]=o,this.tag.set(o,new Map)}}if(this.worker){this.fastupdate=!1,t=[];for(const n of this.index.values())n.then&&t.push(n);if(t.length){const n=this;return Promise.all(t).then(function(r){let o=0;for(const l of n.index.entries()){const h=l[0];let c=l[1];c.then&&(c=r[o],n.index.set(h,c),o++)}return n})}}else t.db&&(this.fastupdate=!1,this.mount(t.db))}A=bt.prototype;A.mount=function(t){let i=this.field;if(this.tag)for(let r=0,o;r<this.F.length;r++){o=this.F[r];var e=void 0;this.index.set(o,e=new it({},this.reg)),i===this.field&&(i=i.slice(0)),i.push(o),e.tag=this.tag.get(o)}e=[];const s={db:t.db,type:t.type,fastupdate:t.fastupdate};for(let r=0,o,l;r<i.length;r++){s.field=l=i[r],o=this.index.get(l);const h=new t.constructor(t.id,s);h.id=t.id,e[r]=h.mount(o),o.document=!0,r?o.bypass=!0:o.store=this.store}const n=this;return this.db=Promise.all(e).then(function(){n.db=!0})};A.commit=async function(){const t=[];for(const i of this.index.values())t.push(i.commit());await Promise.all(t),this.reg.clear()};A.destroy=function(){const t=[];for(const i of this.index.values())t.push(i.destroy());return Promise.all(t)};function Pi(t,i){const e=new Map;let s=i.index||i.field||i;X(s)&&(s=[s]);for(let r=0,o,l;r<s.length;r++){if(o=s[r],X(o)||(l=o,o=o.field),l=Bt(l)?Object.assign({},t,l):t,this.worker){var n=void 0;n=(n=l.encoder)&&n.encode?n:new Dt(typeof n=="string"?me[n]:n||{}),n=new vt(l,n),e.set(o,n)}this.worker||e.set(o,new it(l,this.reg)),l.custom?this.B[r]=l.custom:(this.B[r]=te(o,this.D),l.filter&&(typeof this.B[r]=="string"&&(this.B[r]=new String(this.B[r])),this.B[r].G=l.filter)),this.field[r]=o}if(this.h){t=i.store,X(t)&&(t=[t]);for(let r=0,o,l;r<t.length;r++)o=t[r],l=o.field||o,o.custom?(this.h[r]=o.custom,o.custom.O=l):(this.h[r]=te(l,this.D),o.filter&&(typeof this.h[r]=="string"&&(this.h[r]=new String(this.h[r])),this.h[r].G=o.filter))}return e}function te(t,i){const e=t.split(":");let s=0;for(let n=0;n<e.length;n++)t=e[n],t[t.length-1]==="]"&&(t=t.substring(0,t.length-2))&&(i[s]=!0),t&&(e[s++]=t);return s<e.length&&(e.length=s),s>1?e:e[0]}A.append=function(t,i){return this.add(t,i,!0)};A.update=function(t,i){return this.remove(t).add(t,i)};A.remove=function(t){Bt(t)&&(t=Nt(t,this.key));for(var i of this.index.values())i.remove(t,!0);if(this.reg.has(t)){if(this.tag&&!this.fastupdate)for(let e of this.tag.values())for(let s of e){i=s[0];const n=s[1],r=n.indexOf(t);r>-1&&(n.length>1?n.splice(r,1):e.delete(i))}this.store&&this.store.delete(t),this.reg.delete(t)}return this.cache&&this.cache.remove(t),this};A.clear=function(){const t=[];for(const i of this.index.values()){const e=i.clear();e.then&&t.push(e)}if(this.tag)for(const i of this.tag.values())i.clear();return this.store&&this.store.clear(),this.cache&&this.cache.clear(),t.length?Promise.all(t):this};A.contain=function(t){return this.db?this.index.get(this.field[0]).db.has(t):this.reg.has(t)};A.cleanup=function(){for(const t of this.index.values())t.cleanup();return this};A.get=function(t){return this.db?this.index.get(this.field[0]).db.enrich(t).then(function(i){return i[0]&&i[0].doc||null}):this.store.get(t)||null};A.set=function(t,i){return typeof t=="object"&&(i=t,t=Nt(i,this.key)),this.store.set(t,i),this};A.searchCache=pe;A.export=Di;A.import=ji;ye(bt.prototype);function be(t,i=0){let e=[],s=[];i&&(i=25e4/i*5e3|0);for(const n of t.entries())s.push(n),s.length===i&&(e.push(s),s=[]);return s.length&&e.push(s),e}function xe(t,i){i||(i=new Map);for(let e=0,s;e<t.length;e++)s=t[e],i.set(s[0],s[1]);return i}function Ue(t,i=0){let e=[],s=[];i&&(i=25e4/i*1e3|0);for(const n of t.entries())s.push([n[0],be(n[1])[0]||[]]),s.length===i&&(e.push(s),s=[]);return s.length&&e.push(s),e}function Qe(t,i){i||(i=new Map);for(let e=0,s,n;e<t.length;e++)s=t[e],n=i.get(s[0]),i.set(s[0],xe(s[1],n));return i}function Ve(t){let i=[],e=[];for(const s of t.keys())e.push(s),e.length===25e4&&(i.push(e),e=[]);return e.length&&i.push(e),i}function Je(t,i){i||(i=new Set);for(let e=0;e<t.length;e++)i.add(t[e]);return i}function ee(t,i,e,s,n,r,o=0){const l=s&&s.constructor===Array;var h=l?s.shift():s;if(!h)return this.export(t,i,n,r+1);if((h=t((i?i+".":"")+(o+1)+"."+e,JSON.stringify(h)))&&h.then){const c=this;return h.then(function(){return ee.call(c,t,i,e,l?s:null,n,r,o+1)})}return ee.call(this,t,i,e,l?s:null,n,r,o+1)}function Di(t,i,e=0,s=0){if(e<this.field.length){const o=this.field[e];if((i=this.index.get(o).export(t,o,e,s=1))&&i.then){const l=this;return i.then(function(){return l.export(t,o,e+1)})}return this.export(t,o,e+1)}let n,r;switch(s){case 0:n="reg",r=Ve(this.reg),i=null;break;case 1:n="tag",r=this.tag&&Ue(this.tag,this.reg.size),i=null;break;case 2:n="doc",r=this.store&&be(this.store),i=null;break;default:return}return ee.call(this,t,i,n,r||null,e,s)}function ji(t,i){var e=t.split(".");e[e.length-1]==="json"&&e.pop();const s=e.length>2?e[0]:"";if(e=e.length>2?e[2]:e[1],this.worker&&s)return this.index.get(s).import(t);if(i){if(typeof i=="string"&&(i=JSON.parse(i)),s)return this.index.get(s).import(e,i);switch(e){case"reg":this.fastupdate=!1,this.reg=Je(i,this.reg);for(let n=0,r;n<this.field.length;n++)r=this.index.get(this.field[n]),r.fastupdate=!1,r.reg=this.reg;if(this.worker){i=[];for(const n of this.index.values())i.push(n.import(t));return Promise.all(i)}break;case"tag":this.tag=Qe(i,this.tag);break;case"doc":this.store=xe(i,this.store)}}}function Oe(t,i){let e="";for(const s of t.entries()){t=s[0];const n=s[1];let r="";for(let o=0,l;o<n.length;o++){l=n[o]||[""];let h="";for(let c=0;c<l.length;c++)h+=(h?",":"")+(i==="string"?'"'+l[c]+'"':l[c]);h="["+h+"]",r+=(r?",":"")+h}r='["'+t+'",['+r+"]]",e+=(e?",":"")+r}return e}it.prototype.remove=function(t,i){const e=this.reg.size&&(this.fastupdate?this.reg.get(t):this.reg.has(t));if(e){if(this.fastupdate){for(let s=0,n,r;s<e.length;s++)if((n=e[s])&&(r=n.length))if(n[r-1]===t)n.pop();else{const o=n.indexOf(t);o>=0&&n.splice(o,1)}}else Ft(this.map,t),this.depth&&Ft(this.ctx,t);i||this.reg.delete(t)}return this.db&&(this.commit_task.push({del:t}),this.M&&Ze(this)),this.cache&&this.cache.remove(t),this};function Ft(t,i){let e=0;var s=typeof i>"u";if(t.constructor===Array){for(let n=0,r,o,l;n<t.length;n++)if((r=t[n])&&r.length){if(s)return 1;if(o=r.indexOf(i),o>=0){if(r.length>1)return r.splice(o,1),1;if(delete t[n],e)return 1;l=1}else{if(l)return 1;e++}}}else for(let n of t.entries())s=n[0],Ft(n[1],i)?e++:t.delete(s);return e}const Ti={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};it.prototype.add=function(t,i,e,s){if(i&&(t||t===0)){if(!s&&!e&&this.reg.has(t))return this.update(t,i);s=this.depth,i=this.encoder.encode(i,!s);const c=i.length;if(c){const u=L(),d=L(),w=this.resolution;for(let g=0;g<c;g++){let m=i[this.rtl?c-1-g:g];var n=m.length;if(n&&(s||!d[m])){var r=this.score?this.score(i,m,g,null,0):Qt(w,c,g),o="";switch(this.tokenize){case"tolerant":if(ot(this,d,m,r,t,e),n>2){for(let f=1,p,x,v,S;f<n-1;f++)p=m.charAt(f),x=m.charAt(f+1),v=m.substring(0,f)+x,S=m.substring(f+2),o=v+p+S,ot(this,d,o,r,t,e),o=v+S,ot(this,d,o,r,t,e);ot(this,d,m.substring(0,m.length-1),r,t,e)}break;case"full":if(n>2){for(let f=0,p;f<n;f++)for(r=n;r>f;r--){o=m.substring(f,r),p=this.rtl?n-1-f:f;var l=this.score?this.score(i,m,g,o,p):Qt(w,c,g,n,p);ot(this,d,o,l,t,e)}break}case"bidirectional":case"reverse":if(n>1){for(l=n-1;l>0;l--){o=m[this.rtl?n-1-l:l]+o;var h=this.score?this.score(i,m,g,o,l):Qt(w,c,g,n,l);ot(this,d,o,h,t,e)}o=""}case"forward":if(n>1){for(l=0;l<n;l++)o+=m[this.rtl?n-1-l:l],ot(this,d,o,r,t,e);break}default:if(ot(this,d,m,r,t,e),s&&c>1&&g<c-1)for(n=this.N,o=m,r=Math.min(s+1,this.rtl?g+1:c-g),l=1;l<r;l++){m=i[this.rtl?c-1-g-l:g+l],h=this.bidirectional&&m>o;const f=this.score?this.score(i,o,g,m,l-1):Qt(n+(c/2>n?0:1),c,g,r-1,l-1);ot(this,u,h?o:m,f,t,e,h?m:o)}}}}this.fastupdate||this.reg.add(t)}}return this.db&&(this.commit_task.push(e?{ins:t}:{del:t}),this.M&&Ze(this)),this};function ot(t,i,e,s,n,r,o){let l,h;if(!(l=i[e])||o&&!l[o]){if(o?(i=l||(i[e]=L()),i[o]=1,h=t.ctx,(l=h.get(o))?h=l:h.set(o,h=t.keystore?new tt(t.keystore):new Map)):(h=t.map,i[e]=1),(l=h.get(e))?h=l:h.set(e,h=l=[]),r){for(let c=0,u;c<l.length;c++)if((u=l[c])&&u.includes(n)){if(c<=s)return;u.splice(u.indexOf(n),1),t.fastupdate&&(i=t.reg.get(n))&&i.splice(i.indexOf(u),1);break}}if(h=h[s]||(h[s]=[]),h.push(n),h.length===2**31-1){if(i=new jt(h),t.fastupdate)for(let c of t.reg.values())c.includes(h)&&(c[c.indexOf(h)]=i);l[s]=h=i}t.fastupdate&&((s=t.reg.get(n))?s.push(h):t.reg.set(n,[h]))}}function Qt(t,i,e,s,n){return e&&t>1?i+(s||0)<=t?e+(n||0):(t-1)/(i+(s||0))*(e+(n||0))+1|0:0}it.prototype.search=function(t,i,e){if(e||(i||typeof t!="object"?typeof i=="object"&&(e=i,i=0):(e=t,t="")),e&&e.cache)return e.cache=!1,t=this.searchCache(t,i,e),e.cache=!0,t;let s=[],n,r,o,l=0,h,c,u,d,w;e&&(t=e.query||t,i=e.limit||i,l=e.offset||0,r=e.context,o=e.suggest,w=(h=e.resolve)&&e.enrich,u=e.boost,d=e.resolution,c=this.db&&e.tag),typeof h>"u"&&(h=this.resolve),r=this.depth&&r!==!1;let g=this.encoder.encode(t,!r);if(n=g.length,i=i||(h?100:0),n===1)return ze.call(this,g[0],"",i,l,h,w,c);if(n===2&&r&&!o)return ze.call(this,g[1],g[0],i,l,h,w,c);let m=L(),f=0,p;if(r&&(p=g[0],f=1),d||d===0||(d=p?this.N:this.resolution),this.db){if(this.db.search&&(e=this.db.search(this,g,i,l,o,h,w,c),e!==!1))return e;const x=this;return(async function(){for(let v,S;f<n;f++){if((S=g[f])&&!m[S]){if(m[S]=1,v=await de(x,S,p,0,0,!1,!1),v=Ye(v,s,o,d)){s=v;break}p&&(o&&v&&s.length||(p=S))}o&&p&&f===n-1&&!s.length&&(d=x.resolution,p="",f=-1,m=L())}return Re(s,d,i,l,o,u,h)})()}for(let x,v;f<n;f++){if((v=g[f])&&!m[v]){if(m[v]=1,x=de(this,v,p,0,0,!1,!1),x=Ye(x,s,o,d)){s=x;break}p&&(o&&x&&s.length||(p=v))}o&&p&&f===n-1&&!s.length&&(d=this.resolution,p="",f=-1,m=L())}return Re(s,d,i,l,o,u,h)};function Re(t,i,e,s,n,r,o){let l=t.length,h=t;if(l>1)h=Xt(t,i,e,s,n,r,o);else if(l===1)return o?we.call(null,t[0],e,s):new B(t[0],this);return o?h:new B(h,this)}function ze(t,i,e,s,n,r,o){return t=de(this,t,i,e,s,n,r,o),this.db?t.then(function(l){return n?l||[]:new B(l,this)}):t&&t.length?n?we.call(this,t,e,s):new B(t,this):n?[]:new B([],this)}function Ye(t,i,e,s){let n=[];if(t&&t.length){if(t.length<=s){i.push(t);return}for(let r=0,o;r<s;r++)(o=t[r])&&(n[r]=o);if(n.length){i.push(n);return}}if(!e)return n}function de(t,i,e,s,n,r,o,l){let h;return e&&(h=t.bidirectional&&i>e)&&(h=e,e=i,i=h),t.db?t.db.get(i,e,s,n,r,o,l):(t=e?(t=t.ctx.get(e))&&t.get(i):t.map.get(i),t)}function it(t,i){if(!this||this.constructor!==it)return new it(t);if(t){var e=X(t)?t:t.preset;e&&(t=Object.assign({},Ti[e],t))}else t={};e=t.context;const s=e===!0?{depth:1}:e||{},n=X(t.encoder)?me[t.encoder]:t.encode||t.encoder||{};this.encoder=n.encode?n:typeof n=="object"?new Dt(n):{encode:n},this.resolution=t.resolution||9,this.tokenize=e=(e=t.tokenize)&&e!=="default"&&e!=="exact"&&e||"strict",this.depth=e==="strict"&&s.depth||0,this.bidirectional=s.bidirectional!==!1,this.fastupdate=!!t.fastupdate,this.score=t.score||null,(e=t.keystore||0)&&(this.keystore=e),this.map=e?new tt(e):new Map,this.ctx=e?new tt(e):new Map,this.reg=i||(this.fastupdate?e?new tt(e):new Map:e?new et(e):new Set),this.N=s.resolution||3,this.rtl=n.rtl||t.rtl||!1,this.cache=(e=t.cache||null)&&new xt(e),this.resolve=t.resolve!==!1,(e=t.db)&&(this.db=this.mount(e)),this.M=t.commit!==!1,this.commit_task=[],this.commit_timer=null,this.priority=t.priority||4}A=it.prototype;A.mount=function(t){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),t.mount(this)};A.commit=function(){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),this.db.commit(this)};A.destroy=function(){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),this.db.destroy()};function Ze(t){t.commit_timer||(t.commit_timer=setTimeout(function(){t.commit_timer=null,t.db.commit(t)},1))}A.clear=function(){return this.map.clear(),this.ctx.clear(),this.reg.clear(),this.cache&&this.cache.clear(),this.db?(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[],this.db.clear()):this};A.append=function(t,i){return this.add(t,i,!0)};A.contain=function(t){return this.db?this.db.has(t):this.reg.has(t)};A.update=function(t,i){const e=this,s=this.remove(t);return s&&s.then?s.then(()=>e.add(t,i)):this.add(t,i)};A.cleanup=function(){return this.fastupdate?(Ft(this.map),this.depth&&Ft(this.ctx),this):this};A.searchCache=pe;A.export=function(t,i,e=0,s=0){let n,r;switch(s){case 0:n="reg",r=Ve(this.reg);break;case 1:n="cfg",r=null;break;case 2:n="map",r=be(this.map,this.reg.size);break;case 3:n="ctx",r=Ue(this.ctx,this.reg.size);break;default:return}return ee.call(this,t,i,n,r,e,s)};A.import=function(t,i){if(i)switch(typeof i=="string"&&(i=JSON.parse(i)),t=t.split("."),t[t.length-1]==="json"&&t.pop(),t.length===3&&t.shift(),t=t.length>1?t[1]:t[0],t){case"reg":this.fastupdate=!1,this.reg=Je(i,this.reg);break;case"map":this.map=xe(i,this.map);break;case"ctx":this.ctx=Qe(i,this.ctx)}};A.serialize=function(t=!0){let i="",e="",s="";if(this.reg.size){let r;for(var n of this.reg.keys())r||(r=typeof n),i+=(i?",":"")+(r==="string"?'"'+n+'"':n);i="index.reg=new Set(["+i+"]);",e=Oe(this.map,r),e="index.map=new Map(["+e+"]);";for(const o of this.ctx.entries()){n=o[0];let l=Oe(o[1],r);l="new Map(["+l+"])",l='["'+n+'",'+l+"]",s+=(s?",":"")+l}s="index.ctx=new Map(["+s+"]);"}return t?"function inject(index){"+i+e+s+"}":i+e+s};ye(it.prototype);const qe=typeof window<"u"&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),ie=["map","ctx","tag","reg","cfg"],yt=L();function ne(t,i={}){if(!this||this.constructor!==ne)return new ne(t,i);typeof t=="object"&&(i=t,t=t.name),t||console.info("Default storage space was used, because a name was not passed."),this.id="flexsearch"+(t?":"+t.toLowerCase().replace(/[^a-z0-9_\-]/g,""):""),this.field=i.field?i.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"",this.type=i.type,this.fastupdate=this.support_tag_search=!1,this.db=null,this.h={}}A=ne.prototype;A.mount=function(t){return t.index?t.mount(this):(t.db=this,this.open())};A.open=function(){if(this.db)return this.db;let t=this;navigator.storage&&navigator.storage.persist&&navigator.storage.persist(),yt[t.id]||(yt[t.id]=[]),yt[t.id].push(t.field);const i=qe.open(t.id,1);return i.onupgradeneeded=function(){const e=t.db=this.result;for(let s=0,n;s<ie.length;s++){n=ie[s];for(let r=0,o;r<yt[t.id].length;r++)o=yt[t.id][r],e.objectStoreNames.contains(n+(n!=="reg"&&o?":"+o:""))||e.createObjectStore(n+(n!=="reg"&&o?":"+o:""))}},t.db=pt(i,function(e){t.db=e,t.db.onversionchange=function(){t.close()}})};A.close=function(){this.db&&this.db.close(),this.db=null};A.destroy=function(){const t=qe.deleteDatabase(this.id);return pt(t)};A.clear=function(){const t=[];for(let e=0,s;e<ie.length;e++){s=ie[e];for(let n=0,r;n<yt[this.id].length;n++)r=yt[this.id][n],t.push(s+(s!=="reg"&&r?":"+r:""))}const i=this.db.transaction(t,"readwrite");for(let e=0;e<t.length;e++)i.objectStore(t[e]).clear();return pt(i)};A.get=function(t,i,e=0,s=0,n=!0,r=!1){t=this.db.transaction((i?"ctx":"map")+(this.field?":"+this.field:""),"readonly").objectStore((i?"ctx":"map")+(this.field?":"+this.field:"")).get(i?i+":"+t:t);const o=this;return pt(t).then(function(l){let h=[];if(!l||!l.length)return h;if(n){if(!e&&!s&&l.length===1)return l[0];for(let c=0,u;c<l.length;c++)if((u=l[c])&&u.length){if(s>=u.length){s-=u.length;continue}const d=e?s+Math.min(u.length-s,e):u.length;for(let w=s;w<d;w++)h.push(u[w]);if(s=0,h.length===e)break}return r?o.enrich(h):h}return l})};A.tag=function(t,i=0,e=0,s=!1){t=this.db.transaction("tag"+(this.field?":"+this.field:""),"readonly").objectStore("tag"+(this.field?":"+this.field:"")).get(t);const n=this;return pt(t).then(function(r){return!r||!r.length||e>=r.length?[]:!i&&!e?r:(r=r.slice(e,e+i),s?n.enrich(r):r)})};A.enrich=function(t){typeof t!="object"&&(t=[t]);const i=this.db.transaction("reg","readonly").objectStore("reg"),e=[];for(let s=0;s<t.length;s++)e[s]=pt(i.get(t[s]));return Promise.all(e).then(function(s){for(let n=0;n<s.length;n++)s[n]={id:t[n],doc:s[n]?JSON.parse(s[n]):null};return s})};A.has=function(t){return t=this.db.transaction("reg","readonly").objectStore("reg").getKey(t),pt(t).then(function(i){return!!i})};A.search=null;A.info=function(){};A.transaction=function(t,i,e){t+=t!=="reg"&&this.field?":"+this.field:"";let s=this.h[t+":"+i];if(s)return e.call(this,s);let n=this.db.transaction(t,i);this.h[t+":"+i]=s=n.objectStore(t);const r=e.call(this,s);return this.h[t+":"+i]=null,pt(n).finally(function(){return r})};A.commit=async function(t){let i=t.commit_task,e=[];t.commit_task=[];for(let s=0,n;s<i.length;s++)n=i[s],n.del&&e.push(n.del);e.length&&await this.remove(e),t.reg.size&&(await this.transaction("map","readwrite",function(s){for(const n of t.map){const r=n[0],o=n[1];o.length&&(s.get(r).onsuccess=function(){let l=this.result;var h;if(l&&l.length){const c=Math.max(l.length,o.length);for(let u=0,d,w;u<c;u++)if((w=o[u])&&w.length){if((d=l[u])&&d.length)for(h=0;h<w.length;h++)d.push(w[h]);else l[u]=w;h=1}}else l=o,h=1;h&&s.put(l,r)})}}),await this.transaction("ctx","readwrite",function(s){for(const n of t.ctx){const r=n[0],o=n[1];for(const l of o){const h=l[0],c=l[1];c.length&&(s.get(r+":"+h).onsuccess=function(){let u=this.result;var d;if(u&&u.length){const w=Math.max(u.length,c.length);for(let g=0,m,f;g<w;g++)if((f=c[g])&&f.length){if((m=u[g])&&m.length)for(d=0;d<f.length;d++)m.push(f[d]);else u[g]=f;d=1}}else u=c,d=1;d&&s.put(u,r+":"+h)})}}}),t.store?await this.transaction("reg","readwrite",function(s){for(const n of t.store){const r=n[0],o=n[1];s.put(typeof o=="object"?JSON.stringify(o):1,r)}}):t.bypass||await this.transaction("reg","readwrite",function(s){for(const n of t.reg.keys())s.put(1,n)}),t.tag&&await this.transaction("tag","readwrite",function(s){for(const n of t.tag){const r=n[0],o=n[1];o.length&&(s.get(r).onsuccess=function(){let l=this.result;l=l&&l.length?l.concat(o):o,s.put(l,r)})}}),t.map.clear(),t.ctx.clear(),t.tag&&t.tag.clear(),t.store&&t.store.clear(),t.document||t.reg.clear())};function ce(t,i,e){const s=t.value;let n,r=0;for(let o=0,l;o<s.length;o++){if(l=e?s:s[o]){for(let h=0,c,u;h<i.length;h++)if(u=i[h],c=l.indexOf(u),c>=0)if(n=1,l.length>1)l.splice(c,1);else{s[o]=[];break}r+=l.length}if(e)break}r?n&&t.update(s):t.delete(),t.continue()}A.remove=function(t){return typeof t!="object"&&(t=[t]),Promise.all([this.transaction("map","readwrite",function(i){i.openCursor().onsuccess=function(){const e=this.result;e&&ce(e,t)}}),this.transaction("ctx","readwrite",function(i){i.openCursor().onsuccess=function(){const e=this.result;e&&ce(e,t)}}),this.transaction("tag","readwrite",function(i){i.openCursor().onsuccess=function(){const e=this.result;e&&ce(e,t,!0)}}),this.transaction("reg","readwrite",function(i){for(let e=0;e<t.length;e++)i.delete(t[e])})])};function pt(t,i){return new Promise((e,s)=>{t.onsuccess=t.oncomplete=function(){i&&i(this.result),i=null,e(this.result)},t.onerror=t.onblocked=s,t=null})}const _i={Index:it,Charset:me,Encoder:Dt,Document:bt,Worker:vt,Resolver:B,IndexedDB:ne,Language:{}};const Oi=""+new URL("year-in-posts-B2lywqdx.png",import.meta.url).href,Et="year-in-posts-list";function Ri(){try{const t=Yt.account.get(Et)||{};return Object.entries(t).map(([e,s])=>({year:parseInt(e),...s})).sort((e,s)=>s.year-e.year)}catch{return[]}}async function zi(t){try{const e=`${ge()}-${t}`;await Gt.yearInPosts.del(e);const s=Yt.account.get(Et)||{};return delete s[t],Yt.account.set(Et,s),!0}catch(i){throw i}}function Yi(t,i){const e=new Date(t),s=new Date(i,0,1),n=new Date(i,11,31,23,59,59,999);return e>=s&&e<=n}async function Be(t){const{masto:i,instance:e}=Fe(),s=[];let n=!1;const r=ei();if(!r)throw new Error("No current account");const o=r.info.id,l=r.info.acct,h=new Date(t,0,1),c=new Date(t,11,31,23,59,59,999),u=await gi(e);let d=null;if(u)try{const I=await i.v1.accounts.$select(o).statuses.list({limit:1,exclude_replies:!1,exclude_reblogs:!1}).values().next();if(I?.value?.length){const D=I.value[0];if(!Yi(D.createdAt,t)){const C=`${t+1}-01-02`;try{const $=await i.v2.search.list({q:`from:${l} before:${C}`,type:"statuses",limit:1});$?.statuses?.length&&(d=$.statuses[0].id)}catch{}}}}catch{}const w=i.v1.accounts.$select(o).statuses.list({limit:40,exclude_replies:!1,exclude_reblogs:!1,max_id:d||void 0}).values();let g=!0;t:for(;;)try{const S=await w.next(),{value:I,done:D}=S;if(D||!I?.length)break t;let C=!1;for(const $ of I){const k=new Date($.createdAt);k>c||(g=!1,k>=h&&(s.push($),C=!0))}if(!C&&!g)break t;await new Promise($=>setTimeout($,500))}catch{break t}if(s.sort((S,I)=>new Date(S.createdAt)-new Date(I.createdAt)),s.length>0)try{const I=s[0].id,D=i.v1.accounts.$select(o).statuses.list({limit:40,min_id:I,exclude_replies:!1,exclude_reblogs:!1}).values();t:for(;;)try{const C=await D.next(),{value:$,done:k}=C;if(k||!$?.length)break t;let T=!1;for(const R of $){const _=new Date(R.createdAt);_<h||_<=c&&(s.find(N=>N.id===R.id)||(s.push(R),n=!0),T=!0)}if(!T)break t;await new Promise(R=>setTimeout(R,500))}catch{break t}n&&s.sort((C,$)=>new Date(C.createdAt)-new Date($.createdAt))}catch{}let m=0;try{m=new TextEncoder().encode(JSON.stringify(s)).length}catch{}const p=`${ge()}-${t}`,x=new Date().getTimezoneOffset();await Gt.yearInPosts.set(p,{id:p,posts:s,count:s.length,year:t,size:m,fetchedAt:Date.now(),timezoneOffset:x});const v=Yt.account.get(Et)||{};return v[t]={count:s.length,size:m,fetchedAt:Date.now(),timezoneOffset:x},Yt.account.set(Et,v),{posts:s,searchEnabled:u,gapsFilled:n}}const Ge=2005;function Bi(){const t=new Date,i=t.getFullYear(),e=t.getMonth(),s=t.getDate();return e===0&&s<=30?i-1:i}function Vt(t){const i=t<=0?"+":"-",e=Math.abs(t),s=Math.floor(e/60),n=e%60;return`UTC${i}${s}${n>0?`:${String(n).padStart(2,"0")}`:""}`}function Ni(){return new Date().getTimezoneOffset()}const Fi={all:"All",original:"Original",replies:"Replies",quotes:"Quotes",boosts:"Boosts",media:"Media"},Ei=[{key:"relevance",condition:"searchQuery"},{key:"createdAt"},{key:"repliesCount"},{key:"favouritesCount"},{key:"reblogsCount"}];function Rt(t,i,e="short"){const s=new Date(2e3,t,1);return oi(i,{month:e}).format(s)}function Ne(t){return t=parseInt(t,10),t>=Ge&&t<=new Date().getFullYear()?t:null}function Li(t){return t=parseInt(t,10),t>=0&&t<=11?t:null}const Jt=30;function qi(){const{i18n:t}=Ee(),[i,e]=ii(),s=i.get("year"),n=i.get("month"),[r,o]=G("all"),[l,h]=G(""),c=Ne(s),u=Li(n);ni(l?`Year in Posts ${c} - Search: ${l}`:c?u!==null?`Year in Posts ${c} - ${Rt(u,t.locale)}`:`Year in Posts ${c}`:"Year in Posts","/yip");const{instance:d}=Fe(),[w,g]=G("default"),[m,f]=G([]),[p,x]=G([]),[v,S]=G(!0),[I,D]=G(!!l),[C,$]=G(Jt),[k,T]=G(l?"relevance":"createdAt"),[R,_]=G("asc"),N=zt(null),K=zt(null),H=mt(()=>ge(),[]);li(["Slash","/"],y=>{I?N.current?.focus():(D(!0),setTimeout(()=>{N.current?.focus()},100))},{useKey:!0,preventDefault:!0,ignoreEventWhen:y=>{const M=!!document.querySelector("#modal-container > *"),b=["INPUT","TEXTAREA"].includes(y.target.tagName);return M||b||y.metaKey||y.ctrlKey||y.altKey||y.shiftKey}});const F=m.length;ft(()=>{l||N.current?.isFocused()||D(!1)},[l,n,r,k,R]);function Z(){const y=Ri();x(y)}ft(()=>{c||Z()},[c]);const Tt=async y=>{y.preventDefault();const M=Ne(y.target.elements.year.value);if(M)try{const b=`${H}-${M}`,j=await Gt.yearInPosts.get(b);j&&j.year===M?e({year:M}):(g("generating"),await Be(M),e({year:M}))}catch{g("error"),le("Unable to generate year posts. Please try again.")}finally{w==="generating"&&g("default")}else le("Invalid year.")};async function nt(y){try{g("generating"),await Be(y),e({year:y})}catch{g("error"),le("Unable to regenerate year posts. Please try again.")}finally{w==="generating"&&g("default")}}async function Lt(y){if(confirm(`Remove year ${y} posts?`))try{await zi(y),x(M=>M.filter(b=>b.year!==y))}catch{alert("Failed to remove year data")}}const ct=mt(()=>{const y={};m.forEach(b=>{const j=new Date(b.createdAt),O=j.getMonth(),E=j.getDate();y[O]||(y[O]={}),y[O][E]||(y[O][E]={total:0,original:0,reply:0,quote:0,boost:0});const z=y[O][E];z.total++,b.reblog?z.boost++:Ct()&&(b.quote?.id||b.quote?.quotedStatus?.id)?z.quote++:b.inReplyToId?z.reply++:z.original++});const M={};return Object.keys(y).forEach(b=>{const j=y[b],O=Math.max(...Object.values(j).map(Q=>Q.total)),z=new Date(c,parseInt(b),1).getDay(),U=[];for(let Q=0;Q<z;Q++)U.push({day:null,count:0,ratio:0,original:0,reply:0,quote:0,boost:0});for(let Q=1;Q<=31;Q++){const st=j[Q],Mt=st?.total||0,V=Mt&&O>0?Mt/O:0;U.push({day:Q,count:Mt,ratio:V,original:st?.original||0,reply:st?.reply||0,quote:st?.quote||0,boost:st?.boost||0})}M[b]=U}),M},[m,c]),ut=mt(()=>{if(r!=="media")return{};const y={};return m.forEach(M=>{const b=new Date(M.createdAt),j=b.getMonth(),O=b.getDate();y[j]||(y[j]={}),y[j][O]||(y[j][O]=[]),y[j][O].push(M)}),Object.keys(y).forEach(M=>{const b=y[M],O=new Date(c,parseInt(M),1).getDay(),E=[];for(let z=0;z<O;z++)E.push(null);for(let z=1;z<=31;z++){const U=b[z]||[];let Q=null,st=!1;if(U.length>0){const Mt=U.filter(V=>{const _t=V.reblog||V;return!V.reblog&&_t.mediaAttachments?.some(rt=>rt.previewUrl||rt.url||rt.previewRemoteUrl||rt.remoteUrl)});Mt.length>0&&(Q=Mt.reduce((V,_t)=>{const rt=_t,ke=(rt.favouritesCount||0)+(rt.reblogsCount||0)+(rt.repliesCount||0)+(rt.quotesCount||0),Se=V?(V.favouritesCount||0)+(V.reblogsCount||0)+(V.repliesCount||0)+(V.quotesCount||0):-1;return ke>Se?_t:ke===Se?V||_t:V},null),st=!0)}E.push(Q?{post:Q,hasMedia:st}:{hasMedia:st})}y[M]=E}),y},[m,c,r]),q=mt(()=>{const y={},M={};return m.forEach(b=>{const j=new Date(b.createdAt).getMonth();y[j]=(y[j]||0)+1,M[j]||(M[j]={original:0,reply:0,quote:0,boost:0}),b.reblog?M[j].boost++:Ct()&&(b.quote?.id||b.quote?.quotedStatus?.id)?M[j].quote++:b.inReplyToId?M[j].reply++:M[j].original++}),Object.entries(y).map(([b,j])=>{const O=M[b];return{month:parseInt(b),count:j,heatmap:ct[b]||[],mediaGrid:ut[b]||[],original:O.original,reply:O.reply,quote:O.quote,boost:O.boost}}).sort((b,j)=>b.month-j.month)},[m,ct,ut]),at=zt(null);ft(()=>{if(F>0){const y=new _i.Document({preset:"match",document:{id:"id",index:["content","spoilerText","poll","media","card"]}});m.forEach(M=>{const b=M.reblog||M,j=b.poll?.options?.map(z=>z.title).join(" "),O=b.mediaAttachments?.map(z=>z.description).join(" "),E=b.card?`${b.card.title} ${b.card.description} ${b.card.url}`:"";y.add({id:M.id,content:hi(b.content),spoilerText:b.spoilerText,poll:j,media:O,card:E})}),at.current=y}},[m]);const P=mt(()=>{if(!l)return m;if(!at.current)return[];console.time(`search: '${l}'`);const y=at.current.search(l,{limit:F});console.timeEnd(`search: '${l}'`);const M=y.flatMap(E=>E.result),b=[...new Set(M)],j=new Map(m.map(E=>[E.id,E]));return b.map(E=>j.get(E)).filter(Boolean)},[m,l]);ft(()=>{$(Jt),l?["relevance","createdAt"].includes(k)||T("relevance"):k==="relevance"&&T("createdAt")},[l,k]);const[Y,kt]=mt(()=>{const y=P.filter(b=>{if(l)return!0;const j=new Date(b.createdAt).getMonth();return u!==null&&j===u}),M={all:y.length,original:0,replies:0,quotes:0,boosts:0,media:0};return y.forEach(b=>{b.reblog?M.boosts++:Ct()&&(b.quote?.id||b.quote?.quotedStatus?.id)?M.quotes++:b.inReplyToId?M.replies++:M.original++;const j=b.reblog||b;!b.reblog&&j.mediaAttachments?.length>0&&M.media++}),[M,y]},[P,u,l]),[St,Xe]=mt(()=>{const y=kt.filter(b=>{if(r==="boosts")return!!b.reblog;if(r==="media"){const j=b.reblog||b;return!b.reblog&&j.mediaAttachments?.length>0}else{if(r==="quotes")return Ct()&&(b.quote?.id||b.quote?.quotedStatus?.id);if(r==="replies")return!!b.inReplyToId;if(r==="original")return!b.reblog&&!(Ct()&&(b.quote?.id||b.quote?.quotedStatus?.id))&&!b.inReplyToId}return!0});let M=y;return k!=="relevance"&&(M=[...y].sort((b,j)=>{const O=b.reblog||b,E=j.reblog||j;let z,U;return k==="createdAt"?(z=new Date(b.createdAt),U=new Date(j.createdAt)):(z=O[k]||0,U=E[k]||0),R==="asc"?z>U?1:-1:U>z?1:-1})),l?[M.slice(0,C),M.length>C]:[M,!1]},[kt,r,l,C,k,R]);ft(()=>{l&&r!=="all"&&St.length===0&&Y.all>0&&o("all")},[l,r,St.length,Y.all]);const Kt=q.findIndex(y=>y.month===u),re=Kt>0?q[Kt-1]:null,oe=Kt<q.length-1?q[Kt+1]:null;return ft(()=>{if(!c){g("default"),f([]);return}(async()=>{g("loading");try{const y=`${H}-${c}`;console.time(`fetchYearPosts-${c}`);const M=await Gt.yearInPosts.get(y);console.timeEnd(`fetchYearPosts-${c}`),M&&M.year===c?(M.posts.sort((b,j)=>new Date(b.createdAt)-new Date(j.createdAt)),f(M.posts),g("results")):g("no-data")}catch{g("error")}})()},[c]),ft(()=>{if(u!==null&&w==="results"){const y=document.querySelector(`.calendar-bar .month-filter[data-month="${u}"]`);y?.focus(),y?.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[u,w==="results"]),a("div",{ref:K,id:"year-in-posts-page",class:"deck-container",tabIndex:"-1",style:{"--month":u||0},children:[a("div",{class:"timeline-deck deck",children:[a("header",{class:w==="loading"?"loading":"",onClick:y=>{y.target.closest("a, button")||K.current?.scrollTo({top:0,behavior:"smooth"})},children:a("div",{class:"header-grid",children:[a("div",{class:"header-side",children:[a(pi,{}),c&&u!==null?a(ht,{to:`/yip?year=${c}`,class:"button plain",onClick:()=>{h("")},children:a(J,{icon:"grid",size:"l",alt:"Year in Posts"})}):c?a(ht,{to:"/yip",class:"button plain",onClick:()=>{h("")},children:a(J,{icon:"month",size:"l",alt:"Year in Posts"})}):a(ht,{to:"/",class:"button plain",children:a(J,{icon:"home",size:"l",alt:"Home"})})]}),c&&a(lt,{children:I?a(Ui,{ref:N,placeholder:`Search posts in ${c}`,searchQuery:l,onSearch:y=>{h(y),$(Jt)},onEscape:()=>{l.trim()||(D(!1),h(""))}}):a("h1",{class:"header-double-lines",children:[a("b",{children:c}),w==="results"&&a("div",{children:u!==null?`${Rt(u)} ${q[u].count} posts`:`${m.length} posts`})]})}),a("div",{class:"header-side",children:c&&a(lt,{children:[a("button",{type:"button",class:`plain ${I?"is-active":""}`,onClick:()=>{I?(D(!1),h("")):(D(!0),setTimeout(()=>{N.current?.focus()},100))},children:a(J,{icon:"search",size:"l",alt:"Search"})}),a(ci,{align:"end",menuButton:a("button",{type:"button",class:"plain",children:a(J,{icon:"more",size:"l",alt:"More"})}),children:a(ui,{type:"checkbox",checked:r==="media",onClick:()=>{o(r==="media"?"all":"media")},children:[a(J,{icon:"check-circle",alt:"☑️"})," ",a("span",{class:"menu-grow",children:"Media only"})]})})]})})]})}),a("main",{children:[!c&&a("div",{class:"year-in-posts-start",children:[w!=="generating"?a(lt,{children:[a("h1",{children:["Year in Posts ",a("sup",{children:"beta"})]}),a("p",{children:"A year-at-a-glance view of your posts."}),a("details",{children:[a("summary",{children:"What is this?"}),a("p",{children:"Year in Posts is a simple, searchable archive of your posts, offering a year-at-a-glance view with calendar visualizations and straight-forward interface to sort and filter through posts."}),a("img",{src:Oi,width:"1200",height:"900",alt:"Preview of Year in Posts UI"}),a("p",{children:a("button",{type:"button",onClick:y=>{y.target.closest("details").open=!1},children:"Let's explore my posts"})})]}),a("form",{class:"year-generate",onSubmit:Tt,children:[a("label",{children:a("input",{type:"number",min:Ge,max:new Date().getFullYear(),name:"year",defaultValue:Bi(),disabled:w==="generating"})}),a("button",{type:"submit",disabled:w==="generating",children:a(J,{icon:"arrow-right",alt:"Generate",size:"l"})})]}),a("div",{class:"insignificant",children:a("small",{children:[a("p",{children:"This downloads your posts (excluding media files) from the server and saves them locally. It may take a longer time and require more disk space."}),a("p",{children:"Once archived, updated or deleted posts are not reflected in the archive until regenerated."})]})}),!v&&a("p",{class:"insignificant",children:a("small",{children:"⚠️ Your server doesn't support advanced search, this will make more requests to the server and take much longer time."})})]}):a("div",{class:"ui-state year-in-posts-start",children:[a(Me,{abrupt:!0}),a("p",{class:"insignificant",children:"Generating Year in Posts…"}),a("p",{class:"insignificant",children:"This might take a while."})]}),p.length>0&&w!=="generating"&&a("div",{class:"year-selection",children:[a("p",{children:"Archived Year in Posts:"}),a("ul",{children:p.map(({year:y,count:M,fetchedAt:b,size:j,timezoneOffset:O})=>{const E=Ni(),z=O!==void 0&&O!==E;return a("li",{children:[a(ht,{to:`/yip?year=${y}`,class:"year-card available",children:[a(J,{icon:"month"})," ",y]})," ",a("small",{class:"ib insignificant",children:[M," posts"," "]})," ",j&&a("small",{class:"tag insignificant collapsed",title:`${j.toLocaleString(t.locale||void 0)} bytes`,children:["~",ai(j)]})," ",a(fi,{align:"end",confirmLabel:a("span",{children:["Regenerate ",y," posts?"]}),onClick:()=>{nt(y)},children:a("button",{type:"button",class:"light small",disabled:w==="loading",title:b,children:[a(J,{icon:"refresh",size:"s",class:"insignificant"})," ",a("span",{class:"insignificant",children:new Date(b).toLocaleDateString(t.locale,{year:"numeric",month:"short",day:"numeric"})})," ",O!==void 0&&a("small",{class:`tag insignificant collapsed ${z?"warn":""}`,title:z?`Generated in ${Vt(O)}, current timezone is ${Vt(E)}`:Vt(O),children:[z&&a(J,{icon:"time"}),Vt(O)]})]})}),a("button",{type:"button",class:"light danger small",onClick:U=>{U.preventDefault(),Lt(y)},children:a(J,{icon:"x",alt:"Remove"})})]},y)})})]})]}),c&&w==="loading"&&a("div",{class:"ui-state year-in-posts-start",children:a(Me,{abrupt:!0})}),c&&w==="results"&&a(lt,{children:[!l&&q.length>0&&a(lt,{children:[a(Wi,{year:c,month:u,monthsWithPosts:q,postType:r}),u===null&&a(Hi,{})]}),(u!==null||l)&&a("div",{class:"post-type-filters",children:Object.entries(Fi).map(([y,M])=>Y[y]>0&&a("button",{type:"button",class:`filter-cat plain ${r===y?"is-active":""}`,onClick:()=>o(y),children:[M," ",a("span",{class:"count",children:Y[y]})]},y))}),(u!==null||l)&&St.length>1&&a("div",{class:"sort-controls",children:[a("span",{class:"filter-label",children:"Sort"})," ",a("fieldset",{class:"radio-field-group",children:Ei.filter(y=>y.key==="relevance"?!!l:y.key==="createdAt"?!0:!l).map(({key:y})=>a("label",{class:"filter-sort",onClick:M=>{k===y&&y!=="relevance"&&(M.preventDefault(),M.stopPropagation(),_(R==="asc"?"desc":"asc"))},children:[a("input",{type:"radio",name:"filter-sort-cat",checked:k===y,onChange:()=>{T(y);const M=/(replies|favourites|reblogs)/.test(y)?"desc":"asc";_(M)}}),{relevance:"Relevance",createdAt:"Date",repliesCount:"Replies",favouritesCount:"Likes",reblogsCount:"Boosts"}[y],k===y&&y!=="relevance"&&(R==="asc"?" ↑":" ↓")]},y))})]}),(u!==null||l)&&a(lt,{children:[a("ul",{class:"timeline",children:St.length===0?a("p",{class:"ui-state insignificant",children:"…"}):St.map((y,M)=>{const b=new Date(y.createdAt),j=St[M-1],O=j?new Date(j.createdAt):null,E=k==="createdAt"&&(!O||b.toDateString()!==O.toDateString());return a(lt,{children:[E&&a("li",{class:"date-header",children:a("h2",{children:[a("span",{children:Ae(y.createdAt,{hideTime:!0,formatOpts:{year:void 0}})})," ",a("small",{class:"insignificant bidi-isolate",children:Ae(y.createdAt,{forceOpts:{weekday:"long"}})})]})},y.createdAt),a("li",{children:F>20?a(Ki,{root:K.current,post:y,instance:d,defaultShow:M<3},y.id):a(ht,{class:"status-link timeline-item",to:y.reblog?`/${d}/s/${y.reblog.id}`:`/${d}/s/${y.id}`,children:a(Le,{status:y,instance:d,size:"m",showCommentCount:!0,showQuoteCount:!0})})},y.id)]})})}),l&&Xe&&a("div",{class:"ui-state",children:a("button",{type:"button",class:"plain6 block",onClick:()=>$(y=>y+Jt),children:"More…"})}),!l&&a("div",{class:"year-in-posts-nav",children:[re?a(ht,{to:`/yip?year=${c}&month=${re.month}`,class:"button light",onClick:()=>{K.current?.scrollTo({top:0,behavior:"instant"})},children:[a(J,{icon:"arrow-left"})," ",Rt(re.month,t.locale,"long")]}):a("span",{}),oe&&a(ht,{to:`/yip?year=${c}&month=${oe.month}`,class:"button light",onClick:()=>{K.current?.scrollTo({top:0,behavior:"instant"})},children:[Rt(oe.month,t.locale,"long")," ",a(J,{icon:"arrow-right"})]})]})]})]})]})]}),a("div",{class:`tron-grid ${u===null?"animated":""}`})]})}const Ki=({root:t,post:i,instance:e,defaultShow:s})=>{const n=zt(),[r,o]=G(s);ft(()=>{if(s)return;const h=new IntersectionObserver(c=>{c[0].isIntersecting&&(queueMicrotask(()=>o(!0)),h.unobserve(n.current))},{root:t,rootMargin:`${Math.max(320,screen.height*.75)}px`});return n.current&&h.observe(n.current),()=>{n.current&&h.unobserve(n.current)}},[s]);const l=i.reblog?.id||i.id;return a("li",{ref:n,style:{height:r?void 0:"10em"},children:r?a(ht,{class:"status-link timeline-item",to:`/${e}/s/${l}`,children:a(Le,{status:i,instance:e,size:"m",showCommentCount:!0,showQuoteCount:!0})}):a(lt,{children:" "})})};function Wi({year:t,month:i,monthsWithPosts:e,postType:s}){const{i18n:n}=Ee();return a("div",{class:`calendar-bar ${i===null?"grid":"horizontal"} ${s==="media"?"media-grid":""}`,children:e.map(({month:r,count:o,heatmap:l,mediaGrid:h,original:c,reply:u,quote:d,boost:w})=>{const g=o>0?c/o:0,m=o>0?u/o:0,f=o>0?d/o:0,p=o>0?w/o:0;return a(ht,{to:`/yip?year=${t}&month=${r}${s!=="all"?`&postType=${s}`:""}`,class:`button plain ${i===r?"is-active month-filter":"month-filter"}`,style:{"--month-original-ratio":g,"--month-reply-ratio":m,"--month-quote-ratio":f,"--month-boost-ratio":p},"data-month":r,children:[a("div",{class:"month-name",children:Rt(r,n.locale)}),s==="media"?h.length>0&&a("div",{class:"month-media-grid",children:h.map((x,v)=>{if(!x)return a("span",{class:"media-day empty"},v);if(!x.hasMedia)return a("span",{class:"media-day no-media"},v);const I=x.post.mediaAttachments?.[0];return a("span",{class:"media-day",children:a("img",{src:I.previewUrl||I.url,loading:"lazy",decoding:"async",onError:D=>{const{src:C}=D.target;C===I.previewUrl||C===I.url?D.target.src=I.previewRemoteUrl||I.remoteUrl:D.target.remove()},alt:""})},v)})}):l.length>0&&a("div",{class:"month-heatmap",children:l.map((x,v)=>{const S=x.count||0,I=S>0?x.original/S:0,D=S>0?x.reply/S:0,C=S>0?x.quote/S:0,$=S>0?x.boost/S:0;return a("span",{class:`heatmap-day ${x.day===null?"empty":""} ${v%7===0||v%7===6?"weekend":""}`,"data-ratio":x.ratio,style:{"--ratio":x.ratio,"--original-ratio":I,"--reply-ratio":D,"--quote-ratio":C,"--boost-ratio":$}},v)})}),a("div",{class:"month-metadata",children:[o," posts "]})]},r)})})}function Hi(){return a("div",{class:"calendar-bar-legends",children:[a("span",{class:"ib",children:[a("span",{class:"calendar-bar-legend-item calendar-bar-original"})," ",a(Wt,{id:"HxF6Fk"})]})," ",a("span",{class:"ib",children:[a("span",{class:"calendar-bar-legend-item calendar-bar-reply"})," ",a(Wt,{id:"N8UzTV"})]})," ",Ct()&&a(lt,{children:[a("span",{class:"ib",children:[a("span",{class:"calendar-bar-legend-item calendar-bar-quote"})," ",a(Wt,{id:"eWLklq"})]})," "]}),a("span",{class:"ib",children:[a("span",{class:"calendar-bar-legend-item calendar-bar-boost"})," ",a(Wt,{id:"puY2t0"})]})]})}const Ui=si(({searchQuery:t,onSearch:i,placeholder:e,onEscape:s},n)=>{const r=zt(null);ri(n,()=>({focus:()=>{r.current?.focus()},setValue:l=>{r.current.value=l},isFocused:()=>document.activeElement===r.current}));const o=di(i,150);return a("form",{class:"search-field",onSubmit:l=>{l.preventDefault();const h=r.current.value.trim();o?.cancel(),o(h)},children:a("input",{ref:r,type:"search",name:"q",class:"block",placeholder:e||"Search posts…",defaultValue:t,dir:"auto",autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellCheck:"false",enterKeyHint:"search",onInput:l=>{const h=l.target.value;o(h)},onKeyDown:l=>{l.key==="Escape"&&!l.target.value.trim()&&s?.()}})})});export{qi as default};
//# sourceMappingURL=year-in-posts-DZVzhOlC.js.map