3 lines
69 KiB
JavaScript
3 lines
69 KiB
JavaScript
import{J as Ge,l as Bt,H as de,a as Ne,V as ti,u as Fe,X as ei,d as q,a2 as ii,A as zt,m as pt,y as at,e as p,k as mt,W as ni,z as Se,Y as si}from"./pwa-viewport-CJ-1bFP1.js";import{D as Zt,af as ri,f as oi,s as oe,p as Ot,w as li,L as lt,I as J,i as hi,d as ci,q as ui,j as ai,n as Me,F as Ee,X as fi}from"./ScheduledAtField-C2dSuh6f.js";import{i as di,N as gi}from"./main-0n0W_4XT.js";import"./ICONS-DaAGffIM.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 K(){return Object.create(null)}function G(t){return typeof t=="string"}function Yt(t){return typeof t=="object"}function Nt(t,i){if(G(i))t=t[i];else for(let e=0;t&&e<i.length;e++)t=t[i[e]];return t}const pi=/[^\p{L}\p{N}]+/u,mi=/(\d{3})/g,yi=/(\D)(\d{3})/g,wi=/(\d{3})(\D)/g,Ae=/[\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,pi)}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=Ae?t.normalize("NFKD").replace(Ae,"").toLowerCase():t.toLowerCase()),this.prepare&&(t=this.prepare(t)),this.numeric&&t.length>3&&(t=t.replace(yi,"$1 $2").replace(wi,"$1 $2").replace(mi,"$1 "));const e=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let s=[],n=K(),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,f=>this.stemmer.get(f))}if(u&&(this.mapper||this.dedupe&&u.length>1)){h="";for(let w=0,f="",m,a;w<u.length;w++)m=u.charAt(w),m===f&&this.dedupe||((a=this.mapper&&this.mapper.get(m))||a===""?a===f&&this.dedupe||!(f=a)||(h+=a):h+=f=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 ge(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 bt);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 bt(t){this.limit=t&&t!==!0?t:1e3,this.cache=new Map,this.h=""}bt.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)};bt.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};bt.prototype.remove=function(t){for(const i of this.cache){const e=i[0];i[1].includes(t)&&this.cache.delete(e)}};bt.prototype.clear=function(){this.cache.clear(),this.h=""};const Ie={normalize:!1,numeric:!1,dedupe:!1},Wt={},le=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"]]),$e=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Ce=[/([^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 pe={Exact:Ie,Default:Wt,Normalize:Wt,LatinBalance:{mapper:le},LatinAdvanced:{mapper:le,matcher:$e,replacer:Ce},LatinExtra:{mapper:le,replacer:Ce.concat([/(?!^)[aeo]/g,""]),matcher:$e},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:Ie,LatinDefault:Wt,LatinSimple:Wt};function Pe(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 Pt(t){if(!this||this.constructor!==Pt)return new Pt(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 Pe(i,n||0,r||i.length,!1)};if(s==="splice")return function(n,r){return Pe(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}})}Pt.prototype.clear=function(){this.index.length=0};Pt.prototype.push=function(){};function tt(t=8){if(!this||this.constructor!==tt)return new tt(t);this.index=K(),this.h=[],this.size=0,t>32?(this.B=Le,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=K(),this.h=[],this.size=0,t>32?(this.B=Le,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=K(),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 Le(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,Tt;async function vi(t){t=t.data;var i=t.task;const e=t.id;let s=t.args;if(i==="init")Tt=t.options||{},(i=t.factory)?(Function("return "+i)()(self),It=new self.FlexSearch.Index(Tt),delete self.FlexSearch):It=new it(Tt),postMessage({id:e});else{let n;i==="export"&&(s[1]?(s[0]=Tt.export,s[2]=0,s[3]=1):s=null),i==="import"?s[0]&&(t=await Tt.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 me(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 ce,je,Jt;function xi(){ce=Jt=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]),ce?Jt||(Jt=Date.now()-je>=this.priority*this.priority*3):(ce=setTimeout(xi,0),je=Date.now()),Jt){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 ft=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=K(),this.worker)return n?this.worker.on("message",h):this.worker.onmessage=h,t.config?new Promise(function(c){ft>1e9&&(ft=0),r.h[++ft]=function(){c(r)},r.worker.postMessage({id:ft,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=bi(s,n,t.worker);return o.then?o.then(function(l){return e.call(r,l)}):e.call(this,o)}dt("add");dt("append");dt("search");dt("update");dt("remove");dt("clear");dt("export");dt("import");vt.prototype.searchCache=ge;me(vt.prototype);function dt(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),ft>1e9&&(ft=0),i.h[++ft]=r,i.worker.postMessage({task:t,id:ft,args:e})}),n?(s.then(n),this):s}}function bi(t,i,e){return i?typeof module<"u"?new(require("worker_threads")).Worker(__dirname+"/worker/node.js"):Ge(()=>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="+vi.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"})}xt.prototype.add=function(t,i,e){if(Yt(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]:G(h)&&(h=[h]),ae(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=K();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){G(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 Pt(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=K();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(G(c)||c.constructor===String){l[c]=i[c];continue}ue(i,l,c,0,c[0],u)}}this.store.set(t,l||i)}this.worker&&(this.fastupdate||this.reg.add(t))}return this};function ue(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++)ue(t,i,e,s,n);else i=i[n]||(i[n]=K()),n=e[++s],ue(t,i,e,s,n)}function ae(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++)ae(t,i,e,s,n,r,o,l);else o=i[++s],ae(t,i,e,s,n,r,o,l)}function ye(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?Ct.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?Ct.call(this,o):o;if(n.push(o),i-=l,!i)break}return n=n.length>1?[].concat.apply([],n):n[0],s?Ct.call(this,n):n}function ne(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 f=void 0;if(n.constructor===Y)f=n.await||n.result;else if(n.then||n.constructor===Array)f=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,f=n.queue;let m=n.async||f,a=n.index,g=n.query;if(a?t.index||(t.index=a):a=t.index,g||n.tag){const b=n.field||n.pluck;if(b&&(!g||t.query&&!d||(t.query=g,t.field=b,t.highlight=d),a=a.index.get(b)),f&&(w||t.await)){w=1;let v;const S=t.C.length,$=new Promise(function(C){v=C});(function(C,I){$.h=function(){I.index=null,I.resolve=!1;let P=m?C.searchAsync(I):C.search(I);return P.then?P.then(function(k){return t.C[S]=k=k.result||k,v(k),k}):(P=P.result||P,v(P),P)}})(a,Object.assign({},n)),t.C.push($),r[i]=$;continue}else n.resolve=!1,n.index=null,f=m?a.searchAsync(n):a.search(n),n.resolve=c,n.index=a}else if(n.and)f=Ht(n,"and",a);else if(n.or)f=Ht(n,"or",a);else if(n.not)f=Ht(n,"not",a);else if(n.xor)f=Ht(n,"xor",a);else continue}f.await?(w=1,f=f.await):f.then?(w=1,f=f.then(function(m){return m.result||m})):f=f.result||f,r[i]=f}if(w&&!t.await&&(t.await=new Promise(function(m){t.return=m})),w){const m=Promise.all(r).then(function(a){for(let g=0;g<t.C.length;g++)if(t.C[g]===m){t.C[g]=function(){return e.call(t,a,o,l,h,c,u,d)};break}we(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 Ht(t,i,e){t=t[i];const s=t[0]||t;return s.index||(s.index=e),e=new Y(s),t.length>1&&(e=e[i].apply(e,t.slice(1))),e}Y.prototype.or=function(){return ne(this,"or",ki,arguments)};function ki(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=We(t,i,e,!1,this.h),e=0)),n&&(this.await=null),n?this.resolve(i,e,s,o):this}Y.prototype.and=function(){return ne(this,"and",Si,arguments)};function Si(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=qt(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}Y.prototype.xor=function(){return ne(this,"xor",Mi,arguments)};function Mi(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=K();let u=0;for(let d=0,w;d<t.length;d++)if(w=t[d]){u<w.length&&(u=w.length);for(let f=0,m;f<w.length;f++)if(m=w[f])for(let a=0,g;a<m.length;a++)g=m[a],c[g]=c[g]?2:1}for(let d=0,w,f=0;d<u;d++)for(let m=0,a;m<t.length;m++)if((a=t[m])&&(w=a[d])){for(let g=0,b;g<w.length;g++)if(b=w[g],c[b]===1)if(r)r--;else if(n){if(h.push(b),h.length===i){t=h;break t}}else{const v=d+(m?l:0);if(h[v]||(h[v]=[]),h[v].push(b),++f===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}Y.prototype.not=function(){return ne(this,"not",Ai,arguments)};function Ai(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 Xt(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 f,m;typeof h=="object"&&(f=h.before,f===0&&(f=-1),m=h.after,m===0&&(m=-1),h=h.total||9e5),d=new Map;for(let jt=0,nt,Kt,ht;jt<i.length;jt++){let ct;if(s)ct=i,ht=s;else{var a=i[jt];if(ht=a.field,!ht)continue;ct=a.result}Kt=e.get(ht),nt=Kt.encoder,a=d.get(nt),typeof a!="string"&&(a=nt.encode(t),d.set(nt,a));for(let Z=0;Z<ct.length;Z++){var g=ct[Z].doc;if(!g||(g=Nt(g,ht),!g))continue;var b=g.trim().split(/\s+/);if(!b.length)continue;g="";var v=[];let ut=[];for(var S=-1,$=-1,C=0,I=0;I<b.length;I++){var P=b[I],k=nt.encode(P);k=k.length>1?k.join(" "):k[0];let D;if(k&&P){for(var _=P.length,R=(nt.split?P.replace(nt.split,""):P).length-k.length,O="",E=0,L=0;L<a.length;L++){var H=a[L];if(H){var N=H.length;N+=R<0?0:R,E&&N<=E||(H=k.indexOf(H),H>-1&&(O=(H?P.substring(0,H):"")+o+P.substring(H,H+N)+l+(H+N<_?P.substring(H+N):""),E=N,D=!0))}}O&&(h&&(S<0&&(S=g.length+(g?1:0)),$=g.length+(g?1:0)+O.length,C+=_,ut.push(v.length),v.push({match:O})),g+=(g?" ":"")+O)}if(!D)P=b[I],g+=(g?" ":"")+P,h&&v.push({text:P});else if(h&&C>=h)break}if(C=ut.length*(r.length-2),f||m||h&&g.length-C>h)if(C=h+C-w*2,I=$-S,f>0&&(I+=f),m>0&&(I+=m),I<=C)b=f?S-(f>0?f:0):S-((C-I)/2|0),v=m?$+(m>0?m:0):b+C,c||(b>0&&g.charAt(b)!==" "&&g.charAt(b-1)!==" "&&(b=g.indexOf(" ",b),b<0&&(b=0)),v<g.length&&g.charAt(v-1)!==" "&&g.charAt(v)!==" "&&(v=g.lastIndexOf(" ",v),v<$?v=$:++v)),g=(b?n:"")+g.substring(b,v)+(v<g.length?n:"");else{for($=[],S={},C={},I={},P={},k={},O=R=_=0,L=E=1;;){var X=void 0;for(let D=0,B;D<ut.length;D++){if(B=ut[D],O)if(R!==O){if(I[D+1])continue;if(B+=O,S[B]){_-=w,C[D+1]=1,I[D+1]=1;continue}if(B>=v.length-1){if(B>=v.length){I[D+1]=1,B>=b.length&&(C[D+1]=1);continue}_-=w}if(g=v[B].text,N=m&&k[D])if(N>0){if(g.length>N)if(I[D+1]=1,c)g=g.substring(0,N);else continue;(N-=g.length)||(N=-1),k[D]=N}else{I[D+1]=1;continue}if(_+g.length+1<=h)g=" "+g,$[D]+=g;else if(c)X=h-_-1,X>0&&(g=" "+g.substring(0,X),$[D]+=g),I[D+1]=1;else{I[D+1]=1;continue}}else{if(I[D])continue;if(B-=R,S[B]){_-=w,I[D]=1,C[D]=1;continue}if(B<=0){if(B<0){I[D]=1,C[D]=1;continue}_-=w}if(g=v[B].text,N=f&&P[D])if(N>0){if(g.length>N)if(I[D]=1,c)g=g.substring(g.length-N);else continue;(N-=g.length)||(N=-1),P[D]=N}else{I[D]=1;continue}if(_+g.length+1<=h)g+=" ",$[D]=g+$[D];else if(c)X=g.length+1-(h-_),X>=0&&X<g.length&&(g=g.substring(X)+" ",$[D]=g+$[D]),I[D]=1;else{I[D]=1;continue}}else{g=v[B].match,f&&(P[D]=f),m&&(k[D]=m),D&&_++;let kt;if(B?!D&&w&&(_+=w):(C[D]=1,I[D]=1),B>=b.length-1||B<v.length-1&&v[B+1].match?kt=1:w&&(_+=w),_-=r.length-2,!D||_+g.length<=h)$[D]=g;else{X=E=L=C[D]=0;break}kt&&(C[D+1]=1,I[D+1]=1)}_+=g.length,X=S[B]=1}if(X)R===O?O++:R++;else{if(R===O?E=0:L=0,!E&&!L)break;E?(R++,O=R):O++}}g="";for(let D=0,B;D<$.length;D++)B=(C[D]?D?" ":"":(D&&!n?" ":"")+n)+$[D],g+=B;n&&!C[$.length]&&(g+=n)}u&&(g=g.replace(u," ")),ct[Z].highlight=g}if(s)break}return i}function Y(t,i){if(!this||this.constructor!==Y)return new Y(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,we(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=Y.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 we(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?we(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?Ct.call(this.index,r):r:ye.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=Xt(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 qt(t,i,e,s,n,r,o){const l=t.length;let h=[],c,u;c=K();for(let d=0,w,f,m,a;d<i;d++)for(let g=0;g<l;g++)if(m=t[g],d<m.length&&(w=m[d]))for(let b=0;b<w.length;b++){if(f=w[b],(u=c[f])?c[f]++:(u=0,c[f]=1),a=h[u]||(h[u]=[]),!o){let v=d+(g||!n?0:r||0);a=a[v]||(a[v]=[])}if(a.push(f),o&&e&&u===l-1&&a.length-s===e)return s?a.slice(s):a}if(t=h.length)if(n)h=h.length>1?We(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 We(t,i,e,s,n){const r=[],o=K();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 f=0;f<d.length;f++)if(c=(s=d[f])&&s.length){for(let m=0;m<c;m++)if(l=s[m],!o[l])if(o[l]=1,e)e--;else{let a=(f+(u<h-1&&n||0))/(u+1)|0;if((r[a]||(r[a]=[])).push(l),++w===i)return r}}}return r}function Ii(t,i,e,s,n){const r=K(),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}K();xt.prototype.search=function(t,i,e,s){e||(!i&&Yt(t)?(e=t,t=""):Yt(i)&&(e=i,i=0));let n=[];var r=[];let o,l,h,c,u,d,w=0,f=!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 a=this.tag&&e.tag;h=e.suggest,f=e.resolve!==!1,u=e.cache,m=f&&this.store&&e.highlight;var g=!!m||f&&this.store&&e.enrich;i=e.limit||i;var b=e.offset||0;if(i||(i=f?100:0),a&&(!this.db||!s)){a.constructor!==Array&&(a=[a]);var v=[];for(let P=0,k;P<a.length;P++)if(k=a[P],k.field&&k.tag){var S=k.tag;if(S.constructor===Array)for(var $=0;$<S.length;$++)v.push(k.field,S[$]);else v.push(k.field,S)}else{S=Object.keys(k);for(let _=0,R,O;_<S.length;_++)if(R=S[_],O=k[R],O.constructor===Array)for($=0;$<O.length;$++)v.push(R,O[$]);else v.push(R,O)}if(a=v,!t){if(r=[],v.length)for(a=0;a<v.length;a+=2){if(this.db){if(s=this.index.get(v[a]),!s)continue;r.push(s=s.db.tag(v[a+1],i,b,g))}else s=$i.call(this,v[a],v[a+1],i,b,g);n.push(f?{field:v[a],tag:v[a+1],result:s}:[s])}if(r.length){const P=this;return Promise.all(r).then(function(k){for(let _=0;_<k.length;_++)f?n[_].result=k[_]:n[_]=k[_];return f?n:new Y(n.length>1?qt(n,1,0,0,h,c):n[0],P)})}return f?n:new Y(n.length>1?qt(n,1,0,0,h,c):n[0],this)}}f||o||!(d=d||this.field)||(G(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 C;v=(this.worker||this.db)&&!s&&[];for(let P=0,k,_,R;P<d.length;P++){if(_=d[P],this.db&&this.tag&&!this.B[P])continue;let O;if(G(_)||(O=_,_=O.field,t=O.query||t,i=At(O.limit,i),b=At(O.offset,b),h=At(O.suggest,h),m=f&&this.store&&At(O.highlight,m),g=!!m||f&&this.store&&At(O.enrich,g),u=At(O.cache,u)),s)k=s[P];else{S=O||e||{},$=S.enrich;var I=this.index.get(_);if(a&&(this.db&&(S.tag=a,S.field=d,C=I.db.support_tag_search),!C&&$&&(S.enrich=!1),C||(S.limit=0,S.offset=0)),k=u?I.searchCache(t,a&&!C?0:i,S):I.search(t,a&&!C?0:i,S),a&&!C&&(S.limit=i,S.offset=b),$&&(S.enrich=$),v){v[P]=k;continue}}if(R=(k=k.result||k)&&k.length,a&&R){if(S=[],$=0,this.db&&s){if(!C)for(I=d.length;I<s.length;I++){let E=s[I];if(E&&E.length)$++,S.push(E);else if(!h)return f?n:new Y(n,this)}}else for(let E=0,L,H;E<a.length;E+=2){if(L=this.tag.get(a[E]),!L){if(h)continue;return f?n:new Y(n,this)}if(H=(L=L&&L.get(a[E+1]))&&L.length)$++,S.push(L);else if(!h)return f?n:new Y(n,this)}if($){if(k=Ii(k,S,i,b,f),R=k.length,!R&&!h)return f?k:new Y(k,this);$--}}if(R)r[w]=_,n.push(k),w++;else if(d.length===1)return f?n:new Y(n,this)}if(v){if(this.db&&a&&a.length&&!C)for(g=0;g<a.length;g+=2){if(r=this.index.get(a[g]),!r){if(h)continue;return f?n:new Y(n,this)}v.push(r.db.tag(a[g+1],i,b,!1))}const P=this;return Promise.all(v).then(function(k){return e&&(e.resolve=f),k.length&&(k=P.search(t,i,e,k)),k})}if(!w)return f?n:new Y(n,this);if(o&&(!g||!this.store))return n=n[0],f?n:new Y(n,this);for(v=[],b=0;b<r.length;b++){if(a=n[b],g&&a.length&&typeof a[0].doc>"u"&&(this.db?v.push(a=this.index.get(this.field[0]).db.enrich(a)):a=Ct.call(this,a)),o)return f?m?Xt(t,a,this.index,o,m):a:new Y(a,this);n[b]={field:r[b],result:a}}if(g&&this.db&&v.length){const P=this;return Promise.all(v).then(function(k){for(let _=0;_<k.length;_++)n[_].result=k[_];return m&&(n=Xt(t,n,P.index,o,m)),l?_e(n):n})}return m&&(n=Xt(t,n,this.index,o,m)),l?_e(n):n};function _e(t){const i=[],e=K(),s=K();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 $i(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=Ct.call(this,t))),t):[]):[]}function Ct(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 xt(t){if(!this||this.constructor!==xt)return new xt(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)&&Gt(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 bt(e),t.cache=!1,this.worker=t.worker||!1,this.priority=t.priority||4,this.index=Ci.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]=Gt(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=xt.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 Ci(t,i){const e=new Map;let s=i.index||i.field||i;G(s)&&(s=[s]);for(let r=0,o,l;r<s.length;r++){if(o=s[r],G(o)||(l=o,o=o.field),l=Yt(l)?Object.assign({},t,l):t,this.worker){var n=void 0;n=(n=l.encoder)&&n.encode?n:new Dt(typeof n=="string"?pe[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]=Gt(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,G(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]=Gt(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 Gt(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){Yt(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=ge;A.export=Di;A.import=Pi;me(xt.prototype);function ve(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 He(t,i=0){let e=[],s=[];i&&(i=25e4/i*1e3|0);for(const n of t.entries())s.push([n[0],ve(n[1])[0]||[]]),s.length===i&&(e.push(s),s=[]);return s.length&&e.push(s),e}function Ue(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 Qe(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 Ve(t,i){i||(i=new Set);for(let e=0;e<t.length;e++)i.add(t[e]);return i}function te(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 te.call(c,t,i,e,l?s:null,n,r,o+1)})}return te.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=Qe(this.reg),i=null;break;case 1:n="tag",r=this.tag&&He(this.tag,this.reg.size),i=null;break;case 2:n="doc",r=this.store&&ve(this.store),i=null;break;default:return}return te.call(this,t,i,n,r||null,e,s)}function Pi(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=Ve(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=Ue(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&&Je(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 ji={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=K(),d=K(),w=this.resolution;for(let f=0;f<c;f++){let m=i[this.rtl?c-1-f:f];var n=m.length;if(n&&(s||!d[m])){var r=this.score?this.score(i,m,f,null,0):Ut(w,c,f),o="";switch(this.tokenize){case"tolerant":if(ot(this,d,m,r,t,e),n>2){for(let a=1,g,b,v,S;a<n-1;a++)g=m.charAt(a),b=m.charAt(a+1),v=m.substring(0,a)+b,S=m.substring(a+2),o=v+g+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 a=0,g;a<n;a++)for(r=n;r>a;r--){o=m.substring(a,r),g=this.rtl?n-1-a:a;var l=this.score?this.score(i,m,f,o,g):Ut(w,c,f,n,g);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,f,o,l):Ut(w,c,f,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&&f<c-1)for(n=this.N,o=m,r=Math.min(s+1,this.rtl?f+1:c-f),l=1;l<r;l++){m=i[this.rtl?c-1-f-l:f+l],h=this.bidirectional&&m>o;const a=this.score?this.score(i,o,f,m,l-1):Ut(n+(c/2>n?0:1),c,f,r-1,l-1);ot(this,u,h?o:m,a,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&&Je(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]=K()),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 Pt(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 Ut(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 f=this.encoder.encode(t,!r);if(n=f.length,i=i||(h?100:0),n===1)return Re.call(this,f[0],"",i,l,h,w,c);if(n===2&&r&&!o)return Re.call(this,f[1],f[0],i,l,h,w,c);let m=K(),a=0,g;if(r&&(g=f[0],a=1),d||d===0||(d=g?this.N:this.resolution),this.db){if(this.db.search&&(e=this.db.search(this,f,i,l,o,h,w,c),e!==!1))return e;const b=this;return(async function(){for(let v,S;a<n;a++){if((S=f[a])&&!m[S]){if(m[S]=1,v=await fe(b,S,g,0,0,!1,!1),v=ze(v,s,o,d)){s=v;break}g&&(o&&v&&s.length||(g=S))}o&&g&&a===n-1&&!s.length&&(d=b.resolution,g="",a=-1,m=K())}return Te(s,d,i,l,o,u,h)})()}for(let b,v;a<n;a++){if((v=f[a])&&!m[v]){if(m[v]=1,b=fe(this,v,g,0,0,!1,!1),b=ze(b,s,o,d)){s=b;break}g&&(o&&b&&s.length||(g=v))}o&&g&&a===n-1&&!s.length&&(d=this.resolution,g="",a=-1,m=K())}return Te(s,d,i,l,o,u,h)};function Te(t,i,e,s,n,r,o){let l=t.length,h=t;if(l>1)h=qt(t,i,e,s,n,r,o);else if(l===1)return o?ye.call(null,t[0],e,s):new Y(t[0],this);return o?h:new Y(h,this)}function Re(t,i,e,s,n,r,o){return t=fe(this,t,i,e,s,n,r,o),this.db?t.then(function(l){return n?l||[]:new Y(l,this)}):t&&t.length?n?ye.call(this,t,e,s):new Y(t,this):n?[]:new Y([],this)}function ze(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 fe(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=G(t)?t:t.preset;e&&(t=Object.assign({},ji[e],t))}else t={};e=t.context;const s=e===!0?{depth:1}:e||{},n=G(t.encoder)?pe[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 bt(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 Je(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=ge;A.export=function(t,i,e=0,s=0){let n,r;switch(s){case 0:n="reg",r=Qe(this.reg);break;case 1:n="cfg",r=null;break;case 2:n="map",r=ve(this.map,this.reg.size);break;case 3:n="ctx",r=He(this.ctx,this.reg.size);break;default:return}return te.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=Ve(i,this.reg);break;case"map":this.map=xe(i,this.map);break;case"ctx":this.ctx=Ue(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};me(it.prototype);const Xe=typeof window<"u"&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),ee=["map","ctx","tag","reg","cfg"],yt=K();function ie(t,i={}){if(!this||this.constructor!==ie)return new ie(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=ie.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=Xe.open(t.id,1);return i.onupgradeneeded=function(){const e=t.db=this.result;for(let s=0,n;s<ee.length;s++){n=ee[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=gt(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=Xe.deleteDatabase(this.id);return gt(t)};A.clear=function(){const t=[];for(let e=0,s;e<ee.length;e++){s=ee[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 gt(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 gt(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 gt(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]=gt(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),gt(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,gt(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 f=0,m,a;f<w;f++)if((a=c[f])&&a.length){if((m=u[f])&&m.length)for(d=0;d<a.length;d++)m.push(a[d]);else u[f]=a;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 he(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&&he(e,t)}}),this.transaction("ctx","readwrite",function(i){i.openCursor().onsuccess=function(){const e=this.result;e&&he(e,t)}}),this.transaction("tag","readwrite",function(i){i.openCursor().onsuccess=function(){const e=this.result;e&&he(e,t,!0)}}),this.transaction("reg","readwrite",function(i){for(let e=0;e<t.length;e++)i.delete(t[e])})])};function gt(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:pe,Encoder:Dt,Document:xt,Worker:vt,Resolver:Y,IndexedDB:ie,Language:{}};const Oi=""+new URL("year-in-posts-B2lywqdx.png",import.meta.url).href,Et="year-in-posts-list";function Ti(){try{const t=Bt.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 Ri(t){try{const e=`${de()}-${t}`;await Zt.yearInPosts.del(e);const s=Bt.account.get(Et)||{};return delete s[t],Bt.account.set(Et,s),!0}catch(i){throw i}}function zi(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}=Ne(),s=[];let n=!1;const r=ti();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 di(e);let d=null;if(u)try{const S=await i.v1.accounts.$select(o).statuses.list({limit:1,exclude_replies:!1,exclude_reblogs:!1}).values().next();if(S?.value?.length){const $=S.value[0];if(!zi($.createdAt,t)){const C=`${t+1}-01-02`;try{const I=await i.v2.search.list({q:`from:${l} before:${C}`,type:"statuses",limit:1});I?.statuses?.length&&(d=I.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();t:for(;;)try{const v=await w.next(),{value:S,done:$}=v;if($||!S?.length)break t;let C=!1;for(const I of S){const P=new Date(I.createdAt);P>c||P>=h&&(s.push(I),C=!0)}if(!C)break t;await new Promise(I=>setTimeout(I,500))}catch{break t}if(s.sort((v,S)=>new Date(v.createdAt)-new Date(S.createdAt)),s.length>0)try{const S=s[0].id,$=i.v1.accounts.$select(o).statuses.list({limit:40,min_id:S,exclude_replies:!1,exclude_reblogs:!1}).values();t:for(;;)try{const C=await $.next(),{value:I,done:P}=C;if(P||!I?.length)break t;let k=!1;for(const _ of I){const R=new Date(_.createdAt);R<h||R<=c&&(s.find(O=>O.id===_.id)||(s.push(_),n=!0),k=!0)}if(!k)break t;await new Promise(_=>setTimeout(_,500))}catch{break t}n&&s.sort((C,I)=>new Date(C.createdAt)-new Date(I.createdAt))}catch{}let f=0;try{f=new TextEncoder().encode(JSON.stringify(s)).length}catch{}const a=`${de()}-${t}`,g=new Date().getTimezoneOffset();await Zt.yearInPosts.set(a,{id:a,posts:s,count:s.length,year:t,size:f,fetchedAt:Date.now(),timezoneOffset:g});const b=Bt.account.get(Et)||{};return b[t]={count:s.length,size:f,fetchedAt:Date.now(),timezoneOffset:g},Bt.account.set(Et,b),{posts:s,searchEnabled:u,gapsFilled:n}}const Ze=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 Qt(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 Yi(){return new Date().getTimezoneOffset()}const Ni={all:"All",original:"Original",replies:"Replies",quotes:"Quotes",boosts:"Boosts",media:"Media"},Fi=[{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 ri(i,{month:e}).format(s)}function Ye(t){return t=parseInt(t,10),t>=Ze&&t<=new Date().getFullYear()?t:null}function Ei(t){return t=parseInt(t,10),t>=0&&t<=11?t:null}const Vt=30;function Ji(){const{i18n:t}=Fe(),[i,e]=ei(),s=i.get("year"),n=i.get("month"),[r,o]=q("all"),[l,h]=q(""),c=Ye(s),u=Ei(n);ii(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}=Ne(),[w,f]=q("default"),[m,a]=q([]),[g,b]=q([]),[v,S]=q(!0),[$,C]=q(!!l),[I,P]=q(Vt),[k,_]=q(l?"relevance":"createdAt"),[R,O]=q("asc"),E=zt(null),L=zt(null),H=pt(()=>de(),[]);oi(["Slash","/"],y=>{$?E.current?.focus():(C(!0),setTimeout(()=>{E.current?.focus()},100))},{useKey:!0,preventDefault:!0,ignoreEventWhen:y=>{const M=!!document.querySelector("#modal-container > *"),x=["INPUT","TEXTAREA"].includes(y.target.tagName);return M||x||y.metaKey||y.ctrlKey||y.altKey||y.shiftKey}});const N=m.length;at(()=>{l||E.current?.isFocused()||C(!1)},[l,n,r,k,R]);function X(){const y=Ti();b(y)}at(()=>{c||X()},[c]);const jt=async y=>{y.preventDefault();const M=Ye(y.target.elements.year.value);if(M)try{const x=`${H}-${M}`,j=await Zt.yearInPosts.get(x);j&&j.year===M?e({year:M}):(f("generating"),await Be(M),e({year:M}))}catch{f("error"),oe("Unable to generate year posts. Please try again.")}finally{w==="generating"&&f("default")}else oe("Invalid year.")};async function nt(y){try{f("generating"),await Be(y),e({year:y})}catch{f("error"),oe("Unable to regenerate year posts. Please try again.")}finally{w==="generating"&&f("default")}}async function Kt(y){if(confirm(`Remove year ${y} posts?`))try{await Ri(y),b(M=>M.filter(x=>x.year!==y))}catch{alert("Failed to remove year data")}}const ht=pt(()=>{const y={};m.forEach(x=>{const j=new Date(x.createdAt),T=j.getMonth(),F=j.getDate();y[T]||(y[T]={}),y[T][F]||(y[T][F]={total:0,original:0,reply:0,quote:0,boost:0});const z=y[T][F];z.total++,x.reblog?z.boost++:Ot()&&(x.quote?.id||x.quote?.quotedStatus?.id)?z.quote++:x.inReplyToId?z.reply++:z.original++});const M={};return Object.keys(y).forEach(x=>{const j=y[x],T=Math.max(...Object.values(j).map(Q=>Q.total)),z=new Date(c,parseInt(x),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&&T>0?Mt/T: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[x]=U}),M},[m,c]),ct=pt(()=>{if(r!=="media")return{};const y={};return m.forEach(M=>{const x=new Date(M.createdAt),j=x.getMonth(),T=x.getDate();y[j]||(y[j]={}),y[j][T]||(y[j][T]=[]),y[j][T].push(M)}),Object.keys(y).forEach(M=>{const x=y[M],T=new Date(c,parseInt(M),1).getDay(),F=[];for(let z=0;z<T;z++)F.push(null);for(let z=1;z<=31;z++){const U=x[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,be=(rt.favouritesCount||0)+(rt.reblogsCount||0)+(rt.repliesCount||0)+(rt.quotesCount||0),ke=V?(V.favouritesCount||0)+(V.reblogsCount||0)+(V.repliesCount||0)+(V.quotesCount||0):-1;return be>ke?_t:be===ke?V||_t:V},null),st=!0)}F.push(Q?{post:Q,hasMedia:st}:{hasMedia:st})}y[M]=F}),y},[m,c,r]),Z=pt(()=>{const y={},M={};return m.forEach(x=>{const j=new Date(x.createdAt).getMonth();y[j]=(y[j]||0)+1,M[j]||(M[j]={original:0,reply:0,quote:0,boost:0}),x.reblog?M[j].boost++:Ot()&&(x.quote?.id||x.quote?.quotedStatus?.id)?M[j].quote++:x.inReplyToId?M[j].reply++:M[j].original++}),Object.entries(y).map(([x,j])=>{const T=M[x];return{month:parseInt(x),count:j,heatmap:ht[x]||[],mediaGrid:ct[x]||[],original:T.original,reply:T.reply,quote:T.quote,boost:T.boost}}).sort((x,j)=>x.month-j.month)},[m,ht,ct]),ut=zt(null);at(()=>{if(N>0){const y=new _i.Document({preset:"match",document:{id:"id",index:["content","spoilerText","poll","media","card"]}});m.forEach(M=>{const x=M.reblog||M,j=x.poll?.options?.map(z=>z.title).join(" "),T=x.mediaAttachments?.map(z=>z.description).join(" "),F=x.card?`${x.card.title} ${x.card.description} ${x.card.url}`:"";y.add({id:M.id,content:li(x.content),spoilerText:x.spoilerText,poll:j,media:T,card:F})}),ut.current=y}},[m]);const D=pt(()=>{if(!l)return m;if(!ut.current)return[];console.time(`search: '${l}'`);const y=ut.current.search(l,{limit:N});console.timeEnd(`search: '${l}'`);const M=y.flatMap(F=>F.result),x=[...new Set(M)],j=new Map(m.map(F=>[F.id,F]));return x.map(F=>j.get(F)).filter(Boolean)},[m,l]);at(()=>{P(Vt),l?["relevance","createdAt"].includes(k)||_("relevance"):k==="relevance"&&_("createdAt")},[l,k]);const[B,kt]=pt(()=>{const y=D.filter(x=>{if(l)return!0;const j=new Date(x.createdAt).getMonth();return u!==null&&j===u}),M={all:y.length,original:0,replies:0,quotes:0,boosts:0,media:0};return y.forEach(x=>{x.reblog?M.boosts++:Ot()&&(x.quote?.id||x.quote?.quotedStatus?.id)?M.quotes++:x.inReplyToId?M.replies++:M.original++;const j=x.reblog||x;!x.reblog&&j.mediaAttachments?.length>0&&M.media++}),[M,y]},[D,u,l]),[St,qe]=pt(()=>{const y=kt.filter(x=>{if(r==="boosts")return!!x.reblog;if(r==="media"){const j=x.reblog||x;return!x.reblog&&j.mediaAttachments?.length>0}else{if(r==="quotes")return Ot()&&(x.quote?.id||x.quote?.quotedStatus?.id);if(r==="replies")return!!x.inReplyToId;if(r==="original")return!x.reblog&&!(Ot()&&(x.quote?.id||x.quote?.quotedStatus?.id))&&!x.inReplyToId}return!0});let M=y;return k!=="relevance"&&(M=[...y].sort((x,j)=>{const T=x.reblog||x,F=j.reblog||j;let z,U;return k==="createdAt"?(z=new Date(x.createdAt),U=new Date(j.createdAt)):(z=T[k]||0,U=F[k]||0),R==="asc"?z>U?1:-1:U>z?1:-1})),l?[M.slice(0,I),M.length>I]:[M,!1]},[kt,r,l,I,k,R]);at(()=>{l&&r!=="all"&&St.length===0&&B.all>0&&o("all")},[l,r,St.length,B.all]);const Lt=Z.findIndex(y=>y.month===u),se=Lt>0?Z[Lt-1]:null,re=Lt<Z.length-1?Z[Lt+1]:null;return at(()=>{if(!c){f("default"),a([]);return}(async()=>{f("loading");try{const y=`${H}-${c}`;console.time(`fetchYearPosts-${c}`);const M=await Zt.yearInPosts.get(y);console.timeEnd(`fetchYearPosts-${c}`),M&&M.year===c?(M.posts.sort((x,j)=>new Date(x.createdAt)-new Date(j.createdAt)),a(M.posts),f("results")):f("no-data")}catch{f("error")}})()},[c]),at(()=>{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"]),p("div",{ref:L,id:"year-in-posts-page",class:"deck-container",tabIndex:"-1",style:{"--month":u||0},children:[p("div",{class:"timeline-deck deck",children:[p("header",{class:w==="loading"?"loading":"",onClick:y=>{y.target.closest("a, button")||L.current?.scrollTo({top:0,behavior:"smooth"})},children:p("div",{class:"header-grid",children:[p("div",{class:"header-side",children:[p(gi,{}),c&&u!==null?p(lt,{to:`/yip?year=${c}`,class:"button plain",onClick:()=>{h("")},children:p(J,{icon:"grid",size:"l",alt:"Year in Posts"})}):c?p(lt,{to:"/yip",class:"button plain",onClick:()=>{h("")},children:p(J,{icon:"month",size:"l",alt:"Year in Posts"})}):p(lt,{to:"/",class:"button plain",children:p(J,{icon:"home",size:"l",alt:"Home"})})]}),c&&p(mt,{children:$?p(Wi,{ref:E,placeholder:`Search posts in ${c}…`,searchQuery:l,onSearch:y=>{h(y),P(Vt)},onEscape:()=>{l.trim()||(C(!1),h(""))}}):p("h1",{class:"header-double-lines",children:[p("b",{children:c}),w==="results"&&p("div",{children:u!==null?`${Rt(u)} – ${Z[u].count} posts`:`${m.length} posts`})]})}),p("div",{class:"header-side",children:c&&p(mt,{children:[p("button",{type:"button",class:`plain ${$?"is-active":""}`,onClick:()=>{$?(C(!1),h("")):(C(!0),setTimeout(()=>{E.current?.focus()},100))},children:p(J,{icon:"search",size:"l",alt:"Search"})}),p(hi,{align:"end",menuButton:p("button",{type:"button",class:"plain",children:p(J,{icon:"more",size:"l",alt:"More"})}),children:p(ci,{type:"checkbox",checked:r==="media",onClick:()=>{o(r==="media"?"all":"media")},children:[p(J,{icon:"check-circle",alt:"☑️"})," ",p("span",{class:"menu-grow",children:"Media only"})]})})]})})]})}),p("main",{children:[!c&&p("div",{class:"year-in-posts-start",children:[w!=="generating"?p(mt,{children:[p("h1",{children:["Year in Posts ",p("sup",{children:"beta"})]}),p("p",{children:"A year-at-a-glance view of your posts."}),p("details",{children:[p("summary",{children:"What is this?"}),p("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."}),p("img",{src:Oi,width:"1200",height:"900",alt:"Preview of Year in Posts UI"}),p("p",{children:p("button",{type:"button",onClick:y=>{y.target.closest("details").open=!1},children:"Let's explore my posts"})})]}),p("form",{class:"year-generate",onSubmit:jt,children:[p("label",{children:p("input",{type:"number",min:Ze,max:new Date().getFullYear(),name:"year",defaultValue:Bi(),disabled:w==="generating"})}),p("button",{type:"submit",disabled:w==="generating",children:p(J,{icon:"arrow-right",alt:"Generate",size:"l"})})]}),p("div",{class:"insignificant",children:p("small",{children:[p("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."}),p("p",{children:"Once archived, updated or deleted posts are not reflected in the archive until regenerated."})]})}),!v&&p("p",{class:"insignificant",children:p("small",{children:"⚠️ Your server doesn't support advanced search, this will make more requests to the server and take much longer time."})})]}):p("div",{class:"ui-state year-in-posts-start",children:[p(Se,{abrupt:!0}),p("p",{class:"insignificant",children:"Generating Year in Posts…"}),p("p",{class:"insignificant",children:"This might take a while."})]}),g.length>0&&w!=="generating"&&p("div",{class:"year-selection",children:[p("p",{children:"Archived Year in Posts:"}),p("ul",{children:g.map(({year:y,count:M,fetchedAt:x,size:j,timezoneOffset:T})=>{const F=Yi(),z=T!==void 0&&T!==F;return p("li",{children:[p(lt,{to:`/yip?year=${y}`,class:"year-card available",children:[p(J,{icon:"month"})," ",y]})," ",p("small",{class:"ib insignificant",children:[M," posts"," "]})," ",j&&p("small",{class:"tag insignificant collapsed",title:`${j.toLocaleString(t.locale||void 0)} bytes`,children:["~",ui(j)]})," ",p(ai,{align:"end",confirmLabel:p("span",{children:["Regenerate ",y," posts?"]}),onClick:()=>{nt(y)},children:p("button",{type:"button",class:"light small",disabled:w==="loading",title:x,children:[p(J,{icon:"refresh",size:"s",class:"insignificant"})," ",p("span",{class:"insignificant",children:new Date(x).toLocaleDateString(t.locale,{year:"numeric",month:"short",day:"numeric"})})," ",T!==void 0&&p("small",{class:`tag insignificant collapsed ${z?"warn":""}`,title:z?`Generated in ${Qt(T)}, current timezone is ${Qt(F)}`:Qt(T),children:[z&&p(J,{icon:"time"}),Qt(T)]})]})}),p("button",{type:"button",class:"light danger small",onClick:U=>{U.preventDefault(),Kt(y)},children:p(J,{icon:"x",alt:"Remove"})})]},y)})})]})]}),c&&w==="loading"&&p("div",{class:"ui-state year-in-posts-start",children:p(Se,{abrupt:!0})}),c&&w==="results"&&p(mt,{children:[!l&&Z.length>0&&p(Li,{year:c,month:u,monthsWithPosts:Z,postType:r}),(u!==null||l)&&p("div",{class:"post-type-filters",children:Object.entries(Ni).map(([y,M])=>B[y]>0&&p("button",{type:"button",class:`filter-cat plain ${r===y?"is-active":""}`,onClick:()=>o(y),children:[M," ",p("span",{class:"count",children:B[y]})]},y))}),(u!==null||l)&&St.length>1&&p("div",{class:"sort-controls",children:[p("span",{class:"filter-label",children:"Sort"})," ",p("fieldset",{class:"radio-field-group",children:Fi.filter(y=>y.key==="relevance"?!!l:y.key==="createdAt"?!0:!l).map(({key:y})=>p("label",{class:"filter-sort",onClick:M=>{k===y&&y!=="relevance"&&(M.preventDefault(),M.stopPropagation(),O(R==="asc"?"desc":"asc"))},children:[p("input",{type:"radio",name:"filter-sort-cat",checked:k===y,onChange:()=>{_(y);const M=/(replies|favourites|reblogs)/.test(y)?"desc":"asc";O(M)}}),{relevance:"Relevance",createdAt:"Date",repliesCount:"Replies",favouritesCount:"Likes",reblogsCount:"Boosts"}[y],k===y&&y!=="relevance"&&(R==="asc"?" ↑":" ↓")]},y))})]}),(u!==null||l)&&p(mt,{children:[p("ul",{class:"timeline",children:St.length===0?p("p",{class:"ui-state insignificant",children:"…"}):St.map((y,M)=>{const x=new Date(y.createdAt),j=St[M-1],T=j?new Date(j.createdAt):null,F=k==="createdAt"&&(!T||x.toDateString()!==T.toDateString());return p(mt,{children:[F&&p("li",{class:"date-header",children:p("h2",{children:[p("span",{children:Me(y.createdAt,{hideTime:!0,formatOpts:{year:void 0}})})," ",p("small",{class:"insignificant bidi-isolate",children:Me(y.createdAt,{forceOpts:{weekday:"long"}})})]})},y.createdAt),p("li",{children:N>20?p(Ki,{root:L.current,post:y,instance:d},y.id):p(lt,{class:"status-link timeline-item",to:y.reblog?`/${d}/s/${y.reblog.id}`:`/${d}/s/${y.id}`,children:p(Ee,{status:y,instance:d,size:"m",showCommentCount:!0,showQuoteCount:!0})})},y.id)]})})}),l&&qe&&p("div",{class:"ui-state",children:p("button",{type:"button",class:"plain6 block",onClick:()=>P(y=>y+Vt),children:"More…"})}),!l&&p("div",{class:"year-in-posts-nav",children:[se?p(lt,{to:`/yip?year=${c}&month=${se.month}`,class:"button light",onClick:()=>{L.current?.scrollTo({top:0,behavior:"instant"})},children:[p(J,{icon:"arrow-left"})," ",Rt(se.month,t.locale,"long")]}):p("span",{}),re&&p(lt,{to:`/yip?year=${c}&month=${re.month}`,class:"button light",onClick:()=>{L.current?.scrollTo({top:0,behavior:"instant"})},children:[Rt(re.month,t.locale,"long")," ",p(J,{icon:"arrow-right"})]})]})]})]})]})]}),p("div",{class:`tron-grid ${u===null?"animated":""}`})]})}const Ki=({root:t,post:i,instance:e})=>{const s=zt(),[n,r]=q(!1);at(()=>{const l=new IntersectionObserver(h=>{h[0].isIntersecting&&(queueMicrotask(()=>r(!0)),l.unobserve(s.current))},{root:t,rootMargin:`${Math.max(320,screen.height*.75)}px`});return s.current&&l.observe(s.current),()=>{s.current&&l.unobserve(s.current)}},[]);const o=i.reblog?.id||i.id;return p("li",{ref:s,style:{height:n?void 0:"10em"},children:n?p(lt,{class:"status-link timeline-item",to:`/${e}/s/${o}`,children:p(Ee,{status:i,instance:e,size:"m",showCommentCount:!0,showQuoteCount:!0})}):p(mt,{children:" "})})};function Li({year:t,month:i,monthsWithPosts:e,postType:s}){const{i18n:n}=Fe();return p("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 f=o>0?c/o:0,m=o>0?u/o:0,a=o>0?d/o:0,g=o>0?w/o:0;return p(lt,{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":f,"--month-reply-ratio":m,"--month-quote-ratio":a,"--month-boost-ratio":g},"data-month":r,children:[p("div",{class:"month-name",children:Rt(r,n.locale)}),s==="media"?h.length>0&&p("div",{class:"month-media-grid",children:h.map((b,v)=>{if(!b)return p("span",{class:"media-day empty"},v);if(!b.hasMedia)return p("span",{class:"media-day no-media"},v);const $=b.post.mediaAttachments?.[0];return p("span",{class:"media-day",children:p("img",{src:$.previewUrl||$.url,loading:"lazy",decoding:"async",onError:C=>{const{src:I}=C.target;I===$.previewUrl||I===$.url?C.target.src=$.previewRemoteUrl||$.remoteUrl:C.target.remove()},alt:""})},v)})}):l.length>0&&p("div",{class:"month-heatmap",children:l.map((b,v)=>{const S=b.count||0,$=S>0?b.original/S:0,C=S>0?b.reply/S:0,I=S>0?b.quote/S:0,P=S>0?b.boost/S:0;return p("span",{class:`heatmap-day ${b.day===null?"empty":""} ${v%7===0||v%7===6?"weekend":""}`,"data-ratio":b.ratio,style:{"--ratio":b.ratio,"--original-ratio":$,"--reply-ratio":C,"--quote-ratio":I,"--boost-ratio":P}},v)})}),p("div",{class:"month-metadata",children:[o," posts "]})]},r)})})}const Wi=ni(({searchQuery:t,onSearch:i,placeholder:e,onEscape:s},n)=>{const r=zt(null);si(n,()=>({focus:()=>{r.current?.focus()},setValue:l=>{r.current.value=l},isFocused:()=>document.activeElement===r.current}));const o=fi(i,150);return p("form",{class:"search-field",onSubmit:l=>{l.preventDefault();const h=r.current.value.trim();o?.cancel(),o(h)},children:p("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{Ji as default};
|
||
//# sourceMappingURL=year-in-posts-w9jDim8R.js.map
|