internxt-crypto 0.0.7-alpha → 0.0.8-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1282 -1253
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const We=require("hash-wasm"),Vt=require("buffer"),Di=require("uuid");var kr=typeof document<"u"?document.currentScript:null;const Ne="AES-GCM",G=256,Ks=128,Os=16,Jt="AES-KW",Le="raw",Rs="CRYPTO library 2025-08-22 18:10:00 key derived from ecc and kyber secrets",at="X25519",Cs="CRYPTO library 2025-07-26 16:18:03 key for opening identity keystore",Is="CRYPTO library 2025-07-30 16:18:03 key for opening encryption keys keystore",Ps="CRYPTO library 2025-07-30 16:20:00 key for account recovery",js="CRYPTO library 2025-07-30 17:20:00 key for protecting current search indices",Bs="CRYPTO library 2025-08-27 17:08:00 derive one key from two keys",Pr="CRYPTO library 2025-08-28 18:27:00 ratchet media key",Fs="CRYPTO library 2025-08-26 18:29:00 prefix for commitment to media keys",Mi="CRYPTO library 2025-08-26 18:30:00 prefix for commitment to public keys",Ui="CRYPTO library 2025-08-26 18:45:00 prefix for commitment to identity keys",Ns=3,Ls=4,Ds=65536,Ms=16,Us=32,rn="Identity keystore",nn="Encryption keystore",sn="Key recovery keystroe",Hi="Current encrypted indices",zi=800,$i=1632,Yi=1184,Vi=2400,Ji=1568,Gi=3168,Xi=64,Gt=256,Hs=6e8,jr=100,q="email",zs=1;async function on(e,t){try{const r=await crypto.subtle.deriveBits({name:at,public:e},t,G);return new Uint8Array(r)}catch(r){throw new Error("Failed to derive elliptic curve secret key",{cause:r})}}async function Xt(){try{return await crypto.subtle.generateKey({name:at},!0,["deriveBits"])}catch(e){throw new Error("Failed to generate elliptic curve key pair",{cause:e})}}async function qt(e){try{const t=await crypto.subtle.exportKey("spki",e);return new Uint8Array(t)}catch(t){throw new Error("Failed to export public key",{cause:t})}}async function Wt(e){try{return await crypto.subtle.importKey("spki",e,{name:at},!0,[])}catch(t){throw new Error("Failed to import public key",{cause:t})}}async function cn(e){try{const t=await crypto.subtle.exportKey("pkcs8",e);return new Uint8Array(t)}catch(t){throw new Error("Failed to export private key",{cause:t})}}async function an(e){try{return await crypto.subtle.importKey("pkcs8",e,{name:at},!0,["deriveBits"])}catch(t){throw new Error("Failed to import private key",{cause:t})}}const qi=Object.freeze(Object.defineProperty({__proto__:null,deriveSecretKey:on,exportPrivateKey:cn,exportPublicKey:qt,generateEccKeys:Xt,importPrivateKey:an,importPublicKey:Wt},Symbol.toStringTag,{value:"Module"}));function Ze(e){return Vt.Buffer.from(e).toString("hex")}function Zt(e){return new TextEncoder().encode(e)}function ln(e){return new TextDecoder().decode(e)}function It(e){return new Uint8Array(Vt.Buffer.from(e,"hex"))}function U(e){return Vt.Buffer.from(e).toString("base64")}function D(e){return new Uint8Array(Vt.Buffer.from(e,"base64"))}function _e(e){try{const t=U(e.iv),r=U(e.ciphertext),n=JSON.stringify({ciphertext:r,iv:t});return btoa(n)}catch(t){throw new Error("Failed to convert ciphertext to base64",{cause:t})}}function Qt(e){try{const t=atob(e),r=JSON.parse(t),n=D(r.iv);return{ciphertext:D(r.ciphertext),iv:n}}catch(t){throw new Error("Failed to convert base64 to ciphertext",{cause:t})}}async function $s(e){try{const t=await qt(e.userPublicKey),r=await cn(e.userPrivateKey),n=JSON.stringify({userPublicKey:U(t),userPrivateKey:U(r)});return btoa(n)}catch(t){throw new Error("Failed to convert identity keys to base64",{cause:t})}}async function Ys(e){try{const t=await qt(e.userPublicKey),r=await cn(e.userPrivateKey),n=JSON.stringify({userPublicKey:U(t),userPrivateKey:U(r),userPublicKyberKey:U(e.userPublicKyberKey),userPrivateKyberKey:U(e.userPrivateKyberKey)});return btoa(n)}catch(t){throw new Error("Failed to convert identity keys to base64",{cause:t})}}function Vs(e){try{const t=_e(e.encryptedKeys),r=JSON.stringify({userID:e.userID,type:e.type.toString(),encryptedKeys:t});return btoa(r)}catch(t){throw new Error("Failed to convert encrypted keystore to base64",{cause:t})}}async function Js(e){try{const t=atob(e),r=JSON.parse(t),n=D(r.userPublicKey),s=D(r.userPrivateKey),o=await Wt(n),i=await an(s);return{userPublicKey:o,userPrivateKey:i}}catch(t){throw new Error("Failed convert base64 to idenity key",{cause:t})}}async function un(e){try{const t=atob(e),r=JSON.parse(t),n=D(r.userPublicKey),s=D(r.userPrivateKey),o=await Wt(n),i=await an(s),c=D(r.userPublicKyberKey),a=D(r.userPrivateKyberKey);return{userPublicKey:o,userPrivateKey:i,userPublicKyberKey:c,userPrivateKyberKey:a}}catch(t){throw new Error("Failed to convert base64 to encryption key",{cause:t})}}function Gs(e){try{const t=atob(e),r=JSON.parse(t),n=Qt(r.encryptedKeys);return{userID:r.userID,type:r.type,encryptedKeys:n}}catch(t){throw new Error("Failed to convert base64 to encrypted keystore",{cause:t})}}function Xs(e){try{const t=JSON.stringify({olmKey:U(e.olmKey),pqKey:U(e.pqKey),index:e.index.toString(),userID:e.userID});return btoa(t)}catch(t){throw new Error("Failed to convert media keys to base64",{cause:t})}}async function Wi(e){try{const t=atob(e),r=JSON.parse(t);return{olmKey:D(r.olmKey),pqKey:D(r.pqKey),index:Number(r.index),userID:r.userID}}catch(t){throw new Error("Failed convert base64 to media keys",{cause:t})}}const Oe=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Zi(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Br(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Se(e,...t){if(!Zi(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Pt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function qs(e,t){Se(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ws(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Qe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function vr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function se(e,t){return e<<32-t|e>>>t}const Qi=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ec(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function tc(e){for(let t=0;t<e.length;t++)e[t]=ec(e[t]);return e}const $n=Qi?e=>e:tc,rc=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",ce={_0:48,_9:57,A:65,F:70,a:97,f:102};function Yn(e){if(e>=ce._0&&e<=ce._9)return e-ce._0;if(e>=ce.A&&e<=ce.F)return e-(ce.A-10);if(e>=ce.a&&e<=ce.f)return e-(ce.a-10)}function X(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(rc)return Uint8Array.fromHex(e);const t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let s=0,o=0;s<r;s++,o+=2){const i=Yn(e.charCodeAt(o)),c=Yn(e.charCodeAt(o+1));if(i===void 0||c===void 0){const a=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+o)}n[s]=i*16+c}return n}function nc(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function er(e){return typeof e=="string"&&(e=nc(e)),Se(e),e}class Zs{}function Qs(e){const t=n=>e().update(er(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function sc(e){const t=(n,s)=>e(s).update(er(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function eo(e=32){if(Oe&&typeof Oe.getRandomValues=="function")return Oe.getRandomValues(new Uint8Array(e));if(Oe&&typeof Oe.randomBytes=="function")return Uint8Array.from(Oe.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function oc(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const s=BigInt(32),o=BigInt(4294967295),i=Number(r>>s&o),c=Number(r&o),a=n?4:0,l=n?0:4;e.setUint32(t+a,i,n),e.setUint32(t+l,c,n)}function ic(e,t,r){return e&t^~e&r}function cc(e,t,r){return e&t^e&r^t&r}class ac extends Zs{constructor(t,r,n,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=s,this.buffer=new Uint8Array(t),this.view=vr(this.buffer)}update(t){Pt(this),t=er(t),Se(t);const{view:r,buffer:n,blockLen:s}=this,o=t.length;for(let i=0;i<o;){const c=Math.min(s-this.pos,o-i);if(c===s){const a=vr(t);for(;s<=o-i;i+=s)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===s&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Pt(this),qs(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:s,isLE:o}=this;let{pos:i}=this;r[i++]=128,Qe(this.buffer.subarray(i)),this.padOffset>s-i&&(this.process(n,0),i=0);for(let h=i;h<s;h++)r[h]=0;oc(n,s-8,BigInt(this.length*8),o),this.process(n,0);const c=vr(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<l;h++)c.setUint32(4*h,u[h],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:s,finished:o,destroyed:i,pos:c}=this;return t.destroyed=i,t.finished=o,t.length=s,t.pos=c,s%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}}const he=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),gt=BigInt(2**32-1),Vn=BigInt(32);function lc(e,t=!1){return t?{h:Number(e>),l:Number(e>>Vn>)}:{h:Number(e>>Vn>)|0,l:Number(e>)|0}}function uc(e,t=!1){const r=e.length;let n=new Uint32Array(r),s=new Uint32Array(r);for(let o=0;o<r;o++){const{h:i,l:c}=lc(e[o],t);[n[o],s[o]]=[i,c]}return[n,s]}const hc=(e,t,r)=>e<<r|t>>>32-r,fc=(e,t,r)=>t<<r|e>>>32-r,dc=(e,t,r)=>t<<r-32|e>>>64-r,pc=(e,t,r)=>e<<r-32|t>>>64-r,yc=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),fe=new Uint32Array(64);class mc extends ac{constructor(t=32){super(64,t,8,!1),this.A=he[0]|0,this.B=he[1]|0,this.C=he[2]|0,this.D=he[3]|0,this.E=he[4]|0,this.F=he[5]|0,this.G=he[6]|0,this.H=he[7]|0}get(){const{A:t,B:r,C:n,D:s,E:o,F:i,G:c,H:a}=this;return[t,r,n,s,o,i,c,a]}set(t,r,n,s,o,i,c,a){this.A=t|0,this.B=r|0,this.C=n|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,r){for(let h=0;h<16;h++,r+=4)fe[h]=t.getUint32(r,!1);for(let h=16;h<64;h++){const m=fe[h-15],y=fe[h-2],p=se(m,7)^se(m,18)^m>>>3,f=se(y,17)^se(y,19)^y>>>10;fe[h]=f+fe[h-7]+p+fe[h-16]|0}let{A:n,B:s,C:o,D:i,E:c,F:a,G:l,H:u}=this;for(let h=0;h<64;h++){const m=se(c,6)^se(c,11)^se(c,25),y=u+m+ic(c,a,l)+yc[h]+fe[h]|0,f=(se(n,2)^se(n,13)^se(n,22))+cc(n,s,o)|0;u=l,l=a,a=c,c=i+y|0,i=o,o=s,s=n,n=y+f|0}n=n+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,s,o,i,c,a,l,u)}roundClean(){Qe(fe)}destroy(){this.set(0,0,0,0,0,0,0,0),Qe(this.buffer)}}const gc=Qs(()=>new mc);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function jt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function to(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(r=>typeof r=="string"):t.every(r=>Number.isSafeInteger(r)):!1}function wc(e){if(typeof e!="function")throw new Error("function expected");return!0}function Bt(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function De(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Ft(e){if(!Array.isArray(e))throw new Error("array expected")}function Nt(e,t){if(!to(!0,t))throw new Error(`${e}: array of strings expected`)}function ro(e,t){if(!to(!1,t))throw new Error(`${e}: array of numbers expected`)}function bc(...e){const t=o=>o,r=(o,i)=>c=>o(i(c)),n=e.map(o=>o.encode).reduceRight(r,t),s=e.map(o=>o.decode).reduce(r,t);return{encode:n,decode:s}}function Ec(e){const t=typeof e=="string"?e.split(""):e,r=t.length;Nt("alphabet",t);const n=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(Ft(s),s.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:s=>(Ft(s),s.map(o=>{Bt("alphabet.decode",o);const i=n.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function xc(e=""){return Bt("join",e),{encode:t=>(Nt("join.decode",t),t.join(e)),decode:t=>(Bt("join.decode",t),t.split(e))}}function kc(e,t="="){return De(e),Bt("padding",t),{encode(r){for(Nt("padding.encode",r);r.length*e%8;)r.push(t);return r},decode(r){Nt("padding.decode",r);let n=r.length;if(n*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;n>0&&r[n-1]===t;n--)if((n-1)*e%8===0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,n)}}}function Fr(e,t,r){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Ft(e),!e.length)return[];let n=0;const s=[],o=Array.from(e,c=>{if(De(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=o.length;for(;;){let c=0,a=!0;for(let l=n;l<i;l++){const u=o[l],h=t*c,m=h+u;if(!Number.isSafeInteger(m)||h/t!==c||m-u!==h)throw new Error("convertRadix: carry overflow");const y=m/r;c=m%r;const p=Math.floor(y);if(o[l]=p,!Number.isSafeInteger(p)||p*r+c!==m)throw new Error("convertRadix: carry overflow");if(a)p?a=!1:n=l;else continue}if(s.push(c),a)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}const no=(e,t)=>t===0?e:no(t,e%t),Lt=(e,t)=>e+(t-no(e,t)),Sr=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Nr(e,t,r,n){if(Ft(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(Lt(t,r)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Lt(t,r)}`);let s=0,o=0;const i=Sr[t],c=Sr[r]-1,a=[];for(const l of e){if(De(l),l>=i)throw new Error(`convertRadix2: invalid data word=${l} from=${t}`);if(s=s<<t|l,o+t>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=r;o-=r)a.push((s>>o-r&c)>>>0);const u=Sr[o];if(u===void 0)throw new Error("invalid carry");s&=u-1}if(s=s<<r-o&c,!n&&o>=t)throw new Error("Excess padding");if(!n&&s>0)throw new Error(`Non-zero padding: ${s}`);return n&&o>0&&a.push(s>>>0),a}function vc(e){De(e);const t=2**8;return{encode:r=>{if(!jt(r))throw new Error("radix.encode input should be Uint8Array");return Fr(Array.from(r),t,e)},decode:r=>(ro("radix.decode",r),Uint8Array.from(Fr(r,e,t)))}}function Sc(e,t=!1){if(De(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Lt(8,e)>32||Lt(e,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!jt(r))throw new Error("radix2.encode input should be Uint8Array");return Nr(Array.from(r),8,e,!t)},decode:r=>(ro("radix2.decode",r),Uint8Array.from(Nr(r,e,8,t)))}}function Tc(e,t){return De(e),wc(t),{encode(r){if(!jt(r))throw new Error("checksum.encode: input should be Uint8Array");const n=t(r).slice(0,e),s=new Uint8Array(r.length+e);return s.set(r),s.set(n,r.length),s},decode(r){if(!jt(r))throw new Error("checksum.decode: input should be Uint8Array");const n=r.slice(0,-e),s=r.slice(-e),o=t(n).slice(0,e);for(let i=0;i<e;i++)if(o[i]!==s[i])throw new Error("Invalid checksum");return n}}}const wt={alphabet:Ec,chain:bc,checksum:Tc,convertRadix:Fr,convertRadix2:Nr,radix:vc,radix2:Sc,join:xc,padding:kc};/*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */const Ac=e=>e[0]==="あいこくしん";function _c(e){Se(e,16,20,24,28,32)}function Kc(e,t=128){if(Br(t),t%32!==0||t>256)throw new TypeError("Invalid entropy");return Cc(eo(t/8),e)}const Oc=e=>{const t=8-e.length/4;return new Uint8Array([gc(e)[0]>>t<<t])};function Rc(e){if(!Array.isArray(e)||e.length!==2048||typeof e[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return e.forEach(t=>{if(typeof t!="string")throw new Error("wordlist: non-string element: "+t)}),wt.chain(wt.checksum(1,Oc),wt.radix2(11,!0),wt.alphabet(e))}function Cc(e,t){return _c(e),Rc(t).encode(e).join(Ac(t)?" ":" ")}const Ic=`abandon
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const je=require("hash-wasm"),Gt=require("buffer"),Di=require("uuid");var vr=typeof document<"u"?document.currentScript:null;const Le="AES-GCM",V=256,Ks=128,Os=16,Xt="AES-KW",De="raw",Rs="CRYPTO library 2025-08-22 18:10:00 key derived from ecc and kyber secrets",lt="X25519",Cs="CRYPTO library 2025-07-26 16:18:03 key for opening identity keystore",Is="CRYPTO library 2025-07-30 16:18:03 key for opening encryption keys keystore",Ps="CRYPTO library 2025-07-30 16:20:00 key for account recovery",js="CRYPTO library 2025-07-30 17:20:00 key for protecting current search indices",Bs="CRYPTO library 2025-08-27 17:08:00 derive one key from two keys",jr="CRYPTO library 2025-08-28 18:27:00 ratchet media key",Fs="CRYPTO library 2025-08-26 18:29:00 prefix for commitment to media keys",Mi="CRYPTO library 2025-08-26 18:30:00 prefix for commitment to public keys",Ui="CRYPTO library 2025-08-26 18:45:00 prefix for commitment to identity keys",Ns=3,Ls=4,Ds=65536,Ms=16,Us=32,nn="Identity keystore",sn="Encryption keystore",on="Key recovery keystroe",Hi="Current encrypted indices",zi=800,$i=1632,Yi=1184,Vi=2400,Ji=1568,Gi=3168,Xi=64,ut=256,Hs=6e8,Br=100,q="email",zs=1;async function cn(e,t){try{const r=await crypto.subtle.deriveBits({name:lt,public:e},t,V);return new Uint8Array(r)}catch(r){throw new Error("Failed to derive elliptic curve secret key",{cause:r})}}async function qt(){try{return await crypto.subtle.generateKey({name:lt},!0,["deriveBits"])}catch(e){throw new Error("Failed to generate elliptic curve key pair",{cause:e})}}async function Wt(e){try{const t=await crypto.subtle.exportKey("spki",e);return new Uint8Array(t)}catch(t){throw new Error("Failed to export public key",{cause:t})}}async function Zt(e){try{return await crypto.subtle.importKey("spki",e,{name:lt},!0,[])}catch(t){throw new Error("Failed to import public key",{cause:t})}}async function an(e){try{const t=await crypto.subtle.exportKey("pkcs8",e);return new Uint8Array(t)}catch(t){throw new Error("Failed to export private key",{cause:t})}}async function ln(e){try{return await crypto.subtle.importKey("pkcs8",e,{name:lt},!0,["deriveBits"])}catch(t){throw new Error("Failed to import private key",{cause:t})}}const qi=Object.freeze(Object.defineProperty({__proto__:null,deriveSecretKey:cn,exportPrivateKey:an,exportPublicKey:Wt,generateEccKeys:qt,importPrivateKey:ln,importPublicKey:Zt},Symbol.toStringTag,{value:"Module"}));function Qe(e){return Gt.Buffer.from(e).toString("hex")}function Qt(e){return new TextEncoder().encode(e)}function un(e){return new TextDecoder().decode(e)}function jt(e){return new Uint8Array(Gt.Buffer.from(e,"hex"))}function U(e){return Gt.Buffer.from(e).toString("base64")}function D(e){return new Uint8Array(Gt.Buffer.from(e,"base64"))}function _e(e){try{const t=U(e.iv),r=U(e.ciphertext),n=JSON.stringify({ciphertext:r,iv:t});return btoa(n)}catch(t){throw new Error("Failed to convert ciphertext to base64",{cause:t})}}function er(e){try{const t=atob(e),r=JSON.parse(t),n=D(r.iv);return{ciphertext:D(r.ciphertext),iv:n}}catch(t){throw new Error("Failed to convert base64 to ciphertext",{cause:t})}}async function $s(e){try{const t=await Wt(e.userPublicKey),r=await an(e.userPrivateKey),n=JSON.stringify({userPublicKey:U(t),userPrivateKey:U(r)});return btoa(n)}catch(t){throw new Error("Failed to convert identity keys to base64",{cause:t})}}async function Ys(e){try{const t=await Wt(e.userPublicKey),r=await an(e.userPrivateKey),n=JSON.stringify({userPublicKey:U(t),userPrivateKey:U(r),userPublicKyberKey:U(e.userPublicKyberKey),userPrivateKyberKey:U(e.userPrivateKyberKey)});return btoa(n)}catch(t){throw new Error("Failed to convert identity keys to base64",{cause:t})}}function Vs(e){try{const t=_e(e.encryptedKeys),r=JSON.stringify({userID:e.userID,type:e.type.toString(),encryptedKeys:t});return btoa(r)}catch(t){throw new Error("Failed to convert encrypted keystore to base64",{cause:t})}}async function Js(e){try{const t=atob(e),r=JSON.parse(t),n=D(r.userPublicKey),s=D(r.userPrivateKey),o=await Zt(n),i=await ln(s);return{userPublicKey:o,userPrivateKey:i}}catch(t){throw new Error("Failed convert base64 to idenity key",{cause:t})}}async function hn(e){try{const t=atob(e),r=JSON.parse(t),n=D(r.userPublicKey),s=D(r.userPrivateKey),o=await Zt(n),i=await ln(s),c=D(r.userPublicKyberKey),a=D(r.userPrivateKyberKey);return{userPublicKey:o,userPrivateKey:i,userPublicKyberKey:c,userPrivateKyberKey:a}}catch(t){throw new Error("Failed to convert base64 to encryption key",{cause:t})}}function Gs(e){try{const t=atob(e),r=JSON.parse(t),n=er(r.encryptedKeys);return{userID:r.userID,type:r.type,encryptedKeys:n}}catch(t){throw new Error("Failed to convert base64 to encrypted keystore",{cause:t})}}function Xs(e){try{const t=JSON.stringify({olmKey:U(e.olmKey),pqKey:U(e.pqKey),index:e.index.toString(),userID:e.userID});return btoa(t)}catch(t){throw new Error("Failed to convert media keys to base64",{cause:t})}}async function Wi(e){try{const t=atob(e),r=JSON.parse(t);return{olmKey:D(r.olmKey),pqKey:D(r.pqKey),index:Number(r.index),userID:r.userID}}catch(t){throw new Error("Failed convert base64 to media keys",{cause:t})}}const Oe=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Zi(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Fr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Se(e,...t){if(!Zi(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Bt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function qs(e,t){Se(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ws(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function et(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Sr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function se(e,t){return e<<32-t|e>>>t}const Qi=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ec(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function tc(e){for(let t=0;t<e.length;t++)e[t]=ec(e[t]);return e}const $n=Qi?e=>e:tc,rc=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",ce={_0:48,_9:57,A:65,F:70,a:97,f:102};function Yn(e){if(e>=ce._0&&e<=ce._9)return e-ce._0;if(e>=ce.A&&e<=ce.F)return e-(ce.A-10);if(e>=ce.a&&e<=ce.f)return e-(ce.a-10)}function X(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(rc)return Uint8Array.fromHex(e);const t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let s=0,o=0;s<r;s++,o+=2){const i=Yn(e.charCodeAt(o)),c=Yn(e.charCodeAt(o+1));if(i===void 0||c===void 0){const a=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+o)}n[s]=i*16+c}return n}function nc(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function tr(e){return typeof e=="string"&&(e=nc(e)),Se(e),e}class Zs{}function Qs(e){const t=n=>e().update(tr(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function sc(e){const t=(n,s)=>e(s).update(tr(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function eo(e=32){if(Oe&&typeof Oe.getRandomValues=="function")return Oe.getRandomValues(new Uint8Array(e));if(Oe&&typeof Oe.randomBytes=="function")return Uint8Array.from(Oe.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function oc(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const s=BigInt(32),o=BigInt(4294967295),i=Number(r>>s&o),c=Number(r&o),a=n?4:0,l=n?0:4;e.setUint32(t+a,i,n),e.setUint32(t+l,c,n)}function ic(e,t,r){return e&t^~e&r}function cc(e,t,r){return e&t^e&r^t&r}class ac extends Zs{constructor(t,r,n,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=s,this.buffer=new Uint8Array(t),this.view=Sr(this.buffer)}update(t){Bt(this),t=tr(t),Se(t);const{view:r,buffer:n,blockLen:s}=this,o=t.length;for(let i=0;i<o;){const c=Math.min(s-this.pos,o-i);if(c===s){const a=Sr(t);for(;s<=o-i;i+=s)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===s&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Bt(this),qs(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:s,isLE:o}=this;let{pos:i}=this;r[i++]=128,et(this.buffer.subarray(i)),this.padOffset>s-i&&(this.process(n,0),i=0);for(let h=i;h<s;h++)r[h]=0;oc(n,s-8,BigInt(this.length*8),o),this.process(n,0);const c=Sr(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<l;h++)c.setUint32(4*h,u[h],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:s,finished:o,destroyed:i,pos:c}=this;return t.destroyed=i,t.finished=o,t.length=s,t.pos=c,s%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}}const he=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),bt=BigInt(2**32-1),Vn=BigInt(32);function lc(e,t=!1){return t?{h:Number(e&bt),l:Number(e>>Vn&bt)}:{h:Number(e>>Vn&bt)|0,l:Number(e&bt)|0}}function uc(e,t=!1){const r=e.length;let n=new Uint32Array(r),s=new Uint32Array(r);for(let o=0;o<r;o++){const{h:i,l:c}=lc(e[o],t);[n[o],s[o]]=[i,c]}return[n,s]}const hc=(e,t,r)=>e<<r|t>>>32-r,fc=(e,t,r)=>t<<r|e>>>32-r,dc=(e,t,r)=>t<<r-32|e>>>64-r,pc=(e,t,r)=>e<<r-32|t>>>64-r,yc=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),fe=new Uint32Array(64);class mc extends ac{constructor(t=32){super(64,t,8,!1),this.A=he[0]|0,this.B=he[1]|0,this.C=he[2]|0,this.D=he[3]|0,this.E=he[4]|0,this.F=he[5]|0,this.G=he[6]|0,this.H=he[7]|0}get(){const{A:t,B:r,C:n,D:s,E:o,F:i,G:c,H:a}=this;return[t,r,n,s,o,i,c,a]}set(t,r,n,s,o,i,c,a){this.A=t|0,this.B=r|0,this.C=n|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,r){for(let h=0;h<16;h++,r+=4)fe[h]=t.getUint32(r,!1);for(let h=16;h<64;h++){const m=fe[h-15],y=fe[h-2],p=se(m,7)^se(m,18)^m>>>3,f=se(y,17)^se(y,19)^y>>>10;fe[h]=f+fe[h-7]+p+fe[h-16]|0}let{A:n,B:s,C:o,D:i,E:c,F:a,G:l,H:u}=this;for(let h=0;h<64;h++){const m=se(c,6)^se(c,11)^se(c,25),y=u+m+ic(c,a,l)+yc[h]+fe[h]|0,f=(se(n,2)^se(n,13)^se(n,22))+cc(n,s,o)|0;u=l,l=a,a=c,c=i+y|0,i=o,o=s,s=n,n=y+f|0}n=n+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,s,o,i,c,a,l,u)}roundClean(){et(fe)}destroy(){this.set(0,0,0,0,0,0,0,0),et(this.buffer)}}const gc=Qs(()=>new mc);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ft(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function to(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(r=>typeof r=="string"):t.every(r=>Number.isSafeInteger(r)):!1}function wc(e){if(typeof e!="function")throw new Error("function expected");return!0}function Nt(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Me(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Lt(e){if(!Array.isArray(e))throw new Error("array expected")}function Dt(e,t){if(!to(!0,t))throw new Error(`${e}: array of strings expected`)}function ro(e,t){if(!to(!1,t))throw new Error(`${e}: array of numbers expected`)}function bc(...e){const t=o=>o,r=(o,i)=>c=>o(i(c)),n=e.map(o=>o.encode).reduceRight(r,t),s=e.map(o=>o.decode).reduce(r,t);return{encode:n,decode:s}}function Ec(e){const t=typeof e=="string"?e.split(""):e,r=t.length;Dt("alphabet",t);const n=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(Lt(s),s.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:s=>(Lt(s),s.map(o=>{Nt("alphabet.decode",o);const i=n.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function xc(e=""){return Nt("join",e),{encode:t=>(Dt("join.decode",t),t.join(e)),decode:t=>(Nt("join.decode",t),t.split(e))}}function kc(e,t="="){return Me(e),Nt("padding",t),{encode(r){for(Dt("padding.encode",r);r.length*e%8;)r.push(t);return r},decode(r){Dt("padding.decode",r);let n=r.length;if(n*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;n>0&&r[n-1]===t;n--)if((n-1)*e%8===0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,n)}}}function Nr(e,t,r){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Lt(e),!e.length)return[];let n=0;const s=[],o=Array.from(e,c=>{if(Me(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=o.length;for(;;){let c=0,a=!0;for(let l=n;l<i;l++){const u=o[l],h=t*c,m=h+u;if(!Number.isSafeInteger(m)||h/t!==c||m-u!==h)throw new Error("convertRadix: carry overflow");const y=m/r;c=m%r;const p=Math.floor(y);if(o[l]=p,!Number.isSafeInteger(p)||p*r+c!==m)throw new Error("convertRadix: carry overflow");if(a)p?a=!1:n=l;else continue}if(s.push(c),a)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}const no=(e,t)=>t===0?e:no(t,e%t),Mt=(e,t)=>e+(t-no(e,t)),Tr=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Lr(e,t,r,n){if(Lt(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(Mt(t,r)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Mt(t,r)}`);let s=0,o=0;const i=Tr[t],c=Tr[r]-1,a=[];for(const l of e){if(Me(l),l>=i)throw new Error(`convertRadix2: invalid data word=${l} from=${t}`);if(s=s<<t|l,o+t>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=r;o-=r)a.push((s>>o-r&c)>>>0);const u=Tr[o];if(u===void 0)throw new Error("invalid carry");s&=u-1}if(s=s<<r-o&c,!n&&o>=t)throw new Error("Excess padding");if(!n&&s>0)throw new Error(`Non-zero padding: ${s}`);return n&&o>0&&a.push(s>>>0),a}function vc(e){Me(e);const t=2**8;return{encode:r=>{if(!Ft(r))throw new Error("radix.encode input should be Uint8Array");return Nr(Array.from(r),t,e)},decode:r=>(ro("radix.decode",r),Uint8Array.from(Nr(r,e,t)))}}function Sc(e,t=!1){if(Me(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Mt(8,e)>32||Mt(e,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!Ft(r))throw new Error("radix2.encode input should be Uint8Array");return Lr(Array.from(r),8,e,!t)},decode:r=>(ro("radix2.decode",r),Uint8Array.from(Lr(r,e,8,t)))}}function Tc(e,t){return Me(e),wc(t),{encode(r){if(!Ft(r))throw new Error("checksum.encode: input should be Uint8Array");const n=t(r).slice(0,e),s=new Uint8Array(r.length+e);return s.set(r),s.set(n,r.length),s},decode(r){if(!Ft(r))throw new Error("checksum.decode: input should be Uint8Array");const n=r.slice(0,-e),s=r.slice(-e),o=t(n).slice(0,e);for(let i=0;i<e;i++)if(o[i]!==s[i])throw new Error("Invalid checksum");return n}}}const Et={alphabet:Ec,chain:bc,checksum:Tc,convertRadix:Nr,convertRadix2:Lr,radix:vc,radix2:Sc,join:xc,padding:kc};/*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */const Ac=e=>e[0]==="あいこくしん";function _c(e){Se(e,16,20,24,28,32)}function Kc(e,t=128){if(Fr(t),t%32!==0||t>256)throw new TypeError("Invalid entropy");return Cc(eo(t/8),e)}const Oc=e=>{const t=8-e.length/4;return new Uint8Array([gc(e)[0]>>t<<t])};function Rc(e){if(!Array.isArray(e)||e.length!==2048||typeof e[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return e.forEach(t=>{if(typeof t!="string")throw new Error("wordlist: non-string element: "+t)}),Et.chain(Et.checksum(1,Oc),Et.radix2(11,!0),Et.alphabet(e))}function Cc(e,t){return _c(e),Rc(t).encode(e).join(Ac(t)?" ":" ")}const Ic=`abandon
|
|
2
2
|
ability
|
|
3
3
|
able
|
|
4
4
|
about
|
|
@@ -2046,10 +2046,10 @@ zebra
|
|
|
2046
2046
|
zero
|
|
2047
2047
|
zone
|
|
2048
2048
|
zoo`.split(`
|
|
2049
|
-
`);function so(e){return Kc(Ic,e)}const Pc=Object.freeze(Object.defineProperty({__proto__:null,UTF8ToUint8:Zt,base64ToCiphertext:Qt,base64ToEncryptedKeystore:Gs,base64ToEncryptionKeys:un,base64ToIdentityKeys:Js,base64ToMediaKeys:Wi,base64ToUint8Array:D,ciphertextToBase64:_e,encryptedKeystoreToBase64:Vs,encryptionKeysToBase64:Ys,genMnemonic:so,hexToUint8Array:It,identityKeysToBase64:$s,mediaKeysToBase64:Xs,uint8ArrayToBase64:U,uint8ArrayToHex:Ze,uint8ToUTF8:ln},Symbol.toStringTag,{value:"Module"}));async function hn(e){return crypto.subtle.importKey(Le,e,{name:Ne,length:G},!0,["encrypt","decrypt"])}async function jc(e){try{const t=await crypto.subtle.exportKey(Le,e);return new Uint8Array(t)}catch(t){throw new Error("Failed to export symmetric CryptoKey",{cause:t})}}async function fn(){return crypto.subtle.generateKey({name:Ne,length:G},!0,["encrypt","decrypt"])}function Bc(){try{const e=new Uint8Array(G/8);return crypto.getRandomValues(e),e}catch(e){throw new Error("Failed to generate symmetric key",{cause:e})}}const Fc=BigInt(0),Ye=BigInt(1),Nc=BigInt(2),Lc=BigInt(7),Dc=BigInt(256),Mc=BigInt(113),oo=[],io=[],co=[];for(let e=0,t=Ye,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],oo.push(2*(5*n+r)),io.push((e+1)*(e+2)/2%64);let s=Fc;for(let o=0;o<7;o++)t=(t<<Ye^(t>>Lc)*Mc)%Dc,t&Nc&&(s^=Ye<<(Ye<<BigInt(o))-Ye);co.push(s)}const ao=uc(co,!0),Uc=ao[0],Hc=ao[1],Jn=(e,t,r)=>r>32?dc(e,t,r):hc(e,t,r),Gn=(e,t,r)=>r>32?pc(e,t,r):fc(e,t,r);function zc(e,t=24){const r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let i=0;i<10;i++)r[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,a=(i+2)%10,l=r[a],u=r[a+1],h=Jn(l,u,1)^r[c],m=Gn(l,u,1)^r[c+1];for(let y=0;y<50;y+=10)e[i+y]^=h,e[i+y+1]^=m}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=io[i],a=Jn(s,o,c),l=Gn(s,o,c),u=oo[i];s=e[u],o=e[u+1],e[u]=a,e[u+1]=l}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)r[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~r[(c+2)%10]&r[(c+4)%10]}e[0]^=Uc[n],e[1]^=Hc[n]}Qe(r)}class tr extends Zs{constructor(t,r,n,s=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=r,this.outputLen=n,this.enableXOF=s,this.rounds=o,Br(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ws(this.state)}clone(){return this._cloneInto()}keccak(){$n(this.state32),zc(this.state32,this.rounds),$n(this.state32),this.posOut=0,this.pos=0}update(t){Pt(this),t=er(t),Se(t);const{blockLen:r,state:n}=this,s=t.length;for(let o=0;o<s;){const i=Math.min(r-this.pos,s-o);for(let c=0;c<i;c++)n[this.pos++]^=t[o++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:r,pos:n,blockLen:s}=this;t[n]^=r,(r&128)!==0&&n===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Pt(this,!1),Se(t),this.finish();const r=this.state,{blockLen:n}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Br(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(qs(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Qe(this.state)}_cloneInto(t){const{blockLen:r,suffix:n,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new tr(r,n,s,i,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=n,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}}const lo=(e,t,r)=>Qs(()=>new tr(t,e,r)),$c=lo(6,136,256/8),Yc=lo(6,72,512/8),uo=(e,t,r)=>sc((n={})=>new tr(t,e,n.dkLen===void 0?r:n.dkLen,!0)),Vc=uo(31,168,128/8),ho=uo(31,136,256/8);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const le=Se,Dt=eo;function Xn(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function St(...e){const t=n=>typeof n=="number"?n:n.bytesLen,r=e.reduce((n,s)=>n+t(s),0);return{bytesLen:r,encode:n=>{const s=new Uint8Array(r);for(let o=0,i=0;o<e.length;o++){const c=e[o],a=t(c),l=typeof c=="number"?n[o]:c.encode(n[o]);le(l,a),s.set(l,i),typeof c!="number"&&l.fill(0),i+=a}return s},decode:n=>{le(n,r);const s=[];for(const o of e){const i=t(o),c=n.subarray(0,i);s.push(typeof o=="number"?c:o.decode(c)),n=n.subarray(i)}return s}}}function Tr(e,t){const r=t*e.bytesLen;return{bytesLen:r,encode:n=>{if(n.length!==t)throw new Error(`vecCoder.encode: wrong length=${n.length}. Expected: ${t}`);const s=new Uint8Array(r);for(let o=0,i=0;o<n.length;o++){const c=e.encode(n[o]);s.set(c,i),c.fill(0),i+=c.length}return s},decode:n=>{le(n,r);const s=[];for(let o=0;o<n.length;o+=e.bytesLen)s.push(e.decode(n.subarray(o,o+e.bytesLen)));return s}}}function xe(...e){for(const t of e)if(Array.isArray(t))for(const r of t)r.fill(0);else t.fill(0)}function qn(e){return(1<<e)-1}X("0609608648016503040201"),X("0609608648016503040202"),X("0609608648016503040203"),X("0609608648016503040204"),X("0609608648016503040205"),X("0609608648016503040206"),X("0609608648016503040207"),X("0609608648016503040208"),X("0609608648016503040209"),X("060960864801650304020A"),X("060960864801650304020B"),X("060960864801650304020C");async function dn(e,t){try{const r=await We.createBLAKE3(e);r.init();for(const n of t)r.update(n);return r}catch(r){throw new Error("Failed to compute hash",{cause:r})}}async function Jc(e){try{return(await dn(Gt,e)).digest()}catch(t){throw new Error("Failed to compute hash",{cause:t})}}async function fo(e,t){try{return(await dn(e,t)).digest("binary")}catch(r){throw new Error("Failed to get bits from data",{cause:r})}}async function rr(e,t){try{return(await dn(e,[t])).digest("binary")}catch(r){throw new Error("Failed to get bits from string",{cause:r})}}async function Gc(e){try{const t=Xs(e),r=await fo(Gt,[Fs,t]);return Ze(r)}catch(t){throw new Error("Failed to compute commitment to media keys",{cause:t})}}const Xc=Object.freeze(Object.defineProperty({__proto__:null,comitToMediaKey:Gc,getBitsFromData:fo,getBitsFromString:rr,hashData:Jc},Symbol.toStringTag,{value:"Module"}));async function qc(e){try{if(!e)return Dt(Os);const t=new Uint8Array(16),r=Dt(12);t.set(r,0);const n=await rr(32,e);return t.set(n,12),t}catch(t){throw new Error("Failed to create IV",{cause:t})}}async function po(e){return rr(Ks,e)}async function Wc(e,t,r,n){try{const s=await crypto.subtle.encrypt({name:Ne,iv:r,additionalData:n},t,e);return new Uint8Array(s)}catch(s){throw new Error("Failed to encrypt symmetrically",{cause:s})}}async function Zc(e,t,r,n){try{const s=await crypto.subtle.decrypt({name:Ne,iv:t,additionalData:n},r,e);return new Uint8Array(s)}catch(s){throw new Error("Failed to decrypt symmetrically",{cause:s})}}async function nr(e,t,r,n){try{const s=await qc(n),o=await po(r);return{ciphertext:await Wc(t,e,s,o),iv:s}}catch(s){throw new Error("Failed to encrypt symmetrically",{cause:s})}}async function et(e,t,r){try{const n=await po(r);return await Zc(t.ciphertext,t.iv,e,n)}catch(n){throw new Error("Failed to decrypt symmetrically",{cause:n})}}const Qc=Object.freeze(Object.defineProperty({__proto__:null,decryptSymmetrically:et,encryptSymmetrically:nr,exportSymmetricCryptoKey:jc,genSymmetricCryptoKey:fn,genSymmetricKey:Bc,importSymmetricCryptoKey:hn},Symbol.toStringTag,{value:"Module"}));async function tt(e,t){try{const r=await We.blake3(e),n=It(r),s=await We.blake3(t,G,n);return It(s)}catch(r){throw new Error("Failed to derive key from base key and context",{cause:r})}}async function lt(e,t){try{if(t.length!=G/8)throw new Error(`Base key length must be exactly ${G/8} bytes`);if(!e)throw new Error("Context is empry");const r=await tt(e,t);return await hn(r)}catch(r){throw new Error("Failed to derive CryptoKey from base key and context",{cause:r})}}async function yo(e,t,r=Ns,n=Ls,s=Ds,o=Us){return We.argon2id({password:e,salt:t,parallelism:r,iterations:n,memorySize:s,hashLength:o,outputType:"binary"})}function ea(){try{const e=new Uint8Array(Ms);return crypto.getRandomValues(e),e}catch(e){throw new Error("Failed to sample salt",{cause:e})}}async function mo(e,t,r){try{if(t.length!=G/8||e.length!=G/8)throw new Error(`Input key length must be exactly ${G/8} bytes`);const n=await We.blake3(e,Gt,t);return await tt(r,n)}catch(n){throw new Error("Failed to derive symmetric key from two keys",{cause:n})}}async function pn(e){try{if(!e)throw new Error("No password given");const t=ea();return{key:await yo(e,t),salt:t}}catch(t){throw new Error("Failed to derive key from password",{cause:t})}}async function yn(e,t){try{if(!t.length)throw new Error("No salt given");if(!e)throw new Error("No password given");return await yo(e,t)}catch(r){throw new Error("Failed to derive key from password and salt",{cause:r})}}async function ta(e){try{const{key:t,salt:r}=await pn(e);return{keyHex:Ze(t),saltHex:Ze(r)}}catch(t){throw new Error("Failed to derive key from password",{cause:t})}}async function go(e,t){try{const r=It(t),n=await yn(e,r);return Ze(n)}catch(r){throw new Error("Failed to derive key from password and salt",{cause:r})}}async function ra(e,t,r){const n=await go(e,t);return r===n}async function wo(e,t){return await mo(e,t,Bs)}async function na(e,t){try{const r=await wo(e,t);return await hn(r)}catch(r){throw new Error("Failed to derive symmetric CryptoKey from two keys",{cause:r})}}async function sa(e){try{const t=await tt(Pr,e.olmKey),r=await tt(Pr,e.pqKey),n=e.index+1,s=e.userID;return{olmKey:t,pqKey:r,index:n,userID:s}}catch(t){throw new Error("Failed to ratchet media key",{cause:t})}}const oa=Object.freeze(Object.defineProperty({__proto__:null,deriveSymmetricCryptoKeyFromContext:lt,deriveSymmetricCryptoKeyFromTwoKeys:na,deriveSymmetricKeyFromContext:tt,deriveSymmetricKeyFromTwoKeys:wo,getKeyFromPassword:pn,getKeyFromPasswordAndSalt:yn,getKeyFromPasswordAndSaltHex:go,getKeyFromPasswordHex:ta,ratchetMediaKey:sa,verifyKeyFromPasswordHex:ra},Symbol.toStringTag,{value:"Module"}));function Tt(e){try{const t=JSON.stringify(e);return btoa(t)}catch(t){throw new Error("Failed to convert User to base64",{cause:t})}}function At(e){try{const t=atob(e);return JSON.parse(t)}catch(t){throw new Error("Failed to convert base64 to User",{cause:t})}}function bo(e){try{const t=JSON.stringify(e);return Zt(t)}catch(t){throw new Error("Failed to convert EmailBody to Uint8Array",{cause:t})}}function mn(e){try{const t=ln(e);return JSON.parse(t)}catch(t){throw new Error("Failed to convert Uint8Array to EmailBody",{cause:t})}}async function Eo(e){try{const t=atob(e),r=JSON.parse(t),n=D(r.eccPublicKey),s=await Wt(n),o=D(r.kyberPublicKey);return{eccPublicKey:s,kyberPublicKey:o}}catch(t){throw new Error("Failed to convert base64 to PublicKeys",{cause:t})}}async function ia(e){try{const t=await qt(e.eccPublicKey),r=JSON.stringify({eccPublicKey:U(t),kyberPublicKey:U(e.kyberPublicKey)});return btoa(r)}catch(t){throw new Error("Failed to convert key of the type PublicKeys to base64",{cause:t})}}function xo(e){try{const t=JSON.stringify({kyberCiphertext:U(e.kyberCiphertext),encryptedKey:U(e.encryptedKey)});return btoa(t)}catch(t){throw new Error("Failed to convert hybrid key to base64",{cause:t})}}function ca(e){try{const t=atob(e),r=JSON.parse(t);return{encryptedKey:D(r.encryptedKey),kyberCiphertext:D(r.kyberCiphertext)}}catch(t){throw new Error("Failed to convert base64 to hybrid key",{cause:t})}}function ko(e){try{const t=JSON.stringify({encryptedKey:U(e.encryptedKey),salt:U(e.salt)});return btoa(t)}catch(t){throw new Error("Failed to convert password-protected key to base64",{cause:t})}}function aa(e){try{const t=atob(e),r=JSON.parse(t);return{encryptedKey:D(r.encryptedKey),salt:D(r.salt)}}catch(t){throw new Error("Failed to convert base64 to password-protected key",{cause:t})}}function la(e){try{const t=JSON.stringify({...e,sender:Tt(e.sender),recipient:Tt(e.recipient),recipients:e.recipients?.map(Tt)});return btoa(t)}catch(t){throw new Error("Failed to convert email public parameters to base64",{cause:t})}}function ua(e){try{const t=atob(e),r=JSON.parse(t);return{...r,sender:At(r.sender),recipient:At(r.recipient),recipients:r.recipients?.map(At)}}catch(t){throw new Error("Failed to convert base64 to email params",{cause:t})}}function vo(e){try{const t=JSON.stringify({encryptedKey:xo(e.encryptedKey),enc:_e(e.enc),recipientID:e.recipientID});return btoa(t)}catch(t){throw new Error("Failed to convert hybrid email to base64",{cause:t})}}function So(e){try{const t=JSON.stringify({encryptedKey:ko(e.encryptedKey),enc:_e(e.enc)});return btoa(t)}catch(t){throw new Error("Failed to convert pwd protected email to base64",{cause:t})}}function To(e){try{const t=JSON.stringify(e);return Zt(t)}catch(t){throw new Error("Failed to convert EmailBody to Uint8Array",{cause:t})}}/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function ha(e,t=8){const s=e.toString(2).padStart(8,"0").slice(-t).padStart(7,"0").split("").reverse().join("");return Number.parseInt(s,2)}const fa=e=>{const{newPoly:t,N:r,Q:n,F:s,ROOT_OF_UNITY:o,brvBits:i}=e,c=(f,d=n)=>{const b=f%d|0;return(b>=0?b|0:d+b|0)|0},a=(f,d=n)=>{const b=c(f,d)|0;return(b>d>>1?b-d|0:b)|0};function l(){const f=t(r);for(let d=0;d<r;d++){const b=ha(d,i),w=BigInt(o)**BigInt(b)%BigInt(n);f[d]=Number(w)|0}return f}const u=l(),h=128,m=1;return{mod:c,smod:a,nttZetas:u,NTT:{encode:f=>{for(let d=1,b=128;b>m;b>>=1)for(let w=0;w<r;w+=2*b){const E=u[d++];for(let x=w;x<w+b;x++){const k=c(E*f[x+b]);f[x+b]=c(f[x]-k)|0,f[x]=c(f[x]+k)|0}}return f},decode:f=>{for(let d=h-1,b=1+m;b<h+m;b<<=1)for(let w=0;w<r;w+=2*b){const E=u[d--];for(let x=w;x<w+b;x++){const k=f[x];f[x]=c(k+f[x+b]),f[x+b]=c(E*(f[x+b]-k))}}for(let d=0;d<f.length;d++)f[d]=c(s*f[d]);return f}},bitsCoder:(f,d)=>{const b=qn(f),w=f*(r/8);return{bytesLen:w,encode:E=>{const x=new Uint8Array(w);for(let k=0,v=0,S=0,T=0;k<E.length;k++)for(v|=(d.encode(E[k])&b)<<S,S+=f;S>=8;S-=8,v>>=8)x[T++]=v&qn(S);return x},decode:E=>{const x=t(r);for(let k=0,v=0,S=0,T=0;k<E.length;k++)for(v|=E[k]<<S,S+=8;S>=f;S-=f,v>>=f)x[T++]=d.decode(v&b);return x}}}}},da=e=>(t,r)=>{r||(r=e.blockLen);const n=new Uint8Array(t.length+2);n.set(t);const s=t.length,o=new Uint8Array(r);let i=e.create({}),c=0,a=0;return{stats:()=>({calls:c,xofs:a}),get:(l,u)=>(n[s+0]=l,n[s+1]=u,i.destroy(),i=e.create({}).update(n),c++,()=>(a++,i.xofInto(o))),clean:()=>{i.destroy(),o.fill(0),n.fill(0)}}},pa=da(Vc);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const Y=256,ue=3329,ya=3303,ma=17,{mod:rt,nttZetas:ga,NTT:we,bitsCoder:wa}=fa({N:Y,Q:ue,F:ya,ROOT_OF_UNITY:ma,newPoly:e=>new Uint16Array(e),brvBits:7}),gn={512:{N:Y,Q:ue,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:Y,Q:ue,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:Y,Q:ue,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},ba=e=>{if(e>=12)return{encode:r=>r,decode:r=>r};const t=2**(e-1);return{encode:r=>((r<<e)+ue/2)/ue,decode:r=>r*ue+t>>>e}},Ve=e=>wa(e,ba(e));function be(e,t){for(let r=0;r<Y;r++)e[r]=rt(e[r]+t[r])}function Ea(e,t){for(let r=0;r<Y;r++)e[r]=rt(e[r]-t[r])}function xa(e,t,r,n,s){const o=rt(t*n*s+e*r),i=rt(e*n+t*r);return{c0:o,c1:i}}function bt(e,t){for(let r=0;r<Y/2;r++){let n=ga[64+(r>>1)];r&1&&(n=-n);const{c0:s,c1:o}=xa(e[2*r+0],e[2*r+1],t[2*r+0],t[2*r+1],n);e[2*r+0]=s,e[2*r+1]=o}return e}function Wn(e){const t=new Uint16Array(Y);for(let r=0;r<Y;){const n=e();if(n.length%3)throw new Error("SampleNTT: unaligned block");for(let s=0;r<Y&&s+3<=n.length;s+=3){const o=(n[s+0]>>0|n[s+1]<<8)&4095,i=(n[s+1]>>4|n[s+2]<<4)&4095;o<ue&&(t[r++]=o),r<Y&&i<ue&&(t[r++]=i)}}return t}function Je(e,t,r,n){const s=e(n*Y/4,t,r),o=new Uint16Array(Y),i=Ws(s);let c=0;for(let a=0,l=0,u=0,h=0;a<i.length;a++){let m=i[a];for(let y=0;y<32;y++)u+=m&1,m>>=1,c+=1,c===n?(h=u,u=0):c===2*n&&(o[l++]=rt(h-u),u=0,c=0)}if(c)throw new Error(`sampleCBD: leftover bits: ${c}`);return o}const ka=e=>{const{K:t,PRF:r,XOF:n,HASH512:s,ETA1:o,ETA2:i,du:c,dv:a}=e,l=Ve(1),u=Ve(a),h=Ve(c),m=St(Tr(Ve(12),t),32),y=Tr(Ve(12),t),p=St(Tr(h,t),u),f=St(32,32);return{secretCoder:y,secretKeyLen:y.bytesLen,publicKeyLen:m.bytesLen,cipherTextLen:p.bytesLen,keygen:d=>{le(d,32);const b=new Uint8Array(33);b.set(d),b[32]=t;const w=s(b),[E,x]=f.decode(w),k=[],v=[];for(let _=0;_<t;_++)k.push(we.encode(Je(r,x,_,o)));const S=n(E);for(let _=0;_<t;_++){const C=we.encode(Je(r,x,t+_,o));for(let O=0;O<t;O++){const j=Wn(S.get(O,_));be(C,bt(j,k[O]))}v.push(C)}S.clean();const T={publicKey:m.encode([v,E]),secretKey:y.encode(k)};return xe(E,x,k,v,b,w),T},encrypt:(d,b,w)=>{const[E,x]=m.decode(d),k=[];for(let O=0;O<t;O++)k.push(we.encode(Je(r,w,O,o)));const v=n(x),S=new Uint16Array(Y),T=[];for(let O=0;O<t;O++){const j=Je(r,w,t+O,i),L=new Uint16Array(Y);for(let M=0;M<t;M++){const B=Wn(v.get(O,M));be(L,bt(B,k[M]))}be(j,we.decode(L)),T.push(j),be(S,bt(E[O],k[O])),L.fill(0)}v.clean();const _=Je(r,w,2*t,i);be(_,we.decode(S));const C=l.decode(b);return be(C,_),xe(E,k,S,_),p.encode([T,C])},decrypt:(d,b)=>{const[w,E]=p.decode(d),x=y.decode(b),k=new Uint16Array(Y);for(let v=0;v<t;v++)be(k,bt(x[v],we.encode(w[v])));return Ea(E,we.decode(k)),xe(k,x,w),l.encode(E)}}};function wn(e){const t=ka(e),{HASH256:r,HASH512:n,KDF:s}=e,{secretCoder:o,cipherTextLen:i}=t,c=t.publicKeyLen,a=St(t.secretKeyLen,t.publicKeyLen,32,32),l=a.bytesLen,u=32;return{publicKeyLen:c,msgLen:u,keygen:(h=Dt(64))=>{le(h,64);const{publicKey:m,secretKey:y}=t.keygen(h.subarray(0,32)),p=r(m),f=a.encode([y,m,p,h.subarray(32)]);return xe(y,p),{publicKey:m,secretKey:f}},encapsulate:(h,m=Dt(32))=>{le(h,c),le(m,u);const y=h.subarray(0,384*e.K),p=o.encode(o.decode(y.slice()));if(!Xn(p,y))throw xe(p),new Error("ML-KEM.encapsulate: wrong publicKey modulus");xe(p);const f=n.create().update(m).update(r(h)).digest(),d=t.encrypt(h,m,f.subarray(32,64));return f.subarray(32).fill(0),{cipherText:d,sharedSecret:f.subarray(0,32)}},decapsulate:(h,m)=>{le(m,l),le(h,i);const[y,p,f,d]=a.decode(m),b=t.decrypt(h,y),w=n.create().update(b).update(f).digest(),E=w.subarray(0,32),x=t.encrypt(p,b,w.subarray(32,64)),k=Xn(h,x),v=s.create({dkLen:32}).update(d).update(h).digest();return xe(b,x,k?v:E),k?E:v}}}function va(e,t,r){return ho.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}const bn={HASH256:$c,HASH512:Yc,KDF:ho,XOF:pa,PRF:va},En=wn({...bn,...gn[512]}),xn=wn({...bn,...gn[768]}),kn=wn({...bn,...gn[1024]});function vn(e){try{return xn.keygen(e)}catch(t){throw new Error("Failed to generate Kyber keys",{cause:t})}}function Ao(e){try{return xn.encapsulate(e)}catch(t){throw new Error("Failed to encapsulate",{cause:t})}}function _o(e,t){try{return xn.decapsulate(e,t)}catch(r){throw new Error("Failed to decapsulate",{cause:r})}}function Sa(e){try{return En.keygen(e)}catch(t){throw new Error("Failed to generate Kyber keys",{cause:t})}}function Ta(e){try{return En.encapsulate(e)}catch(t){throw new Error("Failed to encapsulate",{cause:t})}}function Aa(e,t){try{return En.decapsulate(e,t)}catch(r){throw new Error("Failed to decapsulate",{cause:r})}}const _a=Object.freeze(Object.defineProperty({__proto__:null,decapsulateKyber:Aa,encapsulateKyber:Ta,generateKyberKeys:Sa},Symbol.toStringTag,{value:"Module"}));function Ka(e){try{return kn.keygen(e)}catch(t){throw new Error("Failed to generate Kyber keys",{cause:t})}}function Oa(e){try{return kn.encapsulate(e)}catch(t){throw new Error("Failed to encapsulate",{cause:t})}}function Ra(e,t){try{return kn.decapsulate(e,t)}catch(r){throw new Error("Failed to decapsulate",{cause:r})}}const Ca=Object.freeze(Object.defineProperty({__proto__:null,decapsulateKyber:Ra,encapsulateKyber:Oa,generateKyberKeys:Ka},Symbol.toStringTag,{value:"Module"})),Ia=Object.freeze(Object.defineProperty({__proto__:null,decapsulateKyber:_o,encapsulateKyber:Ao,generateKyberKeys:vn,kyber1024:Ca,kyber512:_a},Symbol.toStringTag,{value:"Module"}));async function sr(e){try{return await crypto.subtle.importKey(Le,e,Jt,!1,["wrapKey","unwrapKey"])}catch(t){throw new Error("Failed to import wrapping key",{cause:t})}}async function Sn(e,t){try{if(e.length!==t.length)throw new Error("secrets must have equal length");const r=await mo(e,t,Rs);return await sr(r)}catch(r){throw new Error("Failed to derive wrapping key",{cause:r})}}async function Tn(e,t){try{return await crypto.subtle.unwrapKey(Le,e,t,Jt,Ne,!1,["encrypt","decrypt"])}catch(r){throw new Error("Failed to unwrap key",{cause:r})}}async function An(e,t){try{const r=await crypto.subtle.wrapKey(Le,e,t,Jt);return new Uint8Array(r)}catch(r){throw new Error("Failed to wrap key",{cause:r})}}const Pa=Object.freeze(Object.defineProperty({__proto__:null,deriveWrappingKey:Sn,importWrappingKey:sr,unwrapKey:Tn,wrapKey:An},Symbol.toStringTag,{value:"Module"}));async function _n(e,t,r){try{const n=await fn();return{enc:await or(e,n,t,r),encryptionKey:n}}catch(n){throw new Error("Failed to symmetrically encrypt email",{cause:n})}}async function Kn(e,t,r,n){try{const s=await fn(),o=await or(e,s,r,n),i=Zt(t),c=await nr(s,i,r);return{enc:o,encryptionKey:s,subjectEnc:c}}catch(s){throw new Error("Failed to symmetrically encrypt email and subject",{cause:s})}}async function Ko(e,t,r,n){try{const s=await et(r,e,n),o=await et(r,t,n);return{body:mn(s),subject:ln(o)}}catch(s){throw new Error("Failed to symmetrically decrypt email and subject",{cause:s})}}async function or(e,t,r,n){try{const s=bo(e);return await nr(t,s,r,n)}catch(s){throw new Error("Failed to symmetrically encrypt email with the given key",{cause:s})}}async function ir(e,t,r){try{const n=await et(t,e,r);return mn(n)}catch(n){throw new Error("Failed to symmetrically decrypt email",{cause:n})}}async function cr(e,t,r){try{const n=await on(t.eccPublicKey,r.eccPrivateKey),{cipherText:s,sharedSecret:o}=Ao(t.kyberPublicKey),i=await Sn(n,o);return{encryptedKey:await An(e,i),kyberCiphertext:s}}catch(n){throw new Error("Failed to encrypt email key using hybrid encryption",{cause:n})}}async function Oo(e,t,r){try{const n=await on(t.eccPublicKey,r.eccPrivateKey),s=_o(e.kyberCiphertext,r.kyberPrivateKey),o=await Sn(n,s);return await Tn(e.encryptedKey,o)}catch(n){throw new Error("Failed to decrypt email key encrypted via hybrid encryption",{cause:n})}}async function Ro(e,t){try{const{key:r,salt:n}=await pn(t),s=await sr(r);return{encryptedKey:await An(e,s),salt:n}}catch(r){throw new Error("Failed to password-protect email key",{cause:r})}}async function Co(e,t){try{const r=await yn(t,e.salt),n=await sr(r);return await Tn(e.encryptedKey,n)}catch(r){throw new Error("Failed to remove password-protection from email key",{cause:r})}}function ie(e){try{const{subject:t,replyToEmailID:r,sender:n,recipients:s}=e;return JSON.stringify({subject:t,replyToEmailID:r,sender:n,recipients:s})}catch(t){throw new Error("Failed to create aux",{cause:t})}}function Me(e){try{const{replyToEmailID:t,sender:r,recipients:n}=e;return JSON.stringify({replyToEmailID:t,sender:r,recipients:n})}catch(t){throw new Error("Failed to create aux without subject",{cause:t})}}function ja(){return Di.v4()}async function Ba(e,t,r){try{const n=ie(e.params),{enc:s,encryptionKey:o}=await _n(e.body,n,e.params.id),i=await cr(o,t.publicKeys,r);return{enc:s,encryptedKey:i,recipientID:t.id,params:e.params}}catch(n){throw new Error("Failed to encrypt email with hybrid encryption",{cause:n})}}async function Fa(e,t,r){try{const n=ie(e.params),{enc:s,encryptionKey:o}=await _n(e.body,n,e.params.id),i=[];for(const c of t){const a=await cr(o,c.publicKeys,r);i.push({enc:s,encryptedKey:a,recipientID:c.id,params:e.params})}return i}catch(n){throw new Error("Failed to encrypt email to multiple recipients with hybrid encryption",{cause:n})}}async function Na(e,t,r){try{const n=ie(e.params),s=await Oo(e.encryptedKey,t,r);return{body:await ir(e.enc,s,n),params:e.params}}catch(n){throw new Error("Failed to decrypt email with hybrid encryption",{cause:n})}}async function La(e,t,r){try{const n=Me(e.params),{enc:s,encryptionKey:o,subjectEnc:i}=await Kn(e.body,e.params.subject,n,e.params.id),c=_e(i),a=await cr(o,t.publicKeys,r),l={...e.params,subject:c};return{enc:s,encryptedKey:a,recipientID:t.id,params:l}}catch(n){throw new Error("Failed to encrypt the email and its subject with hybrid encryption",{cause:n})}}async function Da(e,t,r){try{const n=Me(e.params),{enc:s,encryptionKey:o,subjectEnc:i}=await Kn(e.body,e.params.subject,n,e.params.id),c=_e(i),a=[];for(const l of t){const u=await cr(o,l.publicKeys,r),h={...e.params,subject:c};a.push({enc:s,encryptedKey:u,recipientID:l.id,params:h})}return a}catch(n){throw new Error("Failed to encrypt the email and its subject to multiple recipients with hybrid encryption",{cause:n})}}async function Ma(e,t,r){try{const n=Me(e.params),s=await Oo(e.encryptedKey,t,r),o=Qt(e.params.subject),{body:i,subject:c}=await Ko(e.enc,o,s,n),a={...e.params,subject:c};return{body:i,params:a}}catch(n){throw new Error("Failed to decrypt the email and its subject with hybrid encryption",{cause:n})}}async function Ua(e,t){try{if(!e?.body||!e.params)throw new Error("Failed to password-protect email: Invalid email structure");const r=ie(e.params),{enc:n,encryptionKey:s}=await _n(e.body,r,e.params.id),o=await Ro(s,t);return{enc:n,encryptedKey:o,params:e.params}}catch(r){throw new Error("Failed to password-protect email",{cause:r})}}async function Ha(e,t){try{const r=ie(e.params),n=await Co(e.encryptedKey,t);return{body:await ir(e.enc,n,r),params:e.params}}catch(r){throw new Error("Failed to decrypt password-protect email",{cause:r})}}async function za(e,t){try{if(!e?.body||!e.params)throw new Error("Failed to password-protect email and subject: Invalid email structure");const r=Me(e.params),{enc:n,encryptionKey:s,subjectEnc:o}=await Kn(e.body,e.params.subject,r,e.params.id),i=await Ro(s,t),c=_e(o),a={...e.params,subject:c};return{enc:n,encryptedKey:i,params:a}}catch(r){throw new Error("Failed to password-protect email and subject",{cause:r})}}async function $a(e,t){try{const r=Me(e.params),n=await Co(e.encryptedKey,t),s=Qt(e.params.subject),{body:o,subject:i}=await Ko(e.enc,s,n,r),c={...e.params,subject:i};return{body:o,params:c}}catch(r){throw new Error("Failed to decrypt password-protect email",{cause:r})}}async function Ya(){try{const e=vn(),t=await Xt(),r={eccPrivateKey:t.privateKey,kyberPrivateKey:e.secretKey};return{publicKeys:{eccPublicKey:t.publicKey,kyberPublicKey:e.publicKey},privateKeys:r}}catch(e){throw new Error("Failed to generate keys for email service",{cause:e})}}const Va=Object.freeze(Object.defineProperty({__proto__:null,base64ToEncHybridKey:ca,base64ToParams:ua,base64ToPublicKey:Eo,base64ToPwdProtectedKey:aa,base64ToUser:At,binaryToEmailBody:mn,createPwdProtectedEmail:Ua,createPwdProtectedEmailAndSubject:za,decryptEmailAndSubjectHybrid:Ma,decryptEmailHybrid:Na,decryptPwdProtectedEmail:Ha,decryptPwdProtectedEmailAndSubject:$a,emailBodyToBinary:bo,emailToBinary:To,encHybridKeyToBase64:xo,encryptEmailAndSubjectHybrid:La,encryptEmailAndSubjectHybridForMultipleRecipients:Da,encryptEmailHybrid:Ba,encryptEmailHybridForMultipleRecipients:Fa,generateEmailID:ja,generateEmailKeys:Ya,getAux:ie,getAuxWithoutSubject:Me,hybridEncyptedEmailToBase64:vo,paramsToBase64:la,publicKeyToBase64:ia,pwdProtectedEmailToBase64:So,pwdProtectedKeyToBase64:ko,userToBase64:Tt},Symbol.toStringTag,{value:"Module"})),Lr=(e,t)=>t.some(r=>e instanceof r);let Zn,Qn;function Ja(){return Zn||(Zn=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Ga(){return Qn||(Qn=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Dr=new WeakMap,Ar=new WeakMap,ar=new WeakMap;function Xa(e){const t=new Promise((r,n)=>{const s=()=>{e.removeEventListener("success",o),e.removeEventListener("error",i)},o=()=>{r(pe(e.result)),s()},i=()=>{n(e.error),s()};e.addEventListener("success",o),e.addEventListener("error",i)});return ar.set(t,e),t}function qa(e){if(Dr.has(e))return;const t=new Promise((r,n)=>{const s=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",i),e.removeEventListener("abort",i)},o=()=>{r(),s()},i=()=>{n(e.error||new DOMException("AbortError","AbortError")),s()};e.addEventListener("complete",o),e.addEventListener("error",i),e.addEventListener("abort",i)});Dr.set(e,t)}let Mr={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return Dr.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return pe(e[t])},set(e,t,r){return e[t]=r,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};function Io(e){Mr=e(Mr)}function Wa(e){return Ga().includes(e)?function(...t){return e.apply(Ur(this),t),pe(this.request)}:function(...t){return pe(e.apply(Ur(this),t))}}function Za(e){return typeof e=="function"?Wa(e):(e instanceof IDBTransaction&&qa(e),Lr(e,Ja())?new Proxy(e,Mr):e)}function pe(e){if(e instanceof IDBRequest)return Xa(e);if(Ar.has(e))return Ar.get(e);const t=Za(e);return t!==e&&(Ar.set(e,t),ar.set(t,e)),t}const Ur=e=>ar.get(e);function Qa(e,t,{blocked:r,upgrade:n,blocking:s,terminated:o}={}){const i=indexedDB.open(e,t),c=pe(i);return n&&i.addEventListener("upgradeneeded",a=>{n(pe(i.result),a.oldVersion,a.newVersion,pe(i.transaction),a)}),r&&i.addEventListener("blocked",a=>r(a.oldVersion,a.newVersion,a)),c.then(a=>{o&&a.addEventListener("close",()=>o()),s&&a.addEventListener("versionchange",l=>s(l.oldVersion,l.newVersion,l))}).catch(()=>{}),c}function el(e,{blocked:t}={}){const r=indexedDB.deleteDatabase(e);return t&&r.addEventListener("blocked",n=>t(n.oldVersion,n)),pe(r).then(()=>{})}const tl=["get","getKey","getAll","getAllKeys","count"],rl=["put","add","delete","clear"],_r=new Map;function es(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(_r.get(t))return _r.get(t);const r=t.replace(/FromIndex$/,""),n=t!==r,s=rl.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(s||tl.includes(r)))return;const o=async function(i,...c){const a=this.transaction(i,s?"readwrite":"readonly");let l=a.store;return n&&(l=l.index(c.shift())),(await Promise.all([l[r](...c),s&&a.done]))[0]};return _r.set(t,o),o}Io(e=>({...e,get:(t,r,n)=>es(t,r)||e.get(t,r,n),has:(t,r)=>!!es(t,r)||e.has(t,r)}));const nl=["continue","continuePrimaryKey","advance"],ts={},Hr=new WeakMap,Po=new WeakMap,sl={get(e,t){if(!nl.includes(t))return e[t];let r=ts[t];return r||(r=ts[t]=function(...n){Hr.set(this,Po.get(this)[t](...n))}),r}};async function*ol(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;t=t;const r=new Proxy(t,sl);for(Po.set(r,t),ar.set(r,Ur(t));t;)yield r,t=await(Hr.get(r)||t.continue()),Hr.delete(r)}function rs(e,t){return t===Symbol.asyncIterator&&Lr(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&Lr(e,[IDBIndex,IDBObjectStore])}Io(e=>({...e,get(t,r,n){return rs(t,r)?ol:e.get(t,r,n)},has(t,r){return rs(t,r)||e.has(t,r)}}));const jo=e=>`ES:${e}:DB`,il=async e=>{try{const t=jo(e);return Qa(t,zs,{upgrade(r){r.objectStoreNames.contains(q)||r.createObjectStore(q,{keyPath:"params.id"}).createIndex("byTime","params.createdAt")}})}catch(t){throw new Error(`Cannot open a database for the user ${e}`,{cause:t})}},cl=e=>e.close(),al=async e=>{const t=jo(e);return el(t)},ll=async e=>lt(js,e),ul=async(e,t,r)=>{try{const n=ie(e.params),o={content:await or(e.body,t,n,e.params.id),params:e.params};await r.put(q,o)}catch(n){throw new Error("Cannot encrypt and add the given email to the database",{cause:n})}},hl=async(e,t,r)=>{try{const n=await Promise.all(e.map(async o=>{const i=ie(o.params);return{content:await or(o.body,t,i,o.params.id),params:o.params}})),s=r.transaction(q,"readwrite");await Promise.all([...n.map(o=>s.store.put(o)),s.done])}catch(n){throw new Error("Cannot encrypt and add emails to the database",{cause:n})}},On=async(e,t)=>{try{const r=ie(t.params);return{body:await ir(t.content,e,r),params:t.params}}catch(r){throw new Error("Cannot decrypt the given email",{cause:r})}},fl=async(e,t,r)=>{try{const n=await r.get(q,e);if(!n)throw new Error(`DB cannot find email with id ${e}`);return On(t,n)}catch(n){throw new Error(`Cannot fetch the email ${e} from the database`,{cause:n})}},dl=async(e,t)=>{try{const r=await t.getAll(q);return(await Promise.all(r.map(async s=>{const o=ie(s.params);return{body:await ir(s.content,e,o),params:s.params}}))).filter(s=>s!==null)}catch(r){throw new Error("Cannot fetch and decrypt all emails from the database",{cause:r})}},pl=async(e,t)=>{await t.delete(q,e)},Rn=async e=>await e.count(q),Bo=async(e,t)=>{try{const r=t.transaction(q,"readwrite");let s=await r.store.index("byTime").openCursor(),o=0;for(;s&&o<e;)await s.delete(),o++,s=await s.continue();await r.done}catch(r){throw new Error(`Cannot delete ${e} oldests emails from the database`,{cause:r})}},yl=async(e,t)=>{try{const r=await Rn(e);if(r<=t)return;await Bo(r-t,e)}catch(r){throw new Error(`Cannot enforce the maximum of ${t} emails on the database`,{cause:r})}},Fo=async(e,t,r)=>{try{const s=e.transaction(q,"readonly").store.index("byTime"),o=[];let i=await s.openCursor(null,r);for(;i;)o.push(i.value),i=await i.continue();return await Promise.all(o.map(a=>On(t,a)))}catch(n){throw new Error("Cannot fetch emails from database",{cause:n})}},No=async(e,t)=>Fo(e,t,"prev"),ml=async(e,t)=>Fo(e,t,"next"),Lo=async(e,t,r,n)=>{try{const o=e.transaction(q,"readonly").store.index("byTime"),i=[];let c;if(n){const h=IDBKeyRange.upperBound(n,!0);c=await o.openCursor(h,"prev")}else c=await o.openCursor(null,"prev");let a=0,l;for(;c&&a<r;)i.push(c.value),l=c.key,a++,c=await c.continue();return{emails:await Promise.all(i.map(h=>On(t,h))),nextCursor:a===r?l:void 0}}catch(s){throw new Error(`Cannot fetch email batch of ${r} from the database`,{cause:s})}};function Do(e){return To(e).byteLength}function gl(){return{esCache:new Map,cacheSize:0,isCacheLimited:!1,isCacheReady:!0}}const wl=async(e,t)=>{const r=gl();r.isCacheReady=!1;try{const n=await Rn(t);if(!n)return r.isCacheReady=!0,r;if(n<=jr){const s=await No(t,e);zr(s,r)}else{let s,o=!1;for(;!o;){const{emails:i,nextCursor:c}=await Lo(t,e,jr,s);if(!c||!i.length)break;s=c,zr(i,r)||(o=!0)}}return r}catch(n){throw new Error(`Email caching failed: ${n}`)}},Mo=async(e,t)=>{const r=t.esCache.get(e);if(!r)throw new Error(`Email not found in cache for ID: ${e}`);return r},bl=async(e,t)=>{try{const r=await Mo(e,t),n=Do(r);t.esCache.delete(e)&&(t.cacheSize-=n)}catch(r){throw new Error(`Failed to delete email with ID ${e}`,{cause:r})}};function zr(e,t){try{for(const r of e){const n=Uo(r,t);if(!n.success)return n}return{success:!0}}catch(r){throw new Error("Failed to add emails to the cache",{cause:r})}}const Uo=(e,t)=>{try{if(t.esCache.has(e.params.id))return{success:!1,reason:"email already exists in cache"};const r=Do(e);return t.cacheSize+r>Hs?(t.isCacheLimited=!0,{success:!1,reason:"hit cache limit"}):(t.esCache.set(e.params.id,e),t.cacheSize+=r,{success:!0})}catch(r){throw new Error("Failed to add email to the cache",{cause:r})}};var A;function H(e,t,r){const n=typeof r,s=typeof e;if(n!=="undefined"){if(s!=="undefined"){if(r){if(s==="function"&&n===s)return function(c){return e(r(c))};if(t=e.constructor,t===r.constructor){if(t===Array)return r.concat(e);if(t===Map){var o=new Map(r);for(var i of e)o.set(i[0],i[1]);return o}if(t===Set){i=new Set(r);for(o of e.values())i.add(o);return i}}}return e}return r}return s==="undefined"?t:e}function Re(e,t){return typeof e>"u"?t:e}function N(){return Object.create(null)}function Z(e){return typeof e=="string"}function nt(e){return typeof e=="object"}function st(e,t){if(Z(t))e=e[t];else for(let r=0;e&&r<t.length;r++)e=e[t[r]];return e}const El=/[^\p{L}\p{N}]+/u,xl=/(\d{3})/g,kl=/(\D)(\d{3})/g,vl=/(\d{3})(\D)/g,ns=/[\u0300-\u036f]/g;function ot(e={}){if(!this||this.constructor!==ot)return new ot(...arguments);if(arguments.length)for(e=0;e<arguments.length;e++)this.assign(arguments[e]);else this.assign(e)}A=ot.prototype;A.assign=function(e){this.normalize=H(e.normalize,!0,this.normalize);let t=e.include,r=t||e.exclude||e.split,n;if(r||r===""){if(typeof r=="object"&&r.constructor!==RegExp){let s="";n=!t,t||(s+="\\p{Z}"),r.letter&&(s+="\\p{L}"),r.number&&(s+="\\p{N}",n=!!t),r.symbol&&(s+="\\p{S}"),r.punctuation&&(s+="\\p{P}"),r.control&&(s+="\\p{C}"),(r=r.char)&&(s+=typeof r=="object"?r.join(""):r);try{this.split=new RegExp("["+(t?"^":"")+s+"]+","u")}catch{this.split=/\s+/}}else this.split=r,n=r===!1||"a1a".split(r).length<2;this.numeric=H(e.numeric,n)}else{try{this.split=H(this.split,El)}catch{this.split=/\s+/}this.numeric=H(e.numeric,H(this.numeric,!0))}if(this.prepare=H(e.prepare,null,this.prepare),this.finalize=H(e.finalize,null,this.finalize),r=e.filter,this.filter=typeof r=="function"?r:H(r&&new Set(r),null,this.filter),this.dedupe=H(e.dedupe,!0,this.dedupe),this.matcher=H((r=e.matcher)&&new Map(r),null,this.matcher),this.mapper=H((r=e.mapper)&&new Map(r),null,this.mapper),this.stemmer=H((r=e.stemmer)&&new Map(r),null,this.stemmer),this.replacer=H(e.replacer,null,this.replacer),this.minlength=H(e.minlength,1,this.minlength),this.maxlength=H(e.maxlength,1024,this.maxlength),this.rtl=H(e.rtl,!1,this.rtl),(this.cache=r=H(e.cache,!0,this.cache))&&(this.F=null,this.L=typeof r=="number"?r: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 s of this.matcher.keys())this.h+=(this.h?"|":"")+s;if(this.stemmer)for(const s of this.stemmer.keys())this.A+=(this.A?"|":"")+s;return this};A.addStemmer=function(e,t){return this.stemmer||(this.stemmer=new Map),this.stemmer.set(e,t),this.A+=(this.A?"|":"")+e,this.K=null,this.cache&&Te(this),this};A.addFilter=function(e){return typeof e=="function"?this.filter=e:(this.filter||(this.filter=new Set),this.filter.add(e)),this.cache&&Te(this),this};A.addMapper=function(e,t){return typeof e=="object"?this.addReplacer(e,t):e.length>1?this.addMatcher(e,t):(this.mapper||(this.mapper=new Map),this.mapper.set(e,t),this.cache&&Te(this),this)};A.addMatcher=function(e,t){return typeof e=="object"?this.addReplacer(e,t):e.length<2&&(this.dedupe||this.mapper)?this.addMapper(e,t):(this.matcher||(this.matcher=new Map),this.matcher.set(e,t),this.h+=(this.h?"|":"")+e,this.J=null,this.cache&&Te(this),this)};A.addReplacer=function(e,t){return typeof e=="string"?this.addMatcher(e,t):(this.replacer||(this.replacer=[]),this.replacer.push(e,t),this.cache&&Te(this),this)};A.encode=function(e,t){if(this.cache&&e.length<=this.H)if(this.F){if(this.B.has(e))return this.B.get(e)}else this.F=setTimeout(Te,50,this);this.normalize&&(typeof this.normalize=="function"?e=this.normalize(e):e=ns?e.normalize("NFKD").replace(ns,"").toLowerCase():e.toLowerCase()),this.prepare&&(e=this.prepare(e)),this.numeric&&e.length>3&&(e=e.replace(kl,"$1 $2").replace(vl,"$1 $2").replace(xl,"$1 "));const r=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let n=[],s=N(),o,i,c=this.split||this.split===""?e.split(this.split):[e];for(let l=0,u,h;l<c.length;l++)if((u=h=c[l])&&!(u.length<this.minlength||u.length>this.maxlength)){if(t){if(s[u])continue;s[u]=1}else{if(o===u)continue;o=u}if(r)n.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 a=this.D.get(u);if(a||a===""){a&&n.push(a);continue}}else this.F=setTimeout(Te,50,this);if(this.stemmer){this.K||(this.K=new RegExp("(?!^)("+this.A+")$"));let m;for(;m!==u&&u.length>2;)m=u,u=u.replace(this.K,y=>this.stemmer.get(y))}if(u&&(this.mapper||this.dedupe&&u.length>1)){a="";for(let m=0,y="",p,f;m<u.length;m++)p=u.charAt(m),p===y&&this.dedupe||((f=this.mapper&&this.mapper.get(p))||f===""?f===y&&this.dedupe||!(y=f)||(a+=f):a+=y=p);u=a}if(this.matcher&&u.length>1&&(this.J||(this.J=new RegExp("("+this.h+")","g")),u=u.replace(this.J,m=>this.matcher.get(m))),u&&this.replacer)for(a=0;u&&a<this.replacer.length;a+=2)u=u.replace(this.replacer[a],this.replacer[a+1]);if(this.cache&&h.length<=this.I&&(this.D.set(h,u),this.D.size>this.L&&(this.D.clear(),this.I=this.I/1.1|0)),u){if(u!==h)if(t){if(s[u])continue;s[u]=1}else{if(i===u)continue;i=u}n.push(u)}}}return this.finalize&&(n=this.finalize(n)||n),this.cache&&e.length<=this.H&&(this.B.set(e,n),this.B.size>this.L&&(this.B.clear(),this.H=this.H/1.1|0)),n};function Te(e){e.F=null,e.B.clear(),e.D.clear()}function Cn(e,t,r){r||(t||typeof e!="object"?typeof t=="object"&&(r=t,t=0):r=e),r&&(e=r.query||e,t=r.limit||t);let n=""+(t||0);r&&(n+=(r.offset||0)+!!r.context+!!r.suggest+(r.resolve!==!1)+(r.resolution||this.resolution)+(r.boost||0)),e=(""+e).toLowerCase(),this.cache||(this.cache=new Ke);let s=this.cache.get(e+n);if(!s){const o=r&&r.cache;o&&(r.cache=!1),s=this.search(e,t,r),o&&(r.cache=o),this.cache.set(e+n,s)}return s}function Ke(e){this.limit=e&&e!==!0?e:1e3,this.cache=new Map,this.h=""}Ke.prototype.set=function(e,t){this.cache.set(this.h=e,t),this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};Ke.prototype.get=function(e){const t=this.cache.get(e);return t&&this.h!==e&&(this.cache.delete(e),this.cache.set(this.h=e,t)),t};Ke.prototype.remove=function(e){for(const t of this.cache){const r=t[0];t[1].includes(e)&&this.cache.delete(r)}};Ke.prototype.clear=function(){this.cache.clear(),this.h=""};const ss={normalize:!1,numeric:!1,dedupe:!1},Et={},Kr=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"]]),os=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),is=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"],cs={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 Ho={Exact:ss,Default:Et,Normalize:Et,LatinBalance:{mapper:Kr},LatinAdvanced:{mapper:Kr,matcher:os,replacer:is},LatinExtra:{mapper:Kr,replacer:is.concat([/(?!^)[aeo]/g,""]),matcher:os},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(e){for(let r=0;r<e.length;r++){var t=e[r];let n=t.charAt(0),s=cs[n];for(let o=1,i;o<t.length&&(i=t.charAt(o),i==="h"||i==="w"||!(i=cs[i])||i===s||(n+=i,s=i,n.length!==4));o++);e[r]=n}}},CJK:{split:""},LatinExact:ss,LatinDefault:Et,LatinSimple:Et};function as(e,t,r,n){let s=[];for(let o=0,i;o<e.index.length;o++)if(i=e.index[o],t>=i.length)t-=i.length;else{t=i[n?"splice":"slice"](t,r);const c=t.length;if(c&&(s=s.length?s.concat(t):t,r-=c,n&&(e.length-=c),!r))break;t=0}return s}function je(e){if(!this||this.constructor!==je)return new je(e);this.index=e?[e]:[],this.length=e?e.length:0;const t=this;return new Proxy([],{get(r,n){if(n==="length")return t.length;if(n==="push")return function(s){t.index[t.index.length-1].push(s),t.length++};if(n==="pop")return function(){if(t.length)return t.length--,t.index[t.index.length-1].pop()};if(n==="indexOf")return function(s){let o=0;for(let i=0,c,a;i<t.index.length;i++){if(c=t.index[i],a=c.indexOf(s),a>=0)return o+a;o+=c.length}return-1};if(n==="includes")return function(s){for(let o=0;o<t.index.length;o++)if(t.index[o].includes(s))return!0;return!1};if(n==="slice")return function(s,o){return as(t,s||0,o||t.length,!1)};if(n==="splice")return function(s,o){return as(t,s||0,o||t.length,!0)};if(n==="constructor")return Array;if(typeof n!="symbol")return(r=t.index[n/2**31|0])&&r[n]},set(r,n,s){return r=n/2**31|0,(t.index[r]||(t.index[r]=[]))[n]=s,t.length++,!0}})}je.prototype.clear=function(){this.index.length=0};je.prototype.push=function(){};function Q(e=8){if(!this||this.constructor!==Q)return new Q(e);this.index=N(),this.h=[],this.size=0,e>32?(this.B=$o,this.A=BigInt(e)):(this.B=zo,this.A=e)}Q.prototype.get=function(e){const t=this.index[this.B(e)];return t&&t.get(e)};Q.prototype.set=function(e,t){var r=this.B(e);let n=this.index[r];n?(r=n.size,n.set(e,t),(r-=n.size)&&this.size++):(this.index[r]=n=new Map([[e,t]]),this.h.push(n),this.size++)};function ee(e=8){if(!this||this.constructor!==ee)return new ee(e);this.index=N(),this.h=[],this.size=0,e>32?(this.B=$o,this.A=BigInt(e)):(this.B=zo,this.A=e)}ee.prototype.add=function(e){var t=this.B(e);let r=this.index[t];r?(t=r.size,r.add(e),(t-=r.size)&&this.size++):(this.index[t]=r=new Set([e]),this.h.push(r),this.size++)};A=Q.prototype;A.has=ee.prototype.has=function(e){const t=this.index[this.B(e)];return t&&t.has(e)};A.delete=ee.prototype.delete=function(e){const t=this.index[this.B(e)];t&&t.delete(e)&&this.size--};A.clear=ee.prototype.clear=function(){this.index=N(),this.h=[],this.size=0};A.values=ee.prototype.values=function*(){for(let e=0;e<this.h.length;e++)for(let t of this.h[e].values())yield t};A.keys=ee.prototype.keys=function*(){for(let e=0;e<this.h.length;e++)for(let t of this.h[e].keys())yield t};A.entries=ee.prototype.entries=function*(){for(let e=0;e<this.h.length;e++)for(let t of this.h[e].entries())yield t};function zo(e){let t=2**this.A-1;if(typeof e=="number")return e&t;let r=0,n=this.A+1;for(let s=0;s<e.length;s++)r=(r*n^e.charCodeAt(s))&t;return this.A===32?r+2**31:r}function $o(e){let t=BigInt(2)**this.A-BigInt(1);var r=typeof e;if(r==="bigint")return e&t;if(r==="number")return BigInt(e)&t;r=BigInt(0);let n=this.A+BigInt(1);for(let s=0;s<e.length;s++)r=(r*n^BigInt(e.charCodeAt(s)))&t;return r}let Ce,Ge;async function Sl(e){e=e.data;var t=e.task;const r=e.id;let n=e.args;switch(t){case"init":Ge=e.options||{},(t=e.factory)?(Function("return "+t)()(self),Ce=new self.FlexSearch.Index(Ge),delete self.FlexSearch):Ce=new te(Ge),postMessage({id:r});break;default:let s;t==="export"&&(n[1]?(n[0]=Ge.export,n[2]=0,n[3]=1):n=null),t==="import"?n[0]&&(e=await Ge.import.call(Ce,n[0]),Ce.import(n[0],e)):((s=n&&Ce[t].apply(Ce,n))&&s.then&&(s=await s),s&&s.await&&(s=await s.await),t==="search"&&s.result&&(s=s.result)),postMessage(t==="search"?{id:r,msg:s}:{id:r})}}function In(e){Ie.call(e,"add"),Ie.call(e,"append"),Ie.call(e,"search"),Ie.call(e,"update"),Ie.call(e,"remove"),Ie.call(e,"searchCache")}let $r,ls,_t;function Tl(){$r=_t=0}function Ie(e){this[e+"Async"]=function(){const t=arguments;var r=t[t.length-1];let n;if(typeof r=="function"&&(n=r,delete t[t.length-1]),$r?_t||(_t=Date.now()-ls>=this.priority*this.priority*3):($r=setTimeout(Tl,0),ls=Date.now()),_t){const o=this;return new Promise(i=>{setTimeout(function(){i(o[e+"Async"].apply(o,t))},0)})}const s=this[e].apply(this,t);return r=s.then?s:new Promise(o=>o(s)),n&&r.then(n),r}}let de=0;function Be(e={},t){function r(c){function a(l){l=l.data||l;const u=l.id,h=u&&o.h[u];h&&(h(l.msg),delete o.h[u])}if(this.worker=c,this.h=N(),this.worker)return s?this.worker.on("message",a):this.worker.onmessage=a,e.config?new Promise(function(l){de>1e9&&(de=0),o.h[++de]=function(){l(o)},o.worker.postMessage({id:de,task:"init",factory:n,options:e})}):(this.priority=e.priority||4,this.encoder=t||null,this.worker.postMessage({task:"init",factory:n,options:e}),this)}if(!this||this.constructor!==Be)return new Be(e);let n=typeof self<"u"?self._factory:typeof window<"u"?window._factory:null;n&&(n=n.toString());const s=typeof window>"u",o=this,i=Al(n,s,e.worker);return i.then?i.then(function(c){return r.call(o,c)}):r.call(this,i)}ye("add");ye("append");ye("search");ye("update");ye("remove");ye("clear");ye("export");ye("import");Be.prototype.searchCache=Cn;In(Be.prototype);function ye(e){Be.prototype[e]=function(){const t=this,r=[].slice.call(arguments);var n=r[r.length-1];let s;return typeof n=="function"&&(s=n,r.pop()),n=new Promise(function(o){e==="export"&&typeof r[0]=="function"&&(r[0]=null),de>1e9&&(de=0),t.h[++de]=o,t.worker.postMessage({task:e,id:de,args:r})}),s?(n.then(s),this):n}}function Al(e,t,r){return t?typeof module<"u"?new(require("worker_threads")).Worker(__dirname+"/worker/node.js"):Promise.resolve().then(()=>require("./__vite-browser-external-Dyvby5gX.js")).then(function(n){return new n.Worker("undefined/node/node.mjs")}):e?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+Sl.toString()],{type:"text/javascript"}))):new window.Worker(typeof r=="string"?r:(typeof document>"u"?require("url").pathToFileURL(__filename).href:kr&&kr.tagName.toUpperCase()==="SCRIPT"&&kr.src||new URL("index.js",document.baseURI).href).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"})}Fe.prototype.add=function(e,t,r){if(nt(e)&&(t=e,e=st(t,this.key)),t&&(e||e===0)){if(!r&&this.reg.has(e))return this.update(e,t);for(let c=0,a;c<this.field.length;c++){a=this.B[c];var n=this.index.get(this.field[c]);if(typeof a=="function"){var s=a(t);s&&n.add(e,s,r,!0)}else s=a.G,(!s||s(t))&&(a.constructor===String?a=[""+a]:Z(a)&&(a=[a]),Vr(t,a,this.D,0,n,e,a[0],r))}if(this.tag)for(n=0;n<this.A.length;n++){var o=this.A[n];s=this.tag.get(this.F[n]);let c=N();if(typeof o=="function"){if(o=o(t),!o)continue}else{var i=o.G;if(i&&!i(t))continue;o.constructor===String&&(o=""+o),o=st(t,o)}if(s&&o){Z(o)&&(o=[o]);for(let a=0,l,u;a<o.length;a++)if(l=o[a],!c[l]&&(c[l]=1,(i=s.get(l))?u=i:s.set(l,u=[]),!r||!u.includes(e))){if(u.length===2**31-1){if(i=new je(u),this.fastupdate)for(let h of this.reg.values())h.includes(u)&&(h[h.indexOf(u)]=i);s.set(l,u=i)}u.push(e),this.fastupdate&&((i=this.reg.get(e))?i.push(u):this.reg.set(e,[u]))}}}if(this.store&&(!r||!this.store.has(e))){let c;if(this.h){c=N();for(let a=0,l;a<this.h.length;a++){if(l=this.h[a],(r=l.G)&&!r(t))continue;let u;if(typeof l=="function"){if(u=l(t),!u)continue;l=[l.O]}else if(Z(l)||l.constructor===String){c[l]=t[l];continue}Yr(t,c,l,0,l[0],u)}}this.store.set(e,c||t)}this.worker&&(this.fastupdate||this.reg.add(e))}return this};function Yr(e,t,r,n,s,o){if(e=e[s],n===r.length-1)t[s]=o||e;else if(e)if(e.constructor===Array)for(t=t[s]=Array(e.length),s=0;s<e.length;s++)Yr(e,t,r,n,s);else t=t[s]||(t[s]=N()),s=r[++n],Yr(e,t,r,n,s)}function Vr(e,t,r,n,s,o,i,c){if(e=e[i])if(n===t.length-1){if(e.constructor===Array){if(r[n]){for(t=0;t<e.length;t++)s.add(o,e[t],!0,!0);return}e=e.join(" ")}s.add(o,e,c,!0)}else if(e.constructor===Array)for(i=0;i<e.length;i++)Vr(e,t,r,n,s,o,i,c);else i=t[++n],Vr(e,t,r,n,s,o,i,c)}function Pn(e,t,r,n){if(!e.length)return e;if(e.length===1)return e=e[0],e=r||e.length>t?e.slice(r,r+t):e,n?Pe.call(this,e):e;let s=[];for(let o=0,i,c;o<e.length;o++)if((i=e[o])&&(c=i.length)){if(r){if(r>=c){r-=c;continue}i=i.slice(r,r+t),c=i.length,r=0}if(c>t&&(i=i.slice(0,t),c=t),!s.length&&c>=t)return n?Pe.call(this,i):i;if(s.push(i),t-=c,!t)break}return s=s.length>1?[].concat.apply([],s):s[0],n?Pe.call(this,s):s}function lr(e,t,r,n){var s=n[0];if(s[0]&&s[0].query)return e[t].apply(e,s);if(!(t!=="and"&&t!=="not"||e.result.length||e.await||s.suggest))return n.length>1&&(s=n[n.length-1]),(n=s.resolve)?e.await||e.result:e;let o=[],i=0,c=0,a,l,u,h,m;for(t=0;t<n.length;t++)if(s=n[t]){var y=void 0;if(s.constructor===P)y=s.await||s.result;else if(s.then||s.constructor===Array)y=s;else{i=s.limit||0,c=s.offset||0,u=s.suggest,l=s.resolve,a=((h=s.highlight||e.highlight)||s.enrich)&&l,y=s.queue;let p=s.async||y,f=s.index,d=s.query;if(f?e.index||(e.index=f):f=e.index,d||s.tag){const b=s.field||s.pluck;if(b&&(!d||e.query&&!h||(e.query=d,e.field=b,e.highlight=h),f=f.index.get(b)),y&&(m||e.await)){m=1;let w;const E=e.C.length,x=new Promise(function(k){w=k});(function(k,v){x.h=function(){v.index=null,v.resolve=!1;let S=p?k.searchAsync(v):k.search(v);return S.then?S.then(function(T){return e.C[E]=T=T.result||T,w(T),T}):(S=S.result||S,w(S),S)}})(f,Object.assign({},s)),e.C.push(x),o[t]=x;continue}else s.resolve=!1,s.index=null,y=p?f.searchAsync(s):f.search(s),s.resolve=l,s.index=f}else if(s.and)y=xt(s,"and",f);else if(s.or)y=xt(s,"or",f);else if(s.not)y=xt(s,"not",f);else if(s.xor)y=xt(s,"xor",f);else continue}y.await?(m=1,y=y.await):y.then?(m=1,y=y.then(function(p){return p.result||p})):y=y.result||y,o[t]=y}if(m&&!e.await&&(e.await=new Promise(function(p){e.return=p})),m){const p=Promise.all(o).then(function(f){for(let d=0;d<e.C.length;d++)if(e.C[d]===p){e.C[d]=function(){return r.call(e,f,i,c,a,l,u,h)};break}jn(e)});e.C.push(p)}else if(e.await)e.C.push(function(){return r.call(e,o,i,c,a,l,u,h)});else return r.call(e,o,i,c,a,l,u,h);return l?e.await||e.result:e}function xt(e,t,r){e=e[t];const n=e[0]||e;return n.index||(n.index=r),r=new P(n),e.length>1&&(r=r[t].apply(r,e.slice(1))),r}P.prototype.or=function(){return lr(this,"or",_l,arguments)};function _l(e,t,r,n,s,o,i){return e.length&&(this.result.length&&e.push(this.result),e.length<2?this.result=e[0]:(this.result=Yo(e,t,r,!1,this.h),r=0)),s&&(this.await=null),s?this.resolve(t,r,n,i):this}P.prototype.and=function(){return lr(this,"and",Kl,arguments)};function Kl(e,t,r,n,s,o,i){if(!o&&!this.result.length)return s?this.result:this;let c;if(e.length)if(this.result.length&&e.unshift(this.result),e.length<2)this.result=e[0];else{let a=0;for(let l=0,u,h;l<e.length;l++)if((u=e[l])&&(h=u.length))a<h&&(a=h);else if(!o){a=0;break}a?(this.result=Mt(e,a,t,r,o,this.h,s),c=!0):this.result=[]}else o||(this.result=e);return s&&(this.await=null),s?this.resolve(t,r,n,i,c):this}P.prototype.xor=function(){return lr(this,"xor",Ol,arguments)};function Ol(e,t,r,n,s,o,i){if(e.length)if(this.result.length&&e.unshift(this.result),e.length<2)this.result=e[0];else{e:{o=r;var c=this.h;const a=[],l=N();let u=0;for(let h=0,m;h<e.length;h++)if(m=e[h]){u<m.length&&(u=m.length);for(let y=0,p;y<m.length;y++)if(p=m[y])for(let f=0,d;f<p.length;f++)d=p[f],l[d]=l[d]?2:1}for(let h=0,m,y=0;h<u;h++)for(let p=0,f;p<e.length;p++)if((f=e[p])&&(m=f[h])){for(let d=0,b;d<m.length;d++)if(b=m[d],l[b]===1)if(o)o--;else if(s){if(a.push(b),a.length===t){e=a;break e}}else{const w=h+(p?c:0);if(a[w]||(a[w]=[]),a[w].push(b),++y===t){e=a;break e}}}e=a}this.result=e,c=!0}else o||(this.result=e);return s&&(this.await=null),s?this.resolve(t,r,n,i,c):this}P.prototype.not=function(){return lr(this,"not",Rl,arguments)};function Rl(e,t,r,n,s,o,i){if(!o&&!this.result.length)return s?this.result:this;if(e.length&&this.result.length){e:{o=r;var c=[];e=new Set(e.flat().flat());for(let a=0,l,u=0;a<this.result.length;a++)if(l=this.result[a]){for(let h=0,m;h<l.length;h++)if(m=l[h],!e.has(m)){if(o)o--;else if(s){if(c.push(m),c.length===t){e=c;break e}}else if(c[a]||(c[a]=[]),c[a].push(m),++u===t){e=c;break e}}}e=c}this.result=e,c=!0}return s&&(this.await=null),s?this.resolve(t,r,n,i,c):this}function Kt(e,t,r,n,s){let o,i,c;typeof s=="string"?(o=s,s=""):o=s.template,i=o.indexOf("$1"),c=o.substring(i+2),i=o.substring(0,i);let a=s&&s.boundary,l=!s||s.clip!==!1,u=s&&s.merge&&c&&i&&new RegExp(c+" "+i,"g");s=s&&s.ellipsis;var h=0;if(typeof s=="object"){var m=s.template;h=m.length-2,s=s.pattern}typeof s!="string"&&(s=s===!1?"":"..."),h&&(s=m.replace("$1",s)),m=s.length-h;let y,p;typeof a=="object"&&(y=a.before,y===0&&(y=-1),p=a.after,p===0&&(p=-1),a=a.total||9e5),h=new Map;for(let Er=0,ge,zn,ze;Er<t.length;Er++){let $e;if(n)$e=t,ze=n;else{var f=t[Er];if(ze=f.field,!ze)continue;$e=f.result}zn=r.get(ze),ge=zn.encoder,f=h.get(ge),typeof f!="string"&&(f=ge.encode(e),h.set(ge,f));for(let yt=0;yt<$e.length;yt++){var d=$e[yt].doc;if(!d||(d=st(d,ze),!d))continue;var b=d.trim().split(/\s+/);if(!b.length)continue;d="";var w=[];let mt=[];for(var E=-1,x=-1,k=0,v=0;v<b.length;v++){var S=b[v],T=ge.encode(S);T=T.length>1?T.join(" "):T[0];let K;if(T&&S){for(var _=S.length,C=(ge.split?S.replace(ge.split,""):S).length-T.length,O="",j=0,L=0;L<f.length;L++){var M=f[L];if(M){var B=M.length;B+=C<0?0:C,j&&B<=j||(M=T.indexOf(M),M>-1&&(O=(M?S.substring(0,M):"")+i+S.substring(M,M+B)+c+(M+B<_?S.substring(M+B):""),j=B,K=!0))}}O&&(a&&(E<0&&(E=d.length+(d?1:0)),x=d.length+(d?1:0)+O.length,k+=_,mt.push(w.length),w.push({match:O})),d+=(d?" ":"")+O)}if(!K)S=b[v],d+=(d?" ":"")+S,a&&w.push({text:S});else if(a&&k>=a)break}if(k=mt.length*(o.length-2),y||p||a&&d.length-k>a)if(k=a+k-m*2,v=x-E,y>0&&(v+=y),p>0&&(v+=p),v<=k)b=y?E-(y>0?y:0):E-((k-v)/2|0),w=p?x+(p>0?p:0):b+k,l||(b>0&&d.charAt(b)!==" "&&d.charAt(b-1)!==" "&&(b=d.indexOf(" ",b),b<0&&(b=0)),w<d.length&&d.charAt(w-1)!==" "&&d.charAt(w)!==" "&&(w=d.lastIndexOf(" ",w),w<x?w=x:++w)),d=(b?s:"")+d.substring(b,w)+(w<d.length?s:"");else{for(x=[],E={},k={},v={},S={},T={},O=C=_=0,L=j=1;;){var ne=void 0;for(let K=0,F;K<mt.length;K++){if(F=mt[K],O)if(C!==O){if(v[K+1])continue;if(F+=O,E[F]){_-=m,k[K+1]=1,v[K+1]=1;continue}if(F>=w.length-1){if(F>=w.length){v[K+1]=1,F>=b.length&&(k[K+1]=1);continue}_-=m}if(d=w[F].text,B=p&&T[K])if(B>0){if(d.length>B)if(v[K+1]=1,l)d=d.substring(0,B);else continue;(B-=d.length)||(B=-1),T[K]=B}else{v[K+1]=1;continue}if(_+d.length+1<=a)d=" "+d,x[K]+=d;else if(l)ne=a-_-1,ne>0&&(d=" "+d.substring(0,ne),x[K]+=d),v[K+1]=1;else{v[K+1]=1;continue}}else{if(v[K])continue;if(F-=C,E[F]){_-=m,v[K]=1,k[K]=1;continue}if(F<=0){if(F<0){v[K]=1,k[K]=1;continue}_-=m}if(d=w[F].text,B=y&&S[K])if(B>0){if(d.length>B)if(v[K]=1,l)d=d.substring(d.length-B);else continue;(B-=d.length)||(B=-1),S[K]=B}else{v[K]=1;continue}if(_+d.length+1<=a)d+=" ",x[K]=d+x[K];else if(l)ne=d.length+1-(a-_),ne>=0&&ne<d.length&&(d=d.substring(ne)+" ",x[K]=d+x[K]),v[K]=1;else{v[K]=1;continue}}else{d=w[F].match,y&&(S[K]=y),p&&(T[K]=p),K&&_++;let xr;if(F?!K&&m&&(_+=m):(k[K]=1,v[K]=1),F>=b.length-1||F<w.length-1&&w[F+1].match?xr=1:m&&(_+=m),_-=o.length-2,!K||_+d.length<=a)x[K]=d;else{ne=j=L=k[K]=0;break}xr&&(k[K+1]=1,v[K+1]=1)}_+=d.length,ne=E[F]=1}if(ne)C===O?O++:C++;else{if(C===O?j=0:L=0,!j&&!L)break;j?(C++,O=C):O++}}d="";for(let K=0,F;K<x.length;K++)F=(k[K]?K?" ":"":(K&&!s?" ":"")+s)+x[K],d+=F;s&&!k[x.length]&&(d+=s)}u&&(d=d.replace(u," ")),$e[yt].highlight=d}if(n)break}return t}function P(e,t){if(!this||this.constructor!==P)return new P(e,t);let r=0,n,s,o,i,c,a;if(e&&e.index){const l=e;if(t=l.index,r=l.boost||0,s=l.query){o=l.field||l.pluck,i=l.highlight;const u=l.resolve;e=l.async||l.queue,l.resolve=!1,l.index=null,e=e?t.searchAsync(l):t.search(l),l.resolve=u,l.index=t,e=e.result||e}else e=[]}if(e&&e.then){const l=this;e=e.then(function(u){l.C[0]=l.result=u.result||u,jn(l)}),n=[e],e=[],c=new Promise(function(u){a=u})}this.index=t||null,this.result=e||[],this.h=r,this.C=n||[],this.await=c||null,this.return=a||null,this.highlight=i||null,this.query=s||"",this.field=o||""}A=P.prototype;A.limit=function(e){if(this.await){const t=this;this.C.push(function(){return t.limit(e).result})}else if(this.result.length){const t=[];for(let r=0,n;r<this.result.length;r++)if(n=this.result[r])if(n.length<=e){if(t[r]=n,e-=n.length,!e)break}else{t[r]=n.slice(0,e);break}this.result=t}return this};A.offset=function(e){if(this.await){const t=this;this.C.push(function(){return t.offset(e).result})}else if(this.result.length){const t=[];for(let r=0,n;r<this.result.length;r++)(n=this.result[r])&&(n.length<=e?e-=n.length:(t[r]=n.slice(e),e=0));this.result=t}return this};A.boost=function(e){if(this.await){const t=this;this.C.push(function(){return t.boost(e).result})}else this.h+=e;return this};function jn(e,t){let r=e.result;var n=e.await;e.await=null;for(let s=0,o;s<e.C.length;s++)if(o=e.C[s]){if(typeof o=="function")r=o(),e.C[s]=r=r.result||r,s--;else if(o.h)r=o.h(),e.C[s]=r=r.result||r,s--;else if(o.then)return e.await=n}return n=e.return,e.C=[],e.return=null,t||n(r),r}A.resolve=function(e,t,r,n,s){let o=this.await?jn(this,!0):this.result;if(o.then){const i=this;return o.then(function(){return i.resolve(e,t,r,n,s)})}return o.length&&(typeof e=="object"?(n=e.highlight||this.highlight,r=!!n||e.enrich,t=e.offset,e=e.limit):(n=n||this.highlight,r=!!n||r),o=s?r?Pe.call(this.index,o):o:Pn.call(this.index,o,e||100,t,r)),this.finalize(o,n)};A.finalize=function(e,t){if(e.then){const n=this;return e.then(function(s){return n.finalize(s,t)})}t&&e.length&&this.query&&(e=Kt(this.query,e,this.index.index,this.field,t));const r=this.return;return this.highlight=this.index=this.result=this.C=this.await=this.return=null,this.query=this.field="",r&&r(e),e};function Mt(e,t,r,n,s,o,i){const c=e.length;let a=[],l,u;l=N();for(let h=0,m,y,p,f;h<t;h++)for(let d=0;d<c;d++)if(p=e[d],h<p.length&&(m=p[h]))for(let b=0;b<m.length;b++){if(y=m[b],(u=l[y])?l[y]++:(u=0,l[y]=1),f=a[u]||(a[u]=[]),!i){let w=h+(d||!s?0:o||0);f=f[w]||(f[w]=[])}if(f.push(y),i&&r&&u===c-1&&f.length-n===r)return n?f.slice(n):f}if(e=a.length)if(s)a=a.length>1?Yo(a,r,n,i,o):(a=a[0])&&r&&a.length>r||n?a.slice(n,r+n):a;else{if(e<c)return[];if(a=a[e-1],r||n)if(i)(a.length>r||n)&&(a=a.slice(n,r+n));else{s=[];for(let h=0,m;h<a.length;h++)if(m=a[h]){if(n&&m.length>n)n-=m.length;else if((r&&m.length>r||n)&&(m=m.slice(n,r+n),r-=m.length,n&&(n-=m.length)),s.push(m),!r)break}a=s}}return a}function Yo(e,t,r,n,s){const o=[],i=N();let c;var a=e.length;let l;if(n){for(s=a-1;s>=0;s--)if(l=(n=e[s])&&n.length){for(a=0;a<l;a++)if(c=n[a],!i[c]){if(i[c]=1,r)r--;else if(o.push(c),o.length===t)return o}}}else for(let u=a-1,h,m=0;u>=0;u--){h=e[u];for(let y=0;y<h.length;y++)if(l=(n=h[y])&&n.length){for(let p=0;p<l;p++)if(c=n[p],!i[c])if(i[c]=1,r)r--;else{let f=(y+(u<a-1&&s||0))/(u+1)|0;if((o[f]||(o[f]=[])).push(c),++m===t)return o}}}return o}function Cl(e,t,r,n,s){const o=N(),i=[];for(let c=0,a;c<t.length;c++){a=t[c];for(let l=0;l<a.length;l++)o[a[l]]=1}if(s){for(let c=0,a;c<e.length;c++)if(a=e[c],o[a]){if(n)n--;else if(i.push(a),o[a]=0,r&&--r===0)break}}else for(let c=0,a,l;c<e.result.length;c++)for(a=e.result[c],t=0;t<a.length;t++)l=a[t],o[l]&&((i[c]||(i[c]=[])).push(l),o[l]=0);return i}Fe.prototype.search=function(e,t,r,n){r||(!t&&nt(e)?(r=e,e=""):nt(t)&&(r=t,t=0));let s=[];var o=[];let i,c,a,l,u,h,m=0,y=!0,p;if(r){r.constructor===Array&&(r={index:r}),e=r.query||e,i=r.pluck,c=r.merge,l=r.boost,h=i||r.field||(h=r.index)&&(h.index?null:h);var f=this.tag&&r.tag;a=r.suggest,y=r.resolve!==!1,u=r.cache,p=y&&this.store&&r.highlight;var d=!!p||y&&this.store&&r.enrich;t=r.limit||t;var b=r.offset||0;if(t||(t=y?100:0),f&&(!this.db||!n)){f.constructor!==Array&&(f=[f]);var w=[];for(let S=0,T;S<f.length;S++)if(T=f[S],T.field&&T.tag){var E=T.tag;if(E.constructor===Array)for(var x=0;x<E.length;x++)w.push(T.field,E[x]);else w.push(T.field,E)}else{E=Object.keys(T);for(let _=0,C,O;_<E.length;_++)if(C=E[_],O=T[C],O.constructor===Array)for(x=0;x<O.length;x++)w.push(C,O[x]);else w.push(C,O)}if(f=w,!e){if(o=[],w.length)for(f=0;f<w.length;f+=2){if(this.db){if(n=this.index.get(w[f]),!n)continue;o.push(n=n.db.tag(w[f+1],t,b,d))}else n=Il.call(this,w[f],w[f+1],t,b,d);s.push(y?{field:w[f],tag:w[f+1],result:n}:[n])}if(o.length){const S=this;return Promise.all(o).then(function(T){for(let _=0;_<T.length;_++)y?s[_].result=T[_]:s[_]=T[_];return y?s:new P(s.length>1?Mt(s,1,0,0,a,l):s[0],S)})}return y?s:new P(s.length>1?Mt(s,1,0,0,a,l):s[0],this)}}y||i||!(h=h||this.field)||(Z(h)?i=h:(h.constructor===Array&&h.length===1&&(h=h[0]),i=h.field||h.index)),h&&h.constructor!==Array&&(h=[h])}h||(h=this.field);let k;w=(this.worker||this.db)&&!n&&[];for(let S=0,T,_,C;S<h.length;S++){if(_=h[S],this.db&&this.tag&&!this.B[S])continue;let O;if(Z(_)||(O=_,_=O.field,e=O.query||e,t=Re(O.limit,t),b=Re(O.offset,b),a=Re(O.suggest,a),p=y&&this.store&&Re(O.highlight,p),d=!!p||y&&this.store&&Re(O.enrich,d),u=Re(O.cache,u)),n)T=n[S];else{E=O||r||{},x=E.enrich;var v=this.index.get(_);if(f&&(this.db&&(E.tag=f,E.field=h,k=v.db.support_tag_search),!k&&x&&(E.enrich=!1),k||(E.limit=0,E.offset=0)),T=u?v.searchCache(e,f&&!k?0:t,E):v.search(e,f&&!k?0:t,E),f&&!k&&(E.limit=t,E.offset=b),x&&(E.enrich=x),w){w[S]=T;continue}}if(C=(T=T.result||T)&&T.length,f&&C){if(E=[],x=0,this.db&&n){if(!k)for(v=h.length;v<n.length;v++){let j=n[v];if(j&&j.length)x++,E.push(j);else if(!a)return y?s:new P(s,this)}}else for(let j=0,L,M;j<f.length;j+=2){if(L=this.tag.get(f[j]),!L){if(a)continue;return y?s:new P(s,this)}if(M=(L=L&&L.get(f[j+1]))&&L.length)x++,E.push(L);else if(!a)return y?s:new P(s,this)}if(x){if(T=Cl(T,E,t,b,y),C=T.length,!C&&!a)return y?T:new P(T,this);x--}}if(C)o[m]=_,s.push(T),m++;else if(h.length===1)return y?s:new P(s,this)}if(w){if(this.db&&f&&f.length&&!k)for(d=0;d<f.length;d+=2){if(o=this.index.get(f[d]),!o){if(a)continue;return y?s:new P(s,this)}w.push(o.db.tag(f[d+1],t,b,!1))}const S=this;return Promise.all(w).then(function(T){return r&&(r.resolve=y),T.length&&(T=S.search(e,t,r,T)),T})}if(!m)return y?s:new P(s,this);if(i&&(!d||!this.store))return s=s[0],y?s:new P(s,this);for(w=[],b=0;b<o.length;b++){if(f=s[b],d&&f.length&&typeof f[0].doc>"u"&&(this.db?w.push(f=this.index.get(this.field[0]).db.enrich(f)):f=Pe.call(this,f)),i)return y?p?Kt(e,f,this.index,i,p):f:new P(f,this);s[b]={field:o[b],result:f}}if(d&&this.db&&w.length){const S=this;return Promise.all(w).then(function(T){for(let _=0;_<T.length;_++)s[_].result=T[_];return p&&(s=Kt(e,s,S.index,i,p)),c?us(s):s})}return p&&(s=Kt(e,s,this.index,i,p)),c?us(s):s};function us(e){const t=[],r=N(),n=N();for(let s=0,o,i,c,a,l,u,h;s<e.length;s++){o=e[s],i=o.field,c=o.result;for(let m=0;m<c.length;m++)l=c[m],typeof l!="object"?l={id:a=l}:a=l.id,(u=r[a])?u.push(i):(l.field=r[a]=[i],t.push(l)),(h=l.highlight)&&(u=n[a],u||(n[a]=u={},l.highlight=u),u[i]=h)}return t}function Il(e,t,r,n,s){return e=this.tag.get(e),e?(e=e.get(t),e?(t=e.length-n,t>0&&((r&&t>r||n)&&(e=e.slice(n,n+r)),s&&(e=Pe.call(this,e))),e):[]):[]}function Pe(e){if(!this||!this.store)return e;if(this.db)return this.index.get(this.field[0]).db.enrich(e);const t=Array(e.length);for(let r=0,n;r<e.length;r++)n=e[r],t[r]={id:n,doc:this.store.get(n)};return t}function Fe(e){if(!this||this.constructor!==Fe)return new Fe(e);const t=e.document||e.doc||e;let r,n;if(this.B=[],this.field=[],this.D=[],this.key=(r=t.key||t.id)&&Ut(r,this.D)||"id",(n=e.keystore||0)&&(this.keystore=n),this.fastupdate=!!e.fastupdate,this.reg=!this.fastupdate||e.worker||e.db?n?new ee(n):new Set:n?new Q(n):new Map,this.h=(r=t.store||null)&&r&&r!==!0&&[],this.store=r?n?new Q(n):new Map:null,this.cache=(r=e.cache||null)&&new Ke(r),e.cache=!1,this.worker=e.worker||!1,this.priority=e.priority||4,this.index=Pl.call(this,e,t),this.tag=null,(r=t.tag)&&(typeof r=="string"&&(r=[r]),r.length)){this.tag=new Map,this.A=[],this.F=[];for(let s=0,o,i;s<r.length;s++){if(o=r[s],i=o.field||o,!i)throw Error("The tag field from the document descriptor is undefined.");o.custom?this.A[s]=o.custom:(this.A[s]=Ut(i,this.D),o.filter&&(typeof this.A[s]=="string"&&(this.A[s]=new String(this.A[s])),this.A[s].G=o.filter)),this.F[s]=i,this.tag.set(i,new Map)}}if(this.worker){this.fastupdate=!1,e=[];for(const s of this.index.values())s.then&&e.push(s);if(e.length){const s=this;return Promise.all(e).then(function(o){let i=0;for(const c of s.index.entries()){const a=c[0];let l=c[1];l.then&&(l=o[i],s.index.set(a,l),i++)}return s})}}else e.db&&(this.fastupdate=!1,this.mount(e.db))}A=Fe.prototype;A.mount=function(e){let t=this.field;if(this.tag)for(let o=0,i;o<this.F.length;o++){i=this.F[o];var r=void 0;this.index.set(i,r=new te({},this.reg)),t===this.field&&(t=t.slice(0)),t.push(i),r.tag=this.tag.get(i)}r=[];const n={db:e.db,type:e.type,fastupdate:e.fastupdate};for(let o=0,i,c;o<t.length;o++){n.field=c=t[o],i=this.index.get(c);const a=new e.constructor(e.id,n);a.id=e.id,r[o]=a.mount(i),i.document=!0,o?i.bypass=!0:i.store=this.store}const s=this;return this.db=Promise.all(r).then(function(){s.db=!0})};A.commit=async function(){const e=[];for(const t of this.index.values())e.push(t.commit());await Promise.all(e),this.reg.clear()};A.destroy=function(){const e=[];for(const t of this.index.values())e.push(t.destroy());return Promise.all(e)};function Pl(e,t){const r=new Map;let n=t.index||t.field||t;Z(n)&&(n=[n]);for(let o=0,i,c;o<n.length;o++){if(i=n[o],Z(i)||(c=i,i=i.field),c=nt(c)?Object.assign({},e,c):e,this.worker){var s=void 0;s=(s=c.encoder)&&s.encode?s:new ot(typeof s=="string"?Ho[s]:s||{}),s=new Be(c,s),r.set(i,s)}this.worker||r.set(i,new te(c,this.reg)),c.custom?this.B[o]=c.custom:(this.B[o]=Ut(i,this.D),c.filter&&(typeof this.B[o]=="string"&&(this.B[o]=new String(this.B[o])),this.B[o].G=c.filter)),this.field[o]=i}if(this.h){e=t.store,Z(e)&&(e=[e]);for(let o=0,i,c;o<e.length;o++)i=e[o],c=i.field||i,i.custom?(this.h[o]=i.custom,i.custom.O=c):(this.h[o]=Ut(c,this.D),i.filter&&(typeof this.h[o]=="string"&&(this.h[o]=new String(this.h[o])),this.h[o].G=i.filter))}return r}function Ut(e,t){const r=e.split(":");let n=0;for(let s=0;s<r.length;s++)e=r[s],e[e.length-1]==="]"&&(e=e.substring(0,e.length-2))&&(t[n]=!0),e&&(r[n++]=e);return n<r.length&&(r.length=n),n>1?r:r[0]}A.append=function(e,t){return this.add(e,t,!0)};A.update=function(e,t){return this.remove(e).add(e,t)};A.remove=function(e){nt(e)&&(e=st(e,this.key));for(var t of this.index.values())t.remove(e,!0);if(this.reg.has(e)){if(this.tag&&!this.fastupdate)for(let r of this.tag.values())for(let n of r){t=n[0];const s=n[1],o=s.indexOf(e);o>-1&&(s.length>1?s.splice(o,1):r.delete(t))}this.store&&this.store.delete(e),this.reg.delete(e)}return this.cache&&this.cache.remove(e),this};A.clear=function(){const e=[];for(const t of this.index.values()){const r=t.clear();r.then&&e.push(r)}if(this.tag)for(const t of this.tag.values())t.clear();return this.store&&this.store.clear(),this.cache&&this.cache.clear(),e.length?Promise.all(e):this};A.contain=function(e){return this.db?this.index.get(this.field[0]).db.has(e):this.reg.has(e)};A.cleanup=function(){for(const e of this.index.values())e.cleanup();return this};A.get=function(e){return this.db?this.index.get(this.field[0]).db.enrich(e).then(function(t){return t[0]&&t[0].doc||null}):this.store.get(e)||null};A.set=function(e,t){return typeof e=="object"&&(t=e,e=st(t,this.key)),this.store.set(e,t),this};A.searchCache=Cn;A.export=jl;A.import=Bl;In(Fe.prototype);function Bn(e,t=0){let r=[],n=[];t&&(t=25e4/t*5e3|0);for(const s of e.entries())n.push(s),n.length===t&&(r.push(n),n=[]);return n.length&&r.push(n),r}function Fn(e,t){t||(t=new Map);for(let r=0,n;r<e.length;r++)n=e[r],t.set(n[0],n[1]);return t}function Vo(e,t=0){let r=[],n=[];t&&(t=25e4/t*1e3|0);for(const s of e.entries())n.push([s[0],Bn(s[1])[0]||[]]),n.length===t&&(r.push(n),n=[]);return n.length&&r.push(n),r}function Jo(e,t){t||(t=new Map);for(let r=0,n,s;r<e.length;r++)n=e[r],s=t.get(n[0]),t.set(n[0],Fn(n[1],s));return t}function Go(e){let t=[],r=[];for(const n of e.keys())r.push(n),r.length===25e4&&(t.push(r),r=[]);return r.length&&t.push(r),t}function Xo(e,t){t||(t=new Set);for(let r=0;r<e.length;r++)t.add(e[r]);return t}function Ht(e,t,r,n,s,o,i=0){const c=n&&n.constructor===Array;var a=c?n.shift():n;if(!a)return this.export(e,t,s,o+1);if((a=e((t?t+".":"")+(i+1)+"."+r,JSON.stringify(a)))&&a.then){const l=this;return a.then(function(){return Ht.call(l,e,t,r,c?n:null,s,o,i+1)})}return Ht.call(this,e,t,r,c?n:null,s,o,i+1)}function jl(e,t,r=0,n=0){if(r<this.field.length){const i=this.field[r];if((t=this.index.get(i).export(e,i,r,n=1))&&t.then){const c=this;return t.then(function(){return c.export(e,i,r+1)})}return this.export(e,i,r+1)}let s,o;switch(n){case 0:s="reg",o=Go(this.reg),t=null;break;case 1:s="tag",o=this.tag&&Vo(this.tag,this.reg.size),t=null;break;case 2:s="doc",o=this.store&&Bn(this.store),t=null;break;default:return}return Ht.call(this,e,t,s,o||null,r,n)}function Bl(e,t){var r=e.split(".");r[r.length-1]==="json"&&r.pop();const n=r.length>2?r[0]:"";if(r=r.length>2?r[2]:r[1],this.worker&&n)return this.index.get(n).import(e);if(t){if(typeof t=="string"&&(t=JSON.parse(t)),n)return this.index.get(n).import(r,t);switch(r){case"reg":this.fastupdate=!1,this.reg=Xo(t,this.reg);for(let s=0,o;s<this.field.length;s++)o=this.index.get(this.field[s]),o.fastupdate=!1,o.reg=this.reg;if(this.worker){t=[];for(const s of this.index.values())t.push(s.import(e));return Promise.all(t)}break;case"tag":this.tag=Jo(t,this.tag);break;case"doc":this.store=Fn(t,this.store)}}}function hs(e,t){let r="";for(const n of e.entries()){e=n[0];const s=n[1];let o="";for(let i=0,c;i<s.length;i++){c=s[i]||[""];let a="";for(let l=0;l<c.length;l++)a+=(a?",":"")+(t==="string"?'"'+c[l]+'"':c[l]);a="["+a+"]",o+=(o?",":"")+a}o='["'+e+'",['+o+"]]",r+=(r?",":"")+o}return r}te.prototype.remove=function(e,t){const r=this.reg.size&&(this.fastupdate?this.reg.get(e):this.reg.has(e));if(r){if(this.fastupdate){for(let n=0,s,o;n<r.length;n++)if((s=r[n])&&(o=s.length))if(s[o-1]===e)s.pop();else{const i=s.indexOf(e);i>=0&&s.splice(i,1)}}else it(this.map,e),this.depth&&it(this.ctx,e);t||this.reg.delete(e)}return this.db&&(this.commit_task.push({del:e}),this.M&&qo(this)),this.cache&&this.cache.remove(e),this};function it(e,t){let r=0;var n=typeof t>"u";if(e.constructor===Array){for(let s=0,o,i,c;s<e.length;s++)if((o=e[s])&&o.length){if(n)return 1;if(i=o.indexOf(t),i>=0){if(o.length>1)return o.splice(i,1),1;if(delete e[s],r)return 1;c=1}else{if(c)return 1;r++}}}else for(let s of e.entries())n=s[0],it(s[1],t)?r++:e.delete(n);return r}const Fl={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};te.prototype.add=function(e,t,r,n){if(t&&(e||e===0)){if(!n&&!r&&this.reg.has(e))return this.update(e,t);n=this.depth,t=this.encoder.encode(t,!n);const l=t.length;if(l){const u=N(),h=N(),m=this.resolution;for(let y=0;y<l;y++){let p=t[this.rtl?l-1-y:y];var s=p.length;if(s&&(n||!h[p])){var o=this.score?this.score(t,p,y,null,0):kt(m,l,y),i="";switch(this.tokenize){case"tolerant":if(ae(this,h,p,o,e,r),s>2){for(let f=1,d,b,w,E;f<s-1;f++)d=p.charAt(f),b=p.charAt(f+1),w=p.substring(0,f)+b,E=p.substring(f+2),i=w+d+E,ae(this,h,i,o,e,r),i=w+E,ae(this,h,i,o,e,r);ae(this,h,p.substring(0,p.length-1),o,e,r)}break;case"full":if(s>2){for(let f=0,d;f<s;f++)for(o=s;o>f;o--){i=p.substring(f,o),d=this.rtl?s-1-f:f;var c=this.score?this.score(t,p,y,i,d):kt(m,l,y,s,d);ae(this,h,i,c,e,r)}break}case"bidirectional":case"reverse":if(s>1){for(c=s-1;c>0;c--){i=p[this.rtl?s-1-c:c]+i;var a=this.score?this.score(t,p,y,i,c):kt(m,l,y,s,c);ae(this,h,i,a,e,r)}i=""}case"forward":if(s>1){for(c=0;c<s;c++)i+=p[this.rtl?s-1-c:c],ae(this,h,i,o,e,r);break}default:if(ae(this,h,p,o,e,r),n&&l>1&&y<l-1)for(s=this.N,i=p,o=Math.min(n+1,this.rtl?y+1:l-y),c=1;c<o;c++){p=t[this.rtl?l-1-y-c:y+c],a=this.bidirectional&&p>i;const f=this.score?this.score(t,i,y,p,c-1):kt(s+(l/2>s?0:1),l,y,o-1,c-1);ae(this,u,a?i:p,f,e,r,a?p:i)}}}}this.fastupdate||this.reg.add(e)}}return this.db&&(this.commit_task.push(r?{ins:e}:{del:e}),this.M&&qo(this)),this};function ae(e,t,r,n,s,o,i){let c,a;if(!(c=t[r])||i&&!c[i]){if(i?(t=c||(t[r]=N()),t[i]=1,a=e.ctx,(c=a.get(i))?a=c:a.set(i,a=e.keystore?new Q(e.keystore):new Map)):(a=e.map,t[r]=1),(c=a.get(r))?a=c:a.set(r,a=c=[]),o){for(let l=0,u;l<c.length;l++)if((u=c[l])&&u.includes(s)){if(l<=n)return;u.splice(u.indexOf(s),1),e.fastupdate&&(t=e.reg.get(s))&&t.splice(t.indexOf(u),1);break}}if(a=a[n]||(a[n]=[]),a.push(s),a.length===2**31-1){if(t=new je(a),e.fastupdate)for(let l of e.reg.values())l.includes(a)&&(l[l.indexOf(a)]=t);c[n]=a=t}e.fastupdate&&((n=e.reg.get(s))?n.push(a):e.reg.set(s,[a]))}}function kt(e,t,r,n,s){return r&&e>1?t+(n||0)<=e?r+(s||0):(e-1)/(t+(n||0))*(r+(s||0))+1|0:0}te.prototype.search=function(e,t,r){if(r||(t||typeof e!="object"?typeof t=="object"&&(r=t,t=0):(r=e,e="")),r&&r.cache)return r.cache=!1,e=this.searchCache(e,t,r),r.cache=!0,e;let n=[],s,o,i,c=0,a,l,u,h,m;r&&(e=r.query||e,t=r.limit||t,c=r.offset||0,o=r.context,i=r.suggest,m=(a=r.resolve)&&r.enrich,u=r.boost,h=r.resolution,l=this.db&&r.tag),typeof a>"u"&&(a=this.resolve),o=this.depth&&o!==!1;let y=this.encoder.encode(e,!o);if(s=y.length,t=t||(a?100:0),s===1)return ds.call(this,y[0],"",t,c,a,m,l);if(s===2&&o&&!i)return ds.call(this,y[1],y[0],t,c,a,m,l);let p=N(),f=0,d;if(o&&(d=y[0],f=1),h||h===0||(h=d?this.N:this.resolution),this.db){if(this.db.search&&(r=this.db.search(this,y,t,c,i,a,m,l),r!==!1))return r;const b=this;return(async function(){for(let w,E;f<s;f++){if((E=y[f])&&!p[E]){if(p[E]=1,w=await Jr(b,E,d,0,0,!1,!1),w=ps(w,n,i,h)){n=w;break}d&&(i&&w&&n.length||(d=E))}i&&d&&f===s-1&&!n.length&&(h=b.resolution,d="",f=-1,p=N())}return fs(n,h,t,c,i,u,a)})()}for(let b,w;f<s;f++){if((w=y[f])&&!p[w]){if(p[w]=1,b=Jr(this,w,d,0,0,!1,!1),b=ps(b,n,i,h)){n=b;break}d&&(i&&b&&n.length||(d=w))}i&&d&&f===s-1&&!n.length&&(h=this.resolution,d="",f=-1,p=N())}return fs(n,h,t,c,i,u,a)};function fs(e,t,r,n,s,o,i){let c=e.length,a=e;if(c>1)a=Mt(e,t,r,n,s,o,i);else if(c===1)return i?Pn.call(null,e[0],r,n):new P(e[0],this);return i?a:new P(a,this)}function ds(e,t,r,n,s,o,i){return e=Jr(this,e,t,r,n,s,o,i),this.db?e.then(function(c){return s?c||[]:new P(c,this)}):e&&e.length?s?Pn.call(this,e,r,n):new P(e,this):s?[]:new P([],this)}function ps(e,t,r,n){let s=[];if(e&&e.length){if(e.length<=n){t.push(e);return}for(let o=0,i;o<n;o++)(i=e[o])&&(s[o]=i);if(s.length){t.push(s);return}}if(!r)return s}function Jr(e,t,r,n,s,o,i,c){let a;return r&&(a=e.bidirectional&&t>r)&&(a=r,r=t,t=a),e.db?e.db.get(t,r,n,s,o,i,c):(e=r?(e=e.ctx.get(r))&&e.get(t):e.map.get(t),e)}function te(e,t){if(!this||this.constructor!==te)return new te(e);if(e){var r=Z(e)?e:e.preset;r&&(e=Object.assign({},Fl[r],e))}else e={};r=e.context;const n=r===!0?{depth:1}:r||{},s=Z(e.encoder)?Ho[e.encoder]:e.encode||e.encoder||{};this.encoder=s.encode?s:typeof s=="object"?new ot(s):{encode:s},this.resolution=e.resolution||9,this.tokenize=r=(r=e.tokenize)&&r!=="default"&&r!=="exact"&&r||"strict",this.depth=r==="strict"&&n.depth||0,this.bidirectional=n.bidirectional!==!1,this.fastupdate=!!e.fastupdate,this.score=e.score||null,(r=e.keystore||0)&&(this.keystore=r),this.map=r?new Q(r):new Map,this.ctx=r?new Q(r):new Map,this.reg=t||(this.fastupdate?r?new Q(r):new Map:r?new ee(r):new Set),this.N=n.resolution||3,this.rtl=s.rtl||e.rtl||!1,this.cache=(r=e.cache||null)&&new Ke(r),this.resolve=e.resolve!==!1,(r=e.db)&&(this.db=this.mount(r)),this.M=e.commit!==!1,this.commit_task=[],this.commit_timer=null,this.priority=e.priority||4}A=te.prototype;A.mount=function(e){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),e.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 qo(e){e.commit_timer||(e.commit_timer=setTimeout(function(){e.commit_timer=null,e.db.commit(e)},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(e,t){return this.add(e,t,!0)};A.contain=function(e){return this.db?this.db.has(e):this.reg.has(e)};A.update=function(e,t){const r=this,n=this.remove(e);return n&&n.then?n.then(()=>r.add(e,t)):this.add(e,t)};A.cleanup=function(){return this.fastupdate?(it(this.map),this.depth&&it(this.ctx),this):this};A.searchCache=Cn;A.export=function(e,t,r=0,n=0){let s,o;switch(n){case 0:s="reg",o=Go(this.reg);break;case 1:s="cfg",o=null;break;case 2:s="map",o=Bn(this.map,this.reg.size);break;case 3:s="ctx",o=Vo(this.ctx,this.reg.size);break;default:return}return Ht.call(this,e,t,s,o,r,n)};A.import=function(e,t){if(t)switch(typeof t=="string"&&(t=JSON.parse(t)),e=e.split("."),e[e.length-1]==="json"&&e.pop(),e.length===3&&e.shift(),e=e.length>1?e[1]:e[0],e){case"reg":this.fastupdate=!1,this.reg=Xo(t,this.reg);break;case"map":this.map=Fn(t,this.map);break;case"ctx":this.ctx=Jo(t,this.ctx)}};A.serialize=function(e=!0){let t="",r="",n="";if(this.reg.size){let o;for(var s of this.reg.keys())o||(o=typeof s),t+=(t?",":"")+(o==="string"?'"'+s+'"':s);t="index.reg=new Set(["+t+"]);",r=hs(this.map,o),r="index.map=new Map(["+r+"]);";for(const i of this.ctx.entries()){s=i[0];let c=hs(i[1],o);c="new Map(["+c+"])",c='["'+s+'",'+c+"]",n+=(n?",":"")+c}n="index.ctx=new Map(["+n+"]);"}return e?"function inject(index){"+t+r+n+"}":t+r+n};In(te.prototype);const Wo=typeof window<"u"&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),zt=["map","ctx","tag","reg","cfg"],Ee=N();function Gr(e,t={}){if(!this||this.constructor!==Gr)return new Gr(e,t);typeof e=="object"&&(t=e,e=e.name),e||console.info("Default storage space was used, because a name was not passed."),this.id="flexsearch"+(e?":"+e.toLowerCase().replace(/[^a-z0-9_\-]/g,""):""),this.field=t.field?t.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"",this.type=t.type,this.fastupdate=this.support_tag_search=!1,this.db=null,this.h={}}A=Gr.prototype;A.mount=function(e){return e.index?e.mount(this):(e.db=this,this.open())};A.open=function(){if(this.db)return this.db;let e=this;navigator.storage&&navigator.storage.persist&&navigator.storage.persist(),Ee[e.id]||(Ee[e.id]=[]),Ee[e.id].push(e.field);const t=Wo.open(e.id,1);return t.onupgradeneeded=function(){const r=e.db=this.result;for(let n=0,s;n<zt.length;n++){s=zt[n];for(let o=0,i;o<Ee[e.id].length;o++)i=Ee[e.id][o],r.objectStoreNames.contains(s+(s!=="reg"&&i?":"+i:""))||r.createObjectStore(s+(s!=="reg"&&i?":"+i:""))}},e.db=me(t,function(r){e.db=r,e.db.onversionchange=function(){e.close()}})};A.close=function(){this.db&&this.db.close(),this.db=null};A.destroy=function(){const e=Wo.deleteDatabase(this.id);return me(e)};A.clear=function(){const e=[];for(let r=0,n;r<zt.length;r++){n=zt[r];for(let s=0,o;s<Ee[this.id].length;s++)o=Ee[this.id][s],e.push(n+(n!=="reg"&&o?":"+o:""))}const t=this.db.transaction(e,"readwrite");for(let r=0;r<e.length;r++)t.objectStore(e[r]).clear();return me(t)};A.get=function(e,t,r=0,n=0,s=!0,o=!1){e=this.db.transaction((t?"ctx":"map")+(this.field?":"+this.field:""),"readonly").objectStore((t?"ctx":"map")+(this.field?":"+this.field:"")).get(t?t+":"+e:e);const i=this;return me(e).then(function(c){let a=[];if(!c||!c.length)return a;if(s){if(!r&&!n&&c.length===1)return c[0];for(let l=0,u;l<c.length;l++)if((u=c[l])&&u.length){if(n>=u.length){n-=u.length;continue}const h=r?n+Math.min(u.length-n,r):u.length;for(let m=n;m<h;m++)a.push(u[m]);if(n=0,a.length===r)break}return o?i.enrich(a):a}return c})};A.tag=function(e,t=0,r=0,n=!1){e=this.db.transaction("tag"+(this.field?":"+this.field:""),"readonly").objectStore("tag"+(this.field?":"+this.field:"")).get(e);const s=this;return me(e).then(function(o){return!o||!o.length||r>=o.length?[]:!t&&!r?o:(o=o.slice(r,r+t),n?s.enrich(o):o)})};A.enrich=function(e){typeof e!="object"&&(e=[e]);const t=this.db.transaction("reg","readonly").objectStore("reg"),r=[];for(let n=0;n<e.length;n++)r[n]=me(t.get(e[n]));return Promise.all(r).then(function(n){for(let s=0;s<n.length;s++)n[s]={id:e[s],doc:n[s]?JSON.parse(n[s]):null};return n})};A.has=function(e){return e=this.db.transaction("reg","readonly").objectStore("reg").getKey(e),me(e).then(function(t){return!!t})};A.search=null;A.info=function(){};A.transaction=function(e,t,r){e+=e!=="reg"&&this.field?":"+this.field:"";let n=this.h[e+":"+t];if(n)return r.call(this,n);let s=this.db.transaction(e,t);this.h[e+":"+t]=n=s.objectStore(e);const o=r.call(this,n);return this.h[e+":"+t]=null,me(s).finally(function(){return o})};A.commit=async function(e){let t=e.commit_task,r=[];e.commit_task=[];for(let n=0,s;n<t.length;n++)s=t[n],s.del&&r.push(s.del);r.length&&await this.remove(r),e.reg.size&&(await this.transaction("map","readwrite",function(n){for(const s of e.map){const o=s[0],i=s[1];i.length&&(n.get(o).onsuccess=function(){let c=this.result;var a;if(c&&c.length){const l=Math.max(c.length,i.length);for(let u=0,h,m;u<l;u++)if((m=i[u])&&m.length){if((h=c[u])&&h.length)for(a=0;a<m.length;a++)h.push(m[a]);else c[u]=m;a=1}}else c=i,a=1;a&&n.put(c,o)})}}),await this.transaction("ctx","readwrite",function(n){for(const s of e.ctx){const o=s[0],i=s[1];for(const c of i){const a=c[0],l=c[1];l.length&&(n.get(o+":"+a).onsuccess=function(){let u=this.result;var h;if(u&&u.length){const m=Math.max(u.length,l.length);for(let y=0,p,f;y<m;y++)if((f=l[y])&&f.length){if((p=u[y])&&p.length)for(h=0;h<f.length;h++)p.push(f[h]);else u[y]=f;h=1}}else u=l,h=1;h&&n.put(u,o+":"+a)})}}}),e.store?await this.transaction("reg","readwrite",function(n){for(const s of e.store){const o=s[0],i=s[1];n.put(typeof i=="object"?JSON.stringify(i):1,o)}}):e.bypass||await this.transaction("reg","readwrite",function(n){for(const s of e.reg.keys())n.put(1,s)}),e.tag&&await this.transaction("tag","readwrite",function(n){for(const s of e.tag){const o=s[0],i=s[1];i.length&&(n.get(o).onsuccess=function(){let c=this.result;c=c&&c.length?c.concat(i):i,n.put(c,o)})}}),e.map.clear(),e.ctx.clear(),e.tag&&e.tag.clear(),e.store&&e.store.clear(),e.document||e.reg.clear())};function Or(e,t,r){const n=e.value;let s,o=0;for(let i=0,c;i<n.length;i++){if(c=r?n:n[i]){for(let a=0,l,u;a<t.length;a++)if(u=t[a],l=c.indexOf(u),l>=0)if(s=1,c.length>1)c.splice(l,1);else{n[i]=[];break}o+=c.length}if(r)break}o?s&&e.update(n):e.delete(),e.continue()}A.remove=function(e){return typeof e!="object"&&(e=[e]),Promise.all([this.transaction("map","readwrite",function(t){t.openCursor().onsuccess=function(){const r=this.result;r&&Or(r,e)}}),this.transaction("ctx","readwrite",function(t){t.openCursor().onsuccess=function(){const r=this.result;r&&Or(r,e)}}),this.transaction("tag","readwrite",function(t){t.openCursor().onsuccess=function(){const r=this.result;r&&Or(r,e,!0)}}),this.transaction("reg","readwrite",function(t){for(let r=0;r<e.length;r++)t.delete(e[r])})])};function me(e,t){return new Promise((r,n)=>{e.onsuccess=e.oncomplete=function(){t&&t(this.result),t=null,r(this.result)},e.onerror=e.onblocked=n,e=null})}const vt=te,ur={preset:"match",tokenize:"forward",resolution:9,minlength:2,optimize:!0,fastupdate:!0,cache:!0},Nl={...ur,minlength:3,resolution:6},Ll={...ur,tokenize:"strict",minlength:1},Dl={...ur,tokenize:"strict",minlength:1},Ml=()=>({subjectIndex:new vt(ur),bodyIndex:new vt(Nl),fromIndex:new vt(Ll),toIndex:new vt(Dl),isReady:!1}),Zo=(e,t)=>{try{const r=e.params.id;if(e.params.subject&&t.subjectIndex.add(r,e.params.subject),e.body?.text&&t.bodyIndex.add(r,e.body.text),e.params.sender){const o=`${e.params.sender.name||""} ${e.params.sender.email||""}`.trim();t.fromIndex.add(r,o)}const s=(e.params.recipients?.length?e.params.recipients:[e.params.recipient]).map(o=>`${o.name||""} ${o.email||""}`.trim()).join(" ");t.toIndex.add(r,s)}catch(r){throw new Error("Failed to add email to the search index",{cause:r})}},Ul=(e,t)=>{try{t.subjectIndex.remove(e),t.bodyIndex.remove(e),t.fromIndex.remove(e),t.toIndex.remove(e)}catch(r){throw new Error(`Failed to remove email with ID ${e} from the search index`,{cause:r})}},Hl=async e=>{try{const t=Ml();t.isReady=!1;for(const r of e.esCache.values())Zo(r,t);return t.isReady=!0,t}catch(t){throw new Error("Failed build an email search index from the cache",{cause:t})}},zl=async(e,t,r,n={})=>{try{if(!r.isReady||!e.trim())return[];const{fields:s=["subject","body","from","to"],limit:o=50,boost:i={subject:3,body:1,from:2,to:2}}=n,c=new Map,a=s.map(async u=>{let h;switch(u){case"subject":h=await r.subjectIndex.searchAsync(e);break;case"body":h=await r.bodyIndex.searchAsync(e);break;case"from":h=await r.fromIndex.searchAsync(e);break;case"to":h=await r.toIndex.searchAsync(e);break;default:return}const m=i[u]||1;h.forEach(y=>{const p=c.get(String(y))||0;c.set(String(y),p+m)})});await Promise.all(a);const l=[];for(const[u,h]of c){const m=t.esCache.get(u);m&&l.push({email:m,score:h})}return l.sort((u,h)=>(h.score||0)-(u.score||0)),l.slice(0,o)}catch(s){throw new Error("Email search failed",{cause:s})}},$l=Object.freeze(Object.defineProperty({__proto__:null,addEmailToCache:Uo,addEmailToSearchIndex:Zo,addEmailsToCache:zr,buildSearchIndexFromCache:Hl,closeDatabase:cl,createCacheFromDB:wl,deleteDatabase:al,deleteEmail:pl,deleteEmailFromCache:bl,deleteOldestEmails:Bo,deriveIndexKey:ll,encryptAndStoreEmail:ul,encryptAndStoreManyEmail:hl,enforceMaxEmailNumber:yl,getAllEmailsSortedNewestFirst:No,getAllEmailsSortedOldestFirst:ml,getAndDecryptAllEmails:dl,getAndDecryptEmail:fl,getEmailBatch:Lo,getEmailCount:Rn,getEmailFromCache:Mo,openDatabase:il,removeEmailFromSearchIndex:Ul,searchEmails:zl},Symbol.toStringTag,{value:"Module"}));function Qo(e,t){return function(){return e.apply(t,arguments)}}const{toString:Yl}=Object.prototype,{getPrototypeOf:Nn}=Object,{iterator:hr,toStringTag:ei}=Symbol,fr=(e=>t=>{const r=Yl.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),re=e=>(e=e.toLowerCase(),t=>fr(t)===e),dr=e=>t=>typeof t===e,{isArray:Ue}=Array,ct=dr("undefined");function ut(e){return e!==null&&!ct(e)&&e.constructor!==null&&!ct(e.constructor)&&V(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ti=re("ArrayBuffer");function Vl(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ti(e.buffer),t}const Jl=dr("string"),V=dr("function"),ri=dr("number"),ht=e=>e!==null&&typeof e=="object",Gl=e=>e===!0||e===!1,Ot=e=>{if(fr(e)!=="object")return!1;const t=Nn(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ei in e)&&!(hr in e)},Xl=e=>{if(!ht(e)||ut(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},ql=re("Date"),Wl=re("File"),Zl=re("Blob"),Ql=re("FileList"),eu=e=>ht(e)&&V(e.pipe),tu=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||V(e.append)&&((t=fr(e))==="formdata"||t==="object"&&V(e.toString)&&e.toString()==="[object FormData]"))},ru=re("URLSearchParams"),[nu,su,ou,iu]=["ReadableStream","Request","Response","Headers"].map(re),cu=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ft(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,s;if(typeof e!="object"&&(e=[e]),Ue(e))for(n=0,s=e.length;n<s;n++)t.call(null,e[n],n,e);else{if(ut(e))return;const o=r?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let c;for(n=0;n<i;n++)c=o[n],t.call(null,e[c],c,e)}}function ni(e,t){if(ut(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n=r.length,s;for(;n-- >0;)if(s=r[n],t===s.toLowerCase())return s;return null}const ke=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:globalThis,si=e=>!ct(e)&&e!==ke;function Xr(){const{caseless:e}=si(this)&&this||{},t={},r=(n,s)=>{const o=e&&ni(t,s)||s;Ot(t[o])&&Ot(n)?t[o]=Xr(t[o],n):Ot(n)?t[o]=Xr({},n):Ue(n)?t[o]=n.slice():t[o]=n};for(let n=0,s=arguments.length;n<s;n++)arguments[n]&&ft(arguments[n],r);return t}const au=(e,t,r,{allOwnKeys:n}={})=>(ft(t,(s,o)=>{r&&V(s)?e[o]=Qo(s,r):e[o]=s},{allOwnKeys:n}),e),lu=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),uu=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},hu=(e,t,r,n)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!n||n(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=r!==!1&&Nn(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},fu=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},du=e=>{if(!e)return null;if(Ue(e))return e;let t=e.length;if(!ri(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},pu=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Nn(Uint8Array)),yu=(e,t)=>{const n=(e&&e[hr]).call(e);let s;for(;(s=n.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},mu=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},gu=re("HTMLFormElement"),wu=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,s){return n.toUpperCase()+s}),ys=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),bu=re("RegExp"),oi=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};ft(r,(s,o)=>{let i;(i=t(s,o,e))!==!1&&(n[o]=i||s)}),Object.defineProperties(e,n)},Eu=e=>{oi(e,(t,r)=>{if(V(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(V(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},xu=(e,t)=>{const r={},n=s=>{s.forEach(o=>{r[o]=!0})};return Ue(e)?n(e):n(String(e).split(t)),r},ku=()=>{},vu=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Su(e){return!!(e&&V(e.append)&&e[ei]==="FormData"&&e[hr])}const Tu=e=>{const t=new Array(10),r=(n,s)=>{if(ht(n)){if(t.indexOf(n)>=0)return;if(ut(n))return n;if(!("toJSON"in n)){t[s]=n;const o=Ue(n)?[]:{};return ft(n,(i,c)=>{const a=r(i,s+1);!ct(a)&&(o[c]=a)}),t[s]=void 0,o}}return n};return r(e,0)},Au=re("AsyncFunction"),_u=e=>e&&(ht(e)||V(e))&&V(e.then)&&V(e.catch),ii=((e,t)=>e?setImmediate:t?((r,n)=>(ke.addEventListener("message",({source:s,data:o})=>{s===ke&&o===r&&n.length&&n.shift()()},!1),s=>{n.push(s),ke.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",V(ke.postMessage)),Ku=typeof queueMicrotask<"u"?queueMicrotask.bind(ke):typeof process<"u"&&process.nextTick||ii,Ou=e=>e!=null&&V(e[hr]),g={isArray:Ue,isArrayBuffer:ti,isBuffer:ut,isFormData:tu,isArrayBufferView:Vl,isString:Jl,isNumber:ri,isBoolean:Gl,isObject:ht,isPlainObject:Ot,isEmptyObject:Xl,isReadableStream:nu,isRequest:su,isResponse:ou,isHeaders:iu,isUndefined:ct,isDate:ql,isFile:Wl,isBlob:Zl,isRegExp:bu,isFunction:V,isStream:eu,isURLSearchParams:ru,isTypedArray:pu,isFileList:Ql,forEach:ft,merge:Xr,extend:au,trim:cu,stripBOM:lu,inherits:uu,toFlatObject:hu,kindOf:fr,kindOfTest:re,endsWith:fu,toArray:du,forEachEntry:yu,matchAll:mu,isHTMLForm:gu,hasOwnProperty:ys,hasOwnProp:ys,reduceDescriptors:oi,freezeMethods:Eu,toObjectSet:xu,toCamelCase:wu,noop:ku,toFiniteNumber:vu,findKey:ni,global:ke,isContextDefined:si,isSpecCompliantForm:Su,toJSONObject:Tu,isAsyncFn:Au,isThenable:_u,setImmediate:ii,asap:Ku,isIterable:Ou};function R(e,t,r,n,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),s&&(this.response=s,this.status=s.status?s.status:null)}g.inherits(R,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:g.toJSONObject(this.config),code:this.code,status:this.status}}});const ci=R.prototype,ai={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{ai[e]={value:e}});Object.defineProperties(R,ai);Object.defineProperty(ci,"isAxiosError",{value:!0});R.from=(e,t,r,n,s,o)=>{const i=Object.create(ci);return g.toFlatObject(e,i,function(a){return a!==Error.prototype},c=>c!=="isAxiosError"),R.call(i,e.message,t,r,n,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};const Ru=null;function qr(e){return g.isPlainObject(e)||g.isArray(e)}function li(e){return g.endsWith(e,"[]")?e.slice(0,-2):e}function ms(e,t,r){return e?e.concat(t).map(function(s,o){return s=li(s),!r&&o?"["+s+"]":s}).join(r?".":""):t}function Cu(e){return g.isArray(e)&&!e.some(qr)}const Iu=g.toFlatObject(g,{},null,function(t){return/^is[A-Z]/.test(t)});function pr(e,t,r){if(!g.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=g.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(f,d){return!g.isUndefined(d[f])});const n=r.metaTokens,s=r.visitor||u,o=r.dots,i=r.indexes,a=(r.Blob||typeof Blob<"u"&&Blob)&&g.isSpecCompliantForm(t);if(!g.isFunction(s))throw new TypeError("visitor must be a function");function l(p){if(p===null)return"";if(g.isDate(p))return p.toISOString();if(g.isBoolean(p))return p.toString();if(!a&&g.isBlob(p))throw new R("Blob is not supported. Use a Buffer instead.");return g.isArrayBuffer(p)||g.isTypedArray(p)?a&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function u(p,f,d){let b=p;if(p&&!d&&typeof p=="object"){if(g.endsWith(f,"{}"))f=n?f:f.slice(0,-2),p=JSON.stringify(p);else if(g.isArray(p)&&Cu(p)||(g.isFileList(p)||g.endsWith(f,"[]"))&&(b=g.toArray(p)))return f=li(f),b.forEach(function(E,x){!(g.isUndefined(E)||E===null)&&t.append(i===!0?ms([f],x,o):i===null?f:f+"[]",l(E))}),!1}return qr(p)?!0:(t.append(ms(d,f,o),l(p)),!1)}const h=[],m=Object.assign(Iu,{defaultVisitor:u,convertValue:l,isVisitable:qr});function y(p,f){if(!g.isUndefined(p)){if(h.indexOf(p)!==-1)throw Error("Circular reference detected in "+f.join("."));h.push(p),g.forEach(p,function(b,w){(!(g.isUndefined(b)||b===null)&&s.call(t,b,g.isString(w)?w.trim():w,f,m))===!0&&y(b,f?f.concat(w):[w])}),h.pop()}}if(!g.isObject(e))throw new TypeError("data must be an object");return y(e),t}function gs(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Ln(e,t){this._pairs=[],e&&pr(e,this,t)}const ui=Ln.prototype;ui.append=function(t,r){this._pairs.push([t,r])};ui.toString=function(t){const r=t?function(n){return t.call(this,n,gs)}:gs;return this._pairs.map(function(s){return r(s[0])+"="+r(s[1])},"").join("&")};function Pu(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function hi(e,t,r){if(!t)return e;const n=r&&r.encode||Pu;g.isFunction(r)&&(r={serialize:r});const s=r&&r.serialize;let o;if(s?o=s(t,r):o=g.isURLSearchParams(t)?t.toString():new Ln(t,r).toString(n),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class ws{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){g.forEach(this.handlers,function(n){n!==null&&t(n)})}}const fi={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ju=typeof URLSearchParams<"u"?URLSearchParams:Ln,Bu=typeof FormData<"u"?FormData:null,Fu=typeof Blob<"u"?Blob:null,Nu={isBrowser:!0,classes:{URLSearchParams:ju,FormData:Bu,Blob:Fu},protocols:["http","https","file","blob","url","data"]},Dn=typeof window<"u"&&typeof document<"u",Wr=typeof navigator=="object"&&navigator||void 0,Lu=Dn&&(!Wr||["ReactNative","NativeScript","NS"].indexOf(Wr.product)<0),Du=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Mu=Dn&&window.location.href||"http://localhost",Uu=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Dn,hasStandardBrowserEnv:Lu,hasStandardBrowserWebWorkerEnv:Du,navigator:Wr,origin:Mu},Symbol.toStringTag,{value:"Module"})),$={...Uu,...Nu};function Hu(e,t){return pr(e,new $.classes.URLSearchParams,{visitor:function(r,n,s,o){return $.isNode&&g.isBuffer(r)?(this.append(n,r.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function zu(e){return g.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function $u(e){const t={},r=Object.keys(e);let n;const s=r.length;let o;for(n=0;n<s;n++)o=r[n],t[o]=e[o];return t}function di(e){function t(r,n,s,o){let i=r[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),a=o>=r.length;return i=!i&&g.isArray(s)?s.length:i,a?(g.hasOwnProp(s,i)?s[i]=[s[i],n]:s[i]=n,!c):((!s[i]||!g.isObject(s[i]))&&(s[i]=[]),t(r,n,s[i],o)&&g.isArray(s[i])&&(s[i]=$u(s[i])),!c)}if(g.isFormData(e)&&g.isFunction(e.entries)){const r={};return g.forEachEntry(e,(n,s)=>{t(zu(n),s,r,0)}),r}return null}function Yu(e,t,r){if(g.isString(e))try{return(t||JSON.parse)(e),g.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const dt={transitional:fi,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",s=n.indexOf("application/json")>-1,o=g.isObject(t);if(o&&g.isHTMLForm(t)&&(t=new FormData(t)),g.isFormData(t))return s?JSON.stringify(di(t)):t;if(g.isArrayBuffer(t)||g.isBuffer(t)||g.isStream(t)||g.isFile(t)||g.isBlob(t)||g.isReadableStream(t))return t;if(g.isArrayBufferView(t))return t.buffer;if(g.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Hu(t,this.formSerializer).toString();if((c=g.isFileList(t))||n.indexOf("multipart/form-data")>-1){const a=this.env&&this.env.FormData;return pr(c?{"files[]":t}:t,a&&new a,this.formSerializer)}}return o||s?(r.setContentType("application/json",!1),Yu(t)):t}],transformResponse:[function(t){const r=this.transitional||dt.transitional,n=r&&r.forcedJSONParsing,s=this.responseType==="json";if(g.isResponse(t)||g.isReadableStream(t))return t;if(t&&g.isString(t)&&(n&&!this.responseType||s)){const i=!(r&&r.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?R.from(c,R.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:$.classes.FormData,Blob:$.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};g.forEach(["delete","get","head","post","put","patch"],e=>{dt.headers[e]={}});const Vu=g.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Ju=e=>{const t={};let r,n,s;return e&&e.split(`
|
|
2050
|
-
`).forEach(function(i){s=i.indexOf(":"),r=i.substring(0,s).trim().toLowerCase(),n=i.substring(s+1).trim(),!(!r||t[r]&&
|
|
2051
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(s=>n.set(s)),n}static accessor(t){const n=(this[bs]=this[bs]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=Xe(i);n[c]||(Wu(s,i),n[c]=!0)}return g.isArray(t)?t.forEach(o):o(t),this}};J.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);g.reduceDescriptors(J.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});g.freezeMethods(J);function Cr(e,t){const r=this||dt,n=t||r,s=J.from(n.headers);let o=n.data;return g.forEach(e,function(c){o=c.call(r,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function pi(e){return!!(e&&e.__CANCEL__)}function He(e,t,r){R.call(this,e??"canceled",R.ERR_CANCELED,t,r),this.name="CanceledError"}g.inherits(He,R,{__CANCEL__:!0});function yi(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new R("Request failed with status code "+r.status,[R.ERR_BAD_REQUEST,R.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Zu(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Qu(e,t){e=e||10;const r=new Array(e),n=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(a){const l=Date.now(),u=n[o];i||(i=l),r[s]=a,n[s]=l;let h=o,m=0;for(;h!==s;)m+=r[h++],h=h%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),l-i<t)return;const y=u&&l-u;return y?Math.round(m*1e3/y):void 0}}function eh(e,t){let r=0,n=1e3/t,s,o;const i=(l,u=Date.now())=>{r=u,s=null,o&&(clearTimeout(o),o=null),e(...l)};return[(...l)=>{const u=Date.now(),h=u-r;h>=n?i(l,u):(s=l,o||(o=setTimeout(()=>{o=null,i(s)},n-h)))},()=>s&&i(s)]}const $t=(e,t,r=3)=>{let n=0;const s=Qu(50,250);return eh(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,a=i-n,l=s(a),u=i<=c;n=i;const h={loaded:i,total:c,progress:c?i/c:void 0,bytes:a,rate:l||void 0,estimated:l&&c&&u?(c-i)/l:void 0,event:o,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(h)},r)},Es=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},xs=e=>(...t)=>g.asap(()=>e(...t)),th=$.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,$.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL($.origin),$.navigator&&/(msie|trident)/i.test($.navigator.userAgent)):()=>!0,rh=$.hasStandardBrowserEnv?{write(e,t,r,n,s,o){const i=[e+"="+encodeURIComponent(t)];g.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),g.isString(n)&&i.push("path="+n),g.isString(s)&&i.push("domain="+s),o===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function nh(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function sh(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function mi(e,t,r){let n=!nh(t);return e&&(n||r==!1)?sh(e,t):t}const ks=e=>e instanceof J?{...e}:e;function Ae(e,t){t=t||{};const r={};function n(l,u,h,m){return g.isPlainObject(l)&&g.isPlainObject(u)?g.merge.call({caseless:m},l,u):g.isPlainObject(u)?g.merge({},u):g.isArray(u)?u.slice():u}function s(l,u,h,m){if(g.isUndefined(u)){if(!g.isUndefined(l))return n(void 0,l,h,m)}else return n(l,u,h,m)}function o(l,u){if(!g.isUndefined(u))return n(void 0,u)}function i(l,u){if(g.isUndefined(u)){if(!g.isUndefined(l))return n(void 0,l)}else return n(void 0,u)}function c(l,u,h){if(h in t)return n(l,u);if(h in e)return n(void 0,l)}const a={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(l,u,h)=>s(ks(l),ks(u),h,!0)};return g.forEach(Object.keys({...e,...t}),function(u){const h=a[u]||s,m=h(e[u],t[u],u);g.isUndefined(m)&&h!==c||(r[u]=m)}),r}const gi=e=>{const t=Ae({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=t;t.headers=i=J.from(i),t.url=hi(mi(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let a;if(g.isFormData(r)){if($.hasStandardBrowserEnv||$.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if((a=i.getContentType())!==!1){const[l,...u]=a?a.split(";").map(h=>h.trim()).filter(Boolean):[];i.setContentType([l||"multipart/form-data",...u].join("; "))}}if($.hasStandardBrowserEnv&&(n&&g.isFunction(n)&&(n=n(t)),n||n!==!1&&th(t.url))){const l=s&&o&&rh.read(o);l&&i.set(s,l)}return t},oh=typeof XMLHttpRequest<"u",ih=oh&&function(e){return new Promise(function(r,n){const s=gi(e);let o=s.data;const i=J.from(s.headers).normalize();let{responseType:c,onUploadProgress:a,onDownloadProgress:l}=s,u,h,m,y,p;function f(){y&&y(),p&&p(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let d=new XMLHttpRequest;d.open(s.method.toUpperCase(),s.url,!0),d.timeout=s.timeout;function b(){if(!d)return;const E=J.from("getAllResponseHeaders"in d&&d.getAllResponseHeaders()),k={data:!c||c==="text"||c==="json"?d.responseText:d.response,status:d.status,statusText:d.statusText,headers:E,config:e,request:d};yi(function(S){r(S),f()},function(S){n(S),f()},k),d=null}"onloadend"in d?d.onloadend=b:d.onreadystatechange=function(){!d||d.readyState!==4||d.status===0&&!(d.responseURL&&d.responseURL.indexOf("file:")===0)||setTimeout(b)},d.onabort=function(){d&&(n(new R("Request aborted",R.ECONNABORTED,e,d)),d=null)},d.onerror=function(){n(new R("Network Error",R.ERR_NETWORK,e,d)),d=null},d.ontimeout=function(){let x=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const k=s.transitional||fi;s.timeoutErrorMessage&&(x=s.timeoutErrorMessage),n(new R(x,k.clarifyTimeoutError?R.ETIMEDOUT:R.ECONNABORTED,e,d)),d=null},o===void 0&&i.setContentType(null),"setRequestHeader"in d&&g.forEach(i.toJSON(),function(x,k){d.setRequestHeader(k,x)}),g.isUndefined(s.withCredentials)||(d.withCredentials=!!s.withCredentials),c&&c!=="json"&&(d.responseType=s.responseType),l&&([m,p]=$t(l,!0),d.addEventListener("progress",m)),a&&d.upload&&([h,y]=$t(a),d.upload.addEventListener("progress",h),d.upload.addEventListener("loadend",y)),(s.cancelToken||s.signal)&&(u=E=>{d&&(n(!E||E.type?new He(null,e,d):E),d.abort(),d=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));const w=Zu(s.url);if(w&&$.protocols.indexOf(w)===-1){n(new R("Unsupported protocol "+w+":",R.ERR_BAD_REQUEST,e));return}d.send(o||null)})},ch=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,s;const o=function(l){if(!s){s=!0,c();const u=l instanceof Error?l:this.reason;n.abort(u instanceof R?u:new He(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,o(new R(`timeout ${t} of ms exceeded`,R.ETIMEDOUT))},t);const c=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(l=>{l.unsubscribe?l.unsubscribe(o):l.removeEventListener("abort",o)}),e=null)};e.forEach(l=>l.addEventListener("abort",o));const{signal:a}=n;return a.unsubscribe=()=>g.asap(c),a}},ah=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,s;for(;n<r;)s=n+t,yield e.slice(n,s),n=s},lh=async function*(e,t){for await(const r of uh(e))yield*ah(r,t)},uh=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},vs=(e,t,r,n)=>{const s=lh(e,t);let o=0,i,c=a=>{i||(i=!0,n&&n(a))};return new ReadableStream({async pull(a){try{const{done:l,value:u}=await s.next();if(l){c(),a.close();return}let h=u.byteLength;if(r){let m=o+=h;r(m)}a.enqueue(new Uint8Array(u))}catch(l){throw c(l),l}},cancel(a){return c(a),s.return()}},{highWaterMark:2})},yr=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",wi=yr&&typeof ReadableStream=="function",hh=yr&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),bi=(e,...t)=>{try{return!!e(...t)}catch{return!1}},fh=wi&&bi(()=>{let e=!1;const t=new Request($.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),Ss=64*1024,Zr=wi&&bi(()=>g.isReadableStream(new Response("").body)),Yt={stream:Zr&&(e=>e.body)};yr&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Yt[t]&&(Yt[t]=g.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new R(`Response type '${t}' is not supported`,R.ERR_NOT_SUPPORT,n)})})})(new Response);const dh=async e=>{if(e==null)return 0;if(g.isBlob(e))return e.size;if(g.isSpecCompliantForm(e))return(await new Request($.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(g.isArrayBufferView(e)||g.isArrayBuffer(e))return e.byteLength;if(g.isURLSearchParams(e)&&(e=e+""),g.isString(e))return(await hh(e)).byteLength},ph=async(e,t)=>{const r=g.toFiniteNumber(e.getContentLength());return r??dh(t)},yh=yr&&(async e=>{let{url:t,method:r,data:n,signal:s,cancelToken:o,timeout:i,onDownloadProgress:c,onUploadProgress:a,responseType:l,headers:u,withCredentials:h="same-origin",fetchOptions:m}=gi(e);l=l?(l+"").toLowerCase():"text";let y=ch([s,o&&o.toAbortSignal()],i),p;const f=y&&y.unsubscribe&&(()=>{y.unsubscribe()});let d;try{if(a&&fh&&r!=="get"&&r!=="head"&&(d=await ph(u,n))!==0){let k=new Request(t,{method:"POST",body:n,duplex:"half"}),v;if(g.isFormData(n)&&(v=k.headers.get("content-type"))&&u.setContentType(v),k.body){const[S,T]=Es(d,$t(xs(a)));n=vs(k.body,Ss,S,T)}}g.isString(h)||(h=h?"include":"omit");const b="credentials"in Request.prototype;p=new Request(t,{...m,signal:y,method:r.toUpperCase(),headers:u.normalize().toJSON(),body:n,duplex:"half",credentials:b?h:void 0});let w=await fetch(p,m);const E=Zr&&(l==="stream"||l==="response");if(Zr&&(c||E&&f)){const k={};["status","statusText","headers"].forEach(_=>{k[_]=w[_]});const v=g.toFiniteNumber(w.headers.get("content-length")),[S,T]=c&&Es(v,$t(xs(c),!0))||[];w=new Response(vs(w.body,Ss,S,()=>{T&&T(),f&&f()}),k)}l=l||"text";let x=await Yt[g.findKey(Yt,l)||"text"](w,e);return!E&&f&&f(),await new Promise((k,v)=>{yi(k,v,{data:x,headers:J.from(w.headers),status:w.status,statusText:w.statusText,config:e,request:p})})}catch(b){throw f&&f(),b&&b.name==="TypeError"&&/Load failed|fetch/i.test(b.message)?Object.assign(new R("Network Error",R.ERR_NETWORK,e,p),{cause:b.cause||b}):R.from(b,b&&b.code,e,p)}}),Qr={http:Ru,xhr:ih,fetch:yh};g.forEach(Qr,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Ts=e=>`- ${e}`,mh=e=>g.isFunction(e)||e===null||e===!1,Ei={getAdapter:e=>{e=g.isArray(e)?e:[e];const{length:t}=e;let r,n;const s={};for(let o=0;o<t;o++){r=e[o];let i;if(n=r,!mh(r)&&(n=Qr[(i=String(r)).toLowerCase()],n===void 0))throw new R(`Unknown adapter '${i}'`);if(n)break;s[i||"#"+o]=n}if(!n){const o=Object.entries(s).map(([c,a])=>`adapter ${c} `+(a===!1?"is not supported by the environment":"is not available in the build"));let i=t?o.length>1?`since :
|
|
2049
|
+
`);function so(e){return Kc(Ic,e)}const Pc=Object.freeze(Object.defineProperty({__proto__:null,UTF8ToUint8:Qt,base64ToCiphertext:er,base64ToEncryptedKeystore:Gs,base64ToEncryptionKeys:hn,base64ToIdentityKeys:Js,base64ToMediaKeys:Wi,base64ToUint8Array:D,ciphertextToBase64:_e,encryptedKeystoreToBase64:Vs,encryptionKeysToBase64:Ys,genMnemonic:so,hexToUint8Array:jt,identityKeysToBase64:$s,mediaKeysToBase64:Xs,uint8ArrayToBase64:U,uint8ArrayToHex:Qe,uint8ToUTF8:un},Symbol.toStringTag,{value:"Module"}));async function fn(e,t){try{const r=await je.createBLAKE3(e);r.init();for(const n of t)r.update(n);return r}catch(r){throw new Error("Failed to compute hash",{cause:r})}}async function jc(e,t,r){try{const n=await je.createBLAKE3(e,t);n.init();for(const s of r)n.update(s);return n}catch(n){throw new Error("Failed to compute keyed hash",{cause:n})}}async function Bc(e){try{return(await fn(ut,e)).digest()}catch(t){throw new Error("Failed to compute hash",{cause:t})}}async function oo(e,t){try{return(await fn(e,t)).digest("binary")}catch(r){throw new Error("Failed to get bits from data",{cause:r})}}async function Ue(e,t){try{return(await fn(e,[t])).digest("binary")}catch(r){throw new Error("Failed to get bits from string",{cause:r})}}async function Fc(e){try{const t=Xs(e),r=await oo(ut,[Fs,t]);return Qe(r)}catch(t){throw new Error("Failed to compute commitment to media keys",{cause:t})}}async function Nc(e,t){try{const r=await Ue(V,e);return(await jc(ut,r,t)).digest()}catch(r){throw new Error("Failed to compute mac",{cause:r})}}const Lc=Object.freeze(Object.defineProperty({__proto__:null,comitToMediaKey:Fc,computeMac:Nc,getBitsFromData:oo,getBitsFromString:Ue,hashData:Bc},Symbol.toStringTag,{value:"Module"}));async function rr(e){return crypto.subtle.importKey(De,new Uint8Array(e),{name:Le,length:V},!0,["encrypt","decrypt"])}async function Dc(e){try{const t=await crypto.subtle.exportKey(De,e);return new Uint8Array(t)}catch(t){throw new Error("Failed to export symmetric CryptoKey",{cause:t})}}async function dn(){return crypto.subtle.generateKey({name:Le,length:V},!0,["encrypt","decrypt"])}function Mc(){try{const e=new Uint8Array(V/8);return crypto.getRandomValues(e),e}catch(e){throw new Error("Failed to generate symmetric key",{cause:e})}}async function Uc(e){try{const t=await Ue(V,e);return rr(t)}catch(t){throw new Error("Failed to derive CryptoKey from the given key material",{cause:t})}}const Hc=BigInt(0),Je=BigInt(1),zc=BigInt(2),$c=BigInt(7),Yc=BigInt(256),Vc=BigInt(113),io=[],co=[],ao=[];for(let e=0,t=Je,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],io.push(2*(5*n+r)),co.push((e+1)*(e+2)/2%64);let s=Hc;for(let o=0;o<7;o++)t=(t<<Je^(t>>$c)*Vc)%Yc,t&zc&&(s^=Je<<(Je<<BigInt(o))-Je);ao.push(s)}const lo=uc(ao,!0),Jc=lo[0],Gc=lo[1],Jn=(e,t,r)=>r>32?dc(e,t,r):hc(e,t,r),Gn=(e,t,r)=>r>32?pc(e,t,r):fc(e,t,r);function Xc(e,t=24){const r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let i=0;i<10;i++)r[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,a=(i+2)%10,l=r[a],u=r[a+1],h=Jn(l,u,1)^r[c],m=Gn(l,u,1)^r[c+1];for(let y=0;y<50;y+=10)e[i+y]^=h,e[i+y+1]^=m}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=co[i],a=Jn(s,o,c),l=Gn(s,o,c),u=io[i];s=e[u],o=e[u+1],e[u]=a,e[u+1]=l}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)r[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~r[(c+2)%10]&r[(c+4)%10]}e[0]^=Jc[n],e[1]^=Gc[n]}et(r)}class nr extends Zs{constructor(t,r,n,s=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=r,this.outputLen=n,this.enableXOF=s,this.rounds=o,Fr(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ws(this.state)}clone(){return this._cloneInto()}keccak(){$n(this.state32),Xc(this.state32,this.rounds),$n(this.state32),this.posOut=0,this.pos=0}update(t){Bt(this),t=tr(t),Se(t);const{blockLen:r,state:n}=this,s=t.length;for(let o=0;o<s;){const i=Math.min(r-this.pos,s-o);for(let c=0;c<i;c++)n[this.pos++]^=t[o++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:r,pos:n,blockLen:s}=this;t[n]^=r,(r&128)!==0&&n===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Bt(this,!1),Se(t),this.finish();const r=this.state,{blockLen:n}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Fr(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(qs(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,et(this.state)}_cloneInto(t){const{blockLen:r,suffix:n,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new nr(r,n,s,i,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=n,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}}const uo=(e,t,r)=>Qs(()=>new nr(t,e,r)),qc=uo(6,136,256/8),Wc=uo(6,72,512/8),ho=(e,t,r)=>sc((n={})=>new nr(t,e,n.dkLen===void 0?r:n.dkLen,!0)),Zc=ho(31,168,128/8),fo=ho(31,136,256/8);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const le=Se,Ut=eo;function Xn(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function At(...e){const t=n=>typeof n=="number"?n:n.bytesLen,r=e.reduce((n,s)=>n+t(s),0);return{bytesLen:r,encode:n=>{const s=new Uint8Array(r);for(let o=0,i=0;o<e.length;o++){const c=e[o],a=t(c),l=typeof c=="number"?n[o]:c.encode(n[o]);le(l,a),s.set(l,i),typeof c!="number"&&l.fill(0),i+=a}return s},decode:n=>{le(n,r);const s=[];for(const o of e){const i=t(o),c=n.subarray(0,i);s.push(typeof o=="number"?c:o.decode(c)),n=n.subarray(i)}return s}}}function Ar(e,t){const r=t*e.bytesLen;return{bytesLen:r,encode:n=>{if(n.length!==t)throw new Error(`vecCoder.encode: wrong length=${n.length}. Expected: ${t}`);const s=new Uint8Array(r);for(let o=0,i=0;o<n.length;o++){const c=e.encode(n[o]);s.set(c,i),c.fill(0),i+=c.length}return s},decode:n=>{le(n,r);const s=[];for(let o=0;o<n.length;o+=e.bytesLen)s.push(e.decode(n.subarray(o,o+e.bytesLen)));return s}}}function xe(...e){for(const t of e)if(Array.isArray(t))for(const r of t)r.fill(0);else t.fill(0)}function qn(e){return(1<<e)-1}X("0609608648016503040201"),X("0609608648016503040202"),X("0609608648016503040203"),X("0609608648016503040204"),X("0609608648016503040205"),X("0609608648016503040206"),X("0609608648016503040207"),X("0609608648016503040208"),X("0609608648016503040209"),X("060960864801650304020A"),X("060960864801650304020B"),X("060960864801650304020C");async function Qc(e){try{if(!e)return Ut(Os);const t=new Uint8Array(16),r=Ut(12);t.set(r,0);const n=await Ue(32,e);return t.set(n,12),t}catch(t){throw new Error("Failed to create IV",{cause:t})}}async function po(e){return Ue(Ks,e)}async function ea(e,t,r,n){try{const s=await crypto.subtle.encrypt({name:Le,iv:r,additionalData:n},t,e);return new Uint8Array(s)}catch(s){throw new Error("Failed to encrypt symmetrically",{cause:s})}}async function ta(e,t,r,n){try{const s=await crypto.subtle.decrypt({name:Le,iv:t,additionalData:n},r,e);return new Uint8Array(s)}catch(s){throw new Error("Failed to decrypt symmetrically",{cause:s})}}async function sr(e,t,r,n){try{const s=await Qc(n),o=await po(r);return{ciphertext:await ea(t,e,s,o),iv:s}}catch(s){throw new Error("Failed to encrypt symmetrically",{cause:s})}}async function tt(e,t,r){try{const n=await po(r);return await ta(t.ciphertext,t.iv,e,n)}catch(n){throw new Error("Failed to decrypt symmetrically",{cause:n})}}const ra=Object.freeze(Object.defineProperty({__proto__:null,decryptSymmetrically:tt,deriveSymmetricCryptoKey:Uc,encryptSymmetrically:sr,exportSymmetricCryptoKey:Dc,genSymmetricCryptoKey:dn,genSymmetricKey:Mc,importSymmetricCryptoKey:rr},Symbol.toStringTag,{value:"Module"}));async function rt(e,t){try{const r=await je.blake3(e),n=jt(r),s=await je.blake3(t,V,n);return jt(s)}catch(r){throw new Error("Failed to derive key from base key and context",{cause:r})}}async function ht(e,t){try{if(t.length!=V/8)throw new Error(`Base key length must be exactly ${V/8} bytes`);if(!e)throw new Error("Context is empry");const r=await rt(e,t);return await rr(r)}catch(r){throw new Error("Failed to derive CryptoKey from base key and context",{cause:r})}}async function yo(e,t,r=Ns,n=Ls,s=Ds,o=Us){return je.argon2id({password:e,salt:t,parallelism:r,iterations:n,memorySize:s,hashLength:o,outputType:"binary"})}function na(){try{const e=new Uint8Array(Ms);return crypto.getRandomValues(e),e}catch(e){throw new Error("Failed to sample salt",{cause:e})}}async function mo(e,t,r){try{if(t.length!=V/8||e.length!=V/8)throw new Error(`Input key length must be exactly ${V/8} bytes`);const n=await je.blake3(e,ut,t);return await rt(r,n)}catch(n){throw new Error("Failed to derive symmetric key from two keys",{cause:n})}}async function pn(e){try{if(!e)throw new Error("No password given");const t=na();return{key:await yo(e,t),salt:t}}catch(t){throw new Error("Failed to derive key from password",{cause:t})}}async function yn(e,t){try{if(!t.length)throw new Error("No salt given");if(!e)throw new Error("No password given");return await yo(e,t)}catch(r){throw new Error("Failed to derive key from password and salt",{cause:r})}}async function sa(e){try{const{key:t,salt:r}=await pn(e);return{keyHex:Qe(t),saltHex:Qe(r)}}catch(t){throw new Error("Failed to derive key from password",{cause:t})}}async function go(e,t){try{const r=jt(t),n=await yn(e,r);return Qe(n)}catch(r){throw new Error("Failed to derive key from password and salt",{cause:r})}}async function oa(e,t,r){const n=await go(e,t);return r===n}async function wo(e,t){return await mo(e,t,Bs)}async function ia(e,t){try{const r=await wo(e,t);return await rr(r)}catch(r){throw new Error("Failed to derive symmetric CryptoKey from two keys",{cause:r})}}async function ca(e){try{const t=await rt(jr,e.olmKey),r=await rt(jr,e.pqKey),n=e.index+1,s=e.userID;return{olmKey:t,pqKey:r,index:n,userID:s}}catch(t){throw new Error("Failed to ratchet media key",{cause:t})}}const aa=Object.freeze(Object.defineProperty({__proto__:null,deriveSymmetricCryptoKeyFromContext:ht,deriveSymmetricCryptoKeyFromTwoKeys:ia,deriveSymmetricKeyFromContext:rt,deriveSymmetricKeyFromTwoKeys:wo,getKeyFromPassword:pn,getKeyFromPasswordAndSalt:yn,getKeyFromPasswordAndSaltHex:go,getKeyFromPasswordHex:sa,ratchetMediaKey:ca,verifyKeyFromPasswordHex:oa},Symbol.toStringTag,{value:"Module"}));function _t(e){try{const t=JSON.stringify(e);return btoa(t)}catch(t){throw new Error("Failed to convert User to base64",{cause:t})}}function Kt(e){try{const t=atob(e);return JSON.parse(t)}catch(t){throw new Error("Failed to convert base64 to User",{cause:t})}}function bo(e){try{const t=JSON.stringify(e);return Qt(t)}catch(t){throw new Error("Failed to convert EmailBody to Uint8Array",{cause:t})}}function mn(e){try{const t=un(e);return JSON.parse(t)}catch(t){throw new Error("Failed to convert Uint8Array to EmailBody",{cause:t})}}async function Eo(e){try{const t=atob(e),r=JSON.parse(t),n=D(r.eccPublicKey),s=await Zt(n),o=D(r.kyberPublicKey);return{eccPublicKey:s,kyberPublicKey:o}}catch(t){throw new Error("Failed to convert base64 to PublicKeys",{cause:t})}}async function la(e){try{const t=await Wt(e.eccPublicKey),r=JSON.stringify({eccPublicKey:U(t),kyberPublicKey:U(e.kyberPublicKey)});return btoa(r)}catch(t){throw new Error("Failed to convert key of the type PublicKeys to base64",{cause:t})}}function xo(e){try{const t=JSON.stringify({kyberCiphertext:U(e.kyberCiphertext),encryptedKey:U(e.encryptedKey)});return btoa(t)}catch(t){throw new Error("Failed to convert hybrid key to base64",{cause:t})}}function ua(e){try{const t=atob(e),r=JSON.parse(t);return{encryptedKey:D(r.encryptedKey),kyberCiphertext:D(r.kyberCiphertext)}}catch(t){throw new Error("Failed to convert base64 to hybrid key",{cause:t})}}function ko(e){try{const t=JSON.stringify({encryptedKey:U(e.encryptedKey),salt:U(e.salt)});return btoa(t)}catch(t){throw new Error("Failed to convert password-protected key to base64",{cause:t})}}function ha(e){try{const t=atob(e),r=JSON.parse(t);return{encryptedKey:D(r.encryptedKey),salt:D(r.salt)}}catch(t){throw new Error("Failed to convert base64 to password-protected key",{cause:t})}}function fa(e){try{const t=JSON.stringify({...e,sender:_t(e.sender),recipient:_t(e.recipient),recipients:e.recipients?.map(_t)});return btoa(t)}catch(t){throw new Error("Failed to convert email public parameters to base64",{cause:t})}}function da(e){try{const t=atob(e),r=JSON.parse(t);return{...r,sender:Kt(r.sender),recipient:Kt(r.recipient),recipients:r.recipients?.map(Kt)}}catch(t){throw new Error("Failed to convert base64 to email params",{cause:t})}}function vo(e){try{const t=JSON.stringify({encryptedKey:xo(e.encryptedKey),enc:_e(e.enc),recipientID:e.recipientID});return btoa(t)}catch(t){throw new Error("Failed to convert hybrid email to base64",{cause:t})}}function So(e){try{const t=JSON.stringify({encryptedKey:ko(e.encryptedKey),enc:_e(e.enc)});return btoa(t)}catch(t){throw new Error("Failed to convert pwd protected email to base64",{cause:t})}}function To(e){try{const t=JSON.stringify(e);return Qt(t)}catch(t){throw new Error("Failed to convert EmailBody to Uint8Array",{cause:t})}}/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function pa(e,t=8){const s=e.toString(2).padStart(8,"0").slice(-t).padStart(7,"0").split("").reverse().join("");return Number.parseInt(s,2)}const ya=e=>{const{newPoly:t,N:r,Q:n,F:s,ROOT_OF_UNITY:o,brvBits:i}=e,c=(f,d=n)=>{const b=f%d|0;return(b>=0?b|0:d+b|0)|0},a=(f,d=n)=>{const b=c(f,d)|0;return(b>d>>1?b-d|0:b)|0};function l(){const f=t(r);for(let d=0;d<r;d++){const b=pa(d,i),w=BigInt(o)**BigInt(b)%BigInt(n);f[d]=Number(w)|0}return f}const u=l(),h=128,m=1;return{mod:c,smod:a,nttZetas:u,NTT:{encode:f=>{for(let d=1,b=128;b>m;b>>=1)for(let w=0;w<r;w+=2*b){const E=u[d++];for(let x=w;x<w+b;x++){const k=c(E*f[x+b]);f[x+b]=c(f[x]-k)|0,f[x]=c(f[x]+k)|0}}return f},decode:f=>{for(let d=h-1,b=1+m;b<h+m;b<<=1)for(let w=0;w<r;w+=2*b){const E=u[d--];for(let x=w;x<w+b;x++){const k=f[x];f[x]=c(k+f[x+b]),f[x+b]=c(E*(f[x+b]-k))}}for(let d=0;d<f.length;d++)f[d]=c(s*f[d]);return f}},bitsCoder:(f,d)=>{const b=qn(f),w=f*(r/8);return{bytesLen:w,encode:E=>{const x=new Uint8Array(w);for(let k=0,v=0,S=0,T=0;k<E.length;k++)for(v|=(d.encode(E[k])&b)<<S,S+=f;S>=8;S-=8,v>>=8)x[T++]=v&qn(S);return x},decode:E=>{const x=t(r);for(let k=0,v=0,S=0,T=0;k<E.length;k++)for(v|=E[k]<<S,S+=8;S>=f;S-=f,v>>=f)x[T++]=d.decode(v&b);return x}}}}},ma=e=>(t,r)=>{r||(r=e.blockLen);const n=new Uint8Array(t.length+2);n.set(t);const s=t.length,o=new Uint8Array(r);let i=e.create({}),c=0,a=0;return{stats:()=>({calls:c,xofs:a}),get:(l,u)=>(n[s+0]=l,n[s+1]=u,i.destroy(),i=e.create({}).update(n),c++,()=>(a++,i.xofInto(o))),clean:()=>{i.destroy(),o.fill(0),n.fill(0)}}},ga=ma(Zc);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const Y=256,ue=3329,wa=3303,ba=17,{mod:nt,nttZetas:Ea,NTT:we,bitsCoder:xa}=ya({N:Y,Q:ue,F:wa,ROOT_OF_UNITY:ba,newPoly:e=>new Uint16Array(e),brvBits:7}),gn={512:{N:Y,Q:ue,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:Y,Q:ue,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:Y,Q:ue,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},ka=e=>{if(e>=12)return{encode:r=>r,decode:r=>r};const t=2**(e-1);return{encode:r=>((r<<e)+ue/2)/ue,decode:r=>r*ue+t>>>e}},Ge=e=>xa(e,ka(e));function be(e,t){for(let r=0;r<Y;r++)e[r]=nt(e[r]+t[r])}function va(e,t){for(let r=0;r<Y;r++)e[r]=nt(e[r]-t[r])}function Sa(e,t,r,n,s){const o=nt(t*n*s+e*r),i=nt(e*n+t*r);return{c0:o,c1:i}}function xt(e,t){for(let r=0;r<Y/2;r++){let n=Ea[64+(r>>1)];r&1&&(n=-n);const{c0:s,c1:o}=Sa(e[2*r+0],e[2*r+1],t[2*r+0],t[2*r+1],n);e[2*r+0]=s,e[2*r+1]=o}return e}function Wn(e){const t=new Uint16Array(Y);for(let r=0;r<Y;){const n=e();if(n.length%3)throw new Error("SampleNTT: unaligned block");for(let s=0;r<Y&&s+3<=n.length;s+=3){const o=(n[s+0]>>0|n[s+1]<<8)&4095,i=(n[s+1]>>4|n[s+2]<<4)&4095;o<ue&&(t[r++]=o),r<Y&&i<ue&&(t[r++]=i)}}return t}function Xe(e,t,r,n){const s=e(n*Y/4,t,r),o=new Uint16Array(Y),i=Ws(s);let c=0;for(let a=0,l=0,u=0,h=0;a<i.length;a++){let m=i[a];for(let y=0;y<32;y++)u+=m&1,m>>=1,c+=1,c===n?(h=u,u=0):c===2*n&&(o[l++]=nt(h-u),u=0,c=0)}if(c)throw new Error(`sampleCBD: leftover bits: ${c}`);return o}const Ta=e=>{const{K:t,PRF:r,XOF:n,HASH512:s,ETA1:o,ETA2:i,du:c,dv:a}=e,l=Ge(1),u=Ge(a),h=Ge(c),m=At(Ar(Ge(12),t),32),y=Ar(Ge(12),t),p=At(Ar(h,t),u),f=At(32,32);return{secretCoder:y,secretKeyLen:y.bytesLen,publicKeyLen:m.bytesLen,cipherTextLen:p.bytesLen,keygen:d=>{le(d,32);const b=new Uint8Array(33);b.set(d),b[32]=t;const w=s(b),[E,x]=f.decode(w),k=[],v=[];for(let _=0;_<t;_++)k.push(we.encode(Xe(r,x,_,o)));const S=n(E);for(let _=0;_<t;_++){const C=we.encode(Xe(r,x,t+_,o));for(let O=0;O<t;O++){const j=Wn(S.get(O,_));be(C,xt(j,k[O]))}v.push(C)}S.clean();const T={publicKey:m.encode([v,E]),secretKey:y.encode(k)};return xe(E,x,k,v,b,w),T},encrypt:(d,b,w)=>{const[E,x]=m.decode(d),k=[];for(let O=0;O<t;O++)k.push(we.encode(Xe(r,w,O,o)));const v=n(x),S=new Uint16Array(Y),T=[];for(let O=0;O<t;O++){const j=Xe(r,w,t+O,i),L=new Uint16Array(Y);for(let M=0;M<t;M++){const B=Wn(v.get(O,M));be(L,xt(B,k[M]))}be(j,we.decode(L)),T.push(j),be(S,xt(E[O],k[O])),L.fill(0)}v.clean();const _=Xe(r,w,2*t,i);be(_,we.decode(S));const C=l.decode(b);return be(C,_),xe(E,k,S,_),p.encode([T,C])},decrypt:(d,b)=>{const[w,E]=p.decode(d),x=y.decode(b),k=new Uint16Array(Y);for(let v=0;v<t;v++)be(k,xt(x[v],we.encode(w[v])));return va(E,we.decode(k)),xe(k,x,w),l.encode(E)}}};function wn(e){const t=Ta(e),{HASH256:r,HASH512:n,KDF:s}=e,{secretCoder:o,cipherTextLen:i}=t,c=t.publicKeyLen,a=At(t.secretKeyLen,t.publicKeyLen,32,32),l=a.bytesLen,u=32;return{publicKeyLen:c,msgLen:u,keygen:(h=Ut(64))=>{le(h,64);const{publicKey:m,secretKey:y}=t.keygen(h.subarray(0,32)),p=r(m),f=a.encode([y,m,p,h.subarray(32)]);return xe(y,p),{publicKey:m,secretKey:f}},encapsulate:(h,m=Ut(32))=>{le(h,c),le(m,u);const y=h.subarray(0,384*e.K),p=o.encode(o.decode(y.slice()));if(!Xn(p,y))throw xe(p),new Error("ML-KEM.encapsulate: wrong publicKey modulus");xe(p);const f=n.create().update(m).update(r(h)).digest(),d=t.encrypt(h,m,f.subarray(32,64));return f.subarray(32).fill(0),{cipherText:d,sharedSecret:f.subarray(0,32)}},decapsulate:(h,m)=>{le(m,l),le(h,i);const[y,p,f,d]=a.decode(m),b=t.decrypt(h,y),w=n.create().update(b).update(f).digest(),E=w.subarray(0,32),x=t.encrypt(p,b,w.subarray(32,64)),k=Xn(h,x),v=s.create({dkLen:32}).update(d).update(h).digest();return xe(b,x,k?v:E),k?E:v}}}function Aa(e,t,r){return fo.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}const bn={HASH256:qc,HASH512:Wc,KDF:fo,XOF:ga,PRF:Aa},En=wn({...bn,...gn[512]}),xn=wn({...bn,...gn[768]}),kn=wn({...bn,...gn[1024]});function vn(e){try{return xn.keygen(e)}catch(t){throw new Error("Failed to generate Kyber keys",{cause:t})}}function Ao(e){try{return xn.encapsulate(e)}catch(t){throw new Error("Failed to encapsulate",{cause:t})}}function _o(e,t){try{return xn.decapsulate(e,t)}catch(r){throw new Error("Failed to decapsulate",{cause:r})}}function _a(e){try{return En.keygen(e)}catch(t){throw new Error("Failed to generate Kyber keys",{cause:t})}}function Ka(e){try{return En.encapsulate(e)}catch(t){throw new Error("Failed to encapsulate",{cause:t})}}function Oa(e,t){try{return En.decapsulate(e,t)}catch(r){throw new Error("Failed to decapsulate",{cause:r})}}const Ra=Object.freeze(Object.defineProperty({__proto__:null,decapsulateKyber:Oa,encapsulateKyber:Ka,generateKyberKeys:_a},Symbol.toStringTag,{value:"Module"}));function Ca(e){try{return kn.keygen(e)}catch(t){throw new Error("Failed to generate Kyber keys",{cause:t})}}function Ia(e){try{return kn.encapsulate(e)}catch(t){throw new Error("Failed to encapsulate",{cause:t})}}function Pa(e,t){try{return kn.decapsulate(e,t)}catch(r){throw new Error("Failed to decapsulate",{cause:r})}}const ja=Object.freeze(Object.defineProperty({__proto__:null,decapsulateKyber:Pa,encapsulateKyber:Ia,generateKyberKeys:Ca},Symbol.toStringTag,{value:"Module"})),Ba=Object.freeze(Object.defineProperty({__proto__:null,decapsulateKyber:_o,encapsulateKyber:Ao,generateKyberKeys:vn,kyber1024:ja,kyber512:Ra},Symbol.toStringTag,{value:"Module"}));async function or(e){try{return await crypto.subtle.importKey(De,e,Xt,!1,["wrapKey","unwrapKey"])}catch(t){throw new Error("Failed to import wrapping key",{cause:t})}}async function Sn(e,t){try{if(e.length!==t.length)throw new Error("secrets must have equal length");const r=await mo(e,t,Rs);return await or(r)}catch(r){throw new Error("Failed to derive wrapping key",{cause:r})}}async function Tn(e,t){try{return await crypto.subtle.unwrapKey(De,e,t,Xt,Le,!1,["encrypt","decrypt"])}catch(r){throw new Error("Failed to unwrap key",{cause:r})}}async function An(e,t){try{const r=await crypto.subtle.wrapKey(De,e,t,Xt);return new Uint8Array(r)}catch(r){throw new Error("Failed to wrap key",{cause:r})}}const Fa=Object.freeze(Object.defineProperty({__proto__:null,deriveWrappingKey:Sn,importWrappingKey:or,unwrapKey:Tn,wrapKey:An},Symbol.toStringTag,{value:"Module"}));async function _n(e,t,r){try{const n=await dn();return{enc:await ir(e,n,t,r),encryptionKey:n}}catch(n){throw new Error("Failed to symmetrically encrypt email",{cause:n})}}async function Kn(e,t,r,n){try{const s=await dn(),o=await ir(e,s,r,n),i=Qt(t),c=await sr(s,i,r);return{enc:o,encryptionKey:s,subjectEnc:c}}catch(s){throw new Error("Failed to symmetrically encrypt email and subject",{cause:s})}}async function Ko(e,t,r,n){try{const s=await tt(r,e,n),o=await tt(r,t,n);return{body:mn(s),subject:un(o)}}catch(s){throw new Error("Failed to symmetrically decrypt email and subject",{cause:s})}}async function ir(e,t,r,n){try{const s=bo(e);return await sr(t,s,r,n)}catch(s){throw new Error("Failed to symmetrically encrypt email with the given key",{cause:s})}}async function cr(e,t,r){try{const n=await tt(t,e,r);return mn(n)}catch(n){throw new Error("Failed to symmetrically decrypt email",{cause:n})}}async function ar(e,t,r){try{const n=await cn(t.eccPublicKey,r.eccPrivateKey),{cipherText:s,sharedSecret:o}=Ao(t.kyberPublicKey),i=await Sn(n,o);return{encryptedKey:await An(e,i),kyberCiphertext:s}}catch(n){throw new Error("Failed to encrypt email key using hybrid encryption",{cause:n})}}async function Oo(e,t,r){try{const n=await cn(t.eccPublicKey,r.eccPrivateKey),s=_o(e.kyberCiphertext,r.kyberPrivateKey),o=await Sn(n,s);return await Tn(e.encryptedKey,o)}catch(n){throw new Error("Failed to decrypt email key encrypted via hybrid encryption",{cause:n})}}async function Ro(e,t){try{const{key:r,salt:n}=await pn(t),s=await or(r);return{encryptedKey:await An(e,s),salt:n}}catch(r){throw new Error("Failed to password-protect email key",{cause:r})}}async function Co(e,t){try{const r=await yn(t,e.salt),n=await or(r);return await Tn(e.encryptedKey,n)}catch(r){throw new Error("Failed to remove password-protection from email key",{cause:r})}}function ie(e){try{const{subject:t,replyToEmailID:r,sender:n,recipients:s}=e;return JSON.stringify({subject:t,replyToEmailID:r,sender:n,recipients:s})}catch(t){throw new Error("Failed to create aux",{cause:t})}}function He(e){try{const{replyToEmailID:t,sender:r,recipients:n}=e;return JSON.stringify({replyToEmailID:t,sender:r,recipients:n})}catch(t){throw new Error("Failed to create aux without subject",{cause:t})}}function Na(){return Di.v4()}async function La(e,t,r){try{const n=ie(e.params),{enc:s,encryptionKey:o}=await _n(e.body,n,e.params.id),i=await ar(o,t.publicKeys,r);return{enc:s,encryptedKey:i,recipientID:t.id,params:e.params}}catch(n){throw new Error("Failed to encrypt email with hybrid encryption",{cause:n})}}async function Da(e,t,r){try{const n=ie(e.params),{enc:s,encryptionKey:o}=await _n(e.body,n,e.params.id),i=[];for(const c of t){const a=await ar(o,c.publicKeys,r);i.push({enc:s,encryptedKey:a,recipientID:c.id,params:e.params})}return i}catch(n){throw new Error("Failed to encrypt email to multiple recipients with hybrid encryption",{cause:n})}}async function Ma(e,t,r){try{const n=ie(e.params),s=await Oo(e.encryptedKey,t,r);return{body:await cr(e.enc,s,n),params:e.params}}catch(n){throw new Error("Failed to decrypt email with hybrid encryption",{cause:n})}}async function Ua(e,t,r){try{const n=He(e.params),{enc:s,encryptionKey:o,subjectEnc:i}=await Kn(e.body,e.params.subject,n,e.params.id),c=_e(i),a=await ar(o,t.publicKeys,r),l={...e.params,subject:c};return{enc:s,encryptedKey:a,recipientID:t.id,params:l}}catch(n){throw new Error("Failed to encrypt the email and its subject with hybrid encryption",{cause:n})}}async function Ha(e,t,r){try{const n=He(e.params),{enc:s,encryptionKey:o,subjectEnc:i}=await Kn(e.body,e.params.subject,n,e.params.id),c=_e(i),a=[];for(const l of t){const u=await ar(o,l.publicKeys,r),h={...e.params,subject:c};a.push({enc:s,encryptedKey:u,recipientID:l.id,params:h})}return a}catch(n){throw new Error("Failed to encrypt the email and its subject to multiple recipients with hybrid encryption",{cause:n})}}async function za(e,t,r){try{const n=He(e.params),s=await Oo(e.encryptedKey,t,r),o=er(e.params.subject),{body:i,subject:c}=await Ko(e.enc,o,s,n),a={...e.params,subject:c};return{body:i,params:a}}catch(n){throw new Error("Failed to decrypt the email and its subject with hybrid encryption",{cause:n})}}async function $a(e,t){try{if(!e?.body||!e.params)throw new Error("Failed to password-protect email: Invalid email structure");const r=ie(e.params),{enc:n,encryptionKey:s}=await _n(e.body,r,e.params.id),o=await Ro(s,t);return{enc:n,encryptedKey:o,params:e.params}}catch(r){throw new Error("Failed to password-protect email",{cause:r})}}async function Ya(e,t){try{const r=ie(e.params),n=await Co(e.encryptedKey,t);return{body:await cr(e.enc,n,r),params:e.params}}catch(r){throw new Error("Failed to decrypt password-protect email",{cause:r})}}async function Va(e,t){try{if(!e?.body||!e.params)throw new Error("Failed to password-protect email and subject: Invalid email structure");const r=He(e.params),{enc:n,encryptionKey:s,subjectEnc:o}=await Kn(e.body,e.params.subject,r,e.params.id),i=await Ro(s,t),c=_e(o),a={...e.params,subject:c};return{enc:n,encryptedKey:i,params:a}}catch(r){throw new Error("Failed to password-protect email and subject",{cause:r})}}async function Ja(e,t){try{const r=He(e.params),n=await Co(e.encryptedKey,t),s=er(e.params.subject),{body:o,subject:i}=await Ko(e.enc,s,n,r),c={...e.params,subject:i};return{body:o,params:c}}catch(r){throw new Error("Failed to decrypt password-protect email",{cause:r})}}async function Ga(){try{const e=vn(),t=await qt(),r={eccPrivateKey:t.privateKey,kyberPrivateKey:e.secretKey};return{publicKeys:{eccPublicKey:t.publicKey,kyberPublicKey:e.publicKey},privateKeys:r}}catch(e){throw new Error("Failed to generate keys for email service",{cause:e})}}const Xa=Object.freeze(Object.defineProperty({__proto__:null,base64ToEncHybridKey:ua,base64ToParams:da,base64ToPublicKey:Eo,base64ToPwdProtectedKey:ha,base64ToUser:Kt,binaryToEmailBody:mn,createPwdProtectedEmail:$a,createPwdProtectedEmailAndSubject:Va,decryptEmailAndSubjectHybrid:za,decryptEmailHybrid:Ma,decryptPwdProtectedEmail:Ya,decryptPwdProtectedEmailAndSubject:Ja,emailBodyToBinary:bo,emailToBinary:To,encHybridKeyToBase64:xo,encryptEmailAndSubjectHybrid:Ua,encryptEmailAndSubjectHybridForMultipleRecipients:Ha,encryptEmailHybrid:La,encryptEmailHybridForMultipleRecipients:Da,generateEmailID:Na,generateEmailKeys:Ga,getAux:ie,getAuxWithoutSubject:He,hybridEncyptedEmailToBase64:vo,paramsToBase64:fa,publicKeyToBase64:la,pwdProtectedEmailToBase64:So,pwdProtectedKeyToBase64:ko,userToBase64:_t},Symbol.toStringTag,{value:"Module"})),Dr=(e,t)=>t.some(r=>e instanceof r);let Zn,Qn;function qa(){return Zn||(Zn=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Wa(){return Qn||(Qn=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Mr=new WeakMap,_r=new WeakMap,lr=new WeakMap;function Za(e){const t=new Promise((r,n)=>{const s=()=>{e.removeEventListener("success",o),e.removeEventListener("error",i)},o=()=>{r(pe(e.result)),s()},i=()=>{n(e.error),s()};e.addEventListener("success",o),e.addEventListener("error",i)});return lr.set(t,e),t}function Qa(e){if(Mr.has(e))return;const t=new Promise((r,n)=>{const s=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",i),e.removeEventListener("abort",i)},o=()=>{r(),s()},i=()=>{n(e.error||new DOMException("AbortError","AbortError")),s()};e.addEventListener("complete",o),e.addEventListener("error",i),e.addEventListener("abort",i)});Mr.set(e,t)}let Ur={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return Mr.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return pe(e[t])},set(e,t,r){return e[t]=r,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};function Io(e){Ur=e(Ur)}function el(e){return Wa().includes(e)?function(...t){return e.apply(Hr(this),t),pe(this.request)}:function(...t){return pe(e.apply(Hr(this),t))}}function tl(e){return typeof e=="function"?el(e):(e instanceof IDBTransaction&&Qa(e),Dr(e,qa())?new Proxy(e,Ur):e)}function pe(e){if(e instanceof IDBRequest)return Za(e);if(_r.has(e))return _r.get(e);const t=tl(e);return t!==e&&(_r.set(e,t),lr.set(t,e)),t}const Hr=e=>lr.get(e);function rl(e,t,{blocked:r,upgrade:n,blocking:s,terminated:o}={}){const i=indexedDB.open(e,t),c=pe(i);return n&&i.addEventListener("upgradeneeded",a=>{n(pe(i.result),a.oldVersion,a.newVersion,pe(i.transaction),a)}),r&&i.addEventListener("blocked",a=>r(a.oldVersion,a.newVersion,a)),c.then(a=>{o&&a.addEventListener("close",()=>o()),s&&a.addEventListener("versionchange",l=>s(l.oldVersion,l.newVersion,l))}).catch(()=>{}),c}function nl(e,{blocked:t}={}){const r=indexedDB.deleteDatabase(e);return t&&r.addEventListener("blocked",n=>t(n.oldVersion,n)),pe(r).then(()=>{})}const sl=["get","getKey","getAll","getAllKeys","count"],ol=["put","add","delete","clear"],Kr=new Map;function es(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(Kr.get(t))return Kr.get(t);const r=t.replace(/FromIndex$/,""),n=t!==r,s=ol.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(s||sl.includes(r)))return;const o=async function(i,...c){const a=this.transaction(i,s?"readwrite":"readonly");let l=a.store;return n&&(l=l.index(c.shift())),(await Promise.all([l[r](...c),s&&a.done]))[0]};return Kr.set(t,o),o}Io(e=>({...e,get:(t,r,n)=>es(t,r)||e.get(t,r,n),has:(t,r)=>!!es(t,r)||e.has(t,r)}));const il=["continue","continuePrimaryKey","advance"],ts={},zr=new WeakMap,Po=new WeakMap,cl={get(e,t){if(!il.includes(t))return e[t];let r=ts[t];return r||(r=ts[t]=function(...n){zr.set(this,Po.get(this)[t](...n))}),r}};async function*al(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;t=t;const r=new Proxy(t,cl);for(Po.set(r,t),lr.set(r,Hr(t));t;)yield r,t=await(zr.get(r)||t.continue()),zr.delete(r)}function rs(e,t){return t===Symbol.asyncIterator&&Dr(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&Dr(e,[IDBIndex,IDBObjectStore])}Io(e=>({...e,get(t,r,n){return rs(t,r)?al:e.get(t,r,n)},has(t,r){return rs(t,r)||e.has(t,r)}}));const jo=e=>`ES:${e}:DB`,ll=async e=>{try{const t=jo(e);return rl(t,zs,{upgrade(r){r.objectStoreNames.contains(q)||r.createObjectStore(q,{keyPath:"params.id"}).createIndex("byTime","params.createdAt")}})}catch(t){throw new Error(`Cannot open a database for the user ${e}`,{cause:t})}},ul=e=>e.close(),hl=async e=>{const t=jo(e);return nl(t)},fl=async e=>ht(js,e),dl=async(e,t,r)=>{try{const n=ie(e.params),o={content:await ir(e.body,t,n,e.params.id),params:e.params};await r.put(q,o)}catch(n){throw new Error("Cannot encrypt and add the given email to the database",{cause:n})}},pl=async(e,t,r)=>{try{const n=await Promise.all(e.map(async o=>{const i=ie(o.params);return{content:await ir(o.body,t,i,o.params.id),params:o.params}})),s=r.transaction(q,"readwrite");await Promise.all([...n.map(o=>s.store.put(o)),s.done])}catch(n){throw new Error("Cannot encrypt and add emails to the database",{cause:n})}},On=async(e,t)=>{try{const r=ie(t.params);return{body:await cr(t.content,e,r),params:t.params}}catch(r){throw new Error("Cannot decrypt the given email",{cause:r})}},yl=async(e,t,r)=>{try{const n=await r.get(q,e);if(!n)throw new Error(`DB cannot find email with id ${e}`);return On(t,n)}catch(n){throw new Error(`Cannot fetch the email ${e} from the database`,{cause:n})}},ml=async(e,t)=>{try{const r=await t.getAll(q);return(await Promise.all(r.map(async s=>{const o=ie(s.params);return{body:await cr(s.content,e,o),params:s.params}}))).filter(s=>s!==null)}catch(r){throw new Error("Cannot fetch and decrypt all emails from the database",{cause:r})}},gl=async(e,t)=>{await t.delete(q,e)},Rn=async e=>await e.count(q),Bo=async(e,t)=>{try{const r=t.transaction(q,"readwrite");let s=await r.store.index("byTime").openCursor(),o=0;for(;s&&o<e;)await s.delete(),o++,s=await s.continue();await r.done}catch(r){throw new Error(`Cannot delete ${e} oldests emails from the database`,{cause:r})}},wl=async(e,t)=>{try{const r=await Rn(e);if(r<=t)return;await Bo(r-t,e)}catch(r){throw new Error(`Cannot enforce the maximum of ${t} emails on the database`,{cause:r})}},Fo=async(e,t,r)=>{try{const s=e.transaction(q,"readonly").store.index("byTime"),o=[];let i=await s.openCursor(null,r);for(;i;)o.push(i.value),i=await i.continue();return await Promise.all(o.map(a=>On(t,a)))}catch(n){throw new Error("Cannot fetch emails from database",{cause:n})}},No=async(e,t)=>Fo(e,t,"prev"),bl=async(e,t)=>Fo(e,t,"next"),Lo=async(e,t,r,n)=>{try{const o=e.transaction(q,"readonly").store.index("byTime"),i=[];let c;if(n){const h=IDBKeyRange.upperBound(n,!0);c=await o.openCursor(h,"prev")}else c=await o.openCursor(null,"prev");let a=0,l;for(;c&&a<r;)i.push(c.value),l=c.key,a++,c=await c.continue();return{emails:await Promise.all(i.map(h=>On(t,h))),nextCursor:a===r?l:void 0}}catch(s){throw new Error(`Cannot fetch email batch of ${r} from the database`,{cause:s})}};function Do(e){return To(e).byteLength}function El(){return{esCache:new Map,cacheSize:0,isCacheLimited:!1,isCacheReady:!0}}const xl=async(e,t)=>{const r=El();r.isCacheReady=!1;try{const n=await Rn(t);if(!n)return r.isCacheReady=!0,r;if(n<=Br){const s=await No(t,e);$r(s,r)}else{let s,o=!1;for(;!o;){const{emails:i,nextCursor:c}=await Lo(t,e,Br,s);if(!c||!i.length)break;s=c,$r(i,r)||(o=!0)}}return r}catch(n){throw new Error(`Email caching failed: ${n}`)}},Mo=async(e,t)=>{const r=t.esCache.get(e);if(!r)throw new Error(`Email not found in cache for ID: ${e}`);return r},kl=async(e,t)=>{try{const r=await Mo(e,t),n=Do(r);t.esCache.delete(e)&&(t.cacheSize-=n)}catch(r){throw new Error(`Failed to delete email with ID ${e}`,{cause:r})}};function $r(e,t){try{for(const r of e){const n=Uo(r,t);if(!n.success)return n}return{success:!0}}catch(r){throw new Error("Failed to add emails to the cache",{cause:r})}}const Uo=(e,t)=>{try{if(t.esCache.has(e.params.id))return{success:!1,reason:"email already exists in cache"};const r=Do(e);return t.cacheSize+r>Hs?(t.isCacheLimited=!0,{success:!1,reason:"hit cache limit"}):(t.esCache.set(e.params.id,e),t.cacheSize+=r,{success:!0})}catch(r){throw new Error("Failed to add email to the cache",{cause:r})}};var A;function H(e,t,r){const n=typeof r,s=typeof e;if(n!=="undefined"){if(s!=="undefined"){if(r){if(s==="function"&&n===s)return function(c){return e(r(c))};if(t=e.constructor,t===r.constructor){if(t===Array)return r.concat(e);if(t===Map){var o=new Map(r);for(var i of e)o.set(i[0],i[1]);return o}if(t===Set){i=new Set(r);for(o of e.values())i.add(o);return i}}}return e}return r}return s==="undefined"?t:e}function Re(e,t){return typeof e>"u"?t:e}function N(){return Object.create(null)}function Z(e){return typeof e=="string"}function st(e){return typeof e=="object"}function ot(e,t){if(Z(t))e=e[t];else for(let r=0;e&&r<t.length;r++)e=e[t[r]];return e}const vl=/[^\p{L}\p{N}]+/u,Sl=/(\d{3})/g,Tl=/(\D)(\d{3})/g,Al=/(\d{3})(\D)/g,ns=/[\u0300-\u036f]/g;function it(e={}){if(!this||this.constructor!==it)return new it(...arguments);if(arguments.length)for(e=0;e<arguments.length;e++)this.assign(arguments[e]);else this.assign(e)}A=it.prototype;A.assign=function(e){this.normalize=H(e.normalize,!0,this.normalize);let t=e.include,r=t||e.exclude||e.split,n;if(r||r===""){if(typeof r=="object"&&r.constructor!==RegExp){let s="";n=!t,t||(s+="\\p{Z}"),r.letter&&(s+="\\p{L}"),r.number&&(s+="\\p{N}",n=!!t),r.symbol&&(s+="\\p{S}"),r.punctuation&&(s+="\\p{P}"),r.control&&(s+="\\p{C}"),(r=r.char)&&(s+=typeof r=="object"?r.join(""):r);try{this.split=new RegExp("["+(t?"^":"")+s+"]+","u")}catch{this.split=/\s+/}}else this.split=r,n=r===!1||"a1a".split(r).length<2;this.numeric=H(e.numeric,n)}else{try{this.split=H(this.split,vl)}catch{this.split=/\s+/}this.numeric=H(e.numeric,H(this.numeric,!0))}if(this.prepare=H(e.prepare,null,this.prepare),this.finalize=H(e.finalize,null,this.finalize),r=e.filter,this.filter=typeof r=="function"?r:H(r&&new Set(r),null,this.filter),this.dedupe=H(e.dedupe,!0,this.dedupe),this.matcher=H((r=e.matcher)&&new Map(r),null,this.matcher),this.mapper=H((r=e.mapper)&&new Map(r),null,this.mapper),this.stemmer=H((r=e.stemmer)&&new Map(r),null,this.stemmer),this.replacer=H(e.replacer,null,this.replacer),this.minlength=H(e.minlength,1,this.minlength),this.maxlength=H(e.maxlength,1024,this.maxlength),this.rtl=H(e.rtl,!1,this.rtl),(this.cache=r=H(e.cache,!0,this.cache))&&(this.F=null,this.L=typeof r=="number"?r: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 s of this.matcher.keys())this.h+=(this.h?"|":"")+s;if(this.stemmer)for(const s of this.stemmer.keys())this.A+=(this.A?"|":"")+s;return this};A.addStemmer=function(e,t){return this.stemmer||(this.stemmer=new Map),this.stemmer.set(e,t),this.A+=(this.A?"|":"")+e,this.K=null,this.cache&&Te(this),this};A.addFilter=function(e){return typeof e=="function"?this.filter=e:(this.filter||(this.filter=new Set),this.filter.add(e)),this.cache&&Te(this),this};A.addMapper=function(e,t){return typeof e=="object"?this.addReplacer(e,t):e.length>1?this.addMatcher(e,t):(this.mapper||(this.mapper=new Map),this.mapper.set(e,t),this.cache&&Te(this),this)};A.addMatcher=function(e,t){return typeof e=="object"?this.addReplacer(e,t):e.length<2&&(this.dedupe||this.mapper)?this.addMapper(e,t):(this.matcher||(this.matcher=new Map),this.matcher.set(e,t),this.h+=(this.h?"|":"")+e,this.J=null,this.cache&&Te(this),this)};A.addReplacer=function(e,t){return typeof e=="string"?this.addMatcher(e,t):(this.replacer||(this.replacer=[]),this.replacer.push(e,t),this.cache&&Te(this),this)};A.encode=function(e,t){if(this.cache&&e.length<=this.H)if(this.F){if(this.B.has(e))return this.B.get(e)}else this.F=setTimeout(Te,50,this);this.normalize&&(typeof this.normalize=="function"?e=this.normalize(e):e=ns?e.normalize("NFKD").replace(ns,"").toLowerCase():e.toLowerCase()),this.prepare&&(e=this.prepare(e)),this.numeric&&e.length>3&&(e=e.replace(Tl,"$1 $2").replace(Al,"$1 $2").replace(Sl,"$1 "));const r=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let n=[],s=N(),o,i,c=this.split||this.split===""?e.split(this.split):[e];for(let l=0,u,h;l<c.length;l++)if((u=h=c[l])&&!(u.length<this.minlength||u.length>this.maxlength)){if(t){if(s[u])continue;s[u]=1}else{if(o===u)continue;o=u}if(r)n.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 a=this.D.get(u);if(a||a===""){a&&n.push(a);continue}}else this.F=setTimeout(Te,50,this);if(this.stemmer){this.K||(this.K=new RegExp("(?!^)("+this.A+")$"));let m;for(;m!==u&&u.length>2;)m=u,u=u.replace(this.K,y=>this.stemmer.get(y))}if(u&&(this.mapper||this.dedupe&&u.length>1)){a="";for(let m=0,y="",p,f;m<u.length;m++)p=u.charAt(m),p===y&&this.dedupe||((f=this.mapper&&this.mapper.get(p))||f===""?f===y&&this.dedupe||!(y=f)||(a+=f):a+=y=p);u=a}if(this.matcher&&u.length>1&&(this.J||(this.J=new RegExp("("+this.h+")","g")),u=u.replace(this.J,m=>this.matcher.get(m))),u&&this.replacer)for(a=0;u&&a<this.replacer.length;a+=2)u=u.replace(this.replacer[a],this.replacer[a+1]);if(this.cache&&h.length<=this.I&&(this.D.set(h,u),this.D.size>this.L&&(this.D.clear(),this.I=this.I/1.1|0)),u){if(u!==h)if(t){if(s[u])continue;s[u]=1}else{if(i===u)continue;i=u}n.push(u)}}}return this.finalize&&(n=this.finalize(n)||n),this.cache&&e.length<=this.H&&(this.B.set(e,n),this.B.size>this.L&&(this.B.clear(),this.H=this.H/1.1|0)),n};function Te(e){e.F=null,e.B.clear(),e.D.clear()}function Cn(e,t,r){r||(t||typeof e!="object"?typeof t=="object"&&(r=t,t=0):r=e),r&&(e=r.query||e,t=r.limit||t);let n=""+(t||0);r&&(n+=(r.offset||0)+!!r.context+!!r.suggest+(r.resolve!==!1)+(r.resolution||this.resolution)+(r.boost||0)),e=(""+e).toLowerCase(),this.cache||(this.cache=new Ke);let s=this.cache.get(e+n);if(!s){const o=r&&r.cache;o&&(r.cache=!1),s=this.search(e,t,r),o&&(r.cache=o),this.cache.set(e+n,s)}return s}function Ke(e){this.limit=e&&e!==!0?e:1e3,this.cache=new Map,this.h=""}Ke.prototype.set=function(e,t){this.cache.set(this.h=e,t),this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};Ke.prototype.get=function(e){const t=this.cache.get(e);return t&&this.h!==e&&(this.cache.delete(e),this.cache.set(this.h=e,t)),t};Ke.prototype.remove=function(e){for(const t of this.cache){const r=t[0];t[1].includes(e)&&this.cache.delete(r)}};Ke.prototype.clear=function(){this.cache.clear(),this.h=""};const ss={normalize:!1,numeric:!1,dedupe:!1},kt={},Or=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"]]),os=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),is=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"],cs={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 Ho={Exact:ss,Default:kt,Normalize:kt,LatinBalance:{mapper:Or},LatinAdvanced:{mapper:Or,matcher:os,replacer:is},LatinExtra:{mapper:Or,replacer:is.concat([/(?!^)[aeo]/g,""]),matcher:os},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(e){for(let r=0;r<e.length;r++){var t=e[r];let n=t.charAt(0),s=cs[n];for(let o=1,i;o<t.length&&(i=t.charAt(o),i==="h"||i==="w"||!(i=cs[i])||i===s||(n+=i,s=i,n.length!==4));o++);e[r]=n}}},CJK:{split:""},LatinExact:ss,LatinDefault:kt,LatinSimple:kt};function as(e,t,r,n){let s=[];for(let o=0,i;o<e.index.length;o++)if(i=e.index[o],t>=i.length)t-=i.length;else{t=i[n?"splice":"slice"](t,r);const c=t.length;if(c&&(s=s.length?s.concat(t):t,r-=c,n&&(e.length-=c),!r))break;t=0}return s}function Be(e){if(!this||this.constructor!==Be)return new Be(e);this.index=e?[e]:[],this.length=e?e.length:0;const t=this;return new Proxy([],{get(r,n){if(n==="length")return t.length;if(n==="push")return function(s){t.index[t.index.length-1].push(s),t.length++};if(n==="pop")return function(){if(t.length)return t.length--,t.index[t.index.length-1].pop()};if(n==="indexOf")return function(s){let o=0;for(let i=0,c,a;i<t.index.length;i++){if(c=t.index[i],a=c.indexOf(s),a>=0)return o+a;o+=c.length}return-1};if(n==="includes")return function(s){for(let o=0;o<t.index.length;o++)if(t.index[o].includes(s))return!0;return!1};if(n==="slice")return function(s,o){return as(t,s||0,o||t.length,!1)};if(n==="splice")return function(s,o){return as(t,s||0,o||t.length,!0)};if(n==="constructor")return Array;if(typeof n!="symbol")return(r=t.index[n/2**31|0])&&r[n]},set(r,n,s){return r=n/2**31|0,(t.index[r]||(t.index[r]=[]))[n]=s,t.length++,!0}})}Be.prototype.clear=function(){this.index.length=0};Be.prototype.push=function(){};function Q(e=8){if(!this||this.constructor!==Q)return new Q(e);this.index=N(),this.h=[],this.size=0,e>32?(this.B=$o,this.A=BigInt(e)):(this.B=zo,this.A=e)}Q.prototype.get=function(e){const t=this.index[this.B(e)];return t&&t.get(e)};Q.prototype.set=function(e,t){var r=this.B(e);let n=this.index[r];n?(r=n.size,n.set(e,t),(r-=n.size)&&this.size++):(this.index[r]=n=new Map([[e,t]]),this.h.push(n),this.size++)};function ee(e=8){if(!this||this.constructor!==ee)return new ee(e);this.index=N(),this.h=[],this.size=0,e>32?(this.B=$o,this.A=BigInt(e)):(this.B=zo,this.A=e)}ee.prototype.add=function(e){var t=this.B(e);let r=this.index[t];r?(t=r.size,r.add(e),(t-=r.size)&&this.size++):(this.index[t]=r=new Set([e]),this.h.push(r),this.size++)};A=Q.prototype;A.has=ee.prototype.has=function(e){const t=this.index[this.B(e)];return t&&t.has(e)};A.delete=ee.prototype.delete=function(e){const t=this.index[this.B(e)];t&&t.delete(e)&&this.size--};A.clear=ee.prototype.clear=function(){this.index=N(),this.h=[],this.size=0};A.values=ee.prototype.values=function*(){for(let e=0;e<this.h.length;e++)for(let t of this.h[e].values())yield t};A.keys=ee.prototype.keys=function*(){for(let e=0;e<this.h.length;e++)for(let t of this.h[e].keys())yield t};A.entries=ee.prototype.entries=function*(){for(let e=0;e<this.h.length;e++)for(let t of this.h[e].entries())yield t};function zo(e){let t=2**this.A-1;if(typeof e=="number")return e&t;let r=0,n=this.A+1;for(let s=0;s<e.length;s++)r=(r*n^e.charCodeAt(s))&t;return this.A===32?r+2**31:r}function $o(e){let t=BigInt(2)**this.A-BigInt(1);var r=typeof e;if(r==="bigint")return e&t;if(r==="number")return BigInt(e)&t;r=BigInt(0);let n=this.A+BigInt(1);for(let s=0;s<e.length;s++)r=(r*n^BigInt(e.charCodeAt(s)))&t;return r}let Ce,qe;async function _l(e){e=e.data;var t=e.task;const r=e.id;let n=e.args;switch(t){case"init":qe=e.options||{},(t=e.factory)?(Function("return "+t)()(self),Ce=new self.FlexSearch.Index(qe),delete self.FlexSearch):Ce=new te(qe),postMessage({id:r});break;default:let s;t==="export"&&(n[1]?(n[0]=qe.export,n[2]=0,n[3]=1):n=null),t==="import"?n[0]&&(e=await qe.import.call(Ce,n[0]),Ce.import(n[0],e)):((s=n&&Ce[t].apply(Ce,n))&&s.then&&(s=await s),s&&s.await&&(s=await s.await),t==="search"&&s.result&&(s=s.result)),postMessage(t==="search"?{id:r,msg:s}:{id:r})}}function In(e){Ie.call(e,"add"),Ie.call(e,"append"),Ie.call(e,"search"),Ie.call(e,"update"),Ie.call(e,"remove"),Ie.call(e,"searchCache")}let Yr,ls,Ot;function Kl(){Yr=Ot=0}function Ie(e){this[e+"Async"]=function(){const t=arguments;var r=t[t.length-1];let n;if(typeof r=="function"&&(n=r,delete t[t.length-1]),Yr?Ot||(Ot=Date.now()-ls>=this.priority*this.priority*3):(Yr=setTimeout(Kl,0),ls=Date.now()),Ot){const o=this;return new Promise(i=>{setTimeout(function(){i(o[e+"Async"].apply(o,t))},0)})}const s=this[e].apply(this,t);return r=s.then?s:new Promise(o=>o(s)),n&&r.then(n),r}}let de=0;function Fe(e={},t){function r(c){function a(l){l=l.data||l;const u=l.id,h=u&&o.h[u];h&&(h(l.msg),delete o.h[u])}if(this.worker=c,this.h=N(),this.worker)return s?this.worker.on("message",a):this.worker.onmessage=a,e.config?new Promise(function(l){de>1e9&&(de=0),o.h[++de]=function(){l(o)},o.worker.postMessage({id:de,task:"init",factory:n,options:e})}):(this.priority=e.priority||4,this.encoder=t||null,this.worker.postMessage({task:"init",factory:n,options:e}),this)}if(!this||this.constructor!==Fe)return new Fe(e);let n=typeof self<"u"?self._factory:typeof window<"u"?window._factory:null;n&&(n=n.toString());const s=typeof window>"u",o=this,i=Ol(n,s,e.worker);return i.then?i.then(function(c){return r.call(o,c)}):r.call(this,i)}ye("add");ye("append");ye("search");ye("update");ye("remove");ye("clear");ye("export");ye("import");Fe.prototype.searchCache=Cn;In(Fe.prototype);function ye(e){Fe.prototype[e]=function(){const t=this,r=[].slice.call(arguments);var n=r[r.length-1];let s;return typeof n=="function"&&(s=n,r.pop()),n=new Promise(function(o){e==="export"&&typeof r[0]=="function"&&(r[0]=null),de>1e9&&(de=0),t.h[++de]=o,t.worker.postMessage({task:e,id:de,args:r})}),s?(n.then(s),this):n}}function Ol(e,t,r){return t?typeof module<"u"?new(require("worker_threads")).Worker(__dirname+"/worker/node.js"):Promise.resolve().then(()=>require("./__vite-browser-external-Dyvby5gX.js")).then(function(n){return new n.Worker("undefined/node/node.mjs")}):e?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+_l.toString()],{type:"text/javascript"}))):new window.Worker(typeof r=="string"?r:(typeof document>"u"?require("url").pathToFileURL(__filename).href:vr&&vr.tagName.toUpperCase()==="SCRIPT"&&vr.src||new URL("index.js",document.baseURI).href).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"})}Ne.prototype.add=function(e,t,r){if(st(e)&&(t=e,e=ot(t,this.key)),t&&(e||e===0)){if(!r&&this.reg.has(e))return this.update(e,t);for(let c=0,a;c<this.field.length;c++){a=this.B[c];var n=this.index.get(this.field[c]);if(typeof a=="function"){var s=a(t);s&&n.add(e,s,r,!0)}else s=a.G,(!s||s(t))&&(a.constructor===String?a=[""+a]:Z(a)&&(a=[a]),Jr(t,a,this.D,0,n,e,a[0],r))}if(this.tag)for(n=0;n<this.A.length;n++){var o=this.A[n];s=this.tag.get(this.F[n]);let c=N();if(typeof o=="function"){if(o=o(t),!o)continue}else{var i=o.G;if(i&&!i(t))continue;o.constructor===String&&(o=""+o),o=ot(t,o)}if(s&&o){Z(o)&&(o=[o]);for(let a=0,l,u;a<o.length;a++)if(l=o[a],!c[l]&&(c[l]=1,(i=s.get(l))?u=i:s.set(l,u=[]),!r||!u.includes(e))){if(u.length===2**31-1){if(i=new Be(u),this.fastupdate)for(let h of this.reg.values())h.includes(u)&&(h[h.indexOf(u)]=i);s.set(l,u=i)}u.push(e),this.fastupdate&&((i=this.reg.get(e))?i.push(u):this.reg.set(e,[u]))}}}if(this.store&&(!r||!this.store.has(e))){let c;if(this.h){c=N();for(let a=0,l;a<this.h.length;a++){if(l=this.h[a],(r=l.G)&&!r(t))continue;let u;if(typeof l=="function"){if(u=l(t),!u)continue;l=[l.O]}else if(Z(l)||l.constructor===String){c[l]=t[l];continue}Vr(t,c,l,0,l[0],u)}}this.store.set(e,c||t)}this.worker&&(this.fastupdate||this.reg.add(e))}return this};function Vr(e,t,r,n,s,o){if(e=e[s],n===r.length-1)t[s]=o||e;else if(e)if(e.constructor===Array)for(t=t[s]=Array(e.length),s=0;s<e.length;s++)Vr(e,t,r,n,s);else t=t[s]||(t[s]=N()),s=r[++n],Vr(e,t,r,n,s)}function Jr(e,t,r,n,s,o,i,c){if(e=e[i])if(n===t.length-1){if(e.constructor===Array){if(r[n]){for(t=0;t<e.length;t++)s.add(o,e[t],!0,!0);return}e=e.join(" ")}s.add(o,e,c,!0)}else if(e.constructor===Array)for(i=0;i<e.length;i++)Jr(e,t,r,n,s,o,i,c);else i=t[++n],Jr(e,t,r,n,s,o,i,c)}function Pn(e,t,r,n){if(!e.length)return e;if(e.length===1)return e=e[0],e=r||e.length>t?e.slice(r,r+t):e,n?Pe.call(this,e):e;let s=[];for(let o=0,i,c;o<e.length;o++)if((i=e[o])&&(c=i.length)){if(r){if(r>=c){r-=c;continue}i=i.slice(r,r+t),c=i.length,r=0}if(c>t&&(i=i.slice(0,t),c=t),!s.length&&c>=t)return n?Pe.call(this,i):i;if(s.push(i),t-=c,!t)break}return s=s.length>1?[].concat.apply([],s):s[0],n?Pe.call(this,s):s}function ur(e,t,r,n){var s=n[0];if(s[0]&&s[0].query)return e[t].apply(e,s);if(!(t!=="and"&&t!=="not"||e.result.length||e.await||s.suggest))return n.length>1&&(s=n[n.length-1]),(n=s.resolve)?e.await||e.result:e;let o=[],i=0,c=0,a,l,u,h,m;for(t=0;t<n.length;t++)if(s=n[t]){var y=void 0;if(s.constructor===P)y=s.await||s.result;else if(s.then||s.constructor===Array)y=s;else{i=s.limit||0,c=s.offset||0,u=s.suggest,l=s.resolve,a=((h=s.highlight||e.highlight)||s.enrich)&&l,y=s.queue;let p=s.async||y,f=s.index,d=s.query;if(f?e.index||(e.index=f):f=e.index,d||s.tag){const b=s.field||s.pluck;if(b&&(!d||e.query&&!h||(e.query=d,e.field=b,e.highlight=h),f=f.index.get(b)),y&&(m||e.await)){m=1;let w;const E=e.C.length,x=new Promise(function(k){w=k});(function(k,v){x.h=function(){v.index=null,v.resolve=!1;let S=p?k.searchAsync(v):k.search(v);return S.then?S.then(function(T){return e.C[E]=T=T.result||T,w(T),T}):(S=S.result||S,w(S),S)}})(f,Object.assign({},s)),e.C.push(x),o[t]=x;continue}else s.resolve=!1,s.index=null,y=p?f.searchAsync(s):f.search(s),s.resolve=l,s.index=f}else if(s.and)y=vt(s,"and",f);else if(s.or)y=vt(s,"or",f);else if(s.not)y=vt(s,"not",f);else if(s.xor)y=vt(s,"xor",f);else continue}y.await?(m=1,y=y.await):y.then?(m=1,y=y.then(function(p){return p.result||p})):y=y.result||y,o[t]=y}if(m&&!e.await&&(e.await=new Promise(function(p){e.return=p})),m){const p=Promise.all(o).then(function(f){for(let d=0;d<e.C.length;d++)if(e.C[d]===p){e.C[d]=function(){return r.call(e,f,i,c,a,l,u,h)};break}jn(e)});e.C.push(p)}else if(e.await)e.C.push(function(){return r.call(e,o,i,c,a,l,u,h)});else return r.call(e,o,i,c,a,l,u,h);return l?e.await||e.result:e}function vt(e,t,r){e=e[t];const n=e[0]||e;return n.index||(n.index=r),r=new P(n),e.length>1&&(r=r[t].apply(r,e.slice(1))),r}P.prototype.or=function(){return ur(this,"or",Rl,arguments)};function Rl(e,t,r,n,s,o,i){return e.length&&(this.result.length&&e.push(this.result),e.length<2?this.result=e[0]:(this.result=Yo(e,t,r,!1,this.h),r=0)),s&&(this.await=null),s?this.resolve(t,r,n,i):this}P.prototype.and=function(){return ur(this,"and",Cl,arguments)};function Cl(e,t,r,n,s,o,i){if(!o&&!this.result.length)return s?this.result:this;let c;if(e.length)if(this.result.length&&e.unshift(this.result),e.length<2)this.result=e[0];else{let a=0;for(let l=0,u,h;l<e.length;l++)if((u=e[l])&&(h=u.length))a<h&&(a=h);else if(!o){a=0;break}a?(this.result=Ht(e,a,t,r,o,this.h,s),c=!0):this.result=[]}else o||(this.result=e);return s&&(this.await=null),s?this.resolve(t,r,n,i,c):this}P.prototype.xor=function(){return ur(this,"xor",Il,arguments)};function Il(e,t,r,n,s,o,i){if(e.length)if(this.result.length&&e.unshift(this.result),e.length<2)this.result=e[0];else{e:{o=r;var c=this.h;const a=[],l=N();let u=0;for(let h=0,m;h<e.length;h++)if(m=e[h]){u<m.length&&(u=m.length);for(let y=0,p;y<m.length;y++)if(p=m[y])for(let f=0,d;f<p.length;f++)d=p[f],l[d]=l[d]?2:1}for(let h=0,m,y=0;h<u;h++)for(let p=0,f;p<e.length;p++)if((f=e[p])&&(m=f[h])){for(let d=0,b;d<m.length;d++)if(b=m[d],l[b]===1)if(o)o--;else if(s){if(a.push(b),a.length===t){e=a;break e}}else{const w=h+(p?c:0);if(a[w]||(a[w]=[]),a[w].push(b),++y===t){e=a;break e}}}e=a}this.result=e,c=!0}else o||(this.result=e);return s&&(this.await=null),s?this.resolve(t,r,n,i,c):this}P.prototype.not=function(){return ur(this,"not",Pl,arguments)};function Pl(e,t,r,n,s,o,i){if(!o&&!this.result.length)return s?this.result:this;if(e.length&&this.result.length){e:{o=r;var c=[];e=new Set(e.flat().flat());for(let a=0,l,u=0;a<this.result.length;a++)if(l=this.result[a]){for(let h=0,m;h<l.length;h++)if(m=l[h],!e.has(m)){if(o)o--;else if(s){if(c.push(m),c.length===t){e=c;break e}}else if(c[a]||(c[a]=[]),c[a].push(m),++u===t){e=c;break e}}}e=c}this.result=e,c=!0}return s&&(this.await=null),s?this.resolve(t,r,n,i,c):this}function Rt(e,t,r,n,s){let o,i,c;typeof s=="string"?(o=s,s=""):o=s.template,i=o.indexOf("$1"),c=o.substring(i+2),i=o.substring(0,i);let a=s&&s.boundary,l=!s||s.clip!==!1,u=s&&s.merge&&c&&i&&new RegExp(c+" "+i,"g");s=s&&s.ellipsis;var h=0;if(typeof s=="object"){var m=s.template;h=m.length-2,s=s.pattern}typeof s!="string"&&(s=s===!1?"":"..."),h&&(s=m.replace("$1",s)),m=s.length-h;let y,p;typeof a=="object"&&(y=a.before,y===0&&(y=-1),p=a.after,p===0&&(p=-1),a=a.total||9e5),h=new Map;for(let xr=0,ge,zn,Ye;xr<t.length;xr++){let Ve;if(n)Ve=t,Ye=n;else{var f=t[xr];if(Ye=f.field,!Ye)continue;Ve=f.result}zn=r.get(Ye),ge=zn.encoder,f=h.get(ge),typeof f!="string"&&(f=ge.encode(e),h.set(ge,f));for(let gt=0;gt<Ve.length;gt++){var d=Ve[gt].doc;if(!d||(d=ot(d,Ye),!d))continue;var b=d.trim().split(/\s+/);if(!b.length)continue;d="";var w=[];let wt=[];for(var E=-1,x=-1,k=0,v=0;v<b.length;v++){var S=b[v],T=ge.encode(S);T=T.length>1?T.join(" "):T[0];let K;if(T&&S){for(var _=S.length,C=(ge.split?S.replace(ge.split,""):S).length-T.length,O="",j=0,L=0;L<f.length;L++){var M=f[L];if(M){var B=M.length;B+=C<0?0:C,j&&B<=j||(M=T.indexOf(M),M>-1&&(O=(M?S.substring(0,M):"")+i+S.substring(M,M+B)+c+(M+B<_?S.substring(M+B):""),j=B,K=!0))}}O&&(a&&(E<0&&(E=d.length+(d?1:0)),x=d.length+(d?1:0)+O.length,k+=_,wt.push(w.length),w.push({match:O})),d+=(d?" ":"")+O)}if(!K)S=b[v],d+=(d?" ":"")+S,a&&w.push({text:S});else if(a&&k>=a)break}if(k=wt.length*(o.length-2),y||p||a&&d.length-k>a)if(k=a+k-m*2,v=x-E,y>0&&(v+=y),p>0&&(v+=p),v<=k)b=y?E-(y>0?y:0):E-((k-v)/2|0),w=p?x+(p>0?p:0):b+k,l||(b>0&&d.charAt(b)!==" "&&d.charAt(b-1)!==" "&&(b=d.indexOf(" ",b),b<0&&(b=0)),w<d.length&&d.charAt(w-1)!==" "&&d.charAt(w)!==" "&&(w=d.lastIndexOf(" ",w),w<x?w=x:++w)),d=(b?s:"")+d.substring(b,w)+(w<d.length?s:"");else{for(x=[],E={},k={},v={},S={},T={},O=C=_=0,L=j=1;;){var ne=void 0;for(let K=0,F;K<wt.length;K++){if(F=wt[K],O)if(C!==O){if(v[K+1])continue;if(F+=O,E[F]){_-=m,k[K+1]=1,v[K+1]=1;continue}if(F>=w.length-1){if(F>=w.length){v[K+1]=1,F>=b.length&&(k[K+1]=1);continue}_-=m}if(d=w[F].text,B=p&&T[K])if(B>0){if(d.length>B)if(v[K+1]=1,l)d=d.substring(0,B);else continue;(B-=d.length)||(B=-1),T[K]=B}else{v[K+1]=1;continue}if(_+d.length+1<=a)d=" "+d,x[K]+=d;else if(l)ne=a-_-1,ne>0&&(d=" "+d.substring(0,ne),x[K]+=d),v[K+1]=1;else{v[K+1]=1;continue}}else{if(v[K])continue;if(F-=C,E[F]){_-=m,v[K]=1,k[K]=1;continue}if(F<=0){if(F<0){v[K]=1,k[K]=1;continue}_-=m}if(d=w[F].text,B=y&&S[K])if(B>0){if(d.length>B)if(v[K]=1,l)d=d.substring(d.length-B);else continue;(B-=d.length)||(B=-1),S[K]=B}else{v[K]=1;continue}if(_+d.length+1<=a)d+=" ",x[K]=d+x[K];else if(l)ne=d.length+1-(a-_),ne>=0&&ne<d.length&&(d=d.substring(ne)+" ",x[K]=d+x[K]),v[K]=1;else{v[K]=1;continue}}else{d=w[F].match,y&&(S[K]=y),p&&(T[K]=p),K&&_++;let kr;if(F?!K&&m&&(_+=m):(k[K]=1,v[K]=1),F>=b.length-1||F<w.length-1&&w[F+1].match?kr=1:m&&(_+=m),_-=o.length-2,!K||_+d.length<=a)x[K]=d;else{ne=j=L=k[K]=0;break}kr&&(k[K+1]=1,v[K+1]=1)}_+=d.length,ne=E[F]=1}if(ne)C===O?O++:C++;else{if(C===O?j=0:L=0,!j&&!L)break;j?(C++,O=C):O++}}d="";for(let K=0,F;K<x.length;K++)F=(k[K]?K?" ":"":(K&&!s?" ":"")+s)+x[K],d+=F;s&&!k[x.length]&&(d+=s)}u&&(d=d.replace(u," ")),Ve[gt].highlight=d}if(n)break}return t}function P(e,t){if(!this||this.constructor!==P)return new P(e,t);let r=0,n,s,o,i,c,a;if(e&&e.index){const l=e;if(t=l.index,r=l.boost||0,s=l.query){o=l.field||l.pluck,i=l.highlight;const u=l.resolve;e=l.async||l.queue,l.resolve=!1,l.index=null,e=e?t.searchAsync(l):t.search(l),l.resolve=u,l.index=t,e=e.result||e}else e=[]}if(e&&e.then){const l=this;e=e.then(function(u){l.C[0]=l.result=u.result||u,jn(l)}),n=[e],e=[],c=new Promise(function(u){a=u})}this.index=t||null,this.result=e||[],this.h=r,this.C=n||[],this.await=c||null,this.return=a||null,this.highlight=i||null,this.query=s||"",this.field=o||""}A=P.prototype;A.limit=function(e){if(this.await){const t=this;this.C.push(function(){return t.limit(e).result})}else if(this.result.length){const t=[];for(let r=0,n;r<this.result.length;r++)if(n=this.result[r])if(n.length<=e){if(t[r]=n,e-=n.length,!e)break}else{t[r]=n.slice(0,e);break}this.result=t}return this};A.offset=function(e){if(this.await){const t=this;this.C.push(function(){return t.offset(e).result})}else if(this.result.length){const t=[];for(let r=0,n;r<this.result.length;r++)(n=this.result[r])&&(n.length<=e?e-=n.length:(t[r]=n.slice(e),e=0));this.result=t}return this};A.boost=function(e){if(this.await){const t=this;this.C.push(function(){return t.boost(e).result})}else this.h+=e;return this};function jn(e,t){let r=e.result;var n=e.await;e.await=null;for(let s=0,o;s<e.C.length;s++)if(o=e.C[s]){if(typeof o=="function")r=o(),e.C[s]=r=r.result||r,s--;else if(o.h)r=o.h(),e.C[s]=r=r.result||r,s--;else if(o.then)return e.await=n}return n=e.return,e.C=[],e.return=null,t||n(r),r}A.resolve=function(e,t,r,n,s){let o=this.await?jn(this,!0):this.result;if(o.then){const i=this;return o.then(function(){return i.resolve(e,t,r,n,s)})}return o.length&&(typeof e=="object"?(n=e.highlight||this.highlight,r=!!n||e.enrich,t=e.offset,e=e.limit):(n=n||this.highlight,r=!!n||r),o=s?r?Pe.call(this.index,o):o:Pn.call(this.index,o,e||100,t,r)),this.finalize(o,n)};A.finalize=function(e,t){if(e.then){const n=this;return e.then(function(s){return n.finalize(s,t)})}t&&e.length&&this.query&&(e=Rt(this.query,e,this.index.index,this.field,t));const r=this.return;return this.highlight=this.index=this.result=this.C=this.await=this.return=null,this.query=this.field="",r&&r(e),e};function Ht(e,t,r,n,s,o,i){const c=e.length;let a=[],l,u;l=N();for(let h=0,m,y,p,f;h<t;h++)for(let d=0;d<c;d++)if(p=e[d],h<p.length&&(m=p[h]))for(let b=0;b<m.length;b++){if(y=m[b],(u=l[y])?l[y]++:(u=0,l[y]=1),f=a[u]||(a[u]=[]),!i){let w=h+(d||!s?0:o||0);f=f[w]||(f[w]=[])}if(f.push(y),i&&r&&u===c-1&&f.length-n===r)return n?f.slice(n):f}if(e=a.length)if(s)a=a.length>1?Yo(a,r,n,i,o):(a=a[0])&&r&&a.length>r||n?a.slice(n,r+n):a;else{if(e<c)return[];if(a=a[e-1],r||n)if(i)(a.length>r||n)&&(a=a.slice(n,r+n));else{s=[];for(let h=0,m;h<a.length;h++)if(m=a[h]){if(n&&m.length>n)n-=m.length;else if((r&&m.length>r||n)&&(m=m.slice(n,r+n),r-=m.length,n&&(n-=m.length)),s.push(m),!r)break}a=s}}return a}function Yo(e,t,r,n,s){const o=[],i=N();let c;var a=e.length;let l;if(n){for(s=a-1;s>=0;s--)if(l=(n=e[s])&&n.length){for(a=0;a<l;a++)if(c=n[a],!i[c]){if(i[c]=1,r)r--;else if(o.push(c),o.length===t)return o}}}else for(let u=a-1,h,m=0;u>=0;u--){h=e[u];for(let y=0;y<h.length;y++)if(l=(n=h[y])&&n.length){for(let p=0;p<l;p++)if(c=n[p],!i[c])if(i[c]=1,r)r--;else{let f=(y+(u<a-1&&s||0))/(u+1)|0;if((o[f]||(o[f]=[])).push(c),++m===t)return o}}}return o}function jl(e,t,r,n,s){const o=N(),i=[];for(let c=0,a;c<t.length;c++){a=t[c];for(let l=0;l<a.length;l++)o[a[l]]=1}if(s){for(let c=0,a;c<e.length;c++)if(a=e[c],o[a]){if(n)n--;else if(i.push(a),o[a]=0,r&&--r===0)break}}else for(let c=0,a,l;c<e.result.length;c++)for(a=e.result[c],t=0;t<a.length;t++)l=a[t],o[l]&&((i[c]||(i[c]=[])).push(l),o[l]=0);return i}Ne.prototype.search=function(e,t,r,n){r||(!t&&st(e)?(r=e,e=""):st(t)&&(r=t,t=0));let s=[];var o=[];let i,c,a,l,u,h,m=0,y=!0,p;if(r){r.constructor===Array&&(r={index:r}),e=r.query||e,i=r.pluck,c=r.merge,l=r.boost,h=i||r.field||(h=r.index)&&(h.index?null:h);var f=this.tag&&r.tag;a=r.suggest,y=r.resolve!==!1,u=r.cache,p=y&&this.store&&r.highlight;var d=!!p||y&&this.store&&r.enrich;t=r.limit||t;var b=r.offset||0;if(t||(t=y?100:0),f&&(!this.db||!n)){f.constructor!==Array&&(f=[f]);var w=[];for(let S=0,T;S<f.length;S++)if(T=f[S],T.field&&T.tag){var E=T.tag;if(E.constructor===Array)for(var x=0;x<E.length;x++)w.push(T.field,E[x]);else w.push(T.field,E)}else{E=Object.keys(T);for(let _=0,C,O;_<E.length;_++)if(C=E[_],O=T[C],O.constructor===Array)for(x=0;x<O.length;x++)w.push(C,O[x]);else w.push(C,O)}if(f=w,!e){if(o=[],w.length)for(f=0;f<w.length;f+=2){if(this.db){if(n=this.index.get(w[f]),!n)continue;o.push(n=n.db.tag(w[f+1],t,b,d))}else n=Bl.call(this,w[f],w[f+1],t,b,d);s.push(y?{field:w[f],tag:w[f+1],result:n}:[n])}if(o.length){const S=this;return Promise.all(o).then(function(T){for(let _=0;_<T.length;_++)y?s[_].result=T[_]:s[_]=T[_];return y?s:new P(s.length>1?Ht(s,1,0,0,a,l):s[0],S)})}return y?s:new P(s.length>1?Ht(s,1,0,0,a,l):s[0],this)}}y||i||!(h=h||this.field)||(Z(h)?i=h:(h.constructor===Array&&h.length===1&&(h=h[0]),i=h.field||h.index)),h&&h.constructor!==Array&&(h=[h])}h||(h=this.field);let k;w=(this.worker||this.db)&&!n&&[];for(let S=0,T,_,C;S<h.length;S++){if(_=h[S],this.db&&this.tag&&!this.B[S])continue;let O;if(Z(_)||(O=_,_=O.field,e=O.query||e,t=Re(O.limit,t),b=Re(O.offset,b),a=Re(O.suggest,a),p=y&&this.store&&Re(O.highlight,p),d=!!p||y&&this.store&&Re(O.enrich,d),u=Re(O.cache,u)),n)T=n[S];else{E=O||r||{},x=E.enrich;var v=this.index.get(_);if(f&&(this.db&&(E.tag=f,E.field=h,k=v.db.support_tag_search),!k&&x&&(E.enrich=!1),k||(E.limit=0,E.offset=0)),T=u?v.searchCache(e,f&&!k?0:t,E):v.search(e,f&&!k?0:t,E),f&&!k&&(E.limit=t,E.offset=b),x&&(E.enrich=x),w){w[S]=T;continue}}if(C=(T=T.result||T)&&T.length,f&&C){if(E=[],x=0,this.db&&n){if(!k)for(v=h.length;v<n.length;v++){let j=n[v];if(j&&j.length)x++,E.push(j);else if(!a)return y?s:new P(s,this)}}else for(let j=0,L,M;j<f.length;j+=2){if(L=this.tag.get(f[j]),!L){if(a)continue;return y?s:new P(s,this)}if(M=(L=L&&L.get(f[j+1]))&&L.length)x++,E.push(L);else if(!a)return y?s:new P(s,this)}if(x){if(T=jl(T,E,t,b,y),C=T.length,!C&&!a)return y?T:new P(T,this);x--}}if(C)o[m]=_,s.push(T),m++;else if(h.length===1)return y?s:new P(s,this)}if(w){if(this.db&&f&&f.length&&!k)for(d=0;d<f.length;d+=2){if(o=this.index.get(f[d]),!o){if(a)continue;return y?s:new P(s,this)}w.push(o.db.tag(f[d+1],t,b,!1))}const S=this;return Promise.all(w).then(function(T){return r&&(r.resolve=y),T.length&&(T=S.search(e,t,r,T)),T})}if(!m)return y?s:new P(s,this);if(i&&(!d||!this.store))return s=s[0],y?s:new P(s,this);for(w=[],b=0;b<o.length;b++){if(f=s[b],d&&f.length&&typeof f[0].doc>"u"&&(this.db?w.push(f=this.index.get(this.field[0]).db.enrich(f)):f=Pe.call(this,f)),i)return y?p?Rt(e,f,this.index,i,p):f:new P(f,this);s[b]={field:o[b],result:f}}if(d&&this.db&&w.length){const S=this;return Promise.all(w).then(function(T){for(let _=0;_<T.length;_++)s[_].result=T[_];return p&&(s=Rt(e,s,S.index,i,p)),c?us(s):s})}return p&&(s=Rt(e,s,this.index,i,p)),c?us(s):s};function us(e){const t=[],r=N(),n=N();for(let s=0,o,i,c,a,l,u,h;s<e.length;s++){o=e[s],i=o.field,c=o.result;for(let m=0;m<c.length;m++)l=c[m],typeof l!="object"?l={id:a=l}:a=l.id,(u=r[a])?u.push(i):(l.field=r[a]=[i],t.push(l)),(h=l.highlight)&&(u=n[a],u||(n[a]=u={},l.highlight=u),u[i]=h)}return t}function Bl(e,t,r,n,s){return e=this.tag.get(e),e?(e=e.get(t),e?(t=e.length-n,t>0&&((r&&t>r||n)&&(e=e.slice(n,n+r)),s&&(e=Pe.call(this,e))),e):[]):[]}function Pe(e){if(!this||!this.store)return e;if(this.db)return this.index.get(this.field[0]).db.enrich(e);const t=Array(e.length);for(let r=0,n;r<e.length;r++)n=e[r],t[r]={id:n,doc:this.store.get(n)};return t}function Ne(e){if(!this||this.constructor!==Ne)return new Ne(e);const t=e.document||e.doc||e;let r,n;if(this.B=[],this.field=[],this.D=[],this.key=(r=t.key||t.id)&&zt(r,this.D)||"id",(n=e.keystore||0)&&(this.keystore=n),this.fastupdate=!!e.fastupdate,this.reg=!this.fastupdate||e.worker||e.db?n?new ee(n):new Set:n?new Q(n):new Map,this.h=(r=t.store||null)&&r&&r!==!0&&[],this.store=r?n?new Q(n):new Map:null,this.cache=(r=e.cache||null)&&new Ke(r),e.cache=!1,this.worker=e.worker||!1,this.priority=e.priority||4,this.index=Fl.call(this,e,t),this.tag=null,(r=t.tag)&&(typeof r=="string"&&(r=[r]),r.length)){this.tag=new Map,this.A=[],this.F=[];for(let s=0,o,i;s<r.length;s++){if(o=r[s],i=o.field||o,!i)throw Error("The tag field from the document descriptor is undefined.");o.custom?this.A[s]=o.custom:(this.A[s]=zt(i,this.D),o.filter&&(typeof this.A[s]=="string"&&(this.A[s]=new String(this.A[s])),this.A[s].G=o.filter)),this.F[s]=i,this.tag.set(i,new Map)}}if(this.worker){this.fastupdate=!1,e=[];for(const s of this.index.values())s.then&&e.push(s);if(e.length){const s=this;return Promise.all(e).then(function(o){let i=0;for(const c of s.index.entries()){const a=c[0];let l=c[1];l.then&&(l=o[i],s.index.set(a,l),i++)}return s})}}else e.db&&(this.fastupdate=!1,this.mount(e.db))}A=Ne.prototype;A.mount=function(e){let t=this.field;if(this.tag)for(let o=0,i;o<this.F.length;o++){i=this.F[o];var r=void 0;this.index.set(i,r=new te({},this.reg)),t===this.field&&(t=t.slice(0)),t.push(i),r.tag=this.tag.get(i)}r=[];const n={db:e.db,type:e.type,fastupdate:e.fastupdate};for(let o=0,i,c;o<t.length;o++){n.field=c=t[o],i=this.index.get(c);const a=new e.constructor(e.id,n);a.id=e.id,r[o]=a.mount(i),i.document=!0,o?i.bypass=!0:i.store=this.store}const s=this;return this.db=Promise.all(r).then(function(){s.db=!0})};A.commit=async function(){const e=[];for(const t of this.index.values())e.push(t.commit());await Promise.all(e),this.reg.clear()};A.destroy=function(){const e=[];for(const t of this.index.values())e.push(t.destroy());return Promise.all(e)};function Fl(e,t){const r=new Map;let n=t.index||t.field||t;Z(n)&&(n=[n]);for(let o=0,i,c;o<n.length;o++){if(i=n[o],Z(i)||(c=i,i=i.field),c=st(c)?Object.assign({},e,c):e,this.worker){var s=void 0;s=(s=c.encoder)&&s.encode?s:new it(typeof s=="string"?Ho[s]:s||{}),s=new Fe(c,s),r.set(i,s)}this.worker||r.set(i,new te(c,this.reg)),c.custom?this.B[o]=c.custom:(this.B[o]=zt(i,this.D),c.filter&&(typeof this.B[o]=="string"&&(this.B[o]=new String(this.B[o])),this.B[o].G=c.filter)),this.field[o]=i}if(this.h){e=t.store,Z(e)&&(e=[e]);for(let o=0,i,c;o<e.length;o++)i=e[o],c=i.field||i,i.custom?(this.h[o]=i.custom,i.custom.O=c):(this.h[o]=zt(c,this.D),i.filter&&(typeof this.h[o]=="string"&&(this.h[o]=new String(this.h[o])),this.h[o].G=i.filter))}return r}function zt(e,t){const r=e.split(":");let n=0;for(let s=0;s<r.length;s++)e=r[s],e[e.length-1]==="]"&&(e=e.substring(0,e.length-2))&&(t[n]=!0),e&&(r[n++]=e);return n<r.length&&(r.length=n),n>1?r:r[0]}A.append=function(e,t){return this.add(e,t,!0)};A.update=function(e,t){return this.remove(e).add(e,t)};A.remove=function(e){st(e)&&(e=ot(e,this.key));for(var t of this.index.values())t.remove(e,!0);if(this.reg.has(e)){if(this.tag&&!this.fastupdate)for(let r of this.tag.values())for(let n of r){t=n[0];const s=n[1],o=s.indexOf(e);o>-1&&(s.length>1?s.splice(o,1):r.delete(t))}this.store&&this.store.delete(e),this.reg.delete(e)}return this.cache&&this.cache.remove(e),this};A.clear=function(){const e=[];for(const t of this.index.values()){const r=t.clear();r.then&&e.push(r)}if(this.tag)for(const t of this.tag.values())t.clear();return this.store&&this.store.clear(),this.cache&&this.cache.clear(),e.length?Promise.all(e):this};A.contain=function(e){return this.db?this.index.get(this.field[0]).db.has(e):this.reg.has(e)};A.cleanup=function(){for(const e of this.index.values())e.cleanup();return this};A.get=function(e){return this.db?this.index.get(this.field[0]).db.enrich(e).then(function(t){return t[0]&&t[0].doc||null}):this.store.get(e)||null};A.set=function(e,t){return typeof e=="object"&&(t=e,e=ot(t,this.key)),this.store.set(e,t),this};A.searchCache=Cn;A.export=Nl;A.import=Ll;In(Ne.prototype);function Bn(e,t=0){let r=[],n=[];t&&(t=25e4/t*5e3|0);for(const s of e.entries())n.push(s),n.length===t&&(r.push(n),n=[]);return n.length&&r.push(n),r}function Fn(e,t){t||(t=new Map);for(let r=0,n;r<e.length;r++)n=e[r],t.set(n[0],n[1]);return t}function Vo(e,t=0){let r=[],n=[];t&&(t=25e4/t*1e3|0);for(const s of e.entries())n.push([s[0],Bn(s[1])[0]||[]]),n.length===t&&(r.push(n),n=[]);return n.length&&r.push(n),r}function Jo(e,t){t||(t=new Map);for(let r=0,n,s;r<e.length;r++)n=e[r],s=t.get(n[0]),t.set(n[0],Fn(n[1],s));return t}function Go(e){let t=[],r=[];for(const n of e.keys())r.push(n),r.length===25e4&&(t.push(r),r=[]);return r.length&&t.push(r),t}function Xo(e,t){t||(t=new Set);for(let r=0;r<e.length;r++)t.add(e[r]);return t}function $t(e,t,r,n,s,o,i=0){const c=n&&n.constructor===Array;var a=c?n.shift():n;if(!a)return this.export(e,t,s,o+1);if((a=e((t?t+".":"")+(i+1)+"."+r,JSON.stringify(a)))&&a.then){const l=this;return a.then(function(){return $t.call(l,e,t,r,c?n:null,s,o,i+1)})}return $t.call(this,e,t,r,c?n:null,s,o,i+1)}function Nl(e,t,r=0,n=0){if(r<this.field.length){const i=this.field[r];if((t=this.index.get(i).export(e,i,r,n=1))&&t.then){const c=this;return t.then(function(){return c.export(e,i,r+1)})}return this.export(e,i,r+1)}let s,o;switch(n){case 0:s="reg",o=Go(this.reg),t=null;break;case 1:s="tag",o=this.tag&&Vo(this.tag,this.reg.size),t=null;break;case 2:s="doc",o=this.store&&Bn(this.store),t=null;break;default:return}return $t.call(this,e,t,s,o||null,r,n)}function Ll(e,t){var r=e.split(".");r[r.length-1]==="json"&&r.pop();const n=r.length>2?r[0]:"";if(r=r.length>2?r[2]:r[1],this.worker&&n)return this.index.get(n).import(e);if(t){if(typeof t=="string"&&(t=JSON.parse(t)),n)return this.index.get(n).import(r,t);switch(r){case"reg":this.fastupdate=!1,this.reg=Xo(t,this.reg);for(let s=0,o;s<this.field.length;s++)o=this.index.get(this.field[s]),o.fastupdate=!1,o.reg=this.reg;if(this.worker){t=[];for(const s of this.index.values())t.push(s.import(e));return Promise.all(t)}break;case"tag":this.tag=Jo(t,this.tag);break;case"doc":this.store=Fn(t,this.store)}}}function hs(e,t){let r="";for(const n of e.entries()){e=n[0];const s=n[1];let o="";for(let i=0,c;i<s.length;i++){c=s[i]||[""];let a="";for(let l=0;l<c.length;l++)a+=(a?",":"")+(t==="string"?'"'+c[l]+'"':c[l]);a="["+a+"]",o+=(o?",":"")+a}o='["'+e+'",['+o+"]]",r+=(r?",":"")+o}return r}te.prototype.remove=function(e,t){const r=this.reg.size&&(this.fastupdate?this.reg.get(e):this.reg.has(e));if(r){if(this.fastupdate){for(let n=0,s,o;n<r.length;n++)if((s=r[n])&&(o=s.length))if(s[o-1]===e)s.pop();else{const i=s.indexOf(e);i>=0&&s.splice(i,1)}}else ct(this.map,e),this.depth&&ct(this.ctx,e);t||this.reg.delete(e)}return this.db&&(this.commit_task.push({del:e}),this.M&&qo(this)),this.cache&&this.cache.remove(e),this};function ct(e,t){let r=0;var n=typeof t>"u";if(e.constructor===Array){for(let s=0,o,i,c;s<e.length;s++)if((o=e[s])&&o.length){if(n)return 1;if(i=o.indexOf(t),i>=0){if(o.length>1)return o.splice(i,1),1;if(delete e[s],r)return 1;c=1}else{if(c)return 1;r++}}}else for(let s of e.entries())n=s[0],ct(s[1],t)?r++:e.delete(n);return r}const Dl={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};te.prototype.add=function(e,t,r,n){if(t&&(e||e===0)){if(!n&&!r&&this.reg.has(e))return this.update(e,t);n=this.depth,t=this.encoder.encode(t,!n);const l=t.length;if(l){const u=N(),h=N(),m=this.resolution;for(let y=0;y<l;y++){let p=t[this.rtl?l-1-y:y];var s=p.length;if(s&&(n||!h[p])){var o=this.score?this.score(t,p,y,null,0):St(m,l,y),i="";switch(this.tokenize){case"tolerant":if(ae(this,h,p,o,e,r),s>2){for(let f=1,d,b,w,E;f<s-1;f++)d=p.charAt(f),b=p.charAt(f+1),w=p.substring(0,f)+b,E=p.substring(f+2),i=w+d+E,ae(this,h,i,o,e,r),i=w+E,ae(this,h,i,o,e,r);ae(this,h,p.substring(0,p.length-1),o,e,r)}break;case"full":if(s>2){for(let f=0,d;f<s;f++)for(o=s;o>f;o--){i=p.substring(f,o),d=this.rtl?s-1-f:f;var c=this.score?this.score(t,p,y,i,d):St(m,l,y,s,d);ae(this,h,i,c,e,r)}break}case"bidirectional":case"reverse":if(s>1){for(c=s-1;c>0;c--){i=p[this.rtl?s-1-c:c]+i;var a=this.score?this.score(t,p,y,i,c):St(m,l,y,s,c);ae(this,h,i,a,e,r)}i=""}case"forward":if(s>1){for(c=0;c<s;c++)i+=p[this.rtl?s-1-c:c],ae(this,h,i,o,e,r);break}default:if(ae(this,h,p,o,e,r),n&&l>1&&y<l-1)for(s=this.N,i=p,o=Math.min(n+1,this.rtl?y+1:l-y),c=1;c<o;c++){p=t[this.rtl?l-1-y-c:y+c],a=this.bidirectional&&p>i;const f=this.score?this.score(t,i,y,p,c-1):St(s+(l/2>s?0:1),l,y,o-1,c-1);ae(this,u,a?i:p,f,e,r,a?p:i)}}}}this.fastupdate||this.reg.add(e)}}return this.db&&(this.commit_task.push(r?{ins:e}:{del:e}),this.M&&qo(this)),this};function ae(e,t,r,n,s,o,i){let c,a;if(!(c=t[r])||i&&!c[i]){if(i?(t=c||(t[r]=N()),t[i]=1,a=e.ctx,(c=a.get(i))?a=c:a.set(i,a=e.keystore?new Q(e.keystore):new Map)):(a=e.map,t[r]=1),(c=a.get(r))?a=c:a.set(r,a=c=[]),o){for(let l=0,u;l<c.length;l++)if((u=c[l])&&u.includes(s)){if(l<=n)return;u.splice(u.indexOf(s),1),e.fastupdate&&(t=e.reg.get(s))&&t.splice(t.indexOf(u),1);break}}if(a=a[n]||(a[n]=[]),a.push(s),a.length===2**31-1){if(t=new Be(a),e.fastupdate)for(let l of e.reg.values())l.includes(a)&&(l[l.indexOf(a)]=t);c[n]=a=t}e.fastupdate&&((n=e.reg.get(s))?n.push(a):e.reg.set(s,[a]))}}function St(e,t,r,n,s){return r&&e>1?t+(n||0)<=e?r+(s||0):(e-1)/(t+(n||0))*(r+(s||0))+1|0:0}te.prototype.search=function(e,t,r){if(r||(t||typeof e!="object"?typeof t=="object"&&(r=t,t=0):(r=e,e="")),r&&r.cache)return r.cache=!1,e=this.searchCache(e,t,r),r.cache=!0,e;let n=[],s,o,i,c=0,a,l,u,h,m;r&&(e=r.query||e,t=r.limit||t,c=r.offset||0,o=r.context,i=r.suggest,m=(a=r.resolve)&&r.enrich,u=r.boost,h=r.resolution,l=this.db&&r.tag),typeof a>"u"&&(a=this.resolve),o=this.depth&&o!==!1;let y=this.encoder.encode(e,!o);if(s=y.length,t=t||(a?100:0),s===1)return ds.call(this,y[0],"",t,c,a,m,l);if(s===2&&o&&!i)return ds.call(this,y[1],y[0],t,c,a,m,l);let p=N(),f=0,d;if(o&&(d=y[0],f=1),h||h===0||(h=d?this.N:this.resolution),this.db){if(this.db.search&&(r=this.db.search(this,y,t,c,i,a,m,l),r!==!1))return r;const b=this;return(async function(){for(let w,E;f<s;f++){if((E=y[f])&&!p[E]){if(p[E]=1,w=await Gr(b,E,d,0,0,!1,!1),w=ps(w,n,i,h)){n=w;break}d&&(i&&w&&n.length||(d=E))}i&&d&&f===s-1&&!n.length&&(h=b.resolution,d="",f=-1,p=N())}return fs(n,h,t,c,i,u,a)})()}for(let b,w;f<s;f++){if((w=y[f])&&!p[w]){if(p[w]=1,b=Gr(this,w,d,0,0,!1,!1),b=ps(b,n,i,h)){n=b;break}d&&(i&&b&&n.length||(d=w))}i&&d&&f===s-1&&!n.length&&(h=this.resolution,d="",f=-1,p=N())}return fs(n,h,t,c,i,u,a)};function fs(e,t,r,n,s,o,i){let c=e.length,a=e;if(c>1)a=Ht(e,t,r,n,s,o,i);else if(c===1)return i?Pn.call(null,e[0],r,n):new P(e[0],this);return i?a:new P(a,this)}function ds(e,t,r,n,s,o,i){return e=Gr(this,e,t,r,n,s,o,i),this.db?e.then(function(c){return s?c||[]:new P(c,this)}):e&&e.length?s?Pn.call(this,e,r,n):new P(e,this):s?[]:new P([],this)}function ps(e,t,r,n){let s=[];if(e&&e.length){if(e.length<=n){t.push(e);return}for(let o=0,i;o<n;o++)(i=e[o])&&(s[o]=i);if(s.length){t.push(s);return}}if(!r)return s}function Gr(e,t,r,n,s,o,i,c){let a;return r&&(a=e.bidirectional&&t>r)&&(a=r,r=t,t=a),e.db?e.db.get(t,r,n,s,o,i,c):(e=r?(e=e.ctx.get(r))&&e.get(t):e.map.get(t),e)}function te(e,t){if(!this||this.constructor!==te)return new te(e);if(e){var r=Z(e)?e:e.preset;r&&(e=Object.assign({},Dl[r],e))}else e={};r=e.context;const n=r===!0?{depth:1}:r||{},s=Z(e.encoder)?Ho[e.encoder]:e.encode||e.encoder||{};this.encoder=s.encode?s:typeof s=="object"?new it(s):{encode:s},this.resolution=e.resolution||9,this.tokenize=r=(r=e.tokenize)&&r!=="default"&&r!=="exact"&&r||"strict",this.depth=r==="strict"&&n.depth||0,this.bidirectional=n.bidirectional!==!1,this.fastupdate=!!e.fastupdate,this.score=e.score||null,(r=e.keystore||0)&&(this.keystore=r),this.map=r?new Q(r):new Map,this.ctx=r?new Q(r):new Map,this.reg=t||(this.fastupdate?r?new Q(r):new Map:r?new ee(r):new Set),this.N=n.resolution||3,this.rtl=s.rtl||e.rtl||!1,this.cache=(r=e.cache||null)&&new Ke(r),this.resolve=e.resolve!==!1,(r=e.db)&&(this.db=this.mount(r)),this.M=e.commit!==!1,this.commit_task=[],this.commit_timer=null,this.priority=e.priority||4}A=te.prototype;A.mount=function(e){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),e.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 qo(e){e.commit_timer||(e.commit_timer=setTimeout(function(){e.commit_timer=null,e.db.commit(e)},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(e,t){return this.add(e,t,!0)};A.contain=function(e){return this.db?this.db.has(e):this.reg.has(e)};A.update=function(e,t){const r=this,n=this.remove(e);return n&&n.then?n.then(()=>r.add(e,t)):this.add(e,t)};A.cleanup=function(){return this.fastupdate?(ct(this.map),this.depth&&ct(this.ctx),this):this};A.searchCache=Cn;A.export=function(e,t,r=0,n=0){let s,o;switch(n){case 0:s="reg",o=Go(this.reg);break;case 1:s="cfg",o=null;break;case 2:s="map",o=Bn(this.map,this.reg.size);break;case 3:s="ctx",o=Vo(this.ctx,this.reg.size);break;default:return}return $t.call(this,e,t,s,o,r,n)};A.import=function(e,t){if(t)switch(typeof t=="string"&&(t=JSON.parse(t)),e=e.split("."),e[e.length-1]==="json"&&e.pop(),e.length===3&&e.shift(),e=e.length>1?e[1]:e[0],e){case"reg":this.fastupdate=!1,this.reg=Xo(t,this.reg);break;case"map":this.map=Fn(t,this.map);break;case"ctx":this.ctx=Jo(t,this.ctx)}};A.serialize=function(e=!0){let t="",r="",n="";if(this.reg.size){let o;for(var s of this.reg.keys())o||(o=typeof s),t+=(t?",":"")+(o==="string"?'"'+s+'"':s);t="index.reg=new Set(["+t+"]);",r=hs(this.map,o),r="index.map=new Map(["+r+"]);";for(const i of this.ctx.entries()){s=i[0];let c=hs(i[1],o);c="new Map(["+c+"])",c='["'+s+'",'+c+"]",n+=(n?",":"")+c}n="index.ctx=new Map(["+n+"]);"}return e?"function inject(index){"+t+r+n+"}":t+r+n};In(te.prototype);const Wo=typeof window<"u"&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),Yt=["map","ctx","tag","reg","cfg"],Ee=N();function Xr(e,t={}){if(!this||this.constructor!==Xr)return new Xr(e,t);typeof e=="object"&&(t=e,e=e.name),e||console.info("Default storage space was used, because a name was not passed."),this.id="flexsearch"+(e?":"+e.toLowerCase().replace(/[^a-z0-9_\-]/g,""):""),this.field=t.field?t.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"",this.type=t.type,this.fastupdate=this.support_tag_search=!1,this.db=null,this.h={}}A=Xr.prototype;A.mount=function(e){return e.index?e.mount(this):(e.db=this,this.open())};A.open=function(){if(this.db)return this.db;let e=this;navigator.storage&&navigator.storage.persist&&navigator.storage.persist(),Ee[e.id]||(Ee[e.id]=[]),Ee[e.id].push(e.field);const t=Wo.open(e.id,1);return t.onupgradeneeded=function(){const r=e.db=this.result;for(let n=0,s;n<Yt.length;n++){s=Yt[n];for(let o=0,i;o<Ee[e.id].length;o++)i=Ee[e.id][o],r.objectStoreNames.contains(s+(s!=="reg"&&i?":"+i:""))||r.createObjectStore(s+(s!=="reg"&&i?":"+i:""))}},e.db=me(t,function(r){e.db=r,e.db.onversionchange=function(){e.close()}})};A.close=function(){this.db&&this.db.close(),this.db=null};A.destroy=function(){const e=Wo.deleteDatabase(this.id);return me(e)};A.clear=function(){const e=[];for(let r=0,n;r<Yt.length;r++){n=Yt[r];for(let s=0,o;s<Ee[this.id].length;s++)o=Ee[this.id][s],e.push(n+(n!=="reg"&&o?":"+o:""))}const t=this.db.transaction(e,"readwrite");for(let r=0;r<e.length;r++)t.objectStore(e[r]).clear();return me(t)};A.get=function(e,t,r=0,n=0,s=!0,o=!1){e=this.db.transaction((t?"ctx":"map")+(this.field?":"+this.field:""),"readonly").objectStore((t?"ctx":"map")+(this.field?":"+this.field:"")).get(t?t+":"+e:e);const i=this;return me(e).then(function(c){let a=[];if(!c||!c.length)return a;if(s){if(!r&&!n&&c.length===1)return c[0];for(let l=0,u;l<c.length;l++)if((u=c[l])&&u.length){if(n>=u.length){n-=u.length;continue}const h=r?n+Math.min(u.length-n,r):u.length;for(let m=n;m<h;m++)a.push(u[m]);if(n=0,a.length===r)break}return o?i.enrich(a):a}return c})};A.tag=function(e,t=0,r=0,n=!1){e=this.db.transaction("tag"+(this.field?":"+this.field:""),"readonly").objectStore("tag"+(this.field?":"+this.field:"")).get(e);const s=this;return me(e).then(function(o){return!o||!o.length||r>=o.length?[]:!t&&!r?o:(o=o.slice(r,r+t),n?s.enrich(o):o)})};A.enrich=function(e){typeof e!="object"&&(e=[e]);const t=this.db.transaction("reg","readonly").objectStore("reg"),r=[];for(let n=0;n<e.length;n++)r[n]=me(t.get(e[n]));return Promise.all(r).then(function(n){for(let s=0;s<n.length;s++)n[s]={id:e[s],doc:n[s]?JSON.parse(n[s]):null};return n})};A.has=function(e){return e=this.db.transaction("reg","readonly").objectStore("reg").getKey(e),me(e).then(function(t){return!!t})};A.search=null;A.info=function(){};A.transaction=function(e,t,r){e+=e!=="reg"&&this.field?":"+this.field:"";let n=this.h[e+":"+t];if(n)return r.call(this,n);let s=this.db.transaction(e,t);this.h[e+":"+t]=n=s.objectStore(e);const o=r.call(this,n);return this.h[e+":"+t]=null,me(s).finally(function(){return o})};A.commit=async function(e){let t=e.commit_task,r=[];e.commit_task=[];for(let n=0,s;n<t.length;n++)s=t[n],s.del&&r.push(s.del);r.length&&await this.remove(r),e.reg.size&&(await this.transaction("map","readwrite",function(n){for(const s of e.map){const o=s[0],i=s[1];i.length&&(n.get(o).onsuccess=function(){let c=this.result;var a;if(c&&c.length){const l=Math.max(c.length,i.length);for(let u=0,h,m;u<l;u++)if((m=i[u])&&m.length){if((h=c[u])&&h.length)for(a=0;a<m.length;a++)h.push(m[a]);else c[u]=m;a=1}}else c=i,a=1;a&&n.put(c,o)})}}),await this.transaction("ctx","readwrite",function(n){for(const s of e.ctx){const o=s[0],i=s[1];for(const c of i){const a=c[0],l=c[1];l.length&&(n.get(o+":"+a).onsuccess=function(){let u=this.result;var h;if(u&&u.length){const m=Math.max(u.length,l.length);for(let y=0,p,f;y<m;y++)if((f=l[y])&&f.length){if((p=u[y])&&p.length)for(h=0;h<f.length;h++)p.push(f[h]);else u[y]=f;h=1}}else u=l,h=1;h&&n.put(u,o+":"+a)})}}}),e.store?await this.transaction("reg","readwrite",function(n){for(const s of e.store){const o=s[0],i=s[1];n.put(typeof i=="object"?JSON.stringify(i):1,o)}}):e.bypass||await this.transaction("reg","readwrite",function(n){for(const s of e.reg.keys())n.put(1,s)}),e.tag&&await this.transaction("tag","readwrite",function(n){for(const s of e.tag){const o=s[0],i=s[1];i.length&&(n.get(o).onsuccess=function(){let c=this.result;c=c&&c.length?c.concat(i):i,n.put(c,o)})}}),e.map.clear(),e.ctx.clear(),e.tag&&e.tag.clear(),e.store&&e.store.clear(),e.document||e.reg.clear())};function Rr(e,t,r){const n=e.value;let s,o=0;for(let i=0,c;i<n.length;i++){if(c=r?n:n[i]){for(let a=0,l,u;a<t.length;a++)if(u=t[a],l=c.indexOf(u),l>=0)if(s=1,c.length>1)c.splice(l,1);else{n[i]=[];break}o+=c.length}if(r)break}o?s&&e.update(n):e.delete(),e.continue()}A.remove=function(e){return typeof e!="object"&&(e=[e]),Promise.all([this.transaction("map","readwrite",function(t){t.openCursor().onsuccess=function(){const r=this.result;r&&Rr(r,e)}}),this.transaction("ctx","readwrite",function(t){t.openCursor().onsuccess=function(){const r=this.result;r&&Rr(r,e)}}),this.transaction("tag","readwrite",function(t){t.openCursor().onsuccess=function(){const r=this.result;r&&Rr(r,e,!0)}}),this.transaction("reg","readwrite",function(t){for(let r=0;r<e.length;r++)t.delete(e[r])})])};function me(e,t){return new Promise((r,n)=>{e.onsuccess=e.oncomplete=function(){t&&t(this.result),t=null,r(this.result)},e.onerror=e.onblocked=n,e=null})}const Tt=te,hr={preset:"match",tokenize:"forward",resolution:9,minlength:2,optimize:!0,fastupdate:!0,cache:!0},Ml={...hr,minlength:3,resolution:6},Ul={...hr,tokenize:"strict",minlength:1},Hl={...hr,tokenize:"strict",minlength:1},zl=()=>({subjectIndex:new Tt(hr),bodyIndex:new Tt(Ml),fromIndex:new Tt(Ul),toIndex:new Tt(Hl),isReady:!1}),Zo=(e,t)=>{try{const r=e.params.id;if(e.params.subject&&t.subjectIndex.add(r,e.params.subject),e.body?.text&&t.bodyIndex.add(r,e.body.text),e.params.sender){const o=`${e.params.sender.name||""} ${e.params.sender.email||""}`.trim();t.fromIndex.add(r,o)}const s=(e.params.recipients?.length?e.params.recipients:[e.params.recipient]).map(o=>`${o.name||""} ${o.email||""}`.trim()).join(" ");t.toIndex.add(r,s)}catch(r){throw new Error("Failed to add email to the search index",{cause:r})}},$l=(e,t)=>{try{t.subjectIndex.remove(e),t.bodyIndex.remove(e),t.fromIndex.remove(e),t.toIndex.remove(e)}catch(r){throw new Error(`Failed to remove email with ID ${e} from the search index`,{cause:r})}},Yl=async e=>{try{const t=zl();t.isReady=!1;for(const r of e.esCache.values())Zo(r,t);return t.isReady=!0,t}catch(t){throw new Error("Failed build an email search index from the cache",{cause:t})}},Vl=async(e,t,r,n={})=>{try{if(!r.isReady||!e.trim())return[];const{fields:s=["subject","body","from","to"],limit:o=50,boost:i={subject:3,body:1,from:2,to:2}}=n,c=new Map,a=s.map(async u=>{let h;switch(u){case"subject":h=await r.subjectIndex.searchAsync(e);break;case"body":h=await r.bodyIndex.searchAsync(e);break;case"from":h=await r.fromIndex.searchAsync(e);break;case"to":h=await r.toIndex.searchAsync(e);break;default:return}const m=i[u]||1;h.forEach(y=>{const p=c.get(String(y))||0;c.set(String(y),p+m)})});await Promise.all(a);const l=[];for(const[u,h]of c){const m=t.esCache.get(u);m&&l.push({email:m,score:h})}return l.sort((u,h)=>(h.score||0)-(u.score||0)),l.slice(0,o)}catch(s){throw new Error("Email search failed",{cause:s})}},Jl=Object.freeze(Object.defineProperty({__proto__:null,addEmailToCache:Uo,addEmailToSearchIndex:Zo,addEmailsToCache:$r,buildSearchIndexFromCache:Yl,closeDatabase:ul,createCacheFromDB:xl,deleteDatabase:hl,deleteEmail:gl,deleteEmailFromCache:kl,deleteOldestEmails:Bo,deriveIndexKey:fl,encryptAndStoreEmail:dl,encryptAndStoreManyEmail:pl,enforceMaxEmailNumber:wl,getAllEmailsSortedNewestFirst:No,getAllEmailsSortedOldestFirst:bl,getAndDecryptAllEmails:ml,getAndDecryptEmail:yl,getEmailBatch:Lo,getEmailCount:Rn,getEmailFromCache:Mo,openDatabase:ll,removeEmailFromSearchIndex:$l,searchEmails:Vl},Symbol.toStringTag,{value:"Module"}));function Qo(e,t){return function(){return e.apply(t,arguments)}}const{toString:Gl}=Object.prototype,{getPrototypeOf:Nn}=Object,{iterator:fr,toStringTag:ei}=Symbol,dr=(e=>t=>{const r=Gl.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),re=e=>(e=e.toLowerCase(),t=>dr(t)===e),pr=e=>t=>typeof t===e,{isArray:ze}=Array,at=pr("undefined");function ft(e){return e!==null&&!at(e)&&e.constructor!==null&&!at(e.constructor)&&J(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ti=re("ArrayBuffer");function Xl(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ti(e.buffer),t}const ql=pr("string"),J=pr("function"),ri=pr("number"),dt=e=>e!==null&&typeof e=="object",Wl=e=>e===!0||e===!1,Ct=e=>{if(dr(e)!=="object")return!1;const t=Nn(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ei in e)&&!(fr in e)},Zl=e=>{if(!dt(e)||ft(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Ql=re("Date"),eu=re("File"),tu=re("Blob"),ru=re("FileList"),nu=e=>dt(e)&&J(e.pipe),su=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||J(e.append)&&((t=dr(e))==="formdata"||t==="object"&&J(e.toString)&&e.toString()==="[object FormData]"))},ou=re("URLSearchParams"),[iu,cu,au,lu]=["ReadableStream","Request","Response","Headers"].map(re),uu=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function pt(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,s;if(typeof e!="object"&&(e=[e]),ze(e))for(n=0,s=e.length;n<s;n++)t.call(null,e[n],n,e);else{if(ft(e))return;const o=r?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let c;for(n=0;n<i;n++)c=o[n],t.call(null,e[c],c,e)}}function ni(e,t){if(ft(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n=r.length,s;for(;n-- >0;)if(s=r[n],t===s.toLowerCase())return s;return null}const ke=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:globalThis,si=e=>!at(e)&&e!==ke;function qr(){const{caseless:e}=si(this)&&this||{},t={},r=(n,s)=>{const o=e&&ni(t,s)||s;Ct(t[o])&&Ct(n)?t[o]=qr(t[o],n):Ct(n)?t[o]=qr({},n):ze(n)?t[o]=n.slice():t[o]=n};for(let n=0,s=arguments.length;n<s;n++)arguments[n]&&pt(arguments[n],r);return t}const hu=(e,t,r,{allOwnKeys:n}={})=>(pt(t,(s,o)=>{r&&J(s)?e[o]=Qo(s,r):e[o]=s},{allOwnKeys:n}),e),fu=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),du=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},pu=(e,t,r,n)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!n||n(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=r!==!1&&Nn(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},yu=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},mu=e=>{if(!e)return null;if(ze(e))return e;let t=e.length;if(!ri(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},gu=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Nn(Uint8Array)),wu=(e,t)=>{const n=(e&&e[fr]).call(e);let s;for(;(s=n.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},bu=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},Eu=re("HTMLFormElement"),xu=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,s){return n.toUpperCase()+s}),ys=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),ku=re("RegExp"),oi=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};pt(r,(s,o)=>{let i;(i=t(s,o,e))!==!1&&(n[o]=i||s)}),Object.defineProperties(e,n)},vu=e=>{oi(e,(t,r)=>{if(J(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(J(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},Su=(e,t)=>{const r={},n=s=>{s.forEach(o=>{r[o]=!0})};return ze(e)?n(e):n(String(e).split(t)),r},Tu=()=>{},Au=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function _u(e){return!!(e&&J(e.append)&&e[ei]==="FormData"&&e[fr])}const Ku=e=>{const t=new Array(10),r=(n,s)=>{if(dt(n)){if(t.indexOf(n)>=0)return;if(ft(n))return n;if(!("toJSON"in n)){t[s]=n;const o=ze(n)?[]:{};return pt(n,(i,c)=>{const a=r(i,s+1);!at(a)&&(o[c]=a)}),t[s]=void 0,o}}return n};return r(e,0)},Ou=re("AsyncFunction"),Ru=e=>e&&(dt(e)||J(e))&&J(e.then)&&J(e.catch),ii=((e,t)=>e?setImmediate:t?((r,n)=>(ke.addEventListener("message",({source:s,data:o})=>{s===ke&&o===r&&n.length&&n.shift()()},!1),s=>{n.push(s),ke.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",J(ke.postMessage)),Cu=typeof queueMicrotask<"u"?queueMicrotask.bind(ke):typeof process<"u"&&process.nextTick||ii,Iu=e=>e!=null&&J(e[fr]),g={isArray:ze,isArrayBuffer:ti,isBuffer:ft,isFormData:su,isArrayBufferView:Xl,isString:ql,isNumber:ri,isBoolean:Wl,isObject:dt,isPlainObject:Ct,isEmptyObject:Zl,isReadableStream:iu,isRequest:cu,isResponse:au,isHeaders:lu,isUndefined:at,isDate:Ql,isFile:eu,isBlob:tu,isRegExp:ku,isFunction:J,isStream:nu,isURLSearchParams:ou,isTypedArray:gu,isFileList:ru,forEach:pt,merge:qr,extend:hu,trim:uu,stripBOM:fu,inherits:du,toFlatObject:pu,kindOf:dr,kindOfTest:re,endsWith:yu,toArray:mu,forEachEntry:wu,matchAll:bu,isHTMLForm:Eu,hasOwnProperty:ys,hasOwnProp:ys,reduceDescriptors:oi,freezeMethods:vu,toObjectSet:Su,toCamelCase:xu,noop:Tu,toFiniteNumber:Au,findKey:ni,global:ke,isContextDefined:si,isSpecCompliantForm:_u,toJSONObject:Ku,isAsyncFn:Ou,isThenable:Ru,setImmediate:ii,asap:Cu,isIterable:Iu};function R(e,t,r,n,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),s&&(this.response=s,this.status=s.status?s.status:null)}g.inherits(R,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:g.toJSONObject(this.config),code:this.code,status:this.status}}});const ci=R.prototype,ai={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{ai[e]={value:e}});Object.defineProperties(R,ai);Object.defineProperty(ci,"isAxiosError",{value:!0});R.from=(e,t,r,n,s,o)=>{const i=Object.create(ci);return g.toFlatObject(e,i,function(a){return a!==Error.prototype},c=>c!=="isAxiosError"),R.call(i,e.message,t,r,n,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};const Pu=null;function Wr(e){return g.isPlainObject(e)||g.isArray(e)}function li(e){return g.endsWith(e,"[]")?e.slice(0,-2):e}function ms(e,t,r){return e?e.concat(t).map(function(s,o){return s=li(s),!r&&o?"["+s+"]":s}).join(r?".":""):t}function ju(e){return g.isArray(e)&&!e.some(Wr)}const Bu=g.toFlatObject(g,{},null,function(t){return/^is[A-Z]/.test(t)});function yr(e,t,r){if(!g.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=g.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(f,d){return!g.isUndefined(d[f])});const n=r.metaTokens,s=r.visitor||u,o=r.dots,i=r.indexes,a=(r.Blob||typeof Blob<"u"&&Blob)&&g.isSpecCompliantForm(t);if(!g.isFunction(s))throw new TypeError("visitor must be a function");function l(p){if(p===null)return"";if(g.isDate(p))return p.toISOString();if(g.isBoolean(p))return p.toString();if(!a&&g.isBlob(p))throw new R("Blob is not supported. Use a Buffer instead.");return g.isArrayBuffer(p)||g.isTypedArray(p)?a&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function u(p,f,d){let b=p;if(p&&!d&&typeof p=="object"){if(g.endsWith(f,"{}"))f=n?f:f.slice(0,-2),p=JSON.stringify(p);else if(g.isArray(p)&&ju(p)||(g.isFileList(p)||g.endsWith(f,"[]"))&&(b=g.toArray(p)))return f=li(f),b.forEach(function(E,x){!(g.isUndefined(E)||E===null)&&t.append(i===!0?ms([f],x,o):i===null?f:f+"[]",l(E))}),!1}return Wr(p)?!0:(t.append(ms(d,f,o),l(p)),!1)}const h=[],m=Object.assign(Bu,{defaultVisitor:u,convertValue:l,isVisitable:Wr});function y(p,f){if(!g.isUndefined(p)){if(h.indexOf(p)!==-1)throw Error("Circular reference detected in "+f.join("."));h.push(p),g.forEach(p,function(b,w){(!(g.isUndefined(b)||b===null)&&s.call(t,b,g.isString(w)?w.trim():w,f,m))===!0&&y(b,f?f.concat(w):[w])}),h.pop()}}if(!g.isObject(e))throw new TypeError("data must be an object");return y(e),t}function gs(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Ln(e,t){this._pairs=[],e&&yr(e,this,t)}const ui=Ln.prototype;ui.append=function(t,r){this._pairs.push([t,r])};ui.toString=function(t){const r=t?function(n){return t.call(this,n,gs)}:gs;return this._pairs.map(function(s){return r(s[0])+"="+r(s[1])},"").join("&")};function Fu(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function hi(e,t,r){if(!t)return e;const n=r&&r.encode||Fu;g.isFunction(r)&&(r={serialize:r});const s=r&&r.serialize;let o;if(s?o=s(t,r):o=g.isURLSearchParams(t)?t.toString():new Ln(t,r).toString(n),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class ws{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){g.forEach(this.handlers,function(n){n!==null&&t(n)})}}const fi={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Nu=typeof URLSearchParams<"u"?URLSearchParams:Ln,Lu=typeof FormData<"u"?FormData:null,Du=typeof Blob<"u"?Blob:null,Mu={isBrowser:!0,classes:{URLSearchParams:Nu,FormData:Lu,Blob:Du},protocols:["http","https","file","blob","url","data"]},Dn=typeof window<"u"&&typeof document<"u",Zr=typeof navigator=="object"&&navigator||void 0,Uu=Dn&&(!Zr||["ReactNative","NativeScript","NS"].indexOf(Zr.product)<0),Hu=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",zu=Dn&&window.location.href||"http://localhost",$u=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Dn,hasStandardBrowserEnv:Uu,hasStandardBrowserWebWorkerEnv:Hu,navigator:Zr,origin:zu},Symbol.toStringTag,{value:"Module"})),$={...$u,...Mu};function Yu(e,t){return yr(e,new $.classes.URLSearchParams,{visitor:function(r,n,s,o){return $.isNode&&g.isBuffer(r)?(this.append(n,r.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function Vu(e){return g.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Ju(e){const t={},r=Object.keys(e);let n;const s=r.length;let o;for(n=0;n<s;n++)o=r[n],t[o]=e[o];return t}function di(e){function t(r,n,s,o){let i=r[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),a=o>=r.length;return i=!i&&g.isArray(s)?s.length:i,a?(g.hasOwnProp(s,i)?s[i]=[s[i],n]:s[i]=n,!c):((!s[i]||!g.isObject(s[i]))&&(s[i]=[]),t(r,n,s[i],o)&&g.isArray(s[i])&&(s[i]=Ju(s[i])),!c)}if(g.isFormData(e)&&g.isFunction(e.entries)){const r={};return g.forEachEntry(e,(n,s)=>{t(Vu(n),s,r,0)}),r}return null}function Gu(e,t,r){if(g.isString(e))try{return(t||JSON.parse)(e),g.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const yt={transitional:fi,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",s=n.indexOf("application/json")>-1,o=g.isObject(t);if(o&&g.isHTMLForm(t)&&(t=new FormData(t)),g.isFormData(t))return s?JSON.stringify(di(t)):t;if(g.isArrayBuffer(t)||g.isBuffer(t)||g.isStream(t)||g.isFile(t)||g.isBlob(t)||g.isReadableStream(t))return t;if(g.isArrayBufferView(t))return t.buffer;if(g.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Yu(t,this.formSerializer).toString();if((c=g.isFileList(t))||n.indexOf("multipart/form-data")>-1){const a=this.env&&this.env.FormData;return yr(c?{"files[]":t}:t,a&&new a,this.formSerializer)}}return o||s?(r.setContentType("application/json",!1),Gu(t)):t}],transformResponse:[function(t){const r=this.transitional||yt.transitional,n=r&&r.forcedJSONParsing,s=this.responseType==="json";if(g.isResponse(t)||g.isReadableStream(t))return t;if(t&&g.isString(t)&&(n&&!this.responseType||s)){const i=!(r&&r.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?R.from(c,R.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:$.classes.FormData,Blob:$.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};g.forEach(["delete","get","head","post","put","patch"],e=>{yt.headers[e]={}});const Xu=g.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),qu=e=>{const t={};let r,n,s;return e&&e.split(`
|
|
2050
|
+
`).forEach(function(i){s=i.indexOf(":"),r=i.substring(0,s).trim().toLowerCase(),n=i.substring(s+1).trim(),!(!r||t[r]&&Xu[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},bs=Symbol("internals");function We(e){return e&&String(e).trim().toLowerCase()}function It(e){return e===!1||e==null?e:g.isArray(e)?e.map(It):String(e)}function Wu(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const Zu=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Cr(e,t,r,n,s){if(g.isFunction(n))return n.call(this,t,r);if(s&&(t=r),!!g.isString(t)){if(g.isString(n))return t.indexOf(n)!==-1;if(g.isRegExp(n))return n.test(t)}}function Qu(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function eh(e,t){const r=g.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(s,o,i){return this[n].call(this,t,s,o,i)},configurable:!0})})}let G=class{constructor(t){t&&this.set(t)}set(t,r,n){const s=this;function o(c,a,l){const u=We(a);if(!u)throw new Error("header name must be a non-empty string");const h=g.findKey(s,u);(!h||s[h]===void 0||l===!0||l===void 0&&s[h]!==!1)&&(s[h||a]=It(c))}const i=(c,a)=>g.forEach(c,(l,u)=>o(l,u,a));if(g.isPlainObject(t)||t instanceof this.constructor)i(t,r);else if(g.isString(t)&&(t=t.trim())&&!Zu(t))i(qu(t),r);else if(g.isObject(t)&&g.isIterable(t)){let c={},a,l;for(const u of t){if(!g.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[l=u[0]]=(a=c[l])?g.isArray(a)?[...a,u[1]]:[a,u[1]]:u[1]}i(c,r)}else t!=null&&o(r,t,n);return this}get(t,r){if(t=We(t),t){const n=g.findKey(this,t);if(n){const s=this[n];if(!r)return s;if(r===!0)return Wu(s);if(g.isFunction(r))return r.call(this,s,n);if(g.isRegExp(r))return r.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=We(t),t){const n=g.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||Cr(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let s=!1;function o(i){if(i=We(i),i){const c=g.findKey(n,i);c&&(!r||Cr(n,n[c],c,r))&&(delete n[c],s=!0)}}return g.isArray(t)?t.forEach(o):o(t),s}clear(t){const r=Object.keys(this);let n=r.length,s=!1;for(;n--;){const o=r[n];(!t||Cr(this,this[o],o,t,!0))&&(delete this[o],s=!0)}return s}normalize(t){const r=this,n={};return g.forEach(this,(s,o)=>{const i=g.findKey(n,o);if(i){r[i]=It(s),delete r[o];return}const c=t?Qu(o):String(o).trim();c!==o&&delete r[o],r[c]=It(s),n[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return g.forEach(this,(n,s)=>{n!=null&&n!==!1&&(r[s]=t&&g.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
2051
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(s=>n.set(s)),n}static accessor(t){const n=(this[bs]=this[bs]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=We(i);n[c]||(eh(s,i),n[c]=!0)}return g.isArray(t)?t.forEach(o):o(t),this}};G.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);g.reduceDescriptors(G.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});g.freezeMethods(G);function Ir(e,t){const r=this||yt,n=t||r,s=G.from(n.headers);let o=n.data;return g.forEach(e,function(c){o=c.call(r,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function pi(e){return!!(e&&e.__CANCEL__)}function $e(e,t,r){R.call(this,e??"canceled",R.ERR_CANCELED,t,r),this.name="CanceledError"}g.inherits($e,R,{__CANCEL__:!0});function yi(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new R("Request failed with status code "+r.status,[R.ERR_BAD_REQUEST,R.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function th(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function rh(e,t){e=e||10;const r=new Array(e),n=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(a){const l=Date.now(),u=n[o];i||(i=l),r[s]=a,n[s]=l;let h=o,m=0;for(;h!==s;)m+=r[h++],h=h%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),l-i<t)return;const y=u&&l-u;return y?Math.round(m*1e3/y):void 0}}function nh(e,t){let r=0,n=1e3/t,s,o;const i=(l,u=Date.now())=>{r=u,s=null,o&&(clearTimeout(o),o=null),e(...l)};return[(...l)=>{const u=Date.now(),h=u-r;h>=n?i(l,u):(s=l,o||(o=setTimeout(()=>{o=null,i(s)},n-h)))},()=>s&&i(s)]}const Vt=(e,t,r=3)=>{let n=0;const s=rh(50,250);return nh(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,a=i-n,l=s(a),u=i<=c;n=i;const h={loaded:i,total:c,progress:c?i/c:void 0,bytes:a,rate:l||void 0,estimated:l&&c&&u?(c-i)/l:void 0,event:o,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(h)},r)},Es=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},xs=e=>(...t)=>g.asap(()=>e(...t)),sh=$.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,$.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL($.origin),$.navigator&&/(msie|trident)/i.test($.navigator.userAgent)):()=>!0,oh=$.hasStandardBrowserEnv?{write(e,t,r,n,s,o){const i=[e+"="+encodeURIComponent(t)];g.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),g.isString(n)&&i.push("path="+n),g.isString(s)&&i.push("domain="+s),o===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function ih(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function ch(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function mi(e,t,r){let n=!ih(t);return e&&(n||r==!1)?ch(e,t):t}const ks=e=>e instanceof G?{...e}:e;function Ae(e,t){t=t||{};const r={};function n(l,u,h,m){return g.isPlainObject(l)&&g.isPlainObject(u)?g.merge.call({caseless:m},l,u):g.isPlainObject(u)?g.merge({},u):g.isArray(u)?u.slice():u}function s(l,u,h,m){if(g.isUndefined(u)){if(!g.isUndefined(l))return n(void 0,l,h,m)}else return n(l,u,h,m)}function o(l,u){if(!g.isUndefined(u))return n(void 0,u)}function i(l,u){if(g.isUndefined(u)){if(!g.isUndefined(l))return n(void 0,l)}else return n(void 0,u)}function c(l,u,h){if(h in t)return n(l,u);if(h in e)return n(void 0,l)}const a={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(l,u,h)=>s(ks(l),ks(u),h,!0)};return g.forEach(Object.keys({...e,...t}),function(u){const h=a[u]||s,m=h(e[u],t[u],u);g.isUndefined(m)&&h!==c||(r[u]=m)}),r}const gi=e=>{const t=Ae({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=t;t.headers=i=G.from(i),t.url=hi(mi(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let a;if(g.isFormData(r)){if($.hasStandardBrowserEnv||$.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if((a=i.getContentType())!==!1){const[l,...u]=a?a.split(";").map(h=>h.trim()).filter(Boolean):[];i.setContentType([l||"multipart/form-data",...u].join("; "))}}if($.hasStandardBrowserEnv&&(n&&g.isFunction(n)&&(n=n(t)),n||n!==!1&&sh(t.url))){const l=s&&o&&oh.read(o);l&&i.set(s,l)}return t},ah=typeof XMLHttpRequest<"u",lh=ah&&function(e){return new Promise(function(r,n){const s=gi(e);let o=s.data;const i=G.from(s.headers).normalize();let{responseType:c,onUploadProgress:a,onDownloadProgress:l}=s,u,h,m,y,p;function f(){y&&y(),p&&p(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let d=new XMLHttpRequest;d.open(s.method.toUpperCase(),s.url,!0),d.timeout=s.timeout;function b(){if(!d)return;const E=G.from("getAllResponseHeaders"in d&&d.getAllResponseHeaders()),k={data:!c||c==="text"||c==="json"?d.responseText:d.response,status:d.status,statusText:d.statusText,headers:E,config:e,request:d};yi(function(S){r(S),f()},function(S){n(S),f()},k),d=null}"onloadend"in d?d.onloadend=b:d.onreadystatechange=function(){!d||d.readyState!==4||d.status===0&&!(d.responseURL&&d.responseURL.indexOf("file:")===0)||setTimeout(b)},d.onabort=function(){d&&(n(new R("Request aborted",R.ECONNABORTED,e,d)),d=null)},d.onerror=function(){n(new R("Network Error",R.ERR_NETWORK,e,d)),d=null},d.ontimeout=function(){let x=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const k=s.transitional||fi;s.timeoutErrorMessage&&(x=s.timeoutErrorMessage),n(new R(x,k.clarifyTimeoutError?R.ETIMEDOUT:R.ECONNABORTED,e,d)),d=null},o===void 0&&i.setContentType(null),"setRequestHeader"in d&&g.forEach(i.toJSON(),function(x,k){d.setRequestHeader(k,x)}),g.isUndefined(s.withCredentials)||(d.withCredentials=!!s.withCredentials),c&&c!=="json"&&(d.responseType=s.responseType),l&&([m,p]=Vt(l,!0),d.addEventListener("progress",m)),a&&d.upload&&([h,y]=Vt(a),d.upload.addEventListener("progress",h),d.upload.addEventListener("loadend",y)),(s.cancelToken||s.signal)&&(u=E=>{d&&(n(!E||E.type?new $e(null,e,d):E),d.abort(),d=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));const w=th(s.url);if(w&&$.protocols.indexOf(w)===-1){n(new R("Unsupported protocol "+w+":",R.ERR_BAD_REQUEST,e));return}d.send(o||null)})},uh=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,s;const o=function(l){if(!s){s=!0,c();const u=l instanceof Error?l:this.reason;n.abort(u instanceof R?u:new $e(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,o(new R(`timeout ${t} of ms exceeded`,R.ETIMEDOUT))},t);const c=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(l=>{l.unsubscribe?l.unsubscribe(o):l.removeEventListener("abort",o)}),e=null)};e.forEach(l=>l.addEventListener("abort",o));const{signal:a}=n;return a.unsubscribe=()=>g.asap(c),a}},hh=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,s;for(;n<r;)s=n+t,yield e.slice(n,s),n=s},fh=async function*(e,t){for await(const r of dh(e))yield*hh(r,t)},dh=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},vs=(e,t,r,n)=>{const s=fh(e,t);let o=0,i,c=a=>{i||(i=!0,n&&n(a))};return new ReadableStream({async pull(a){try{const{done:l,value:u}=await s.next();if(l){c(),a.close();return}let h=u.byteLength;if(r){let m=o+=h;r(m)}a.enqueue(new Uint8Array(u))}catch(l){throw c(l),l}},cancel(a){return c(a),s.return()}},{highWaterMark:2})},mr=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",wi=mr&&typeof ReadableStream=="function",ph=mr&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),bi=(e,...t)=>{try{return!!e(...t)}catch{return!1}},yh=wi&&bi(()=>{let e=!1;const t=new Request($.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),Ss=64*1024,Qr=wi&&bi(()=>g.isReadableStream(new Response("").body)),Jt={stream:Qr&&(e=>e.body)};mr&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Jt[t]&&(Jt[t]=g.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new R(`Response type '${t}' is not supported`,R.ERR_NOT_SUPPORT,n)})})})(new Response);const mh=async e=>{if(e==null)return 0;if(g.isBlob(e))return e.size;if(g.isSpecCompliantForm(e))return(await new Request($.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(g.isArrayBufferView(e)||g.isArrayBuffer(e))return e.byteLength;if(g.isURLSearchParams(e)&&(e=e+""),g.isString(e))return(await ph(e)).byteLength},gh=async(e,t)=>{const r=g.toFiniteNumber(e.getContentLength());return r??mh(t)},wh=mr&&(async e=>{let{url:t,method:r,data:n,signal:s,cancelToken:o,timeout:i,onDownloadProgress:c,onUploadProgress:a,responseType:l,headers:u,withCredentials:h="same-origin",fetchOptions:m}=gi(e);l=l?(l+"").toLowerCase():"text";let y=uh([s,o&&o.toAbortSignal()],i),p;const f=y&&y.unsubscribe&&(()=>{y.unsubscribe()});let d;try{if(a&&yh&&r!=="get"&&r!=="head"&&(d=await gh(u,n))!==0){let k=new Request(t,{method:"POST",body:n,duplex:"half"}),v;if(g.isFormData(n)&&(v=k.headers.get("content-type"))&&u.setContentType(v),k.body){const[S,T]=Es(d,Vt(xs(a)));n=vs(k.body,Ss,S,T)}}g.isString(h)||(h=h?"include":"omit");const b="credentials"in Request.prototype;p=new Request(t,{...m,signal:y,method:r.toUpperCase(),headers:u.normalize().toJSON(),body:n,duplex:"half",credentials:b?h:void 0});let w=await fetch(p,m);const E=Qr&&(l==="stream"||l==="response");if(Qr&&(c||E&&f)){const k={};["status","statusText","headers"].forEach(_=>{k[_]=w[_]});const v=g.toFiniteNumber(w.headers.get("content-length")),[S,T]=c&&Es(v,Vt(xs(c),!0))||[];w=new Response(vs(w.body,Ss,S,()=>{T&&T(),f&&f()}),k)}l=l||"text";let x=await Jt[g.findKey(Jt,l)||"text"](w,e);return!E&&f&&f(),await new Promise((k,v)=>{yi(k,v,{data:x,headers:G.from(w.headers),status:w.status,statusText:w.statusText,config:e,request:p})})}catch(b){throw f&&f(),b&&b.name==="TypeError"&&/Load failed|fetch/i.test(b.message)?Object.assign(new R("Network Error",R.ERR_NETWORK,e,p),{cause:b.cause||b}):R.from(b,b&&b.code,e,p)}}),en={http:Pu,xhr:lh,fetch:wh};g.forEach(en,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Ts=e=>`- ${e}`,bh=e=>g.isFunction(e)||e===null||e===!1,Ei={getAdapter:e=>{e=g.isArray(e)?e:[e];const{length:t}=e;let r,n;const s={};for(let o=0;o<t;o++){r=e[o];let i;if(n=r,!bh(r)&&(n=en[(i=String(r)).toLowerCase()],n===void 0))throw new R(`Unknown adapter '${i}'`);if(n)break;s[i||"#"+o]=n}if(!n){const o=Object.entries(s).map(([c,a])=>`adapter ${c} `+(a===!1?"is not supported by the environment":"is not available in the build"));let i=t?o.length>1?`since :
|
|
2052
2052
|
`+o.map(Ts).join(`
|
|
2053
|
-
`):" "+Ts(o[0]):"as no adapter specified";throw new R("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return n},adapters:
|
|
2054
|
-
`+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Ae(this.defaults,r);const{transitional:n,paramsSerializer:s,headers:o}=r;n!==void 0&&Ct.assertOptions(n,{silentJSONParsing:oe.transitional(oe.boolean),forcedJSONParsing:oe.transitional(oe.boolean),clarifyTimeoutError:oe.transitional(oe.boolean)},!1),s!=null&&(g.isFunction(s)?r.paramsSerializer={serialize:s}:Ct.assertOptions(s,{encode:oe.function,serialize:oe.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Ct.assertOptions(r,{baseUrl:oe.spelling("baseURL"),withXsrfToken:oe.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=o&&g.merge(o.common,o[r.method]);o&&g.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),r.headers=J.concat(i,o);const c=[];let a=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(r)===!1||(a=a&&f.synchronous,c.unshift(f.fulfilled,f.rejected))});const l=[];this.interceptors.response.forEach(function(f){l.push(f.fulfilled,f.rejected)});let u,h=0,m;if(!a){const p=[As.bind(this),void 0];for(p.unshift(...c),p.push(...l),m=p.length,u=Promise.resolve(r);h<m;)u=u.then(p[h++],p[h++]);return u}m=c.length;let y=r;for(h=0;h<m;){const p=c[h++],f=c[h++];try{y=p(y)}catch(d){f.call(this,d);break}}try{u=As.call(this,y)}catch(p){return Promise.reject(p)}for(h=0,m=l.length;h<m;)u=u.then(l[h++],l[h++]);return u}getUri(t){t=Ae(this.defaults,t);const r=mi(t.baseURL,t.url,t.allowAbsoluteUrls);return hi(r,t.params,t.paramsSerializer)}};g.forEach(["delete","get","head","options"],function(t){ve.prototype[t]=function(r,n){return this.request(Ae(n||{},{method:t,url:r,data:(n||{}).data}))}});g.forEach(["post","put","patch"],function(t){function r(n){return function(o,i,c){return this.request(Ae(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}ve.prototype[t]=r(),ve.prototype[t+"Form"]=r(!0)});let wh=class ki{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});const n=this;this.promise.then(s=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](s);n._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{n.subscribe(c),o=c}).then(s);return i.cancel=function(){n.unsubscribe(o)},i},t(function(o,i,c){n.reason||(n.reason=new He(o,i,c),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new ki(function(s){t=s}),cancel:t}}};function bh(e){return function(r){return e.apply(null,r)}}function Eh(e){return g.isObject(e)&&e.isAxiosError===!0}const en={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(en).forEach(([e,t])=>{en[t]=e});function vi(e){const t=new ve(e),r=Qo(ve.prototype.request,t);return g.extend(r,ve.prototype,t,{allOwnKeys:!0}),g.extend(r,t,null,{allOwnKeys:!0}),r.create=function(s){return vi(Ae(e,s))},r}const I=vi(dt);I.Axios=ve;I.CanceledError=He;I.CancelToken=wh;I.isCancel=pi;I.VERSION=xi;I.toFormData=pr;I.AxiosError=R;I.Cancel=I.CanceledError;I.all=function(t){return Promise.all(t)};I.spread=bh;I.isAxiosError=Eh;I.mergeConfig=Ae;I.AxiosHeaders=J;I.formToJSON=e=>di(g.isHTMLForm(e)?new FormData(e):e);I.getAdapter=Ei.getAdapter;I.HttpStatusCode=en;I.default=I;const{Axios:bf,AxiosError:Ef,CanceledError:xf,isCancel:kf,CancelToken:vf,VERSION:Sf,all:Tf,Cancel:Af,isAxiosError:_f,spread:Kf,toFormData:Of,AxiosHeaders:Rf,HttpStatusCode:Cf,formToJSON:If,getAdapter:Pf,mergeConfig:jf}=I;async function xh(e){try{return(await I.get("/api/getPublicKeys",{params:{emails:e},withCredentials:!0,headers:{"Content-Type":"application/json"}})).data}catch(t){throw I.isAxiosError(t)?t.response?.status===401?new Error("Unauthorized: Invalid or expired token"):t.response?.status===403?new Error("Forbidden: Insufficient permissions"):t.response?.status===404?new Error("User is not found"):new Error("AxiosError:",t):new Error("Failed to retrieve public keys",{cause:t})}}async function kh(e){try{const t=await xh(e),r=[];for(const n of t){const s=await Eo(n);r.push(s)}return r}catch(t){throw new Error("Failed to get recipients public keys",{cause:t})}}class pt{constructor(t=0,r="Network Error"){this.status=t,this.text=r}}const vh=()=>{if(!(typeof localStorage>"u"))return{get:e=>Promise.resolve(localStorage.getItem(e)),set:(e,t)=>Promise.resolve(localStorage.setItem(e,t)),remove:e=>Promise.resolve(localStorage.removeItem(e))}},z={origin:"https://api.emailjs.com",blockHeadless:!1,storageProvider:vh()},Mn=e=>e?typeof e=="string"?{publicKey:e}:e.toString()==="[object Object]"?e:{}:{},Sh=(e,t="https://api.emailjs.com")=>{if(!e)return;const r=Mn(e);z.publicKey=r.publicKey,z.blockHeadless=r.blockHeadless,z.storageProvider=r.storageProvider,z.blockList=r.blockList,z.limitRate=r.limitRate,z.origin=r.origin||t},Si=async(e,t,r={})=>{const n=await fetch(z.origin+e,{method:"POST",headers:r,body:t}),s=await n.text(),o=new pt(n.status,s);if(n.ok)return o;throw o},Ti=(e,t,r)=>{if(!e||typeof e!="string")throw"The public key is required. Visit https://dashboard.emailjs.com/admin/account";if(!t||typeof t!="string")throw"The service ID is required. Visit https://dashboard.emailjs.com/admin";if(!r||typeof r!="string")throw"The template ID is required. Visit https://dashboard.emailjs.com/admin/templates"},Th=e=>{if(e&&e.toString()!=="[object Object]")throw"The template params have to be the object. Visit https://www.emailjs.com/docs/sdk/send/"},Ai=e=>e.webdriver||!e.languages||e.languages.length===0,_i=()=>new pt(451,"Unavailable For Headless Browser"),Ah=(e,t)=>{if(!Array.isArray(e))throw"The BlockList list has to be an array";if(typeof t!="string")throw"The BlockList watchVariable has to be a string"},_h=e=>!e.list?.length||!e.watchVariable,Kh=(e,t)=>e instanceof FormData?e.get(t):e[t],Ki=(e,t)=>{if(_h(e))return!1;Ah(e.list,e.watchVariable);const r=Kh(t,e.watchVariable);return typeof r!="string"?!1:e.list.includes(r)},Oi=()=>new pt(403,"Forbidden"),Oh=(e,t)=>{if(typeof e!="number"||e<0)throw"The LimitRate throttle has to be a positive number";if(t&&typeof t!="string")throw"The LimitRate ID has to be a non-empty string"},Rh=async(e,t,r)=>{const n=Number(await r.get(e)||0);return t-Date.now()+n},Ri=async(e,t,r)=>{if(!t.throttle||!r)return!1;Oh(t.throttle,t.id);const n=t.id||e;return await Rh(n,t.throttle,r)>0?!0:(await r.set(n,Date.now().toString()),!1)},Ci=()=>new pt(429,"Too Many Requests"),Ch=async(e,t,r,n)=>{const s=Mn(n),o=s.publicKey||z.publicKey,i=s.blockHeadless||z.blockHeadless,c=s.storageProvider||z.storageProvider,a={...z.blockList,...s.blockList},l={...z.limitRate,...s.limitRate};return i&&Ai(navigator)?Promise.reject(_i()):(Ti(o,e,t),Th(r),r&&Ki(a,r)?Promise.reject(Oi()):await Ri(location.pathname,l,c)?Promise.reject(Ci()):Si("/api/v1.0/email/send",JSON.stringify({lib_version:"4.4.1",user_id:o,service_id:e,template_id:t,template_params:r}),{"Content-type":"application/json"}))},Ih=e=>{if(!e||e.nodeName!=="FORM")throw"The 3rd parameter is expected to be the HTML form element or the style selector of the form"},Ph=e=>typeof e=="string"?document.querySelector(e):e,jh=async(e,t,r,n)=>{const s=Mn(n),o=s.publicKey||z.publicKey,i=s.blockHeadless||z.blockHeadless,c=z.storageProvider||s.storageProvider,a={...z.blockList,...s.blockList},l={...z.limitRate,...s.limitRate};if(i&&Ai(navigator))return Promise.reject(_i());const u=Ph(r);Ti(o,e,t),Ih(u);const h=new FormData(u);return Ki(a,h)?Promise.reject(Oi()):await Ri(location.pathname,l,c)?Promise.reject(Ci()):(h.append("lib_version","4.4.1"),h.append("service_id",e),h.append("template_id",t),h.append("user_id",o),Si("/api/v1.0/email/send-form",h))},Bh={init:Sh,send:Ch,sendForm:jh,EmailJSResponseStatus:pt},Fh={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},qe={getVariable:Lh},Nh={serviceID:"VITE_SERVICE_ID",templateID:"VITE_TEMPLATE_ID",publicKey:"VITE_PUBLIC_KEY",baseUrl:"VITE_BASE_URL"};function Lh(e){const t=Nh[e];if(!t)throw new Error(`Unknown variable name: "${e}"`);const r=Fh[t];if(!r)throw new Error(`Variable "${e}" is empty`);return r}async function Ii(e,t){try{const r={from_email:t.sender.email,from_name:t.sender.name,to_email:t.recipient.email,to_name:t.recipient.name,email_subject:t.subject,email_body:e,timestamp:new Date().toISOString()},n=qe.getVariable("serviceID"),s=qe.getVariable("templateID"),o=qe.getVariable("publicKey");await Bh.send(n,s,r,o).then(i=>{console.log("SUCCESS!",i.status,i.text)},i=>{throw new Error(`emailjs error: ${i}`)})}catch(r){throw new Error("Failed to send an email",{cause:r})}}async function Dh(e){try{if(e.recipientID!==e.params.recipient.id)throw new Error("Email is encrypted for another recipient");const t=vo(e);await Ii(t,e.params)}catch(t){throw new Error(`Failed to email to the recipient: ${t.message}`,{cause:t})}}async function Mh(e){try{const t=So(e);await Ii(t,e.params)}catch(t){throw new Error("Failed to email to the recipient",{cause:t})}}const Uh=Object.freeze(Object.defineProperty({__proto__:null,getRecipientsPublicKeys:kh,sendHybridEmail:Dh,sendPwdProtectedEmail:Mh},Symbol.toStringTag,{value:"Module"}));var W=(e=>(e.IDENTITY="identity",e.ENCRYPTION="encryption",e.RECOVERY="recovery",e.INDEX="index",e))(W||{});function Hh(e){return sessionStorage.getItem(e)}function zh(e,t){return sessionStorage.setItem(e,t)}function $h(e){sessionStorage.removeItem(e)}function Yh(e){return!!sessionStorage.getItem(e)}function Vh(){sessionStorage.clear()}const Un={set:zh,get:Hh,removeItem:$h,exists:Yh,clear:Vh},Jh=Object.freeze(Object.defineProperty({__proto__:null,default:Un},Symbol.toStringTag,{value:"Module"}));async function tn(e,t,r,n){try{const s=r+n,o=D(t);return await nr(e,o,s)}catch(s){throw new Error("Failed to encrypt keystore content",{cause:s})}}async function Hn(e,t,r,n){try{const s=r+n,o=await et(e,t,s);return U(o)}catch(s){throw new Error("Failed to decrypt keystore content",{cause:s})}}function gr(){try{const e=Un.get("userID");if(!e)throw new Error("No UserID");return e}catch(e){throw new Error("Failed to get UserID from session storage",{cause:e})}}function wr(){try{const e=Un.get("baseKey");if(!e)throw new Error("No base key");return D(e)}catch(e){throw new Error("Failed to get base key from session storage",{cause:e})}}async function Pi(e){return lt(Cs,e)}async function ji(e){const t=await rr(G,e);return lt(Ps,t)}async function Bi(e){return lt(Is,e)}function Fi(){return so(G)}async function Ni(){try{const e=await Xt(),t=vn();return{userPrivateKey:e.privateKey,userPublicKey:e.publicKey,userPublicKyberKey:t.publicKey,userPrivateKyberKey:t.secretKey}}catch(e){throw new Error("Failed to generate encryption keys",{cause:e})}}async function Gh(){try{const e=gr(),t=wr(),r=await Ni(),n=await Ys(r),s=await Bi(t),o=await tn(s,n,e,nn),i={userID:e,type:W.ENCRYPTION,encryptedKeys:o},c=Fi(),a=await ji(c),l=await tn(a,n,e,sn),u={userID:e,type:W.RECOVERY,encryptedKeys:l};return{encryptionKeystore:i,recoveryKeystore:u,recoveryCodes:c}}catch(e){throw new Error("Failed to create encryption and recovery keystores",{cause:e})}}async function Xh(e){try{if(e.type!=W.ENCRYPTION)throw new Error("Input is invalid");const t=wr(),r=await Bi(t),n=await Hn(r,e.encryptedKeys,e.userID,nn);return await un(n)}catch(t){throw new Error("Failed to open encryption keystore",{cause:t})}}async function qh(e,t){try{if(t.type!=W.RECOVERY)throw new Error("Input is invalid");const r=await ji(e),n=await Hn(r,t.encryptedKeys,t.userID,sn);return await un(n)}catch(r){throw new Error("Failed to open recovery keystore",{cause:r})}}async function Li(){try{const e=await Xt();return{userPrivateKey:e.privateKey,userPublicKey:e.publicKey}}catch(e){throw new Error("Failed to generate idenity keys",{cause:e})}}async function Wh(){try{const e=W.IDENTITY,t=gr(),r=wr(),n=await Li(),s=await $s(n),o=await Pi(r),i=await tn(o,s,t,rn);return{userID:t,type:e,encryptedKeys:i}}catch(e){throw new Error("Failed to create identity keystore",{cause:e})}}async function Zh(e){try{if(e.type!=W.IDENTITY)throw new Error("Input is invalid");const t=wr(),r=await Pi(t),n=await Hn(r,e.encryptedKeys,e.userID,rn);return await Js(n)}catch(t){throw new Error("Failed to open identity keystore",{cause:t})}}const Qh=Object.freeze(Object.defineProperty({__proto__:null,createEncryptionAndRecoveryKeystores:Gh,createIdentityKeystore:Wh,generateEncryptionKeys:Ni,generateIdentityKeys:Li,generateRecoveryCodes:Fi,openEncryptionKeystore:Xh,openIdentityKeystore:Zh,openRecoveryKeystore:qh},Symbol.toStringTag,{value:"Module"}));async function ef(e,t){try{const r=qe.getVariable("baseUrl");return await I.post(r+`${t}`,{encryptedKeystore:e},{withCredentials:!0,headers:{"Content-Type":"application/json"}})}catch(r){throw I.isAxiosError(r)?r.response?.status===401?new Error("Unauthorized: Invalid or expired token"):r.response?.status===403?new Error("Forbidden: Insufficient permissions"):new Error("AxiosError:",r):new Error("Failed to send keystore",{cause:r})}}async function tf(e){try{const t=qe.getVariable("baseUrl");return(await I.get(t+`${e}`,{withCredentials:!0,headers:{"Content-Type":"application/json"}})).data}catch(t){throw I.isAxiosError(t)?t.response?.status===401?new Error("Unauthorized: Invalid or expired token"):t.response?.status===403?new Error("Forbidden: Insufficient permissions"):t.response?.status===404?new Error("Keystore not found for the specified user"):new Error("AxiosError:",t):new Error("Failed to retrive keystore",{cause:t})}}async function rf(e){try{const t=gr(),r=e.type,n=`/uploadKeystore/${t}/${r}`,s=Vs(e);return await ef(s,n)}catch(t){throw new Error("Failed to upload keystore to the server",{cause:t})}}async function nf(){return br(W.ENCRYPTION)}async function sf(){return br(W.IDENTITY)}async function of(){return br(W.RECOVERY)}async function cf(){return br(W.INDEX)}async function br(e){try{const t=gr(),r=e.toString(),n=`/downloadKeystore/${t}/${r}`,s=await tf(n);return Gs(s)}catch(t){throw new Error("Failed to retrieve keystore from the server",{cause:t})}}const af=Object.freeze(Object.defineProperty({__proto__:null,getEncryptionKeystoreFromServer:nf,getIdentityKeystoreFromServer:sf,getIndexKeystoreFromServer:cf,getRecoveryKeystoreFromServer:of,uploadKeystoreToServer:rf},Symbol.toStringTag,{value:"Module"}));function lf(e){return localStorage.getItem(e)}function uf(e,t){return localStorage.setItem(e,t)}function hf(e){localStorage.removeItem(e)}function ff(e){return!!localStorage.getItem(e)}function df(){localStorage.clear()}const pf={set:uf,get:lf,removeItem:hf,exists:ff,clear:df},yf=Object.freeze(Object.defineProperty({__proto__:null,default:pf},Symbol.toStringTag,{value:"Module"})),mf=Object.freeze(Object.defineProperty({__proto__:null,localStorageService:yf,sessionStorageService:Jh},Symbol.toStringTag,{value:"Module"}));exports.AES_ALGORITHM=Ne;exports.AES_KEY_BIT_LENGTH=G;exports.ARGON2ID_ITERATIONS=Ls;exports.ARGON2ID_MEMORY_SIZE=Ds;exports.ARGON2ID_OUTPUT_BYTE_LENGTH=Us;exports.ARGON2ID_PARALLELISM=Ns;exports.ARGON2ID_SALT_BYTE_LENGTH=Ms;exports.AUX_LEN=Ks;exports.CONTEXT_DERIVE=Bs;exports.CONTEXT_ENC_KEYSTORE=Is;exports.CONTEXT_INDEX=js;exports.CONTEXT_LOGIN=Cs;exports.CONTEXT_RATCHET=Pr;exports.CONTEXT_RECOVERY=Ps;exports.CONTEXT_WRAPPING=Rs;exports.DB_LABEL=q;exports.DB_VERSION=zs;exports.ECC_ALGORITHM=at;exports.ENCRYPTION_KEYSTORE_TAG=nn;exports.HASH_BIT_LEN=Gt;exports.IDENTITY_KEYSTORE_TAG=rn;exports.INDEX_KEYSTORE_TAG=Hi;exports.IV_LEN_BYTES=Os;exports.KEY_FORMAT=Le;exports.KEY_WRAPPING_ALGORITHM=Jt;exports.KYBER1024_PUBLIC_KEY_LENGTH=Ji;exports.KYBER1024_SECRET_KEY_LENGTH=Gi;exports.KYBER512_PUBLIC_KEY_LENGTH=zi;exports.KYBER512_SECRET_KEY_LENGTH=$i;exports.KYBER768_PUBLIC_KEY_LENGTH=Yi;exports.KYBER768_SECRET_KEY_LENGTH=Vi;exports.KYBER_SEED_LENGTH=Xi;exports.KeystoreType=W;exports.MAX_CACHE_SIZE=Hs;exports.MAX_EMAIL_PER_BATCH=jr;exports.PREFIX_IDENTITY_KEY_COMMITMENT=Ui;exports.PREFIX_MEDIA_KEY_COMMITMENT=Fs;exports.PREFIX_PUBLIC_KEY_COMMITMENT=Mi;exports.RECOVERY_KEYSTORE_TAG=sn;exports.asymmetric=qi;exports.deriveKey=oa;exports.emailCrypto=Va;exports.emailSearch=$l;exports.emailService=Uh;exports.hash=Xc;exports.keyWrapper=Pa;exports.keystoreCrypto=Qh;exports.keystoreService=af;exports.pq=Ia;exports.storage=mf;exports.symmetric=Qc;exports.utils=Pc;
|
|
2053
|
+
`):" "+Ts(o[0]):"as no adapter specified";throw new R("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return n},adapters:en};function Pr(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new $e(null,e)}function As(e){return Pr(e),e.headers=G.from(e.headers),e.data=Ir.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ei.getAdapter(e.adapter||yt.adapter)(e).then(function(n){return Pr(e),n.data=Ir.call(e,e.transformResponse,n),n.headers=G.from(n.headers),n},function(n){return pi(n)||(Pr(e),n&&n.response&&(n.response.data=Ir.call(e,e.transformResponse,n.response),n.response.headers=G.from(n.response.headers))),Promise.reject(n)})}const xi="1.11.0",gr={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{gr[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const _s={};gr.transitional=function(t,r,n){function s(o,i){return"[Axios v"+xi+"] Transitional option '"+o+"'"+i+(n?". "+n:"")}return(o,i,c)=>{if(t===!1)throw new R(s(i," has been removed"+(r?" in "+r:"")),R.ERR_DEPRECATED);return r&&!_s[i]&&(_s[i]=!0,console.warn(s(i," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(o,i,c):!0}};gr.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function Eh(e,t,r){if(typeof e!="object")throw new R("options must be an object",R.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let s=n.length;for(;s-- >0;){const o=n[s],i=t[o];if(i){const c=e[o],a=c===void 0||i(c,o,e);if(a!==!0)throw new R("option "+o+" must be "+a,R.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new R("Unknown option "+o,R.ERR_BAD_OPTION)}}const Pt={assertOptions:Eh,validators:gr},oe=Pt.validators;let ve=class{constructor(t){this.defaults=t||{},this.interceptors={request:new ws,response:new ws}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
2054
|
+
`+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Ae(this.defaults,r);const{transitional:n,paramsSerializer:s,headers:o}=r;n!==void 0&&Pt.assertOptions(n,{silentJSONParsing:oe.transitional(oe.boolean),forcedJSONParsing:oe.transitional(oe.boolean),clarifyTimeoutError:oe.transitional(oe.boolean)},!1),s!=null&&(g.isFunction(s)?r.paramsSerializer={serialize:s}:Pt.assertOptions(s,{encode:oe.function,serialize:oe.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Pt.assertOptions(r,{baseUrl:oe.spelling("baseURL"),withXsrfToken:oe.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=o&&g.merge(o.common,o[r.method]);o&&g.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),r.headers=G.concat(i,o);const c=[];let a=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(r)===!1||(a=a&&f.synchronous,c.unshift(f.fulfilled,f.rejected))});const l=[];this.interceptors.response.forEach(function(f){l.push(f.fulfilled,f.rejected)});let u,h=0,m;if(!a){const p=[As.bind(this),void 0];for(p.unshift(...c),p.push(...l),m=p.length,u=Promise.resolve(r);h<m;)u=u.then(p[h++],p[h++]);return u}m=c.length;let y=r;for(h=0;h<m;){const p=c[h++],f=c[h++];try{y=p(y)}catch(d){f.call(this,d);break}}try{u=As.call(this,y)}catch(p){return Promise.reject(p)}for(h=0,m=l.length;h<m;)u=u.then(l[h++],l[h++]);return u}getUri(t){t=Ae(this.defaults,t);const r=mi(t.baseURL,t.url,t.allowAbsoluteUrls);return hi(r,t.params,t.paramsSerializer)}};g.forEach(["delete","get","head","options"],function(t){ve.prototype[t]=function(r,n){return this.request(Ae(n||{},{method:t,url:r,data:(n||{}).data}))}});g.forEach(["post","put","patch"],function(t){function r(n){return function(o,i,c){return this.request(Ae(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}ve.prototype[t]=r(),ve.prototype[t+"Form"]=r(!0)});let xh=class ki{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});const n=this;this.promise.then(s=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](s);n._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{n.subscribe(c),o=c}).then(s);return i.cancel=function(){n.unsubscribe(o)},i},t(function(o,i,c){n.reason||(n.reason=new $e(o,i,c),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new ki(function(s){t=s}),cancel:t}}};function kh(e){return function(r){return e.apply(null,r)}}function vh(e){return g.isObject(e)&&e.isAxiosError===!0}const tn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(tn).forEach(([e,t])=>{tn[t]=e});function vi(e){const t=new ve(e),r=Qo(ve.prototype.request,t);return g.extend(r,ve.prototype,t,{allOwnKeys:!0}),g.extend(r,t,null,{allOwnKeys:!0}),r.create=function(s){return vi(Ae(e,s))},r}const I=vi(yt);I.Axios=ve;I.CanceledError=$e;I.CancelToken=xh;I.isCancel=pi;I.VERSION=xi;I.toFormData=yr;I.AxiosError=R;I.Cancel=I.CanceledError;I.all=function(t){return Promise.all(t)};I.spread=kh;I.isAxiosError=vh;I.mergeConfig=Ae;I.AxiosHeaders=G;I.formToJSON=e=>di(g.isHTMLForm(e)?new FormData(e):e);I.getAdapter=Ei.getAdapter;I.HttpStatusCode=tn;I.default=I;const{Axios:kf,AxiosError:vf,CanceledError:Sf,isCancel:Tf,CancelToken:Af,VERSION:_f,all:Kf,Cancel:Of,isAxiosError:Rf,spread:Cf,toFormData:If,AxiosHeaders:Pf,HttpStatusCode:jf,formToJSON:Bf,getAdapter:Ff,mergeConfig:Nf}=I;async function Sh(e){try{return(await I.get("/api/getPublicKeys",{params:{emails:e},withCredentials:!0,headers:{"Content-Type":"application/json"}})).data}catch(t){throw I.isAxiosError(t)?t.response?.status===401?new Error("Unauthorized: Invalid or expired token"):t.response?.status===403?new Error("Forbidden: Insufficient permissions"):t.response?.status===404?new Error("User is not found"):new Error("AxiosError:",t):new Error("Failed to retrieve public keys",{cause:t})}}async function Th(e){try{const t=await Sh(e),r=[];for(const n of t){const s=await Eo(n);r.push(s)}return r}catch(t){throw new Error("Failed to get recipients public keys",{cause:t})}}class mt{constructor(t=0,r="Network Error"){this.status=t,this.text=r}}const Ah=()=>{if(!(typeof localStorage>"u"))return{get:e=>Promise.resolve(localStorage.getItem(e)),set:(e,t)=>Promise.resolve(localStorage.setItem(e,t)),remove:e=>Promise.resolve(localStorage.removeItem(e))}},z={origin:"https://api.emailjs.com",blockHeadless:!1,storageProvider:Ah()},Mn=e=>e?typeof e=="string"?{publicKey:e}:e.toString()==="[object Object]"?e:{}:{},_h=(e,t="https://api.emailjs.com")=>{if(!e)return;const r=Mn(e);z.publicKey=r.publicKey,z.blockHeadless=r.blockHeadless,z.storageProvider=r.storageProvider,z.blockList=r.blockList,z.limitRate=r.limitRate,z.origin=r.origin||t},Si=async(e,t,r={})=>{const n=await fetch(z.origin+e,{method:"POST",headers:r,body:t}),s=await n.text(),o=new mt(n.status,s);if(n.ok)return o;throw o},Ti=(e,t,r)=>{if(!e||typeof e!="string")throw"The public key is required. Visit https://dashboard.emailjs.com/admin/account";if(!t||typeof t!="string")throw"The service ID is required. Visit https://dashboard.emailjs.com/admin";if(!r||typeof r!="string")throw"The template ID is required. Visit https://dashboard.emailjs.com/admin/templates"},Kh=e=>{if(e&&e.toString()!=="[object Object]")throw"The template params have to be the object. Visit https://www.emailjs.com/docs/sdk/send/"},Ai=e=>e.webdriver||!e.languages||e.languages.length===0,_i=()=>new mt(451,"Unavailable For Headless Browser"),Oh=(e,t)=>{if(!Array.isArray(e))throw"The BlockList list has to be an array";if(typeof t!="string")throw"The BlockList watchVariable has to be a string"},Rh=e=>!e.list?.length||!e.watchVariable,Ch=(e,t)=>e instanceof FormData?e.get(t):e[t],Ki=(e,t)=>{if(Rh(e))return!1;Oh(e.list,e.watchVariable);const r=Ch(t,e.watchVariable);return typeof r!="string"?!1:e.list.includes(r)},Oi=()=>new mt(403,"Forbidden"),Ih=(e,t)=>{if(typeof e!="number"||e<0)throw"The LimitRate throttle has to be a positive number";if(t&&typeof t!="string")throw"The LimitRate ID has to be a non-empty string"},Ph=async(e,t,r)=>{const n=Number(await r.get(e)||0);return t-Date.now()+n},Ri=async(e,t,r)=>{if(!t.throttle||!r)return!1;Ih(t.throttle,t.id);const n=t.id||e;return await Ph(n,t.throttle,r)>0?!0:(await r.set(n,Date.now().toString()),!1)},Ci=()=>new mt(429,"Too Many Requests"),jh=async(e,t,r,n)=>{const s=Mn(n),o=s.publicKey||z.publicKey,i=s.blockHeadless||z.blockHeadless,c=s.storageProvider||z.storageProvider,a={...z.blockList,...s.blockList},l={...z.limitRate,...s.limitRate};return i&&Ai(navigator)?Promise.reject(_i()):(Ti(o,e,t),Kh(r),r&&Ki(a,r)?Promise.reject(Oi()):await Ri(location.pathname,l,c)?Promise.reject(Ci()):Si("/api/v1.0/email/send",JSON.stringify({lib_version:"4.4.1",user_id:o,service_id:e,template_id:t,template_params:r}),{"Content-type":"application/json"}))},Bh=e=>{if(!e||e.nodeName!=="FORM")throw"The 3rd parameter is expected to be the HTML form element or the style selector of the form"},Fh=e=>typeof e=="string"?document.querySelector(e):e,Nh=async(e,t,r,n)=>{const s=Mn(n),o=s.publicKey||z.publicKey,i=s.blockHeadless||z.blockHeadless,c=z.storageProvider||s.storageProvider,a={...z.blockList,...s.blockList},l={...z.limitRate,...s.limitRate};if(i&&Ai(navigator))return Promise.reject(_i());const u=Fh(r);Ti(o,e,t),Bh(u);const h=new FormData(u);return Ki(a,h)?Promise.reject(Oi()):await Ri(location.pathname,l,c)?Promise.reject(Ci()):(h.append("lib_version","4.4.1"),h.append("service_id",e),h.append("template_id",t),h.append("user_id",o),Si("/api/v1.0/email/send-form",h))},Lh={init:_h,send:jh,sendForm:Nh,EmailJSResponseStatus:mt},Dh={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Ze={getVariable:Uh},Mh={serviceID:"VITE_SERVICE_ID",templateID:"VITE_TEMPLATE_ID",publicKey:"VITE_PUBLIC_KEY",baseUrl:"VITE_BASE_URL"};function Uh(e){const t=Mh[e];if(!t)throw new Error(`Unknown variable name: "${e}"`);const r=Dh[t];if(!r)throw new Error(`Variable "${e}" is empty`);return r}async function Ii(e,t){try{const r={from_email:t.sender.email,from_name:t.sender.name,to_email:t.recipient.email,to_name:t.recipient.name,email_subject:t.subject,email_body:e,timestamp:new Date().toISOString()},n=Ze.getVariable("serviceID"),s=Ze.getVariable("templateID"),o=Ze.getVariable("publicKey");await Lh.send(n,s,r,o).then(i=>{console.log("SUCCESS!",i.status,i.text)},i=>{throw new Error(`emailjs error: ${i}`)})}catch(r){throw new Error("Failed to send an email",{cause:r})}}async function Hh(e){try{if(e.recipientID!==e.params.recipient.id)throw new Error("Email is encrypted for another recipient");const t=vo(e);await Ii(t,e.params)}catch(t){throw new Error(`Failed to email to the recipient: ${t.message}`,{cause:t})}}async function zh(e){try{const t=So(e);await Ii(t,e.params)}catch(t){throw new Error("Failed to email to the recipient",{cause:t})}}const $h=Object.freeze(Object.defineProperty({__proto__:null,getRecipientsPublicKeys:Th,sendHybridEmail:Hh,sendPwdProtectedEmail:zh},Symbol.toStringTag,{value:"Module"}));var W=(e=>(e.IDENTITY="identity",e.ENCRYPTION="encryption",e.RECOVERY="recovery",e.INDEX="index",e))(W||{});function Yh(e){return sessionStorage.getItem(e)}function Vh(e,t){return sessionStorage.setItem(e,t)}function Jh(e){sessionStorage.removeItem(e)}function Gh(e){return!!sessionStorage.getItem(e)}function Xh(){sessionStorage.clear()}const Un={set:Vh,get:Yh,removeItem:Jh,exists:Gh,clear:Xh},qh=Object.freeze(Object.defineProperty({__proto__:null,default:Un},Symbol.toStringTag,{value:"Module"}));async function rn(e,t,r,n){try{const s=r+n,o=D(t);return await sr(e,o,s)}catch(s){throw new Error("Failed to encrypt keystore content",{cause:s})}}async function Hn(e,t,r,n){try{const s=r+n,o=await tt(e,t,s);return U(o)}catch(s){throw new Error("Failed to decrypt keystore content",{cause:s})}}function wr(){try{const e=Un.get("userID");if(!e)throw new Error("No UserID");return e}catch(e){throw new Error("Failed to get UserID from session storage",{cause:e})}}function br(){try{const e=Un.get("baseKey");if(!e)throw new Error("No base key");return D(e)}catch(e){throw new Error("Failed to get base key from session storage",{cause:e})}}async function Pi(e){return ht(Cs,e)}async function ji(e){const t=await Ue(V,e);return ht(Ps,t)}async function Bi(e){return ht(Is,e)}function Fi(){return so(V)}async function Ni(){try{const e=await qt(),t=vn();return{userPrivateKey:e.privateKey,userPublicKey:e.publicKey,userPublicKyberKey:t.publicKey,userPrivateKyberKey:t.secretKey}}catch(e){throw new Error("Failed to generate encryption keys",{cause:e})}}async function Wh(){try{const e=wr(),t=br(),r=await Ni(),n=await Ys(r),s=await Bi(t),o=await rn(s,n,e,sn),i={userID:e,type:W.ENCRYPTION,encryptedKeys:o},c=Fi(),a=await ji(c),l=await rn(a,n,e,on),u={userID:e,type:W.RECOVERY,encryptedKeys:l};return{encryptionKeystore:i,recoveryKeystore:u,recoveryCodes:c}}catch(e){throw new Error("Failed to create encryption and recovery keystores",{cause:e})}}async function Zh(e){try{if(e.type!=W.ENCRYPTION)throw new Error("Input is invalid");const t=br(),r=await Bi(t),n=await Hn(r,e.encryptedKeys,e.userID,sn);return await hn(n)}catch(t){throw new Error("Failed to open encryption keystore",{cause:t})}}async function Qh(e,t){try{if(t.type!=W.RECOVERY)throw new Error("Input is invalid");const r=await ji(e),n=await Hn(r,t.encryptedKeys,t.userID,on);return await hn(n)}catch(r){throw new Error("Failed to open recovery keystore",{cause:r})}}async function Li(){try{const e=await qt();return{userPrivateKey:e.privateKey,userPublicKey:e.publicKey}}catch(e){throw new Error("Failed to generate idenity keys",{cause:e})}}async function ef(){try{const e=W.IDENTITY,t=wr(),r=br(),n=await Li(),s=await $s(n),o=await Pi(r),i=await rn(o,s,t,nn);return{userID:t,type:e,encryptedKeys:i}}catch(e){throw new Error("Failed to create identity keystore",{cause:e})}}async function tf(e){try{if(e.type!=W.IDENTITY)throw new Error("Input is invalid");const t=br(),r=await Pi(t),n=await Hn(r,e.encryptedKeys,e.userID,nn);return await Js(n)}catch(t){throw new Error("Failed to open identity keystore",{cause:t})}}const rf=Object.freeze(Object.defineProperty({__proto__:null,createEncryptionAndRecoveryKeystores:Wh,createIdentityKeystore:ef,generateEncryptionKeys:Ni,generateIdentityKeys:Li,generateRecoveryCodes:Fi,openEncryptionKeystore:Zh,openIdentityKeystore:tf,openRecoveryKeystore:Qh},Symbol.toStringTag,{value:"Module"}));async function nf(e,t){try{const r=Ze.getVariable("baseUrl");return await I.post(r+`${t}`,{encryptedKeystore:e},{withCredentials:!0,headers:{"Content-Type":"application/json"}})}catch(r){throw I.isAxiosError(r)?r.response?.status===401?new Error("Unauthorized: Invalid or expired token"):r.response?.status===403?new Error("Forbidden: Insufficient permissions"):new Error("AxiosError:",r):new Error("Failed to send keystore",{cause:r})}}async function sf(e){try{const t=Ze.getVariable("baseUrl");return(await I.get(t+`${e}`,{withCredentials:!0,headers:{"Content-Type":"application/json"}})).data}catch(t){throw I.isAxiosError(t)?t.response?.status===401?new Error("Unauthorized: Invalid or expired token"):t.response?.status===403?new Error("Forbidden: Insufficient permissions"):t.response?.status===404?new Error("Keystore not found for the specified user"):new Error("AxiosError:",t):new Error("Failed to retrive keystore",{cause:t})}}async function of(e){try{const t=wr(),r=e.type,n=`/uploadKeystore/${t}/${r}`,s=Vs(e);return await nf(s,n)}catch(t){throw new Error("Failed to upload keystore to the server",{cause:t})}}async function cf(){return Er(W.ENCRYPTION)}async function af(){return Er(W.IDENTITY)}async function lf(){return Er(W.RECOVERY)}async function uf(){return Er(W.INDEX)}async function Er(e){try{const t=wr(),r=e.toString(),n=`/downloadKeystore/${t}/${r}`,s=await sf(n);return Gs(s)}catch(t){throw new Error("Failed to retrieve keystore from the server",{cause:t})}}const hf=Object.freeze(Object.defineProperty({__proto__:null,getEncryptionKeystoreFromServer:cf,getIdentityKeystoreFromServer:af,getIndexKeystoreFromServer:uf,getRecoveryKeystoreFromServer:lf,uploadKeystoreToServer:of},Symbol.toStringTag,{value:"Module"}));function ff(e){return localStorage.getItem(e)}function df(e,t){return localStorage.setItem(e,t)}function pf(e){localStorage.removeItem(e)}function yf(e){return!!localStorage.getItem(e)}function mf(){localStorage.clear()}const gf={set:df,get:ff,removeItem:pf,exists:yf,clear:mf},wf=Object.freeze(Object.defineProperty({__proto__:null,default:gf},Symbol.toStringTag,{value:"Module"})),bf=Object.freeze(Object.defineProperty({__proto__:null,localStorageService:wf,sessionStorageService:qh},Symbol.toStringTag,{value:"Module"}));exports.AES_ALGORITHM=Le;exports.AES_KEY_BIT_LENGTH=V;exports.ARGON2ID_ITERATIONS=Ls;exports.ARGON2ID_MEMORY_SIZE=Ds;exports.ARGON2ID_OUTPUT_BYTE_LENGTH=Us;exports.ARGON2ID_PARALLELISM=Ns;exports.ARGON2ID_SALT_BYTE_LENGTH=Ms;exports.AUX_LEN=Ks;exports.CONTEXT_DERIVE=Bs;exports.CONTEXT_ENC_KEYSTORE=Is;exports.CONTEXT_INDEX=js;exports.CONTEXT_LOGIN=Cs;exports.CONTEXT_RATCHET=jr;exports.CONTEXT_RECOVERY=Ps;exports.CONTEXT_WRAPPING=Rs;exports.DB_LABEL=q;exports.DB_VERSION=zs;exports.ECC_ALGORITHM=lt;exports.ENCRYPTION_KEYSTORE_TAG=sn;exports.HASH_BIT_LEN=ut;exports.IDENTITY_KEYSTORE_TAG=nn;exports.INDEX_KEYSTORE_TAG=Hi;exports.IV_LEN_BYTES=Os;exports.KEY_FORMAT=De;exports.KEY_WRAPPING_ALGORITHM=Xt;exports.KYBER1024_PUBLIC_KEY_LENGTH=Ji;exports.KYBER1024_SECRET_KEY_LENGTH=Gi;exports.KYBER512_PUBLIC_KEY_LENGTH=zi;exports.KYBER512_SECRET_KEY_LENGTH=$i;exports.KYBER768_PUBLIC_KEY_LENGTH=Yi;exports.KYBER768_SECRET_KEY_LENGTH=Vi;exports.KYBER_SEED_LENGTH=Xi;exports.KeystoreType=W;exports.MAX_CACHE_SIZE=Hs;exports.MAX_EMAIL_PER_BATCH=Br;exports.PREFIX_IDENTITY_KEY_COMMITMENT=Ui;exports.PREFIX_MEDIA_KEY_COMMITMENT=Fs;exports.PREFIX_PUBLIC_KEY_COMMITMENT=Mi;exports.RECOVERY_KEYSTORE_TAG=on;exports.asymmetric=qi;exports.deriveKey=aa;exports.emailCrypto=Xa;exports.emailSearch=Jl;exports.emailService=$h;exports.hash=Lc;exports.keyWrapper=Fa;exports.keystoreCrypto=rf;exports.keystoreService=hf;exports.pq=Ba;exports.storage=bf;exports.symmetric=ra;exports.utils=Pc;
|
|
2055
2055
|
//# sourceMappingURL=index.js.map
|