@graffiti-garden/implementation-decentralized 0.1.6 → 0.1.8
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/3-protocol/4-graffiti.d.ts +1 -0
- package/dist/3-protocol/4-graffiti.d.ts.map +1 -1
- package/dist/browser/index.js +6 -6
- package/dist/browser/index.js.map +3 -3
- package/dist/browser/{style-BOBMBTYJ-2YZTO5FX.js → style-EDM5B7ME-CSVOYXSW.js} +11 -2
- package/dist/browser/{style-BOBMBTYJ-2YZTO5FX.js.map → style-EDM5B7ME-CSVOYXSW.js.map} +2 -2
- package/dist/cjs/3-protocol/4-graffiti.js +26 -11
- package/dist/cjs/3-protocol/4-graffiti.js.map +2 -2
- package/dist/esm/3-protocol/4-graffiti.js +26 -11
- package/dist/esm/3-protocol/4-graffiti.js.map +2 -2
- package/package.json +2 -2
- package/src/3-protocol/4-graffiti.ts +34 -17
package/dist/browser/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{a as vp,b as Ap,c as
|
|
2
|
-
`)===0?L.substr(1,L.length):L}).forEach(function(L){var H=L.split(":"),N=H.shift().trim();if(N){var Fe=H.join(":").trim();try{E.append(N,Fe)}catch(Pt){console.warn("Response "+Pt.message)}}}),E}_.call(v.prototype);function z(m,E){if(!(this instanceof z))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(E||(E={}),this.type="default",this.status=E.status===void 0?200:E.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=E.statusText===void 0?"":""+E.statusText,this.headers=new f(E.headers),this.url=E.url||"",this._initBody(m)}_.call(z.prototype),z.prototype.clone=function(){return new z(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},z.error=function(){var m=new z(null,{status:200,statusText:""});return m.ok=!1,m.status=0,m.type="error",m};var V=[301,302,303,307,308];z.redirect=function(m,E){if(V.indexOf(E)===-1)throw new RangeError("Invalid status code");return new z(null,{status:E,headers:{location:m}})},n.DOMException=r.DOMException;try{new n.DOMException}catch{n.DOMException=function(E,U){this.message=E,this.name=U;var L=Error(E);this.stack=L.stack},n.DOMException.prototype=Object.create(Error.prototype),n.DOMException.prototype.constructor=n.DOMException}function J(m,E){return new Promise(function(U,L){var H=new v(m,E);if(H.signal&&H.signal.aborted)return L(new n.DOMException("Aborted","AbortError"));var N=new XMLHttpRequest;function Fe(){N.abort()}N.onload=function(){var te={statusText:N.statusText,headers:I(N.getAllResponseHeaders()||"")};H.url.indexOf("file://")===0&&(N.status<200||N.status>599)?te.status=200:te.status=N.status,te.url="responseURL"in N?N.responseURL:te.headers.get("X-Request-URL");var le="response"in N?N.response:N.responseText;setTimeout(function(){U(new z(le,te))},0)},N.onerror=function(){setTimeout(function(){L(new TypeError("Network request failed"))},0)},N.ontimeout=function(){setTimeout(function(){L(new TypeError("Network request timed out"))},0)},N.onabort=function(){setTimeout(function(){L(new n.DOMException("Aborted","AbortError"))},0)};function Pt(te){try{return te===""&&r.location.href?r.location.href:te}catch{return te}}if(N.open(H.method,Pt(H.url),!0),H.credentials==="include"?N.withCredentials=!0:H.credentials==="omit"&&(N.withCredentials=!1),"responseType"in N&&(o.blob?N.responseType="blob":o.arrayBuffer&&(N.responseType="arraybuffer")),E&&typeof E.headers=="object"&&!(E.headers instanceof f||r.Headers&&E.headers instanceof r.Headers)){var Vr=[];Object.getOwnPropertyNames(E.headers).forEach(function(te){Vr.push(c(te)),N.setRequestHeader(te,u(E.headers[te]))}),H.headers.forEach(function(te,le){Vr.indexOf(le)===-1&&N.setRequestHeader(le,te)})}else H.headers.forEach(function(te,le){N.setRequestHeader(le,te)});H.signal&&(H.signal.addEventListener("abort",Fe),N.onreadystatechange=function(){N.readyState===4&&H.signal.removeEventListener("abort",Fe)}),N.send(typeof H._bodyInit>"u"?null:H._bodyInit)})}return J.polyfill=!0,r.fetch||(r.fetch=J,r.Headers=f,r.Request=v,r.Response=z),n.Headers=f,n.Request=v,n.Response=z,n.fetch=J,n})({})})(Ho);Ho.fetch.ponyfill=!0;delete Ho.fetch.polyfill;var kn=Fo.fetch?Fo:Ho;vt=kn.fetch;vt.default=kn.fetch;vt.fetch=kn.fetch;vt.Headers=kn.Headers;vt.Request=kn.Request;vt.Response=kn.Response;Vf.exports=vt});function ac(e){let t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function cc(e,t){return typeof t=="bigint"?t.toString():t}function uc(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function Xr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Li(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Rp(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}var Ni="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Yr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Jn(e){if(Yr(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(Yr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}var lc=new Set(["string","number","symbol"]);function Bi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Kn(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function ne(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function fc(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var dc={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function pc(e,t){if(!Jn(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let i=e._zod.def.shape;for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=Rp(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Li(this,"shape",i),i}});return Kn(e,o)}function zt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function hc(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function He(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function qn(e){return typeof e=="string"?e:e?.message}function ji(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function ot(e,t,n){var r;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:qn(e.inst?._zod.def?.error?.(e))??qn(i?.(e))??qn(t?.error?.(e))??qn(n.customError?.(e))??qn(n.localeError?.(e))??"Invalid input",{inst:a,schema:c,continue:u,input:l,...f}=e;return f.path??(f.path=[]),f.message=s,t?.reportInput&&(f.input=l),f}function Zi(...e){let[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function mc(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Pp(e,n,r.value)}}function It(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function gc(e,t,n){return It(e,t,n,!1)}function Pp(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:It(this,t,n.bind(this))},set(r){It(this,t,r)}})}function Op(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Mi,ht=!1,kp={configurable:!0,get(){ht=!0}};function Ee(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Mi!==e._zod){Mi=void 0;return}Mi=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,kp);let o=ht;ht=!1;try{let i=n(this);return ht?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),ht=ht||o,i}catch(i){throw delete this[t],ht=ht||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function yc(e,t,n,r){let o=Op(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,i),i.value=n(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:i})}})}var wc;var Fi={value:void 0,enumerable:!1},bc="captureStackTrace"in Error?Error:null;function Ip(e){let t=bc;if(t){let n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return bc=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function C(e,t,n,r){let o={};function i(p){this.def=p,this.constr=f,this.traits=new Set}i.prototype=o;let s=n,a=s&&new WeakSet;function c(p,g){if(!p._zod){Fi.value=new i(g);try{Object.defineProperty(p,"_zod",Fi)}finally{Fi.value=void 0}}if(p._zod.traits.has(e))return;if(p._zod.traits.add(e),t(p,g),a){let x=Object.getPrototypeOf(p),A=p._zod.constr.prototype,h=x;for(;h&&h!==A;)h=Object.getPrototypeOf(h);let _=h??x;a.has(_)||(a.add(_),mc(_,s))}let w=f.prototype;for(let x in w)Object.prototype.hasOwnProperty.call(w,x)&&(x in p||(p[x]=w[x].bind(p)))}let u=r?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function f(p){let g=r?.Parent?Ip(l):this;c(g,p);let w=g._zod.deferred;if(w){for(let A of w)A();g._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;return x&&x(g),g}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:p=>r?.Parent&&p instanceof r.Parent?!0:p?._zod?.traits?.has(e)}),Object.defineProperty(f,"name",{value:e}),f}var it=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(wc=globalThis).__zod_globalConfig??(wc.__zod_globalConfig={});var Ct=globalThis.__zod_globalConfig;function st(e){return e&&Object.assign(Ct,e),Ct}function zp(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,cc,2)),e.message}function $p(e){this._zod.message=e}var Cp={get:zp,set:$p,enumerable:!0,configurable:!0},Gi={value:void 0,enumerable:!1},qi={value:void 0,enumerable:!1},_c=new WeakSet([Object.prototype,Error.prototype]),xc=(e,t)=>{e.name="$ZodError",Gi.value=e._zod,Object.defineProperty(e,"_zod",Gi),qi.value=t,Object.defineProperty(e,"issues",qi),Gi.value=void 0,qi.value=void 0,Object.defineProperty(e,"message",Cp);let n=Object.getPrototypeOf(e);_c.has(n)||(_c.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},Ec=C("$ZodError",xc),Vn=C("$ZodError",xc,void 0,{Parent:Error});var Up=e=>{let t=(n,r,o,i)=>{let s=o?{...o,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new it;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map(u=>ot(u,s,st())));throw Ni(c,i?.callee??t),c}return a.value};return t},Qr=Up(Vn),Mp=e=>{let t=async(n,r,o,i)=>{let s=o?{...o,async:!0}:{async:!0},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(i?.Err??e)(a.issues.map(u=>ot(u,s,st())));throw Ni(c,i?.callee??t),c}return a.value};return t},eo=Mp(Vn),Lp=e=>(t,n,r)=>{let o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new it;return i.issues.length?{success:!1,error:new(e??Ec)(i.issues.map(s=>ot(s,o,st())))}:{success:!0,data:i.value}},Wn=Lp(Vn),Np=e=>async(t,n,r)=>{let o=r?{...r,async:!0}:{async:!0},i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>ot(s,o,st())))}:{success:!0,data:i.value}},Yn=Np(Vn);var Sc=/^https?$/;var vc=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Ac=/^-?\d+$/,Ji=/^-?\d+(?:\.\d+)?$/,Tc=/^(?:true|false)$/i;var Rc=/^undefined$/i;var Dt=C("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Pc={number:"number",bigint:"bigint",object:"date"};var Oc=C("$ZodCheckGreaterThan",(e,t)=>{Dt.init(e,t);let n=Pc[typeof t.value];e._zod.onattach.push(r=>{let o=r._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Pc[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}});var kc=C("$ZodCheckNumberFormat",(e,t)=>{Dt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[o,i]=dc[t.format];e._zod.onattach.push(s=>{let a=s._zod.bag;a.format=t.format,a.minimum=o,a.maximum=i,n&&(a.pattern=Ac)}),e._zod.check=s=>{let a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}});var Ic=C("$ZodCheckStringFormat",(e,t)=>{var n,r;Dt.init(e,t),e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})});var $c={major:4,minor:5,patch:4};var oe=C("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=$c;let r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let i of o)for(let s of i._zod.onattach)s(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,c,u)=>{if(a.memo)return a;let l=zt(a),f;for(let p of c){if(p._zod.def.when){if(hc(a)||!p._zod.def.when(a))continue}else if(l)continue;let g=a.issues.length,w=p._zod.check(a);if(w instanceof Promise&&u?.async===!1)throw new it;if(f||w instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await w,a.issues.length!==g&&(ji(a.issues,g,e),l||(l=zt(a,g)))});else{if(a.issues.length===g)continue;ji(a.issues,g,e),l||(l=zt(a,g))}}return f?f.then(()=>a):a},s=(a,c,u)=>{if(zt(a))return a.aborted=!0,a;let l=i(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new it;return l.then(f=>e._zod.parse(f,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(f=>s(f,a,c)):s(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new it;return u.then(l=>i(l,o,c))}return i(u,o,c)}}},{get"~standard"(){return gc(this,"~standard",Bp(this))},set"~standard"(e){It(this,"~standard",e)}}),Cc=e=>e.success?{value:e.data}:{issues:e.error?.issues};function Bp(e){return{validate:t=>{try{return Cc(Wn(e,t))}catch{return Yn(e,t).then(Cc)}},vendor:"zod",version:1}}var Wi=C("$ZodString",(e,t)=>{oe.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??vc(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Yi=C("$ZodStringFormat",(e,t)=>{Ic.init(e,t),Wi.init(e,t)});var Hc=1,Gc=2;function jp(e,t){if(!t.normalize&&t.protocol?.source===Sc.source&&!/^https?:\/\//i.test(e))return Hc;try{return new URL(e)}catch{return Gc}}var Zp=/[\t\n\r]/g;function Fp(e){return e.replace(Zp,"")}function Hp(e,t){return t.lastIndex=0,t.test(e.hostname)}function Gp(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var qc=C("$ZodURL",(e,t)=>{Yi.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),o=jp(r,t);if(o===Hc){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===Gc){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!Hp(o,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Gp(o,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?o.href:Fp(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}});var Xi=C("$ZodNumber",(e,t)=>{oe.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ji,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),Jc=C("$ZodNumberFormat",(e,t)=>{kc.init(e,t),Xi.init(e,t)}),Kc=C("$ZodBoolean",(e,t)=>{oe.init(e,t),e._zod.pattern=Tc,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}});var Vc=C("$ZodUndefined",(e,t)=>{oe.init(e,t),e._zod.pattern=Rc,e._zod.values=new Set([void 0]),e._zod.parse=(n,r)=>{let o=n.value;return typeof o>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),n}});var Wc=C("$ZodUnknown",(e,t)=>{oe.init(e,t),e._zod.parse=n=>n}),Yc=C("$ZodNever",(e,t)=>{oe.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Dc(e,t,n){e.issues.length&&t.issues.push(...He(n,e.issues)),t.value[n]=e.value}var Xc=C("$ZodArray",(e,t)=>{oe.init(e,t);let n=Ct.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);let s=[];for(let a=0;a<i.length;a++){let c=i[a],u=t.element._zod.run({value:c,issues:[]},o);u instanceof Promise?s.push(u.then(l=>Dc(l,r,a))):Dc(u,r,a)}return s.length?Promise.all(s).then(()=>r):r}});function to(e,t,n,r,o,i){let s=n in r,a=i==="optional";if(!(!s&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!s)return;t.issues.push(...He(n,e.issues))}if(!s&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?s&&(t.value[n]=void 0):t.value[n]=e.value}}var qp=[];function Jp(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:qp,o=r.length?[...t,...r]:t;for(let s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=fc(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function Kp(e,t,n,r,o,i){let s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,l=c.optin,f=c.optout;for(let p in t){if(a.has(p))continue;if(p==="__proto__"){u==="never"&&s.push(p);continue}if(u==="never"){s.push(p);continue}let g=c.run({value:t[p],issues:[]},r);g instanceof Promise?e.push(g.then(w=>to(w,n,p,t,l,f))):to(g,n,p,t,l,f)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var Uc=new WeakMap,Qc=C("$ZodObject",(e,t)=>{if(oe.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Uc.set(t,c),Object.defineProperty(t,"shape",{get:()=>{let u={...c};return Object.defineProperty(t,"shape",{value:u}),Uc.set(t,u),u}})}let r=uc(()=>Jp(t));Ee(e,"propValues",c=>{let u=c.def.shape,l={};for(let f in u){let p=u[f]._zod;if(p.values){Object.prototype.hasOwnProperty.call(l,f)||Li(l,f,new Set);for(let g of p.values)l[f].add(g);p.optin!==void 0&&l[f].add(void 0)}}return l});let o=Yr,i=t.catchall,s,a=Ct.memoizer;a?.attach(e),e._zod.parse=(c,u)=>{s??(s=r.value);let l=c.value;if(!o(l))return c.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),c;c.value=a?a.alloc(e,c,{},u):{};let f=[],p=s.shape;for(let g of s.allKeys){if(g==="__proto__")continue;let w=p[g],x=w._zod.optin,A=w._zod.optout,h=w._zod.run({value:l[g],issues:[]},u);h instanceof Promise?f.push(h.then(_=>to(_,c,g,l,x,A))):to(h,c,g,l,x,A)}return i?Kp(f,l,c,u,r.value,e):f.length?Promise.all(f).then(()=>c):c}});function Mc(e,t,n,r){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter(i=>!zt(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>ot(s,r,st())))}),t)}var eu=C("$ZodUnion",(e,t)=>{oe.init(e,t),Ee(e,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),Ee(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Ee(e,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),Ee(e,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){let o=r.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>Xr(i.source)).join("|")})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}return i?Promise.all(s).then(a=>Mc(a,r,e,o)):Mc(s,r,e,o)}});var tu=C("$ZodIntersection",(e,t)=>{oe.init(e,t),e._zod.parse=(n,r)=>{let o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([c,u])=>Lc(n,c,u)):Lc(n,i,s)}});function Vi(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Jn(e)&&Jn(t)){let n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let i of r){if(i==="__proto__")continue;let s=Vi(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t[r],s=Vi(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Lc(e,t,n){let r=new Map,o,i=new Map,s=(u,l)=>{let f;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),f=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let p=String(u.path[0]);i.has(p)||i.set(p,u),f=[p]}else return!1;for(let p of f)r.has(p)||r.set(p,{}),r.get(p)[l]=!0;return!0};for(let u of t.issues)s(u,"l")||e.issues.push(u);for(let u of n.issues)s(u,"r")||e.issues.push(u);let a=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(let l of a)!u.includes(l)&&i.has(l)&&e.issues.push(i.get(l))}let c=Vi(t.value,n.value);if(!c.valid){if(zt(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var nu=C("$ZodTuple",(e,t)=>{oe.init(e,t);let n=t.items,r=Ct.memoizer;r?.attach(e),e._zod.parse=(o,i)=>{let s=o.value;if(!Array.isArray(s))return o.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];let a=[],c=Nc(n,"optin"),u=Nc(n,"optout");if(!t.rest){if(s.length<c)return o.issues.push({code:"too_small",minimum:c,inclusive:!0,input:s,inst:e,origin:"array"}),o;s.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}let l=new Array(n.length);for(let f=0;f<n.length;f++){let p=n[f]._zod.run({value:s[f],issues:[]},i);p instanceof Promise?a.push(p.then(g=>{l[f]=g})):l[f]=p}if(t.rest){let f=n.length-1,p=s.slice(n.length);for(let g of p){f++;let w=t.rest._zod.run({value:g,issues:[]},i);w instanceof Promise?a.push(w.then(x=>Bc(x,o,f))):Bc(w,o,f)}}return a.length?Promise.all(a).then(()=>jc(l,o,n,s,u)):jc(l,o,n,s,u)}});function Nc(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function Bc(e,t,n){e.issues.length&&t.issues.push(...He(n,e.issues)),t.value[n]=e.value}function jc(e,t,n,r,o){for(let i=0;i<n.length;i++){let s=e[i],a=i<r.length;if(!a&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(s.issues.length){if(!a&&i>=o){t.value.length=i;break}t.issues.push(...He(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=r.length&&(n[i]._zod.optout==="optional"&&t.value[i]===void 0);i--)t.value.length=i;return t}var ru=C("$ZodRecord",(e,t)=>{oe.init(e,t);let n=Ct.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Jn(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},o):{};let c=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let f=t.keyType._zod.run({value:l,issues:[]},o);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(w=>ot(w,o,st())),input:l,path:[l],inst:e});continue}let p=f.value;if(p==="__proto__")continue;let g=t.valueType._zod.run({value:i[l],issues:[]},o);g instanceof Promise?s.push(g.then(w=>{w.issues.length&&r.issues.push(...He(l,w.issues)),r.value[p]=w.value})):(g.issues.length&&r.issues.push(...He(l,g.issues)),r.value[p]=g.value)}let u;for(let l in i)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;r.value[l]=i[l]}else u=u??[],u.push(l);u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{r.value=n?n.alloc(e,r,{},o):{};let c;for(let u of Reflect.ownKeys(i)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&Ji.test(u)&&l.issues.length){let w=t.keyType._zod.run({value:Number(u),issues:[]},o);if(w instanceof Promise)throw new Error("Async schemas not supported in object keys currently");w.issues.length===0&&(l=w)}if(l.issues.length){t.mode==="loose"?r.value[u]=i[u]:a?(c=c??[],c.push(u)):r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(w=>ot(w,o,st())),input:u,path:[u],inst:e});continue}let p=l.value;if(p==="__proto__")continue;let g=t.valueType._zod.run({value:i[u],issues:[]},o);g instanceof Promise?s.push(g.then(w=>{w.issues.length&&r.issues.push(...He(u,w.issues)),r.value[p]=w.value})):(g.issues.length&&r.issues.push(...He(u,g.issues)),r.value[p]=g.value)}c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}return s.length?Promise.all(s).then(()=>r):r}});var ou=C("$ZodEnum",(e,t)=>{oe.init(e,t);let n=ac(t.entries),r=new Set(n);e._zod.values=r;let o=n.filter(i=>lc.has(typeof i));e._zod.pattern=new RegExp(o.length?`^(${o.map(i=>Bi(i.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(i,s)=>{let a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:n,input:a,inst:e}),i}});function Zc(e,t){return e.value=t.issues.length?void 0:t.value,e}var iu=C("$ZodOptional",(e,t)=>{oe.init(e,t),Ee(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",Ee(e,"values",n=>{let r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),Ee(e,"pattern",n=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Xr(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>Zc(n,i)):Zc(n,o)}return t.innerType._zod.run(n,r)}});var su=C("$ZodNullable",(e,t)=>{oe.init(e,t),Ee(e,"optin",n=>n.def.innerType._zod.optin),Ee(e,"optout",n=>n.def.innerType._zod.optout),Ee(e,"pattern",n=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Xr(r.source)}|null)$`):void 0}),Ee(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)});var au=C("$ZodCustom",(e,t)=>{Dt.init(e,t),oe.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{let r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>Fc(i,n,r,e));Fc(o,n,r,e)}});function Fc(e,t,n,r){if(!e){let o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Zi(o))}}function cu(e,t){return new e({type:"string",...ne(t)})}function uu(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ne(t)})}function lu(e,t){return new e({type:"number",checks:[],...ne(t)})}function fu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ne(t)})}function du(e,t){return new e({type:"boolean",...ne(t)})}function pu(e,t){return new e({type:"undefined",...ne(t)})}function hu(e){return new e({type:"unknown"})}function mu(e,t){return new e({type:"never",...ne(t)})}function Qi(e,t){return new Oc({check:"greater_than",...ne(t),value:e,inclusive:!0})}function Ut(e){return Qi(0,e)}function gu(e,t,n){let r=ne(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}var de=C("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");oe.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){It(this,"with",e)},parse(e,t){return Qr(this,e,t,{callee:this.parse})},parseAsync(e,t){return eo(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return Wn(this,e,t)},safeParseAsync(e,t){return Yn(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0})},clone(e,t){return Kn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}}),wu=C("ZodMiniString",(e,t)=>{Wi.init(e,t),de.init(e,t)});function B(e){return cu(wu,e)}var Yp=C("ZodMiniStringFormat",(e,t)=>{Yi.init(e,t),wu.init(e,t)});var Xp=C("ZodMiniURL",(e,t)=>{qc.init(e,t),Yp.init(e,t)});function Z(e){return uu(Xp,e)}var bu=C("ZodMiniNumber",(e,t)=>{Xi.init(e,t),de.init(e,t)});function _u(e){return lu(bu,e)}var Qp=C("ZodMiniNumberFormat",(e,t)=>{Jc.init(e,t),bu.init(e,t)});function nn(e){return fu(Qp,e)}var eh=C("ZodMiniBoolean",(e,t)=>{Kc.init(e,t),de.init(e,t)});function rn(e){return du(eh,e)}var th=C("ZodMiniUndefined",(e,t)=>{Vc.init(e,t),de.init(e,t)});function xu(e){return pu(th,e)}var nh=C("ZodMiniUnknown",(e,t)=>{Wc.init(e,t),de.init(e,t)});function rh(){return hu(nh)}var oh=C("ZodMiniNever",(e,t)=>{Yc.init(e,t),de.init(e,t)});function ih(e){return mu(oh,e)}var sh=C("ZodMiniArray",(e,t)=>{Xc.init(e,t),de.init(e,t)});function q(e,t){return new sh({type:"array",element:e,...ne(t)})}var es=C("ZodMiniObject",(e,t)=>{Qc.init(e,t),de.init(e,t),yc(e,"shape",n=>n._zod.def.shape,!1)});function Se(e,t){let n={type:"object",shape:e??{},...ne(t)};return new es(n)}function ye(e,t){return new es({type:"object",shape:e,catchall:ih(),...ne(t)})}function we(e,t){return new es({type:"object",shape:e,catchall:rh(),...ne(t)})}function at(e,t){return pc(e,t)}var ah=C("ZodMiniUnion",(e,t)=>{eu.init(e,t),de.init(e,t)});function ct(e,t){return new ah({type:"union",options:e,...ne(t)})}var ch=C("ZodMiniIntersection",(e,t)=>{tu.init(e,t),de.init(e,t)});function Eu(e,t){return new ch({type:"intersection",left:e,right:t})}var uh=C("ZodMiniTuple",(e,t)=>{nu.init(e,t),de.init(e,t)});function me(e,t,n){let r=t instanceof oe,o=r?n:t,i=r?t:null;return new uh({type:"tuple",items:e,rest:i,...ne(o)})}var yu=C("ZodMiniRecord",(e,t)=>{ru.init(e,t),de.init(e,t)});function Su(e,t,n){return!t||!t._zod?new yu({type:"record",keyType:B(),valueType:e,...ne(t)}):new yu({type:"record",keyType:e,valueType:t,...ne(n)})}var lh=C("ZodMiniEnum",(e,t)=>{ou.init(e,t),de.init(e,t),e.options=Object.values(t.entries)});function vu(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new lh({type:"enum",entries:n,...ne(t)})}var fh=C("ZodMiniOptional",(e,t)=>{iu.init(e,t),de.init(e,t)});function X(e){return new fh({type:"optional",innerType:e})}var dh=C("ZodMiniNullable",(e,t)=>{su.init(e,t),de.init(e,t)});function Ue(e){return new dh({type:"nullable",innerType:e})}var ph=C("ZodMiniCustom",(e,t)=>{au.init(e,t),de.init(e,t)});function Mt(e,t){return gu(ph,e??(()=>!0),t)}function on(e,t={}){let n=Mt(r=>r instanceof e,t);return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}var Ru=we({value:we({}),channels:q(B()),allowed:X(Ue(q(Z())))}),PS=at(Ru,{url:Z(),actor:Z()}),Au=ct([we({url:Z()}),Z()]),sn=we({actor:Z()}),no=X(Ue(sn)),Tu=ct([rn(),we({})]),Pu=we({data:on(Blob),allowed:X(Ue(q(Z())))}),OS=at(Pu,{actor:Z()}),mh=we({types:X(q(B())),maxBytes:X(nn().check(Ut()))}),ro=class{constructor(t){this.graffiti=t,this.sessionEvents=this.graffiti.sessionEvents}graffiti;sessionEvents;login=(...t)=>{let n=me([X(Ue(Z()))]).parse(t);return this.graffiti.login(...n)};logout=(...t)=>{let n=me([sn]).parse(t);return this.graffiti.logout(...n)};handleToActor=(...t)=>{let n=me([B()]).parse(t);return this.graffiti.handleToActor(...n)};actorToHandle=(...t)=>{let n=me([Z()]).parse(t);return this.graffiti.actorToHandle(...n)};post=(...t)=>{let n=me([Ru,sn]).parse(t);return this.graffiti.post(...n)};get=(...t)=>{let n=me([Au,Tu,no]).parse(t);return this.graffiti.get(n[0],n[1],n[2])};delete=(...t)=>{let n=me([Au,sn]).parse(t);return this.graffiti.delete(...n)};postMedia=(...t)=>{let n=me([Pu,sn]).parse(t);return this.graffiti.postMedia(...n)};getMedia=(...t)=>{let n=me([Z(),mh,no]).parse(t);return this.graffiti.getMedia(...n)};deleteMedia=(...t)=>{let n=me([Z(),sn]).parse(t);return this.graffiti.deleteMedia(...n)};discover=(...t)=>{let n=me([q(B()),Tu,no]).parse(t);return this.graffiti.discover(n[0],n[1],n[2])};continueDiscover=(...t)=>{let n=me([B(),no]).parse(t);return this.graffiti.continueDiscover(...n)}};var gh={type:"object",properties:{value:{type:"object"},channels:{type:"array",items:{type:"string"}},allowed:{type:"array",items:{type:"string"},nullable:!0},url:{type:"string"},actor:{type:"string"}},additionalProperties:!1,required:["value","channels","actor","url"]},zS={...gh,required:["value","channels"]};var mt=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorForbidden",Object.setPrototypeOf(this,e.prototype)}},Q=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,e.prototype)}},an=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorInvalidSchema",Object.setPrototypeOf(this,e.prototype)}},oo=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorSchemaMismatch",Object.setPrototypeOf(this,e.prototype)}},gt=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorTooLarge",Object.setPrototypeOf(this,e.prototype)}},io=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorNotAcceptable",Object.setPrototypeOf(this,e.prototype)}},Me=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorCursorExpired",Object.setPrototypeOf(this,e.prototype)}};function ns(e){return typeof e=="string"?e:e.url}function rs(e,t,n){if(n===e.actor)return e;let r=e.allowed&&n?[n]:void 0,o=e.channels.filter(i=>t.includes(i));return{...e,...r?{allowed:r}:{},channels:o}}function Ou(e,t){let[n,r]=e.toLowerCase().split(";")[0].split("/");return!n||!r?!1:t.some(o=>{let[i,s]=o.toLowerCase().split(";")[0].split("/");return!i||!s?!1:(i===n||i==="*")&&(s===r||s==="*")})}var ts;async function so(e){if(!ts){let{default:t}=await import("./ajv-X6C4R6QN.js");ts=new t({strict:!1})}try{return ts.compile(e)}catch(t){throw new an(t instanceof Error?t.message:String(t))}}function ku(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var os=e=>e?`"${e}" `:"";function Xn(e,t=""){if(typeof e!="number")throw new TypeError(os(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(os(t)+"expected integer >= 0, got "+e);return e}function Qn(e,t,n=""){if(ku(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Xn(t,"length");let r=ku(e),o=t!==void 0?` of length ${t}`:"",i=r?`length=${e.length}`:`type=${typeof e}`,s=os(n)+"expected Uint8Array"+o+", got "+i;throw r?new RangeError(s):new TypeError(s)}function Iu(e){return Uint8Array.from(Qn(e))}function zu(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(Xn(e.outputLen),Xn(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}function $u(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Lt(e=32){Xn(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var yh=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","Tagged"];function is(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(t==="string"||t==="number"||t==="bigint"||t==="symbol")return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";let n=wh(e);return n||"Object"}function wh(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(yh.includes(t))return t}var y=class{constructor(t,n,r){this.major=t,this.majorEncoded=t<<5,this.name=n,this.terminal=r}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}static equals(t,n){return t===n||t.major===n.major&&t.name===n.name}};y.uint=new y(0,"uint",!0);y.negint=new y(1,"negint",!0);y.bytes=new y(2,"bytes",!0);y.string=new y(3,"string",!0);y.array=new y(4,"array",!1);y.map=new y(5,"map",!1);y.tag=new y(6,"tag",!1);y.float=new y(7,"float",!0);y.false=new y(7,"false",!0);y.true=new y(7,"true",!0);y.null=new y(7,"null",!0);y.undefined=new y(7,"undefined",!0);y.break=new y(7,"break",!0);var P=class{constructor(t,n,r){this.type=t,this.value=n,this.encodedLength=r,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var er=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",bh=new TextEncoder;function ao(e){return er&&globalThis.Buffer.isBuffer(e)}function tr(e){return e instanceof Uint8Array?ao(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var _h=24,xh=200,co=er?e=>e.length>=_h?globalThis.Buffer.from(e):Cu(e):e=>e.length>=xh?bh.encode(e):Cu(e),Ge=e=>Uint8Array.from(e),Du=er?(e,t,n)=>ao(e)?new Uint8Array(e.subarray(t,n)):e.slice(t,n):(e,t,n)=>e.slice(t,n),Uu=er?(e,t)=>(e=e.map(n=>n instanceof Uint8Array?n:globalThis.Buffer.from(n)),tr(globalThis.Buffer.concat(e,t))):(e,t)=>{let n=new Uint8Array(t),r=0;for(let o of e)r+o.length>n.length&&(o=o.subarray(0,n.length-r)),n.set(o,r),r+=o.length;return n},ss=er?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function cn(e,t){if(ao(e)&&ao(t))return e.compare(t);for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return 0}function Cu(e){let t=[],n=0;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);o<128?t[n++]=o:o<2048?(t[n++]=o>>6|192,t[n++]=o&63|128):(o&64512)===55296&&r+1<e.length&&(e.charCodeAt(r+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++r)&1023),t[n++]=o>>18|240,t[n++]=o>>12&63|128,t[n++]=o>>6&63|128,t[n++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),t[n++]=o>>12|224,t[n++]=o>>6&63|128,t[n++]=o&63|128)}return t}var Eh=256,nr=class{constructor(t=Eh){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}pushByte(t){let n=this.chunks[this.chunks.length-1];this.cursor>this.maxCursor&&(n=ss(this.chunkSize),this.chunks.push(n),this.maxCursor+=n.length,this._initReuseChunk===null&&(this._initReuseChunk=n));let r=n.length-(this.maxCursor-this.cursor)-1;n[r]=t,this.cursor++}push(t){let n=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=n.length-(this.maxCursor-this.cursor)-1;n.set(t,o)}else{if(n){let o=n.length-(this.maxCursor-this.cursor)-1;o<n.length&&(this.chunks[this.chunks.length-1]=n.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(n=ss(this.chunkSize),this.chunks.push(n),this.maxCursor+=n.length,this._initReuseChunk===null&&(this._initReuseChunk=n),n.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let n;if(this.chunks.length===1){let r=this.chunks[0];t&&this.cursor>r.length/2?(n=this.cursor===r.length?r:r.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):n=Du(r,0,this.cursor)}else n=Uu(this.chunks,this.cursor);return t&&this.reset(),n}},uo=class{constructor(t){this.dest=t,this.cursor=0,this.chunks=[t]}reset(){this.cursor=0}pushByte(t){if(this.cursor>=this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest[this.cursor++]=t}push(t){if(this.cursor+t.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(t,this.cursor),this.cursor+=t.length}toBytes(t=!1){let n=this.dest.subarray(0,this.cursor);return t&&this.reset(),n}};var $="CBOR decode error:",lo="CBOR encode error:",rr=[];rr[23]=1;rr[24]=2;rr[25]=3;rr[26]=5;rr[27]=9;function ut(e,t,n){if(e.length-t<n)throw new Error(`${$} not enough data for type`)}var ae=[24,256,65536,4294967296,BigInt("18446744073709551616")];function ve(e,t,n){ut(e,t,1);let r=e[t];if(n.strict===!0&&r<ae[0])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return r}function Ae(e,t,n){ut(e,t,2);let r=e[t]<<8|e[t+1];if(n.strict===!0&&r<ae[1])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return r}function Te(e,t,n){ut(e,t,4);let r=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(n.strict===!0&&r<ae[2])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return r}function Re(e,t,n){ut(e,t,8);let r=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(r)<<BigInt(32))+BigInt(o);if(n.strict===!0&&i<ae[3])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(n.allowBigInt===!0)return i;throw new Error(`${$} integers outside of the safe integer range are not supported`)}function Mu(e,t,n,r){return new P(y.uint,ve(e,t+1,r),2)}function Lu(e,t,n,r){return new P(y.uint,Ae(e,t+1,r),3)}function Nu(e,t,n,r){return new P(y.uint,Te(e,t+1,r),5)}function Bu(e,t,n,r){return new P(y.uint,Re(e,t+1,r),9)}function qe(e,t){return ie(e,0,t.value)}function ie(e,t,n){if(n<ae[0]){let r=Number(n);e.pushByte(t|r)}else if(n<ae[1]){let r=Number(n);e.push([t|24,r])}else if(n<ae[2]){let r=Number(n);e.push([t|25,r>>>8,r&255])}else if(n<ae[3]){let r=Number(n);e.push([t|26,r>>>24&255,r>>>16&255,r>>>8&255,r&255])}else{let r=BigInt(n);if(r<ae[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(r&BigInt(4294967295)),s=Number(r>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${$} encountered BigInt larger than allowable range`)}}qe.encodedSize=function(t){return ie.encodedSize(t.value)};ie.encodedSize=function(t){return t<ae[0]?1:t<ae[1]?2:t<ae[2]?3:t<ae[3]?5:9};qe.compareTokens=function(t,n){return t.value<n.value?-1:t.value>n.value?1:0};function ju(e,t,n,r){return new P(y.negint,-1-ve(e,t+1,r),2)}function Zu(e,t,n,r){return new P(y.negint,-1-Ae(e,t+1,r),3)}function Fu(e,t,n,r){return new P(y.negint,-1-Te(e,t+1,r),5)}var as=BigInt(-1),Hu=BigInt(1);function Gu(e,t,n,r){let o=Re(e,t+1,r);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new P(y.negint,i,9)}if(r.allowBigInt!==!0)throw new Error(`${$} integers outside of the safe integer range are not supported`);return new P(y.negint,as-BigInt(o),9)}function fo(e,t){let n=t.value,r=typeof n=="bigint"?n*as-Hu:n*-1-1;ie(e,t.type.majorEncoded,r)}fo.encodedSize=function(t){let n=t.value,r=typeof n=="bigint"?n*as-Hu:n*-1-1;return r<ae[0]?1:r<ae[1]?2:r<ae[2]?3:r<ae[3]?5:9};fo.compareTokens=function(t,n){return t.value<n.value?1:t.value>n.value?-1:0};function or(e,t,n,r){ut(e,t,n+r);let o=e.slice(t+n,t+n+r);return new P(y.bytes,o,n+r)}function qu(e,t,n,r){return or(e,t,1,n)}function Ju(e,t,n,r){return or(e,t,2,ve(e,t+1,r))}function Ku(e,t,n,r){return or(e,t,3,Ae(e,t+1,r))}function Vu(e,t,n,r){return or(e,t,5,Te(e,t+1,r))}function Wu(e,t,n,r){let o=Re(e,t+1,r);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer bytes lengths not supported`);return or(e,t,9,o)}function po(e){return e.encodedBytes===void 0&&(e.encodedBytes=y.equals(e.type,y.string)?co(e.value):e.value),e.encodedBytes}function un(e,t){let n=po(t);ie(e,t.type.majorEncoded,n.length),e.push(n)}un.encodedSize=function(t){let n=po(t);return ie.encodedSize(n.length)+n.length};un.compareTokens=function(t,n){return vh(po(t),po(n))};function vh(e,t){return e.length<t.length?-1:e.length>t.length?1:cn(e,t)}var Yu=new TextDecoder,Th=32;function Rh(e,t,n){if(n-t<Th){let o="";for(let i=t;i<n;i++){let s=e[i];if(s&128)return Yu.decode(e.subarray(t,n));o+=String.fromCharCode(s)}return o}return Yu.decode(e.subarray(t,n))}function ir(e,t,n,r,o){let i=n+r;ut(e,t,i);let s=new P(y.string,Rh(e,t+n,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=e.slice(t+n,t+i)),s}function Xu(e,t,n,r){return ir(e,t,1,n,r)}function Qu(e,t,n,r){return ir(e,t,2,ve(e,t+1,r),r)}function el(e,t,n,r){return ir(e,t,3,Ae(e,t+1,r),r)}function tl(e,t,n,r){return ir(e,t,5,Te(e,t+1,r),r)}function nl(e,t,n,r){let o=Re(e,t+1,r);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer string lengths not supported`);return ir(e,t,9,o,r)}var rl=un;function ln(e,t,n,r){return new P(y.array,r,n)}function ol(e,t,n,r){return ln(e,t,1,n)}function il(e,t,n,r){return ln(e,t,2,ve(e,t+1,r))}function sl(e,t,n,r){return ln(e,t,3,Ae(e,t+1,r))}function al(e,t,n,r){return ln(e,t,5,Te(e,t+1,r))}function cl(e,t,n,r){let o=Re(e,t+1,r);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer array lengths not supported`);return ln(e,t,9,o)}function ul(e,t,n,r){if(r.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return ln(e,t,1,1/0)}function ho(e,t){ie(e,y.array.majorEncoded,t.value)}ho.compareTokens=qe.compareTokens;ho.encodedSize=function(t){return ie.encodedSize(t.value)};function fn(e,t,n,r){return new P(y.map,r,n)}function ll(e,t,n,r){return fn(e,t,1,n)}function fl(e,t,n,r){return fn(e,t,2,ve(e,t+1,r))}function dl(e,t,n,r){return fn(e,t,3,Ae(e,t+1,r))}function pl(e,t,n,r){return fn(e,t,5,Te(e,t+1,r))}function hl(e,t,n,r){let o=Re(e,t+1,r);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer map lengths not supported`);return fn(e,t,9,o)}function ml(e,t,n,r){if(r.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return fn(e,t,1,1/0)}function mo(e,t){ie(e,y.map.majorEncoded,t.value)}mo.compareTokens=qe.compareTokens;mo.encodedSize=function(t){return ie.encodedSize(t.value)};function gl(e,t,n,r){return new P(y.tag,n,1)}function yl(e,t,n,r){return new P(y.tag,ve(e,t+1,r),2)}function wl(e,t,n,r){return new P(y.tag,Ae(e,t+1,r),3)}function bl(e,t,n,r){return new P(y.tag,Te(e,t+1,r),5)}function _l(e,t,n,r){return new P(y.tag,Re(e,t+1,r),9)}function go(e,t){ie(e,y.tag.majorEncoded,t.value)}go.compareTokens=qe.compareTokens;go.encodedSize=function(t){return ie.encodedSize(t.value)};var yo=20,wo=21,bo=22,_o=23;function El(e,t,n,r){if(r.allowUndefined===!1)throw new Error(`${$} undefined values are not supported`);return r.coerceUndefinedToNull===!0?new P(y.null,null,1):new P(y.undefined,void 0,1)}function Sl(e,t,n,r){if(r.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return new P(y.break,void 0,1)}function cs(e,t,n){if(n){if(n.allowNaN===!1&&Number.isNaN(e))throw new Error(`${$} NaN values are not supported`);if(n.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${$} Infinity values are not supported`)}return new P(y.float,e,t)}function vl(e,t,n,r){return cs(xo(e,t+1),3,r)}function Al(e,t,n,r){return cs(Eo(e,t+1),5,r)}function Tl(e,t,n,r){return cs(Ol(e,t+1),9,r)}function sr(e,t,n){let r=t.value;if(r===!1)e.pushByte(y.float.majorEncoded|yo);else if(r===!0)e.pushByte(y.float.majorEncoded|wo);else if(r===null)e.pushByte(y.float.majorEncoded|bo);else if(r===void 0)e.pushByte(y.float.majorEncoded|_o);else{let o,i=!1;(!n||n.float64!==!0)&&(us(r),o=xo(se,1),r===o||Number.isNaN(r)?(se[0]=249,e.push(se.slice(0,3)),i=!0):(ls(r),o=Eo(se,1),r===o&&(se[0]=250,e.push(se.slice(0,5)),i=!0))),i||(Pl(r),o=Ol(se,1),se[0]=251,e.push(se.slice(0,9)))}}sr.encodedSize=function(t,n){let r=t.value;if(r===!1||r===!0||r===null||r===void 0)return 1;if(!n||n.float64!==!0){us(r);let o=xo(se,1);if(r===o||Number.isNaN(r))return 3;if(ls(r),o=Eo(se,1),r===o)return 5}return 9};var Rl=new ArrayBuffer(9),Ie=new DataView(Rl,1),se=new Uint8Array(Rl,0);function us(e){if(e===1/0)Ie.setUint16(0,31744,!1);else if(e===-1/0)Ie.setUint16(0,64512,!1);else if(Number.isNaN(e))Ie.setUint16(0,32256,!1);else{Ie.setFloat32(0,e);let t=Ie.getUint32(0),n=(t&2139095040)>>23,r=t&8388607;if(n===255)Ie.setUint16(0,31744,!1);else if(n===0)Ie.setUint16(0,(t&2147483648)>>16|r>>13,!1);else{let o=n-127;o<-24?Ie.setUint16(0,0):o<-14?Ie.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Ie.setUint16(0,(t&2147483648)>>16|o+15<<10|r>>13,!1)}}}function xo(e,t){if(e.length-t<2)throw new Error(`${$} not enough data for float16`);let n=(e[t]<<8)+e[t+1];if(n===31744)return 1/0;if(n===64512)return-1/0;if(n===32256)return NaN;let r=n>>10&31,o=n&1023,i;return r===0?i=o*2**-24:r!==31?i=(o+1024)*2**(r-25):i=o===0?1/0:NaN,n&32768?-i:i}function ls(e){Ie.setFloat32(0,e,!1)}function Eo(e,t){if(e.length-t<4)throw new Error(`${$} not enough data for float32`);let n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,4).getFloat32(0,!1)}function Pl(e){Ie.setFloat64(0,e,!1)}function Ol(e,t){if(e.length-t<8)throw new Error(`${$} not enough data for float64`);let n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,8).getFloat64(0,!1)}function zh(e,t){let n=e.value;if(n===!1)return Uint8Array.of(y.float.majorEncoded|yo);if(n===!0)return Uint8Array.of(y.float.majorEncoded|wo);if(n===null)return Uint8Array.of(y.float.majorEncoded|bo);if(n===void 0)return Uint8Array.of(y.float.majorEncoded|_o);if(!t){if(us(n),n===xo(se,1)||Number.isNaN(n))return se[0]=249,se.slice(0,3);if(ls(n),n===Eo(se,1))return se[0]=250,se.slice(0,5)}return Pl(n),se[0]=251,se.slice(0,9)}function xl(e,t){let n=e,r=t?.float64===!0,o=r?n._keyBytesFloat64:n._keyBytes;if(o!==void 0)return o;let i=zh(e,r);return r?n._keyBytesFloat64=i:n._keyBytes=i,i}sr.compareTokens=function(t,n,r){let o=xl(t,r),i=xl(n,r);return o.length!==i.length?o.length<i.length?-1:1:cn(o,i)};function j(e,t,n){throw new Error(`${$} encountered invalid minor (${n}) for major ${e[t]>>>5}`)}function So(e){return()=>{throw new Error(`${$} ${e}`)}}var T=[];for(let e=0;e<=23;e++)T[e]=j;T[24]=Mu;T[25]=Lu;T[26]=Nu;T[27]=Bu;T[28]=j;T[29]=j;T[30]=j;T[31]=j;for(let e=32;e<=55;e++)T[e]=j;T[56]=ju;T[57]=Zu;T[58]=Fu;T[59]=Gu;T[60]=j;T[61]=j;T[62]=j;T[63]=j;for(let e=64;e<=87;e++)T[e]=qu;T[88]=Ju;T[89]=Ku;T[90]=Vu;T[91]=Wu;T[92]=j;T[93]=j;T[94]=j;T[95]=So("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)T[e]=Xu;T[120]=Qu;T[121]=el;T[122]=tl;T[123]=nl;T[124]=j;T[125]=j;T[126]=j;T[127]=So("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)T[e]=ol;T[152]=il;T[153]=sl;T[154]=al;T[155]=cl;T[156]=j;T[157]=j;T[158]=j;T[159]=ul;for(let e=160;e<=183;e++)T[e]=ll;T[184]=fl;T[185]=dl;T[186]=pl;T[187]=hl;T[188]=j;T[189]=j;T[190]=j;T[191]=ml;for(let e=192;e<=215;e++)T[e]=gl;T[216]=yl;T[217]=wl;T[218]=bl;T[219]=_l;T[220]=j;T[221]=j;T[222]=j;T[223]=j;for(let e=224;e<=243;e++)T[e]=So("simple values are not supported");T[244]=j;T[245]=j;T[246]=j;T[247]=El;T[248]=So("simple values are not supported");T[249]=vl;T[250]=Al;T[251]=Tl;T[252]=j;T[253]=j;T[254]=j;T[255]=Sl;var Le=[];for(let e=0;e<24;e++)Le[e]=new P(y.uint,e,1);for(let e=-1;e>=-24;e--)Le[31-e]=new P(y.negint,e,1);Le[64]=new P(y.bytes,new Uint8Array(0),1);Le[96]=new P(y.string,"",1);Le[128]=new P(y.array,0,1);Le[160]=new P(y.map,0,1);Le[244]=new P(y.false,!1,1);Le[245]=new P(y.true,!0,1);Le[246]=new P(y.null,null,1);function fs(e){switch(e.type){case y.false:return Ge([244]);case y.true:return Ge([245]);case y.null:return Ge([246]);case y.bytes:return e.value.length?void 0:Ge([64]);case y.string:return e.value===""?Ge([96]):void 0;case y.array:return e.value===0?Ge([128]):void 0;case y.map:return e.value===0?Ge([160]):void 0;case y.uint:return e.value<24?Ge([Number(e.value)]):void 0;case y.negint:if(e.value>=-24)return Ge([31-Number(e.value)])}}var Ch={float64:!1,mapSorter:ps,quickEncodeToken:fs},Cl=Object.freeze({mapSorter:Mh,quickEncodeToken:fs});function Dh(){let e=[];return e[y.uint.major]=qe,e[y.negint.major]=fo,e[y.bytes.major]=un,e[y.string.major]=rl,e[y.array.major]=ho,e[y.map.major]=mo,e[y.tag.major]=go,e[y.float.major]=sr,e}var jt=Dh(),vo=new nr,pn=class e{constructor(t,n){this.obj=t,this.parent=n}includes(t){let n=this;do if(n.obj===t)return!0;while(n=n.parent);return!1}static createCheck(t,n){if(t&&t.includes(n))throw new Error(`${lo} object contains circular references`);return new e(n,t)}},yt={null:new P(y.null,null),undefined:new P(y.undefined,void 0),true:new P(y.true,!0),false:new P(y.false,!1),emptyArray:new P(y.array,0),emptyMap:new P(y.map,0)},Je={number(e,t,n,r){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new P(y.float,e):e>=0?new P(y.uint,e):new P(y.negint,e)},bigint(e,t,n,r){return e>=BigInt(0)?new P(y.uint,e):new P(y.negint,e)},Uint8Array(e,t,n,r){return new P(y.bytes,e)},string(e,t,n,r){return new P(y.string,e)},boolean(e,t,n,r){return e?yt.true:yt.false},null(e,t,n,r){return yt.null},undefined(e,t,n,r){return yt.undefined},ArrayBuffer(e,t,n,r){return new P(y.bytes,new Uint8Array(e))},DataView(e,t,n,r){return new P(y.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,n,r){if(!e.length)return n.addBreakTokens===!0?[yt.emptyArray,new P(y.break)]:yt.emptyArray;r=pn.createCheck(r,e);let o=[],i=0;for(let s of e)o[i++]=Bt(s,n,r);return n.addBreakTokens?[new P(y.array,e.length),o,new P(y.break)]:[new P(y.array,e.length),o]},Object(e,t,n,r){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length,a;if(s){a=new Array(s),r=pn.createCheck(r,e);let c=!o&&n.ignoreUndefinedProperties,u=0;for(let l of i){let f=o?e.get(l):e[l];c&&f===void 0||(a[u++]=[Bt(l,n,r),Bt(f,n,r)])}u<s&&(a.length=u)}return a?.length?(Uh(a,n),n.addBreakTokens?[new P(y.map,a.length),a,new P(y.break)]:[new P(y.map,a.length),a]):n.addBreakTokens===!0?[yt.emptyMap,new P(y.break)]:yt.emptyMap},Tagged(e,t,n,r){return[new P(y.tag,e.tag),Bt(e.value,n,r)]}};Je.Map=Je.Object;Je.Buffer=Je.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Je[`${e}Array`]=Je.DataView;function Bt(e,t={},n){let r=is(e),o=t&&t.typeEncoders&&t.typeEncoders[r]||Je[r];if(typeof o=="function"){let s=o(e,r,t,n);if(s!=null)return s}let i=Je[r];if(!i)throw new Error(`${lo} unsupported type: ${r}`);return i(e,r,t,n)}function Uh(e,t){let n=t.mapSorter;n&&e.sort((r,o)=>n(r,o,t))}function ps(e,t,n){let r=Array.isArray(e[0])?e[0][0]:e[0],o=Array.isArray(t[0])?t[0][0]:t[0];if(r.type.major!==o.type.major)return r.type.compare(o.type);let i=r.type.major,s=jt[i].compareTokens(r,o,n);return s===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),s}function Mh(e,t){if(e[0]instanceof P&&t[0]instanceof P){let n=e[0],r=t[0];return n._keyBytes||(n._keyBytes=kl(n.value)),r._keyBytes||(r._keyBytes=kl(r.value)),cn(n._keyBytes,r._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function kl(e){return Dl(e,jt,Cl)}function dn(e,t,n,r){if(Array.isArray(t))for(let o of t)dn(e,o,n,r);else n[t.type.major](e,t,r)}var Il=y.uint.majorEncoded,zl=y.negint.majorEncoded,Lh=y.bytes.majorEncoded,Nh=y.string.majorEncoded,$l=y.array.majorEncoded,ds=y.map.majorEncoded,Bh=y.float.majorEncoded|yo,jh=y.float.majorEncoded|wo,Zh=y.float.majorEncoded|bo,Fh=y.float.majorEncoded|_o,Hh=BigInt(-1),Gh=BigInt(1);function wt(e,t,n){n<24?e.pushByte(t|Number(n)):ie(e,t,n)}function qh(e){return e.addBreakTokens!==!0}function Jh(e,t,n,r,o){let i=n==="Map",s=i?t.keys():Object.keys(t),a=i?t.size:s.length;if(!a){e.pushByte(ds);return}o=pn.createCheck(o,t);let c=!i&&r.ignoreUndefinedProperties,u=new Array(a),l=0;for(let f of s){let p=i?t.get(f):t[f];c&&p===void 0||(u[l++]=[Bt(f,r,o),p])}if(l===0){e.pushByte(ds);return}l<a&&(u.length=l),u.sort((f,p)=>ps(f,p,r)),wt(e,ds,l);for(let[f,p]of u)dn(e,f,jt,r),hs(e,p,r,o)}function hs(e,t,n,r){let o=is(t),i=n.typeEncoders&&n.typeEncoders[o];if(i){let s=i(t,o,n,r);if(s!=null){dn(e,s,jt,n);return}}switch(o){case"null":e.pushByte(Zh);return;case"undefined":e.pushByte(Fh);return;case"boolean":e.pushByte(t?jh:Bh);return;case"number":!Number.isInteger(t)||!Number.isSafeInteger(t)?sr(e,new P(y.float,t),n):t>=0?wt(e,Il,t):wt(e,zl,t*-1-1);return;case"bigint":t>=BigInt(0)?wt(e,Il,t):wt(e,zl,t*Hh-Gh);return;case"string":{let s=co(t);wt(e,Nh,s.length),e.push(s);return}case"Uint8Array":wt(e,Lh,t.length),e.push(t);return;case"Array":if(!t.length){e.pushByte($l);return}r=pn.createCheck(r,t),wt(e,$l,t.length);for(let s of t)hs(e,s,n,r);return;case"Object":case"Map":if(n.mapSorter===ps)Jh(e,t,o,n,r);else{let s=Je.Object(t,o,n,r);dn(e,s,jt,n)}return;default:{let s=Je[o];if(!s)throw new Error(`${lo} unsupported type: ${o}`);let a=s(t,o,n,r);dn(e,a,jt,n)}}}function Dl(e,t,n,r){let o=r instanceof Uint8Array,i=o?new uo(r):vo,s=Bt(e,n);if(!Array.isArray(s)&&n.quickEncodeToken){let a=n.quickEncodeToken(s);if(a)return o?(i.push(a),i.toBytes()):a;let c=t[s.type.major];if(c.encodedSize){let u=c.encodedSize(s,n);if(o||(i=new nr(u)),c(i,s,n),i.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return o?i.toBytes():tr(i.chunks[0])}}return i.reset(),dn(i,s,t,n),i.toBytes(!0)}function ms(e,t){return t=Object.assign({},Ch,t),qh(t)?(vo.reset(),hs(vo,e,t,void 0),vo.toBytes(!0)):Dl(e,jt,t)}var Kh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Ao=class{constructor(t,n={}){this._pos=0,this.data=t,this.options=n}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],n=Le[t];if(n===void 0){let r=T[t];if(!r)throw new Error(`${$} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;n=r(this.data,this._pos,o,this.options)}return this._pos+=n.encodedLength,n}},bt=Symbol.for("DONE"),hn=Symbol.for("BREAK");function Vh(e,t,n){let r=[];for(let o=0;o<e.value;o++){let i=_t(t,n);if(i===hn){if(e.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed array`)}if(i===bt)throw new Error(`${$} found array but not enough entries (got ${o}, expected ${e.value})`);r[o]=i}return r}function Wh(e,t,n){let r=n.useMaps===!0,o=n.rejectDuplicateMapKeys===!0,i=r?void 0:{},s=r?new Map:void 0;for(let a=0;a<e.value;a++){let c=_t(t,n);if(c===hn){if(e.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed map`)}if(c===bt)throw new Error(`${$} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(!r&&typeof c!="string")throw new Error(`${$} non-string keys not supported (got ${typeof c})`);if(o&&(r&&s.has(c)||!r&&Object.hasOwn(i,c)))throw new Error(`${$} found repeat map key "${c}"`);let u=_t(t,n);if(u===bt)throw new Error(`${$} found map but not enough entries (got ${a} [no value], expected ${e.value})`);r?s.set(c,u):i[c]=u}return r?s:i}function*Yh(e,t,n){for(let r=0;r<e.value;r++){let o=_t(t,n);if(o===hn){if(e.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed map`)}if(o===bt)throw new Error(`${$} found map but not enough entries (got ${r} [no key], expected ${e.value})`);let i=_t(t,n);if(i===bt)throw new Error(`${$} found map but not enough entries (got ${r} [no value], expected ${e.value})`);yield[o,i]}}function Xh(e,t){let n=function(){if(n._called)throw new Error(`${$} tag decode() may only be called once`);n._called=!0;let r=_t(e,t);if(r===bt)throw new Error(`${$} tag content missing`);if(r===hn)throw new Error(`${$} got unexpected break in tag content`);return r};return n.entries=function(){if(n._called)throw new Error(`${$} tag decode() may only be called once`);n._called=!0;let r=e.next();if(!y.equals(r.type,y.map))throw new Error(`${$} entries() requires map content, got ${r.type.name}`);let o=[];for(let i of Yh(r,e,t))o.push(i);return o},n._called=!1,n}function _t(e,t){if(e.done())return bt;let n=e.next();if(y.equals(n.type,y.break))return hn;if(n.type.terminal)return n.value;if(y.equals(n.type,y.array))return Vh(n,e,t);if(y.equals(n.type,y.map))return Wh(n,e,t);if(y.equals(n.type,y.tag)){if(t.tags&&typeof t.tags[n.value]=="function"){let r=Xh(e,t),o=t.tags[n.value](r);if(!r._called)throw new Error(`${$} tag decoder must call decode() or entries()`);return o}throw new Error(`${$} tag not supported (${n.value})`)}throw new Error("unsupported")}function Ul(e,t){if(!(e instanceof Uint8Array))throw new Error(`${$} data to decode must be a Uint8Array`);t=Object.assign({},Kh,t);let n=tr(e),r=t.tokenizer||new Ao(n,t),o=_t(r,t);if(o===bt)throw new Error(`${$} did not find any content to decode`);if(o===hn)throw new Error(`${$} got unexpected break`);return[o,e.subarray(r.pos())]}function gs(e,t){let[n,r]=Ul(e,t);if(r.length>0)throw new Error(`${$} too many terminals, data makes no sense`);return n}var To=class e{constructor(t,n){if(typeof t!="number"||!Number.isInteger(t)||t<0)throw new TypeError("Tagged: tag must be a non-negative integer");this.tag=t,this.value=n}static decoder(t){return n=>new e(t,n())}static preserve(...t){let n={};for(let r of t)n[r]=e.decoder(r);return n}};Object.defineProperty(To.prototype,Symbol.toStringTag,{value:"Tagged"});var Fv=new Uint8Array(0);function Ml(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0}function mn(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return Zt(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return Zt(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));throw new Error("Unknown type, must be binary type")}function em(e){return e?.buffer instanceof ArrayBuffer}function Zt(e){return em(e)?e:e.slice()}function tm(e,t,n){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),o=0;o<r.length;o++)r[o]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");if(r[a]=i,n){var c=s.toLowerCase().charCodeAt(0),u=s.toUpperCase().charCodeAt(0);c!==a&&(r[c]=i),u!==a&&(r[u]=i)}}var l=e.length,f=e.charAt(0),p=Math.log(l)/Math.log(256),g=Math.log(256)/Math.log(l);function w(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var _=0,S=0,b=0,v=h.length;b!==v&&h[b]===0;)b++,_++;for(var O=(v-b)*g+1>>>0,I=new Uint8Array(O);b!==v;){for(var z=h[b],V=0,J=O-1;(z!==0||V<S)&&J!==-1;J--,V++)z+=256*I[J]>>>0,I[J]=z%l>>>0,z=z/l>>>0;if(z!==0)throw new Error("Non-zero carry");S=V,b++}for(var m=O-S;m!==O&&I[m]===0;)m++;for(var E=f.repeat(_);m<O;++m)E+=e.charAt(I[m]);return E}function x(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var _=0;if(h[_]!==" "){for(var S=0,b=0;h[_]===f;)S++,_++;for(var v=(h.length-_)*p+1>>>0,O=new Uint8Array(v);h[_];){var I=r[h.charCodeAt(_)];if(I===255)return;for(var z=0,V=v-1;(I!==0||z<b)&&V!==-1;V--,z++)I+=l*O[V]>>>0,O[V]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");b=z,_++}if(h[_]!==" "){for(var J=v-b;J!==v&&O[J]===0;)J++;for(var m=new Uint8Array(S+(v-J)),E=S;J!==v;)m[E++]=O[J++];return m}}}function A(h){var _=x(h);if(_)return _;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:x,decode:A}}var nm=tm,rm=nm,Ll=rm;var ys=class{name;prefix;baseEncode;constructor(t,n,r){this.name=t,this.prefix=n,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},ws=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,n,r){this.name=t,this.prefix=n;let o=n.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=r}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Nl(this,t)}},bs=class{decoders;constructor(t){this.decoders=t}or(t){return Nl(this,t)}decode(t){let n=t[0],r=this.decoders[n];if(r!=null)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Nl(e,t){return new bs({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var _s=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,n,r,o){this.name=t,this.prefix=n,this.baseEncode=r,this.baseDecode=o,this.encoder=new ys(t,n,r),this.decoder=new ws(t,n,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Bl({name:e,prefix:t,encode:n,decode:r}){return new _s(e,t,n,r)}function gn({name:e,prefix:t,alphabet:n,caseInsensitive:r=!1}){let{encode:o,decode:i}=Ll(n,e,r);return Bl({prefix:t,name:e,encode:o,decode:s=>mn(i(s))})}function om(e,t,n,r){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*n/8|0),s=0,a=0,c=0;for(let u=0;u<o;++u){let l=t[e[u]];if(l===void 0)throw new SyntaxError(`Non-${r} character`);a=a<<n|l,s+=n,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=n||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function im(e,t,n){let r=t[t.length-1]==="=",o=(1<<n)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>n;)s-=n,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<n-s]),r)for(;(i.length*n&7)!==0;)i+="=";return i}function sm(e,t){let n={};for(let r=0;r<e.length;++r)if(n[e[r]]=r,t){let o=e[r].toLowerCase(),i=e[r].toUpperCase();o!==e[r]&&(n[o]=r),i!==e[r]&&(n[i]=r)}return n}function Ke({name:e,prefix:t,bitsPerChar:n,alphabet:r,caseInsensitive:o=!1}){let i=sm(r,o);return Bl({prefix:t,name:e,encode(s){return im(s,r,n)},decode(s){return om(s,i,n,e)}})}var ar=Ke({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),Wv=Ke({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),Yv=Ke({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),Xv=Ke({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),Qv=Ke({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),eA=Ke({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),tA=Ke({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),nA=Ke({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),rA=Ke({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ro=gn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),sA=gn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var lt=gn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),uA=gn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var am=Fl,jl=128,cm=127,um=~cm,lm=Math.pow(2,31);function Fl(e,t,n){t=t||[],n=n||0;for(var r=n;e>=lm;)t[n++]=e&255|jl,e/=128;for(;e&um;)t[n++]=e&255|jl,e>>>=7;return t[n]=e|0,Fl.bytes=n-r+1,t}var fm=xs,dm=128,Zl=127;function xs(e,r){var n=0,r=r||0,o=0,i=r,s,a=e.length;do{if(i>=a)throw xs.bytes=0,new RangeError("Could not decode varint");s=e[i++],n+=o<28?(s&Zl)<<o:(s&Zl)*Math.pow(2,o),o+=7}while(s>=dm);return xs.bytes=i-r,n}var pm=Math.pow(2,7),hm=Math.pow(2,14),mm=Math.pow(2,21),gm=Math.pow(2,28),ym=Math.pow(2,35),wm=Math.pow(2,42),bm=Math.pow(2,49),_m=Math.pow(2,56),xm=Math.pow(2,63),Em=function(e){return e<pm?1:e<hm?2:e<mm?3:e<gm?4:e<ym?5:e<wm?6:e<bm?7:e<_m?8:e<xm?9:10},Sm={encode:am,decode:fm,encodingLength:Em},vm=Sm,cr=vm;function ur(e,t=0){let n=cr.decode(e,t),r=cr.decode.bytes;if(r>9)throw new RangeError("Invalid varint: too long");if(r>1&&e[t+r-1]===0)throw new RangeError("Invalid varint: not minimally encoded");return[n,r]}function yn(e,t,n=0){return cr.encode(e,t,n),t}function wn(e){return cr.encodingLength(e)}function Gl(e,t){let n=t.byteLength,r=wn(e),o=r+wn(n),i=new Uint8Array(o+n);return yn(e,i,0),yn(n,i,r),i.set(t,o),new bn(e,n,t,i)}function ql(e){let t=mn(e),[n,r]=ur(t),[o,i]=ur(t.subarray(r)),s=t.subarray(r+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new bn(n,o,s,t)}function Jl(e,t){if(e===t)return!0;{let n=t;return e.code===n.code&&e.size===n.size&&n.bytes instanceof Uint8Array&&Ml(e.bytes,n.bytes)}}var bn=class{code;size;digest;bytes;constructor(t,n,r,o){this.code=t,this.size=n,this.digest=Zt(r),this.bytes=Zt(o)}};function Kl(e,t){let{bytes:n,version:r}=e;return r===0?Rm(n,Es(e),t??lt.encoder):Pm(n,Es(e),t??ar.encoder)}var Vl=new WeakMap;function Es(e){let t=Vl.get(e);if(t==null){let n=new Map;return Vl.set(e,n),n}return t}var fr=class e{code;version;multihash;bytes;"/";constructor(t,n,r,o){this.code=n,this.version=t,this.multihash=r,this.bytes=Zt(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:n}=this;if(t!==lr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(n.code!==Om)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(n)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:n}=this.multihash,r=Gl(t,n);return e.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,n){let r=n;return r!=null&&t.code===r.code&&t.version===r.version&&Jl(t.multihash,r.multihash)}toString(t){return Kl(this,t)}toJSON(){return{"/":Kl(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let n=t;if(n instanceof e)return n;if(n["/"]!=null&&n["/"]===n.bytes||n.asCID===n){let{version:r,code:o,multihash:i,bytes:s}=n;return new e(r,o,i,s??Wl(r,o,i.bytes))}else if(n[km]===!0){let{version:r,multihash:o,code:i}=n,s=ql(o);return e.create(r,i,s)}else return null}static create(t,n,r){if(typeof n!="number")throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(n!==lr)throw new Error(`Version 0 CID must use dag-pb (code: ${lr}) block encoding`);return new e(t,n,r,r.bytes)}case 1:{let o=Wl(t,n,r.bytes);return new e(t,n,r,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,lr,t)}static createV1(t,n){return e.create(1,t,n)}static decode(t){let[n,r]=e.decodeFirst(t);if(r.length!==0)throw new Error("Incorrect length");return n}static decodeFirst(t){let n=e.inspectBytes(t),r=n.size-n.multihashSize,o=mn(t.subarray(r,r+n.multihashSize));if(o.byteLength!==n.multihashSize)throw new Error("Incorrect length");let i=o.subarray(n.multihashSize-n.digestSize),s=new bn(n.multihashCode,n.digestSize,i,o);return[n.version===0?e.createV0(s):e.createV1(n.codec,s),t.subarray(n.size)]}static inspectBytes(t){let n=0,r=()=>{let[f,p]=ur(t.subarray(n));return n+=p,f},o=r(),i=lr;if(o===18?(o=0,n=0):i=r(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=n,a=r(),c=r(),u=n+c,l=u-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:l,size:u}}static parse(t,n){let[r,o]=Tm(t,n),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Es(i).set(r,t),i}};function Tm(e,t){switch(e[0]){case"Q":{let n=t??lt;return[lt.prefix,n.decode(`${lt.prefix}${e}`)]}case lt.prefix:{let n=t??lt;return[lt.prefix,n.decode(e)]}case ar.prefix:{let n=t??ar;return[ar.prefix,n.decode(e)]}case Ro.prefix:{let n=t??Ro;return[Ro.prefix,n.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Rm(e,t,n){let{prefix:r}=n;if(r!==lt.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);let o=t.get(r);if(o==null){let i=n.encode(e).slice(1);return t.set(r,i),i}else return o}function Pm(e,t,n){let{prefix:r}=n,o=t.get(r);if(o==null){let i=n.encode(e);return t.set(r,i),i}else return o}var lr=112,Om=18;function Wl(e,t,n){let r=wn(e),o=r+wn(t),i=new Uint8Array(o+n.byteLength);return yn(e,i,0),yn(t,i,r),i.set(n,o),i}var km=Symbol.for("@ipld/js-cid/CID");var Yl=42;function Im(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function zm(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=fr.asCID(e);if(!t)return null;let n=new Uint8Array(t.bytes.byteLength+1);return n.set(t.bytes,1),[new P(y.tag,Yl),new P(y.bytes,n)]}function $m(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Cm(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}function Dm(e){for(let t of e.keys())if(typeof t!="string"||t.length===0)throw new Error("Non-string Map keys are not supported by the IPLD Data Model and cannot be encoded");return null}var Ss={float64:!0,typeEncoders:{Map:Dm,Object:zm,undefined:$m,number:Cm}},xA={...Ss,typeEncoders:{...Ss.typeEncoders}};function Um(e){let t=e();if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return fr.decode(t.subarray(1))}var vs={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:{[Yl]:Um}},EA={...vs,tags:{...vs.tags}};var pe=e=>ms(e,Ss),Ne=e=>gs(Im(e),vs);function Mm(){let e=new Map;return async(t,n)=>{if(t.params&&t.params["no-cache"]==="true")return await n();let r=e.get(t.didUrl);if(r!==void 0)return r;let o=await n();return o.didResolutionMetadata?.error!=="notFound"&&e.set(t.didUrl,o),o}}function Lm(e,t){return t()}var Nm="(?:%[0-9a-fA-F]{2})",Xl=`(?:[a-zA-Z0-9._-]|${Nm})`,Bm="([a-z0-9]+)",jm=`((?:${Xl}*:)*(${Xl}+))`,Ql="[a-zA-Z0-9_.:%-]",Zm=`;${Ql}+=${Ql}*`,Fm=`((${Zm})*)`,Hm="(/[^#?]*)?",Gm="([?][^#]*)?",qm="(#.*)?",Jm=new RegExp(`^did:${Bm}:${jm}${Fm}${Hm}${Gm}${qm}$`);function Km(e){if(e===""||!e)return null;let t=e.match(Jm);if(t){let n={did:`did:${t[1]}:${t[2]}`,method:t[1],id:t[2],didUrl:e};if(t[4]){let r=t[4].slice(1).split(";");n.params={};for(let o of r){let i=o.split("=");n.params[i[0]]=i[1]}}return t[6]&&(n.path=t[6]),t[7]&&(n.query=t[7].slice(1)),t[8]&&(n.fragment=t[8].slice(1)),n}return null}var Po={didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};function Vm(e){return async(t,n,r)=>{try{let o=await e(t,n,r);return{...Po,didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:o}}catch(o){return{...Po,didResolutionMetadata:{error:"notFound",message:o.toString()}}}}}var Oo=class{constructor(t={},n={}){this.registry=t,this.cache=n.cache===!0?Mm():n.cache||Lm,n.legacyResolvers&&Object.keys(n.legacyResolvers).map(r=>{this.registry[r]||(this.registry[r]=Vm(n.legacyResolvers[r]))})}async resolve(t,n={}){let r=Km(t);if(r===null)return{...Po,didResolutionMetadata:{error:"invalidDid"}};let o=this.registry[r.method];return o?this.cache(r,()=>o(r.did,r,this,n)):{...Po,didResolutionMetadata:{error:"unsupportedDidMethod"}}}};function dr(e,t){return function(){return e.apply(t,arguments)}}var{toString:Wm}=Object.prototype,{getPrototypeOf:xt}=Object,{iterator:mr,toStringTag:nf}=Symbol,pr=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),rf=e=>typeof e=="string"&&(e==="__proto__"||e==="constructor"||e==="prototype"),of=(e,t,n)=>e===Object.prototype||!n&&t===null,Ym=e=>{if(!Object.isExtensible(e))return!1;let t=Object.getOwnPropertyNames(e);return Object.getOwnPropertySymbols&&t.push(...Object.getOwnPropertySymbols(e)),t.every(n=>{if(rf(n))return!1;let r=Object.getOwnPropertyDescriptor(e,n);return!!r&&r.configurable&&r.writable===!0})},hr=(e,t)=>{let n=e,r=[];for(;n!=null;){if(r.indexOf(n)!==-1)return!1;r.push(n);let o=xt(n);if(of(n,o,n===e))return!1;if(pr(n,t))return!0;n=o}return!1},Xm=(e,t)=>e!=null&&hr(e,t)?e[t]:void 0,Qm=e=>{if(e==null||typeof e!="object"&&typeof e!="function")return e;let t=xt(e);if(t===null&&Ym(e))return e;let n=Object.create(null),r=Object.create(null),o=[],i=e;for(;i!=null&&o.indexOf(i)===-1;){o.push(i);let s=i===e?t:xt(i);if(of(i,s,i===e))break;let a=Object.getOwnPropertyNames(i);Object.getOwnPropertySymbols&&a.push(...Object.getOwnPropertySymbols(i));for(let c of a)rf(c)||pr(r,c)||(n[c]=e[c],r[c]=!0);i=s}return n},Ts=(e=>t=>{let n=Wm.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ze=e=>(e=e.toLowerCase(),t=>Ts(t)===e),Io=e=>t=>typeof t===e,{isArray:Ht}=Array,Gt=Io("undefined");function _n(e){return e!==null&&!Gt(e)&&e.constructor!==null&&!Gt(e.constructor)&&be(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var sf=ze("ArrayBuffer");function eg(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&sf(e.buffer),t}var tg=Io("string"),be=Io("function"),af=Io("number"),xn=e=>e!==null&&typeof e=="object",ng=e=>e===!0||e===!1,ko=e=>{if(!xn(e))return!1;let t=xt(e);return(t===null||t===Object.prototype||xt(t)===null)&&!hr(e,nf)&&!hr(e,mr)},rg=e=>{if(!xn(e)||_n(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},og=ze("Date"),ig=ze("File"),sg=e=>!!(e&&typeof e.uri<"u"),ag=e=>e&&typeof e.getParts<"u",cg=ze("Blob"),ug=ze("FileList"),lg=ze("Set"),fg=e=>xn(e)&&be(e.pipe);function dg(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}var ef=dg(),tf=typeof ef.FormData<"u"?ef.FormData:void 0,pg=e=>{if(!e)return!1;if(tf&&e instanceof tf)return!0;let t=xt(e);if(!t||t===Object.prototype||!be(e.append))return!1;let n=Ts(e);return n==="formdata"||n==="object"&&be(e.toString)&&e.toString()==="[object FormData]"},hg=ze("URLSearchParams"),[mg,gg,yg,wg]=["ReadableStream","Request","Response","Headers"].map(ze),bg=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function gr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Ht(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(_n(e))return;let i=n?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length,a;for(r=0;r<s;r++)a=i[r],t.call(null,e[a],a,e)}}function cf(e,t){if(_n(e))return null;t=t.toLowerCase();let n=Object.keys(e),r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}var Ft=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,uf=e=>!Gt(e)&&e!==Ft;function As(...e){let{caseless:t,skipUndefined:n}=uf(this)&&this||{},r={},o=(i,s)=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;let a=t&&typeof s=="string"&&cf(r,s)||s,c=pr(r,a)?r[a]:void 0;ko(c)&&ko(i)?r[a]=As(c,i):ko(i)?r[a]=As({},i):Ht(i)?r[a]=i.slice():(!n||!Gt(i))&&(r[a]=i)};for(let i=0,s=e.length;i<s;i++){let a=e[i];if(!a||_n(a)||(gr(a,o),typeof a!="object"||Ht(a)))continue;let c=Object.getOwnPropertySymbols(a);for(let u=0;u<c.length;u++){let l=c[u];Ig.call(a,l)&&o(a[l],l)}}return r}var _g=(e,t,n,{allOwnKeys:r}={})=>(gr(t,(o,i)=>{n&&be(o)?Object.defineProperty(e,i,{__proto__:null,value:dr(o,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{__proto__:null,value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),xg=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Eg=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},Sg=(e,t,n,r)=>{let o,i,s,a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],(!r||r(s,e,t))&&!a[s]&&(t[s]=e[s],a[s]=!0);e=n!==!1&&xt(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},vg=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},Ag=e=>{if(!e)return null;if(Ht(e))return e;let t=e.length;if(!af(t))return null;let n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Tg=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&xt(Uint8Array)),Rg=(e,t)=>{let r=(e&&e[mr]).call(e),o;for(;(o=r.next())&&!o.done;){let i=o.value;t.call(e,i[0],i[1])}},Pg=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Og=ze("HTMLFormElement"),kg=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),{propertyIsEnumerable:Ig}=Object.prototype,zg=ze("RegExp"),lf=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};gr(n,(o,i)=>{let s;(s=t(o,i,e))!==!1&&(r[i]=s||o)}),Object.defineProperties(e,r)},$g=e=>{lf(e,(t,n)=>{if(be(e)&&["arguments","caller","callee"].includes(n))return!1;let r=e[n];if(be(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Cg=(e,t)=>{let n={},r=o=>{o.forEach(i=>{n[i]=!0})};return Ht(e)?r(e):r(String(e).split(t)),n},Dg=()=>{},Ug=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Mg(e){return!!(e&&be(e.append)&&e[nf]==="FormData"&&e[mr])}var Lg=e=>{let t=new WeakSet,n=r=>{if(xn(r)){if(t.has(r))return;if(_n(r))return r;if(!("toJSON"in r)){t.add(r);let o;if(lg(r)){o=[];for(let i of r){let s=n(i);!Gt(s)&&o.push(s)}}else o=Ht(r)?[]:{},gr(r,(i,s)=>{let a=n(i);!Gt(a)&&(o[s]=a)});return t.delete(r),o}}return r};return n(e)},Ng=ze("AsyncFunction"),Bg=e=>e&&(xn(e)||be(e))&&be(e.then)&&be(e.catch),ff=((e,t)=>e?setImmediate:t?((n,r)=>(Ft.addEventListener("message",({source:o,data:i})=>{o===Ft&&i===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Ft.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",be(Ft.postMessage)),jg=typeof queueMicrotask<"u"?queueMicrotask.bind(Ft):typeof process<"u"&&process.nextTick||ff,df=e=>e!=null&&be(e[mr]),Zg=e=>e!=null&&hr(e,mr)&&df(e),d={isArray:Ht,isArrayBuffer:sf,isBuffer:_n,isFormData:pg,isArrayBufferView:eg,isString:tg,isNumber:af,isBoolean:ng,isObject:xn,isPlainObject:ko,isEmptyObject:rg,isReadableStream:mg,isRequest:gg,isResponse:yg,isHeaders:wg,isUndefined:Gt,isDate:og,isFile:ig,isReactNativeBlob:sg,isReactNative:ag,isBlob:cg,isRegExp:zg,isFunction:be,isStream:fg,isURLSearchParams:hg,isTypedArray:Tg,isFileList:ug,forEach:gr,merge:As,extend:_g,trim:bg,stripBOM:xg,inherits:Eg,toFlatObject:Sg,kindOf:Ts,kindOfTest:ze,endsWith:vg,toArray:Ag,forEachEntry:Rg,matchAll:Pg,isHTMLForm:Og,hasOwnProperty:pr,hasOwnProp:pr,hasOwnInPrototypeChain:hr,getSafeProp:Xm,toSafeFlatObject:Qm,reduceDescriptors:lf,freezeMethods:$g,toObjectSet:Cg,toCamelCase:kg,noop:Dg,toFiniteNumber:Ug,findKey:cf,global:Ft,isContextDefined:uf,isSpecCompliantForm:Mg,toJSONObject:Lg,isAsyncFn:Ng,isThenable:Bg,setImmediate:ff,asap:jg,isIterable:df,isSafeIterable:Zg};var Fg=d.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"]),pf=e=>{let t={},n,r,o;return e&&e.split(`
|
|
3
|
-
`).forEach(function(s){o=s.indexOf(":"),n=s.substring(0,o).trim().toLowerCase(),r=s.substring(o+1).trim();let a=d.hasOwnProp(t,n);!n||a&&d.hasOwnProp(Fg,n)||(n==="set-cookie"?a?t[n].push(r):t[n]=[r]:t[n]=a?t[n]+", "+r:r)}),t};function Hg(e){let t=0,n=e.length;for(;t<n;){let r=e.charCodeAt(t);if(r!==9&&r!==32)break;t+=1}for(;n>t;){let r=e.charCodeAt(n-1);if(r!==9&&r!==32)break;n-=1}return t===0&&n===e.length?e:e.slice(t,n)}var Gg=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),qg=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function
|
|
4
|
-
`)}getSetCookie(){let t=this.get("set-cookie");return d.isArray(t)?t:t==null||t===!1?[]:[t]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static parseParameters(t){return Yg(t)}static concat(t,...n){let r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){let r=(this[mf]=this[mf]={accessors:{}}).accessors,o=this.prototype;function i(s){let a=yr(s);r[a]||(ey(o,s),r[a]=!0)}return d.isArray(t)?t.forEach(i):i(t),this}};En.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);d.reduceDescriptors(En.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});d.freezeMethods(En);var ee=En;var wr="[REDACTED ****]";function ty(e){if(d.hasOwnProp(e,"toJSON"))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(d.hasOwnProp(t,"toJSON"))return!0;t=Object.getPrototypeOf(t)}return!1}function ny(e,t){let n=new Set(t.map(i=>String(i).toLowerCase())),r=[],o=i=>{if(i===null||typeof i!="object"||d.isBuffer(i))return i;if(r.indexOf(i)!==-1)return;i instanceof ee&&(i=i.toJSON()),r.push(i);let s;if(d.isArray(i))s=[],i.forEach((a,c)=>{let u=o(a);d.isUndefined(u)||(s[c]=u)});else{if(!d.isPlainObject(i)&&ty(i))return r.pop(),i;s=Object.create(null);for(let[a,c]of Object.entries(i)){let u=n.has(a.toLowerCase())?wr:o(c);d.isUndefined(u)||(s[a]=u)}}return r.pop(),s};return o(e)}function gf(e){try{return String(e)}catch{return""}}function ry(e){return e.errors.map(n=>{try{return n&&n.message?gf(n.message):gf(n)}catch{return""}}).filter(Boolean).join("; ")||e.name||"AggregateError"}var ue=class e extends Error{static from(t,n,r,o,i,s){let a=t.message;!a&&d.isArray(t.errors)&&t.errors.length&&(a=ry(t));let c=new e(a,n||t.code,r,o,i);return Object.defineProperty(c,"cause",{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),c.name=t.name,t.status!=null&&c.status==null&&(c.status=t.status),s&&Object.assign(c,s),c}constructor(t,n,r,o,i){super(t),Object.defineProperty(this,"message",{__proto__:null,value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),o&&(this.request=o),i&&(this.response=i,this.status=i.status)}toJSON(){let t=this.config,n=t&&d.hasOwnProp(t,"redact")?t.redact:void 0,r=d.isArray(n)&&n.length>0?ny(t,n):d.toJSONObject(t);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:r,code:this.code,status:this.status}}};ue.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";ue.ERR_BAD_OPTION="ERR_BAD_OPTION";ue.ECONNABORTED="ECONNABORTED";ue.ETIMEDOUT="ETIMEDOUT";ue.ECONNREFUSED="ECONNREFUSED";ue.ERR_NETWORK="ERR_NETWORK";ue.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";ue.ERR_DEPRECATED="ERR_DEPRECATED";ue.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";ue.ERR_BAD_REQUEST="ERR_BAD_REQUEST";ue.ERR_CANCELED="ERR_CANCELED";ue.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";ue.ERR_INVALID_URL="ERR_INVALID_URL";ue.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";var R=ue;var Et=null;var zs=100;function Is(e){return d.isPlainObject(e)||d.isArray(e)}function yf(e){return d.endsWith(e,"[]")?e.slice(0,-2):e}function ks(e,t,n){return e?e.concat(t).map(function(o,i){return o=yf(o),!n&&i?"["+o+"]":o}).join(n?".":""):t}function oy(e){return d.isArray(e)&&!e.some(Is)}var iy=d.toFlatObject(d,{},null,function(t){return/^is[A-Z]/.test(t)});function sy(e,t,n){if(!d.isObject(e))throw new TypeError("target must be an object");t=t||new(Et||FormData);let r=(_,S)=>{let b=d.getSafeProp(n,_);return d.isUndefined(b)?S:b},o=r("metaTokens",!0),i=r("visitor")||x,s=r("dots",!1),a=r("indexes",!1),c=r("Blob")||typeof Blob<"u"&&Blob,u=r("maxDepth",zs),l=c&&d.isSpecCompliantForm(t),f=[];if(!d.isFunction(i))throw new TypeError("visitor must be a function");function p(_){if(_===null)return"";if(d.isDate(_))return _.toISOString();if(d.isBoolean(_))return _.toString();if(!l&&d.isBlob(_))throw new R("Blob is not supported. Use a Buffer instead.");if(d.isArrayBuffer(_)||d.isTypedArray(_)){if(l&&typeof c=="function")return new c([_]);if(Et&&Et.isBufferAvailable())return Et.from(_);throw new R("Blob is not supported. Use a Buffer instead.",R.ERR_NOT_SUPPORT)}return _}function g(_){if(_>u)throw new R("Object is too deeply nested ("+_+" levels). Max depth: "+u,R.ERR_FORM_DATA_DEPTH_EXCEEDED)}function w(_,S){if(u===1/0)return JSON.stringify(_);let b=[];return JSON.stringify(_,function(O,I){if(!d.isObject(I))return I;for(;b.length&&b[b.length-1]!==this;)b.pop();return b.push(I),g(S+b.length-1),I})}function x(_,S,b){let v=_;if(d.isReactNative(t)&&d.isReactNativeBlob(_))return t.append(ks(b,S,s),p(_)),!1;if(_&&!b&&typeof _=="object"){if(d.endsWith(S,"{}"))S=o?S:S.slice(0,-2),_=w(_,1);else if(d.isArray(_)&&oy(_)||(d.isFileList(_)||d.endsWith(S,"[]"))&&(v=d.toArray(_)))return S=yf(S),v.forEach(function(I,z){!(d.isUndefined(I)||I===null)&&t.append(a===!0?ks([S],z,s):a===null?S:S+"[]",p(I))}),!1}return Is(_)?!0:(t.append(ks(b,S,s),p(_)),!1)}let A=Object.assign(iy,{defaultVisitor:x,convertValue:p,isVisitable:Is});function h(_,S,b=0){if(!d.isUndefined(_)){if(g(b),f.indexOf(_)!==-1)throw new Error("Circular reference detected in "+S.join("."));f.push(_),d.forEach(_,function(O,I){(!(d.isUndefined(O)||O===null)&&i.call(t,O,d.isString(I)?I.trim():I,S,A))===!0&&h(O,S?S.concat(I):[I],b+1)}),f.pop()}}if(!d.isObject(e))throw new TypeError("data must be an object");return h(e),t}var St=sy;function wf(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(r){return t[r]})}function bf(e,t){this._pairs=[],e&&St(e,this,t)}var _f=bf.prototype;_f.append=function(t,n){this._pairs.push([t,n])};_f.toString=function(t){let n=t?r=>t.call(this,r,wf):wf;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};var Co=bf;function ay(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function br(e,t,n){if(!t)return e;e=e||"";let r=d.isFunction(n)?{serialize:n}:n,o=d.getSafeProp(r,"encode")||ay,i=d.getSafeProp(r,"serialize"),s;if(i?s=i(t,r):s=d.isURLSearchParams(t)?t.toString():new Co(t,r).toString(o),s){let a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}var _r=Symbol("internals");function Ef(e){return e?e.length:0}function xf(e){if(e)for(;e.length&&e[e.length-1]===null;)e.pop()}function xr(e,t){let n=e.handlers,r=Ef(n);n!==t.handlersRef?(t.handlersRef=n,t.handlerEntries.clear()):r!==t.handlersLength&&(r?t.handlerEntries.forEach(function(i,s){n[i.index]!==i.handler&&t.handlerEntries.delete(s)}):t.handlerEntries.clear()),t.handlersLength=r}var $s=class{constructor(){this.handlers=[],this[_r]={handlersRef:this.handlers,handlersLength:this.handlers.length,handlerEntries:new Map,iterationDepth:0,nextId:0}}use(t,n,r){let o={fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null},i=this[_r];this.handlers==null&&(this.handlers=[]),xr(this,i);let s=i.nextId++;return this.handlers.push(o),i.handlerEntries.set(s,{handler:o,index:this.handlers.length-1}),i.handlersLength=this.handlers.length,s}eject(t){let n=this[_r];xr(this,n);let r=n.handlerEntries.get(t);if(r){if(n.handlerEntries.delete(t),this.handlers[r.index]!==r.handler)return;this.handlers[r.index]=null,n.iterationDepth||(xf(this.handlers),n.handlersLength=this.handlers.length)}}clear(){this.handlers&&(this.handlers=[],xr(this,this[_r]))}forEach(t){let n=this[_r];xr(this,n),n.iterationDepth++;try{d.forEach(this.handlers,function(o){o!==null&&t(o)})}finally{--n.iterationDepth||(xr(this,n),xf(this.handlers),n.handlersLength=Ef(this.handlers))}}},Cs=$s;var Sn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0};var Sf=typeof URLSearchParams<"u"?URLSearchParams:Co;var vf=typeof FormData<"u"?FormData:null;var Af=typeof Blob<"u"?Blob:null;var Tf={isBrowser:!0,classes:{URLSearchParams:Sf,FormData:vf,Blob:Af},protocols:["http","https","file","blob","url","data"]};var Ms={};Ap(Ms,{hasBrowserEnv:()=>Us,hasStandardBrowserEnv:()=>cy,hasStandardBrowserWebWorkerEnv:()=>uy,navigator:()=>Ds,origin:()=>ly});var Us=typeof window<"u"&&typeof document<"u",Ds=typeof navigator=="object"&&navigator||void 0,cy=Us&&(!Ds||["ReactNative","NativeScript","NS"].indexOf(Ds.product)<0),uy=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ly=Us&&window.location.href||"http://localhost";var W={...Ms,...Tf};function Ls(e,t){return St(e,new W.classes.URLSearchParams,{visitor:function(n,r,o,i){return W.isNode&&d.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}var Rf=zs;function Pf(e){if(e>Rf)throw new R("FormData field is too deeply nested ("+e+" levels). Max depth: "+Rf,R.ERR_FORM_DATA_DEPTH_EXCEEDED)}function fy(e){let t=[],n=/[^.[\]]+|\[([^.[\]]*)]/g,r;for(;(r=n.exec(e))!==null;)Pf(t.length),t.push(r[0]==="[]"?"":r[1]||r[0]);return t}function dy(e){let t={},n=Object.keys(e),r,o=n.length,i;for(r=0;r<o;r++)i=n[r],t[i]=e[i];return t}function py(e){function t(n,r,o,i){Pf(i);let s=n[i++];if(s==="__proto__")return!0;let a=Number.isFinite(+s),c=i>=n.length;return s=!s&&d.isArray(o)?o.length:s,c?(d.hasOwnProp(o,s)?o[s]=d.isArray(o[s])?o[s].concat(r):[o[s],r]:o[s]=r,!a):((!d.hasOwnProp(o,s)||!d.isObject(o[s]))&&(o[s]=[]),t(n,r,o[s],i)&&d.isArray(o[s])&&(o[s]=dy(o[s])),!a)}if(d.isFormData(e)&&d.isFunction(e.entries)){let n={};return d.forEachEntry(e,(r,o)=>{t(fy(r),o,n,0)}),n}return null}var Do=py;var hy=Object.freeze(["get","delete","head","options","post","put","patch","purge","link","unlink","query"]),Uo=hy;var vn=(e,t)=>e!=null&&d.hasOwnProp(e,t)?e[t]:void 0;function my(e,t,n){if(d.isString(e))try{return(t||JSON.parse)(e),d.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}var Ns={transitional:Sn,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){let r=n.getContentType()||"",o=r.indexOf("application/json")>-1,i=d.isObject(t);if(i&&d.isHTMLForm(t)&&(t=new FormData(t)),d.isFormData(t))return o?JSON.stringify(Do(t)):t;if(d.isArrayBuffer(t)||d.isBuffer(t)||d.isStream(t)||d.isFile(t)||d.isBlob(t)||d.isReadableStream(t))return t;if(d.isArrayBufferView(t))return t.buffer;if(d.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(i){let c=vn(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return Ls(t,c).toString();if((a=d.isFileList(t))||r.indexOf("multipart/form-data")>-1){let u=vn(this,"env"),l=u&&u.FormData;return St(a?{"files[]":t}:t,l&&new l,c)}}return i||o?(n.setContentType("application/json",!1),my(t)):t}],transformResponse:[function(t){let n=vn(this,"transitional")||Ns.transitional,r=n&&n.forcedJSONParsing,o=vn(this,"responseType"),i=o==="json";if(d.isResponse(t)||d.isReadableStream(t))return t;if(t&&d.isString(t)&&(r&&!o||i)){let a=!(n&&n.silentJSONParsing)&&i;try{return JSON.parse(t,vn(this,"parseReviver"))}catch(c){if(a)throw c.name==="SyntaxError"?R.from(c,R.ERR_BAD_RESPONSE,this,null,vn(this,"response")):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:W.classes.FormData,Blob:W.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};d.forEach(Uo,e=>{Ns.headers[e]={}});var An=Ns;function Er(e,t){let n=this||An,r=t||n,o=ee.from(r.headers),i=r.data;return d.forEach(e,function(a){i=a.call(n,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function Sr(e){return!!(e&&e.__CANCEL__)}var Bs=class extends R{constructor(t,n,r){super(t??"canceled",R.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}},Ve=Bs;function vr(e,t,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new R("Request failed with status code "+n.status,n.status>=400&&n.status<500?R.ERR_BAD_REQUEST:R.ERR_BAD_RESPONSE,n.config,n.request,n))}var gy=/[\t\n\r]/g;function Ar(e){if(typeof e!="string")return e;let t=0;for(;t<e.length&&e.charCodeAt(t)<=32;)t++;return e.slice(t).replace(gy,"")}function Tr(e){let t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}function yy(e,t){e=e||10;let n=new Array(e),r=new Array(e),o=0,i=0,s;return t=t!==void 0?t:1e3,function(c){let u=Date.now(),l=r[i];s||(s=u),n[o]=c,r[o]=u;let f=i,p=0;for(;f!==o;)p+=n[f++],f=f%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),u-s<t)return;let g=l&&u-l;return g?Math.round(p*1e3/g):void 0}}var Of=yy;function wy(e,t){let n=0,r=1e3/t,o,i,s=(l,f=Date.now())=>{n=f,o=null,i&&(clearTimeout(i),i=null),e(...l)};return[(...l)=>{let f=Date.now(),p=f-n;p>=r?s(l,f):(o=l,i||(i=setTimeout(()=>{i=null,s(o)},r-p)))},()=>o&&s(o),(...l)=>s(l)]}var kf=wy;var Tn=(e,t,n=3)=>{let r=0,o=Of(50,250);return kf(i=>{if(!i||!d.isNumber(i.loaded))return;let s=i.loaded,a=i.lengthComputable?i.total:void 0,c=Math.max(0,a!=null?Math.min(s,a):s),u=Math.max(0,c-r),l=o(u);r=Math.max(r,c);let f={loaded:c,total:a,progress:a?c/a:void 0,bytes:u,rate:l||void 0,estimated:l&&a?(a-c)/l:void 0,event:i,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},js=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Zs=(e,t=d.asap)=>(...n)=>t(()=>e(...n));var If=W.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,W.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(W.origin),W.navigator&&/(msie|trident)/i.test(W.navigator.userAgent)):()=>!0;var zf=W.hasStandardBrowserEnv?{write(e,t,n,r,o,i,s){if(typeof document>"u")return;let a=[`${e}=${encodeURIComponent(t)}`];d.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),d.isString(r)&&a.push(`path=${r}`),d.isString(o)&&a.push(`domain=${o}`),i===!0&&a.push("secure"),d.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(e){if(typeof document>"u")return null;let t=document.cookie.split(";");for(let n=0;n<t.length;n++){let r=t[n].replace(/^\s+/,""),o=r.indexOf("=");if(o!==-1&&r.slice(0,o)===e)try{return decodeURIComponent(r.slice(o+1))}catch{return r.slice(o+1)}}return null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Fs(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Hs(e,t){if(!t)return e;let n=e.length;for(;n>0&&e.charCodeAt(n-1)===47;)n--;return e.slice(0,n)+"/"+t.replace(/^\/+/,"")}var by=/^https?:(?!\/\/)/i;function _y(e){return e&&e.replace(/(^|&)([^=&]*=)?[^&]+/g,(t,n,r="")=>`${n}${r}${wr}`)}function xy(e){let t=e.replace(/^(https?:\/{0,2})[^/?#]*@/i,`$1${wr}@`),n=t.indexOf("#"),o=(n===-1?t:t.slice(0,n)).replace(/([?&][^=&#]*=)[^&#]*/g,`$1${wr}`);return n===-1?o:`${o}#${_y(t.slice(n+1))}`}function $f(e,t){if(typeof e=="string"){let n=Ar(e);if(by.test(n))throw new R(`Invalid URL ${JSON.stringify(xy(n))}: missing "//" after protocol`,R.ERR_INVALID_URL,t)}}function Rr(e,t,n,r){$f(t,r);let o=!Fs(t);return e&&(o||n===!1)?($f(e,r),Hs(e,t)):t}var Cf=e=>e instanceof ee?{...e}:e,Ey=e=>Object.getOwnPropertySymbols&&Object.getOwnPropertyDescriptor?Object.keys(e).concat(Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)):Object.keys(e);function Be(e,t){e=e||{},t=t||{};let n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(l,f,p,g){return d.isPlainObject(l)&&d.isPlainObject(f)?d.merge.call({caseless:g},l,f):d.isPlainObject(f)?d.merge({},f):d.isArray(f)?f.slice():f}function o(l,f,p,g){if(d.isUndefined(f)){if(!d.isUndefined(l))return r(void 0,l,p,g)}else return r(l,f,p,g)}function i(l,f){if(!d.isUndefined(f))return r(void 0,f)}function s(l,f){if(d.isUndefined(f)){if(!d.isUndefined(l))return r(void 0,l)}else return r(void 0,f)}function a(l){let f=d.hasOwnProp(t,"transitional")?t.transitional:void 0;if(!d.isUndefined(f))if(d.isPlainObject(f)){if(d.hasOwnProp(f,l))return f[l]}else return;let p=d.hasOwnProp(e,"transitional")?e.transitional:void 0;if(d.isPlainObject(p)&&d.hasOwnProp(p,l))return p[l]}function c(l,f,p){if(d.hasOwnProp(t,p))return r(l,f);if(d.hasOwnProp(e,p))return r(void 0,l)}let u={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutErrorMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,allowedSocketPaths:s,responseEncoding:s,validateStatus:c,headers:(l,f,p)=>o(Cf(l),Cf(f),p,!0)};return d.forEach(Ey({...e,...t}),function(f){if(f==="__proto__"||f==="constructor"||f==="prototype")return;let p=d.hasOwnProp(u,f)?u[f]:o,g=d.hasOwnProp(e,f)?e[f]:void 0,w=d.hasOwnProp(t,f)?t[f]:void 0,x=p(g,w,f);d.isUndefined(x)&&p!==c||(n[f]=x)}),d.hasOwnProp(t,"validateStatus")&&d.isUndefined(t.validateStatus)&&a("validateStatusUndefinedResolves")===!1&&(d.hasOwnProp(e,"validateStatus")?n.validateStatus=r(void 0,e.validateStatus):delete n.validateStatus),n}var Sy=["content-type","content-length"];function Gs(e,t,n){if(n!=="content-only"){e.set(t);return}Object.entries(t||{}).forEach(([r,o])=>{Sy.includes(r.toLowerCase())&&e.set(r,o)})}var vy=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16)));function Ay(e){let t=Be({},e),n=p=>d.hasOwnProp(t,p)?t[p]:void 0,r=n("data"),o=n("withXSRFToken"),i=n("xsrfHeaderName"),s=n("xsrfCookieName"),a=n("headers"),c=n("auth"),u=n("baseURL"),l=n("allowAbsoluteUrls"),f=n("url");if(t.headers=a=ee.from(a),t.url=br(Rr(u,f,l,t),n("params"),n("paramsSerializer")),c){let p=d.getSafeProp(c,"username")||"",g=d.getSafeProp(c,"password")||"";try{a.set("Authorization","Basic "+btoa(p+":"+(g?vy(g):"")))}catch(w){throw R.from(w,R.ERR_BAD_OPTION_VALUE,e)}}if(d.isFormData(r)){let p=d.getSafeProp(r,"getHeaders");W.hasStandardBrowserEnv||W.hasStandardBrowserWebWorkerEnv||d.isReactNative(r)?a.setContentType(void 0):d.isFunction(p)&&Gs(a,p.call(r),n("formDataHeaderPolicy"))}if(W.hasStandardBrowserEnv&&(d.isFunction(o)&&(o=o(t)),o===!0||o==null&&If(t.url))){let g=i&&s&&zf.read(s);g&&a.set(i,g)}return t}var Mo=Ay;var Ty=typeof XMLHttpRequest<"u",Df=Ty&&function(e){return new Promise(function(n,r){let o=Mo(e),i=o.data,s=ee.from(o.headers).normalize(),{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,l,f,p,g,w,x;function A(){g&&g(),w&&w(),o.cancelToken&&o.cancelToken.unsubscribe(l),o.signal&&o.signal.removeEventListener("abort",l)}let h=new XMLHttpRequest;h.open(o.method.toUpperCase(),o.url,!0),h.timeout=o.timeout;function _(b){if(!h)return;if(h.status===0&&(Tr(Ar(o.url))||Tr(W.origin))!=="file"&&!(h.responseURL&&h.responseURL.startsWith("file:"))){r(new R("Request aborted",R.ECONNABORTED,e,h)),A(),h=null;return}try{b?x&&x(b):w&&w()}catch(z){setTimeout(()=>{throw z})}if(!h)return;let v=ee.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),I={data:!a||a==="text"||a==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:v,config:e,request:h};vr(function(V){n(V),A()},function(V){r(V),A()},I),h=null}"onloadend"in h?h.onloadend=_:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.startsWith("file:"))||setTimeout(_)},h.onabort=function(){h&&(r(new R("Request aborted",R.ECONNABORTED,e,h)),A(),h=null)},h.onerror=function(v){let O=v&&v.message?v.message:"Network Error",I=new R(O,R.ERR_NETWORK,e,h);I.event=v||null,r(I),A(),h=null},h.ontimeout=function(){let v=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded",O=o.transitional||Sn;o.timeoutErrorMessage&&(v=o.timeoutErrorMessage),r(new R(v,O.clarifyTimeoutError?R.ETIMEDOUT:R.ECONNABORTED,e,h)),A(),h=null},i===void 0&&s.setContentType(null),"setRequestHeader"in h&&d.forEach(zo(s),function(v,O){h.setRequestHeader(O,v)}),d.isUndefined(o.withCredentials)||(h.withCredentials=!!o.withCredentials),a&&a!=="json"&&(h.responseType=o.responseType),u&&([p,w,x]=Tn(u,!0),h.addEventListener("progress",p)),c&&h.upload&&([f,g]=Tn(c),h.upload.addEventListener("progress",f),h.upload.addEventListener("loadend",g)),(o.cancelToken||o.signal)&&(l=b=>{h&&(r(!b||b.type?new Ve(null,e,h):b),h.abort(),A(),h=null)},o.cancelToken&&o.cancelToken.subscribe(l),o.signal&&(o.signal.aborted?l():o.signal.addEventListener("abort",l)));let S=Tr(o.url);if(S&&!W.protocols.includes(S)){r(new R("Unsupported protocol "+S+":",R.ERR_BAD_REQUEST,e)),A();return}h.send(i||null)})};var Ry=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;let n=new AbortController,r=!1,o=function(c){if(!r){r=!0,s();let u=c instanceof Error?c:this.reason;n.abort(u instanceof R?u:new Ve(u instanceof Error?u.message:u))}},i=t&&setTimeout(()=>{i=null,o(new R(`timeout of ${t}ms exceeded`,R.ETIMEDOUT))},t),s=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(o):c.removeEventListener("abort",o)}),e=null)};e.forEach(c=>{if(!r){if(c.aborted){o.call(c);return}c.addEventListener("abort",o,{once:!0})}});let{signal:a}=n;return a.unsubscribe=()=>d.asap(s),a},Uf=Ry;var Py=function*(e,t){let n=e.byteLength;if(!t||n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},Oy=async function*(e,t){for await(let n of ky(e))yield*Py(n,t)},ky=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},qs=(e,t,n,r)=>{let o=Oy(e,t),i=0,s,a=c=>{s||(s=!0,r&&r(c))};return new ReadableStream({async pull(c){try{let{done:u,value:l}=await o.next();if(u){a(),c.close();return}let f=l.byteLength;if(n){let p=i+=f;n(p)}c.enqueue(new Uint8Array(l))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})};var Mf=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,Nf=(e,t,n)=>t+2<n&&Mf(e.charCodeAt(t+1))&&Mf(e.charCodeAt(t+2)),Lf=e=>e<=57?e-48:(e&223)-55,Iy=e=>e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===43||e===47||e===45||e===95,zy=e=>e===9||e===10||e===12||e===13||e===32,$y=e=>{let t=Math.floor(e/4),n=e%4;return t*3+(n===2?1:n===3?2:0)},Cy=e=>{let t=e.length,n=0;return t>0&&e.charCodeAt(t-1)===61&&(n++,t>1&&e.charCodeAt(t-2)===61&&n++),Math.floor((t-n)*3/4)},Dy=e=>{let t=e.length,n=0,r=0,o=!1;for(let i=0;i<t;i++){let s=e.charCodeAt(i);if(s===37&&Nf(e,i,t)&&(s=Lf(e.charCodeAt(i+1))*16+Lf(e.charCodeAt(i+2)),i+=2),!zy(s)){if(s===61){r++;continue}if(!Iy(s)||r>0){o=!0;continue}n++}}return o||r>2||r>0&&(n+r)%4!==0||n%4===1?Cy(e):$y(n)},Uy=(e,t)=>{if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let n=e.indexOf(",");if(n<0)return 0;let r=e.slice(5,n),o=e.slice(n+1);if(/;base64/i.test(r))return t(o);let s=0;for(let a=0,c=o.length;a<c;a++){let u=o.charCodeAt(a);if(u===37&&Nf(o,a,c))s+=1,a+=2;else if(u<128)s+=1;else if(u<2048)s+=2;else if(u>=55296&&u<=56319&&a+1<c){let l=o.charCodeAt(a+1);l>=56320&&l<=57343?(s+=4,a++):s+=3}else s+=3}return s};function Js(e){let t=typeof e=="string"?e.indexOf("#"):-1;return Uy(t===-1?e:e.slice(0,t),Dy)}var Rn="1.20.0";var Bf=64*1024,My={cache:"default",redirect:"follow",referrer:"about:client",referrerPolicy:"",mode:"cors",integrity:"",keepalive:!1,priority:"auto",window:null},{isFunction:Lo}=d,Ly=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16))),jf=e=>{if(!d.isString(e))return e;try{return decodeURIComponent(e)}catch{return e}},Zf=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Ny=e=>{let t=e.indexOf("://"),n=e;return t!==-1&&(n=n.slice(t+3)),n.includes("@")||n.includes(":")},By=e=>{let t=d.global!==void 0&&d.global!==null?d.global:globalThis,{ReadableStream:n,TextEncoder:r}=t;e=d.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);let{fetch:o,Request:i,Response:s}=e,a=o?Lo(o):typeof fetch=="function",c=Lo(i),u=Lo(s);if(!a)return!1;let l=a&&Lo(n),f=a&&(typeof r=="function"?(h=>_=>h.encode(_))(new r):async h=>new Uint8Array(await new i(h).arrayBuffer())),p=c&&l&&Zf(()=>{let h=!1,_=new i(W.origin,{body:new n,method:"POST",get duplex(){return h=!0,"half"}}),S=_.headers.has("Content-Type");return _.body!=null&&_.body.cancel(),h&&!S}),g=u&&l&&Zf(()=>d.isReadableStream(new s("").body)),w={stream:g&&(h=>h.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!w[h]&&(w[h]=(_,S)=>{let b=_&&_[h];if(b)return b.call(_);throw new R(`Response type '${h}' is not supported`,R.ERR_NOT_SUPPORT,S)})});let x=async h=>{if(h==null)return 0;if(d.isBlob(h))return h.size;if(d.isSpecCompliantForm(h))return(await new i(W.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(d.isArrayBufferView(h)||d.isArrayBuffer(h))return h.byteLength;if(d.isURLSearchParams(h)&&(h=h+""),d.isString(h))return(await f(h)).byteLength},A=async(h,_)=>{let S=d.toFiniteNumber(h.getContentLength());return S??x(_)};return async h=>{let{url:_,method:S,data:b,signal:v,cancelToken:O,timeout:I,onDownloadProgress:z,onUploadProgress:V,responseType:J,headers:m,withCredentials:E="same-origin",fetchOptions:U,maxContentLength:L,maxBodyLength:H,maxRedirects:N}=Mo(h),Fe=d.isNumber(L)&&L>-1,Pt=d.isNumber(H)&&H>-1,Vr=G=>d.hasOwnProp(h,G)?h[G]:void 0,te=o||fetch;J=J?(J+"").toLowerCase():"text";let le=Uf([v,O&&O.toAbortSignal()],I),ce=null,Ot=le&&le.unsubscribe&&(()=>{le.unsubscribe()}),tn,Hn=null,rc=()=>new R("Request body larger than maxBodyLength limit",R.ERR_BAD_REQUEST,h,ce);try{let G,ke=Vr("auth");if(ke){let M=d.getSafeProp(ke,"username")||"",fe=d.getSafeProp(ke,"password")||"";G={username:M,password:fe}}if(Ny(_)){let M=new URL(_,W.origin);if(!G&&(M.username||M.password)){let fe=jf(M.username),pt=jf(M.password);G={username:fe,password:pt}}(M.username||M.password)&&(M.username="",M.password="",_=M.href)}if(G&&(m.delete("authorization"),m.set("Authorization","Basic "+btoa(Ly((G.username||"")+":"+(G.password||""))))),Fe&&typeof _=="string"&&_.startsWith("data:")&&Js(_)>L)throw new R("maxContentLength size of "+L+" exceeded",R.ERR_BAD_RESPONSE,h,ce);if(Pt&&S!=="get"&&S!=="head"){let M=await x(b);if(typeof M=="number"&&isFinite(M)&&(tn=M,M>H))throw rc()}let Wr=Pt&&(d.isReadableStream(b)||d.isStream(b)),oc=(M,fe,pt)=>qs(M,Bf,kt=>{if(Pt&&kt>H)throw Hn=rc();fe&&fe(kt)},pt);if(p&&S!=="get"&&S!=="head"&&(V||Wr)){if(tn=tn??await A(m,b),tn!==0||Wr){let M=new i(_,{method:"POST",body:b,duplex:"half"}),fe;if(d.isFormData(b)&&(fe=M.headers.get("content-type"))&&m.setContentType(fe),M.body){let[pt,kt]=V&&js(tn,Tn(Zs(V)))||[];b=oc(M.body,pt,kt)}}}else if(Wr&&!c&&l&&S!=="get"&&S!=="head")b=oc(b);else if(Wr&&c&&!p&&S!=="get"&&S!=="head")throw new R("Stream request bodies are not supported by the current fetch implementation",R.ERR_NOT_SUPPORT,h,ce);d.isString(E)||(E=E?"include":"omit");let Ep=c&&"credentials"in i.prototype;if(d.isFormData(b)){let M=m.getContentType();M&&/^multipart\/form-data/i.test(M)&&!/boundary=/i.test(M)&&m.delete("content-type")}m.set("User-Agent","axios/"+Rn,!1);let De=U==null?U:Object.assign(Object.create(null),U);De&&(delete De.body,delete De.headers,delete De.method,delete De.signal,delete De.duplex,delete De.credentials);let tt=Object.assign(Object.create(null),De,{signal:le,method:S.toUpperCase(),headers:zo(m.normalize()),body:b,duplex:"half",credentials:Ep?E:void 0});c&&(d.forEach(My,(M,fe)=>{tt[fe]===void 0&&(tt[fe]=M)}),tt.signal===void 0&&(tt.signal=null),tt.body===void 0&&(tt.body=null)),N===0&&(tt.redirect="manual",De&&(De.redirect="manual")),ce=c&&new i(_,tt);let nt=await(c?te(ce,De):te(_,tt)),ic=ee.from(nt.headers);if(Fe){let M=d.toFiniteNumber(ic.getContentLength());if(M!=null&&M>L)throw new R("maxContentLength size of "+L+" exceeded",R.ERR_BAD_RESPONSE,h,ce)}let Ui=g&&(J==="stream"||J==="response");if(g&&nt.body&&(z||Fe||Ui&&Ot)){let M={};["status","statusText","headers"].forEach(Gn=>{M[Gn]=nt[Gn]});let fe=d.toFiniteNumber(ic.getContentLength()),[pt,kt]=z&&js(fe,Tn(Zs(z),!0))||[],sc=0,Sp=Gn=>{if(Fe&&(sc=Gn,sc>L))throw new R("maxContentLength size of "+L+" exceeded",R.ERR_BAD_RESPONSE,h,ce);pt&&pt(Gn)};nt=new s(qs(nt.body,Bf,Sp,()=>{kt&&kt(),Ot&&Ot()}),M)}J=J||"text";let rt=await w[d.findKey(w,J)||"text"](nt,h);if(Fe&&!g&&!Ui){let M;if(rt!=null&&(typeof rt.byteLength=="number"?M=rt.byteLength:typeof rt.size=="number"?M=rt.size:typeof rt=="string"&&(M=typeof r=="function"?new r().encode(rt).byteLength:rt.length)),typeof M=="number"&&M>L)throw new R("maxContentLength size of "+L+" exceeded",R.ERR_BAD_RESPONSE,h,ce)}return!Ui&&Ot&&Ot(),await new Promise((M,fe)=>{vr(M,fe,{data:rt,headers:ee.from(nt.headers),status:nt.status,statusText:nt.statusText,config:h,request:ce})})}catch(G){if(Ot&&Ot(),le&&le.aborted&&le.reason instanceof R){let ke=le.reason;throw ke.config=h,ce&&(ke.request=ce),G!==ke&&Object.defineProperty(ke,"cause",{__proto__:null,value:G,writable:!0,enumerable:!1,configurable:!0}),ke}if(Hn)throw ce&&!Hn.request&&(Hn.request=ce),Hn;if(G instanceof R)throw ce&&!G.request&&(G.request=ce),G;if(G&&G.name==="TypeError"&&/Load failed|fetch/i.test(G.message)){let ke=new R("Network Error",R.ERR_NETWORK,h,ce,G&&G.response);throw Object.defineProperty(ke,"cause",{__proto__:null,value:G.cause||G,writable:!0,enumerable:!1,configurable:!0}),ke}throw R.from(G,G&&G.code,h,ce,G&&G.response)}}},jy=new Map,Ks=e=>{let t=e&&e.env||{},{fetch:n,Request:r,Response:o}=t,i=[r,o,n],s=i.length,a=s,c,u,l=jy;for(;a--;)c=i[a],u=l.get(c),u===void 0&&l.set(c,u=a?new Map:By(t)),l=u;return u},VT=Ks();var Vs={http:Et,xhr:Df,fetch:{get:Ks}};d.forEach(Vs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch{}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});var Ff=e=>`- ${e}`,Fy=e=>d.isFunction(e)||e===null||e===!1;function Hy(e,t){e=d.isArray(e)?e:[e];let{length:n}=e,r,o,i={};for(let s=0;s<n;s++){r=e[s];let a;if(o=r,!Fy(r)&&(o=Vs[(a=String(r)).toLowerCase()],o===void 0))throw new R(`Unknown adapter '${a}'`);if(o&&(d.isFunction(o)||(o=o.get(t))))break;i[a||"#"+s]=o}if(!o){let s=Object.entries(i).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build")),a=n?s.length>1?`since :
|
|
1
|
+
import{a as vp,b as Ap,c as Rp}from"./chunk-O4MIY67H.js";var Wf=vp((vt,Vf)=>{var Fo=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof global<"u"&&global,Ho=(function(){function e(){this.fetch=!1,this.DOMException=Fo.DOMException}return e.prototype=Fo,new e})();(function(e){var t=(function(n){var r=typeof e<"u"&&e||typeof self<"u"&&self||typeof global<"u"&&global||{},o={searchParams:"URLSearchParams"in r,iterable:"Symbol"in r&&"iterator"in Symbol,blob:"FileReader"in r&&"Blob"in r&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:"FormData"in r,arrayBuffer:"ArrayBuffer"in r};function i(m){return m&&DataView.prototype.isPrototypeOf(m)}if(o.arrayBuffer)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(m){return m&&s.indexOf(Object.prototype.toString.call(m))>-1};function c(m){if(typeof m!="string"&&(m=String(m)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(m)||m==="")throw new TypeError('Invalid character in header field name: "'+m+'"');return m.toLowerCase()}function u(m){return typeof m!="string"&&(m=String(m)),m}function l(m){var E={next:function(){var U=m.shift();return{done:U===void 0,value:U}}};return o.iterable&&(E[Symbol.iterator]=function(){return E}),E}function f(m){this.map={},m instanceof f?m.forEach(function(E,U){this.append(U,E)},this):Array.isArray(m)?m.forEach(function(E){if(E.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+E.length);this.append(E[0],E[1])},this):m&&Object.getOwnPropertyNames(m).forEach(function(E){this.append(E,m[E])},this)}f.prototype.append=function(m,E){m=c(m),E=u(E);var U=this.map[m];this.map[m]=U?U+", "+E:E},f.prototype.delete=function(m){delete this.map[c(m)]},f.prototype.get=function(m){return m=c(m),this.has(m)?this.map[m]:null},f.prototype.has=function(m){return this.map.hasOwnProperty(c(m))},f.prototype.set=function(m,E){this.map[c(m)]=u(E)},f.prototype.forEach=function(m,E){for(var U in this.map)this.map.hasOwnProperty(U)&&m.call(E,this.map[U],U,this)},f.prototype.keys=function(){var m=[];return this.forEach(function(E,U){m.push(U)}),l(m)},f.prototype.values=function(){var m=[];return this.forEach(function(E){m.push(E)}),l(m)},f.prototype.entries=function(){var m=[];return this.forEach(function(E,U){m.push([U,E])}),l(m)},o.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(m){if(!m._noBody){if(m.bodyUsed)return Promise.reject(new TypeError("Already read"));m.bodyUsed=!0}}function g(m){return new Promise(function(E,U){m.onload=function(){E(m.result)},m.onerror=function(){U(m.error)}})}function w(m){var E=new FileReader,U=g(E);return E.readAsArrayBuffer(m),U}function x(m){var E=new FileReader,U=g(E),M=/charset=([A-Za-z0-9_-]+)/.exec(m.type),H=M?M[1]:"utf-8";return E.readAsText(m,H),U}function A(m){for(var E=new Uint8Array(m),U=new Array(E.length),M=0;M<E.length;M++)U[M]=String.fromCharCode(E[M]);return U.join("")}function h(m){if(m.slice)return m.slice(0);var E=new Uint8Array(m.byteLength);return E.set(new Uint8Array(m)),E.buffer}function _(){return this.bodyUsed=!1,this._initBody=function(m){this.bodyUsed=this.bodyUsed,this._bodyInit=m,m?typeof m=="string"?this._bodyText=m:o.blob&&Blob.prototype.isPrototypeOf(m)?this._bodyBlob=m:o.formData&&FormData.prototype.isPrototypeOf(m)?this._bodyFormData=m:o.searchParams&&URLSearchParams.prototype.isPrototypeOf(m)?this._bodyText=m.toString():o.arrayBuffer&&o.blob&&i(m)?(this._bodyArrayBuffer=h(m.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(m)||a(m))?this._bodyArrayBuffer=h(m):this._bodyText=m=Object.prototype.toString.call(m):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof m=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):o.searchParams&&URLSearchParams.prototype.isPrototypeOf(m)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o.blob&&(this.blob=function(){var m=p(this);if(m)return m;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var m=p(this);return m||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(o.blob)return this.blob().then(w);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var m=p(this);if(m)return m;if(this._bodyBlob)return x(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(A(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o.formData&&(this.formData=function(){return this.text().then(O)}),this.json=function(){return this.text().then(JSON.parse)},this}var S=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function b(m){var E=m.toUpperCase();return S.indexOf(E)>-1?E:m}function v(m,E){if(!(this instanceof v))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');E=E||{};var U=E.body;if(m instanceof v){if(m.bodyUsed)throw new TypeError("Already read");this.url=m.url,this.credentials=m.credentials,E.headers||(this.headers=new f(m.headers)),this.method=m.method,this.mode=m.mode,this.signal=m.signal,!U&&m._bodyInit!=null&&(U=m._bodyInit,m.bodyUsed=!0)}else this.url=String(m);if(this.credentials=E.credentials||this.credentials||"same-origin",(E.headers||!this.headers)&&(this.headers=new f(E.headers)),this.method=b(E.method||this.method||"GET"),this.mode=E.mode||this.mode||null,this.signal=E.signal||this.signal||(function(){if("AbortController"in r){var N=new AbortController;return N.signal}})(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&U)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(U),(this.method==="GET"||this.method==="HEAD")&&(E.cache==="no-store"||E.cache==="no-cache")){var M=/([?&])_=[^&]*/;if(M.test(this.url))this.url=this.url.replace(M,"$1_="+new Date().getTime());else{var H=/\?/;this.url+=(H.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})};function O(m){var E=new FormData;return m.trim().split("&").forEach(function(U){if(U){var M=U.split("="),H=M.shift().replace(/\+/g," "),N=M.join("=").replace(/\+/g," ");E.append(decodeURIComponent(H),decodeURIComponent(N))}}),E}function I(m){var E=new f,U=m.replace(/\r?\n[\t ]+/g," ");return U.split("\r").map(function(M){return M.indexOf(`
|
|
2
|
+
`)===0?M.substr(1,M.length):M}).forEach(function(M){var H=M.split(":"),N=H.shift().trim();if(N){var Fe=H.join(":").trim();try{E.append(N,Fe)}catch(Pt){console.warn("Response "+Pt.message)}}}),E}_.call(v.prototype);function z(m,E){if(!(this instanceof z))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(E||(E={}),this.type="default",this.status=E.status===void 0?200:E.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=E.statusText===void 0?"":""+E.statusText,this.headers=new f(E.headers),this.url=E.url||"",this._initBody(m)}_.call(z.prototype),z.prototype.clone=function(){return new z(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},z.error=function(){var m=new z(null,{status:200,statusText:""});return m.ok=!1,m.status=0,m.type="error",m};var V=[301,302,303,307,308];z.redirect=function(m,E){if(V.indexOf(E)===-1)throw new RangeError("Invalid status code");return new z(null,{status:E,headers:{location:m}})},n.DOMException=r.DOMException;try{new n.DOMException}catch{n.DOMException=function(E,U){this.message=E,this.name=U;var M=Error(E);this.stack=M.stack},n.DOMException.prototype=Object.create(Error.prototype),n.DOMException.prototype.constructor=n.DOMException}function K(m,E){return new Promise(function(U,M){var H=new v(m,E);if(H.signal&&H.signal.aborted)return M(new n.DOMException("Aborted","AbortError"));var N=new XMLHttpRequest;function Fe(){N.abort()}N.onload=function(){var te={statusText:N.statusText,headers:I(N.getAllResponseHeaders()||"")};H.url.indexOf("file://")===0&&(N.status<200||N.status>599)?te.status=200:te.status=N.status,te.url="responseURL"in N?N.responseURL:te.headers.get("X-Request-URL");var le="response"in N?N.response:N.responseText;setTimeout(function(){U(new z(le,te))},0)},N.onerror=function(){setTimeout(function(){M(new TypeError("Network request failed"))},0)},N.ontimeout=function(){setTimeout(function(){M(new TypeError("Network request timed out"))},0)},N.onabort=function(){setTimeout(function(){M(new n.DOMException("Aborted","AbortError"))},0)};function Pt(te){try{return te===""&&r.location.href?r.location.href:te}catch{return te}}if(N.open(H.method,Pt(H.url),!0),H.credentials==="include"?N.withCredentials=!0:H.credentials==="omit"&&(N.withCredentials=!1),"responseType"in N&&(o.blob?N.responseType="blob":o.arrayBuffer&&(N.responseType="arraybuffer")),E&&typeof E.headers=="object"&&!(E.headers instanceof f||r.Headers&&E.headers instanceof r.Headers)){var Vr=[];Object.getOwnPropertyNames(E.headers).forEach(function(te){Vr.push(c(te)),N.setRequestHeader(te,u(E.headers[te]))}),H.headers.forEach(function(te,le){Vr.indexOf(le)===-1&&N.setRequestHeader(le,te)})}else H.headers.forEach(function(te,le){N.setRequestHeader(le,te)});H.signal&&(H.signal.addEventListener("abort",Fe),N.onreadystatechange=function(){N.readyState===4&&H.signal.removeEventListener("abort",Fe)}),N.send(typeof H._bodyInit>"u"?null:H._bodyInit)})}return K.polyfill=!0,r.fetch||(r.fetch=K,r.Headers=f,r.Request=v,r.Response=z),n.Headers=f,n.Request=v,n.Response=z,n.fetch=K,n})({})})(Ho);Ho.fetch.ponyfill=!0;delete Ho.fetch.polyfill;var kn=Fo.fetch?Fo:Ho;vt=kn.fetch;vt.default=kn.fetch;vt.fetch=kn.fetch;vt.Headers=kn.Headers;vt.Request=kn.Request;vt.Response=kn.Response;Vf.exports=vt});function ac(e){let t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function cc(e,t){return typeof t=="bigint"?t.toString():t}function uc(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function Xr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Mi(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Tp(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}var Ni="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Yr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Kn(e){if(Yr(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(Yr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}var lc=new Set(["string","number","symbol"]);function Bi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Jn(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function ne(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function fc(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var dc={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function pc(e,t){if(!Kn(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let i=e._zod.def.shape;for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=Tp(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Mi(this,"shape",i),i}});return Jn(e,o)}function zt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function hc(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function He(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function qn(e){return typeof e=="string"?e:e?.message}function ji(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function ot(e,t,n){var r;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:qn(e.inst?._zod.def?.error?.(e))??qn(i?.(e))??qn(t?.error?.(e))??qn(n.customError?.(e))??qn(n.localeError?.(e))??"Invalid input",{inst:a,schema:c,continue:u,input:l,...f}=e;return f.path??(f.path=[]),f.message=s,t?.reportInput&&(f.input=l),f}function Zi(...e){let[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function mc(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Pp(e,n,r.value)}}function It(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function gc(e,t,n){return It(e,t,n,!1)}function Pp(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:It(this,t,n.bind(this))},set(r){It(this,t,r)}})}function Op(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Li,ht=!1,kp={configurable:!0,get(){ht=!0}};function Ee(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Li!==e._zod){Li=void 0;return}Li=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,kp);let o=ht;ht=!1;try{let i=n(this);return ht?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),ht=ht||o,i}catch(i){throw delete this[t],ht=ht||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function yc(e,t,n,r){let o=Op(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,i),i.value=n(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:i})}})}var wc;var Fi={value:void 0,enumerable:!1},bc="captureStackTrace"in Error?Error:null;function Ip(e){let t=bc;if(t){let n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return bc=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function C(e,t,n,r){let o={};function i(p){this.def=p,this.constr=f,this.traits=new Set}i.prototype=o;let s=n,a=s&&new WeakSet;function c(p,g){if(!p._zod){Fi.value=new i(g);try{Object.defineProperty(p,"_zod",Fi)}finally{Fi.value=void 0}}if(p._zod.traits.has(e))return;if(p._zod.traits.add(e),t(p,g),a){let x=Object.getPrototypeOf(p),A=p._zod.constr.prototype,h=x;for(;h&&h!==A;)h=Object.getPrototypeOf(h);let _=h??x;a.has(_)||(a.add(_),mc(_,s))}let w=f.prototype;for(let x in w)Object.prototype.hasOwnProperty.call(w,x)&&(x in p||(p[x]=w[x].bind(p)))}let u=r?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function f(p){let g=r?.Parent?Ip(l):this;c(g,p);let w=g._zod.deferred;if(w){for(let A of w)A();g._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;return x&&x(g),g}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:p=>r?.Parent&&p instanceof r.Parent?!0:p?._zod?.traits?.has(e)}),Object.defineProperty(f,"name",{value:e}),f}var it=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(wc=globalThis).__zod_globalConfig??(wc.__zod_globalConfig={});var Ct=globalThis.__zod_globalConfig;function st(e){return e&&Object.assign(Ct,e),Ct}function zp(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,cc,2)),e.message}function $p(e){this._zod.message=e}var Cp={get:zp,set:$p,enumerable:!0,configurable:!0},Gi={value:void 0,enumerable:!1},qi={value:void 0,enumerable:!1},_c=new WeakSet([Object.prototype,Error.prototype]),xc=(e,t)=>{e.name="$ZodError",Gi.value=e._zod,Object.defineProperty(e,"_zod",Gi),qi.value=t,Object.defineProperty(e,"issues",qi),Gi.value=void 0,qi.value=void 0,Object.defineProperty(e,"message",Cp);let n=Object.getPrototypeOf(e);_c.has(n)||(_c.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},Ec=C("$ZodError",xc),Vn=C("$ZodError",xc,void 0,{Parent:Error});var Up=e=>{let t=(n,r,o,i)=>{let s=o?{...o,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new it;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map(u=>ot(u,s,st())));throw Ni(c,i?.callee??t),c}return a.value};return t},Qr=Up(Vn),Lp=e=>{let t=async(n,r,o,i)=>{let s=o?{...o,async:!0}:{async:!0},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(i?.Err??e)(a.issues.map(u=>ot(u,s,st())));throw Ni(c,i?.callee??t),c}return a.value};return t},eo=Lp(Vn),Mp=e=>(t,n,r)=>{let o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new it;return i.issues.length?{success:!1,error:new(e??Ec)(i.issues.map(s=>ot(s,o,st())))}:{success:!0,data:i.value}},Wn=Mp(Vn),Np=e=>async(t,n,r)=>{let o=r?{...r,async:!0}:{async:!0},i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>ot(s,o,st())))}:{success:!0,data:i.value}},Yn=Np(Vn);var Sc=/^https?$/;var vc=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Ac=/^-?\d+$/,Ki=/^-?\d+(?:\.\d+)?$/,Rc=/^(?:true|false)$/i;var Tc=/^undefined$/i;var Dt=C("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Pc={number:"number",bigint:"bigint",object:"date"};var Oc=C("$ZodCheckGreaterThan",(e,t)=>{Dt.init(e,t);let n=Pc[typeof t.value];e._zod.onattach.push(r=>{let o=r._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Pc[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}});var kc=C("$ZodCheckNumberFormat",(e,t)=>{Dt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[o,i]=dc[t.format];e._zod.onattach.push(s=>{let a=s._zod.bag;a.format=t.format,a.minimum=o,a.maximum=i,n&&(a.pattern=Ac)}),e._zod.check=s=>{let a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}});var Ic=C("$ZodCheckStringFormat",(e,t)=>{var n,r;Dt.init(e,t),e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})});var $c={major:4,minor:5,patch:4};var oe=C("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=$c;let r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let i of o)for(let s of i._zod.onattach)s(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,c,u)=>{if(a.memo)return a;let l=zt(a),f;for(let p of c){if(p._zod.def.when){if(hc(a)||!p._zod.def.when(a))continue}else if(l)continue;let g=a.issues.length,w=p._zod.check(a);if(w instanceof Promise&&u?.async===!1)throw new it;if(f||w instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await w,a.issues.length!==g&&(ji(a.issues,g,e),l||(l=zt(a,g)))});else{if(a.issues.length===g)continue;ji(a.issues,g,e),l||(l=zt(a,g))}}return f?f.then(()=>a):a},s=(a,c,u)=>{if(zt(a))return a.aborted=!0,a;let l=i(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new it;return l.then(f=>e._zod.parse(f,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(f=>s(f,a,c)):s(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new it;return u.then(l=>i(l,o,c))}return i(u,o,c)}}},{get"~standard"(){return gc(this,"~standard",Bp(this))},set"~standard"(e){It(this,"~standard",e)}}),Cc=e=>e.success?{value:e.data}:{issues:e.error?.issues};function Bp(e){return{validate:t=>{try{return Cc(Wn(e,t))}catch{return Yn(e,t).then(Cc)}},vendor:"zod",version:1}}var Wi=C("$ZodString",(e,t)=>{oe.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??vc(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Yi=C("$ZodStringFormat",(e,t)=>{Ic.init(e,t),Wi.init(e,t)});var Hc=1,Gc=2;function jp(e,t){if(!t.normalize&&t.protocol?.source===Sc.source&&!/^https?:\/\//i.test(e))return Hc;try{return new URL(e)}catch{return Gc}}var Zp=/[\t\n\r]/g;function Fp(e){return e.replace(Zp,"")}function Hp(e,t){return t.lastIndex=0,t.test(e.hostname)}function Gp(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var qc=C("$ZodURL",(e,t)=>{Yi.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),o=jp(r,t);if(o===Hc){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===Gc){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!Hp(o,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Gp(o,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?o.href:Fp(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}});var Xi=C("$ZodNumber",(e,t)=>{oe.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ki,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),Kc=C("$ZodNumberFormat",(e,t)=>{kc.init(e,t),Xi.init(e,t)}),Jc=C("$ZodBoolean",(e,t)=>{oe.init(e,t),e._zod.pattern=Rc,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}});var Vc=C("$ZodUndefined",(e,t)=>{oe.init(e,t),e._zod.pattern=Tc,e._zod.values=new Set([void 0]),e._zod.parse=(n,r)=>{let o=n.value;return typeof o>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),n}});var Wc=C("$ZodUnknown",(e,t)=>{oe.init(e,t),e._zod.parse=n=>n}),Yc=C("$ZodNever",(e,t)=>{oe.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Dc(e,t,n){e.issues.length&&t.issues.push(...He(n,e.issues)),t.value[n]=e.value}var Xc=C("$ZodArray",(e,t)=>{oe.init(e,t);let n=Ct.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);let s=[];for(let a=0;a<i.length;a++){let c=i[a],u=t.element._zod.run({value:c,issues:[]},o);u instanceof Promise?s.push(u.then(l=>Dc(l,r,a))):Dc(u,r,a)}return s.length?Promise.all(s).then(()=>r):r}});function to(e,t,n,r,o,i){let s=n in r,a=i==="optional";if(!(!s&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!s)return;t.issues.push(...He(n,e.issues))}if(!s&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?s&&(t.value[n]=void 0):t.value[n]=e.value}}var qp=[];function Kp(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:qp,o=r.length?[...t,...r]:t;for(let s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=fc(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function Jp(e,t,n,r,o,i){let s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,l=c.optin,f=c.optout;for(let p in t){if(a.has(p))continue;if(p==="__proto__"){u==="never"&&s.push(p);continue}if(u==="never"){s.push(p);continue}let g=c.run({value:t[p],issues:[]},r);g instanceof Promise?e.push(g.then(w=>to(w,n,p,t,l,f))):to(g,n,p,t,l,f)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var Uc=new WeakMap,Qc=C("$ZodObject",(e,t)=>{if(oe.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Uc.set(t,c),Object.defineProperty(t,"shape",{get:()=>{let u={...c};return Object.defineProperty(t,"shape",{value:u}),Uc.set(t,u),u}})}let r=uc(()=>Kp(t));Ee(e,"propValues",c=>{let u=c.def.shape,l={};for(let f in u){let p=u[f]._zod;if(p.values){Object.prototype.hasOwnProperty.call(l,f)||Mi(l,f,new Set);for(let g of p.values)l[f].add(g);p.optin!==void 0&&l[f].add(void 0)}}return l});let o=Yr,i=t.catchall,s,a=Ct.memoizer;a?.attach(e),e._zod.parse=(c,u)=>{s??(s=r.value);let l=c.value;if(!o(l))return c.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),c;c.value=a?a.alloc(e,c,{},u):{};let f=[],p=s.shape;for(let g of s.allKeys){if(g==="__proto__")continue;let w=p[g],x=w._zod.optin,A=w._zod.optout,h=w._zod.run({value:l[g],issues:[]},u);h instanceof Promise?f.push(h.then(_=>to(_,c,g,l,x,A))):to(h,c,g,l,x,A)}return i?Jp(f,l,c,u,r.value,e):f.length?Promise.all(f).then(()=>c):c}});function Lc(e,t,n,r){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter(i=>!zt(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>ot(s,r,st())))}),t)}var eu=C("$ZodUnion",(e,t)=>{oe.init(e,t),Ee(e,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),Ee(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Ee(e,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),Ee(e,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){let o=r.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>Xr(i.source)).join("|")})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}return i?Promise.all(s).then(a=>Lc(a,r,e,o)):Lc(s,r,e,o)}});var tu=C("$ZodIntersection",(e,t)=>{oe.init(e,t),e._zod.parse=(n,r)=>{let o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([c,u])=>Mc(n,c,u)):Mc(n,i,s)}});function Vi(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Kn(e)&&Kn(t)){let n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let i of r){if(i==="__proto__")continue;let s=Vi(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t[r],s=Vi(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Mc(e,t,n){let r=new Map,o,i=new Map,s=(u,l)=>{let f;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),f=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let p=String(u.path[0]);i.has(p)||i.set(p,u),f=[p]}else return!1;for(let p of f)r.has(p)||r.set(p,{}),r.get(p)[l]=!0;return!0};for(let u of t.issues)s(u,"l")||e.issues.push(u);for(let u of n.issues)s(u,"r")||e.issues.push(u);let a=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(let l of a)!u.includes(l)&&i.has(l)&&e.issues.push(i.get(l))}let c=Vi(t.value,n.value);if(!c.valid){if(zt(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var nu=C("$ZodTuple",(e,t)=>{oe.init(e,t);let n=t.items,r=Ct.memoizer;r?.attach(e),e._zod.parse=(o,i)=>{let s=o.value;if(!Array.isArray(s))return o.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];let a=[],c=Nc(n,"optin"),u=Nc(n,"optout");if(!t.rest){if(s.length<c)return o.issues.push({code:"too_small",minimum:c,inclusive:!0,input:s,inst:e,origin:"array"}),o;s.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}let l=new Array(n.length);for(let f=0;f<n.length;f++){let p=n[f]._zod.run({value:s[f],issues:[]},i);p instanceof Promise?a.push(p.then(g=>{l[f]=g})):l[f]=p}if(t.rest){let f=n.length-1,p=s.slice(n.length);for(let g of p){f++;let w=t.rest._zod.run({value:g,issues:[]},i);w instanceof Promise?a.push(w.then(x=>Bc(x,o,f))):Bc(w,o,f)}}return a.length?Promise.all(a).then(()=>jc(l,o,n,s,u)):jc(l,o,n,s,u)}});function Nc(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function Bc(e,t,n){e.issues.length&&t.issues.push(...He(n,e.issues)),t.value[n]=e.value}function jc(e,t,n,r,o){for(let i=0;i<n.length;i++){let s=e[i],a=i<r.length;if(!a&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(s.issues.length){if(!a&&i>=o){t.value.length=i;break}t.issues.push(...He(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=r.length&&(n[i]._zod.optout==="optional"&&t.value[i]===void 0);i--)t.value.length=i;return t}var ru=C("$ZodRecord",(e,t)=>{oe.init(e,t);let n=Ct.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Kn(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},o):{};let c=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let f=t.keyType._zod.run({value:l,issues:[]},o);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(w=>ot(w,o,st())),input:l,path:[l],inst:e});continue}let p=f.value;if(p==="__proto__")continue;let g=t.valueType._zod.run({value:i[l],issues:[]},o);g instanceof Promise?s.push(g.then(w=>{w.issues.length&&r.issues.push(...He(l,w.issues)),r.value[p]=w.value})):(g.issues.length&&r.issues.push(...He(l,g.issues)),r.value[p]=g.value)}let u;for(let l in i)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;r.value[l]=i[l]}else u=u??[],u.push(l);u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{r.value=n?n.alloc(e,r,{},o):{};let c;for(let u of Reflect.ownKeys(i)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&Ki.test(u)&&l.issues.length){let w=t.keyType._zod.run({value:Number(u),issues:[]},o);if(w instanceof Promise)throw new Error("Async schemas not supported in object keys currently");w.issues.length===0&&(l=w)}if(l.issues.length){t.mode==="loose"?r.value[u]=i[u]:a?(c=c??[],c.push(u)):r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(w=>ot(w,o,st())),input:u,path:[u],inst:e});continue}let p=l.value;if(p==="__proto__")continue;let g=t.valueType._zod.run({value:i[u],issues:[]},o);g instanceof Promise?s.push(g.then(w=>{w.issues.length&&r.issues.push(...He(u,w.issues)),r.value[p]=w.value})):(g.issues.length&&r.issues.push(...He(u,g.issues)),r.value[p]=g.value)}c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}return s.length?Promise.all(s).then(()=>r):r}});var ou=C("$ZodEnum",(e,t)=>{oe.init(e,t);let n=ac(t.entries),r=new Set(n);e._zod.values=r;let o=n.filter(i=>lc.has(typeof i));e._zod.pattern=new RegExp(o.length?`^(${o.map(i=>Bi(i.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(i,s)=>{let a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:n,input:a,inst:e}),i}});function Zc(e,t){return e.value=t.issues.length?void 0:t.value,e}var iu=C("$ZodOptional",(e,t)=>{oe.init(e,t),Ee(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",Ee(e,"values",n=>{let r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),Ee(e,"pattern",n=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Xr(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>Zc(n,i)):Zc(n,o)}return t.innerType._zod.run(n,r)}});var su=C("$ZodNullable",(e,t)=>{oe.init(e,t),Ee(e,"optin",n=>n.def.innerType._zod.optin),Ee(e,"optout",n=>n.def.innerType._zod.optout),Ee(e,"pattern",n=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Xr(r.source)}|null)$`):void 0}),Ee(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)});var au=C("$ZodCustom",(e,t)=>{Dt.init(e,t),oe.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{let r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>Fc(i,n,r,e));Fc(o,n,r,e)}});function Fc(e,t,n,r){if(!e){let o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Zi(o))}}function cu(e,t){return new e({type:"string",...ne(t)})}function uu(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ne(t)})}function lu(e,t){return new e({type:"number",checks:[],...ne(t)})}function fu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ne(t)})}function du(e,t){return new e({type:"boolean",...ne(t)})}function pu(e,t){return new e({type:"undefined",...ne(t)})}function hu(e){return new e({type:"unknown"})}function mu(e,t){return new e({type:"never",...ne(t)})}function Qi(e,t){return new Oc({check:"greater_than",...ne(t),value:e,inclusive:!0})}function Ut(e){return Qi(0,e)}function gu(e,t,n){let r=ne(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}var de=C("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");oe.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){It(this,"with",e)},parse(e,t){return Qr(this,e,t,{callee:this.parse})},parseAsync(e,t){return eo(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return Wn(this,e,t)},safeParseAsync(e,t){return Yn(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0})},clone(e,t){return Jn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}}),wu=C("ZodMiniString",(e,t)=>{Wi.init(e,t),de.init(e,t)});function B(e){return cu(wu,e)}var Yp=C("ZodMiniStringFormat",(e,t)=>{Yi.init(e,t),wu.init(e,t)});var Xp=C("ZodMiniURL",(e,t)=>{qc.init(e,t),Yp.init(e,t)});function Z(e){return uu(Xp,e)}var bu=C("ZodMiniNumber",(e,t)=>{Xi.init(e,t),de.init(e,t)});function _u(e){return lu(bu,e)}var Qp=C("ZodMiniNumberFormat",(e,t)=>{Kc.init(e,t),bu.init(e,t)});function nn(e){return fu(Qp,e)}var eh=C("ZodMiniBoolean",(e,t)=>{Jc.init(e,t),de.init(e,t)});function rn(e){return du(eh,e)}var th=C("ZodMiniUndefined",(e,t)=>{Vc.init(e,t),de.init(e,t)});function xu(e){return pu(th,e)}var nh=C("ZodMiniUnknown",(e,t)=>{Wc.init(e,t),de.init(e,t)});function rh(){return hu(nh)}var oh=C("ZodMiniNever",(e,t)=>{Yc.init(e,t),de.init(e,t)});function ih(e){return mu(oh,e)}var sh=C("ZodMiniArray",(e,t)=>{Xc.init(e,t),de.init(e,t)});function q(e,t){return new sh({type:"array",element:e,...ne(t)})}var es=C("ZodMiniObject",(e,t)=>{Qc.init(e,t),de.init(e,t),yc(e,"shape",n=>n._zod.def.shape,!1)});function Se(e,t){let n={type:"object",shape:e??{},...ne(t)};return new es(n)}function ye(e,t){return new es({type:"object",shape:e,catchall:ih(),...ne(t)})}function we(e,t){return new es({type:"object",shape:e,catchall:rh(),...ne(t)})}function at(e,t){return pc(e,t)}var ah=C("ZodMiniUnion",(e,t)=>{eu.init(e,t),de.init(e,t)});function ct(e,t){return new ah({type:"union",options:e,...ne(t)})}var ch=C("ZodMiniIntersection",(e,t)=>{tu.init(e,t),de.init(e,t)});function Eu(e,t){return new ch({type:"intersection",left:e,right:t})}var uh=C("ZodMiniTuple",(e,t)=>{nu.init(e,t),de.init(e,t)});function me(e,t,n){let r=t instanceof oe,o=r?n:t,i=r?t:null;return new uh({type:"tuple",items:e,rest:i,...ne(o)})}var yu=C("ZodMiniRecord",(e,t)=>{ru.init(e,t),de.init(e,t)});function Su(e,t,n){return!t||!t._zod?new yu({type:"record",keyType:B(),valueType:e,...ne(t)}):new yu({type:"record",keyType:e,valueType:t,...ne(n)})}var lh=C("ZodMiniEnum",(e,t)=>{ou.init(e,t),de.init(e,t),e.options=Object.values(t.entries)});function vu(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new lh({type:"enum",entries:n,...ne(t)})}var fh=C("ZodMiniOptional",(e,t)=>{iu.init(e,t),de.init(e,t)});function X(e){return new fh({type:"optional",innerType:e})}var dh=C("ZodMiniNullable",(e,t)=>{su.init(e,t),de.init(e,t)});function Ue(e){return new dh({type:"nullable",innerType:e})}var ph=C("ZodMiniCustom",(e,t)=>{au.init(e,t),de.init(e,t)});function Lt(e,t){return gu(ph,e??(()=>!0),t)}function on(e,t={}){let n=Lt(r=>r instanceof e,t);return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}var Tu=we({value:we({}),channels:q(B()),allowed:X(Ue(q(Z())))}),PS=at(Tu,{url:Z(),actor:Z()}),Au=ct([we({url:Z()}),Z()]),sn=we({actor:Z()}),no=X(Ue(sn)),Ru=ct([rn(),we({})]),Pu=we({data:on(Blob),allowed:X(Ue(q(Z())))}),OS=at(Pu,{actor:Z()}),mh=we({types:X(q(B())),maxBytes:X(nn().check(Ut()))}),ro=class{constructor(t){this.graffiti=t,this.sessionEvents=this.graffiti.sessionEvents}graffiti;sessionEvents;login=(...t)=>{let n=me([X(Ue(Z()))]).parse(t);return this.graffiti.login(...n)};logout=(...t)=>{let n=me([sn]).parse(t);return this.graffiti.logout(...n)};handleToActor=(...t)=>{let n=me([B()]).parse(t);return this.graffiti.handleToActor(...n)};actorToHandle=(...t)=>{let n=me([Z()]).parse(t);return this.graffiti.actorToHandle(...n)};post=(...t)=>{let n=me([Tu,sn]).parse(t);return this.graffiti.post(...n)};get=(...t)=>{let n=me([Au,Ru,no]).parse(t);return this.graffiti.get(n[0],n[1],n[2])};delete=(...t)=>{let n=me([Au,sn]).parse(t);return this.graffiti.delete(...n)};postMedia=(...t)=>{let n=me([Pu,sn]).parse(t);return this.graffiti.postMedia(...n)};getMedia=(...t)=>{let n=me([Z(),mh,no]).parse(t);return this.graffiti.getMedia(...n)};deleteMedia=(...t)=>{let n=me([Z(),sn]).parse(t);return this.graffiti.deleteMedia(...n)};discover=(...t)=>{let n=me([q(B()),Ru,no]).parse(t);return this.graffiti.discover(n[0],n[1],n[2])};continueDiscover=(...t)=>{let n=me([B(),no]).parse(t);return this.graffiti.continueDiscover(...n)}};var gh={type:"object",properties:{value:{type:"object"},channels:{type:"array",items:{type:"string"}},allowed:{type:"array",items:{type:"string"},nullable:!0},url:{type:"string"},actor:{type:"string"}},additionalProperties:!1,required:["value","channels","actor","url"]},zS={...gh,required:["value","channels"]};var mt=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorForbidden",Object.setPrototypeOf(this,e.prototype)}},Q=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,e.prototype)}},an=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorInvalidSchema",Object.setPrototypeOf(this,e.prototype)}},oo=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorSchemaMismatch",Object.setPrototypeOf(this,e.prototype)}},gt=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorTooLarge",Object.setPrototypeOf(this,e.prototype)}},io=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorNotAcceptable",Object.setPrototypeOf(this,e.prototype)}},Le=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorCursorExpired",Object.setPrototypeOf(this,e.prototype)}};function ns(e){return typeof e=="string"?e:e.url}function rs(e,t,n){if(n===e.actor)return e;let r=e.allowed&&n?[n]:void 0,o=e.channels.filter(i=>t.includes(i));return{...e,...r?{allowed:r}:{},channels:o}}function Ou(e,t){let[n,r]=e.toLowerCase().split(";")[0].split("/");return!n||!r?!1:t.some(o=>{let[i,s]=o.toLowerCase().split(";")[0].split("/");return!i||!s?!1:(i===n||i==="*")&&(s===r||s==="*")})}var ts;async function so(e){if(!ts){let{default:t}=await import("./ajv-X6C4R6QN.js");ts=new t({strict:!1})}try{return ts.compile(e)}catch(t){throw new an(t instanceof Error?t.message:String(t))}}function ku(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var os=e=>e?`"${e}" `:"";function Xn(e,t=""){if(typeof e!="number")throw new TypeError(os(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(os(t)+"expected integer >= 0, got "+e);return e}function Qn(e,t,n=""){if(ku(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Xn(t,"length");let r=ku(e),o=t!==void 0?` of length ${t}`:"",i=r?`length=${e.length}`:`type=${typeof e}`,s=os(n)+"expected Uint8Array"+o+", got "+i;throw r?new RangeError(s):new TypeError(s)}function Iu(e){return Uint8Array.from(Qn(e))}function zu(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(Xn(e.outputLen),Xn(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}function $u(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Mt(e=32){Xn(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var yh=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","Tagged"];function is(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(t==="string"||t==="number"||t==="bigint"||t==="symbol")return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";let n=wh(e);return n||"Object"}function wh(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(yh.includes(t))return t}var y=class{constructor(t,n,r){this.major=t,this.majorEncoded=t<<5,this.name=n,this.terminal=r}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}static equals(t,n){return t===n||t.major===n.major&&t.name===n.name}};y.uint=new y(0,"uint",!0);y.negint=new y(1,"negint",!0);y.bytes=new y(2,"bytes",!0);y.string=new y(3,"string",!0);y.array=new y(4,"array",!1);y.map=new y(5,"map",!1);y.tag=new y(6,"tag",!1);y.float=new y(7,"float",!0);y.false=new y(7,"false",!0);y.true=new y(7,"true",!0);y.null=new y(7,"null",!0);y.undefined=new y(7,"undefined",!0);y.break=new y(7,"break",!0);var P=class{constructor(t,n,r){this.type=t,this.value=n,this.encodedLength=r,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var er=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",bh=new TextEncoder;function ao(e){return er&&globalThis.Buffer.isBuffer(e)}function tr(e){return e instanceof Uint8Array?ao(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var _h=24,xh=200,co=er?e=>e.length>=_h?globalThis.Buffer.from(e):Cu(e):e=>e.length>=xh?bh.encode(e):Cu(e),Ge=e=>Uint8Array.from(e),Du=er?(e,t,n)=>ao(e)?new Uint8Array(e.subarray(t,n)):e.slice(t,n):(e,t,n)=>e.slice(t,n),Uu=er?(e,t)=>(e=e.map(n=>n instanceof Uint8Array?n:globalThis.Buffer.from(n)),tr(globalThis.Buffer.concat(e,t))):(e,t)=>{let n=new Uint8Array(t),r=0;for(let o of e)r+o.length>n.length&&(o=o.subarray(0,n.length-r)),n.set(o,r),r+=o.length;return n},ss=er?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function cn(e,t){if(ao(e)&&ao(t))return e.compare(t);for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return 0}function Cu(e){let t=[],n=0;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);o<128?t[n++]=o:o<2048?(t[n++]=o>>6|192,t[n++]=o&63|128):(o&64512)===55296&&r+1<e.length&&(e.charCodeAt(r+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++r)&1023),t[n++]=o>>18|240,t[n++]=o>>12&63|128,t[n++]=o>>6&63|128,t[n++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),t[n++]=o>>12|224,t[n++]=o>>6&63|128,t[n++]=o&63|128)}return t}var Eh=256,nr=class{constructor(t=Eh){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}pushByte(t){let n=this.chunks[this.chunks.length-1];this.cursor>this.maxCursor&&(n=ss(this.chunkSize),this.chunks.push(n),this.maxCursor+=n.length,this._initReuseChunk===null&&(this._initReuseChunk=n));let r=n.length-(this.maxCursor-this.cursor)-1;n[r]=t,this.cursor++}push(t){let n=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=n.length-(this.maxCursor-this.cursor)-1;n.set(t,o)}else{if(n){let o=n.length-(this.maxCursor-this.cursor)-1;o<n.length&&(this.chunks[this.chunks.length-1]=n.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(n=ss(this.chunkSize),this.chunks.push(n),this.maxCursor+=n.length,this._initReuseChunk===null&&(this._initReuseChunk=n),n.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let n;if(this.chunks.length===1){let r=this.chunks[0];t&&this.cursor>r.length/2?(n=this.cursor===r.length?r:r.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):n=Du(r,0,this.cursor)}else n=Uu(this.chunks,this.cursor);return t&&this.reset(),n}},uo=class{constructor(t){this.dest=t,this.cursor=0,this.chunks=[t]}reset(){this.cursor=0}pushByte(t){if(this.cursor>=this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest[this.cursor++]=t}push(t){if(this.cursor+t.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(t,this.cursor),this.cursor+=t.length}toBytes(t=!1){let n=this.dest.subarray(0,this.cursor);return t&&this.reset(),n}};var $="CBOR decode error:",lo="CBOR encode error:",rr=[];rr[23]=1;rr[24]=2;rr[25]=3;rr[26]=5;rr[27]=9;function ut(e,t,n){if(e.length-t<n)throw new Error(`${$} not enough data for type`)}var ae=[24,256,65536,4294967296,BigInt("18446744073709551616")];function ve(e,t,n){ut(e,t,1);let r=e[t];if(n.strict===!0&&r<ae[0])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return r}function Ae(e,t,n){ut(e,t,2);let r=e[t]<<8|e[t+1];if(n.strict===!0&&r<ae[1])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return r}function Re(e,t,n){ut(e,t,4);let r=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(n.strict===!0&&r<ae[2])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return r}function Te(e,t,n){ut(e,t,8);let r=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(r)<<BigInt(32))+BigInt(o);if(n.strict===!0&&i<ae[3])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(n.allowBigInt===!0)return i;throw new Error(`${$} integers outside of the safe integer range are not supported`)}function Lu(e,t,n,r){return new P(y.uint,ve(e,t+1,r),2)}function Mu(e,t,n,r){return new P(y.uint,Ae(e,t+1,r),3)}function Nu(e,t,n,r){return new P(y.uint,Re(e,t+1,r),5)}function Bu(e,t,n,r){return new P(y.uint,Te(e,t+1,r),9)}function qe(e,t){return ie(e,0,t.value)}function ie(e,t,n){if(n<ae[0]){let r=Number(n);e.pushByte(t|r)}else if(n<ae[1]){let r=Number(n);e.push([t|24,r])}else if(n<ae[2]){let r=Number(n);e.push([t|25,r>>>8,r&255])}else if(n<ae[3]){let r=Number(n);e.push([t|26,r>>>24&255,r>>>16&255,r>>>8&255,r&255])}else{let r=BigInt(n);if(r<ae[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(r&BigInt(4294967295)),s=Number(r>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${$} encountered BigInt larger than allowable range`)}}qe.encodedSize=function(t){return ie.encodedSize(t.value)};ie.encodedSize=function(t){return t<ae[0]?1:t<ae[1]?2:t<ae[2]?3:t<ae[3]?5:9};qe.compareTokens=function(t,n){return t.value<n.value?-1:t.value>n.value?1:0};function ju(e,t,n,r){return new P(y.negint,-1-ve(e,t+1,r),2)}function Zu(e,t,n,r){return new P(y.negint,-1-Ae(e,t+1,r),3)}function Fu(e,t,n,r){return new P(y.negint,-1-Re(e,t+1,r),5)}var as=BigInt(-1),Hu=BigInt(1);function Gu(e,t,n,r){let o=Te(e,t+1,r);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new P(y.negint,i,9)}if(r.allowBigInt!==!0)throw new Error(`${$} integers outside of the safe integer range are not supported`);return new P(y.negint,as-BigInt(o),9)}function fo(e,t){let n=t.value,r=typeof n=="bigint"?n*as-Hu:n*-1-1;ie(e,t.type.majorEncoded,r)}fo.encodedSize=function(t){let n=t.value,r=typeof n=="bigint"?n*as-Hu:n*-1-1;return r<ae[0]?1:r<ae[1]?2:r<ae[2]?3:r<ae[3]?5:9};fo.compareTokens=function(t,n){return t.value<n.value?1:t.value>n.value?-1:0};function or(e,t,n,r){ut(e,t,n+r);let o=e.slice(t+n,t+n+r);return new P(y.bytes,o,n+r)}function qu(e,t,n,r){return or(e,t,1,n)}function Ku(e,t,n,r){return or(e,t,2,ve(e,t+1,r))}function Ju(e,t,n,r){return or(e,t,3,Ae(e,t+1,r))}function Vu(e,t,n,r){return or(e,t,5,Re(e,t+1,r))}function Wu(e,t,n,r){let o=Te(e,t+1,r);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer bytes lengths not supported`);return or(e,t,9,o)}function po(e){return e.encodedBytes===void 0&&(e.encodedBytes=y.equals(e.type,y.string)?co(e.value):e.value),e.encodedBytes}function un(e,t){let n=po(t);ie(e,t.type.majorEncoded,n.length),e.push(n)}un.encodedSize=function(t){let n=po(t);return ie.encodedSize(n.length)+n.length};un.compareTokens=function(t,n){return vh(po(t),po(n))};function vh(e,t){return e.length<t.length?-1:e.length>t.length?1:cn(e,t)}var Yu=new TextDecoder,Rh=32;function Th(e,t,n){if(n-t<Rh){let o="";for(let i=t;i<n;i++){let s=e[i];if(s&128)return Yu.decode(e.subarray(t,n));o+=String.fromCharCode(s)}return o}return Yu.decode(e.subarray(t,n))}function ir(e,t,n,r,o){let i=n+r;ut(e,t,i);let s=new P(y.string,Th(e,t+n,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=e.slice(t+n,t+i)),s}function Xu(e,t,n,r){return ir(e,t,1,n,r)}function Qu(e,t,n,r){return ir(e,t,2,ve(e,t+1,r),r)}function el(e,t,n,r){return ir(e,t,3,Ae(e,t+1,r),r)}function tl(e,t,n,r){return ir(e,t,5,Re(e,t+1,r),r)}function nl(e,t,n,r){let o=Te(e,t+1,r);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer string lengths not supported`);return ir(e,t,9,o,r)}var rl=un;function ln(e,t,n,r){return new P(y.array,r,n)}function ol(e,t,n,r){return ln(e,t,1,n)}function il(e,t,n,r){return ln(e,t,2,ve(e,t+1,r))}function sl(e,t,n,r){return ln(e,t,3,Ae(e,t+1,r))}function al(e,t,n,r){return ln(e,t,5,Re(e,t+1,r))}function cl(e,t,n,r){let o=Te(e,t+1,r);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer array lengths not supported`);return ln(e,t,9,o)}function ul(e,t,n,r){if(r.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return ln(e,t,1,1/0)}function ho(e,t){ie(e,y.array.majorEncoded,t.value)}ho.compareTokens=qe.compareTokens;ho.encodedSize=function(t){return ie.encodedSize(t.value)};function fn(e,t,n,r){return new P(y.map,r,n)}function ll(e,t,n,r){return fn(e,t,1,n)}function fl(e,t,n,r){return fn(e,t,2,ve(e,t+1,r))}function dl(e,t,n,r){return fn(e,t,3,Ae(e,t+1,r))}function pl(e,t,n,r){return fn(e,t,5,Re(e,t+1,r))}function hl(e,t,n,r){let o=Te(e,t+1,r);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer map lengths not supported`);return fn(e,t,9,o)}function ml(e,t,n,r){if(r.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return fn(e,t,1,1/0)}function mo(e,t){ie(e,y.map.majorEncoded,t.value)}mo.compareTokens=qe.compareTokens;mo.encodedSize=function(t){return ie.encodedSize(t.value)};function gl(e,t,n,r){return new P(y.tag,n,1)}function yl(e,t,n,r){return new P(y.tag,ve(e,t+1,r),2)}function wl(e,t,n,r){return new P(y.tag,Ae(e,t+1,r),3)}function bl(e,t,n,r){return new P(y.tag,Re(e,t+1,r),5)}function _l(e,t,n,r){return new P(y.tag,Te(e,t+1,r),9)}function go(e,t){ie(e,y.tag.majorEncoded,t.value)}go.compareTokens=qe.compareTokens;go.encodedSize=function(t){return ie.encodedSize(t.value)};var yo=20,wo=21,bo=22,_o=23;function El(e,t,n,r){if(r.allowUndefined===!1)throw new Error(`${$} undefined values are not supported`);return r.coerceUndefinedToNull===!0?new P(y.null,null,1):new P(y.undefined,void 0,1)}function Sl(e,t,n,r){if(r.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return new P(y.break,void 0,1)}function cs(e,t,n){if(n){if(n.allowNaN===!1&&Number.isNaN(e))throw new Error(`${$} NaN values are not supported`);if(n.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${$} Infinity values are not supported`)}return new P(y.float,e,t)}function vl(e,t,n,r){return cs(xo(e,t+1),3,r)}function Al(e,t,n,r){return cs(Eo(e,t+1),5,r)}function Rl(e,t,n,r){return cs(Ol(e,t+1),9,r)}function sr(e,t,n){let r=t.value;if(r===!1)e.pushByte(y.float.majorEncoded|yo);else if(r===!0)e.pushByte(y.float.majorEncoded|wo);else if(r===null)e.pushByte(y.float.majorEncoded|bo);else if(r===void 0)e.pushByte(y.float.majorEncoded|_o);else{let o,i=!1;(!n||n.float64!==!0)&&(us(r),o=xo(se,1),r===o||Number.isNaN(r)?(se[0]=249,e.push(se.slice(0,3)),i=!0):(ls(r),o=Eo(se,1),r===o&&(se[0]=250,e.push(se.slice(0,5)),i=!0))),i||(Pl(r),o=Ol(se,1),se[0]=251,e.push(se.slice(0,9)))}}sr.encodedSize=function(t,n){let r=t.value;if(r===!1||r===!0||r===null||r===void 0)return 1;if(!n||n.float64!==!0){us(r);let o=xo(se,1);if(r===o||Number.isNaN(r))return 3;if(ls(r),o=Eo(se,1),r===o)return 5}return 9};var Tl=new ArrayBuffer(9),Ie=new DataView(Tl,1),se=new Uint8Array(Tl,0);function us(e){if(e===1/0)Ie.setUint16(0,31744,!1);else if(e===-1/0)Ie.setUint16(0,64512,!1);else if(Number.isNaN(e))Ie.setUint16(0,32256,!1);else{Ie.setFloat32(0,e);let t=Ie.getUint32(0),n=(t&2139095040)>>23,r=t&8388607;if(n===255)Ie.setUint16(0,31744,!1);else if(n===0)Ie.setUint16(0,(t&2147483648)>>16|r>>13,!1);else{let o=n-127;o<-24?Ie.setUint16(0,0):o<-14?Ie.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Ie.setUint16(0,(t&2147483648)>>16|o+15<<10|r>>13,!1)}}}function xo(e,t){if(e.length-t<2)throw new Error(`${$} not enough data for float16`);let n=(e[t]<<8)+e[t+1];if(n===31744)return 1/0;if(n===64512)return-1/0;if(n===32256)return NaN;let r=n>>10&31,o=n&1023,i;return r===0?i=o*2**-24:r!==31?i=(o+1024)*2**(r-25):i=o===0?1/0:NaN,n&32768?-i:i}function ls(e){Ie.setFloat32(0,e,!1)}function Eo(e,t){if(e.length-t<4)throw new Error(`${$} not enough data for float32`);let n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,4).getFloat32(0,!1)}function Pl(e){Ie.setFloat64(0,e,!1)}function Ol(e,t){if(e.length-t<8)throw new Error(`${$} not enough data for float64`);let n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,8).getFloat64(0,!1)}function zh(e,t){let n=e.value;if(n===!1)return Uint8Array.of(y.float.majorEncoded|yo);if(n===!0)return Uint8Array.of(y.float.majorEncoded|wo);if(n===null)return Uint8Array.of(y.float.majorEncoded|bo);if(n===void 0)return Uint8Array.of(y.float.majorEncoded|_o);if(!t){if(us(n),n===xo(se,1)||Number.isNaN(n))return se[0]=249,se.slice(0,3);if(ls(n),n===Eo(se,1))return se[0]=250,se.slice(0,5)}return Pl(n),se[0]=251,se.slice(0,9)}function xl(e,t){let n=e,r=t?.float64===!0,o=r?n._keyBytesFloat64:n._keyBytes;if(o!==void 0)return o;let i=zh(e,r);return r?n._keyBytesFloat64=i:n._keyBytes=i,i}sr.compareTokens=function(t,n,r){let o=xl(t,r),i=xl(n,r);return o.length!==i.length?o.length<i.length?-1:1:cn(o,i)};function j(e,t,n){throw new Error(`${$} encountered invalid minor (${n}) for major ${e[t]>>>5}`)}function So(e){return()=>{throw new Error(`${$} ${e}`)}}var R=[];for(let e=0;e<=23;e++)R[e]=j;R[24]=Lu;R[25]=Mu;R[26]=Nu;R[27]=Bu;R[28]=j;R[29]=j;R[30]=j;R[31]=j;for(let e=32;e<=55;e++)R[e]=j;R[56]=ju;R[57]=Zu;R[58]=Fu;R[59]=Gu;R[60]=j;R[61]=j;R[62]=j;R[63]=j;for(let e=64;e<=87;e++)R[e]=qu;R[88]=Ku;R[89]=Ju;R[90]=Vu;R[91]=Wu;R[92]=j;R[93]=j;R[94]=j;R[95]=So("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)R[e]=Xu;R[120]=Qu;R[121]=el;R[122]=tl;R[123]=nl;R[124]=j;R[125]=j;R[126]=j;R[127]=So("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)R[e]=ol;R[152]=il;R[153]=sl;R[154]=al;R[155]=cl;R[156]=j;R[157]=j;R[158]=j;R[159]=ul;for(let e=160;e<=183;e++)R[e]=ll;R[184]=fl;R[185]=dl;R[186]=pl;R[187]=hl;R[188]=j;R[189]=j;R[190]=j;R[191]=ml;for(let e=192;e<=215;e++)R[e]=gl;R[216]=yl;R[217]=wl;R[218]=bl;R[219]=_l;R[220]=j;R[221]=j;R[222]=j;R[223]=j;for(let e=224;e<=243;e++)R[e]=So("simple values are not supported");R[244]=j;R[245]=j;R[246]=j;R[247]=El;R[248]=So("simple values are not supported");R[249]=vl;R[250]=Al;R[251]=Rl;R[252]=j;R[253]=j;R[254]=j;R[255]=Sl;var Me=[];for(let e=0;e<24;e++)Me[e]=new P(y.uint,e,1);for(let e=-1;e>=-24;e--)Me[31-e]=new P(y.negint,e,1);Me[64]=new P(y.bytes,new Uint8Array(0),1);Me[96]=new P(y.string,"",1);Me[128]=new P(y.array,0,1);Me[160]=new P(y.map,0,1);Me[244]=new P(y.false,!1,1);Me[245]=new P(y.true,!0,1);Me[246]=new P(y.null,null,1);function fs(e){switch(e.type){case y.false:return Ge([244]);case y.true:return Ge([245]);case y.null:return Ge([246]);case y.bytes:return e.value.length?void 0:Ge([64]);case y.string:return e.value===""?Ge([96]):void 0;case y.array:return e.value===0?Ge([128]):void 0;case y.map:return e.value===0?Ge([160]):void 0;case y.uint:return e.value<24?Ge([Number(e.value)]):void 0;case y.negint:if(e.value>=-24)return Ge([31-Number(e.value)])}}var Ch={float64:!1,mapSorter:ps,quickEncodeToken:fs},Cl=Object.freeze({mapSorter:Lh,quickEncodeToken:fs});function Dh(){let e=[];return e[y.uint.major]=qe,e[y.negint.major]=fo,e[y.bytes.major]=un,e[y.string.major]=rl,e[y.array.major]=ho,e[y.map.major]=mo,e[y.tag.major]=go,e[y.float.major]=sr,e}var jt=Dh(),vo=new nr,pn=class e{constructor(t,n){this.obj=t,this.parent=n}includes(t){let n=this;do if(n.obj===t)return!0;while(n=n.parent);return!1}static createCheck(t,n){if(t&&t.includes(n))throw new Error(`${lo} object contains circular references`);return new e(n,t)}},yt={null:new P(y.null,null),undefined:new P(y.undefined,void 0),true:new P(y.true,!0),false:new P(y.false,!1),emptyArray:new P(y.array,0),emptyMap:new P(y.map,0)},Ke={number(e,t,n,r){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new P(y.float,e):e>=0?new P(y.uint,e):new P(y.negint,e)},bigint(e,t,n,r){return e>=BigInt(0)?new P(y.uint,e):new P(y.negint,e)},Uint8Array(e,t,n,r){return new P(y.bytes,e)},string(e,t,n,r){return new P(y.string,e)},boolean(e,t,n,r){return e?yt.true:yt.false},null(e,t,n,r){return yt.null},undefined(e,t,n,r){return yt.undefined},ArrayBuffer(e,t,n,r){return new P(y.bytes,new Uint8Array(e))},DataView(e,t,n,r){return new P(y.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,n,r){if(!e.length)return n.addBreakTokens===!0?[yt.emptyArray,new P(y.break)]:yt.emptyArray;r=pn.createCheck(r,e);let o=[],i=0;for(let s of e)o[i++]=Bt(s,n,r);return n.addBreakTokens?[new P(y.array,e.length),o,new P(y.break)]:[new P(y.array,e.length),o]},Object(e,t,n,r){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length,a;if(s){a=new Array(s),r=pn.createCheck(r,e);let c=!o&&n.ignoreUndefinedProperties,u=0;for(let l of i){let f=o?e.get(l):e[l];c&&f===void 0||(a[u++]=[Bt(l,n,r),Bt(f,n,r)])}u<s&&(a.length=u)}return a?.length?(Uh(a,n),n.addBreakTokens?[new P(y.map,a.length),a,new P(y.break)]:[new P(y.map,a.length),a]):n.addBreakTokens===!0?[yt.emptyMap,new P(y.break)]:yt.emptyMap},Tagged(e,t,n,r){return[new P(y.tag,e.tag),Bt(e.value,n,r)]}};Ke.Map=Ke.Object;Ke.Buffer=Ke.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ke[`${e}Array`]=Ke.DataView;function Bt(e,t={},n){let r=is(e),o=t&&t.typeEncoders&&t.typeEncoders[r]||Ke[r];if(typeof o=="function"){let s=o(e,r,t,n);if(s!=null)return s}let i=Ke[r];if(!i)throw new Error(`${lo} unsupported type: ${r}`);return i(e,r,t,n)}function Uh(e,t){let n=t.mapSorter;n&&e.sort((r,o)=>n(r,o,t))}function ps(e,t,n){let r=Array.isArray(e[0])?e[0][0]:e[0],o=Array.isArray(t[0])?t[0][0]:t[0];if(r.type.major!==o.type.major)return r.type.compare(o.type);let i=r.type.major,s=jt[i].compareTokens(r,o,n);return s===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),s}function Lh(e,t){if(e[0]instanceof P&&t[0]instanceof P){let n=e[0],r=t[0];return n._keyBytes||(n._keyBytes=kl(n.value)),r._keyBytes||(r._keyBytes=kl(r.value)),cn(n._keyBytes,r._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function kl(e){return Dl(e,jt,Cl)}function dn(e,t,n,r){if(Array.isArray(t))for(let o of t)dn(e,o,n,r);else n[t.type.major](e,t,r)}var Il=y.uint.majorEncoded,zl=y.negint.majorEncoded,Mh=y.bytes.majorEncoded,Nh=y.string.majorEncoded,$l=y.array.majorEncoded,ds=y.map.majorEncoded,Bh=y.float.majorEncoded|yo,jh=y.float.majorEncoded|wo,Zh=y.float.majorEncoded|bo,Fh=y.float.majorEncoded|_o,Hh=BigInt(-1),Gh=BigInt(1);function wt(e,t,n){n<24?e.pushByte(t|Number(n)):ie(e,t,n)}function qh(e){return e.addBreakTokens!==!0}function Kh(e,t,n,r,o){let i=n==="Map",s=i?t.keys():Object.keys(t),a=i?t.size:s.length;if(!a){e.pushByte(ds);return}o=pn.createCheck(o,t);let c=!i&&r.ignoreUndefinedProperties,u=new Array(a),l=0;for(let f of s){let p=i?t.get(f):t[f];c&&p===void 0||(u[l++]=[Bt(f,r,o),p])}if(l===0){e.pushByte(ds);return}l<a&&(u.length=l),u.sort((f,p)=>ps(f,p,r)),wt(e,ds,l);for(let[f,p]of u)dn(e,f,jt,r),hs(e,p,r,o)}function hs(e,t,n,r){let o=is(t),i=n.typeEncoders&&n.typeEncoders[o];if(i){let s=i(t,o,n,r);if(s!=null){dn(e,s,jt,n);return}}switch(o){case"null":e.pushByte(Zh);return;case"undefined":e.pushByte(Fh);return;case"boolean":e.pushByte(t?jh:Bh);return;case"number":!Number.isInteger(t)||!Number.isSafeInteger(t)?sr(e,new P(y.float,t),n):t>=0?wt(e,Il,t):wt(e,zl,t*-1-1);return;case"bigint":t>=BigInt(0)?wt(e,Il,t):wt(e,zl,t*Hh-Gh);return;case"string":{let s=co(t);wt(e,Nh,s.length),e.push(s);return}case"Uint8Array":wt(e,Mh,t.length),e.push(t);return;case"Array":if(!t.length){e.pushByte($l);return}r=pn.createCheck(r,t),wt(e,$l,t.length);for(let s of t)hs(e,s,n,r);return;case"Object":case"Map":if(n.mapSorter===ps)Kh(e,t,o,n,r);else{let s=Ke.Object(t,o,n,r);dn(e,s,jt,n)}return;default:{let s=Ke[o];if(!s)throw new Error(`${lo} unsupported type: ${o}`);let a=s(t,o,n,r);dn(e,a,jt,n)}}}function Dl(e,t,n,r){let o=r instanceof Uint8Array,i=o?new uo(r):vo,s=Bt(e,n);if(!Array.isArray(s)&&n.quickEncodeToken){let a=n.quickEncodeToken(s);if(a)return o?(i.push(a),i.toBytes()):a;let c=t[s.type.major];if(c.encodedSize){let u=c.encodedSize(s,n);if(o||(i=new nr(u)),c(i,s,n),i.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return o?i.toBytes():tr(i.chunks[0])}}return i.reset(),dn(i,s,t,n),i.toBytes(!0)}function ms(e,t){return t=Object.assign({},Ch,t),qh(t)?(vo.reset(),hs(vo,e,t,void 0),vo.toBytes(!0)):Dl(e,jt,t)}var Jh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Ao=class{constructor(t,n={}){this._pos=0,this.data=t,this.options=n}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],n=Me[t];if(n===void 0){let r=R[t];if(!r)throw new Error(`${$} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;n=r(this.data,this._pos,o,this.options)}return this._pos+=n.encodedLength,n}},bt=Symbol.for("DONE"),hn=Symbol.for("BREAK");function Vh(e,t,n){let r=[];for(let o=0;o<e.value;o++){let i=_t(t,n);if(i===hn){if(e.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed array`)}if(i===bt)throw new Error(`${$} found array but not enough entries (got ${o}, expected ${e.value})`);r[o]=i}return r}function Wh(e,t,n){let r=n.useMaps===!0,o=n.rejectDuplicateMapKeys===!0,i=r?void 0:{},s=r?new Map:void 0;for(let a=0;a<e.value;a++){let c=_t(t,n);if(c===hn){if(e.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed map`)}if(c===bt)throw new Error(`${$} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(!r&&typeof c!="string")throw new Error(`${$} non-string keys not supported (got ${typeof c})`);if(o&&(r&&s.has(c)||!r&&Object.hasOwn(i,c)))throw new Error(`${$} found repeat map key "${c}"`);let u=_t(t,n);if(u===bt)throw new Error(`${$} found map but not enough entries (got ${a} [no value], expected ${e.value})`);r?s.set(c,u):i[c]=u}return r?s:i}function*Yh(e,t,n){for(let r=0;r<e.value;r++){let o=_t(t,n);if(o===hn){if(e.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed map`)}if(o===bt)throw new Error(`${$} found map but not enough entries (got ${r} [no key], expected ${e.value})`);let i=_t(t,n);if(i===bt)throw new Error(`${$} found map but not enough entries (got ${r} [no value], expected ${e.value})`);yield[o,i]}}function Xh(e,t){let n=function(){if(n._called)throw new Error(`${$} tag decode() may only be called once`);n._called=!0;let r=_t(e,t);if(r===bt)throw new Error(`${$} tag content missing`);if(r===hn)throw new Error(`${$} got unexpected break in tag content`);return r};return n.entries=function(){if(n._called)throw new Error(`${$} tag decode() may only be called once`);n._called=!0;let r=e.next();if(!y.equals(r.type,y.map))throw new Error(`${$} entries() requires map content, got ${r.type.name}`);let o=[];for(let i of Yh(r,e,t))o.push(i);return o},n._called=!1,n}function _t(e,t){if(e.done())return bt;let n=e.next();if(y.equals(n.type,y.break))return hn;if(n.type.terminal)return n.value;if(y.equals(n.type,y.array))return Vh(n,e,t);if(y.equals(n.type,y.map))return Wh(n,e,t);if(y.equals(n.type,y.tag)){if(t.tags&&typeof t.tags[n.value]=="function"){let r=Xh(e,t),o=t.tags[n.value](r);if(!r._called)throw new Error(`${$} tag decoder must call decode() or entries()`);return o}throw new Error(`${$} tag not supported (${n.value})`)}throw new Error("unsupported")}function Ul(e,t){if(!(e instanceof Uint8Array))throw new Error(`${$} data to decode must be a Uint8Array`);t=Object.assign({},Jh,t);let n=tr(e),r=t.tokenizer||new Ao(n,t),o=_t(r,t);if(o===bt)throw new Error(`${$} did not find any content to decode`);if(o===hn)throw new Error(`${$} got unexpected break`);return[o,e.subarray(r.pos())]}function gs(e,t){let[n,r]=Ul(e,t);if(r.length>0)throw new Error(`${$} too many terminals, data makes no sense`);return n}var Ro=class e{constructor(t,n){if(typeof t!="number"||!Number.isInteger(t)||t<0)throw new TypeError("Tagged: tag must be a non-negative integer");this.tag=t,this.value=n}static decoder(t){return n=>new e(t,n())}static preserve(...t){let n={};for(let r of t)n[r]=e.decoder(r);return n}};Object.defineProperty(Ro.prototype,Symbol.toStringTag,{value:"Tagged"});var Fv=new Uint8Array(0);function Ll(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0}function mn(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return Zt(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return Zt(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));throw new Error("Unknown type, must be binary type")}function em(e){return e?.buffer instanceof ArrayBuffer}function Zt(e){return em(e)?e:e.slice()}function tm(e,t,n){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),o=0;o<r.length;o++)r[o]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");if(r[a]=i,n){var c=s.toLowerCase().charCodeAt(0),u=s.toUpperCase().charCodeAt(0);c!==a&&(r[c]=i),u!==a&&(r[u]=i)}}var l=e.length,f=e.charAt(0),p=Math.log(l)/Math.log(256),g=Math.log(256)/Math.log(l);function w(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var _=0,S=0,b=0,v=h.length;b!==v&&h[b]===0;)b++,_++;for(var O=(v-b)*g+1>>>0,I=new Uint8Array(O);b!==v;){for(var z=h[b],V=0,K=O-1;(z!==0||V<S)&&K!==-1;K--,V++)z+=256*I[K]>>>0,I[K]=z%l>>>0,z=z/l>>>0;if(z!==0)throw new Error("Non-zero carry");S=V,b++}for(var m=O-S;m!==O&&I[m]===0;)m++;for(var E=f.repeat(_);m<O;++m)E+=e.charAt(I[m]);return E}function x(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var _=0;if(h[_]!==" "){for(var S=0,b=0;h[_]===f;)S++,_++;for(var v=(h.length-_)*p+1>>>0,O=new Uint8Array(v);h[_];){var I=r[h.charCodeAt(_)];if(I===255)return;for(var z=0,V=v-1;(I!==0||z<b)&&V!==-1;V--,z++)I+=l*O[V]>>>0,O[V]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");b=z,_++}if(h[_]!==" "){for(var K=v-b;K!==v&&O[K]===0;)K++;for(var m=new Uint8Array(S+(v-K)),E=S;K!==v;)m[E++]=O[K++];return m}}}function A(h){var _=x(h);if(_)return _;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:x,decode:A}}var nm=tm,rm=nm,Ml=rm;var ys=class{name;prefix;baseEncode;constructor(t,n,r){this.name=t,this.prefix=n,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},ws=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,n,r){this.name=t,this.prefix=n;let o=n.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=r}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Nl(this,t)}},bs=class{decoders;constructor(t){this.decoders=t}or(t){return Nl(this,t)}decode(t){let n=t[0],r=this.decoders[n];if(r!=null)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Nl(e,t){return new bs({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var _s=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,n,r,o){this.name=t,this.prefix=n,this.baseEncode=r,this.baseDecode=o,this.encoder=new ys(t,n,r),this.decoder=new ws(t,n,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Bl({name:e,prefix:t,encode:n,decode:r}){return new _s(e,t,n,r)}function gn({name:e,prefix:t,alphabet:n,caseInsensitive:r=!1}){let{encode:o,decode:i}=Ml(n,e,r);return Bl({prefix:t,name:e,encode:o,decode:s=>mn(i(s))})}function om(e,t,n,r){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*n/8|0),s=0,a=0,c=0;for(let u=0;u<o;++u){let l=t[e[u]];if(l===void 0)throw new SyntaxError(`Non-${r} character`);a=a<<n|l,s+=n,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=n||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function im(e,t,n){let r=t[t.length-1]==="=",o=(1<<n)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>n;)s-=n,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<n-s]),r)for(;(i.length*n&7)!==0;)i+="=";return i}function sm(e,t){let n={};for(let r=0;r<e.length;++r)if(n[e[r]]=r,t){let o=e[r].toLowerCase(),i=e[r].toUpperCase();o!==e[r]&&(n[o]=r),i!==e[r]&&(n[i]=r)}return n}function Je({name:e,prefix:t,bitsPerChar:n,alphabet:r,caseInsensitive:o=!1}){let i=sm(r,o);return Bl({prefix:t,name:e,encode(s){return im(s,r,n)},decode(s){return om(s,i,n,e)}})}var ar=Je({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),Wv=Je({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),Yv=Je({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),Xv=Je({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),Qv=Je({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),eA=Je({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),tA=Je({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),nA=Je({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),rA=Je({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var To=gn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),sA=gn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var lt=gn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),uA=gn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var am=Fl,jl=128,cm=127,um=~cm,lm=Math.pow(2,31);function Fl(e,t,n){t=t||[],n=n||0;for(var r=n;e>=lm;)t[n++]=e&255|jl,e/=128;for(;e&um;)t[n++]=e&255|jl,e>>>=7;return t[n]=e|0,Fl.bytes=n-r+1,t}var fm=xs,dm=128,Zl=127;function xs(e,r){var n=0,r=r||0,o=0,i=r,s,a=e.length;do{if(i>=a)throw xs.bytes=0,new RangeError("Could not decode varint");s=e[i++],n+=o<28?(s&Zl)<<o:(s&Zl)*Math.pow(2,o),o+=7}while(s>=dm);return xs.bytes=i-r,n}var pm=Math.pow(2,7),hm=Math.pow(2,14),mm=Math.pow(2,21),gm=Math.pow(2,28),ym=Math.pow(2,35),wm=Math.pow(2,42),bm=Math.pow(2,49),_m=Math.pow(2,56),xm=Math.pow(2,63),Em=function(e){return e<pm?1:e<hm?2:e<mm?3:e<gm?4:e<ym?5:e<wm?6:e<bm?7:e<_m?8:e<xm?9:10},Sm={encode:am,decode:fm,encodingLength:Em},vm=Sm,cr=vm;function ur(e,t=0){let n=cr.decode(e,t),r=cr.decode.bytes;if(r>9)throw new RangeError("Invalid varint: too long");if(r>1&&e[t+r-1]===0)throw new RangeError("Invalid varint: not minimally encoded");return[n,r]}function yn(e,t,n=0){return cr.encode(e,t,n),t}function wn(e){return cr.encodingLength(e)}function Gl(e,t){let n=t.byteLength,r=wn(e),o=r+wn(n),i=new Uint8Array(o+n);return yn(e,i,0),yn(n,i,r),i.set(t,o),new bn(e,n,t,i)}function ql(e){let t=mn(e),[n,r]=ur(t),[o,i]=ur(t.subarray(r)),s=t.subarray(r+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new bn(n,o,s,t)}function Kl(e,t){if(e===t)return!0;{let n=t;return e.code===n.code&&e.size===n.size&&n.bytes instanceof Uint8Array&&Ll(e.bytes,n.bytes)}}var bn=class{code;size;digest;bytes;constructor(t,n,r,o){this.code=t,this.size=n,this.digest=Zt(r),this.bytes=Zt(o)}};function Jl(e,t){let{bytes:n,version:r}=e;return r===0?Tm(n,Es(e),t??lt.encoder):Pm(n,Es(e),t??ar.encoder)}var Vl=new WeakMap;function Es(e){let t=Vl.get(e);if(t==null){let n=new Map;return Vl.set(e,n),n}return t}var fr=class e{code;version;multihash;bytes;"/";constructor(t,n,r,o){this.code=n,this.version=t,this.multihash=r,this.bytes=Zt(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:n}=this;if(t!==lr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(n.code!==Om)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(n)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:n}=this.multihash,r=Gl(t,n);return e.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,n){let r=n;return r!=null&&t.code===r.code&&t.version===r.version&&Kl(t.multihash,r.multihash)}toString(t){return Jl(this,t)}toJSON(){return{"/":Jl(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let n=t;if(n instanceof e)return n;if(n["/"]!=null&&n["/"]===n.bytes||n.asCID===n){let{version:r,code:o,multihash:i,bytes:s}=n;return new e(r,o,i,s??Wl(r,o,i.bytes))}else if(n[km]===!0){let{version:r,multihash:o,code:i}=n,s=ql(o);return e.create(r,i,s)}else return null}static create(t,n,r){if(typeof n!="number")throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(n!==lr)throw new Error(`Version 0 CID must use dag-pb (code: ${lr}) block encoding`);return new e(t,n,r,r.bytes)}case 1:{let o=Wl(t,n,r.bytes);return new e(t,n,r,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,lr,t)}static createV1(t,n){return e.create(1,t,n)}static decode(t){let[n,r]=e.decodeFirst(t);if(r.length!==0)throw new Error("Incorrect length");return n}static decodeFirst(t){let n=e.inspectBytes(t),r=n.size-n.multihashSize,o=mn(t.subarray(r,r+n.multihashSize));if(o.byteLength!==n.multihashSize)throw new Error("Incorrect length");let i=o.subarray(n.multihashSize-n.digestSize),s=new bn(n.multihashCode,n.digestSize,i,o);return[n.version===0?e.createV0(s):e.createV1(n.codec,s),t.subarray(n.size)]}static inspectBytes(t){let n=0,r=()=>{let[f,p]=ur(t.subarray(n));return n+=p,f},o=r(),i=lr;if(o===18?(o=0,n=0):i=r(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=n,a=r(),c=r(),u=n+c,l=u-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:l,size:u}}static parse(t,n){let[r,o]=Rm(t,n),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Es(i).set(r,t),i}};function Rm(e,t){switch(e[0]){case"Q":{let n=t??lt;return[lt.prefix,n.decode(`${lt.prefix}${e}`)]}case lt.prefix:{let n=t??lt;return[lt.prefix,n.decode(e)]}case ar.prefix:{let n=t??ar;return[ar.prefix,n.decode(e)]}case To.prefix:{let n=t??To;return[To.prefix,n.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Tm(e,t,n){let{prefix:r}=n;if(r!==lt.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);let o=t.get(r);if(o==null){let i=n.encode(e).slice(1);return t.set(r,i),i}else return o}function Pm(e,t,n){let{prefix:r}=n,o=t.get(r);if(o==null){let i=n.encode(e);return t.set(r,i),i}else return o}var lr=112,Om=18;function Wl(e,t,n){let r=wn(e),o=r+wn(t),i=new Uint8Array(o+n.byteLength);return yn(e,i,0),yn(t,i,r),i.set(n,o),i}var km=Symbol.for("@ipld/js-cid/CID");var Yl=42;function Im(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function zm(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=fr.asCID(e);if(!t)return null;let n=new Uint8Array(t.bytes.byteLength+1);return n.set(t.bytes,1),[new P(y.tag,Yl),new P(y.bytes,n)]}function $m(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Cm(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}function Dm(e){for(let t of e.keys())if(typeof t!="string"||t.length===0)throw new Error("Non-string Map keys are not supported by the IPLD Data Model and cannot be encoded");return null}var Ss={float64:!0,typeEncoders:{Map:Dm,Object:zm,undefined:$m,number:Cm}},xA={...Ss,typeEncoders:{...Ss.typeEncoders}};function Um(e){let t=e();if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return fr.decode(t.subarray(1))}var vs={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:{[Yl]:Um}},EA={...vs,tags:{...vs.tags}};var pe=e=>ms(e,Ss),Ne=e=>gs(Im(e),vs);function Lm(){let e=new Map;return async(t,n)=>{if(t.params&&t.params["no-cache"]==="true")return await n();let r=e.get(t.didUrl);if(r!==void 0)return r;let o=await n();return o.didResolutionMetadata?.error!=="notFound"&&e.set(t.didUrl,o),o}}function Mm(e,t){return t()}var Nm="(?:%[0-9a-fA-F]{2})",Xl=`(?:[a-zA-Z0-9._-]|${Nm})`,Bm="([a-z0-9]+)",jm=`((?:${Xl}*:)*(${Xl}+))`,Ql="[a-zA-Z0-9_.:%-]",Zm=`;${Ql}+=${Ql}*`,Fm=`((${Zm})*)`,Hm="(/[^#?]*)?",Gm="([?][^#]*)?",qm="(#.*)?",Km=new RegExp(`^did:${Bm}:${jm}${Fm}${Hm}${Gm}${qm}$`);function Jm(e){if(e===""||!e)return null;let t=e.match(Km);if(t){let n={did:`did:${t[1]}:${t[2]}`,method:t[1],id:t[2],didUrl:e};if(t[4]){let r=t[4].slice(1).split(";");n.params={};for(let o of r){let i=o.split("=");n.params[i[0]]=i[1]}}return t[6]&&(n.path=t[6]),t[7]&&(n.query=t[7].slice(1)),t[8]&&(n.fragment=t[8].slice(1)),n}return null}var Po={didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};function Vm(e){return async(t,n,r)=>{try{let o=await e(t,n,r);return{...Po,didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:o}}catch(o){return{...Po,didResolutionMetadata:{error:"notFound",message:o.toString()}}}}}var Oo=class{constructor(t={},n={}){this.registry=t,this.cache=n.cache===!0?Lm():n.cache||Mm,n.legacyResolvers&&Object.keys(n.legacyResolvers).map(r=>{this.registry[r]||(this.registry[r]=Vm(n.legacyResolvers[r]))})}async resolve(t,n={}){let r=Jm(t);if(r===null)return{...Po,didResolutionMetadata:{error:"invalidDid"}};let o=this.registry[r.method];return o?this.cache(r,()=>o(r.did,r,this,n)):{...Po,didResolutionMetadata:{error:"unsupportedDidMethod"}}}};function dr(e,t){return function(){return e.apply(t,arguments)}}var{toString:Wm}=Object.prototype,{getPrototypeOf:xt}=Object,{iterator:mr,toStringTag:nf}=Symbol,pr=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),rf=e=>typeof e=="string"&&(e==="__proto__"||e==="constructor"||e==="prototype"),of=(e,t,n)=>e===Object.prototype||!n&&t===null,Ym=e=>{if(!Object.isExtensible(e))return!1;let t=Object.getOwnPropertyNames(e);return Object.getOwnPropertySymbols&&t.push(...Object.getOwnPropertySymbols(e)),t.every(n=>{if(rf(n))return!1;let r=Object.getOwnPropertyDescriptor(e,n);return!!r&&r.configurable&&r.writable===!0})},hr=(e,t)=>{let n=e,r=[];for(;n!=null;){if(r.indexOf(n)!==-1)return!1;r.push(n);let o=xt(n);if(of(n,o,n===e))return!1;if(pr(n,t))return!0;n=o}return!1},Xm=(e,t)=>e!=null&&hr(e,t)?e[t]:void 0,Qm=e=>{if(e==null||typeof e!="object"&&typeof e!="function")return e;let t=xt(e);if(t===null&&Ym(e))return e;let n=Object.create(null),r=Object.create(null),o=[],i=e;for(;i!=null&&o.indexOf(i)===-1;){o.push(i);let s=i===e?t:xt(i);if(of(i,s,i===e))break;let a=Object.getOwnPropertyNames(i);Object.getOwnPropertySymbols&&a.push(...Object.getOwnPropertySymbols(i));for(let c of a)rf(c)||pr(r,c)||(n[c]=e[c],r[c]=!0);i=s}return n},Rs=(e=>t=>{let n=Wm.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ze=e=>(e=e.toLowerCase(),t=>Rs(t)===e),Io=e=>t=>typeof t===e,{isArray:Ht}=Array,Gt=Io("undefined");function _n(e){return e!==null&&!Gt(e)&&e.constructor!==null&&!Gt(e.constructor)&&be(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var sf=ze("ArrayBuffer");function eg(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&sf(e.buffer),t}var tg=Io("string"),be=Io("function"),af=Io("number"),xn=e=>e!==null&&typeof e=="object",ng=e=>e===!0||e===!1,ko=e=>{if(!xn(e))return!1;let t=xt(e);return(t===null||t===Object.prototype||xt(t)===null)&&!hr(e,nf)&&!hr(e,mr)},rg=e=>{if(!xn(e)||_n(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},og=ze("Date"),ig=ze("File"),sg=e=>!!(e&&typeof e.uri<"u"),ag=e=>e&&typeof e.getParts<"u",cg=ze("Blob"),ug=ze("FileList"),lg=ze("Set"),fg=e=>xn(e)&&be(e.pipe);function dg(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}var ef=dg(),tf=typeof ef.FormData<"u"?ef.FormData:void 0,pg=e=>{if(!e)return!1;if(tf&&e instanceof tf)return!0;let t=xt(e);if(!t||t===Object.prototype||!be(e.append))return!1;let n=Rs(e);return n==="formdata"||n==="object"&&be(e.toString)&&e.toString()==="[object FormData]"},hg=ze("URLSearchParams"),[mg,gg,yg,wg]=["ReadableStream","Request","Response","Headers"].map(ze),bg=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function gr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Ht(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(_n(e))return;let i=n?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length,a;for(r=0;r<s;r++)a=i[r],t.call(null,e[a],a,e)}}function cf(e,t){if(_n(e))return null;t=t.toLowerCase();let n=Object.keys(e),r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}var Ft=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,uf=e=>!Gt(e)&&e!==Ft;function As(...e){let{caseless:t,skipUndefined:n}=uf(this)&&this||{},r={},o=(i,s)=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;let a=t&&typeof s=="string"&&cf(r,s)||s,c=pr(r,a)?r[a]:void 0;ko(c)&&ko(i)?r[a]=As(c,i):ko(i)?r[a]=As({},i):Ht(i)?r[a]=i.slice():(!n||!Gt(i))&&(r[a]=i)};for(let i=0,s=e.length;i<s;i++){let a=e[i];if(!a||_n(a)||(gr(a,o),typeof a!="object"||Ht(a)))continue;let c=Object.getOwnPropertySymbols(a);for(let u=0;u<c.length;u++){let l=c[u];Ig.call(a,l)&&o(a[l],l)}}return r}var _g=(e,t,n,{allOwnKeys:r}={})=>(gr(t,(o,i)=>{n&&be(o)?Object.defineProperty(e,i,{__proto__:null,value:dr(o,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{__proto__:null,value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),xg=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Eg=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},Sg=(e,t,n,r)=>{let o,i,s,a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],(!r||r(s,e,t))&&!a[s]&&(t[s]=e[s],a[s]=!0);e=n!==!1&&xt(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},vg=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},Ag=e=>{if(!e)return null;if(Ht(e))return e;let t=e.length;if(!af(t))return null;let n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Rg=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&xt(Uint8Array)),Tg=(e,t)=>{let r=(e&&e[mr]).call(e),o;for(;(o=r.next())&&!o.done;){let i=o.value;t.call(e,i[0],i[1])}},Pg=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Og=ze("HTMLFormElement"),kg=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),{propertyIsEnumerable:Ig}=Object.prototype,zg=ze("RegExp"),lf=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};gr(n,(o,i)=>{let s;(s=t(o,i,e))!==!1&&(r[i]=s||o)}),Object.defineProperties(e,r)},$g=e=>{lf(e,(t,n)=>{if(be(e)&&["arguments","caller","callee"].includes(n))return!1;let r=e[n];if(be(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Cg=(e,t)=>{let n={},r=o=>{o.forEach(i=>{n[i]=!0})};return Ht(e)?r(e):r(String(e).split(t)),n},Dg=()=>{},Ug=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Lg(e){return!!(e&&be(e.append)&&e[nf]==="FormData"&&e[mr])}var Mg=e=>{let t=new WeakSet,n=r=>{if(xn(r)){if(t.has(r))return;if(_n(r))return r;if(!("toJSON"in r)){t.add(r);let o;if(lg(r)){o=[];for(let i of r){let s=n(i);!Gt(s)&&o.push(s)}}else o=Ht(r)?[]:{},gr(r,(i,s)=>{let a=n(i);!Gt(a)&&(o[s]=a)});return t.delete(r),o}}return r};return n(e)},Ng=ze("AsyncFunction"),Bg=e=>e&&(xn(e)||be(e))&&be(e.then)&&be(e.catch),ff=((e,t)=>e?setImmediate:t?((n,r)=>(Ft.addEventListener("message",({source:o,data:i})=>{o===Ft&&i===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Ft.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",be(Ft.postMessage)),jg=typeof queueMicrotask<"u"?queueMicrotask.bind(Ft):typeof process<"u"&&process.nextTick||ff,df=e=>e!=null&&be(e[mr]),Zg=e=>e!=null&&hr(e,mr)&&df(e),d={isArray:Ht,isArrayBuffer:sf,isBuffer:_n,isFormData:pg,isArrayBufferView:eg,isString:tg,isNumber:af,isBoolean:ng,isObject:xn,isPlainObject:ko,isEmptyObject:rg,isReadableStream:mg,isRequest:gg,isResponse:yg,isHeaders:wg,isUndefined:Gt,isDate:og,isFile:ig,isReactNativeBlob:sg,isReactNative:ag,isBlob:cg,isRegExp:zg,isFunction:be,isStream:fg,isURLSearchParams:hg,isTypedArray:Rg,isFileList:ug,forEach:gr,merge:As,extend:_g,trim:bg,stripBOM:xg,inherits:Eg,toFlatObject:Sg,kindOf:Rs,kindOfTest:ze,endsWith:vg,toArray:Ag,forEachEntry:Tg,matchAll:Pg,isHTMLForm:Og,hasOwnProperty:pr,hasOwnProp:pr,hasOwnInPrototypeChain:hr,getSafeProp:Xm,toSafeFlatObject:Qm,reduceDescriptors:lf,freezeMethods:$g,toObjectSet:Cg,toCamelCase:kg,noop:Dg,toFiniteNumber:Ug,findKey:cf,global:Ft,isContextDefined:uf,isSpecCompliantForm:Lg,toJSONObject:Mg,isAsyncFn:Ng,isThenable:Bg,setImmediate:ff,asap:jg,isIterable:df,isSafeIterable:Zg};var Fg=d.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"]),pf=e=>{let t={},n,r,o;return e&&e.split(`
|
|
3
|
+
`).forEach(function(s){o=s.indexOf(":"),n=s.substring(0,o).trim().toLowerCase(),r=s.substring(o+1).trim();let a=d.hasOwnProp(t,n);!n||a&&d.hasOwnProp(Fg,n)||(n==="set-cookie"?a?t[n].push(r):t[n]=[r]:t[n]=a?t[n]+", "+r:r)}),t};function Hg(e){let t=0,n=e.length;for(;t<n;){let r=e.charCodeAt(t);if(r!==9&&r!==32)break;t+=1}for(;n>t;){let r=e.charCodeAt(n-1);if(r!==9&&r!==32)break;n-=1}return t===0&&n===e.length?e:e.slice(t,n)}var Gg=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),qg=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function Ts(e,t){return d.isArray(e)?e.map(n=>Ts(n,t)):Hg(String(e).replace(t,""))}var hf=e=>Ts(e,Gg),Kg=e=>Ts(e,qg);function zo(e){let t=Object.create(null);return d.forEach(e.toJSON(),(n,r)=>{t[r]=Kg(n)}),t}var mf=Symbol("internals");function yr(e){return e&&String(e).trim().toLowerCase()}function $o(e){return e===!1||e==null?e:d.isArray(e)?e.map($o):hf(String(e))}function Jg(e){let t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}var Vg=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function Ps(e){let t=0,n=e.length;for(;t<n;){let r=e.charCodeAt(t);if(r!==9&&r!==32)break;t+=1}for(;n>t;){let r=e.charCodeAt(n-1);if(r!==9&&r!==32)break;n-=1}return t===0&&n===e.length?e:e.slice(t,n)}function Wg(e){let t=e.length-1;if(t<1||e.charCodeAt(0)!==34||e.charCodeAt(t)!==34)return e;let n="";for(let r=1;r<t;r++){let o=e.charCodeAt(r);if(o===34||o===92&&(r+=1,r>=t))return e;n+=e[r]}return n}function Yg(e){let t=Object.create(null),n=String(e),r=0,o=!1,i=!1;function s(a){let c=Ps(n.slice(r,a)),u=c.indexOf("=");if(u<1)return;let l=Ps(c.slice(0,u));if(!Vg.test(l))return;let f=l.toLowerCase();if(f==="__proto__"||f==="constructor"||f==="prototype")return;let p=Ps(c.slice(u+1));t[f]=Wg(p)}for(let a=0;a<n.length;a++){let c=n.charCodeAt(a);o?i?i=!1:c===92?i=!0:c===34&&(o=!1):c===34?o=!0:(c===44||c===59)&&(s(a),r=a+1)}return s(n.length),t}var Xg=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Os(e,t,n,r,o){if(d.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!d.isString(t)){if(d.isString(r))return t.indexOf(r)!==-1;if(d.isRegExp(r))return r.test(t)}}function Qg(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function ey(e,t){let n=d.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{__proto__:null,value:function(o,i,s){return this[r].call(this,t,o,i,s)},configurable:!0})})}var En=class{constructor(t){t&&this.set(t)}set(t,n,r){let o=this;function i(a,c,u){let l=yr(c);if(!l)return;let f=d.findKey(o,l);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||c]=$o(a))}let s=(a,c)=>d.forEach(a,(u,l)=>i(u,l,c));if(d.isPlainObject(t)||t instanceof this.constructor)s(t,n);else if(d.isString(t)&&(t=t.trim())&&!Xg(t))s(pf(t),n);else if(d.isObject(t)&&d.isSafeIterable(t)){let a=Object.create(null),c,u;for(let l of t){if(!d.isArray(l))throw new TypeError("Object iterator must return a key-value pair");u=l[0],d.hasOwnProp(a,u)?(c=a[u],a[u]=d.isArray(c)?[...c,l[1]]:[c,l[1]]):a[u]=l[1]}s(a,n)}else t!=null&&i(n,t,r);return this}get(t,n){if(t=yr(t),t){let r=d.findKey(this,t);if(r){let o=this[r];if(!n)return o;if(n===!0)return Jg(o);if(d.isFunction(n))return n.call(this,o,r);if(d.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=yr(t),t){let r=d.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Os(this,this[r],r,n)))}return!1}delete(t,n){let r=this,o=!1;function i(s){if(s=yr(s),s){let a=d.findKey(r,s);a&&(!n||Os(r,r[a],a,n))&&(delete r[a],o=!0)}}return d.isArray(t)?t.forEach(i):i(t),o}clear(t){let n=Object.keys(this),r=n.length,o=!1;for(;r--;){let i=n[r];(!t||Os(this,this[i],i,t,!0))&&(delete this[i],o=!0)}return o}normalize(t){let n=this,r={};return d.forEach(this,(o,i)=>{let s=d.findKey(r,i);if(s){n[s]=$o(o),delete n[i];return}let a=t?Qg(i):String(i).trim();a!==i&&delete n[i],n[a]=$o(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let n=Object.create(null);return d.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&d.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
|
4
|
+
`)}getSetCookie(){let t=this.get("set-cookie");return d.isArray(t)?t:t==null||t===!1?[]:[t]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static parseParameters(t){return Yg(t)}static concat(t,...n){let r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){let r=(this[mf]=this[mf]={accessors:{}}).accessors,o=this.prototype;function i(s){let a=yr(s);r[a]||(ey(o,s),r[a]=!0)}return d.isArray(t)?t.forEach(i):i(t),this}};En.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);d.reduceDescriptors(En.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});d.freezeMethods(En);var ee=En;var wr="[REDACTED ****]";function ty(e){if(d.hasOwnProp(e,"toJSON"))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(d.hasOwnProp(t,"toJSON"))return!0;t=Object.getPrototypeOf(t)}return!1}function ny(e,t){let n=new Set(t.map(i=>String(i).toLowerCase())),r=[],o=i=>{if(i===null||typeof i!="object"||d.isBuffer(i))return i;if(r.indexOf(i)!==-1)return;i instanceof ee&&(i=i.toJSON()),r.push(i);let s;if(d.isArray(i))s=[],i.forEach((a,c)=>{let u=o(a);d.isUndefined(u)||(s[c]=u)});else{if(!d.isPlainObject(i)&&ty(i))return r.pop(),i;s=Object.create(null);for(let[a,c]of Object.entries(i)){let u=n.has(a.toLowerCase())?wr:o(c);d.isUndefined(u)||(s[a]=u)}}return r.pop(),s};return o(e)}function gf(e){try{return String(e)}catch{return""}}function ry(e){return e.errors.map(n=>{try{return n&&n.message?gf(n.message):gf(n)}catch{return""}}).filter(Boolean).join("; ")||e.name||"AggregateError"}var ue=class e extends Error{static from(t,n,r,o,i,s){let a=t.message;!a&&d.isArray(t.errors)&&t.errors.length&&(a=ry(t));let c=new e(a,n||t.code,r,o,i);return Object.defineProperty(c,"cause",{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),c.name=t.name,t.status!=null&&c.status==null&&(c.status=t.status),s&&Object.assign(c,s),c}constructor(t,n,r,o,i){super(t),Object.defineProperty(this,"message",{__proto__:null,value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),o&&(this.request=o),i&&(this.response=i,this.status=i.status)}toJSON(){let t=this.config,n=t&&d.hasOwnProp(t,"redact")?t.redact:void 0,r=d.isArray(n)&&n.length>0?ny(t,n):d.toJSONObject(t);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:r,code:this.code,status:this.status}}};ue.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";ue.ERR_BAD_OPTION="ERR_BAD_OPTION";ue.ECONNABORTED="ECONNABORTED";ue.ETIMEDOUT="ETIMEDOUT";ue.ECONNREFUSED="ECONNREFUSED";ue.ERR_NETWORK="ERR_NETWORK";ue.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";ue.ERR_DEPRECATED="ERR_DEPRECATED";ue.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";ue.ERR_BAD_REQUEST="ERR_BAD_REQUEST";ue.ERR_CANCELED="ERR_CANCELED";ue.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";ue.ERR_INVALID_URL="ERR_INVALID_URL";ue.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";var T=ue;var Et=null;var zs=100;function Is(e){return d.isPlainObject(e)||d.isArray(e)}function yf(e){return d.endsWith(e,"[]")?e.slice(0,-2):e}function ks(e,t,n){return e?e.concat(t).map(function(o,i){return o=yf(o),!n&&i?"["+o+"]":o}).join(n?".":""):t}function oy(e){return d.isArray(e)&&!e.some(Is)}var iy=d.toFlatObject(d,{},null,function(t){return/^is[A-Z]/.test(t)});function sy(e,t,n){if(!d.isObject(e))throw new TypeError("target must be an object");t=t||new(Et||FormData);let r=(_,S)=>{let b=d.getSafeProp(n,_);return d.isUndefined(b)?S:b},o=r("metaTokens",!0),i=r("visitor")||x,s=r("dots",!1),a=r("indexes",!1),c=r("Blob")||typeof Blob<"u"&&Blob,u=r("maxDepth",zs),l=c&&d.isSpecCompliantForm(t),f=[];if(!d.isFunction(i))throw new TypeError("visitor must be a function");function p(_){if(_===null)return"";if(d.isDate(_))return _.toISOString();if(d.isBoolean(_))return _.toString();if(!l&&d.isBlob(_))throw new T("Blob is not supported. Use a Buffer instead.");if(d.isArrayBuffer(_)||d.isTypedArray(_)){if(l&&typeof c=="function")return new c([_]);if(Et&&Et.isBufferAvailable())return Et.from(_);throw new T("Blob is not supported. Use a Buffer instead.",T.ERR_NOT_SUPPORT)}return _}function g(_){if(_>u)throw new T("Object is too deeply nested ("+_+" levels). Max depth: "+u,T.ERR_FORM_DATA_DEPTH_EXCEEDED)}function w(_,S){if(u===1/0)return JSON.stringify(_);let b=[];return JSON.stringify(_,function(O,I){if(!d.isObject(I))return I;for(;b.length&&b[b.length-1]!==this;)b.pop();return b.push(I),g(S+b.length-1),I})}function x(_,S,b){let v=_;if(d.isReactNative(t)&&d.isReactNativeBlob(_))return t.append(ks(b,S,s),p(_)),!1;if(_&&!b&&typeof _=="object"){if(d.endsWith(S,"{}"))S=o?S:S.slice(0,-2),_=w(_,1);else if(d.isArray(_)&&oy(_)||(d.isFileList(_)||d.endsWith(S,"[]"))&&(v=d.toArray(_)))return S=yf(S),v.forEach(function(I,z){!(d.isUndefined(I)||I===null)&&t.append(a===!0?ks([S],z,s):a===null?S:S+"[]",p(I))}),!1}return Is(_)?!0:(t.append(ks(b,S,s),p(_)),!1)}let A=Object.assign(iy,{defaultVisitor:x,convertValue:p,isVisitable:Is});function h(_,S,b=0){if(!d.isUndefined(_)){if(g(b),f.indexOf(_)!==-1)throw new Error("Circular reference detected in "+S.join("."));f.push(_),d.forEach(_,function(O,I){(!(d.isUndefined(O)||O===null)&&i.call(t,O,d.isString(I)?I.trim():I,S,A))===!0&&h(O,S?S.concat(I):[I],b+1)}),f.pop()}}if(!d.isObject(e))throw new TypeError("data must be an object");return h(e),t}var St=sy;function wf(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(r){return t[r]})}function bf(e,t){this._pairs=[],e&&St(e,this,t)}var _f=bf.prototype;_f.append=function(t,n){this._pairs.push([t,n])};_f.toString=function(t){let n=t?r=>t.call(this,r,wf):wf;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};var Co=bf;function ay(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function br(e,t,n){if(!t)return e;e=e||"";let r=d.isFunction(n)?{serialize:n}:n,o=d.getSafeProp(r,"encode")||ay,i=d.getSafeProp(r,"serialize"),s;if(i?s=i(t,r):s=d.isURLSearchParams(t)?t.toString():new Co(t,r).toString(o),s){let a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}var _r=Symbol("internals");function Ef(e){return e?e.length:0}function xf(e){if(e)for(;e.length&&e[e.length-1]===null;)e.pop()}function xr(e,t){let n=e.handlers,r=Ef(n);n!==t.handlersRef?(t.handlersRef=n,t.handlerEntries.clear()):r!==t.handlersLength&&(r?t.handlerEntries.forEach(function(i,s){n[i.index]!==i.handler&&t.handlerEntries.delete(s)}):t.handlerEntries.clear()),t.handlersLength=r}var $s=class{constructor(){this.handlers=[],this[_r]={handlersRef:this.handlers,handlersLength:this.handlers.length,handlerEntries:new Map,iterationDepth:0,nextId:0}}use(t,n,r){let o={fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null},i=this[_r];this.handlers==null&&(this.handlers=[]),xr(this,i);let s=i.nextId++;return this.handlers.push(o),i.handlerEntries.set(s,{handler:o,index:this.handlers.length-1}),i.handlersLength=this.handlers.length,s}eject(t){let n=this[_r];xr(this,n);let r=n.handlerEntries.get(t);if(r){if(n.handlerEntries.delete(t),this.handlers[r.index]!==r.handler)return;this.handlers[r.index]=null,n.iterationDepth||(xf(this.handlers),n.handlersLength=this.handlers.length)}}clear(){this.handlers&&(this.handlers=[],xr(this,this[_r]))}forEach(t){let n=this[_r];xr(this,n),n.iterationDepth++;try{d.forEach(this.handlers,function(o){o!==null&&t(o)})}finally{--n.iterationDepth||(xr(this,n),xf(this.handlers),n.handlersLength=Ef(this.handlers))}}},Cs=$s;var Sn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0};var Sf=typeof URLSearchParams<"u"?URLSearchParams:Co;var vf=typeof FormData<"u"?FormData:null;var Af=typeof Blob<"u"?Blob:null;var Rf={isBrowser:!0,classes:{URLSearchParams:Sf,FormData:vf,Blob:Af},protocols:["http","https","file","blob","url","data"]};var Ls={};Ap(Ls,{hasBrowserEnv:()=>Us,hasStandardBrowserEnv:()=>cy,hasStandardBrowserWebWorkerEnv:()=>uy,navigator:()=>Ds,origin:()=>ly});var Us=typeof window<"u"&&typeof document<"u",Ds=typeof navigator=="object"&&navigator||void 0,cy=Us&&(!Ds||["ReactNative","NativeScript","NS"].indexOf(Ds.product)<0),uy=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ly=Us&&window.location.href||"http://localhost";var W={...Ls,...Rf};function Ms(e,t){return St(e,new W.classes.URLSearchParams,{visitor:function(n,r,o,i){return W.isNode&&d.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}var Tf=zs;function Pf(e){if(e>Tf)throw new T("FormData field is too deeply nested ("+e+" levels). Max depth: "+Tf,T.ERR_FORM_DATA_DEPTH_EXCEEDED)}function fy(e){let t=[],n=/[^.[\]]+|\[([^.[\]]*)]/g,r;for(;(r=n.exec(e))!==null;)Pf(t.length),t.push(r[0]==="[]"?"":r[1]||r[0]);return t}function dy(e){let t={},n=Object.keys(e),r,o=n.length,i;for(r=0;r<o;r++)i=n[r],t[i]=e[i];return t}function py(e){function t(n,r,o,i){Pf(i);let s=n[i++];if(s==="__proto__")return!0;let a=Number.isFinite(+s),c=i>=n.length;return s=!s&&d.isArray(o)?o.length:s,c?(d.hasOwnProp(o,s)?o[s]=d.isArray(o[s])?o[s].concat(r):[o[s],r]:o[s]=r,!a):((!d.hasOwnProp(o,s)||!d.isObject(o[s]))&&(o[s]=[]),t(n,r,o[s],i)&&d.isArray(o[s])&&(o[s]=dy(o[s])),!a)}if(d.isFormData(e)&&d.isFunction(e.entries)){let n={};return d.forEachEntry(e,(r,o)=>{t(fy(r),o,n,0)}),n}return null}var Do=py;var hy=Object.freeze(["get","delete","head","options","post","put","patch","purge","link","unlink","query"]),Uo=hy;var vn=(e,t)=>e!=null&&d.hasOwnProp(e,t)?e[t]:void 0;function my(e,t,n){if(d.isString(e))try{return(t||JSON.parse)(e),d.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}var Ns={transitional:Sn,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){let r=n.getContentType()||"",o=r.indexOf("application/json")>-1,i=d.isObject(t);if(i&&d.isHTMLForm(t)&&(t=new FormData(t)),d.isFormData(t))return o?JSON.stringify(Do(t)):t;if(d.isArrayBuffer(t)||d.isBuffer(t)||d.isStream(t)||d.isFile(t)||d.isBlob(t)||d.isReadableStream(t))return t;if(d.isArrayBufferView(t))return t.buffer;if(d.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(i){let c=vn(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return Ms(t,c).toString();if((a=d.isFileList(t))||r.indexOf("multipart/form-data")>-1){let u=vn(this,"env"),l=u&&u.FormData;return St(a?{"files[]":t}:t,l&&new l,c)}}return i||o?(n.setContentType("application/json",!1),my(t)):t}],transformResponse:[function(t){let n=vn(this,"transitional")||Ns.transitional,r=n&&n.forcedJSONParsing,o=vn(this,"responseType"),i=o==="json";if(d.isResponse(t)||d.isReadableStream(t))return t;if(t&&d.isString(t)&&(r&&!o||i)){let a=!(n&&n.silentJSONParsing)&&i;try{return JSON.parse(t,vn(this,"parseReviver"))}catch(c){if(a)throw c.name==="SyntaxError"?T.from(c,T.ERR_BAD_RESPONSE,this,null,vn(this,"response")):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:W.classes.FormData,Blob:W.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};d.forEach(Uo,e=>{Ns.headers[e]={}});var An=Ns;function Er(e,t){let n=this||An,r=t||n,o=ee.from(r.headers),i=r.data;return d.forEach(e,function(a){i=a.call(n,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function Sr(e){return!!(e&&e.__CANCEL__)}var Bs=class extends T{constructor(t,n,r){super(t??"canceled",T.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}},Ve=Bs;function vr(e,t,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new T("Request failed with status code "+n.status,n.status>=400&&n.status<500?T.ERR_BAD_REQUEST:T.ERR_BAD_RESPONSE,n.config,n.request,n))}var gy=/[\t\n\r]/g;function Ar(e){if(typeof e!="string")return e;let t=0;for(;t<e.length&&e.charCodeAt(t)<=32;)t++;return e.slice(t).replace(gy,"")}function Rr(e){let t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}function yy(e,t){e=e||10;let n=new Array(e),r=new Array(e),o=0,i=0,s;return t=t!==void 0?t:1e3,function(c){let u=Date.now(),l=r[i];s||(s=u),n[o]=c,r[o]=u;let f=i,p=0;for(;f!==o;)p+=n[f++],f=f%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),u-s<t)return;let g=l&&u-l;return g?Math.round(p*1e3/g):void 0}}var Of=yy;function wy(e,t){let n=0,r=1e3/t,o,i,s=(l,f=Date.now())=>{n=f,o=null,i&&(clearTimeout(i),i=null),e(...l)};return[(...l)=>{let f=Date.now(),p=f-n;p>=r?s(l,f):(o=l,i||(i=setTimeout(()=>{i=null,s(o)},r-p)))},()=>o&&s(o),(...l)=>s(l)]}var kf=wy;var Rn=(e,t,n=3)=>{let r=0,o=Of(50,250);return kf(i=>{if(!i||!d.isNumber(i.loaded))return;let s=i.loaded,a=i.lengthComputable?i.total:void 0,c=Math.max(0,a!=null?Math.min(s,a):s),u=Math.max(0,c-r),l=o(u);r=Math.max(r,c);let f={loaded:c,total:a,progress:a?c/a:void 0,bytes:u,rate:l||void 0,estimated:l&&a?(a-c)/l:void 0,event:i,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},js=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Zs=(e,t=d.asap)=>(...n)=>t(()=>e(...n));var If=W.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,W.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(W.origin),W.navigator&&/(msie|trident)/i.test(W.navigator.userAgent)):()=>!0;var zf=W.hasStandardBrowserEnv?{write(e,t,n,r,o,i,s){if(typeof document>"u")return;let a=[`${e}=${encodeURIComponent(t)}`];d.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),d.isString(r)&&a.push(`path=${r}`),d.isString(o)&&a.push(`domain=${o}`),i===!0&&a.push("secure"),d.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(e){if(typeof document>"u")return null;let t=document.cookie.split(";");for(let n=0;n<t.length;n++){let r=t[n].replace(/^\s+/,""),o=r.indexOf("=");if(o!==-1&&r.slice(0,o)===e)try{return decodeURIComponent(r.slice(o+1))}catch{return r.slice(o+1)}}return null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Fs(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Hs(e,t){if(!t)return e;let n=e.length;for(;n>0&&e.charCodeAt(n-1)===47;)n--;return e.slice(0,n)+"/"+t.replace(/^\/+/,"")}var by=/^https?:(?!\/\/)/i;function _y(e){return e&&e.replace(/(^|&)([^=&]*=)?[^&]+/g,(t,n,r="")=>`${n}${r}${wr}`)}function xy(e){let t=e.replace(/^(https?:\/{0,2})[^/?#]*@/i,`$1${wr}@`),n=t.indexOf("#"),o=(n===-1?t:t.slice(0,n)).replace(/([?&][^=&#]*=)[^&#]*/g,`$1${wr}`);return n===-1?o:`${o}#${_y(t.slice(n+1))}`}function $f(e,t){if(typeof e=="string"){let n=Ar(e);if(by.test(n))throw new T(`Invalid URL ${JSON.stringify(xy(n))}: missing "//" after protocol`,T.ERR_INVALID_URL,t)}}function Tr(e,t,n,r){$f(t,r);let o=!Fs(t);return e&&(o||n===!1)?($f(e,r),Hs(e,t)):t}var Cf=e=>e instanceof ee?{...e}:e,Ey=e=>Object.getOwnPropertySymbols&&Object.getOwnPropertyDescriptor?Object.keys(e).concat(Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)):Object.keys(e);function Be(e,t){e=e||{},t=t||{};let n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(l,f,p,g){return d.isPlainObject(l)&&d.isPlainObject(f)?d.merge.call({caseless:g},l,f):d.isPlainObject(f)?d.merge({},f):d.isArray(f)?f.slice():f}function o(l,f,p,g){if(d.isUndefined(f)){if(!d.isUndefined(l))return r(void 0,l,p,g)}else return r(l,f,p,g)}function i(l,f){if(!d.isUndefined(f))return r(void 0,f)}function s(l,f){if(d.isUndefined(f)){if(!d.isUndefined(l))return r(void 0,l)}else return r(void 0,f)}function a(l){let f=d.hasOwnProp(t,"transitional")?t.transitional:void 0;if(!d.isUndefined(f))if(d.isPlainObject(f)){if(d.hasOwnProp(f,l))return f[l]}else return;let p=d.hasOwnProp(e,"transitional")?e.transitional:void 0;if(d.isPlainObject(p)&&d.hasOwnProp(p,l))return p[l]}function c(l,f,p){if(d.hasOwnProp(t,p))return r(l,f);if(d.hasOwnProp(e,p))return r(void 0,l)}let u={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutErrorMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,allowedSocketPaths:s,responseEncoding:s,validateStatus:c,headers:(l,f,p)=>o(Cf(l),Cf(f),p,!0)};return d.forEach(Ey({...e,...t}),function(f){if(f==="__proto__"||f==="constructor"||f==="prototype")return;let p=d.hasOwnProp(u,f)?u[f]:o,g=d.hasOwnProp(e,f)?e[f]:void 0,w=d.hasOwnProp(t,f)?t[f]:void 0,x=p(g,w,f);d.isUndefined(x)&&p!==c||(n[f]=x)}),d.hasOwnProp(t,"validateStatus")&&d.isUndefined(t.validateStatus)&&a("validateStatusUndefinedResolves")===!1&&(d.hasOwnProp(e,"validateStatus")?n.validateStatus=r(void 0,e.validateStatus):delete n.validateStatus),n}var Sy=["content-type","content-length"];function Gs(e,t,n){if(n!=="content-only"){e.set(t);return}Object.entries(t||{}).forEach(([r,o])=>{Sy.includes(r.toLowerCase())&&e.set(r,o)})}var vy=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16)));function Ay(e){let t=Be({},e),n=p=>d.hasOwnProp(t,p)?t[p]:void 0,r=n("data"),o=n("withXSRFToken"),i=n("xsrfHeaderName"),s=n("xsrfCookieName"),a=n("headers"),c=n("auth"),u=n("baseURL"),l=n("allowAbsoluteUrls"),f=n("url");if(t.headers=a=ee.from(a),t.url=br(Tr(u,f,l,t),n("params"),n("paramsSerializer")),c){let p=d.getSafeProp(c,"username")||"",g=d.getSafeProp(c,"password")||"";try{a.set("Authorization","Basic "+btoa(p+":"+(g?vy(g):"")))}catch(w){throw T.from(w,T.ERR_BAD_OPTION_VALUE,e)}}if(d.isFormData(r)){let p=d.getSafeProp(r,"getHeaders");W.hasStandardBrowserEnv||W.hasStandardBrowserWebWorkerEnv||d.isReactNative(r)?a.setContentType(void 0):d.isFunction(p)&&Gs(a,p.call(r),n("formDataHeaderPolicy"))}if(W.hasStandardBrowserEnv&&(d.isFunction(o)&&(o=o(t)),o===!0||o==null&&If(t.url))){let g=i&&s&&zf.read(s);g&&a.set(i,g)}return t}var Lo=Ay;var Ry=typeof XMLHttpRequest<"u",Df=Ry&&function(e){return new Promise(function(n,r){let o=Lo(e),i=o.data,s=ee.from(o.headers).normalize(),{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,l,f,p,g,w,x;function A(){g&&g(),w&&w(),o.cancelToken&&o.cancelToken.unsubscribe(l),o.signal&&o.signal.removeEventListener("abort",l)}let h=new XMLHttpRequest;h.open(o.method.toUpperCase(),o.url,!0),h.timeout=o.timeout;function _(b){if(!h)return;if(h.status===0&&(Rr(Ar(o.url))||Rr(W.origin))!=="file"&&!(h.responseURL&&h.responseURL.startsWith("file:"))){r(new T("Request aborted",T.ECONNABORTED,e,h)),A(),h=null;return}try{b?x&&x(b):w&&w()}catch(z){setTimeout(()=>{throw z})}if(!h)return;let v=ee.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),I={data:!a||a==="text"||a==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:v,config:e,request:h};vr(function(V){n(V),A()},function(V){r(V),A()},I),h=null}"onloadend"in h?h.onloadend=_:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.startsWith("file:"))||setTimeout(_)},h.onabort=function(){h&&(r(new T("Request aborted",T.ECONNABORTED,e,h)),A(),h=null)},h.onerror=function(v){let O=v&&v.message?v.message:"Network Error",I=new T(O,T.ERR_NETWORK,e,h);I.event=v||null,r(I),A(),h=null},h.ontimeout=function(){let v=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded",O=o.transitional||Sn;o.timeoutErrorMessage&&(v=o.timeoutErrorMessage),r(new T(v,O.clarifyTimeoutError?T.ETIMEDOUT:T.ECONNABORTED,e,h)),A(),h=null},i===void 0&&s.setContentType(null),"setRequestHeader"in h&&d.forEach(zo(s),function(v,O){h.setRequestHeader(O,v)}),d.isUndefined(o.withCredentials)||(h.withCredentials=!!o.withCredentials),a&&a!=="json"&&(h.responseType=o.responseType),u&&([p,w,x]=Rn(u,!0),h.addEventListener("progress",p)),c&&h.upload&&([f,g]=Rn(c),h.upload.addEventListener("progress",f),h.upload.addEventListener("loadend",g)),(o.cancelToken||o.signal)&&(l=b=>{h&&(r(!b||b.type?new Ve(null,e,h):b),h.abort(),A(),h=null)},o.cancelToken&&o.cancelToken.subscribe(l),o.signal&&(o.signal.aborted?l():o.signal.addEventListener("abort",l)));let S=Rr(o.url);if(S&&!W.protocols.includes(S)){r(new T("Unsupported protocol "+S+":",T.ERR_BAD_REQUEST,e)),A();return}h.send(i||null)})};var Ty=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;let n=new AbortController,r=!1,o=function(c){if(!r){r=!0,s();let u=c instanceof Error?c:this.reason;n.abort(u instanceof T?u:new Ve(u instanceof Error?u.message:u))}},i=t&&setTimeout(()=>{i=null,o(new T(`timeout of ${t}ms exceeded`,T.ETIMEDOUT))},t),s=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(o):c.removeEventListener("abort",o)}),e=null)};e.forEach(c=>{if(!r){if(c.aborted){o.call(c);return}c.addEventListener("abort",o,{once:!0})}});let{signal:a}=n;return a.unsubscribe=()=>d.asap(s),a},Uf=Ty;var Py=function*(e,t){let n=e.byteLength;if(!t||n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},Oy=async function*(e,t){for await(let n of ky(e))yield*Py(n,t)},ky=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},qs=(e,t,n,r)=>{let o=Oy(e,t),i=0,s,a=c=>{s||(s=!0,r&&r(c))};return new ReadableStream({async pull(c){try{let{done:u,value:l}=await o.next();if(u){a(),c.close();return}let f=l.byteLength;if(n){let p=i+=f;n(p)}c.enqueue(new Uint8Array(l))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})};var Lf=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,Nf=(e,t,n)=>t+2<n&&Lf(e.charCodeAt(t+1))&&Lf(e.charCodeAt(t+2)),Mf=e=>e<=57?e-48:(e&223)-55,Iy=e=>e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===43||e===47||e===45||e===95,zy=e=>e===9||e===10||e===12||e===13||e===32,$y=e=>{let t=Math.floor(e/4),n=e%4;return t*3+(n===2?1:n===3?2:0)},Cy=e=>{let t=e.length,n=0;return t>0&&e.charCodeAt(t-1)===61&&(n++,t>1&&e.charCodeAt(t-2)===61&&n++),Math.floor((t-n)*3/4)},Dy=e=>{let t=e.length,n=0,r=0,o=!1;for(let i=0;i<t;i++){let s=e.charCodeAt(i);if(s===37&&Nf(e,i,t)&&(s=Mf(e.charCodeAt(i+1))*16+Mf(e.charCodeAt(i+2)),i+=2),!zy(s)){if(s===61){r++;continue}if(!Iy(s)||r>0){o=!0;continue}n++}}return o||r>2||r>0&&(n+r)%4!==0||n%4===1?Cy(e):$y(n)},Uy=(e,t)=>{if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let n=e.indexOf(",");if(n<0)return 0;let r=e.slice(5,n),o=e.slice(n+1);if(/;base64/i.test(r))return t(o);let s=0;for(let a=0,c=o.length;a<c;a++){let u=o.charCodeAt(a);if(u===37&&Nf(o,a,c))s+=1,a+=2;else if(u<128)s+=1;else if(u<2048)s+=2;else if(u>=55296&&u<=56319&&a+1<c){let l=o.charCodeAt(a+1);l>=56320&&l<=57343?(s+=4,a++):s+=3}else s+=3}return s};function Ks(e){let t=typeof e=="string"?e.indexOf("#"):-1;return Uy(t===-1?e:e.slice(0,t),Dy)}var Tn="1.20.0";var Bf=64*1024,Ly={cache:"default",redirect:"follow",referrer:"about:client",referrerPolicy:"",mode:"cors",integrity:"",keepalive:!1,priority:"auto",window:null},{isFunction:Mo}=d,My=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16))),jf=e=>{if(!d.isString(e))return e;try{return decodeURIComponent(e)}catch{return e}},Zf=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Ny=e=>{let t=e.indexOf("://"),n=e;return t!==-1&&(n=n.slice(t+3)),n.includes("@")||n.includes(":")},By=e=>{let t=d.global!==void 0&&d.global!==null?d.global:globalThis,{ReadableStream:n,TextEncoder:r}=t;e=d.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);let{fetch:o,Request:i,Response:s}=e,a=o?Mo(o):typeof fetch=="function",c=Mo(i),u=Mo(s);if(!a)return!1;let l=a&&Mo(n),f=a&&(typeof r=="function"?(h=>_=>h.encode(_))(new r):async h=>new Uint8Array(await new i(h).arrayBuffer())),p=c&&l&&Zf(()=>{let h=!1,_=new i(W.origin,{body:new n,method:"POST",get duplex(){return h=!0,"half"}}),S=_.headers.has("Content-Type");return _.body!=null&&_.body.cancel(),h&&!S}),g=u&&l&&Zf(()=>d.isReadableStream(new s("").body)),w={stream:g&&(h=>h.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!w[h]&&(w[h]=(_,S)=>{let b=_&&_[h];if(b)return b.call(_);throw new T(`Response type '${h}' is not supported`,T.ERR_NOT_SUPPORT,S)})});let x=async h=>{if(h==null)return 0;if(d.isBlob(h))return h.size;if(d.isSpecCompliantForm(h))return(await new i(W.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(d.isArrayBufferView(h)||d.isArrayBuffer(h))return h.byteLength;if(d.isURLSearchParams(h)&&(h=h+""),d.isString(h))return(await f(h)).byteLength},A=async(h,_)=>{let S=d.toFiniteNumber(h.getContentLength());return S??x(_)};return async h=>{let{url:_,method:S,data:b,signal:v,cancelToken:O,timeout:I,onDownloadProgress:z,onUploadProgress:V,responseType:K,headers:m,withCredentials:E="same-origin",fetchOptions:U,maxContentLength:M,maxBodyLength:H,maxRedirects:N}=Lo(h),Fe=d.isNumber(M)&&M>-1,Pt=d.isNumber(H)&&H>-1,Vr=G=>d.hasOwnProp(h,G)?h[G]:void 0,te=o||fetch;K=K?(K+"").toLowerCase():"text";let le=Uf([v,O&&O.toAbortSignal()],I),ce=null,Ot=le&&le.unsubscribe&&(()=>{le.unsubscribe()}),tn,Hn=null,rc=()=>new T("Request body larger than maxBodyLength limit",T.ERR_BAD_REQUEST,h,ce);try{let G,ke=Vr("auth");if(ke){let L=d.getSafeProp(ke,"username")||"",fe=d.getSafeProp(ke,"password")||"";G={username:L,password:fe}}if(Ny(_)){let L=new URL(_,W.origin);if(!G&&(L.username||L.password)){let fe=jf(L.username),pt=jf(L.password);G={username:fe,password:pt}}(L.username||L.password)&&(L.username="",L.password="",_=L.href)}if(G&&(m.delete("authorization"),m.set("Authorization","Basic "+btoa(My((G.username||"")+":"+(G.password||""))))),Fe&&typeof _=="string"&&_.startsWith("data:")&&Ks(_)>M)throw new T("maxContentLength size of "+M+" exceeded",T.ERR_BAD_RESPONSE,h,ce);if(Pt&&S!=="get"&&S!=="head"){let L=await x(b);if(typeof L=="number"&&isFinite(L)&&(tn=L,L>H))throw rc()}let Wr=Pt&&(d.isReadableStream(b)||d.isStream(b)),oc=(L,fe,pt)=>qs(L,Bf,kt=>{if(Pt&&kt>H)throw Hn=rc();fe&&fe(kt)},pt);if(p&&S!=="get"&&S!=="head"&&(V||Wr)){if(tn=tn??await A(m,b),tn!==0||Wr){let L=new i(_,{method:"POST",body:b,duplex:"half"}),fe;if(d.isFormData(b)&&(fe=L.headers.get("content-type"))&&m.setContentType(fe),L.body){let[pt,kt]=V&&js(tn,Rn(Zs(V)))||[];b=oc(L.body,pt,kt)}}}else if(Wr&&!c&&l&&S!=="get"&&S!=="head")b=oc(b);else if(Wr&&c&&!p&&S!=="get"&&S!=="head")throw new T("Stream request bodies are not supported by the current fetch implementation",T.ERR_NOT_SUPPORT,h,ce);d.isString(E)||(E=E?"include":"omit");let Ep=c&&"credentials"in i.prototype;if(d.isFormData(b)){let L=m.getContentType();L&&/^multipart\/form-data/i.test(L)&&!/boundary=/i.test(L)&&m.delete("content-type")}m.set("User-Agent","axios/"+Tn,!1);let De=U==null?U:Object.assign(Object.create(null),U);De&&(delete De.body,delete De.headers,delete De.method,delete De.signal,delete De.duplex,delete De.credentials);let tt=Object.assign(Object.create(null),De,{signal:le,method:S.toUpperCase(),headers:zo(m.normalize()),body:b,duplex:"half",credentials:Ep?E:void 0});c&&(d.forEach(Ly,(L,fe)=>{tt[fe]===void 0&&(tt[fe]=L)}),tt.signal===void 0&&(tt.signal=null),tt.body===void 0&&(tt.body=null)),N===0&&(tt.redirect="manual",De&&(De.redirect="manual")),ce=c&&new i(_,tt);let nt=await(c?te(ce,De):te(_,tt)),ic=ee.from(nt.headers);if(Fe){let L=d.toFiniteNumber(ic.getContentLength());if(L!=null&&L>M)throw new T("maxContentLength size of "+M+" exceeded",T.ERR_BAD_RESPONSE,h,ce)}let Ui=g&&(K==="stream"||K==="response");if(g&&nt.body&&(z||Fe||Ui&&Ot)){let L={};["status","statusText","headers"].forEach(Gn=>{L[Gn]=nt[Gn]});let fe=d.toFiniteNumber(ic.getContentLength()),[pt,kt]=z&&js(fe,Rn(Zs(z),!0))||[],sc=0,Sp=Gn=>{if(Fe&&(sc=Gn,sc>M))throw new T("maxContentLength size of "+M+" exceeded",T.ERR_BAD_RESPONSE,h,ce);pt&&pt(Gn)};nt=new s(qs(nt.body,Bf,Sp,()=>{kt&&kt(),Ot&&Ot()}),L)}K=K||"text";let rt=await w[d.findKey(w,K)||"text"](nt,h);if(Fe&&!g&&!Ui){let L;if(rt!=null&&(typeof rt.byteLength=="number"?L=rt.byteLength:typeof rt.size=="number"?L=rt.size:typeof rt=="string"&&(L=typeof r=="function"?new r().encode(rt).byteLength:rt.length)),typeof L=="number"&&L>M)throw new T("maxContentLength size of "+M+" exceeded",T.ERR_BAD_RESPONSE,h,ce)}return!Ui&&Ot&&Ot(),await new Promise((L,fe)=>{vr(L,fe,{data:rt,headers:ee.from(nt.headers),status:nt.status,statusText:nt.statusText,config:h,request:ce})})}catch(G){if(Ot&&Ot(),le&&le.aborted&&le.reason instanceof T){let ke=le.reason;throw ke.config=h,ce&&(ke.request=ce),G!==ke&&Object.defineProperty(ke,"cause",{__proto__:null,value:G,writable:!0,enumerable:!1,configurable:!0}),ke}if(Hn)throw ce&&!Hn.request&&(Hn.request=ce),Hn;if(G instanceof T)throw ce&&!G.request&&(G.request=ce),G;if(G&&G.name==="TypeError"&&/Load failed|fetch/i.test(G.message)){let ke=new T("Network Error",T.ERR_NETWORK,h,ce,G&&G.response);throw Object.defineProperty(ke,"cause",{__proto__:null,value:G.cause||G,writable:!0,enumerable:!1,configurable:!0}),ke}throw T.from(G,G&&G.code,h,ce,G&&G.response)}}},jy=new Map,Js=e=>{let t=e&&e.env||{},{fetch:n,Request:r,Response:o}=t,i=[r,o,n],s=i.length,a=s,c,u,l=jy;for(;a--;)c=i[a],u=l.get(c),u===void 0&&l.set(c,u=a?new Map:By(t)),l=u;return u},VR=Js();var Vs={http:Et,xhr:Df,fetch:{get:Js}};d.forEach(Vs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch{}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});var Ff=e=>`- ${e}`,Fy=e=>d.isFunction(e)||e===null||e===!1;function Hy(e,t){e=d.isArray(e)?e:[e];let{length:n}=e,r,o,i={};for(let s=0;s<n;s++){r=e[s];let a;if(o=r,!Fy(r)&&(o=Vs[(a=String(r)).toLowerCase()],o===void 0))throw new T(`Unknown adapter '${a}'`);if(o&&(d.isFunction(o)||(o=o.get(t))))break;i[a||"#"+s]=o}if(!o){let s=Object.entries(i).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build")),a=n?s.length>1?`since :
|
|
5
5
|
`+s.map(Ff).join(`
|
|
6
|
-
`):" "+Ff(s[0]):"as no adapter specified";throw new
|
|
6
|
+
`):" "+Ff(s[0]):"as no adapter specified";throw new T("There is no suitable adapter to dispatch the request "+a,T.ERR_NOT_SUPPORT)}return o}var No={getAdapter:Hy,adapters:Vs};function Ws(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Ve(null,e)}function Pr(e){let t=d.toSafeFlatObject(e);return Ws(t),t.headers=ee.from(d.getSafeProp(t,"headers")),t.data=Er.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),No.getAdapter(t.adapter||An.adapter,t)(t).then(function(o){Ws(t),t.response=o;try{o.data=Er.call(t,t.transformResponse,o)}finally{delete t.response}return o.headers=ee.from(o.headers),o},function(o){if(!Sr(o)&&(Ws(t),o&&o.response)){t.response=o.response;try{o.response.data=Er.call(t,t.transformResponse,o.response)}finally{delete t.response}o.response.headers=ee.from(o.response.headers)}return Promise.reject(o)})}var Bo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Bo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});var Hf={};Bo.transitional=function(t,n,r){function o(i,s){return"[Axios v"+Tn+"] Transitional option '"+i+"'"+s+(r?". "+r:"")}return(i,s,a)=>{if(t===!1)throw new T(o(s," has been removed"+(n?" in "+n:"")),T.ERR_DEPRECATED);return n&&!Hf[s]&&(Hf[s]=!0,console.warn(o(s," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,s,a):!0}};Bo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Gy(e,t,n){if(typeof e!="object"||e===null)throw new T("options must be an object",T.ERR_BAD_OPTION_VALUE);let r=Object.keys(e),o=r.length;for(;o-- >0;){let i=r[o],s=Object.prototype.hasOwnProperty.call(t,i)?t[i]:void 0;if(s){let a=e[i],c=a===void 0||s(a,i,e);if(c!==!0)throw new T("option "+i+" must be "+c,T.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new T("Unknown option "+i,T.ERR_BAD_OPTION)}}var Or={assertOptions:Gy,validators:Bo};var he=Or.validators,Pn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Cs,response:new Cs}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error)try{let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;let i=o.stack,s="";if(typeof i=="string"){let a=i.indexOf(`
|
|
7
7
|
`);s=a===-1?"":i.slice(a+1)}if(!r.stack)r.stack=s;else if(s){let a=s.indexOf(`
|
|
8
8
|
`),c=a===-1?-1:s.indexOf(`
|
|
9
9
|
`,a+1),u=c===-1?"":s.slice(c+1);String(r.stack).endsWith(u)||(r.stack+=`
|
|
10
|
-
`+s)}}catch{}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Be(this.defaults,n);let{transitional:r,paramsSerializer:o,headers:i}=n;r!==void 0&&Or.assertOptions(r,{silentJSONParsing:he.transitional(he.boolean),forcedJSONParsing:he.transitional(he.boolean),clarifyTimeoutError:he.transitional(he.boolean),legacyInterceptorReqResOrdering:he.transitional(he.boolean),advertiseZstdAcceptEncoding:he.transitional(he.boolean),validateStatusUndefinedResolves:he.transitional(he.boolean)},!1),o!=null&&(d.isFunction(o)?n.paramsSerializer={serialize:o}:Or.assertOptions(o,{encode:he.function,serialize:he.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Or.assertOptions(n,{baseUrl:he.spelling("baseURL"),withXsrfToken:he.spelling("withXSRFToken")},!0),n.method=(d.getSafeProp(n,"method")||d.getSafeProp(this.defaults,"method")||"get").toLowerCase();let s=i&&d.merge(i.common,i[n.method]);i&&d.forEach(Uo.concat("common"),w=>{delete i[w]}),n.headers=ee.concat(s,i);let a=[],c=!0;this.interceptors.request.forEach(function(x){if(typeof x.runWhen=="function"&&x.runWhen(n)===!1)return;c=c&&x.synchronous;let A=n.transitional||Sn;A&&A.legacyInterceptorReqResOrdering?a.unshift(x.fulfilled,x.rejected):a.push(x.fulfilled,x.rejected)});let u=[];this.interceptors.response.forEach(function(x){u.push(x.fulfilled,x.rejected)});let l,f=0,p;if(!c){let w=[Pr.bind(this),void 0];for(w.unshift(...a),w.push(...u),p=w.length,l=Promise.resolve(n);f<p;)l=l.then(w[f++],w[f++]);return l}p=a.length;let g=n;for(;f<p;){let w=a[f++],x=a[f++];try{g=w?w(g):g}catch(A){if(!x){l=Promise.reject(A);break}try{let h=x.call(this,A);d.isThenable(h)&&(l=Promise.resolve(h).then(()=>Pr.call(this,g)))}catch(h){l=Promise.reject(h)}break}}if(!l)try{l=Pr.call(this,g)}catch(w){l=Promise.reject(w)}for(f=0,p=u.length;f<p;)l=l.then(u[f++],u[f++]);return l}getUri(t){t=Be(this.defaults,t);let n=Rr(t.baseURL,t.url,t.allowAbsoluteUrls,t);return br(n,t.params,t.paramsSerializer)}};d.forEach(["delete","get","head","options"],function(t){Pn.prototype[t]=function(n,r){return this.request(Be(r||{},{method:t,url:n,data:r&&d.hasOwnProp(r,"data")?r.data:void 0}))}});d.forEach(["post","put","patch","query"],function(t){function n(r){return function(i,s,a){return this.request(Be(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}Pn.prototype[t]=n(),t!=="query"&&(Pn.prototype[t+"Form"]=n(!0))});var kr=Pn;var Ys=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});let r=this;this.promise.then(o=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](o);r._listeners=null}),this.promise.then=o=>{let i,s=new Promise(a=>{r.subscribe(a),i=a}).then(o);return s.cancel=function(){r.unsubscribe(i)},s},t(function(i,s,a){r.reason||(r.reason=new Ve(i,s,a),n(r.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;let n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){let t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new e(function(o){t=o}),cancel:t}}},Gf=Ys;function Xs(e){return function(n){return e.apply(null,n)}}function Qs(e){return d.isObject(e)&&e.isAxiosError===!0}var jo={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,ContentTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,UnprocessableContent: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,WebServerReturnsAnUnknownError:520,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(jo).forEach(([e,t])=>{jo[t]===void 0&&(jo[t]=e)});var qf=jo;function Jf(e){let t=new kr(e),n=dr(kr.prototype.request,t);return d.extend(n,kr.prototype,t,{allOwnKeys:!0}),d.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Jf(Be(e,o))},n}var re=Jf(An);re.Axios=kr;re.CanceledError=Ve;re.CancelToken=Gf;re.isCancel=Sr;re.VERSION=Rn;re.toFormData=St;re.AxiosError=R;re.Cancel=re.CanceledError;re.all=function(t){return Promise.all(t)};re.spread=Xs;re.isAxiosError=Qs;re.mergeConfig=Be;re.AxiosHeaders=ee;re.formToJSON=e=>Do(d.isHTMLForm(e)?new FormData(e):e);re.getAdapter=No.getAdapter;re.HttpStatusCode=qf;re.default=re;var Zo=re;var{Axios:KR,AxiosError:VR,CanceledError:WR,isCancel:YR,CancelToken:XR,VERSION:QR,all:eP,Cancel:tP,isAxiosError:nP,spread:rP,toFormData:oP,AxiosHeaders:iP,HttpStatusCode:sP,formToJSON:aP,getAdapter:cP,mergeConfig:uP,create:lP}=Zo;function qy(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function Pe(e,t,n){if(!e.s){if(n instanceof ea)if(n.s)t&1&&(t=n.s),n=n.v;else{n.o=Pe.bind(null,e,t);return}if(n&&n.then){n.then(Pe.bind(null,e,t),Pe.bind(null,e,2));return}e.s=t,e.v=n;let r=e.o;r&&r(e)}}var ea=(function(){function e(){}return e.prototype.then=function(t,n){let r=new e,o=this.s;if(o){let i=o&1?t:n;if(i){try{Pe(r,1,i(this.v))}catch(s){Pe(r,2,s)}return r}else return this}return this.o=function(i){try{let s=i.v;i.s&1?Pe(r,1,t?t(s):s):n?Pe(r,1,n(s)):Pe(r,2,s)}catch(s){Pe(r,2,s)}},r},e})();function On(e){return e instanceof ea&&e.s&1}function Jy(e,t){var n;do{var r=e();if(r&&r.then)if(On(r))r=r.v;else{n=!0;break}var o=t();if(On(o)&&(o=o.v),!o)return r}while(!o.then);let i=new ea,s=Pe.bind(null,i,2);return(n?r.then(a):o.then(c)).then(void 0,s),i;function a(u){for(r=u;o=t(),On(o)&&(o=o.v),!!o;){if(o.then){o.then(c).then(void 0,s);return}if(r=e(),r&&r.then)if(On(r))r=r.v;else{r.then(a).then(void 0,s);return}}Pe(i,1,r)}function c(u){if(u){do{if(r=e(),r&&r.then)if(On(r))r=r.v;else{r.then(a).then(void 0,s);return}if(u=t(),On(u)&&(u=u.v),!u){Pe(i,1,r);return}}while(!u.then);u.then(c).then(void 0,s)}else Pe(i,1,r)}}function Kf(){return{plc:function(t,n){try{let o=function(){let l=typeof c?.["@context"]<"u"?"application/did+ld+json":"application/did+json";return i?{didDocument:c,didDocumentMetadata:a,didResolutionMetadata:{error:"notFound",message:i}}:{didDocument:c,didDocumentMetadata:a,didResolutionMetadata:{contentType:l}}},r,i=null,s=`https://plc.directory/${encodeURIComponent(t)}`,a={},c=null,u=Jy(function(){function l(){r||c?.id===t||(i="resolver_error: DID document id does not match requested did")}let f=qy(function(){return Promise.resolve(Zo.get(s)).then(function(p){c=p.data})},function(p){i=`resolver_error: '"https://plc.directory/" + DID' must resolve to a valid https URL containing a JSON document: ${p}`,r=1});return f&&f.then?f.then(l):l(f)},function(){return!r&&!1});return Promise.resolve(u&&u.then?u.then(o):o(u))}catch(r){return Promise.reject(r)}}}}var Yf=Tp(Wf(),1);function Ky(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}var Vy=function(e){try{return Promise.resolve((0,Yf.default)(e,{mode:"cors"})).then(function(t){if(t.status>=400)throw new Error(`Bad response ${t.statusText}`);return t.json()})}catch(t){return Promise.reject(t)}};function Oe(e,t,n){if(!e.s){if(n instanceof ta)if(n.s)t&1&&(t=n.s),n=n.v;else{n.o=Oe.bind(null,e,t);return}if(n&&n.then){n.then(Oe.bind(null,e,t),Oe.bind(null,e,2));return}e.s=t,e.v=n;let r=e.o;r&&r(e)}}var Wy="/.well-known/did.json",ta=(function(){function e(){}return e.prototype.then=function(t,n){let r=new e,o=this.s;if(o){let i=o&1?t:n;if(i){try{Oe(r,1,i(this.v))}catch(s){Oe(r,2,s)}return r}else return this}return this.o=function(i){try{let s=i.v;i.s&1?Oe(r,1,t?t(s):s):n?Oe(r,1,n(s)):Oe(r,2,s)}catch(s){Oe(r,2,s)}},r},e})();function In(e){return e instanceof ta&&e.s&1}function Yy(e,t){var n;do{var r=e();if(r&&r.then)if(In(r))r=r.v;else{n=!0;break}var o=t();if(In(o)&&(o=o.v),!o)return r}while(!o.then);let i=new ta,s=Oe.bind(null,i,2);return(n?r.then(a):o.then(c)).then(void 0,s),i;function a(u){for(r=u;o=t(),In(o)&&(o=o.v),!!o;){if(o.then){o.then(c).then(void 0,s);return}if(r=e(),r&&r.then)if(In(r))r=r.v;else{r.then(a).then(void 0,s);return}}Oe(i,1,r)}function c(u){if(u){do{if(r=e(),r&&r.then)if(In(r))r=r.v;else{r.then(a).then(void 0,s);return}if(u=t(),In(u)&&(u=u.v),!u){Oe(i,1,r);return}}while(!u.then);u.then(c).then(void 0,s)}else Oe(i,1,r)}}function Xf(){return{web:function(t,n){try{let o=function(){let p=typeof l?.["@context"]<"u"?"application/did+ld+json":"application/did+json";return i?{didDocument:l,didDocumentMetadata:u,didResolutionMetadata:{error:"notFound",message:i}}:{didDocument:l,didDocumentMetadata:u,didResolutionMetadata:{contentType:p}}},r,i=null,s=decodeURIComponent(n.id)+Wy,a=n.id.split(":");a.length>1&&(s=a.map(decodeURIComponent).join("/")+"/did.json");let c=`https://${s}`,u={},l=null,f=Yy(function(){function p(){r||l?.id===t||(i="resolver_error: DID document id does not match requested did")}let g=Ky(function(){return Promise.resolve(Vy(c)).then(function(w){l=w})},function(w){i=`resolver_error: DID must resolve to a valid https URL containing a JSON document: ${w}`,r=1});return g&&g.then?g.then(p):p(g)},function(){return!r&&!1});return Promise.resolve(f&&f.then?f.then(o):o(f))}catch(r){return Promise.reject(r)}}}}var Go=class{methods={...Kf(),...Xf()};resolver=new Oo(this.methods,{cache:!0});inFlight=new Map;async resolve(t){if(!Object.keys(this.methods).some(o=>t.startsWith(`did:${o}:`)))throw new Error(`Unrecognized DID method: ${t}`);let n=this.inFlight.get(t);if(n)return n;let r=this.resolver.resolve(t).then(({didDocument:o})=>{if(!o)throw new Q(`DID not found: ${t}`);return o});this.inFlight.set(t,r);try{return await r}finally{this.inFlight.delete(t)}}};var oa;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(oa="oauth4webapi/v3.8.7");function Dr(e,t){if(e==null)return!1;try{return e instanceof t||Object.getPrototypeOf(e)[Symbol.toStringTag]===t.prototype[Symbol.toStringTag]}catch{return!1}}var xe="ERR_INVALID_ARG_VALUE",$e="ERR_INVALID_ARG_TYPE";function K(e,t,n){let r=new TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}var Jt=Symbol(),Wo=Symbol(),Yo=Symbol(),Kt=Symbol();var qo=Symbol();var Xy=new TextEncoder,Qy=new TextDecoder;function Qf(e){return typeof e=="string"?Xy.encode(e):Qy.decode(e)}var ia;Uint8Array.prototype.toBase64?ia=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0})):ia=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));let n=[];for(let r=0;r<t.byteLength;r+=32768)n.push(String.fromCharCode.apply(null,t.subarray(r,r+32768)));return btoa(n.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")};var sa;Uint8Array.fromBase64?sa=e=>{try{return Uint8Array.fromBase64(e,{alphabet:"base64url"})}catch(t){throw K("The input to be decoded is not correctly encoded.",xe,t)}}:sa=e=>{try{let t=atob(e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"")),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}catch(t){throw K("The input to be decoded is not correctly encoded.",xe,t)}};function aa(e){return typeof e=="string"?sa(e):ia(e)}var At=class extends Error{code;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=ri,Error.captureStackTrace?.(this,this.constructor)}},zr=class extends Error{code;constructor(t,n){super(t,n),this.name=this.constructor.name,n?.code&&(this.code=n?.code),Error.captureStackTrace?.(this,this.constructor)}};function D(e,t,n){return new zr(e,{code:t,cause:n})}function Jo(e){return!(e===null||typeof e!="object"||Array.isArray(e))}function ca(e){Dr(e,Headers)&&(e=Object.fromEntries(e.entries()));let t=new Headers(e??{});if(oa&&!t.has("user-agent")&&t.set("user-agent",oa),t.has("authorization"))throw K('"options.headers" must not include the "authorization" header name',xe);return t}function td(e,t){if(t!==void 0){if(typeof t=="function"&&(t=t(e.href)),!(t instanceof AbortSignal))throw K('"options.signal" must return or be an instance of AbortSignal',$e);return t}}function nd(e){return e.includes("//")?e.replace("//","/"):e}function ew(e,t,n=!1){return e.pathname==="/"?e.pathname=t:e.pathname=nd(`${t}/${n?e.pathname:e.pathname.replace(/(\/)$/,"")}`),e}function tw(e,t){return e.pathname=nd(`${e.pathname}/${t}`),e}async function nw(e,t,n,r){if(!(e instanceof URL))throw K(`"${t}" must be an instance of URL`,$e);ei(e,r?.[Jt]!==!0);let o=n(new URL(e.href)),i=ca(r?.headers);return i.set("accept","application/json"),(r?.[Kt]||fetch)(o.href,{body:void 0,headers:Object.fromEntries(i.entries()),method:"GET",redirect:"manual",signal:td(o,r?.signal)})}async function rd(e,t){return nw(e,"issuerIdentifier",n=>{switch(t?.algorithm){case void 0:case"oidc":tw(n,".well-known/openid-configuration");break;case"oauth2":ew(n,".well-known/oauth-authorization-server");break;default:throw K('"options.algorithm" must be "oidc" (default), or "oauth2"',xe)}return n},t)}function Ir(e,t,n,r,o){try{if(typeof e!="number"||!Number.isFinite(e))throw K(`${n} must be a number`,$e,o);if(e>0)return;if(t){if(e!==0)throw K(`${n} must be a non-negative number`,xe,o);return}throw K(`${n} must be a positive number`,xe,o)}catch(i){throw r?D(i.message,r,o):i}}function _e(e,t,n,r){try{if(typeof e!="string")throw K(`${t} must be a string`,$e,r);if(e.length===0)throw K(`${t} must not be empty`,xe,r)}catch(o){throw n?D(o.message,n,r):o}}async function od(e,t){let n=e;if(!(n instanceof URL)&&n!==Vo)throw K('"expectedIssuerIdentifier" must be an instance of URL',$e);if(!Dr(t,Response))throw K('"response" must be an instance of Response',$e);if(t.status!==200)throw D('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)',oi,t);ba(t);let r=await _d(t);if(_e(r.issuer,'"response" body "issuer" property',F,{body:r}),n!==Vo&&new URL(r.issuer).href!==n.href)throw D('"response" body "issuer" property does not match the expected value',ii,{expected:n.href,body:r,attribute:"issuer"});return r}function id(e){ow(e,"application/json")}function rw(e,...t){let n='"response" content-type must be ';if(t.length>2){let r=t.pop();n+=`${t.join(", ")}, or ${r}`}else t.length===2?n+=`${t[0]} or ${t[1]}`:n+=t[0];return D(n,ga,e)}function ow(e,t){if(pa(e)!==t)throw rw(e,t)}function iw(){return aa(crypto.getRandomValues(new Uint8Array(32)))}function sd(){return iw()}function ua(e){let t=e?.[Wo];return typeof t=="number"&&Number.isFinite(t)?t:0}function la(e){let t=e?.[Yo];return typeof t=="number"&&Number.isFinite(t)&&Math.sign(t)!==-1?t:30}function fa(){return Math.floor(Date.now()/1e3)}function Xo(e){if(typeof e!="object"||e===null)throw K('"as" must be an object',$e);_e(e.issuer,'"as.issuer"')}function Qo(e){if(typeof e!="object"||e===null)throw K('"client" must be an object',$e);_e(e.client_id,'"client.client_id"')}function da(e){return _e(e,'"clientSecret"'),(t,n,r,o)=>{r.set("client_id",n.client_id),r.set("client_secret",e)}}function ad(){return(e,t,n,r)=>{n.set("client_id",t.client_id)}}var sw=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch{return null}};function ei(e,t){if(t&&e.protocol!=="https:")throw D("only requests to HTTPS are allowed",ya,e);if(e.protocol!=="https:"&&e.protocol!=="http:")throw D("only HTTP and HTTPS requests are allowed",wa,e)}function ed(e,t,n,r){let o;if(typeof e!="string"||!(o=sw(e)))throw D(`authorization server metadata does not contain a valid ${n?`"as.mtls_endpoint_aliases.${t}"`:`"as.${t}"`}`,e===void 0?Iw:zw,{attribute:n?`mtls_endpoint_aliases.${t}`:t});return ei(o,r),o}function ti(e,t,n,r){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?ed(e.mtls_endpoint_aliases[t],t,n,r):ed(e[t],t,n,r)}function cd(e){if(e instanceof $n){let{0:t,length:n}=e.cause;return n===1&&t.scheme==="dpop"&&t.parameters.error==="use_dpop_nonce"}return e instanceof zn?e.error==="use_dpop_nonce":!1}var zn=class extends Error{cause;code;error;status;error_description;response;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=Ow,this.cause=n.cause,this.error=n.cause.error,this.status=n.response.status,this.error_description=n.cause.error_description,Object.defineProperty(this,"response",{enumerable:!1,value:n.response}),Error.captureStackTrace?.(this,this.constructor)}},$r=class extends Error{cause;code;error;error_description;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=kw,this.cause=n.cause,this.error=n.cause.get("error"),this.error_description=n.cause.get("error_description")??void 0,Error.captureStackTrace?.(this,this.constructor)}},$n=class extends Error{cause;code;response;status;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=Pw,this.cause=n.cause,this.status=n.response.status,this.response=n.response,Object.defineProperty(this,"response",{enumerable:!1}),Error.captureStackTrace?.(this,this.constructor)}},Ko="[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+",aw="[a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2}",cw='"((?:[^"\\\\]|\\\\[\\s\\S])*)"',uw="("+Ko+")\\s*=\\s*"+cw,lw="("+Ko+")\\s*=\\s*("+Ko+")",fw=new RegExp("^[,\\s]*("+Ko+")"),dw=new RegExp("^[,\\s]*"+uw+"[,\\s]*(.*)"),pw=new RegExp("^[,\\s]*"+lw+"[,\\s]*(.*)"),hw=new RegExp("^("+aw+")(?:$|[,\\s])(.*)");function mw(e){if(!Dr(e,Response))throw K('"response" must be an instance of Response',$e);let t=e.headers.get("www-authenticate");if(t===null)return;let n=[],r=t;for(;r;){let o=r.match(fw),i=o?.[1].toLowerCase();if(!i)return;let s=r.substring(o[0].length);if(s&&!s.match(/^[\s,]/))return;let a=s.match(/^\s+(.*)$/),c=!!a;r=a?a[1]:void 0;let u={},l;if(c)for(;r;){let p,g;if(o=r.match(dw)){if([,p,g,r]=o,g.includes("\\"))try{g=JSON.parse(`"${g}"`)}catch{}u[p.toLowerCase()]=g;continue}if(o=r.match(pw)){[,p,g,r]=o,u[p.toLowerCase()]=g;continue}if(o=r.match(hw)){if(Object.keys(u).length)break;[,l,r]=o;break}return}else r=s||void 0;let f={scheme:i,parameters:u};l&&(f.token68=l),n.push(f)}if(n.length)return n}async function gw(e){if(e.status>399&&e.status<500){ba(e),id(e);try{let t=await e.clone().json();if(Jo(t)&&typeof t.error=="string"&&t.error.length)return t}catch{}}}async function ud(e,t,n){if(e.status!==t){_w(e);let r;throw(r=await gw(e))?(await e.body?.cancel(),new zn("server responded with an error in the response body",{cause:r,response:e})):D(`"response" is not a conform ${n} response (unexpected HTTP status code)`,oi,e)}}function yw(e){if(!ha.has(e))throw K('"options.DPoP" is not a valid DPoPHandle',xe)}function pa(e){return e.headers.get("content-type")?.split(";")[0]}async function ld(e,t,n,r,o,i,s){return await n(e,t,o,i),i.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),(s?.[Kt]||fetch)(r.href,{body:o,headers:Object.fromEntries(i.entries()),method:"POST",redirect:"manual",signal:td(r,s?.signal)})}async function ww(e,t,n,r,o,i){let s=ti(e,"token_endpoint",t.use_mtls_endpoint_aliases,i?.[Jt]!==!0);o.set("grant_type",r);let a=ca(i?.headers);a.set("accept","application/json"),i?.DPoP!==void 0&&(yw(i.DPoP),await i.DPoP.addProof(s,a,"POST"));let c=await ld(e,t,n,s,o,a,i);return i?.DPoP?.cacheNonce(c,s),c}var fd=new WeakMap,bw=new WeakMap;function ni(e){if(!e.id_token)return;let t=fd.get(e);if(!t)throw K('"ref" was already garbage collected or did not resolve from the proper sources',xe);return t}async function dd(e,t,n,r,o,i){if(Xo(e),Qo(t),!Dr(n,Response))throw K('"response" must be an instance of Response',$e);await ud(n,200,"Token Endpoint"),ba(n);let s=await _d(n);if(_e(s.access_token,'"response" body "access_token" property',F,{body:s}),_e(s.token_type,'"response" body "token_type" property',F,{body:s}),s.token_type=s.token_type.toLowerCase(),s.expires_in!==void 0){let a=typeof s.expires_in!="number"?parseFloat(s.expires_in):s.expires_in;Ir(a,!0,'"response" body "expires_in" property',F,{body:s}),s.expires_in=a}if(s.refresh_token!==void 0&&_e(s.refresh_token,'"response" body "refresh_token" property',F,{body:s}),s.scope!==void 0&&typeof s.scope!="string")throw D('"response" body "scope" property must be a string',F,{body:s});if(s.id_token!==void 0){_e(s.id_token,'"response" body "id_token" property',F,{body:s});let a=["aud","exp","iat","iss","sub"];t.require_auth_time===!0&&a.push("auth_time"),t.default_max_age!==void 0&&(Ir(t.default_max_age,!0,'"client.default_max_age"'),a.push("auth_time")),r?.length&&a.push(...r);let{claims:c,jwt:u}=await $w(s.id_token,Dw.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,"RS256"),ua(t),la(t),o).then(Aw.bind(void 0,a)).then(Ew.bind(void 0,e)).then(xw.bind(void 0,t.client_id));if(Array.isArray(c.aud)&&c.aud.length!==1){if(c.azp===void 0)throw D('ID Token "aud" (audience) claim includes additional untrusted audiences',We,{claims:c,claim:"aud"});if(c.azp!==t.client_id)throw D('unexpected ID Token "azp" (authorized party) claim value',We,{expected:t.client_id,claims:c,claim:"azp"})}c.auth_time!==void 0&&Ir(c.auth_time,!0,'ID Token "auth_time" (authentication time)',F,{claims:c}),bw.set(n,u),fd.set(s,c)}if(i?.[s.token_type]!==void 0)i[s.token_type](n,s);else if(s.token_type!=="dpop"&&s.token_type!=="bearer")throw new At("unsupported `token_type` value",{cause:{body:s}});return s}function _w(e){let t;if(t=mw(e))throw new $n("server responded with a challenge in the WWW-Authenticate HTTP Header",{cause:t,response:e})}function xw(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw D('unexpected JWT "aud" (audience) claim value',We,{expected:e,claims:t.claims,claim:"aud"})}else if(t.claims.aud!==e)throw D('unexpected JWT "aud" (audience) claim value',We,{expected:e,claims:t.claims,claim:"aud"});return t}function Ew(e,t){let n=e[_a]?.(t)??e.issuer;if(t.claims.iss!==n)throw D('unexpected JWT "iss" (issuer) claim value',We,{expected:n,claims:t.claims,claim:"iss"});return t}var ha=new WeakSet;function Sw(e){return ha.add(e),e}var ma=Symbol();async function pd(e,t,n,r,o,i,s){if(Xo(e),Qo(t),!ha.has(r))throw K('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()',xe);_e(o,'"redirectUri"');let a=qt(r,"code");if(!a)throw D('no authorization code in "callbackParameters"',F);let c=new URLSearchParams(s?.additionalParameters);return c.set("redirect_uri",o),c.set("code",a),i!==ma&&(_e(i,'"codeVerifier"'),c.set("code_verifier",i)),ww(e,t,n,"authorization_code",c,s)}var vw={aud:"audience",c_hash:"code hash",client_id:"client id",exp:"expiration time",iat:"issued at",iss:"issuer",jti:"jwt id",nonce:"nonce",s_hash:"state hash",sub:"subject",ath:"access token hash",htm:"http method",htu:"http uri",cnf:"confirmation",auth_time:"authentication time"};function Aw(e,t){for(let n of e)if(t.claims[n]===void 0)throw D(`JWT "${n}" (${vw[n]}) claim missing`,F,{claims:t.claims});return t}var na=Symbol(),ra=Symbol();async function hd(e,t,n,r){return typeof r?.expectedNonce=="string"||typeof r?.maxAge=="number"||r?.requireIdToken?Tw(e,t,n,r.expectedNonce,r.maxAge,r[qo],r.recognizedTokenTypes):Rw(e,t,n,r?.[qo],r?.recognizedTokenTypes)}async function Tw(e,t,n,r,o,i,s){let a=[];switch(r){case void 0:r=na;break;case na:break;default:_e(r,'"expectedNonce" argument'),a.push("nonce")}switch(o??=t.default_max_age,o){case void 0:o=ra;break;case ra:break;default:Ir(o,!0,'"maxAge" argument'),a.push("auth_time")}let c=await dd(e,t,n,a,i,s);_e(c.id_token,'"response" body "id_token" property',F,{body:c});let u=ni(c);if(o!==ra){let l=fa()+ua(t),f=la(t);if(u.auth_time+o<l-f)throw D("too much time has elapsed since the last End-User authentication",Cn,{claims:u,now:l,tolerance:f,claim:"auth_time"})}if(r===na){if(u.nonce!==void 0)throw D('unexpected ID Token "nonce" claim value',We,{expected:void 0,claims:u,claim:"nonce"})}else if(u.nonce!==r)throw D('unexpected ID Token "nonce" claim value',We,{expected:r,claims:u,claim:"nonce"});return c}async function Rw(e,t,n,r,o){let i=await dd(e,t,n,void 0,r,o),s=ni(i);if(s){if(t.default_max_age!==void 0){Ir(t.default_max_age,!0,'"client.default_max_age"');let a=fa()+ua(t),c=la(t);if(s.auth_time+t.default_max_age<a-c)throw D("too much time has elapsed since the last End-User authentication",Cn,{claims:s,now:a,tolerance:c,claim:"auth_time"})}if(s.nonce!==void 0)throw D('unexpected ID Token "nonce" claim value',We,{expected:void 0,claims:s,claim:"nonce"})}return i}var Pw="OAUTH_WWW_AUTHENTICATE_CHALLENGE",Ow="OAUTH_RESPONSE_BODY_ERROR",ri="OAUTH_UNSUPPORTED_OPERATION",kw="OAUTH_AUTHORIZATION_RESPONSE_ERROR";var Cr="OAUTH_PARSE_ERROR",F="OAUTH_INVALID_RESPONSE";var ga="OAUTH_RESPONSE_IS_NOT_JSON",oi="OAUTH_RESPONSE_IS_NOT_CONFORM",ya="OAUTH_HTTP_REQUEST_FORBIDDEN",wa="OAUTH_REQUEST_PROTOCOL_FORBIDDEN",Cn="OAUTH_JWT_TIMESTAMP_CHECK_FAILED",We="OAUTH_JWT_CLAIM_COMPARISON_FAILED",ii="OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED";var Iw="OAUTH_MISSING_SERVER_METADATA",zw="OAUTH_INVALID_SERVER_METADATA";async function md(e,t,n,r,o){Xo(e),Qo(t),_e(r,'"token"');let i=ti(e,"revocation_endpoint",t.use_mtls_endpoint_aliases,o?.[Jt]!==!0),s=new URLSearchParams(o?.additionalParameters);s.set("token",r);let a=ca(o?.headers);return a.delete("accept"),ld(e,t,n,i,s,a,o)}async function gd(e){if(!Dr(e,Response))throw K('"response" must be an instance of Response',$e);await ud(e,200,"Revocation Endpoint")}function ba(e){if(e.bodyUsed)throw K('"response" body has been used already',xe)}async function $w(e,t,n,r,o){let{0:i,1:s,length:a}=e.split(".");if(a===5)if(o!==void 0)e=await o(e),{0:i,1:s,length:a}=e.split(".");else throw new At("JWE decryption is not configured",{cause:e});if(a!==3)throw D("Invalid JWT",F,e);let c;try{c=JSON.parse(Qf(aa(i)))}catch(f){throw D("failed to parse JWT Header body as base64url encoded JSON",Cr,f)}if(!Jo(c))throw D("JWT Header must be a top level object",F,e);if(t(c),c.crit!==void 0)throw new At('no JWT "crit" header parameter extensions are supported',{cause:{header:c}});let u;try{u=JSON.parse(Qf(aa(s)))}catch(f){throw D("failed to parse JWT Payload body as base64url encoded JSON",Cr,f)}if(!Jo(u))throw D("JWT Payload must be a top level object",F,e);let l=fa()+n;if(u.exp!==void 0){if(typeof u.exp!="number")throw D('unexpected JWT "exp" (expiration time) claim type',F,{claims:u});if(u.exp<=l-r)throw D('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp',Cn,{claims:u,now:l,tolerance:r,claim:"exp"})}if(u.iat!==void 0&&typeof u.iat!="number")throw D('unexpected JWT "iat" (issued at) claim type',F,{claims:u});if(u.iss!==void 0&&typeof u.iss!="string")throw D('unexpected JWT "iss" (issuer) claim type',F,{claims:u});if(u.nbf!==void 0){if(typeof u.nbf!="number")throw D('unexpected JWT "nbf" (not before) claim type',F,{claims:u});if(u.nbf>l+r)throw D('unexpected JWT "nbf" (not before) claim value',Cn,{claims:u,now:l,tolerance:r,claim:"nbf"})}if(u.aud!==void 0&&typeof u.aud!="string"&&!Array.isArray(u.aud))throw D('unexpected JWT "aud" (audience) claim type',F,{claims:u});return{header:c,claims:u,jwt:e}}async function Cw(e){if(e.bodyUsed)throw K("form_post Request instances must contain a readable body",xe,{cause:e});return e.text()}async function yd(e){if(e.method!=="POST")throw K("form_post responses are expected to use the POST method",xe,{cause:e});if(pa(e)!=="application/x-www-form-urlencoded")throw K("form_post responses are expected to use the application/x-www-form-urlencoded content-type",xe,{cause:e});return Cw(e)}function Dw(e,t,n,r){if(e!==void 0){if(typeof e=="string"?r.alg!==e:!e.includes(r.alg))throw D('unexpected JWT "alg" header parameter',F,{header:r,expected:e,reason:"client configuration"});return}if(Array.isArray(t)){if(!t.includes(r.alg))throw D('unexpected JWT "alg" header parameter',F,{header:r,expected:t,reason:"authorization server metadata"});return}if(n!==void 0){if(typeof n=="string"?r.alg!==n:typeof n=="function"?!n(r.alg):!n.includes(r.alg))throw D('unexpected JWT "alg" header parameter',F,{header:r,expected:n,reason:"default value"});return}throw D('missing client or server configuration to verify used JWT "alg" header parameter',void 0,{client:e,issuer:t,fallback:n})}function qt(e,t){let{0:n,length:r}=e.getAll(t);if(r>1)throw D(`"${t}" parameter must be provided only once`,F);return n}var wd=Symbol(),Uw=Symbol();function bd(e,t,n,r){if(Xo(e),Qo(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw K('"parameters" must be an instance of URLSearchParams, or URL',$e);if(qt(n,"response"))throw D('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()',F,{parameters:n});let o=qt(n,"iss"),i=qt(n,"state");if(!o&&e.authorization_response_iss_parameter_supported)throw D('response parameter "iss" (issuer) missing',F,{parameters:n});if(o&&o!==e.issuer)throw D('unexpected "iss" (issuer) response parameter value',F,{expected:e.issuer,parameters:n});switch(r){case void 0:case Uw:if(i!==void 0)throw D('unexpected "state" response parameter encountered',F,{expected:void 0,parameters:n});break;case wd:break;default:if(_e(r,'"expectedState" argument'),i!==r)throw D(i===void 0?'response parameter "state" missing':'unexpected "state" response parameter value',F,{expected:r,parameters:n})}if(qt(n,"error"))throw new $r("authorization response from the server is an error",{cause:n});let a=qt(n,"id_token"),c=qt(n,"token");if(a!==void 0||c!==void 0)throw new At("implicit and hybrid flows are not supported");return Sw(new URLSearchParams(n))}async function _d(e,t=id){let n;try{n=await e.json()}catch(r){throw t(e),D('failed to parse "response" body as JSON',Cr,r)}if(!Jo(n))throw D('"response" body must be a top level object',F,{body:n});return n}var Vo=Symbol(),_a=Symbol();var Mr,xd;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(xd="openid-client/v6.8.7",Mr={"user-agent":xd});var je=e=>Ea.get(e),Ea,xa;function Lw(e){return e!==void 0?da(e):(xa||=new WeakMap,(t,n,r,o)=>{let i;return(i=xa.get(n))||(Nw(n.client_secret,'"metadata.client_secret"'),i=da(n.client_secret),xa.set(n,i)),i(t,n,r,o)})}function Nw(e,t){if(typeof e!="string")throw Ye(`${t} must be a string`,Nr);if(e.length===0)throw Ye(`${t} must not be empty`,Lr)}function Bw(){return ad()}var Dn=Kt;var Lr="ERR_INVALID_ARG_VALUE",Nr="ERR_INVALID_ARG_TYPE";function Ye(e,t,n){let r=new TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}function Sd(){return sd()}var Un=class extends Error{code;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=n?.code,Error.captureStackTrace?.(this,this.constructor)}},sO=new TextDecoder;function ge(e,t,n){return new Un(e,{cause:t,code:n})}function Ur(e){if(e instanceof TypeError||e instanceof Un||e instanceof zn||e instanceof $r||e instanceof $n)throw e;if(e instanceof zr)switch(e.code){case ya:throw ge("only requests to HTTPS are allowed",e,e.code);case wa:throw ge("only requests to HTTP or HTTPS are allowed",e,e.code);case oi:throw ge("unexpected HTTP response status code",e.cause,e.code);case ga:throw ge("unexpected response content-type",e.cause,e.code);case Cr:throw ge("parsing error occured",e,e.code);case F:throw ge("invalid response encountered",e,e.code);case We:throw ge("unexpected JWT claim value encountered",e,e.code);case ii:throw ge("unexpected JSON attribute value encountered",e,e.code);case Cn:throw ge("JWT timestamp claim value failed validation",e,e.code);default:throw ge(e.message,e,e.code)}if(e instanceof At)throw ge("unsupported operation",e,e.code);if(e instanceof DOMException)switch(e.name){case"OperationError":throw ge("runtime operation error",e,ri);case"NotSupportedError":throw ge("runtime unsupported operation",e,ri);case"TimeoutError":throw ge("operation timed out",e,"OAUTH_TIMEOUT");case"AbortError":throw ge("operation aborted",e,"OAUTH_ABORT")}throw new Un("something went wrong",{cause:e})}function jw(e,t,n){return e.origin==="https://login.microsoftonline.com"&&(!n?.algorithm||n.algorithm==="oidc")?(t[Ad]=!0,!0):!1}function Zw(e,t){return!!(e.hostname.endsWith(".b2clogin.com")&&(!t?.algorithm||t.algorithm==="oidc"))}async function vd(e,t,n,r,o){let i=await Fw(e,o),s=new Mn(i,t,n,r),a=je(s);if(o?.[Dn]&&(a.fetch=o[Dn]),o?.timeout&&(a.timeout=o.timeout),o?.execute)for(let c of o.execute)c(s);return s}async function Fw(e,t){if(!(e instanceof URL))throw Ye('"server" must be an instance of URL',Nr);let n=!e.href.includes("/.well-known/"),r=t?.timeout??30,o=AbortSignal.timeout(r*1e3),i=await(n?rd(e,{algorithm:t?.algorithm,[Kt]:t?.[Dn],[Jt]:t?.execute?.includes(Ed),signal:o,headers:new Headers(Mr)}):(t?.[Dn]||fetch)((ei(e,!t?.execute?.includes(Ed)),e.href),{headers:Object.fromEntries(new Headers({accept:"application/json",...Mr}).entries()),body:void 0,method:"GET",redirect:"manual",signal:o})).then(s=>od(Vo,s)).catch(Ur);return n&&new URL(i.issuer).href!==e.href&&(jw(e,i,t)||Zw(e,t)||(()=>{throw new Un("discovered metadata issuer does not match the expected issuer",{code:ii,cause:{expected:e.href,body:i,attribute:"issuer"}})})()),i}function Hw(e){return{supportsPKCE:{__proto__:null,value(t="S256"){return e.code_challenge_methods_supported?.includes(t)===!0}}}}function Gw(e){Object.defineProperties(e,Hw(e))}var Ad=Symbol(),Mn=class{constructor(t,n,r,o){if(typeof n!="string"||!n.length)throw Ye('"clientId" must be a non-empty string',Nr);if(typeof r=="string"&&(r={client_secret:r}),r?.client_id!==void 0&&n!==r.client_id)throw Ye('"clientId" and "metadata.client_id" must be the same',Lr);let i={...structuredClone(r),client_id:n};i[Wo]=r?.[Wo]??0,i[Yo]=r?.[Yo]??30;let s;o?s=o:typeof i.client_secret=="string"&&i.client_secret.length?s=Lw(i.client_secret):s=Bw();let a=Object.freeze(i),c=structuredClone(t);Ad in t&&(c[_a]=({claims:{tid:l}})=>t.issuer.replace("{tenantid}",l));let u=Object.freeze(c);Ea||=new WeakMap,Ea.set(this,{__proto__:null,as:u,c:a,auth:s,tlsOnly:!0,jwksCache:{}})}serverMetadata(){let t=structuredClone(je(this).as);return Gw(t),t}clientMetadata(){return structuredClone(je(this).c)}get timeout(){return je(this).timeout}set timeout(t){je(this).timeout=t}get[Dn](){return je(this).fetch}set[Dn](t){je(this).fetch=t}};Object.freeze(Mn.prototype);function qw(e){let t;if(e.expires_in!==void 0){let n=new Date;n.setSeconds(n.getSeconds()+e.expires_in),t=n.getTime()}return{expiresIn:{__proto__:null,value(){if(t){let n=Date.now();return t>n?Math.floor((t-n)/1e3):0}}},claims:{__proto__:null,value(){return ni(e)}}}}function Jw(e){Object.defineProperties(e,qw(e))}function Ed(e){je(e).tlsOnly=!1}function Kw(e){return e=new URL(e),e.search="",e.hash="",e.href}function Vw(e,t){try{return Object.getPrototypeOf(e)[Symbol.toStringTag]===t}catch{return!1}}async function Sa(e,t,n,r,o){if(va(e),o?.flag!==si&&!(t instanceof URL)&&!Vw(t,"Request"))throw Ye('"currentUrl" must be an instance of URL, or Request',Nr);let i,s,{as:a,c,auth:u,fetch:l,tlsOnly:f,jarm:p,hybrid:g,nonRepudiation:w,timeout:x,decrypt:A,implicit:h}=je(e);if(o?.flag===si)i=o.authResponse,s=o.redirectUri;else{if(!(t instanceof URL)){let v=t;switch(t=new URL(t.url),v.method){case"GET":break;case"POST":let O=new URLSearchParams(await yd(v));if(g)t.hash=O.toString();else for(let[I,z]of O.entries())t.searchParams.append(I,z);break;default:throw Ye("unexpected Request HTTP method",Lr)}}switch(s=Kw(t),!0){case!!p:i=await p(t,n?.expectedState);break;case!!g:i=await g(t,n?.expectedNonce,n?.expectedState,n?.maxAge);break;case!!h:throw new TypeError("authorizationCodeGrant() cannot be used by response_type=id_token clients");default:try{i=bd(a,c,t.searchParams,n?.expectedState)}catch(v){Ur(v)}}}let _=await pd(a,c,u,i,s,n?.pkceCodeVerifier||ma,{additionalParameters:r,[Kt]:l,[Jt]:!f,DPoP:o?.DPoP,headers:new Headers(Mr),signal:Rd(x)}).catch(Ur);(typeof n?.expectedNonce=="string"||typeof n?.maxAge=="number")&&(n.idTokenExpected=!0);let S=hd(a,c,_,{expectedNonce:n?.expectedNonce,maxAge:n?.maxAge,requireIdToken:n?.idTokenExpected,[qo]:A}),b;try{b=await S}catch(v){if(Ww(v,o))return Sa(e,void 0,n,r,{...o,flag:si,authResponse:i,redirectUri:s});Ur(v)}return b.id_token&&await w?.(_),Jw(b),b}function Td(e,t){va(e);let{as:n,c:r,tlsOnly:o,hybrid:i,jarm:s,implicit:a}=je(e),c=ti(n,"authorization_endpoint",!1,o);if(t=new URLSearchParams(t),t.has("client_id")||t.set("client_id",r.client_id),!t.has("request_uri")&&!t.has("request")){if(t.has("response_type")||t.set("response_type",i?"code id_token":a?"id_token":"code"),a&&!t.has("nonce"))throw Ye("response_type=id_token clients must provide a nonce parameter in their authorization request parameters",Lr);s&&t.set("response_mode","jwt")}for(let[u,l]of t.entries())c.searchParams.append(u,l);return c}function va(e){if(!(e instanceof Mn))throw Ye('"config" must be an instance of Configuration',Nr);if(Object.getPrototypeOf(e)!==Mn.prototype)throw Ye("subclassing Configuration is not allowed",Lr)}function Rd(e){return e?AbortSignal.timeout(e*1e3):void 0}function Ww(e,t){return t?.DPoP&&t.flag!==si?cd(e):!1}var si=Symbol();async function Pd(e,t,n){va(e);let{as:r,c:o,auth:i,fetch:s,tlsOnly:a,timeout:c}=je(e);return md(r,o,i,t,{[Kt]:s,[Jt]:!a,additionalParameters:new URLSearchParams(n),headers:new Headers(Mr),signal:Rd(c)}).then(gd).catch(Ur)}var Od="oauth2:",Br="graffiti-auth-oauth2-data",ai=class{eventTarget=new EventTarget;constructor(){let t=this.completeOauth();(async()=>{await new Promise(r=>setTimeout(r,0)),await t;let n=new CustomEvent("initialized");this.eventTarget.dispatchEvent(n)})()}async login(...t){try{await this.login_(...t)}catch(n){let r=n instanceof Error?n:new Error("Unknown error"),o={loginId:t[1],error:r};this.eventTarget.dispatchEvent(new CustomEvent("login",{detail:o}))}}async login_(t,n,r,o){let i=await this.getAuthorizationConfiguration(t),s=r.map(encodeURIComponent).join(" "),a=Sd(),c,u;if(typeof window<"u"){c=window.location.href;let p={loginId:n,redirectUri:c,authorizationEndpoint:t,state:a,serviceEndpoints:r};window.localStorage.setItem(Br,JSON.stringify(p))}else{let g=(await import("node:http").catch(x=>{throw new Error("Unrecognized environment: cannot find window or node:http")})).createServer();try{await new Promise((x,A)=>{g.once("error",A),g.listen(0,"::1",x)})}catch{try{g.close()}catch{}throw new Error("Failed to start local oauth callback server.")}let w=g.address();if(!w){try{g.close()}catch{}throw new Error("Failed to get local oauth callback server address.")}c=typeof w=="string"?`http://${w}`:`http://${w.family==="IPv6"?`[${w.address}]`:w.address}:${w.port}`,u=new Promise((x,A)=>{let h=setTimeout(()=>{try{g.close()}catch{}A("Oauth callback timed out.")},3e5),_=new Set;g.on("connection",b=>{_.add(b),b.on("close",()=>{_.delete(b)})});let S=async(b,v)=>{try{let O=new URL(b.url??"/",c);await this.onCallbackUrl({loginId:n,callbackUrl:O,configuration:i,expectedState:a,serviceEndpoints:r}),v.statusCode=200,v.setHeader("Content-Type","text/plain"),v.end("You may now close this window.")}catch(O){throw v.statusCode=500,v.setHeader("Content-Type","text/plain"),v.end("Error processing OAuth callback."),O}finally{clearTimeout(h),g.off("request",S);for(let O of _)O.destroy();g.close(()=>x())}};g.on("request",S)})}let l=new URL(c);l.hash="",l.search="";let f=Td(i,{scope:s,redirect_uri:l.toString(),state:a});typeof window<"u"?o==="assign"?window.location.assign(f.toString()):window.location.replace(f.toString()):(console.log("Please open the following URL in your browser:"),console.log(f.toString()),await u)}completeOauth(){if(typeof window>"u")return;let t=window.localStorage.getItem(Br);if(!t)return;let n;try{n=JSON.parse(t)}catch{console.error("Invalid OAuth2 login data in local storage."),window.localStorage.removeItem(Br);return}let r=Yw.safeParse(n);if(!r.success){console.error("Invalid OAuth2 login data structure in local storage.",r.error),window.localStorage.removeItem(Br);return}let{loginId:o,redirectUri:i,authorizationEndpoint:s,state:a,serviceEndpoints:c}=r.data;try{let u=new URL(i),l=new URL(window.location.href);if(u.pathname!==l.pathname)return;let f=l.searchParams;return!f.has("code")&&!f.has("error")?void 0:(window.history.replaceState({},document.title,u.toString()),window.localStorage.removeItem(Br),new Promise(p=>setTimeout(p,0)).then(()=>this.getAuthorizationConfiguration(s)).then(p=>this.onCallbackUrl({loginId:o,callbackUrl:l,configuration:p,expectedState:a,serviceEndpoints:c})).catch(p=>{let g=p instanceof Error?p:new Error("Unknown error"),w={loginId:o,error:g};this.eventTarget.dispatchEvent(new CustomEvent("login",{detail:w}))}))}catch(u){console.error(u)}}async onCallbackUrl(t){let{loginId:n,callbackUrl:r,configuration:o,expectedState:i,serviceEndpoints:s}=t,a=await Sa(o,r,{expectedState:i}),c=a.access_token,l=a.scope?.split(" ").map(decodeURIComponent)||s;if(!s.every(p=>l.includes(p)))throw new Error("Not all requested service endpoints were granted.");let f=new CustomEvent("login",{detail:{loginId:n,token:c}});this.eventTarget.dispatchEvent(f)}async logout(t,n,r){try{await this.logout_(t,n,r)}catch(o){let i=o instanceof Error?o:new Error("Unknown error"),s={logoutId:n,error:i};this.eventTarget.dispatchEvent(new CustomEvent("logout",{detail:s}))}}async logout_(t,n,r){let o=await this.getAuthorizationConfiguration(t);await Pd(o,r);let i={logoutId:n};this.eventTarget.dispatchEvent(new CustomEvent("logout",{detail:i}))}async getAuthorizationConfiguration(t){if(!t.startsWith(Od))throw new Error(`Unrecognized authorization endpoint method: ${t}`);let n=t.slice(Od.length),r;try{r=new URL(n)}catch{throw new Error("Invalid issuer URL.")}return await vd(r,"graffiti-client")}},kd=Eu(Se({loginId:B()}),ct([Se({token:B(),error:X(xu())}),Se({error:on(Error)})])),Id=Se({logoutId:B(),error:X(on(Error))}),zd=X(Ue(Se({error:X(on(Error))}))),Yw=Se({loginId:B(),redirectUri:Z(),authorizationEndpoint:Z(),state:B(),serviceEndpoints:q(Z())});var Xw="https://";function Ce(e){if(!e.startsWith(Xw))throw new Error("Unrecognized storage bucket endpoint type")}async function ci(e){Ce(e);let t=`${e}/auth`,n=await fetch(t);if(!n.ok)throw new Error("Failed to get storage bucket authorization endpoint");return await n.text()}var Vt=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorUnauthorized",Object.setPrototypeOf(this,e.prototype)}};async function Xe(...e){let t=await fetch(...e);if(!t.ok){let n;try{n=await t.text()}catch{n=t.statusText}throw t.status===401?new Vt(n):t.status===403?new mt(n):t.status===404?new Q(n):t.status===410?new Me(n):t.status===413?new gt(n):new Error(n)}return t}var Qw=32,eb=1024*1024,tb=2;function $d(e){return Math.min(Qw,Math.floor(eb/e))}var ui=class{getAuthorizationEndpoint=ci;queues=new Map;unsupportedBatchEndpoints=new Set;async put(t,n,r,o){Ce(t);let i=`${t}/value/${encodeURIComponent(n)}`;await Xe(i,{method:"PUT",headers:{"Content-Type":"application/octet-stream",Authorization:`Bearer ${o}`},body:r.slice()})}async delete(t,n,r){Ce(t);let o=`${t}/value/${encodeURIComponent(n)}`;await Xe(o,{method:"DELETE",headers:{Authorization:`Bearer ${r}`}})}async get(t,n,r){return Ce(t),r!==void 0&&Number.isSafeInteger(r)&&r>0&&$d(r)>=2&&!this.unsupportedBatchEndpoints.has(t)?new Promise((o,i)=>{let s=this.queues.get(t);s||(s=new Map,this.queues.set(t,s));let a=s.get(r);a||(a={requests:[]},s.set(r,a)),a.requests.push({key:n,resolve:o,reject:i}),a.requests.length===$d(r)?this.flush(t,r,a):a.timer===void 0&&(a.timer=setTimeout(()=>this.flush(t,r,a),tb))}):this.getOne(t,n,r)}flush(t,n,r){r.timer!==void 0&&clearTimeout(r.timer);let o=r.requests,i=this.queues.get(t);i.delete(n),i.size===0&&this.queues.delete(t),o.length===1||this.unsupportedBatchEndpoints.has(t)?o.forEach(({key:s,resolve:a,reject:c})=>{this.getOne(t,s,n).then(a,c)}):this.getBatch(t,n,o)}async getBatch(t,n,r){try{let o=await fetch(`${t}/values`,{method:"POST",headers:{"Content-Type":"application/cbor",Accept:"application/cbor"},body:pe({keys:r.map(({key:s})=>s),maxValueBytes:n}).slice()});if(o.status===404){this.unsupportedBatchEndpoints.add(t),await Promise.all(r.map(async({key:s,resolve:a,reject:c})=>{try{a(await this.getOne(t,s,n))}catch(u){c(u)}}));return}if(!o.ok)throw new Error(await o.text());let i=Ne(await o.arrayBuffer());if(!i||typeof i!="object"||!("results"in i)||!Array.isArray(i.results)||i.results.length!==r.length)throw new Error("Invalid storage batch response");i.results.forEach((s,a)=>{let{resolve:c,reject:u}=r[a];!s||typeof s!="object"||!("status"in s)?u(new Error("Invalid storage batch result")):s.status===200&&"value"in s&&s.value instanceof Uint8Array&&s.value.byteLength<=n?c(s.value):s.status===404?u(new Q("Value not found")):s.status===413?u(new gt("Value exceeds maximum byte limit")):u(new Error("Invalid storage batch result"))})}catch(o){r.forEach(({reject:i})=>i(o))}}async getOne(t,n,r){let o=`${t}/value/${encodeURIComponent(n)}`,i=await Xe(o),s=i.body?.getReader();if(!s)throw new Error("Failed to read value from storage bucket");let a=i.headers.get("Content-Length"),c=a?Number(a):void 0;if(!!c&&!!Number.isFinite(c)&&c>=0){let w=c;if(r!==void 0&&w>r)throw new Error("Value exceeds maximum byte limit");let x=new Uint8Array(w),A=0,h=!1;try{for(;A<=x.length;){let{done:_,value:S}=await s.read();if(_){h=!0;break}if(!S||S.length===0)continue;let b=A+S.length;if(b>x.length)throw new Error("Received more data than expected");x.set(S,A),A=b}}finally{s.releaseLock()}if(!h)throw new Error("Failed to read complete value from storage bucket");return A===w?x:x.slice(0,A)}let l=[],f=0;try{for(;;){let{done:w,value:x}=await s.read();if(w)break;if(!(!x||x.length===0)){if(f+=x.length,r!==void 0&&f>r)throw new Error("Value exceeds maximum byte limit");l.push(x.slice())}}}finally{s.releaseLock()}let p=new Uint8Array(f),g=0;for(let w of l)p.set(w,g),g+=w.length;return p}async*export(t,n){Ce(t);let r=`${t}/export`,o;for(;;){let s=await(await Xe(o?`${r}?cursor=${encodeURIComponent(o)}`:r,{headers:{Authorization:`Bearer ${n}`}})).blob(),a=Ne(await s.arrayBuffer()),c=nb.parse(a);for(let u of c.keys)yield{key:u};if(c.cursor)o=c.cursor;else break}}},nb=Se({keys:q(B()),cursor:X(Ue(B()))});var rb=ye({value:we({}),channels:q(B()),allowed:X(Ue(q(Z()))),url:Z(),actor:Z()}),Aa=Mt(e=>e instanceof Uint8Array),Cd=q(Aa),Ln="t",Ze="o",Nn="m",Dd=ye({[Ln]:Cd,[Ze]:rb,[Nn]:Aa}),jr="id",ft="m",Zr="l",li=ye({[jr]:B(),[ft]:Dd,[Zr]:_u()}),Ud=ye({id:B()}),Md=ye({results:q(li),hasMore:rn(),cursor:B()});async function Ta(){try{return globalThis.indexedDB?(await new Promise((e,t)=>{let n=indexedDB.open("__idb_probe__",1);n.onupgradeneeded=()=>n.result.createObjectStore("k"),n.onsuccess=()=>{n.result.close(),e()},n.onerror=()=>t(n.error)}),!0):!1}catch{return!1}}function Fr(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}async function Nd(e,t,n,r,o=0){let i=r.messageIds.slice(o);return Promise.all(i.map(async s=>{let a=await e.messages.get(Fr(t,s));if(!a){try{await e.messageIds.del(n)}catch{}throw new Error("Cache out of sync - perhaps clear browser storage")}return a}))}async function Bd(e,t,n,r,o){await e.messages.setMany(o.messages.map(s=>[Fr(t,s[jr]),s]));let i={cursor:o.cursor,version:r?.version??crypto.randomUUID(),messageIds:[...r?.messageIds??[],...o.messages.map(s=>s[jr])],generation:crypto.randomUUID(),hasMore:o.hasMore,waitTil:o.waitTil};return await e.messageIds.set(n,i),i}async function jd(e,t,n){let r=pe({inboxUrl:e,type:t,body:n??null});return crypto.subtle.digest("SHA-256",new Uint8Array(r)).then(o=>Array.from(new Uint8Array(o)).map(i=>i.toString(16).padStart(2,"0")).join(""))}async function Ld(){await new Promise(e=>{let t=indexedDB.deleteDatabase("graffiti-inbox-cache");t.onsuccess=()=>e(),t.onerror=()=>e(),t.onblocked=()=>e()})}async function Zd(){if(await Ta()){let{openDB:n}=await import("./build-KAK33G4E.js"),r=await n("graffiti-inbox-cache",1,{upgrade(o){o.objectStoreNames.contains("m")||o.createObjectStore("m"),o.objectStoreNames.contains("q")||o.createObjectStore("q")}});return{messages:{get:async o=>{try{return r.get("m",o)}catch(i){console.error("Error getting message from cache:",i),console.error("resetting cache..."),await Ld();return}},set:async(o,i)=>{await r.put("m",i,o)},setMany:async o=>{if(o.length===0)return;let i=r.transaction("m","readwrite");await Promise.all([...o.map(([s,a])=>i.store.put(a,s)),i.done])},del:o=>r.delete("m",o)},messageIds:{get:async o=>{try{return await r.get("q",o)}catch(i){console.error("Error getting message IDs from cache:",i),console.error("resetting cache..."),await Ld();return}},set:async(o,i)=>{await r.put("q",i,o)},del:o=>r.delete("q",o)}}}let e=new Map,t=new Map;return{messages:{get:async n=>e.get(n),set:async(n,r)=>{e.set(n,r)},setMany:async n=>{for(let[r,o]of n)e.set(r,o)},del:async n=>{e.delete(n)}},messageIds:{get:async n=>t.get(n),set:async(n,r)=>{t.set(n,r)},del:async n=>{t.delete(n)}}}}var ob=3e4,ib=3e4,fi=class{getAuthorizationEndpoint=ci;cache_=null;get cache(){return this.cache_||(this.cache_=Zd()),this.cache_}async send(t,n){Ce(t);let r=`${t}/send`,i=await(await Xe(r,{method:"PUT",headers:{"Content-Type":"application/cbor"},body:new Uint8Array(pe({m:n}))})).blob(),s=Ne(await i.arrayBuffer());return Ud.parse(s).id}async get(t,n,r){let o=Fr(t,n),i=await this.cache,s=await i.messages.get(o);if(s!==void 0)return s;let a=`${t}/message/${n}`,c=null;try{c=await Xe(a,{method:"GET",headers:{...r?{Authorization:`Bearer ${r}`}:{}}})}catch(p){if(p instanceof Q)return await i.messages.set(o,null),null;throw p}let u=await c.blob(),l=Ne(await u.arrayBuffer()),f=li.parse(l);return await i.messages.set(o,f),f}async label(t,n,r,o){if(Ce(t),o){let c=`${t}/label/${n}`;await Xe(c,{method:"PUT",headers:{"Content-Type":"application/cbor",Authorization:`Bearer ${o}`},body:new Uint8Array(pe({l:r}))})}let i=await this.cache,s=Fr(t,n),a=await i.messages.get(s);a&&await i.messages.set(s,{...a,l:r})}async fetchMessageBatch(t,n,r,o,i,s){let a=AbortSignal.timeout(ob),c=await Xe(`${t}/${n}${i?`?cursor=${encodeURIComponent(i)}`:""}`,{method:"POST",headers:{"Content-Type":"application/cbor",...o?{Authorization:`Bearer ${o}`}:{}},body:r,signal:s?AbortSignal.any([s,a]):a}),u=c.headers.get("Retry-After"),l=u?parseInt(u):void 0,f=l&&Number.isFinite(l)?Date.now()+l*1e3:void 0;return{response:c,waitTil:f}}async withQueryLock(t,n,r,o){if(!n)return r();let i=AbortSignal.timeout(ib),s=!1;try{return await window.navigator.locks.request(`graffiti:inbox:${t}`,{mode:"exclusive",signal:o?AbortSignal.any([o,i]):i},async()=>(s=!0,r()))}catch(a){throw!s&&i.aborted?new Error("Timed out waiting for another tab's inbox query",{cause:a}):a}}async*messageStreamer(t){let{inboxUrl:n,inboxToken:r}=t,o=t.kind==="export"?"export":"query",i=t.kind==="query"?t.schema:t.kind==="continue"?t.cursor.objectSchema:{},s=await so(i),a=t.kind==="query"?t.body:void 0,c=t.kind==="continue"?t.cursor.messageIdsCacheKey:await jd(n,o,a),u=t.kind==="continue"?t.cursor.version:void 0,l=await this.cache,f=typeof window<"u"&&await Ta(),p=await l.messageIds.get(c),g=p?.generation,w=p?.version,x=t.kind==="continue"?t.cursor.numSeen:0,A=!0,h=async S=>{for(;;){S?.throwIfAborted();let b=await this.withQueryLock(c,f,async()=>{S?.throwIfAborted();let v=await l.messageIds.get(c);if(u!==void 0&&u!==v?.version)throw new Me("Cursor is stale");if(v?.version!==w){if(!A)throw new Me("Cursor is stale");x=0}if(v?.generation&&v.generation!==g)return{query:v};if(v?.waitTil!==void 0&&v.waitTil>Date.now())return{waitTil:v.waitTil};let O;try{O=await this.fetchMessageBatch(n,o,A?a:void 0,r,v?.cursor,S)}catch(E){if(!(E instanceof Me&&v?.cursor)){if(A&&!S?.aborted)return{initialFetchError:E};throw E}if(!A||(await l.messageIds.del(c),u!==void 0))throw E;v=void 0,x=0,O=await this.fetchMessageBatch(n,o,a,r,void 0,S)}let I=Ne(new Uint8Array(await O.response.arrayBuffer())),{results:z,hasMore:V,cursor:J}=Md.parse(I),m=z.map(E=>{let U=E[ft][Ze];if(!s(U))throw new Error("Server returned data that does not match schema");return{...E,[ft]:{...E[ft],[Ze]:U}}});return v=await Bd(l,n,c,v,{messages:m,cursor:J,hasMore:V,waitTil:O.waitTil}),{query:v}},S);if("initialFetchError"in b)throw console.error("Unexpected error in stream, waiting 5 seconds before continuing..."),await new Promise(v=>setTimeout(v,5e3)),b.initialFetchError;if("waitTil"in b){await ab(b.waitTil);continue}return b.query}},_;for(;;){let S=_?await _:await h().then(z=>({query:z}),z=>({error:z}));if(_=void 0,"error"in S)throw S.error;let b=S.query,v=await Nd(l,n,c,b,x);x=b.messageIds.length,g=b.generation,w=b.version,A=!1;let O=new AbortController;b.hasMore&&(_=h(O.signal).then(z=>({query:z}),z=>({error:z})));let I=!1;try{for(let z of v)yield z;I=!0}finally{I||O.abort()}if(!b.hasMore){let z={numSeen:x,version:b.version,messageIdsCacheKey:c,objectSchema:i};return JSON.stringify(z)}}}query(t,n,r,o){Ce(t);let i=new Uint8Array(pe({tags:n,schema:r}));return this.messageStreamer({kind:"query",inboxUrl:t,body:i,schema:r,inboxToken:o})}continueQuery(t,n,r){Ce(t);let o=JSON.parse(n),i=sb.parse(o);return this.messageStreamer({kind:"continue",inboxUrl:t,cursor:i,inboxToken:r})}export(t,n){return Ce(t),this.messageStreamer({kind:"export",inboxUrl:t,inboxToken:n})}},sb=ye({messageIdsCacheKey:B(),version:B(),numSeen:nn().check(Ut()),objectSchema:ct([we({}),rn()])});async function ab(e){if(e!==void 0){let t=e-Date.now();t>0&&await new Promise(n=>setTimeout(n,t))}}var Bn="base64url";var di=class{async encode(t,n){if(t!==Bn)throw new Error(`Unsupported string encoding method: ${t}`);return"u"+btoa(String.fromCodePoint(...n)).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=+$/,"")}async decode(t){if(!t.startsWith("u"))throw new Error(`Unsupported string encoding prefix: ${t[0]}`);t=t.slice(1);let n=t.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4!==0;)n+="=";return Uint8Array.from(atob(n),r=>r.charCodeAt(0))}};function Fd(){let t=(typeof globalThis=="object"?globalThis.crypto:null)?.subtle;if(typeof t=="object"&&t!=null)return t;throw new Error("crypto.subtle must be defined")}function Hd(e,t,n){let r=async o=>{Qn(o);let i=Fd();return new Uint8Array(await i.digest(e,o))};return r.webCryptoName=e,r.outputLen=n,r.blockLen=t,r.create=()=>{throw new Error("not implemented")},Object.freeze(r)}function cb(e){zu(e);let t=e.webCryptoName;if(typeof t!="string")throw new Error("non-web hash");return t}var Wt=Hd("SHA-256",64,32);var Gd=Hd("SHA-512",128,64),Ra=(()=>{let e=async(t,n,r)=>{let o=Fd();Qn(n,void 0,"key"),Qn(r,void 0,"message");let i=cb(t),s=Iu(r);try{let a=await o.importKey("raw",n,{name:"HMAC",hash:i},!1,["sign"]);return new Uint8Array(await o.sign("HMAC",a,s))}finally{$u(s)}};return e.create=(t,n)=>{throw new Error("not implemented")},e})();var pi="sha2-256",Hr=18,jn=32,hi=class{async register(t,n){if(t!==pi)throw new Error(`Unsupported content address method: ${t}`);let r=await Wt(n),o=new Uint8Array(2+r.length);return o[0]=Hr,o[1]=jn,o.set(r,2),o}async getMethod(t){if(t[0]===Hr&&t[1]===jn&&t.length===2+jn)return pi;throw new Error("Unrecognized content address format.")}};var Yd=Object.freeze,Zn=0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,yi=0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,mi=0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Oa=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,ka=0x6666666666666666666666666666666666666666666666666666666666666658n,gi=Zn-1n,ub=Yd({p:Zn,n:yi,h:8n,a:gi,d:mi,Gx:Oa,Gy:ka}),Gr=32,qd=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&e.BYTES_PER_ELEMENT===1,et=(e,t,n="")=>{if(qd(e)&&(t===void 0||e.length===t))return e;let r=qd(e),o=t!==void 0?` of length ${t}`:"",i=r?`length=${e.length}`:`type=${typeof e}`,s=(n?`"${n}" `:"")+"expected Uint8Array"+o+", got "+i;throw r?new RangeError(s):new TypeError(s)},Ia=(e,t="",n)=>Uint8Array.from(et(e,n,t)),Xd=(e,t)=>e.toString(16).padStart(t,"0"),Qd=e=>{let t="";for(let n of et(e))t+=Xd(n,2);return t},ep=e=>{let t="hex invalid";if(typeof e!="string")throw new TypeError(t);if(e.length%2||!/^[\da-f]*$/i.test(e))throw new RangeError(t);let n=new Uint8Array(e.length/2);for(let r=0,o=0;r<n.length;r++,o+=2){let i=e.charCodeAt(o),s=e.charCodeAt(o+1);n[r]=((i&15)+(i>>6)*9)*16+(s&15)+(s>>6)*9}return n},qr=(...e)=>{let t=0;for(let o of e)t+=et(o).length;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.length;return n};var Yt=(e,t,n,r="bad number: out of range")=>{if(typeof e!="bigint")throw new TypeError(r);if(t<=e&&e<n)return e;throw new RangeError(r)},Y=(e,t=Zn)=>(e%=t)>=0n?e:t+e,Jd=(1n<<255n)-1n,k=e=>{if(e<0n)throw new RangeError("negative coordinate");let t=(e>>255n)*19n+(e&Jd);return t=(t>>255n)*19n+(t&Jd),t%Zn},tp=e=>Y(e,yi),lb=(e,t)=>{if(e===0n)throw new Error("invert: expected non-zero number");if(t<=1n)throw new Error("invert: expected modulus > 1, got "+t);let n=Y(e,t),r=t,o=0n,i=1n;for(;n!==0n;){let a=r/n,c=r-n*a,u=o-i*a;r=n,n=c,o=i,i=u}if(r!==1n)throw new Error("invert: does not exist");return Y(o,t)},fb=e=>{let t=Ca[e];if(typeof t!="function")throw new Error("hashes."+e+" not set");return t};var za=async(e,...t)=>et(await fb(e)(qr(...t)),64,"digest");var Pa=e=>{if(e instanceof dt)return e;throw new TypeError("Point expected")},np=2n**256n,dt=class e{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,r,o){let i=np;this.X=Yt(t,0n,i),this.Y=Yt(n,0n,i),this.Z=Yt(r,1n,i),this.T=Yt(o,0n,i),Yd(this)}static CURVE(){return ub}static fromAffine(t){return new e(t.x,t.y,1n,k(t.x*t.y))}static fromBytes(t,n=!1){let r=Ia(t,"point",Gr),o=r[31];r[31]=o&-129;let i=$a(r);n||Yt(i,0n,Zn);let s=k(i*i),a=Y(s-1n),c=k(mi*s+1n),{isValid:u,value:l}=pb(a,c);if(!u)throw new Error("bad point: y not sqrt");let f=!!(o&128);if(!n&&l===0n&&f)throw new Error("bad point: x==0, isLastByteOdd");return f!==!!(l&1n)&&(l=Y(-l)),new e(l,i,1n,k(l*i))}static fromHex(t,n){return e.fromBytes(ep(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){let t=gi,n=mi,r=this;if(r.is0())throw new Error("bad point: ZERO");let{X:o,Y:i,Z:s,T:a}=r,c=k(o*o),u=k(i*i),l=k(s*s),f=k(l*l),p=k(c*t),g=k(l*(p+u)),w=Y(f+k(n*k(c*u)));if(g!==w)throw new Error("bad point: equation left != right (1)");let x=k(o*i),A=k(s*a);if(x!==A)throw new Error("bad point: equation left != right (2)");return this}equals(t){let{X:n,Y:r,Z:o}=this,{X:i,Y:s,Z:a}=Pa(t);return k(n*a)===k(i*o)&&k(r*a)===k(s*o)}is0(){return this.equals(Xt)}negate(){return new e(Y(-this.X),this.Y,this.Z,Y(-this.T))}double(){let{X:t,Y:n,Z:r}=this,o=gi,i=k(t*t),s=k(n*n),a=k(2n*r*r),c=k(o*i),u=Y(t+n),l=Y(k(u*u)-i-s),f=Y(c+s),p=Y(f-a),g=Y(c-s),w=k(l*p),x=k(f*g),A=k(l*g),h=k(p*f);return new e(w,x,h,A)}add(t){let{X:n,Y:r,Z:o,T:i}=this,{X:s,Y:a,Z:c,T:u}=Pa(t),l=gi,f=mi,p=k(n*s),g=k(r*a),w=k(k(i*f)*u),x=k(o*c),A=Y(k(Y(n+r)*Y(s+a))-p-g),h=Y(x-w),_=Y(x+w),S=Y(g-k(l*p)),b=k(A*h),v=k(_*S),O=k(A*S),I=k(h*_);return new e(b,v,I,O)}subtract(t){return this.add(Pa(t).negate())}multiply(t,n=!0){if(!n&&t===0n||(Yt(t,1n,yi),!n&&this.is0()))return Xt;if(t===1n)return this;if(this.equals(Tt))return bb(t).p;let r=Xt,o=Tt,i=this;for(let s=0;n?s<256:t>0n;s++)t&1n?r=r.add(i):n&&(o=o.add(i)),i=i.double(),t>>=1n;return r}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){let{X:t,Y:n,Z:r}=this;if(this.equals(Xt))return{x:0n,y:1n};let o=lb(r,Zn);if(k(r*o)!==1n)throw new Error("invalid inverse");return{x:k(t*o),y:k(n*o)}}toBytes(){let{x:t,y:n}=this.toAffine(),r=rp(n);return r[31]|=t&1n?128:0,r}toHex(){return Qd(this.toBytes())}clearCofactor(){return this.multiply(8n,!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return this.multiply(yi/2n,!1).double().add(this).is0()}},Tt=new dt(Oa,ka,1n,Y(Oa*ka)),Xt=new dt(0n,1n,1n,0n);dt.BASE=Tt;dt.ZERO=Xt;var rp=e=>ep(Xd(Yt(e,0n,np),64)).reverse(),$a=e=>BigInt("0x"+Qd(Uint8Array.from(et(e)).reverse())),Qe=(e,t)=>{let n=e;for(;t-- >0;)n=k(n*n);return n},db=e=>{let t=k(e*e),n=k(t*e),r=k(Qe(n,2)*n),o=k(Qe(r,1)*e),i=k(Qe(o,5)*o),s=k(Qe(i,10)*i),a=k(Qe(s,20)*s),c=k(Qe(a,40)*a),u=k(Qe(c,80)*c),l=k(Qe(u,80)*c),f=k(Qe(l,10)*i);return k(Qe(f,2)*e)},Kd=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,pb=(e,t)=>{let n=k(t*k(t*t)),r=k(k(n*n)*t),o=db(k(e*r)),i=k(e*k(n*o)),s=k(t*k(i*i)),a=i,c=k(i*Kd),u=s===e,l=s===Y(-e),f=s===Y(-e*Kd);return u&&(i=a),(l||f)&&(i=c),(Y(i)&1n)===1n&&(i=Y(-i)),{isValid:u||l,value:i}},wi=e=>tp($a(e)),hb=e=>{let t=Ia(e),n=t.slice(0,32);n[0]&=248,n[31]&=127,n[31]|=64;let r=t.slice(32),o=wi(n),i=Tt.multiply(o),s=i.toBytes();return{head:n,prefix:r,scalar:o,point:i,pointBytes:s}},op=e=>za("sha512Async",et(e,Gr,"secretKey")).then(hb);var ip=e=>op(e).then(t=>t.pointBytes);var sp=async e=>e[1](await za("sha512Async",e[0]));var mb=(e,t,n)=>{let{pointBytes:r,scalar:o}=e,i=wi(t),s=Tt.multiply(i).toBytes();return[qr(s,r,n),u=>{let l=tp(i+wi(u)*o);return et(qr(s,rp(l)),64)}]},ap=async(e,t)=>{let n=Ia(e,"message"),r=await op(t);return sp(mb(r,await za("sha512Async",r.prefix,n),n))};var gb=e=>{if(e===null||typeof e!="object")throw new TypeError("expected valid options object");return e.zip215??!0},yb=(e,t,n,r)=>{e=et(e,64,"signature"),t=et(t,void 0,"message"),n=et(n,Gr,"publicKey");let o=gb(r),i=e.subarray(0,Gr),s=$a(e.subarray(Gr,64)),a,c,u,l=Uint8Array.of(),f=!1;try{a=dt.fromBytes(n,o),c=dt.fromBytes(i,o),u=Tt.multiply(s,!1),l=qr(i,n,t),f=!0}catch{}return[l,g=>{if(!f||!o&&a.isSmallOrder())return!1;let w=wi(g);return c.add(a.multiply(w,!1)).subtract(u).clearCofactor().is0()}]},cp=async(e,t,n,r={})=>sp(yb(e,t,n,r));var Ca={sha512Async:async e=>{let t=globalThis?.crypto?.subtle;if(!t)throw new Error("crypto.subtle must be defined, consider polyfill");return new Uint8Array(await t.digest("SHA-512",qr(e)))},sha512:void 0};var wb=()=>{let e=[],t=Tt,n;for(let r=0;r<33;r++){n=t,e.push(n);for(let o=1;o<128;o++)n=n.add(t),e.push(n);t=n.double()}return e},Vd,Wd=(e,t)=>{let n=t.negate();return e?n:t},bb=e=>{let t=Vd||(Vd=wb()),n=Xt,r=Tt;for(let o=0;o<33;o++){let i=Number(e&255n);e>>=8n,i>128&&(i-=256,e+=1n);let s=o*128,a=s+Math.abs(i)-1,c=o%2!==0,u=i<0;i===0?r=r.add(Wd(c,t[s])):n=n.add(Wd(u,t[a]))}if(e!==0n)throw new Error("invalid wnaf");return{p:n,f:r}};Ca.sha512Async=Gd;var Qt="pk:sha2-256+ed25519",Da=0,bi=class{async register(t,n){if(t!==Qt)throw new Error(`Unsupported channel attestation method: ${t}`);let r=await this.channelToPrivateKey(n);return await this.channelPublicIdFromPrivateKey(r)}async getMethod(t){if(t[0]===Da)return Qt;throw new Error("Unrecognized channel attestation method.")}async channelToPrivateKey(t){let n=new TextEncoder().encode(t);return await Wt(n)}async channelPublicIdFromPrivateKey(t){let n=await ip(t),r=new Uint8Array(n.length+1);return r[0]=Da,r.set(n,1),r}async attest(t,n,r){if(t!==Qt)throw new Error(`Unsupported channel attestation method: ${t}`);let o=await this.channelToPrivateKey(r),i=await this.channelPublicIdFromPrivateKey(o),s=new TextEncoder().encode(n);return{attestation:await ap(s,o),channelPublicId:i}}async validate(t,n,r){let o=r[0];if(o!==Da)throw new Error(`Unrecognized channel attestation method prefix: ${o}`);return await cp(t,new TextEncoder().encode(n),r.slice(1))}};var Ua="hmac:sha2-256",up=0,_i=class{async attest(t,n){if(t!==Ua)throw new Error(`Unsupported allowed attestation method: ${t}`);let r=Lt(),o=await Ra(Wt,r,new TextEncoder().encode(n)),i=new Uint8Array(r.length+3);return i[0]=up,i[1]=Hr,i[2]=jn,i.set(r,3),{attestation:o,ticket:i}}async validate(t,n,r){let o=r[0],i=r[1],s=r[2];if(o!==up||i!==Hr||s!==jn)throw new Error("Unrecognized allowed ticket format");let a=await Ra(Wt,r.slice(3),new TextEncoder().encode(n));return t.length!==a.length?!1:a.every((c,u)=>t[u]===c)}};var Ma="did:web:",xi=class{constructor(t){this.services=t}services;actorToHandle=async t=>{let r=(await this.services.dids.resolve(t)).alsoKnownAs?.find(s=>s.startsWith(Ma));if(!r)throw new Q(`Handle for actor DID ${t} not found`);let o=r.slice(Ma.length),i=await this.services.dids.resolve(r);if(!i.alsoKnownAs||!i.alsoKnownAs.includes(t))throw new Error(`Handle ${o} does not match actor ${t}`);return o};handleToActor=async t=>{let n=`${Ma}${t}`,o=(await this.services.dids.resolve(n)).alsoKnownAs?.at(0);if(!o)throw new Q(`Actor for handle DID ${n} not found`);let i=await this.services.dids.resolve(o);if(!i.alsoKnownAs||!i.alsoKnownAs.includes(n))throw new Error(`Actor ${o} does not match handle ${t}`);return o}};function Ei(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)r!=="__proto__"&&(e[r]=n[r])}return e}var _b={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function La(e,t){function n(o,i,s){if(!(typeof document>"u")){s=Ei({},t,s),typeof s.expires=="number"&&(s.expires=new Date(Date.now()+s.expires*864e5)),s.expires&&(s.expires=s.expires.toUTCString()),o=encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var c in s)s[c]&&(a+="; "+c,s[c]!==!0&&(a+="="+s[c].split(";")[0]));return document.cookie=o+"="+e.write(i,o)+a}}function r(o){if(!(typeof document>"u"||arguments.length&&!o)){for(var i=document.cookie?document.cookie.split("; "):[],s={},a=0;a<i.length;a++){var c=i[a].split("="),u=c.slice(1).join("=");try{var l=decodeURIComponent(c[0]);if(l in s||(s[l]=e.read(u,l)),o===l)break}catch{}}return o?s[o]:s}}return Object.create({set:n,get:r,remove:function(o,i){n(o,"",Ei({},i,{expires:-1}))},withAttributes:function(o){return La(this.converter,Ei({},this.attributes,o))},withConverter:function(o){return La(Ei({},this.converter,o),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var Si=La(_b,{path:"/"});var xb=365;function lp(e,t){Si.set(e,t,dp())}function fp(e){return Si.get(e)}function Na(e){Si.remove(e,dp())}function dp(){let e={expires:xb,path:"/",sameSite:"lax"};return typeof window<"u"&&window.location.protocol==="https:"&&(e.sameSite="none",e.secure=!0),e}var Ri="GraffitiInbox",Oi="GraffitiStorageBucket",Fa="#graffitiPersonalInbox",ki="#graffitiStorageBucket",Eb="#graffitiSharedInbox_",Pi=class{constructor(t){this.services=t;let n=new Promise(o=>{this.services.authorization.eventTarget.addEventListener("initialized",i=>{if(!(i instanceof CustomEvent))return;let s=zd.safeParse(i.detail);if(!s.success)return;let a=s.data?.error;a&&console.error(a),o()})});this.services.authorization.eventTarget.addEventListener("login",this.onLogin.bind(this)),this.services.authorization.eventTarget.addEventListener("logout",this.onLogout.bind(this));let r;if(typeof window<"u"){let o=new URLSearchParams(window.location.search).get("actor");if(o)try{let i=decodeURIComponent(o),s=new URL(window.location.toString());s.searchParams.delete("actor"),window.history.replaceState({},"",s.toString()),r=this.login(i,"replace")}catch(i){console.error("Error decoding actor:",i)}}(async()=>{await new Promise(i=>setTimeout(i,0)),await r;for(let i of this.loggedInSessions){let s=new CustomEvent("login",{detail:{session:{actor:i.actor}}});this.sessionEvents.dispatchEvent(s)}await n;let o=new CustomEvent("initialized");this.sessionEvents.dispatchEvent(o)})()}services;sessionEvents=new EventTarget;initialAuthorizationNavigation="assign";inProgressLogin=void 0;inProgressLogout=void 0;async login(t,n=this.initialAuthorizationNavigation){try{await this.login_(t,n)}catch(r){let o=new CustomEvent("login",{detail:{error:r instanceof Error?r:new Error(String(r)),session:{actor:t}}});this.sessionEvents.dispatchEvent(o)}}async login_(t,n){if(this.loggedInSessions.find(b=>b.actor===t)){this.sessionEvents.dispatchEvent(new CustomEvent("login",{detail:{session:{actor:t}}}));return}let i=(await this.services.dids.resolve(t)).service;if(!i)throw new Error(`No services found in actor document for ${t}`);let s=i.find(b=>b.id===ki&&b.type===Oi),a=i.find(b=>b.id===Fa&&b.type===Ri),c=i.filter(b=>b.id.match(new RegExp(`^${Eb}\\d+$`))&&b.type===Ri);if(!a||!s||c.length===0)throw new Error(`Required services not found in actor document for ${t}`);let u=ja(s),l=ja(a),f=c.map(ja),p=[{endpoint:u,type:"bucket"},{endpoint:l,type:"personal-inbox"},...f.map(b=>({endpoint:b,type:"shared-inbox"}))],g=await Promise.all(p.map(async({endpoint:b,type:v})=>{let O=await(v==="bucket"?this.services.storageBuckets.getAuthorizationEndpoint(b):this.services.inboxes.getAuthorizationEndpoint(b));return{endpoint:b,authorizationEndpoint:O,type:v}})),w=new Map;g.forEach(({authorizationEndpoint:b,endpoint:v,type:O})=>{w.has(b)||w.set(b,[]),w.get(b).push({endpoint:v,type:O})});let x=[...w.entries()],h={...{actor:t},tokens:[],servicesByAuthorization:x};typeof window<"u"?window.localStorage.setItem(vi,JSON.stringify(h)):this.inProgressLogin=h;let[_,S]=x[0];await this.services.authorization.login(_,t,S.map(b=>b.endpoint),n)}async onLogin(t){if(!(t instanceof CustomEvent))return;let n=kd.safeParse(t.detail);if(!n.success)return;let r=n.data.loginId;try{await this.onLogin_(n.data)}catch(o){let i=new CustomEvent("login",{detail:{error:o instanceof Error?o:new Error(String(o)),session:{actor:r}}});this.sessionEvents.dispatchEvent(i)}}async onLogin_(t){if(t.error)throw t.error;let n=t.token,r=t.loginId,o;if(typeof window<"u"){let i=window.localStorage.getItem(vi);if(!i)throw new Error("No in-progress login found");let s=JSON.parse(i);o=Za.parse(s)}else{if(!this.inProgressLogin)throw new Error("No in-progress login found");o=this.inProgressLogin}if(o.actor!==r)throw new Error("Actor mismatch in login response - concurrent logins?");if(o.tokens.push(n),o.tokens.length===o.servicesByAuthorization.length){typeof window>"u"?this.inProgressLogin=void 0:window.localStorage.removeItem(vi);let i=o.servicesByAuthorization.flatMap(([u,l],f)=>l.map(p=>({token:o.tokens[f],serviceEndpoint:p.endpoint,authorizationEndpoint:u,type:p.type}))),s={...o,storageBucket:i.find(u=>u.type==="bucket"),personalInbox:i.find(u=>u.type==="personal-inbox"),sharedInboxes:i.filter(u=>u.type==="shared-inbox")},a=this.loggedInSessions;a.push(s),this.loggedInSessions=a;let c=new CustomEvent("login",{detail:{session:{actor:r}}});this.sessionEvents.dispatchEvent(c)}else{typeof window<"u"?window.localStorage.setItem(vi,JSON.stringify(o)):this.inProgressLogin=o;let[i,s]=o.servicesByAuthorization[o.tokens.length];await this.services.authorization.login(i,r,s.map(a=>a.endpoint),"replace")}}async logout(t){try{await this.logout_(t)}catch(n){let r=new CustomEvent("logout",{detail:{error:n instanceof Vt?void 0:n instanceof Error?n:new Error(String(n)),actor:t}});this.sessionEvents.dispatchEvent(r)}}async logout_(t){let n=this.loggedInSessions.find(s=>s.actor===t);if(!n)throw new Error(`No session found for actor ${t}`);this.loggedInSessions=this.loggedInSessions.filter(s=>s.actor!==t);let r=n.tokens.pop();if(!r)throw new Error("No tokens found in session");typeof window<"u"?window.localStorage.setItem(Ai,JSON.stringify(n)):this.inProgressLogout=n;let[o,i]=n.servicesByAuthorization[n.tokens.length];await this.services.authorization.logout(o,t,r)}async onLogout(t){if(!(t instanceof CustomEvent))return;let n=Id.safeParse(t.detail);if(!n.success)return;let r=n.data.logoutId;try{await this.onLogout_(n.data)}catch(o){let i=new CustomEvent("logout",{detail:{error:o instanceof Error?o:new Error(String(o)),actor:r}});this.sessionEvents.dispatchEvent(i)}}async onLogout_(t){if(t.error)throw t.error;let n=t.logoutId,r;if(typeof window<"u"){let i=window.localStorage.getItem(Ai);if(!i)throw new Error("No in-progress logout found");let s=JSON.parse(i);r=Za.parse(s)}else{if(!this.inProgressLogout)throw new Error("No in-progress logout found");r=this.inProgressLogout}if(r.actor!==n)throw new Error("Actor mismatch in logout response - concurrent logouts?");let o=r.tokens.pop();if(o){typeof window<"u"?window.localStorage.setItem(Ai,JSON.stringify(r)):this.inProgressLogout=r;let[i,s]=r.servicesByAuthorization[r.tokens.length];await this.services.authorization.logout(i,n,o)}else{typeof window>"u"?this.inProgressLogout=void 0:window.localStorage.removeItem(Ai);let i=new CustomEvent("logout",{detail:{actor:n}});this.sessionEvents.dispatchEvent(i)}}get loggedInSessions(){if(typeof window>"u")return pp;let t=fp(Ti);if(!t)return[];let n;try{n=JSON.parse(t)}catch{return console.error("Error parsing stored session data"),Na(Ti),[]}let r=q(Ab).safeParse(n);return r.success?r.data:(console.error("Stored session data is invalid"),Na(Ti),[])}set loggedInSessions(t){if(typeof window>"u"){pp=t;return}lp(Ti,JSON.stringify(t))}resolveSession(t){let n=this.loggedInSessions.find(r=>r.actor===t.actor);if(!n){let r=new CustomEvent("logout",{detail:{actor:t.actor}});throw this.sessionEvents.dispatchEvent(r),new Error("Not logged in")}return n}},pp=[],vi="graffiti-login-in-progress",Ai="graffiti-logout-in-progress",Ti="graffiti-sessions-logged-in",Sb=Se({actor:Z()}),Ba=Se({token:B(),serviceEndpoint:Z(),authorizationEndpoint:Z()}),vb=q(me([Z(),q(Se({endpoint:Z(),type:vu(["bucket","personal-inbox","shared-inbox"])}))])),Za=at(Sb,{tokens:q(B()),servicesByAuthorization:vb}),Ab=at(Za,{storageBucket:Ba,personalInbox:Ba,sharedInboxes:q(Ba)});function ja(e){if(typeof e.serviceEndpoint=="string")return e.serviceEndpoint;throw new Error(`Service endpoint for ${e.id} is not a string`)}var Ii=32*1024,zi=class{constructor(t){this.primitives=t}primitives;async encode(t,n){t=Va(t);let r=[...new Set(t.channels)],o=await Promise.all(r.map(x=>this.primitives.channelAttestations.attest(Qt,n,x))),i=o.map(x=>x.attestation),s=o.map(x=>x.channelPublicId),a={[Ga]:t.value,[qa]:i,[gp]:Lt(32)},c;if(Array.isArray(t.allowed)){let x=await Promise.all(t.allowed.map(async A=>this.primitives.allowedAttestations.attest(Ua,A)));a[Ja]=x.map(A=>A.attestation),c=x.map(A=>A.ticket)}let u=pe(a);if(u.byteLength>Ii)throw new Error("The object is too large");let l=await this.primitives.contentAddresses.register(pi,u),f=await this.primitives.stringEncoder.encode(Bn,l),p=Rb(n,f),g=[new TextEncoder().encode(p),...s];return{object:{value:t.value,channels:r,url:p,actor:n,...t.allowed?{allowed:t.allowed}:{}},tags:g,objectBytes:u,allowedTickets:c}}async validate(t,n,r,o){if(r.byteLength>Ii)throw new Error("Object is too big");let{actor:i,contentAddress:s}=Wa(t.url);if(i!==t.actor)throw new Error("Object actor does not match URL actor");let a=n.at(0);if(!a)throw new Error("No object URL tag");if(new TextDecoder().decode(a)!==t.url)throw new Error("Object URL tag does not match object URL");let c=n.slice(1),u=await this.primitives.stringEncoder.decode(s),l=await this.primitives.contentAddresses.getMethod(u),f=await this.primitives.contentAddresses.register(l,r);if(f.length!==u.length||!f.every((S,b)=>S===u[b]))throw new Error("Content address is invalid");let p=Ne(r),g=Tb.parse(p),w=g[Ga],x=g[qa],A=g[Ja],h=pe(w),_=pe(t.value);if(h.length!==_.length||!h.every((S,b)=>S===_[b]))throw new Error("Object value does not match storage value");if(x.length!==c.length)throw new Error("Not as many channel attestations and public ids");for(let[S,b]of x.entries()){let v=c[S];if(!await this.primitives.channelAttestations.validate(b,i,v))throw new Error("Invalid channel attestation")}if(t.channels.length){if(t.channels.length!==c.length)throw new Error("Number of claimed channels does not match attestations/public IDs");let S=await this.primitives.channelAttestations.getMethod(c[0]),b=await Promise.all(t.channels.map(v=>this.primitives.channelAttestations.register(S,v)));for(let[v,O]of b.entries()){let I=c[v];if(O.length!==I.length||!O.every((z,V)=>z===I[V]))throw new Error("Channel public id does not match expected")}}if(o){if(!A)throw new Error("Object is public but thought to be private");let S,b,v;if("recipient"in o?(S=[o.recipient],b=[o.allowedTicket],v=A.filter((O,I)=>I===o.allowedIndex)):(S=[...t.allowed??[]],b=o.allowedTickets,v=A),S.length!==t.allowed?.length)throw new Error("Recipient count does not match object allowed list");if(!S.every(O=>t.allowed?.includes(O)))throw new Error("Recipient not in object allowed list");for(let[O,I]of S.entries()){let z=b.at(O),V=v.at(O);if(!z)throw new Error("Missing allowed ticket for recipient");if(!V)throw new Error("Missing allowed attestation for recipient");if(!await this.primitives.allowedAttestations.validate(V,I,z))throw new Error("Invalid allowed attestation for recipient")}}else if(A)throw new Error("Object is private but no recipient info provided")}},Ga="v",qa="c",Ja="a",gp="n",Ha=Mt(e=>e instanceof Uint8Array),Tb=ye({[Ga]:we({}),[qa]:q(Ha),[Ja]:X(q(Ha)),[gp]:Ha}),Ka="graffiti:";function hp(e){let t=e.replace(/:/g,"!").replace(/\//g,"~");return encodeURIComponent(t)}function mp(e){return decodeURIComponent(e).replace(/!/g,":").replace(/~/g,"/")}function Rb(e,t){return`${Ka}${hp(e)}:${hp(t)}`}function Wa(e){if(!e.startsWith(Ka))throw new Error("Invalid object URL");let n=e.slice(Ka.length).split(":");if(n.length!==2)throw new Error("Invalid object URL format");let[r,o]=n;return{actor:mp(r),contentAddress:mp(o)}}function Va(e){return e===void 0?null:Array.isArray(e)?e.map(Va):typeof e=="object"?Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0).map(([t,n])=>[t,Va(n)])):e}var yp=class{dialog=document.createElement("dialog");shadow;main_;useTemplateHTML;templates_;onManualClose;displayTemplateSeq=0;constructor(e){this.useTemplateHTML=e.useTemplateHTML,this.onManualClose=e.onManualClose,this.dialog.className="graffiti-modal",this.dialog.addEventListener("click",n=>{if("pointerType"in n&&!n.pointerType)return;let r=this.dialog.getBoundingClientRect();(r.top>n.clientY||r.left>n.clientX||n.clientY>r.top+r.height||n.clientX>r.left+r.width)&&(this.close(),this.onManualClose?.())});let t=document.createElement("div");this.shadow=t.attachShadow({mode:"closed"}),this.shadow.appendChild(this.dialog),document.body.append(t)}get templates(){return this.templates_||(this.main_,this.templates_=new Promise(async e=>e(await this.useTemplateHTML())).then(e=>{let t=new DOMParser().parseFromString(e,"text/html"),n=new Map;return t.querySelectorAll("template").forEach(r=>{let o=r.id;o&&n.set(o,r)}),n})),this.templates_}get main(){return this.main_||(this.templates_,this.main_=Promise.all([import("./style-BOBMBTYJ-2YZTO5FX.js"),import("./graffiti-KV3G3O72-QD3APAKT.js"),import("./rock-salt-LI7DAH66-M6W5PPFD.js")]).then(async([{default:e},{default:t},{default:n}])=>{let r=document.createElement("header"),o=document.createElement("button");o.className="secondary",o.textContent="Close",o?.addEventListener("click",()=>{this.close(),this.onManualClose?.()}),r.appendChild(o);let i=document.createElement("main");this.dialog.appendChild(r),this.dialog.appendChild(i);let s=new FontFace("Rock Salt",`url(${n})`,{style:"normal",weight:"400"});document.fonts.add(s),await s.load(),e=e.replace("url(graffiti.jpg)",`url(${t})`);let a=new CSSStyleSheet;return a.replace(e).then(()=>{this.shadow.adoptedStyleSheets=[a]}),i})),this.main_}async open(){await this.main,this.dialog.showModal(),this.dialog.focus()}close(){this.dialog.close()}async displayTemplate(e){let t=++this.displayTemplateSeq,n=()=>{if(t!==this.displayTemplateSeq)throw new Error(`displayTemplate(${e}) overridden by concurrent call`)},r=await this.main;n();let o=(await this.templates).get(e);if(n(),!o)throw new Error(`Template not found: ${e}`);let i=o.content.cloneNode(!0);return r.replaceChildren(i),r}};var _p=Mt(e=>e instanceof Uint8Array),Qa="k",Fn="t",nc=ye({[Qa]:B(),[Fn]:X(B())}),en="id",ec="e",Jr="a",Pb=q(ye({[en]:B(),[ec]:X(Z()),[Jr]:X(Z())})),$i="s",Ci="n",Ob=at(nc,{[$i]:X(q(_p)),[Ci]:Pb}),Kr="a",tc="i",kb=at(nc,{[Kr]:_p,[tc]:nn().check(Ut())}),Ib=ct([nc,Ob,kb]),zb=0,Ya=1,Rt=2,Xa=3,$b=128,wp="graffiti-login-remembered-handle",Di=class{dids=new Go;authorization=new ai;storageBuckets=new ui;inboxes=new fi;stringEncoder=new di;contentAddresses=new hi;channelAttestations=new bi;allowedAttestations=new _i;sessions=new Pi({dids:this.dids,authorization:this.authorization,storageBuckets:this.storageBuckets,inboxes:this.inboxes});handles=new xi({dids:this.dids});objectEncoding=new zi({stringEncoder:this.stringEncoder,contentAddresses:this.contentAddresses,channelAttestations:this.channelAttestations,allowedAttestations:this.allowedAttestations});modal=typeof window>"u"?void 0:new yp({useTemplateHTML:()=>import("./login-dialog.html-WIDO3XZF.js").then(({template:t})=>t),onManualClose:()=>{let t=new CustomEvent("login",{detail:{error:new Error("User cancelled login"),manual:!0}});this.sessionEvents.dispatchEvent(t)}});defaultInboxEndpoints;identityCreatorEndpoint;constructor(t){t?.replaceInitialLoginHistoryEntry&&(this.sessions.initialAuthorizationNavigation="replace"),this.defaultInboxEndpoints=t?.defaultInboxEndpoints??["https://graffiti.actor/i/shared"],this.identityCreatorEndpoint=t?.identityCreatorEndpoint??"https://graffiti.actor/create",this.sessionEvents.addEventListener("login",async n=>{if(!(n instanceof CustomEvent))return;let r=n.detail;if(r.error!==void 0){if("manual"in r&&r.manual)return;alert("Login failed: "+r.error.message);let s=r.session?.actor,a;if(s)try{a=await this.actorToHandle(s)}catch(c){console.error("Failed to handle actor:",c)}this.login_(a);return}let o=r.session.actor,i;try{i=await this.actorToHandle(o)}catch(s){console.error("Failed to load handle from actor:",s)}i&&this.rememberHandleInBrowserStorage(i)});for(let n of["post","get","delete","postMedia","getMedia","deleteMedia"]){let r=this[n];this[n]=async(...o)=>{try{return await r(...o)}catch(i){let s=o[o.length-1];throw await this.tryLogoutIfUnauthorized(i,s),i}}}}actorToHandle=this.handles.actorToHandle.bind(this.handles);handleToActor=this.handles.handleToActor.bind(this.handles);sessionEvents=this.sessions.sessionEvents;login=async t=>{try{let n;try{n=t?await this.actorToHandle(t):void 0}catch(r){console.error("Error fetching handle for actor:",r)}await this.login_(n)}catch(n){let r=new CustomEvent("login",{detail:{error:n instanceof Error?n:new Error(String(n))}});this.sessionEvents.dispatchEvent(r)}};async login_(t){if(typeof window<"u"){let n;if(t!==void 0){n=await this.modal?.displayTemplate("graffiti-login-handle");let o=n?.querySelector("#username"),i=t||this.getRememberedHandleFromBrowserStorage();o&&(o.value=i??""),o?.addEventListener("focus",()=>o?.select()),setTimeout(()=>o?.focus(),0),n?.querySelector("#graffiti-login-handle-form")?.addEventListener("submit",async s=>{s.preventDefault(),o?.setAttribute("disabled","true");let a=n?.querySelector("#graffiti-login-handle-submit");if(a?.setAttribute("disabled","true"),a&&(a.innerHTML="Logging in..."),!o?.value){alert("No handle provided"),this.login_("");return}let c=o.value;if(!c.includes(".")&&!c.startsWith("localhost")){let l=new URL(this.identityCreatorEndpoint).host;c=`${c}.${l}`}let u;try{u=await this.handleToActor(c)}catch{alert("Could not find an identity associated with that handle."),this.login_(c);return}try{await this.sessions.login(u)}catch(l){alert("Error logging in."),console.error(l),this.login_(c)}}),n?.querySelector("#graffiti-login-forgot")?.addEventListener("click",s=>{s.preventDefault(),this.loginWithoutHandle()})}else n=await this.modal?.displayTemplate("graffiti-login-welcome"),n?.querySelector("#graffiti-login-existing")?.addEventListener("click",o=>{o.preventDefault(),this.login_("")}),setTimeout(()=>n?.querySelector("#graffiti-login-new")?.focus(),0);let r=new URL(this.identityCreatorEndpoint);r.searchParams.set("redirect_uri",encodeURIComponent(window.location.toString())),n?.querySelector("#graffiti-login-new")?.setAttribute("href",r.toString()),await this.modal?.open()}else{let n=await import("readline").catch(s=>{throw new Error("Unrecognized environment: neither window nor readline")});console.log("If you do not already have a Graffiti handle, you can create one here:"),console.log(this.identityCreatorEndpoint);let r=n.createInterface({input:process.stdin,output:process.stdout}),o=await new Promise(s=>{r.question(`Please enter your handle${t?` (default: ${t})`:""}: `,a=>{r.close(),s(a||t)})});if(!o)throw new Error("No handle provided");let i=await this.handleToActor(o);await this.sessions.login(i)}}async loginWithoutHandle(){let t=await this.modal?.displayTemplate("graffiti-login-provider"),n=new URL("/",this.identityCreatorEndpoint),r=t?.querySelector("#graffiti-provider");r&&(r.value=n.host),r?.addEventListener("focus",()=>r.select()),setTimeout(()=>r?.focus(),0),t?.querySelector("#graffiti-login-provider-form")?.addEventListener("submit",o=>{o.preventDefault();try{let i=r?.value.trim()??"",s=i===n.host?n:new URL(`https://${i}`);if(!s.hostname||s.username||s.password||s.pathname!=="/"||s.search||s.hash)throw new Error("Invalid provider domain");let a=new URL("/forgot-handle",s);a.searchParams.set("redirect_uri",window.location.toString()),window.location.assign(a.toString())}catch{alert("Enter a valid provider domain.")}}),t?.querySelector("#graffiti-login-provider-back")?.addEventListener("click",o=>{o.preventDefault(),this.login_("")}),await this.modal?.open()}rememberHandleInBrowserStorage(t){if(!(typeof window>"u"))try{window.localStorage.setItem(wp,t)}catch(n){console.error("Failed to remember handle in browser storage:",n)}}getRememberedHandleFromBrowserStorage(){if(!(typeof window>"u"))try{return window.localStorage.getItem(wp)??void 0}catch(t){console.error("Failed to load handle from browser storage:",t);return}}logout=async t=>{await this.sessions.logout(t.actor)};post=async(...t)=>{let[n,r]=t,o=this.sessions.resolveSession(r),{object:i,tags:s,objectBytes:a,allowedTickets:c}=await this.objectEncoding.encode(n,r.actor),u=Lt(),l=await this.stringEncoder.encode(Bn,u);return await this.storageBuckets.put(o.storageBucket.serviceEndpoint,l,a,o.storageBucket.token),await this.announceObject(i,s,c,l,r),i};get=async(...t)=>{let[n,r,o]=t,i,s=await so(r);if(o){let u=this.sessions.resolveSession(o);i=[u.personalInbox,...u.sharedInboxes]}else i=this.defaultInboxEndpoints.map(u=>({serviceEndpoint:u}));let a=ns(n),c=[new TextEncoder().encode(a)];for(let u of i){let l,f=this.querySingleEndpoint(u.serviceEndpoint,{tags:c,objectSchema:{}},u.token,o?.actor);for await(let p of f)p.object.url===a&&(p.tombstone?l=void 0:l=p.object);if(l){if(!s(l))throw new oo("Object exists but does not match the supplied schema");return l}}throw new Q("Object not found")};delete=async(t,n)=>{let r=this.sessions.resolveSession(n),o=ns(t),{actor:i}=Wa(o);if(i!==n.actor)throw new mt("Cannot delete someone else's actor");let s=this.querySingleEndpoint(r.personalInbox.serviceEndpoint,{tags:[new TextEncoder().encode(o)],objectSchema:{}},r.personalInbox.token),a;for await(let w of s)w.object.url===o&&(w.tombstone?a=void 0:a=w);if(!a)throw new Q(`Object ${o} not found`);let{object:c,storageBucketKey:u,tags:l,allowedTickets:f,announcements:p,messageId:g}=a;return await this.storageBuckets.delete(r.storageBucket.serviceEndpoint,u,r.storageBucket.token),await this.announceObject(c,l,f,u,n,[...p??[],{[Jr]:n.actor,[en]:g}]),c};postMedia=async(...t)=>{let[n,r]=t,o=n.data.type,i=this.sessions.resolveSession(r),s=Lt(),a=await this.stringEncoder.encode(Bn,s);await this.storageBuckets.put(i.storageBucket.serviceEndpoint,a,new Uint8Array(await n.data.arrayBuffer()),i.storageBucket.token);let{url:c}=await this.post({value:{key:a,type:o,size:n.data.size},channels:[],allowed:n.allowed},r);return c};getMedia=async(...t)=>{let[n,r,o]=t;if(r?.maxBytes!==void 0&&(!Number.isSafeInteger(r.maxBytes)||r.maxBytes<0))throw new TypeError("maxBytes must be a nonnegative safe integer");let i=await this.get(n,Cb,o),{key:s,type:a,size:c}=i.value;if(r?.maxBytes!==void 0&&c>r.maxBytes)throw new gt("File size exceeds limit");if(r?.types&&!Ou(a,r.types))throw new io(`Unacceptable media type, ${a}`);let l=(await this.dids.resolve(i.actor))?.service?.find(w=>w.id===ki&&w.type===Oi);if(!l)throw new Q(`Actor ${i.actor} has no storage bucket service`);if(typeof l.serviceEndpoint!="string")throw new Q(`Actor ${i.actor} does not have a valid storage bucket endpoint`);let f=l.serviceEndpoint,p=await this.storageBuckets.get(f,s,c);return{data:new Blob([p.slice()],{type:a}),actor:i.actor,allowed:i.allowed}};deleteMedia=async(...t)=>{let[n,r]=t,o=this.sessions.resolveSession(r),i=await this.delete(n,r);if(!("key"in i.value&&typeof i.value.key=="string"))throw new Error("Deleted object was not media: "+JSON.stringify(i,null,2));await this.storageBuckets.delete(o.storageBucket.serviceEndpoint,i.value.key,o.storageBucket.token)};async*discoverMeta(t,n,r,o){let i=new Map,s;if(o){let f=this.sessions.resolveSession(o);s=[f.personalInbox,...f.sharedInboxes]}else s=this.defaultInboxEndpoints.map(f=>({serviceEndpoint:f}));for(let f in r)if(!s.some(p=>p.serviceEndpoint===f))throw new mt("Cursor does not match actor's inboxes");let a=await Promise.all(t.map(f=>this.channelAttestations.register(Qt,f))),c=s.map(f=>{let p=r[f.serviceEndpoint];return this.querySingleEndpoint(f.serviceEndpoint,p?{cursor:p}:{tags:a,objectSchema:n},f.token,o?.actor)}),u=c.map(async(f,p)=>bp(f,p)),l=u.length;try{for(;l>0;){let f=await Promise.race(u);if(f.error!==void 0)u[f.index]=new Promise(()=>{}),l--,yield{error:f.error,origin:s[f.index].serviceEndpoint},this.tryLogoutIfUnauthorized(f.error,o);else if(f.result.done){let p=s[f.index];r[p.serviceEndpoint]=f.result.value,u[f.index]=new Promise(()=>{}),l--}else{u[f.index]=bp(c[f.index],f.index);let{object:p,tombstone:g,tags:w}=f.result.value;if(g){if(i.get(p.url)===!0)continue;i.set(p.url,!0),yield{tombstone:g,object:{url:p.url}}}else{if(i.get(p.url)===!1)continue;let A=a.reduce((h,_,S)=>{for(let b of w)if(_.length===b.length&&_.every((v,O)=>b[O]===v)){h.push(S);break}return h},[]).map(h=>t[h]);A.length===0&&(yield{error:new Error("Inbox returned object without matching channels"),origin:s[f.index].serviceEndpoint}),i.set(p.url,!1),yield{object:{...p,channels:A}}}}}}catch(f){throw this.tryLogoutIfUnauthorized(f,o),f}finally{await Promise.all(c.map(async f=>{await f.return("")}))}return{cursor:JSON.stringify({channels:t,cursors:r})}}discover=(...t)=>{let[n,r,o]=t;return this.discoverMeta(n,r,{},o)};continueDiscover=(...t)=>{let[n,r]=t,o,i;try{let s=JSON.parse(n),a=Db.parse(s);o=a.channels,i=a.cursors}catch{return(async function*(){throw new Me("Invalid cursor")})()}return this.discoverMeta(o,{},i,r)};async tryLogoutIfUnauthorized(t,n){t instanceof Vt&&n&&await this.sessions.logout(n.actor)}async announceObject(t,n,r,o,i,s){let a=this.sessions.resolveSession(i),c={[Qa]:o},u=[],l=t.allowed;if(Array.isArray(l)){if(!r||r.length!==l.length)throw new Error("If allowed actors are specified, there must be a corresponding ticket for each allowed actor");let g=await Promise.allSettled(l.map(async(w,x)=>{let A=JSON.parse(JSON.stringify(t)),h=rs(A,[],w),S=(await this.dids.resolve(w)).service?.find(I=>I.type===Ri&&I.id===Fa);if(!S)throw new Error(`Recipient ${w} does not have a personal inbox`);if(typeof S.serviceEndpoint!="string")throw new Error(`Recipient ${w} does not have a valid personal inbox endpoint`);let b=s?s.find(I=>I[Jr]===w)?.[en]:void 0,v={...c,...b?{[Fn]:b}:{},[Kr]:r[x],[tc]:x},O=await this.inboxes.send(S.serviceEndpoint,{[Ln]:n,[Ze]:h,[Nn]:pe(v)});u.push({[en]:O,[Jr]:w})}));for(let[w,x]of g.entries())if(x.status==="rejected"){let A=l[w];console.error("Error sending to recipient:",A),console.error(x.reason)}}else{let g=JSON.parse(JSON.stringify(t)),w=rs(g,[]),x=a.sharedInboxes,A=await Promise.allSettled(x.map(async h=>{let _=s?s.find(v=>v[ec]===h.serviceEndpoint)?.[en]:void 0,S={...c,..._?{[Fn]:_}:{}},b=await this.inboxes.send(h.serviceEndpoint,{..._?{[Fn]:_}:{},[Ln]:n,[Ze]:w,[Nn]:pe(S)});u.push({[en]:b,[ec]:h.serviceEndpoint})}));for(let[h,_]of A.entries())if(_.status==="rejected"){let S=x[h];console.error("Error sending to inbox:",S),console.error(_.reason)}}let f=s?s.find(g=>g[Jr]===i.actor)?.[en]:void 0,p={...c,...r?{[$i]:r}:{},...f?{[Fn]:f}:{},[Ci]:u};await this.inboxes.send(a.personalInbox.serviceEndpoint,{[Ln]:n,[Ze]:t,[Nn]:pe(p)})}async*querySingleEndpoint(t,n,r,o){let i="tags"in n?this.inboxes.query(t,n.tags,n.objectSchema,r):this.inboxes.continueQuery(t,n.cursor,r),s=[],a=null;try{for(;;){for(;a===null&&s.length<$b;){let l=await i.next();if(l.done){a=l.value;break}let f=this.processOneLabeledMessage(t,l.value,r,o).catch(p=>{throw p});s.push(f)}let c=s.shift();if(!c){if(a!==null)return a;throw new Error("Process queue empty but no return value")}let u=await c;u&&(yield u)}}finally{await i.return("")}}labelInboxMessage(t,n,r,o){this.inboxes.label(t,n,r,o).catch(i=>console.error("Could not label inbox message:",i))}async processOneLabeledMessage(t,n,r,o){let i=n.l;if(i!==Ya&&i!==zb&&i!==Rt)return;let s=n.id,{o:a,m:c,t:u}=n.m,l;try{let A=Ne(c);l=Ib.parse(A)}catch{this.labelInboxMessage(t,s,Xa,r);return}let{[Qa]:f,[Fn]:p}=l,g=$i in l?l[$i]:void 0,w=Ci in l?l[Ci]:void 0;if(i===Ya)return{messageId:s,object:a,storageBucketKey:f,allowedTickets:g,tags:u,announcements:w};if(i===Rt){if(!p)return;let A=await this.inboxes.get(t,p,r);return!A||A[ft][Ze].url!==a.url?void 0:(A[Zr]!==Rt&&this.labelInboxMessage(t,p,Rt,r),{messageId:s,tombstone:!0,object:a,storageBucketKey:f,allowedTickets:g,tags:u,announcements:w})}let x;try{let A=a.actor,_=(await this.dids.resolve(A))?.service?.find(O=>O.id===ki&&O.type===Oi);if(!_)throw new Q(`Actor ${A} has no storage bucket service`);if(typeof _.serviceEndpoint!="string")throw new Q(`Actor ${A} does not have a valid storage bucket endpoint`);let S=_.serviceEndpoint,b=await this.storageBuckets.get(S,f,Ii);if(Kr in l&&!o)throw new mt("Recipient is required when allowed ticket is present");let v=g?{allowedTickets:g}:Kr in l?{recipient:o??"null",allowedTicket:l[Kr],allowedIndex:l[tc]}:void 0;await this.objectEncoding.validate(a,u,b,v)}catch(A){x=A}if(p){if(x instanceof Q)return this.inboxes.get(t,p,r).then(A=>{A&&A[ft][Ze].url===a.url&&A[Zr]!==Rt&&this.labelInboxMessage(t,p,Rt,r),this.labelInboxMessage(t,s,Rt,r)}).catch(A=>console.error("Could not inspect tombstone message:",A)),{messageId:s,tombstone:!0,object:a,storageBucketKey:f,allowedTickets:g,tags:u,announcements:w};console.error("Recieved an incorrect tombstone object"),console.error(x),this.labelInboxMessage(t,s,Xa,r)}else{if(x===void 0)return this.labelInboxMessage(t,s,Ya,r),{messageId:s,object:a,storageBucketKey:f,tags:u,allowedTickets:g,announcements:w};x instanceof Q?this.labelInboxMessage(t,s,Rt,r):(console.error("Recieved an incorrect object"),console.error(x),this.labelInboxMessage(t,s,Xa,r))}}},Cb={properties:{value:{properties:{type:{type:"string"},size:{type:"number"},key:{type:"string"}},required:["type","size","key"]}}},Db=ye({cursors:Su(Z(),B()),channels:q(B())});async function bp(e,t){try{return{index:t,result:await e.next()}}catch(n){if(n instanceof Me||n instanceof an)throw n;return{index:t,error:n instanceof Error?n:new Error(String(n))}}}var xp=class extends ro{constructor(t){let n=new Di(t);super(n)}};export{xp as GraffitiDecentralized};
|
|
10
|
+
`+s)}}catch{}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Be(this.defaults,n);let{transitional:r,paramsSerializer:o,headers:i}=n;r!==void 0&&Or.assertOptions(r,{silentJSONParsing:he.transitional(he.boolean),forcedJSONParsing:he.transitional(he.boolean),clarifyTimeoutError:he.transitional(he.boolean),legacyInterceptorReqResOrdering:he.transitional(he.boolean),advertiseZstdAcceptEncoding:he.transitional(he.boolean),validateStatusUndefinedResolves:he.transitional(he.boolean)},!1),o!=null&&(d.isFunction(o)?n.paramsSerializer={serialize:o}:Or.assertOptions(o,{encode:he.function,serialize:he.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Or.assertOptions(n,{baseUrl:he.spelling("baseURL"),withXsrfToken:he.spelling("withXSRFToken")},!0),n.method=(d.getSafeProp(n,"method")||d.getSafeProp(this.defaults,"method")||"get").toLowerCase();let s=i&&d.merge(i.common,i[n.method]);i&&d.forEach(Uo.concat("common"),w=>{delete i[w]}),n.headers=ee.concat(s,i);let a=[],c=!0;this.interceptors.request.forEach(function(x){if(typeof x.runWhen=="function"&&x.runWhen(n)===!1)return;c=c&&x.synchronous;let A=n.transitional||Sn;A&&A.legacyInterceptorReqResOrdering?a.unshift(x.fulfilled,x.rejected):a.push(x.fulfilled,x.rejected)});let u=[];this.interceptors.response.forEach(function(x){u.push(x.fulfilled,x.rejected)});let l,f=0,p;if(!c){let w=[Pr.bind(this),void 0];for(w.unshift(...a),w.push(...u),p=w.length,l=Promise.resolve(n);f<p;)l=l.then(w[f++],w[f++]);return l}p=a.length;let g=n;for(;f<p;){let w=a[f++],x=a[f++];try{g=w?w(g):g}catch(A){if(!x){l=Promise.reject(A);break}try{let h=x.call(this,A);d.isThenable(h)&&(l=Promise.resolve(h).then(()=>Pr.call(this,g)))}catch(h){l=Promise.reject(h)}break}}if(!l)try{l=Pr.call(this,g)}catch(w){l=Promise.reject(w)}for(f=0,p=u.length;f<p;)l=l.then(u[f++],u[f++]);return l}getUri(t){t=Be(this.defaults,t);let n=Tr(t.baseURL,t.url,t.allowAbsoluteUrls,t);return br(n,t.params,t.paramsSerializer)}};d.forEach(["delete","get","head","options"],function(t){Pn.prototype[t]=function(n,r){return this.request(Be(r||{},{method:t,url:n,data:r&&d.hasOwnProp(r,"data")?r.data:void 0}))}});d.forEach(["post","put","patch","query"],function(t){function n(r){return function(i,s,a){return this.request(Be(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}Pn.prototype[t]=n(),t!=="query"&&(Pn.prototype[t+"Form"]=n(!0))});var kr=Pn;var Ys=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});let r=this;this.promise.then(o=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](o);r._listeners=null}),this.promise.then=o=>{let i,s=new Promise(a=>{r.subscribe(a),i=a}).then(o);return s.cancel=function(){r.unsubscribe(i)},s},t(function(i,s,a){r.reason||(r.reason=new Ve(i,s,a),n(r.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;let n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){let t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new e(function(o){t=o}),cancel:t}}},Gf=Ys;function Xs(e){return function(n){return e.apply(null,n)}}function Qs(e){return d.isObject(e)&&e.isAxiosError===!0}var jo={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,ContentTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,UnprocessableContent: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,WebServerReturnsAnUnknownError:520,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(jo).forEach(([e,t])=>{jo[t]===void 0&&(jo[t]=e)});var qf=jo;function Kf(e){let t=new kr(e),n=dr(kr.prototype.request,t);return d.extend(n,kr.prototype,t,{allOwnKeys:!0}),d.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Kf(Be(e,o))},n}var re=Kf(An);re.Axios=kr;re.CanceledError=Ve;re.CancelToken=Gf;re.isCancel=Sr;re.VERSION=Tn;re.toFormData=St;re.AxiosError=T;re.Cancel=re.CanceledError;re.all=function(t){return Promise.all(t)};re.spread=Xs;re.isAxiosError=Qs;re.mergeConfig=Be;re.AxiosHeaders=ee;re.formToJSON=e=>Do(d.isHTMLForm(e)?new FormData(e):e);re.getAdapter=No.getAdapter;re.HttpStatusCode=qf;re.default=re;var Zo=re;var{Axios:JT,AxiosError:VT,CanceledError:WT,isCancel:YT,CancelToken:XT,VERSION:QT,all:eP,Cancel:tP,isAxiosError:nP,spread:rP,toFormData:oP,AxiosHeaders:iP,HttpStatusCode:sP,formToJSON:aP,getAdapter:cP,mergeConfig:uP,create:lP}=Zo;function qy(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function Pe(e,t,n){if(!e.s){if(n instanceof ea)if(n.s)t&1&&(t=n.s),n=n.v;else{n.o=Pe.bind(null,e,t);return}if(n&&n.then){n.then(Pe.bind(null,e,t),Pe.bind(null,e,2));return}e.s=t,e.v=n;let r=e.o;r&&r(e)}}var ea=(function(){function e(){}return e.prototype.then=function(t,n){let r=new e,o=this.s;if(o){let i=o&1?t:n;if(i){try{Pe(r,1,i(this.v))}catch(s){Pe(r,2,s)}return r}else return this}return this.o=function(i){try{let s=i.v;i.s&1?Pe(r,1,t?t(s):s):n?Pe(r,1,n(s)):Pe(r,2,s)}catch(s){Pe(r,2,s)}},r},e})();function On(e){return e instanceof ea&&e.s&1}function Ky(e,t){var n;do{var r=e();if(r&&r.then)if(On(r))r=r.v;else{n=!0;break}var o=t();if(On(o)&&(o=o.v),!o)return r}while(!o.then);let i=new ea,s=Pe.bind(null,i,2);return(n?r.then(a):o.then(c)).then(void 0,s),i;function a(u){for(r=u;o=t(),On(o)&&(o=o.v),!!o;){if(o.then){o.then(c).then(void 0,s);return}if(r=e(),r&&r.then)if(On(r))r=r.v;else{r.then(a).then(void 0,s);return}}Pe(i,1,r)}function c(u){if(u){do{if(r=e(),r&&r.then)if(On(r))r=r.v;else{r.then(a).then(void 0,s);return}if(u=t(),On(u)&&(u=u.v),!u){Pe(i,1,r);return}}while(!u.then);u.then(c).then(void 0,s)}else Pe(i,1,r)}}function Jf(){return{plc:function(t,n){try{let o=function(){let l=typeof c?.["@context"]<"u"?"application/did+ld+json":"application/did+json";return i?{didDocument:c,didDocumentMetadata:a,didResolutionMetadata:{error:"notFound",message:i}}:{didDocument:c,didDocumentMetadata:a,didResolutionMetadata:{contentType:l}}},r,i=null,s=`https://plc.directory/${encodeURIComponent(t)}`,a={},c=null,u=Ky(function(){function l(){r||c?.id===t||(i="resolver_error: DID document id does not match requested did")}let f=qy(function(){return Promise.resolve(Zo.get(s)).then(function(p){c=p.data})},function(p){i=`resolver_error: '"https://plc.directory/" + DID' must resolve to a valid https URL containing a JSON document: ${p}`,r=1});return f&&f.then?f.then(l):l(f)},function(){return!r&&!1});return Promise.resolve(u&&u.then?u.then(o):o(u))}catch(r){return Promise.reject(r)}}}}var Yf=Rp(Wf(),1);function Jy(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}var Vy=function(e){try{return Promise.resolve((0,Yf.default)(e,{mode:"cors"})).then(function(t){if(t.status>=400)throw new Error(`Bad response ${t.statusText}`);return t.json()})}catch(t){return Promise.reject(t)}};function Oe(e,t,n){if(!e.s){if(n instanceof ta)if(n.s)t&1&&(t=n.s),n=n.v;else{n.o=Oe.bind(null,e,t);return}if(n&&n.then){n.then(Oe.bind(null,e,t),Oe.bind(null,e,2));return}e.s=t,e.v=n;let r=e.o;r&&r(e)}}var Wy="/.well-known/did.json",ta=(function(){function e(){}return e.prototype.then=function(t,n){let r=new e,o=this.s;if(o){let i=o&1?t:n;if(i){try{Oe(r,1,i(this.v))}catch(s){Oe(r,2,s)}return r}else return this}return this.o=function(i){try{let s=i.v;i.s&1?Oe(r,1,t?t(s):s):n?Oe(r,1,n(s)):Oe(r,2,s)}catch(s){Oe(r,2,s)}},r},e})();function In(e){return e instanceof ta&&e.s&1}function Yy(e,t){var n;do{var r=e();if(r&&r.then)if(In(r))r=r.v;else{n=!0;break}var o=t();if(In(o)&&(o=o.v),!o)return r}while(!o.then);let i=new ta,s=Oe.bind(null,i,2);return(n?r.then(a):o.then(c)).then(void 0,s),i;function a(u){for(r=u;o=t(),In(o)&&(o=o.v),!!o;){if(o.then){o.then(c).then(void 0,s);return}if(r=e(),r&&r.then)if(In(r))r=r.v;else{r.then(a).then(void 0,s);return}}Oe(i,1,r)}function c(u){if(u){do{if(r=e(),r&&r.then)if(In(r))r=r.v;else{r.then(a).then(void 0,s);return}if(u=t(),In(u)&&(u=u.v),!u){Oe(i,1,r);return}}while(!u.then);u.then(c).then(void 0,s)}else Oe(i,1,r)}}function Xf(){return{web:function(t,n){try{let o=function(){let p=typeof l?.["@context"]<"u"?"application/did+ld+json":"application/did+json";return i?{didDocument:l,didDocumentMetadata:u,didResolutionMetadata:{error:"notFound",message:i}}:{didDocument:l,didDocumentMetadata:u,didResolutionMetadata:{contentType:p}}},r,i=null,s=decodeURIComponent(n.id)+Wy,a=n.id.split(":");a.length>1&&(s=a.map(decodeURIComponent).join("/")+"/did.json");let c=`https://${s}`,u={},l=null,f=Yy(function(){function p(){r||l?.id===t||(i="resolver_error: DID document id does not match requested did")}let g=Jy(function(){return Promise.resolve(Vy(c)).then(function(w){l=w})},function(w){i=`resolver_error: DID must resolve to a valid https URL containing a JSON document: ${w}`,r=1});return g&&g.then?g.then(p):p(g)},function(){return!r&&!1});return Promise.resolve(f&&f.then?f.then(o):o(f))}catch(r){return Promise.reject(r)}}}}var Go=class{methods={...Jf(),...Xf()};resolver=new Oo(this.methods,{cache:!0});inFlight=new Map;async resolve(t){if(!Object.keys(this.methods).some(o=>t.startsWith(`did:${o}:`)))throw new Error(`Unrecognized DID method: ${t}`);let n=this.inFlight.get(t);if(n)return n;let r=this.resolver.resolve(t).then(({didDocument:o})=>{if(!o)throw new Q(`DID not found: ${t}`);return o});this.inFlight.set(t,r);try{return await r}finally{this.inFlight.delete(t)}}};var oa;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(oa="oauth4webapi/v3.8.7");function Dr(e,t){if(e==null)return!1;try{return e instanceof t||Object.getPrototypeOf(e)[Symbol.toStringTag]===t.prototype[Symbol.toStringTag]}catch{return!1}}var xe="ERR_INVALID_ARG_VALUE",$e="ERR_INVALID_ARG_TYPE";function J(e,t,n){let r=new TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}var Kt=Symbol(),Wo=Symbol(),Yo=Symbol(),Jt=Symbol();var qo=Symbol();var Xy=new TextEncoder,Qy=new TextDecoder;function Qf(e){return typeof e=="string"?Xy.encode(e):Qy.decode(e)}var ia;Uint8Array.prototype.toBase64?ia=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0})):ia=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));let n=[];for(let r=0;r<t.byteLength;r+=32768)n.push(String.fromCharCode.apply(null,t.subarray(r,r+32768)));return btoa(n.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")};var sa;Uint8Array.fromBase64?sa=e=>{try{return Uint8Array.fromBase64(e,{alphabet:"base64url"})}catch(t){throw J("The input to be decoded is not correctly encoded.",xe,t)}}:sa=e=>{try{let t=atob(e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"")),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}catch(t){throw J("The input to be decoded is not correctly encoded.",xe,t)}};function aa(e){return typeof e=="string"?sa(e):ia(e)}var At=class extends Error{code;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=ri,Error.captureStackTrace?.(this,this.constructor)}},zr=class extends Error{code;constructor(t,n){super(t,n),this.name=this.constructor.name,n?.code&&(this.code=n?.code),Error.captureStackTrace?.(this,this.constructor)}};function D(e,t,n){return new zr(e,{code:t,cause:n})}function Ko(e){return!(e===null||typeof e!="object"||Array.isArray(e))}function ca(e){Dr(e,Headers)&&(e=Object.fromEntries(e.entries()));let t=new Headers(e??{});if(oa&&!t.has("user-agent")&&t.set("user-agent",oa),t.has("authorization"))throw J('"options.headers" must not include the "authorization" header name',xe);return t}function td(e,t){if(t!==void 0){if(typeof t=="function"&&(t=t(e.href)),!(t instanceof AbortSignal))throw J('"options.signal" must return or be an instance of AbortSignal',$e);return t}}function nd(e){return e.includes("//")?e.replace("//","/"):e}function ew(e,t,n=!1){return e.pathname==="/"?e.pathname=t:e.pathname=nd(`${t}/${n?e.pathname:e.pathname.replace(/(\/)$/,"")}`),e}function tw(e,t){return e.pathname=nd(`${e.pathname}/${t}`),e}async function nw(e,t,n,r){if(!(e instanceof URL))throw J(`"${t}" must be an instance of URL`,$e);ei(e,r?.[Kt]!==!0);let o=n(new URL(e.href)),i=ca(r?.headers);return i.set("accept","application/json"),(r?.[Jt]||fetch)(o.href,{body:void 0,headers:Object.fromEntries(i.entries()),method:"GET",redirect:"manual",signal:td(o,r?.signal)})}async function rd(e,t){return nw(e,"issuerIdentifier",n=>{switch(t?.algorithm){case void 0:case"oidc":tw(n,".well-known/openid-configuration");break;case"oauth2":ew(n,".well-known/oauth-authorization-server");break;default:throw J('"options.algorithm" must be "oidc" (default), or "oauth2"',xe)}return n},t)}function Ir(e,t,n,r,o){try{if(typeof e!="number"||!Number.isFinite(e))throw J(`${n} must be a number`,$e,o);if(e>0)return;if(t){if(e!==0)throw J(`${n} must be a non-negative number`,xe,o);return}throw J(`${n} must be a positive number`,xe,o)}catch(i){throw r?D(i.message,r,o):i}}function _e(e,t,n,r){try{if(typeof e!="string")throw J(`${t} must be a string`,$e,r);if(e.length===0)throw J(`${t} must not be empty`,xe,r)}catch(o){throw n?D(o.message,n,r):o}}async function od(e,t){let n=e;if(!(n instanceof URL)&&n!==Vo)throw J('"expectedIssuerIdentifier" must be an instance of URL',$e);if(!Dr(t,Response))throw J('"response" must be an instance of Response',$e);if(t.status!==200)throw D('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)',oi,t);ba(t);let r=await _d(t);if(_e(r.issuer,'"response" body "issuer" property',F,{body:r}),n!==Vo&&new URL(r.issuer).href!==n.href)throw D('"response" body "issuer" property does not match the expected value',ii,{expected:n.href,body:r,attribute:"issuer"});return r}function id(e){ow(e,"application/json")}function rw(e,...t){let n='"response" content-type must be ';if(t.length>2){let r=t.pop();n+=`${t.join(", ")}, or ${r}`}else t.length===2?n+=`${t[0]} or ${t[1]}`:n+=t[0];return D(n,ga,e)}function ow(e,t){if(pa(e)!==t)throw rw(e,t)}function iw(){return aa(crypto.getRandomValues(new Uint8Array(32)))}function sd(){return iw()}function ua(e){let t=e?.[Wo];return typeof t=="number"&&Number.isFinite(t)?t:0}function la(e){let t=e?.[Yo];return typeof t=="number"&&Number.isFinite(t)&&Math.sign(t)!==-1?t:30}function fa(){return Math.floor(Date.now()/1e3)}function Xo(e){if(typeof e!="object"||e===null)throw J('"as" must be an object',$e);_e(e.issuer,'"as.issuer"')}function Qo(e){if(typeof e!="object"||e===null)throw J('"client" must be an object',$e);_e(e.client_id,'"client.client_id"')}function da(e){return _e(e,'"clientSecret"'),(t,n,r,o)=>{r.set("client_id",n.client_id),r.set("client_secret",e)}}function ad(){return(e,t,n,r)=>{n.set("client_id",t.client_id)}}var sw=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch{return null}};function ei(e,t){if(t&&e.protocol!=="https:")throw D("only requests to HTTPS are allowed",ya,e);if(e.protocol!=="https:"&&e.protocol!=="http:")throw D("only HTTP and HTTPS requests are allowed",wa,e)}function ed(e,t,n,r){let o;if(typeof e!="string"||!(o=sw(e)))throw D(`authorization server metadata does not contain a valid ${n?`"as.mtls_endpoint_aliases.${t}"`:`"as.${t}"`}`,e===void 0?Iw:zw,{attribute:n?`mtls_endpoint_aliases.${t}`:t});return ei(o,r),o}function ti(e,t,n,r){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?ed(e.mtls_endpoint_aliases[t],t,n,r):ed(e[t],t,n,r)}function cd(e){if(e instanceof $n){let{0:t,length:n}=e.cause;return n===1&&t.scheme==="dpop"&&t.parameters.error==="use_dpop_nonce"}return e instanceof zn?e.error==="use_dpop_nonce":!1}var zn=class extends Error{cause;code;error;status;error_description;response;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=Ow,this.cause=n.cause,this.error=n.cause.error,this.status=n.response.status,this.error_description=n.cause.error_description,Object.defineProperty(this,"response",{enumerable:!1,value:n.response}),Error.captureStackTrace?.(this,this.constructor)}},$r=class extends Error{cause;code;error;error_description;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=kw,this.cause=n.cause,this.error=n.cause.get("error"),this.error_description=n.cause.get("error_description")??void 0,Error.captureStackTrace?.(this,this.constructor)}},$n=class extends Error{cause;code;response;status;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=Pw,this.cause=n.cause,this.status=n.response.status,this.response=n.response,Object.defineProperty(this,"response",{enumerable:!1}),Error.captureStackTrace?.(this,this.constructor)}},Jo="[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+",aw="[a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2}",cw='"((?:[^"\\\\]|\\\\[\\s\\S])*)"',uw="("+Jo+")\\s*=\\s*"+cw,lw="("+Jo+")\\s*=\\s*("+Jo+")",fw=new RegExp("^[,\\s]*("+Jo+")"),dw=new RegExp("^[,\\s]*"+uw+"[,\\s]*(.*)"),pw=new RegExp("^[,\\s]*"+lw+"[,\\s]*(.*)"),hw=new RegExp("^("+aw+")(?:$|[,\\s])(.*)");function mw(e){if(!Dr(e,Response))throw J('"response" must be an instance of Response',$e);let t=e.headers.get("www-authenticate");if(t===null)return;let n=[],r=t;for(;r;){let o=r.match(fw),i=o?.[1].toLowerCase();if(!i)return;let s=r.substring(o[0].length);if(s&&!s.match(/^[\s,]/))return;let a=s.match(/^\s+(.*)$/),c=!!a;r=a?a[1]:void 0;let u={},l;if(c)for(;r;){let p,g;if(o=r.match(dw)){if([,p,g,r]=o,g.includes("\\"))try{g=JSON.parse(`"${g}"`)}catch{}u[p.toLowerCase()]=g;continue}if(o=r.match(pw)){[,p,g,r]=o,u[p.toLowerCase()]=g;continue}if(o=r.match(hw)){if(Object.keys(u).length)break;[,l,r]=o;break}return}else r=s||void 0;let f={scheme:i,parameters:u};l&&(f.token68=l),n.push(f)}if(n.length)return n}async function gw(e){if(e.status>399&&e.status<500){ba(e),id(e);try{let t=await e.clone().json();if(Ko(t)&&typeof t.error=="string"&&t.error.length)return t}catch{}}}async function ud(e,t,n){if(e.status!==t){_w(e);let r;throw(r=await gw(e))?(await e.body?.cancel(),new zn("server responded with an error in the response body",{cause:r,response:e})):D(`"response" is not a conform ${n} response (unexpected HTTP status code)`,oi,e)}}function yw(e){if(!ha.has(e))throw J('"options.DPoP" is not a valid DPoPHandle',xe)}function pa(e){return e.headers.get("content-type")?.split(";")[0]}async function ld(e,t,n,r,o,i,s){return await n(e,t,o,i),i.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),(s?.[Jt]||fetch)(r.href,{body:o,headers:Object.fromEntries(i.entries()),method:"POST",redirect:"manual",signal:td(r,s?.signal)})}async function ww(e,t,n,r,o,i){let s=ti(e,"token_endpoint",t.use_mtls_endpoint_aliases,i?.[Kt]!==!0);o.set("grant_type",r);let a=ca(i?.headers);a.set("accept","application/json"),i?.DPoP!==void 0&&(yw(i.DPoP),await i.DPoP.addProof(s,a,"POST"));let c=await ld(e,t,n,s,o,a,i);return i?.DPoP?.cacheNonce(c,s),c}var fd=new WeakMap,bw=new WeakMap;function ni(e){if(!e.id_token)return;let t=fd.get(e);if(!t)throw J('"ref" was already garbage collected or did not resolve from the proper sources',xe);return t}async function dd(e,t,n,r,o,i){if(Xo(e),Qo(t),!Dr(n,Response))throw J('"response" must be an instance of Response',$e);await ud(n,200,"Token Endpoint"),ba(n);let s=await _d(n);if(_e(s.access_token,'"response" body "access_token" property',F,{body:s}),_e(s.token_type,'"response" body "token_type" property',F,{body:s}),s.token_type=s.token_type.toLowerCase(),s.expires_in!==void 0){let a=typeof s.expires_in!="number"?parseFloat(s.expires_in):s.expires_in;Ir(a,!0,'"response" body "expires_in" property',F,{body:s}),s.expires_in=a}if(s.refresh_token!==void 0&&_e(s.refresh_token,'"response" body "refresh_token" property',F,{body:s}),s.scope!==void 0&&typeof s.scope!="string")throw D('"response" body "scope" property must be a string',F,{body:s});if(s.id_token!==void 0){_e(s.id_token,'"response" body "id_token" property',F,{body:s});let a=["aud","exp","iat","iss","sub"];t.require_auth_time===!0&&a.push("auth_time"),t.default_max_age!==void 0&&(Ir(t.default_max_age,!0,'"client.default_max_age"'),a.push("auth_time")),r?.length&&a.push(...r);let{claims:c,jwt:u}=await $w(s.id_token,Dw.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,"RS256"),ua(t),la(t),o).then(Aw.bind(void 0,a)).then(Ew.bind(void 0,e)).then(xw.bind(void 0,t.client_id));if(Array.isArray(c.aud)&&c.aud.length!==1){if(c.azp===void 0)throw D('ID Token "aud" (audience) claim includes additional untrusted audiences',We,{claims:c,claim:"aud"});if(c.azp!==t.client_id)throw D('unexpected ID Token "azp" (authorized party) claim value',We,{expected:t.client_id,claims:c,claim:"azp"})}c.auth_time!==void 0&&Ir(c.auth_time,!0,'ID Token "auth_time" (authentication time)',F,{claims:c}),bw.set(n,u),fd.set(s,c)}if(i?.[s.token_type]!==void 0)i[s.token_type](n,s);else if(s.token_type!=="dpop"&&s.token_type!=="bearer")throw new At("unsupported `token_type` value",{cause:{body:s}});return s}function _w(e){let t;if(t=mw(e))throw new $n("server responded with a challenge in the WWW-Authenticate HTTP Header",{cause:t,response:e})}function xw(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw D('unexpected JWT "aud" (audience) claim value',We,{expected:e,claims:t.claims,claim:"aud"})}else if(t.claims.aud!==e)throw D('unexpected JWT "aud" (audience) claim value',We,{expected:e,claims:t.claims,claim:"aud"});return t}function Ew(e,t){let n=e[_a]?.(t)??e.issuer;if(t.claims.iss!==n)throw D('unexpected JWT "iss" (issuer) claim value',We,{expected:n,claims:t.claims,claim:"iss"});return t}var ha=new WeakSet;function Sw(e){return ha.add(e),e}var ma=Symbol();async function pd(e,t,n,r,o,i,s){if(Xo(e),Qo(t),!ha.has(r))throw J('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()',xe);_e(o,'"redirectUri"');let a=qt(r,"code");if(!a)throw D('no authorization code in "callbackParameters"',F);let c=new URLSearchParams(s?.additionalParameters);return c.set("redirect_uri",o),c.set("code",a),i!==ma&&(_e(i,'"codeVerifier"'),c.set("code_verifier",i)),ww(e,t,n,"authorization_code",c,s)}var vw={aud:"audience",c_hash:"code hash",client_id:"client id",exp:"expiration time",iat:"issued at",iss:"issuer",jti:"jwt id",nonce:"nonce",s_hash:"state hash",sub:"subject",ath:"access token hash",htm:"http method",htu:"http uri",cnf:"confirmation",auth_time:"authentication time"};function Aw(e,t){for(let n of e)if(t.claims[n]===void 0)throw D(`JWT "${n}" (${vw[n]}) claim missing`,F,{claims:t.claims});return t}var na=Symbol(),ra=Symbol();async function hd(e,t,n,r){return typeof r?.expectedNonce=="string"||typeof r?.maxAge=="number"||r?.requireIdToken?Rw(e,t,n,r.expectedNonce,r.maxAge,r[qo],r.recognizedTokenTypes):Tw(e,t,n,r?.[qo],r?.recognizedTokenTypes)}async function Rw(e,t,n,r,o,i,s){let a=[];switch(r){case void 0:r=na;break;case na:break;default:_e(r,'"expectedNonce" argument'),a.push("nonce")}switch(o??=t.default_max_age,o){case void 0:o=ra;break;case ra:break;default:Ir(o,!0,'"maxAge" argument'),a.push("auth_time")}let c=await dd(e,t,n,a,i,s);_e(c.id_token,'"response" body "id_token" property',F,{body:c});let u=ni(c);if(o!==ra){let l=fa()+ua(t),f=la(t);if(u.auth_time+o<l-f)throw D("too much time has elapsed since the last End-User authentication",Cn,{claims:u,now:l,tolerance:f,claim:"auth_time"})}if(r===na){if(u.nonce!==void 0)throw D('unexpected ID Token "nonce" claim value',We,{expected:void 0,claims:u,claim:"nonce"})}else if(u.nonce!==r)throw D('unexpected ID Token "nonce" claim value',We,{expected:r,claims:u,claim:"nonce"});return c}async function Tw(e,t,n,r,o){let i=await dd(e,t,n,void 0,r,o),s=ni(i);if(s){if(t.default_max_age!==void 0){Ir(t.default_max_age,!0,'"client.default_max_age"');let a=fa()+ua(t),c=la(t);if(s.auth_time+t.default_max_age<a-c)throw D("too much time has elapsed since the last End-User authentication",Cn,{claims:s,now:a,tolerance:c,claim:"auth_time"})}if(s.nonce!==void 0)throw D('unexpected ID Token "nonce" claim value',We,{expected:void 0,claims:s,claim:"nonce"})}return i}var Pw="OAUTH_WWW_AUTHENTICATE_CHALLENGE",Ow="OAUTH_RESPONSE_BODY_ERROR",ri="OAUTH_UNSUPPORTED_OPERATION",kw="OAUTH_AUTHORIZATION_RESPONSE_ERROR";var Cr="OAUTH_PARSE_ERROR",F="OAUTH_INVALID_RESPONSE";var ga="OAUTH_RESPONSE_IS_NOT_JSON",oi="OAUTH_RESPONSE_IS_NOT_CONFORM",ya="OAUTH_HTTP_REQUEST_FORBIDDEN",wa="OAUTH_REQUEST_PROTOCOL_FORBIDDEN",Cn="OAUTH_JWT_TIMESTAMP_CHECK_FAILED",We="OAUTH_JWT_CLAIM_COMPARISON_FAILED",ii="OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED";var Iw="OAUTH_MISSING_SERVER_METADATA",zw="OAUTH_INVALID_SERVER_METADATA";async function md(e,t,n,r,o){Xo(e),Qo(t),_e(r,'"token"');let i=ti(e,"revocation_endpoint",t.use_mtls_endpoint_aliases,o?.[Kt]!==!0),s=new URLSearchParams(o?.additionalParameters);s.set("token",r);let a=ca(o?.headers);return a.delete("accept"),ld(e,t,n,i,s,a,o)}async function gd(e){if(!Dr(e,Response))throw J('"response" must be an instance of Response',$e);await ud(e,200,"Revocation Endpoint")}function ba(e){if(e.bodyUsed)throw J('"response" body has been used already',xe)}async function $w(e,t,n,r,o){let{0:i,1:s,length:a}=e.split(".");if(a===5)if(o!==void 0)e=await o(e),{0:i,1:s,length:a}=e.split(".");else throw new At("JWE decryption is not configured",{cause:e});if(a!==3)throw D("Invalid JWT",F,e);let c;try{c=JSON.parse(Qf(aa(i)))}catch(f){throw D("failed to parse JWT Header body as base64url encoded JSON",Cr,f)}if(!Ko(c))throw D("JWT Header must be a top level object",F,e);if(t(c),c.crit!==void 0)throw new At('no JWT "crit" header parameter extensions are supported',{cause:{header:c}});let u;try{u=JSON.parse(Qf(aa(s)))}catch(f){throw D("failed to parse JWT Payload body as base64url encoded JSON",Cr,f)}if(!Ko(u))throw D("JWT Payload must be a top level object",F,e);let l=fa()+n;if(u.exp!==void 0){if(typeof u.exp!="number")throw D('unexpected JWT "exp" (expiration time) claim type',F,{claims:u});if(u.exp<=l-r)throw D('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp',Cn,{claims:u,now:l,tolerance:r,claim:"exp"})}if(u.iat!==void 0&&typeof u.iat!="number")throw D('unexpected JWT "iat" (issued at) claim type',F,{claims:u});if(u.iss!==void 0&&typeof u.iss!="string")throw D('unexpected JWT "iss" (issuer) claim type',F,{claims:u});if(u.nbf!==void 0){if(typeof u.nbf!="number")throw D('unexpected JWT "nbf" (not before) claim type',F,{claims:u});if(u.nbf>l+r)throw D('unexpected JWT "nbf" (not before) claim value',Cn,{claims:u,now:l,tolerance:r,claim:"nbf"})}if(u.aud!==void 0&&typeof u.aud!="string"&&!Array.isArray(u.aud))throw D('unexpected JWT "aud" (audience) claim type',F,{claims:u});return{header:c,claims:u,jwt:e}}async function Cw(e){if(e.bodyUsed)throw J("form_post Request instances must contain a readable body",xe,{cause:e});return e.text()}async function yd(e){if(e.method!=="POST")throw J("form_post responses are expected to use the POST method",xe,{cause:e});if(pa(e)!=="application/x-www-form-urlencoded")throw J("form_post responses are expected to use the application/x-www-form-urlencoded content-type",xe,{cause:e});return Cw(e)}function Dw(e,t,n,r){if(e!==void 0){if(typeof e=="string"?r.alg!==e:!e.includes(r.alg))throw D('unexpected JWT "alg" header parameter',F,{header:r,expected:e,reason:"client configuration"});return}if(Array.isArray(t)){if(!t.includes(r.alg))throw D('unexpected JWT "alg" header parameter',F,{header:r,expected:t,reason:"authorization server metadata"});return}if(n!==void 0){if(typeof n=="string"?r.alg!==n:typeof n=="function"?!n(r.alg):!n.includes(r.alg))throw D('unexpected JWT "alg" header parameter',F,{header:r,expected:n,reason:"default value"});return}throw D('missing client or server configuration to verify used JWT "alg" header parameter',void 0,{client:e,issuer:t,fallback:n})}function qt(e,t){let{0:n,length:r}=e.getAll(t);if(r>1)throw D(`"${t}" parameter must be provided only once`,F);return n}var wd=Symbol(),Uw=Symbol();function bd(e,t,n,r){if(Xo(e),Qo(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw J('"parameters" must be an instance of URLSearchParams, or URL',$e);if(qt(n,"response"))throw D('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()',F,{parameters:n});let o=qt(n,"iss"),i=qt(n,"state");if(!o&&e.authorization_response_iss_parameter_supported)throw D('response parameter "iss" (issuer) missing',F,{parameters:n});if(o&&o!==e.issuer)throw D('unexpected "iss" (issuer) response parameter value',F,{expected:e.issuer,parameters:n});switch(r){case void 0:case Uw:if(i!==void 0)throw D('unexpected "state" response parameter encountered',F,{expected:void 0,parameters:n});break;case wd:break;default:if(_e(r,'"expectedState" argument'),i!==r)throw D(i===void 0?'response parameter "state" missing':'unexpected "state" response parameter value',F,{expected:r,parameters:n})}if(qt(n,"error"))throw new $r("authorization response from the server is an error",{cause:n});let a=qt(n,"id_token"),c=qt(n,"token");if(a!==void 0||c!==void 0)throw new At("implicit and hybrid flows are not supported");return Sw(new URLSearchParams(n))}async function _d(e,t=id){let n;try{n=await e.json()}catch(r){throw t(e),D('failed to parse "response" body as JSON',Cr,r)}if(!Ko(n))throw D('"response" body must be a top level object',F,{body:n});return n}var Vo=Symbol(),_a=Symbol();var Lr,xd;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(xd="openid-client/v6.8.7",Lr={"user-agent":xd});var je=e=>Ea.get(e),Ea,xa;function Mw(e){return e!==void 0?da(e):(xa||=new WeakMap,(t,n,r,o)=>{let i;return(i=xa.get(n))||(Nw(n.client_secret,'"metadata.client_secret"'),i=da(n.client_secret),xa.set(n,i)),i(t,n,r,o)})}function Nw(e,t){if(typeof e!="string")throw Ye(`${t} must be a string`,Nr);if(e.length===0)throw Ye(`${t} must not be empty`,Mr)}function Bw(){return ad()}var Dn=Jt;var Mr="ERR_INVALID_ARG_VALUE",Nr="ERR_INVALID_ARG_TYPE";function Ye(e,t,n){let r=new TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}function Sd(){return sd()}var Un=class extends Error{code;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=n?.code,Error.captureStackTrace?.(this,this.constructor)}},sO=new TextDecoder;function ge(e,t,n){return new Un(e,{cause:t,code:n})}function Ur(e){if(e instanceof TypeError||e instanceof Un||e instanceof zn||e instanceof $r||e instanceof $n)throw e;if(e instanceof zr)switch(e.code){case ya:throw ge("only requests to HTTPS are allowed",e,e.code);case wa:throw ge("only requests to HTTP or HTTPS are allowed",e,e.code);case oi:throw ge("unexpected HTTP response status code",e.cause,e.code);case ga:throw ge("unexpected response content-type",e.cause,e.code);case Cr:throw ge("parsing error occured",e,e.code);case F:throw ge("invalid response encountered",e,e.code);case We:throw ge("unexpected JWT claim value encountered",e,e.code);case ii:throw ge("unexpected JSON attribute value encountered",e,e.code);case Cn:throw ge("JWT timestamp claim value failed validation",e,e.code);default:throw ge(e.message,e,e.code)}if(e instanceof At)throw ge("unsupported operation",e,e.code);if(e instanceof DOMException)switch(e.name){case"OperationError":throw ge("runtime operation error",e,ri);case"NotSupportedError":throw ge("runtime unsupported operation",e,ri);case"TimeoutError":throw ge("operation timed out",e,"OAUTH_TIMEOUT");case"AbortError":throw ge("operation aborted",e,"OAUTH_ABORT")}throw new Un("something went wrong",{cause:e})}function jw(e,t,n){return e.origin==="https://login.microsoftonline.com"&&(!n?.algorithm||n.algorithm==="oidc")?(t[Ad]=!0,!0):!1}function Zw(e,t){return!!(e.hostname.endsWith(".b2clogin.com")&&(!t?.algorithm||t.algorithm==="oidc"))}async function vd(e,t,n,r,o){let i=await Fw(e,o),s=new Ln(i,t,n,r),a=je(s);if(o?.[Dn]&&(a.fetch=o[Dn]),o?.timeout&&(a.timeout=o.timeout),o?.execute)for(let c of o.execute)c(s);return s}async function Fw(e,t){if(!(e instanceof URL))throw Ye('"server" must be an instance of URL',Nr);let n=!e.href.includes("/.well-known/"),r=t?.timeout??30,o=AbortSignal.timeout(r*1e3),i=await(n?rd(e,{algorithm:t?.algorithm,[Jt]:t?.[Dn],[Kt]:t?.execute?.includes(Ed),signal:o,headers:new Headers(Lr)}):(t?.[Dn]||fetch)((ei(e,!t?.execute?.includes(Ed)),e.href),{headers:Object.fromEntries(new Headers({accept:"application/json",...Lr}).entries()),body:void 0,method:"GET",redirect:"manual",signal:o})).then(s=>od(Vo,s)).catch(Ur);return n&&new URL(i.issuer).href!==e.href&&(jw(e,i,t)||Zw(e,t)||(()=>{throw new Un("discovered metadata issuer does not match the expected issuer",{code:ii,cause:{expected:e.href,body:i,attribute:"issuer"}})})()),i}function Hw(e){return{supportsPKCE:{__proto__:null,value(t="S256"){return e.code_challenge_methods_supported?.includes(t)===!0}}}}function Gw(e){Object.defineProperties(e,Hw(e))}var Ad=Symbol(),Ln=class{constructor(t,n,r,o){if(typeof n!="string"||!n.length)throw Ye('"clientId" must be a non-empty string',Nr);if(typeof r=="string"&&(r={client_secret:r}),r?.client_id!==void 0&&n!==r.client_id)throw Ye('"clientId" and "metadata.client_id" must be the same',Mr);let i={...structuredClone(r),client_id:n};i[Wo]=r?.[Wo]??0,i[Yo]=r?.[Yo]??30;let s;o?s=o:typeof i.client_secret=="string"&&i.client_secret.length?s=Mw(i.client_secret):s=Bw();let a=Object.freeze(i),c=structuredClone(t);Ad in t&&(c[_a]=({claims:{tid:l}})=>t.issuer.replace("{tenantid}",l));let u=Object.freeze(c);Ea||=new WeakMap,Ea.set(this,{__proto__:null,as:u,c:a,auth:s,tlsOnly:!0,jwksCache:{}})}serverMetadata(){let t=structuredClone(je(this).as);return Gw(t),t}clientMetadata(){return structuredClone(je(this).c)}get timeout(){return je(this).timeout}set timeout(t){je(this).timeout=t}get[Dn](){return je(this).fetch}set[Dn](t){je(this).fetch=t}};Object.freeze(Ln.prototype);function qw(e){let t;if(e.expires_in!==void 0){let n=new Date;n.setSeconds(n.getSeconds()+e.expires_in),t=n.getTime()}return{expiresIn:{__proto__:null,value(){if(t){let n=Date.now();return t>n?Math.floor((t-n)/1e3):0}}},claims:{__proto__:null,value(){return ni(e)}}}}function Kw(e){Object.defineProperties(e,qw(e))}function Ed(e){je(e).tlsOnly=!1}function Jw(e){return e=new URL(e),e.search="",e.hash="",e.href}function Vw(e,t){try{return Object.getPrototypeOf(e)[Symbol.toStringTag]===t}catch{return!1}}async function Sa(e,t,n,r,o){if(va(e),o?.flag!==si&&!(t instanceof URL)&&!Vw(t,"Request"))throw Ye('"currentUrl" must be an instance of URL, or Request',Nr);let i,s,{as:a,c,auth:u,fetch:l,tlsOnly:f,jarm:p,hybrid:g,nonRepudiation:w,timeout:x,decrypt:A,implicit:h}=je(e);if(o?.flag===si)i=o.authResponse,s=o.redirectUri;else{if(!(t instanceof URL)){let v=t;switch(t=new URL(t.url),v.method){case"GET":break;case"POST":let O=new URLSearchParams(await yd(v));if(g)t.hash=O.toString();else for(let[I,z]of O.entries())t.searchParams.append(I,z);break;default:throw Ye("unexpected Request HTTP method",Mr)}}switch(s=Jw(t),!0){case!!p:i=await p(t,n?.expectedState);break;case!!g:i=await g(t,n?.expectedNonce,n?.expectedState,n?.maxAge);break;case!!h:throw new TypeError("authorizationCodeGrant() cannot be used by response_type=id_token clients");default:try{i=bd(a,c,t.searchParams,n?.expectedState)}catch(v){Ur(v)}}}let _=await pd(a,c,u,i,s,n?.pkceCodeVerifier||ma,{additionalParameters:r,[Jt]:l,[Kt]:!f,DPoP:o?.DPoP,headers:new Headers(Lr),signal:Td(x)}).catch(Ur);(typeof n?.expectedNonce=="string"||typeof n?.maxAge=="number")&&(n.idTokenExpected=!0);let S=hd(a,c,_,{expectedNonce:n?.expectedNonce,maxAge:n?.maxAge,requireIdToken:n?.idTokenExpected,[qo]:A}),b;try{b=await S}catch(v){if(Ww(v,o))return Sa(e,void 0,n,r,{...o,flag:si,authResponse:i,redirectUri:s});Ur(v)}return b.id_token&&await w?.(_),Kw(b),b}function Rd(e,t){va(e);let{as:n,c:r,tlsOnly:o,hybrid:i,jarm:s,implicit:a}=je(e),c=ti(n,"authorization_endpoint",!1,o);if(t=new URLSearchParams(t),t.has("client_id")||t.set("client_id",r.client_id),!t.has("request_uri")&&!t.has("request")){if(t.has("response_type")||t.set("response_type",i?"code id_token":a?"id_token":"code"),a&&!t.has("nonce"))throw Ye("response_type=id_token clients must provide a nonce parameter in their authorization request parameters",Mr);s&&t.set("response_mode","jwt")}for(let[u,l]of t.entries())c.searchParams.append(u,l);return c}function va(e){if(!(e instanceof Ln))throw Ye('"config" must be an instance of Configuration',Nr);if(Object.getPrototypeOf(e)!==Ln.prototype)throw Ye("subclassing Configuration is not allowed",Mr)}function Td(e){return e?AbortSignal.timeout(e*1e3):void 0}function Ww(e,t){return t?.DPoP&&t.flag!==si?cd(e):!1}var si=Symbol();async function Pd(e,t,n){va(e);let{as:r,c:o,auth:i,fetch:s,tlsOnly:a,timeout:c}=je(e);return md(r,o,i,t,{[Jt]:s,[Kt]:!a,additionalParameters:new URLSearchParams(n),headers:new Headers(Lr),signal:Td(c)}).then(gd).catch(Ur)}var Od="oauth2:",Br="graffiti-auth-oauth2-data",ai=class{eventTarget=new EventTarget;constructor(){let t=this.completeOauth();(async()=>{await new Promise(r=>setTimeout(r,0)),await t;let n=new CustomEvent("initialized");this.eventTarget.dispatchEvent(n)})()}async login(...t){try{await this.login_(...t)}catch(n){let r=n instanceof Error?n:new Error("Unknown error"),o={loginId:t[1],error:r};this.eventTarget.dispatchEvent(new CustomEvent("login",{detail:o}))}}async login_(t,n,r,o){let i=await this.getAuthorizationConfiguration(t),s=r.map(encodeURIComponent).join(" "),a=Sd(),c,u;if(typeof window<"u"){c=window.location.href;let p={loginId:n,redirectUri:c,authorizationEndpoint:t,state:a,serviceEndpoints:r};window.localStorage.setItem(Br,JSON.stringify(p))}else{let g=(await import("node:http").catch(x=>{throw new Error("Unrecognized environment: cannot find window or node:http")})).createServer();try{await new Promise((x,A)=>{g.once("error",A),g.listen(0,"::1",x)})}catch{try{g.close()}catch{}throw new Error("Failed to start local oauth callback server.")}let w=g.address();if(!w){try{g.close()}catch{}throw new Error("Failed to get local oauth callback server address.")}c=typeof w=="string"?`http://${w}`:`http://${w.family==="IPv6"?`[${w.address}]`:w.address}:${w.port}`,u=new Promise((x,A)=>{let h=setTimeout(()=>{try{g.close()}catch{}A("Oauth callback timed out.")},3e5),_=new Set;g.on("connection",b=>{_.add(b),b.on("close",()=>{_.delete(b)})});let S=async(b,v)=>{try{let O=new URL(b.url??"/",c);await this.onCallbackUrl({loginId:n,callbackUrl:O,configuration:i,expectedState:a,serviceEndpoints:r}),v.statusCode=200,v.setHeader("Content-Type","text/plain"),v.end("You may now close this window.")}catch(O){throw v.statusCode=500,v.setHeader("Content-Type","text/plain"),v.end("Error processing OAuth callback."),O}finally{clearTimeout(h),g.off("request",S);for(let O of _)O.destroy();g.close(()=>x())}};g.on("request",S)})}let l=new URL(c);l.hash="",l.search="";let f=Rd(i,{scope:s,redirect_uri:l.toString(),state:a});typeof window<"u"?o==="assign"?window.location.assign(f.toString()):window.location.replace(f.toString()):(console.log("Please open the following URL in your browser:"),console.log(f.toString()),await u)}completeOauth(){if(typeof window>"u")return;let t=window.localStorage.getItem(Br);if(!t)return;let n;try{n=JSON.parse(t)}catch{console.error("Invalid OAuth2 login data in local storage."),window.localStorage.removeItem(Br);return}let r=Yw.safeParse(n);if(!r.success){console.error("Invalid OAuth2 login data structure in local storage.",r.error),window.localStorage.removeItem(Br);return}let{loginId:o,redirectUri:i,authorizationEndpoint:s,state:a,serviceEndpoints:c}=r.data;try{let u=new URL(i),l=new URL(window.location.href);if(u.pathname!==l.pathname)return;let f=l.searchParams;return!f.has("code")&&!f.has("error")?void 0:(window.history.replaceState({},document.title,u.toString()),window.localStorage.removeItem(Br),new Promise(p=>setTimeout(p,0)).then(()=>this.getAuthorizationConfiguration(s)).then(p=>this.onCallbackUrl({loginId:o,callbackUrl:l,configuration:p,expectedState:a,serviceEndpoints:c})).catch(p=>{let g=p instanceof Error?p:new Error("Unknown error"),w={loginId:o,error:g};this.eventTarget.dispatchEvent(new CustomEvent("login",{detail:w}))}))}catch(u){console.error(u)}}async onCallbackUrl(t){let{loginId:n,callbackUrl:r,configuration:o,expectedState:i,serviceEndpoints:s}=t,a=await Sa(o,r,{expectedState:i}),c=a.access_token,l=a.scope?.split(" ").map(decodeURIComponent)||s;if(!s.every(p=>l.includes(p)))throw new Error("Not all requested service endpoints were granted.");let f=new CustomEvent("login",{detail:{loginId:n,token:c}});this.eventTarget.dispatchEvent(f)}async logout(t,n,r){try{await this.logout_(t,n,r)}catch(o){let i=o instanceof Error?o:new Error("Unknown error"),s={logoutId:n,error:i};this.eventTarget.dispatchEvent(new CustomEvent("logout",{detail:s}))}}async logout_(t,n,r){let o=await this.getAuthorizationConfiguration(t);await Pd(o,r);let i={logoutId:n};this.eventTarget.dispatchEvent(new CustomEvent("logout",{detail:i}))}async getAuthorizationConfiguration(t){if(!t.startsWith(Od))throw new Error(`Unrecognized authorization endpoint method: ${t}`);let n=t.slice(Od.length),r;try{r=new URL(n)}catch{throw new Error("Invalid issuer URL.")}return await vd(r,"graffiti-client")}},kd=Eu(Se({loginId:B()}),ct([Se({token:B(),error:X(xu())}),Se({error:on(Error)})])),Id=Se({logoutId:B(),error:X(on(Error))}),zd=X(Ue(Se({error:X(on(Error))}))),Yw=Se({loginId:B(),redirectUri:Z(),authorizationEndpoint:Z(),state:B(),serviceEndpoints:q(Z())});var Xw="https://";function Ce(e){if(!e.startsWith(Xw))throw new Error("Unrecognized storage bucket endpoint type")}async function ci(e){Ce(e);let t=`${e}/auth`,n=await fetch(t);if(!n.ok)throw new Error("Failed to get storage bucket authorization endpoint");return await n.text()}var Vt=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorUnauthorized",Object.setPrototypeOf(this,e.prototype)}};async function Xe(...e){let t=await fetch(...e);if(!t.ok){let n;try{n=await t.text()}catch{n=t.statusText}throw t.status===401?new Vt(n):t.status===403?new mt(n):t.status===404?new Q(n):t.status===410?new Le(n):t.status===413?new gt(n):new Error(n)}return t}var Qw=32,eb=1024*1024,tb=2;function $d(e){return Math.min(Qw,Math.floor(eb/e))}var ui=class{getAuthorizationEndpoint=ci;queues=new Map;unsupportedBatchEndpoints=new Set;async put(t,n,r,o){Ce(t);let i=`${t}/value/${encodeURIComponent(n)}`;await Xe(i,{method:"PUT",headers:{"Content-Type":"application/octet-stream",Authorization:`Bearer ${o}`},body:r.slice()})}async delete(t,n,r){Ce(t);let o=`${t}/value/${encodeURIComponent(n)}`;await Xe(o,{method:"DELETE",headers:{Authorization:`Bearer ${r}`}})}async get(t,n,r){return Ce(t),r!==void 0&&Number.isSafeInteger(r)&&r>0&&$d(r)>=2&&!this.unsupportedBatchEndpoints.has(t)?new Promise((o,i)=>{let s=this.queues.get(t);s||(s=new Map,this.queues.set(t,s));let a=s.get(r);a||(a={requests:[]},s.set(r,a)),a.requests.push({key:n,resolve:o,reject:i}),a.requests.length===$d(r)?this.flush(t,r,a):a.timer===void 0&&(a.timer=setTimeout(()=>this.flush(t,r,a),tb))}):this.getOne(t,n,r)}flush(t,n,r){r.timer!==void 0&&clearTimeout(r.timer);let o=r.requests,i=this.queues.get(t);i.delete(n),i.size===0&&this.queues.delete(t),o.length===1||this.unsupportedBatchEndpoints.has(t)?o.forEach(({key:s,resolve:a,reject:c})=>{this.getOne(t,s,n).then(a,c)}):this.getBatch(t,n,o)}async getBatch(t,n,r){try{let o=await fetch(`${t}/values`,{method:"POST",headers:{"Content-Type":"application/cbor",Accept:"application/cbor"},body:pe({keys:r.map(({key:s})=>s),maxValueBytes:n}).slice()});if(o.status===404){this.unsupportedBatchEndpoints.add(t),await Promise.all(r.map(async({key:s,resolve:a,reject:c})=>{try{a(await this.getOne(t,s,n))}catch(u){c(u)}}));return}if(!o.ok)throw new Error(await o.text());let i=Ne(await o.arrayBuffer());if(!i||typeof i!="object"||!("results"in i)||!Array.isArray(i.results)||i.results.length!==r.length)throw new Error("Invalid storage batch response");i.results.forEach((s,a)=>{let{resolve:c,reject:u}=r[a];!s||typeof s!="object"||!("status"in s)?u(new Error("Invalid storage batch result")):s.status===200&&"value"in s&&s.value instanceof Uint8Array&&s.value.byteLength<=n?c(s.value):s.status===404?u(new Q("Value not found")):s.status===413?u(new gt("Value exceeds maximum byte limit")):u(new Error("Invalid storage batch result"))})}catch(o){r.forEach(({reject:i})=>i(o))}}async getOne(t,n,r){let o=`${t}/value/${encodeURIComponent(n)}`,i=await Xe(o),s=i.body?.getReader();if(!s)throw new Error("Failed to read value from storage bucket");let a=i.headers.get("Content-Length"),c=a?Number(a):void 0;if(!!c&&!!Number.isFinite(c)&&c>=0){let w=c;if(r!==void 0&&w>r)throw new Error("Value exceeds maximum byte limit");let x=new Uint8Array(w),A=0,h=!1;try{for(;A<=x.length;){let{done:_,value:S}=await s.read();if(_){h=!0;break}if(!S||S.length===0)continue;let b=A+S.length;if(b>x.length)throw new Error("Received more data than expected");x.set(S,A),A=b}}finally{s.releaseLock()}if(!h)throw new Error("Failed to read complete value from storage bucket");return A===w?x:x.slice(0,A)}let l=[],f=0;try{for(;;){let{done:w,value:x}=await s.read();if(w)break;if(!(!x||x.length===0)){if(f+=x.length,r!==void 0&&f>r)throw new Error("Value exceeds maximum byte limit");l.push(x.slice())}}}finally{s.releaseLock()}let p=new Uint8Array(f),g=0;for(let w of l)p.set(w,g),g+=w.length;return p}async*export(t,n){Ce(t);let r=`${t}/export`,o;for(;;){let s=await(await Xe(o?`${r}?cursor=${encodeURIComponent(o)}`:r,{headers:{Authorization:`Bearer ${n}`}})).blob(),a=Ne(await s.arrayBuffer()),c=nb.parse(a);for(let u of c.keys)yield{key:u};if(c.cursor)o=c.cursor;else break}}},nb=Se({keys:q(B()),cursor:X(Ue(B()))});var rb=ye({value:we({}),channels:q(B()),allowed:X(Ue(q(Z()))),url:Z(),actor:Z()}),Aa=Lt(e=>e instanceof Uint8Array),Cd=q(Aa),Mn="t",Ze="o",Nn="m",Dd=ye({[Mn]:Cd,[Ze]:rb,[Nn]:Aa}),jr="id",ft="m",Zr="l",li=ye({[jr]:B(),[ft]:Dd,[Zr]:_u()}),Ud=ye({id:B()}),Ld=ye({results:q(li),hasMore:rn(),cursor:B()});async function Ra(){try{return globalThis.indexedDB?(await new Promise((e,t)=>{let n=indexedDB.open("__idb_probe__",1);n.onupgradeneeded=()=>n.result.createObjectStore("k"),n.onsuccess=()=>{n.result.close(),e()},n.onerror=()=>t(n.error)}),!0):!1}catch{return!1}}function Fr(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}async function Nd(e,t,n,r,o=0){let i=r.messageIds.slice(o);return Promise.all(i.map(async s=>{let a=await e.messages.get(Fr(t,s));if(!a){try{await e.messageIds.del(n)}catch{}throw new Error("Cache out of sync - perhaps clear browser storage")}return a}))}async function Bd(e,t,n,r,o){await e.messages.setMany(o.messages.map(s=>[Fr(t,s[jr]),s]));let i={cursor:o.cursor,version:r?.version??crypto.randomUUID(),messageIds:[...r?.messageIds??[],...o.messages.map(s=>s[jr])],generation:crypto.randomUUID(),hasMore:o.hasMore,waitTil:o.waitTil};return await e.messageIds.set(n,i),i}async function jd(e,t,n){let r=pe({inboxUrl:e,type:t,body:n??null});return crypto.subtle.digest("SHA-256",new Uint8Array(r)).then(o=>Array.from(new Uint8Array(o)).map(i=>i.toString(16).padStart(2,"0")).join(""))}async function Md(){await new Promise(e=>{let t=indexedDB.deleteDatabase("graffiti-inbox-cache");t.onsuccess=()=>e(),t.onerror=()=>e(),t.onblocked=()=>e()})}async function Zd(){if(await Ra()){let{openDB:n}=await import("./build-KAK33G4E.js"),r=await n("graffiti-inbox-cache",1,{upgrade(o){o.objectStoreNames.contains("m")||o.createObjectStore("m"),o.objectStoreNames.contains("q")||o.createObjectStore("q")}});return{messages:{get:async o=>{try{return r.get("m",o)}catch(i){console.error("Error getting message from cache:",i),console.error("resetting cache..."),await Md();return}},set:async(o,i)=>{await r.put("m",i,o)},setMany:async o=>{if(o.length===0)return;let i=r.transaction("m","readwrite");await Promise.all([...o.map(([s,a])=>i.store.put(a,s)),i.done])},del:o=>r.delete("m",o)},messageIds:{get:async o=>{try{return await r.get("q",o)}catch(i){console.error("Error getting message IDs from cache:",i),console.error("resetting cache..."),await Md();return}},set:async(o,i)=>{await r.put("q",i,o)},del:o=>r.delete("q",o)}}}let e=new Map,t=new Map;return{messages:{get:async n=>e.get(n),set:async(n,r)=>{e.set(n,r)},setMany:async n=>{for(let[r,o]of n)e.set(r,o)},del:async n=>{e.delete(n)}},messageIds:{get:async n=>t.get(n),set:async(n,r)=>{t.set(n,r)},del:async n=>{t.delete(n)}}}}var ob=3e4,ib=3e4,fi=class{getAuthorizationEndpoint=ci;cache_=null;get cache(){return this.cache_||(this.cache_=Zd()),this.cache_}async send(t,n){Ce(t);let r=`${t}/send`,i=await(await Xe(r,{method:"PUT",headers:{"Content-Type":"application/cbor"},body:new Uint8Array(pe({m:n}))})).blob(),s=Ne(await i.arrayBuffer());return Ud.parse(s).id}async get(t,n,r){let o=Fr(t,n),i=await this.cache,s=await i.messages.get(o);if(s!==void 0)return s;let a=`${t}/message/${n}`,c=null;try{c=await Xe(a,{method:"GET",headers:{...r?{Authorization:`Bearer ${r}`}:{}}})}catch(p){if(p instanceof Q)return await i.messages.set(o,null),null;throw p}let u=await c.blob(),l=Ne(await u.arrayBuffer()),f=li.parse(l);return await i.messages.set(o,f),f}async label(t,n,r,o){if(Ce(t),o){let c=`${t}/label/${n}`;await Xe(c,{method:"PUT",headers:{"Content-Type":"application/cbor",Authorization:`Bearer ${o}`},body:new Uint8Array(pe({l:r}))})}let i=await this.cache,s=Fr(t,n),a=await i.messages.get(s);a&&await i.messages.set(s,{...a,l:r})}async fetchMessageBatch(t,n,r,o,i,s){let a=AbortSignal.timeout(ob),c=await Xe(`${t}/${n}${i?`?cursor=${encodeURIComponent(i)}`:""}`,{method:"POST",headers:{"Content-Type":"application/cbor",...o?{Authorization:`Bearer ${o}`}:{}},body:r,signal:s?AbortSignal.any([s,a]):a}),u=c.headers.get("Retry-After"),l=u?parseInt(u):void 0,f=l&&Number.isFinite(l)?Date.now()+l*1e3:void 0;return{response:c,waitTil:f}}async withQueryLock(t,n,r,o){if(!n)return r();let i=AbortSignal.timeout(ib),s=!1;try{return await window.navigator.locks.request(`graffiti:inbox:${t}`,{mode:"exclusive",signal:o?AbortSignal.any([o,i]):i},async()=>(s=!0,r()))}catch(a){throw!s&&i.aborted?new Error("Timed out waiting for another tab's inbox query",{cause:a}):a}}async*messageStreamer(t){let{inboxUrl:n,inboxToken:r}=t,o=t.kind==="export"?"export":"query",i=t.kind==="query"?t.schema:t.kind==="continue"?t.cursor.objectSchema:{},s=await so(i),a=t.kind==="query"?t.body:void 0,c=t.kind==="continue"?t.cursor.messageIdsCacheKey:await jd(n,o,a),u=t.kind==="continue"?t.cursor.version:void 0,l=await this.cache,f=typeof window<"u"&&await Ra(),p=await l.messageIds.get(c),g=p?.generation,w=p?.version,x=t.kind==="continue"?t.cursor.numSeen:0,A=!0,h=async S=>{for(;;){S?.throwIfAborted();let b=await this.withQueryLock(c,f,async()=>{S?.throwIfAborted();let v=await l.messageIds.get(c);if(u!==void 0&&u!==v?.version)throw new Le("Cursor is stale");if(v?.version!==w){if(!A)throw new Le("Cursor is stale");x=0}if(v?.generation&&v.generation!==g)return{query:v};if(v?.waitTil!==void 0&&v.waitTil>Date.now())return{waitTil:v.waitTil};let O;try{O=await this.fetchMessageBatch(n,o,A?a:void 0,r,v?.cursor,S)}catch(E){if(!(E instanceof Le&&v?.cursor)){if(A&&!S?.aborted)return{initialFetchError:E};throw E}if(!A||(await l.messageIds.del(c),u!==void 0))throw E;v=void 0,x=0,O=await this.fetchMessageBatch(n,o,a,r,void 0,S)}let I=Ne(new Uint8Array(await O.response.arrayBuffer())),{results:z,hasMore:V,cursor:K}=Ld.parse(I),m=z.map(E=>{let U=E[ft][Ze];if(!s(U))throw new Error("Server returned data that does not match schema");return{...E,[ft]:{...E[ft],[Ze]:U}}});return v=await Bd(l,n,c,v,{messages:m,cursor:K,hasMore:V,waitTil:O.waitTil}),{query:v}},S);if("initialFetchError"in b)throw console.error("Unexpected error in stream, waiting 5 seconds before continuing..."),await new Promise(v=>setTimeout(v,5e3)),b.initialFetchError;if("waitTil"in b){await ab(b.waitTil);continue}return b.query}},_;for(;;){let S=_?await _:await h().then(z=>({query:z}),z=>({error:z}));if(_=void 0,"error"in S)throw S.error;let b=S.query,v=await Nd(l,n,c,b,x);x=b.messageIds.length,g=b.generation,w=b.version,A=!1;let O=new AbortController;b.hasMore&&(_=h(O.signal).then(z=>({query:z}),z=>({error:z})));let I=!1;try{for(let z of v)yield z;I=!0}finally{I||O.abort()}if(!b.hasMore){let z={numSeen:x,version:b.version,messageIdsCacheKey:c,objectSchema:i};return JSON.stringify(z)}}}query(t,n,r,o){Ce(t);let i=new Uint8Array(pe({tags:n,schema:r}));return this.messageStreamer({kind:"query",inboxUrl:t,body:i,schema:r,inboxToken:o})}continueQuery(t,n,r){Ce(t);let o=JSON.parse(n),i=sb.parse(o);return this.messageStreamer({kind:"continue",inboxUrl:t,cursor:i,inboxToken:r})}export(t,n){return Ce(t),this.messageStreamer({kind:"export",inboxUrl:t,inboxToken:n})}},sb=ye({messageIdsCacheKey:B(),version:B(),numSeen:nn().check(Ut()),objectSchema:ct([we({}),rn()])});async function ab(e){if(e!==void 0){let t=e-Date.now();t>0&&await new Promise(n=>setTimeout(n,t))}}var Bn="base64url";var di=class{async encode(t,n){if(t!==Bn)throw new Error(`Unsupported string encoding method: ${t}`);return"u"+btoa(String.fromCodePoint(...n)).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=+$/,"")}async decode(t){if(!t.startsWith("u"))throw new Error(`Unsupported string encoding prefix: ${t[0]}`);t=t.slice(1);let n=t.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4!==0;)n+="=";return Uint8Array.from(atob(n),r=>r.charCodeAt(0))}};function Fd(){let t=(typeof globalThis=="object"?globalThis.crypto:null)?.subtle;if(typeof t=="object"&&t!=null)return t;throw new Error("crypto.subtle must be defined")}function Hd(e,t,n){let r=async o=>{Qn(o);let i=Fd();return new Uint8Array(await i.digest(e,o))};return r.webCryptoName=e,r.outputLen=n,r.blockLen=t,r.create=()=>{throw new Error("not implemented")},Object.freeze(r)}function cb(e){zu(e);let t=e.webCryptoName;if(typeof t!="string")throw new Error("non-web hash");return t}var Wt=Hd("SHA-256",64,32);var Gd=Hd("SHA-512",128,64),Ta=(()=>{let e=async(t,n,r)=>{let o=Fd();Qn(n,void 0,"key"),Qn(r,void 0,"message");let i=cb(t),s=Iu(r);try{let a=await o.importKey("raw",n,{name:"HMAC",hash:i},!1,["sign"]);return new Uint8Array(await o.sign("HMAC",a,s))}finally{$u(s)}};return e.create=(t,n)=>{throw new Error("not implemented")},e})();var pi="sha2-256",Hr=18,jn=32,hi=class{async register(t,n){if(t!==pi)throw new Error(`Unsupported content address method: ${t}`);let r=await Wt(n),o=new Uint8Array(2+r.length);return o[0]=Hr,o[1]=jn,o.set(r,2),o}async getMethod(t){if(t[0]===Hr&&t[1]===jn&&t.length===2+jn)return pi;throw new Error("Unrecognized content address format.")}};var Yd=Object.freeze,Zn=0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,yi=0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,mi=0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Oa=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,ka=0x6666666666666666666666666666666666666666666666666666666666666658n,gi=Zn-1n,ub=Yd({p:Zn,n:yi,h:8n,a:gi,d:mi,Gx:Oa,Gy:ka}),Gr=32,qd=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&e.BYTES_PER_ELEMENT===1,et=(e,t,n="")=>{if(qd(e)&&(t===void 0||e.length===t))return e;let r=qd(e),o=t!==void 0?` of length ${t}`:"",i=r?`length=${e.length}`:`type=${typeof e}`,s=(n?`"${n}" `:"")+"expected Uint8Array"+o+", got "+i;throw r?new RangeError(s):new TypeError(s)},Ia=(e,t="",n)=>Uint8Array.from(et(e,n,t)),Xd=(e,t)=>e.toString(16).padStart(t,"0"),Qd=e=>{let t="";for(let n of et(e))t+=Xd(n,2);return t},ep=e=>{let t="hex invalid";if(typeof e!="string")throw new TypeError(t);if(e.length%2||!/^[\da-f]*$/i.test(e))throw new RangeError(t);let n=new Uint8Array(e.length/2);for(let r=0,o=0;r<n.length;r++,o+=2){let i=e.charCodeAt(o),s=e.charCodeAt(o+1);n[r]=((i&15)+(i>>6)*9)*16+(s&15)+(s>>6)*9}return n},qr=(...e)=>{let t=0;for(let o of e)t+=et(o).length;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.length;return n};var Yt=(e,t,n,r="bad number: out of range")=>{if(typeof e!="bigint")throw new TypeError(r);if(t<=e&&e<n)return e;throw new RangeError(r)},Y=(e,t=Zn)=>(e%=t)>=0n?e:t+e,Kd=(1n<<255n)-1n,k=e=>{if(e<0n)throw new RangeError("negative coordinate");let t=(e>>255n)*19n+(e&Kd);return t=(t>>255n)*19n+(t&Kd),t%Zn},tp=e=>Y(e,yi),lb=(e,t)=>{if(e===0n)throw new Error("invert: expected non-zero number");if(t<=1n)throw new Error("invert: expected modulus > 1, got "+t);let n=Y(e,t),r=t,o=0n,i=1n;for(;n!==0n;){let a=r/n,c=r-n*a,u=o-i*a;r=n,n=c,o=i,i=u}if(r!==1n)throw new Error("invert: does not exist");return Y(o,t)},fb=e=>{let t=Ca[e];if(typeof t!="function")throw new Error("hashes."+e+" not set");return t};var za=async(e,...t)=>et(await fb(e)(qr(...t)),64,"digest");var Pa=e=>{if(e instanceof dt)return e;throw new TypeError("Point expected")},np=2n**256n,dt=class e{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,r,o){let i=np;this.X=Yt(t,0n,i),this.Y=Yt(n,0n,i),this.Z=Yt(r,1n,i),this.T=Yt(o,0n,i),Yd(this)}static CURVE(){return ub}static fromAffine(t){return new e(t.x,t.y,1n,k(t.x*t.y))}static fromBytes(t,n=!1){let r=Ia(t,"point",Gr),o=r[31];r[31]=o&-129;let i=$a(r);n||Yt(i,0n,Zn);let s=k(i*i),a=Y(s-1n),c=k(mi*s+1n),{isValid:u,value:l}=pb(a,c);if(!u)throw new Error("bad point: y not sqrt");let f=!!(o&128);if(!n&&l===0n&&f)throw new Error("bad point: x==0, isLastByteOdd");return f!==!!(l&1n)&&(l=Y(-l)),new e(l,i,1n,k(l*i))}static fromHex(t,n){return e.fromBytes(ep(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){let t=gi,n=mi,r=this;if(r.is0())throw new Error("bad point: ZERO");let{X:o,Y:i,Z:s,T:a}=r,c=k(o*o),u=k(i*i),l=k(s*s),f=k(l*l),p=k(c*t),g=k(l*(p+u)),w=Y(f+k(n*k(c*u)));if(g!==w)throw new Error("bad point: equation left != right (1)");let x=k(o*i),A=k(s*a);if(x!==A)throw new Error("bad point: equation left != right (2)");return this}equals(t){let{X:n,Y:r,Z:o}=this,{X:i,Y:s,Z:a}=Pa(t);return k(n*a)===k(i*o)&&k(r*a)===k(s*o)}is0(){return this.equals(Xt)}negate(){return new e(Y(-this.X),this.Y,this.Z,Y(-this.T))}double(){let{X:t,Y:n,Z:r}=this,o=gi,i=k(t*t),s=k(n*n),a=k(2n*r*r),c=k(o*i),u=Y(t+n),l=Y(k(u*u)-i-s),f=Y(c+s),p=Y(f-a),g=Y(c-s),w=k(l*p),x=k(f*g),A=k(l*g),h=k(p*f);return new e(w,x,h,A)}add(t){let{X:n,Y:r,Z:o,T:i}=this,{X:s,Y:a,Z:c,T:u}=Pa(t),l=gi,f=mi,p=k(n*s),g=k(r*a),w=k(k(i*f)*u),x=k(o*c),A=Y(k(Y(n+r)*Y(s+a))-p-g),h=Y(x-w),_=Y(x+w),S=Y(g-k(l*p)),b=k(A*h),v=k(_*S),O=k(A*S),I=k(h*_);return new e(b,v,I,O)}subtract(t){return this.add(Pa(t).negate())}multiply(t,n=!0){if(!n&&t===0n||(Yt(t,1n,yi),!n&&this.is0()))return Xt;if(t===1n)return this;if(this.equals(Rt))return bb(t).p;let r=Xt,o=Rt,i=this;for(let s=0;n?s<256:t>0n;s++)t&1n?r=r.add(i):n&&(o=o.add(i)),i=i.double(),t>>=1n;return r}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){let{X:t,Y:n,Z:r}=this;if(this.equals(Xt))return{x:0n,y:1n};let o=lb(r,Zn);if(k(r*o)!==1n)throw new Error("invalid inverse");return{x:k(t*o),y:k(n*o)}}toBytes(){let{x:t,y:n}=this.toAffine(),r=rp(n);return r[31]|=t&1n?128:0,r}toHex(){return Qd(this.toBytes())}clearCofactor(){return this.multiply(8n,!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return this.multiply(yi/2n,!1).double().add(this).is0()}},Rt=new dt(Oa,ka,1n,Y(Oa*ka)),Xt=new dt(0n,1n,1n,0n);dt.BASE=Rt;dt.ZERO=Xt;var rp=e=>ep(Xd(Yt(e,0n,np),64)).reverse(),$a=e=>BigInt("0x"+Qd(Uint8Array.from(et(e)).reverse())),Qe=(e,t)=>{let n=e;for(;t-- >0;)n=k(n*n);return n},db=e=>{let t=k(e*e),n=k(t*e),r=k(Qe(n,2)*n),o=k(Qe(r,1)*e),i=k(Qe(o,5)*o),s=k(Qe(i,10)*i),a=k(Qe(s,20)*s),c=k(Qe(a,40)*a),u=k(Qe(c,80)*c),l=k(Qe(u,80)*c),f=k(Qe(l,10)*i);return k(Qe(f,2)*e)},Jd=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,pb=(e,t)=>{let n=k(t*k(t*t)),r=k(k(n*n)*t),o=db(k(e*r)),i=k(e*k(n*o)),s=k(t*k(i*i)),a=i,c=k(i*Jd),u=s===e,l=s===Y(-e),f=s===Y(-e*Jd);return u&&(i=a),(l||f)&&(i=c),(Y(i)&1n)===1n&&(i=Y(-i)),{isValid:u||l,value:i}},wi=e=>tp($a(e)),hb=e=>{let t=Ia(e),n=t.slice(0,32);n[0]&=248,n[31]&=127,n[31]|=64;let r=t.slice(32),o=wi(n),i=Rt.multiply(o),s=i.toBytes();return{head:n,prefix:r,scalar:o,point:i,pointBytes:s}},op=e=>za("sha512Async",et(e,Gr,"secretKey")).then(hb);var ip=e=>op(e).then(t=>t.pointBytes);var sp=async e=>e[1](await za("sha512Async",e[0]));var mb=(e,t,n)=>{let{pointBytes:r,scalar:o}=e,i=wi(t),s=Rt.multiply(i).toBytes();return[qr(s,r,n),u=>{let l=tp(i+wi(u)*o);return et(qr(s,rp(l)),64)}]},ap=async(e,t)=>{let n=Ia(e,"message"),r=await op(t);return sp(mb(r,await za("sha512Async",r.prefix,n),n))};var gb=e=>{if(e===null||typeof e!="object")throw new TypeError("expected valid options object");return e.zip215??!0},yb=(e,t,n,r)=>{e=et(e,64,"signature"),t=et(t,void 0,"message"),n=et(n,Gr,"publicKey");let o=gb(r),i=e.subarray(0,Gr),s=$a(e.subarray(Gr,64)),a,c,u,l=Uint8Array.of(),f=!1;try{a=dt.fromBytes(n,o),c=dt.fromBytes(i,o),u=Rt.multiply(s,!1),l=qr(i,n,t),f=!0}catch{}return[l,g=>{if(!f||!o&&a.isSmallOrder())return!1;let w=wi(g);return c.add(a.multiply(w,!1)).subtract(u).clearCofactor().is0()}]},cp=async(e,t,n,r={})=>sp(yb(e,t,n,r));var Ca={sha512Async:async e=>{let t=globalThis?.crypto?.subtle;if(!t)throw new Error("crypto.subtle must be defined, consider polyfill");return new Uint8Array(await t.digest("SHA-512",qr(e)))},sha512:void 0};var wb=()=>{let e=[],t=Rt,n;for(let r=0;r<33;r++){n=t,e.push(n);for(let o=1;o<128;o++)n=n.add(t),e.push(n);t=n.double()}return e},Vd,Wd=(e,t)=>{let n=t.negate();return e?n:t},bb=e=>{let t=Vd||(Vd=wb()),n=Xt,r=Rt;for(let o=0;o<33;o++){let i=Number(e&255n);e>>=8n,i>128&&(i-=256,e+=1n);let s=o*128,a=s+Math.abs(i)-1,c=o%2!==0,u=i<0;i===0?r=r.add(Wd(c,t[s])):n=n.add(Wd(u,t[a]))}if(e!==0n)throw new Error("invalid wnaf");return{p:n,f:r}};Ca.sha512Async=Gd;var Qt="pk:sha2-256+ed25519",Da=0,bi=class{async register(t,n){if(t!==Qt)throw new Error(`Unsupported channel attestation method: ${t}`);let r=await this.channelToPrivateKey(n);return await this.channelPublicIdFromPrivateKey(r)}async getMethod(t){if(t[0]===Da)return Qt;throw new Error("Unrecognized channel attestation method.")}async channelToPrivateKey(t){let n=new TextEncoder().encode(t);return await Wt(n)}async channelPublicIdFromPrivateKey(t){let n=await ip(t),r=new Uint8Array(n.length+1);return r[0]=Da,r.set(n,1),r}async attest(t,n,r){if(t!==Qt)throw new Error(`Unsupported channel attestation method: ${t}`);let o=await this.channelToPrivateKey(r),i=await this.channelPublicIdFromPrivateKey(o),s=new TextEncoder().encode(n);return{attestation:await ap(s,o),channelPublicId:i}}async validate(t,n,r){let o=r[0];if(o!==Da)throw new Error(`Unrecognized channel attestation method prefix: ${o}`);return await cp(t,new TextEncoder().encode(n),r.slice(1))}};var Ua="hmac:sha2-256",up=0,_i=class{async attest(t,n){if(t!==Ua)throw new Error(`Unsupported allowed attestation method: ${t}`);let r=Mt(),o=await Ta(Wt,r,new TextEncoder().encode(n)),i=new Uint8Array(r.length+3);return i[0]=up,i[1]=Hr,i[2]=jn,i.set(r,3),{attestation:o,ticket:i}}async validate(t,n,r){let o=r[0],i=r[1],s=r[2];if(o!==up||i!==Hr||s!==jn)throw new Error("Unrecognized allowed ticket format");let a=await Ta(Wt,r.slice(3),new TextEncoder().encode(n));return t.length!==a.length?!1:a.every((c,u)=>t[u]===c)}};var La="did:web:",xi=class{constructor(t){this.services=t}services;actorToHandle=async t=>{let r=(await this.services.dids.resolve(t)).alsoKnownAs?.find(s=>s.startsWith(La));if(!r)throw new Q(`Handle for actor DID ${t} not found`);let o=r.slice(La.length),i=await this.services.dids.resolve(r);if(!i.alsoKnownAs||!i.alsoKnownAs.includes(t))throw new Error(`Handle ${o} does not match actor ${t}`);return o};handleToActor=async t=>{let n=`${La}${t}`,o=(await this.services.dids.resolve(n)).alsoKnownAs?.at(0);if(!o)throw new Q(`Actor for handle DID ${n} not found`);let i=await this.services.dids.resolve(o);if(!i.alsoKnownAs||!i.alsoKnownAs.includes(n))throw new Error(`Actor ${o} does not match handle ${t}`);return o}};function Ei(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)r!=="__proto__"&&(e[r]=n[r])}return e}var _b={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function Ma(e,t){function n(o,i,s){if(!(typeof document>"u")){s=Ei({},t,s),typeof s.expires=="number"&&(s.expires=new Date(Date.now()+s.expires*864e5)),s.expires&&(s.expires=s.expires.toUTCString()),o=encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var c in s)s[c]&&(a+="; "+c,s[c]!==!0&&(a+="="+s[c].split(";")[0]));return document.cookie=o+"="+e.write(i,o)+a}}function r(o){if(!(typeof document>"u"||arguments.length&&!o)){for(var i=document.cookie?document.cookie.split("; "):[],s={},a=0;a<i.length;a++){var c=i[a].split("="),u=c.slice(1).join("=");try{var l=decodeURIComponent(c[0]);if(l in s||(s[l]=e.read(u,l)),o===l)break}catch{}}return o?s[o]:s}}return Object.create({set:n,get:r,remove:function(o,i){n(o,"",Ei({},i,{expires:-1}))},withAttributes:function(o){return Ma(this.converter,Ei({},this.attributes,o))},withConverter:function(o){return Ma(Ei({},this.converter,o),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var Si=Ma(_b,{path:"/"});var xb=365;function lp(e,t){Si.set(e,t,dp())}function fp(e){return Si.get(e)}function Na(e){Si.remove(e,dp())}function dp(){let e={expires:xb,path:"/",sameSite:"lax"};return typeof window<"u"&&window.location.protocol==="https:"&&(e.sameSite="none",e.secure=!0),e}var Ti="GraffitiInbox",Oi="GraffitiStorageBucket",Fa="#graffitiPersonalInbox",ki="#graffitiStorageBucket",Eb="#graffitiSharedInbox_",Pi=class{constructor(t){this.services=t;let n=new Promise(o=>{this.services.authorization.eventTarget.addEventListener("initialized",i=>{if(!(i instanceof CustomEvent))return;let s=zd.safeParse(i.detail);if(!s.success)return;let a=s.data?.error;a&&console.error(a),o()})});this.services.authorization.eventTarget.addEventListener("login",this.onLogin.bind(this)),this.services.authorization.eventTarget.addEventListener("logout",this.onLogout.bind(this));let r;if(typeof window<"u"){let o=new URLSearchParams(window.location.search).get("actor");if(o)try{let i=decodeURIComponent(o),s=new URL(window.location.toString());s.searchParams.delete("actor"),window.history.replaceState({},"",s.toString()),r=this.login(i,"replace")}catch(i){console.error("Error decoding actor:",i)}}(async()=>{await new Promise(i=>setTimeout(i,0)),await r;for(let i of this.loggedInSessions){let s=new CustomEvent("login",{detail:{session:{actor:i.actor}}});this.sessionEvents.dispatchEvent(s)}await n;let o=new CustomEvent("initialized");this.sessionEvents.dispatchEvent(o)})()}services;sessionEvents=new EventTarget;initialAuthorizationNavigation="assign";inProgressLogin=void 0;inProgressLogout=void 0;async login(t,n=this.initialAuthorizationNavigation){try{await this.login_(t,n)}catch(r){let o=new CustomEvent("login",{detail:{error:r instanceof Error?r:new Error(String(r)),session:{actor:t}}});this.sessionEvents.dispatchEvent(o)}}async login_(t,n){if(this.loggedInSessions.find(b=>b.actor===t)){this.sessionEvents.dispatchEvent(new CustomEvent("login",{detail:{session:{actor:t}}}));return}let i=(await this.services.dids.resolve(t)).service;if(!i)throw new Error(`No services found in actor document for ${t}`);let s=i.find(b=>b.id===ki&&b.type===Oi),a=i.find(b=>b.id===Fa&&b.type===Ti),c=i.filter(b=>b.id.match(new RegExp(`^${Eb}\\d+$`))&&b.type===Ti);if(!a||!s||c.length===0)throw new Error(`Required services not found in actor document for ${t}`);let u=ja(s),l=ja(a),f=c.map(ja),p=[{endpoint:u,type:"bucket"},{endpoint:l,type:"personal-inbox"},...f.map(b=>({endpoint:b,type:"shared-inbox"}))],g=await Promise.all(p.map(async({endpoint:b,type:v})=>{let O=await(v==="bucket"?this.services.storageBuckets.getAuthorizationEndpoint(b):this.services.inboxes.getAuthorizationEndpoint(b));return{endpoint:b,authorizationEndpoint:O,type:v}})),w=new Map;g.forEach(({authorizationEndpoint:b,endpoint:v,type:O})=>{w.has(b)||w.set(b,[]),w.get(b).push({endpoint:v,type:O})});let x=[...w.entries()],h={...{actor:t},tokens:[],servicesByAuthorization:x};typeof window<"u"?window.localStorage.setItem(vi,JSON.stringify(h)):this.inProgressLogin=h;let[_,S]=x[0];await this.services.authorization.login(_,t,S.map(b=>b.endpoint),n)}async onLogin(t){if(!(t instanceof CustomEvent))return;let n=kd.safeParse(t.detail);if(!n.success)return;let r=n.data.loginId;try{await this.onLogin_(n.data)}catch(o){let i=new CustomEvent("login",{detail:{error:o instanceof Error?o:new Error(String(o)),session:{actor:r}}});this.sessionEvents.dispatchEvent(i)}}async onLogin_(t){if(t.error)throw t.error;let n=t.token,r=t.loginId,o;if(typeof window<"u"){let i=window.localStorage.getItem(vi);if(!i)throw new Error("No in-progress login found");let s=JSON.parse(i);o=Za.parse(s)}else{if(!this.inProgressLogin)throw new Error("No in-progress login found");o=this.inProgressLogin}if(o.actor!==r)throw new Error("Actor mismatch in login response - concurrent logins?");if(o.tokens.push(n),o.tokens.length===o.servicesByAuthorization.length){typeof window>"u"?this.inProgressLogin=void 0:window.localStorage.removeItem(vi);let i=o.servicesByAuthorization.flatMap(([u,l],f)=>l.map(p=>({token:o.tokens[f],serviceEndpoint:p.endpoint,authorizationEndpoint:u,type:p.type}))),s={...o,storageBucket:i.find(u=>u.type==="bucket"),personalInbox:i.find(u=>u.type==="personal-inbox"),sharedInboxes:i.filter(u=>u.type==="shared-inbox")},a=this.loggedInSessions;a.push(s),this.loggedInSessions=a;let c=new CustomEvent("login",{detail:{session:{actor:r}}});this.sessionEvents.dispatchEvent(c)}else{typeof window<"u"?window.localStorage.setItem(vi,JSON.stringify(o)):this.inProgressLogin=o;let[i,s]=o.servicesByAuthorization[o.tokens.length];await this.services.authorization.login(i,r,s.map(a=>a.endpoint),"replace")}}async logout(t){try{await this.logout_(t)}catch(n){let r=new CustomEvent("logout",{detail:{error:n instanceof Vt?void 0:n instanceof Error?n:new Error(String(n)),actor:t}});this.sessionEvents.dispatchEvent(r)}}async logout_(t){let n=this.loggedInSessions.find(s=>s.actor===t);if(!n)throw new Error(`No session found for actor ${t}`);this.loggedInSessions=this.loggedInSessions.filter(s=>s.actor!==t);let r=n.tokens.pop();if(!r)throw new Error("No tokens found in session");typeof window<"u"?window.localStorage.setItem(Ai,JSON.stringify(n)):this.inProgressLogout=n;let[o,i]=n.servicesByAuthorization[n.tokens.length];await this.services.authorization.logout(o,t,r)}async onLogout(t){if(!(t instanceof CustomEvent))return;let n=Id.safeParse(t.detail);if(!n.success)return;let r=n.data.logoutId;try{await this.onLogout_(n.data)}catch(o){let i=new CustomEvent("logout",{detail:{error:o instanceof Error?o:new Error(String(o)),actor:r}});this.sessionEvents.dispatchEvent(i)}}async onLogout_(t){if(t.error)throw t.error;let n=t.logoutId,r;if(typeof window<"u"){let i=window.localStorage.getItem(Ai);if(!i)throw new Error("No in-progress logout found");let s=JSON.parse(i);r=Za.parse(s)}else{if(!this.inProgressLogout)throw new Error("No in-progress logout found");r=this.inProgressLogout}if(r.actor!==n)throw new Error("Actor mismatch in logout response - concurrent logouts?");let o=r.tokens.pop();if(o){typeof window<"u"?window.localStorage.setItem(Ai,JSON.stringify(r)):this.inProgressLogout=r;let[i,s]=r.servicesByAuthorization[r.tokens.length];await this.services.authorization.logout(i,n,o)}else{typeof window>"u"?this.inProgressLogout=void 0:window.localStorage.removeItem(Ai);let i=new CustomEvent("logout",{detail:{actor:n}});this.sessionEvents.dispatchEvent(i)}}get loggedInSessions(){if(typeof window>"u")return pp;let t=fp(Ri);if(!t)return[];let n;try{n=JSON.parse(t)}catch{return console.error("Error parsing stored session data"),Na(Ri),[]}let r=q(Ab).safeParse(n);return r.success?r.data:(console.error("Stored session data is invalid"),Na(Ri),[])}set loggedInSessions(t){if(typeof window>"u"){pp=t;return}lp(Ri,JSON.stringify(t))}resolveSession(t){let n=this.loggedInSessions.find(r=>r.actor===t.actor);if(!n){let r=new CustomEvent("logout",{detail:{actor:t.actor}});throw this.sessionEvents.dispatchEvent(r),new Error("Not logged in")}return n}},pp=[],vi="graffiti-login-in-progress",Ai="graffiti-logout-in-progress",Ri="graffiti-sessions-logged-in",Sb=Se({actor:Z()}),Ba=Se({token:B(),serviceEndpoint:Z(),authorizationEndpoint:Z()}),vb=q(me([Z(),q(Se({endpoint:Z(),type:vu(["bucket","personal-inbox","shared-inbox"])}))])),Za=at(Sb,{tokens:q(B()),servicesByAuthorization:vb}),Ab=at(Za,{storageBucket:Ba,personalInbox:Ba,sharedInboxes:q(Ba)});function ja(e){if(typeof e.serviceEndpoint=="string")return e.serviceEndpoint;throw new Error(`Service endpoint for ${e.id} is not a string`)}var Ii=32*1024,zi=class{constructor(t){this.primitives=t}primitives;async encode(t,n){t=Va(t);let r=[...new Set(t.channels)],o=await Promise.all(r.map(x=>this.primitives.channelAttestations.attest(Qt,n,x))),i=o.map(x=>x.attestation),s=o.map(x=>x.channelPublicId),a={[Ga]:t.value,[qa]:i,[gp]:Mt(32)},c;if(Array.isArray(t.allowed)){let x=await Promise.all(t.allowed.map(async A=>this.primitives.allowedAttestations.attest(Ua,A)));a[Ka]=x.map(A=>A.attestation),c=x.map(A=>A.ticket)}let u=pe(a);if(u.byteLength>Ii)throw new Error("The object is too large");let l=await this.primitives.contentAddresses.register(pi,u),f=await this.primitives.stringEncoder.encode(Bn,l),p=Tb(n,f),g=[new TextEncoder().encode(p),...s];return{object:{value:t.value,channels:r,url:p,actor:n,...t.allowed?{allowed:t.allowed}:{}},tags:g,objectBytes:u,allowedTickets:c}}async validate(t,n,r,o){if(r.byteLength>Ii)throw new Error("Object is too big");let{actor:i,contentAddress:s}=Wa(t.url);if(i!==t.actor)throw new Error("Object actor does not match URL actor");let a=n.at(0);if(!a)throw new Error("No object URL tag");if(new TextDecoder().decode(a)!==t.url)throw new Error("Object URL tag does not match object URL");let c=n.slice(1),u=await this.primitives.stringEncoder.decode(s),l=await this.primitives.contentAddresses.getMethod(u),f=await this.primitives.contentAddresses.register(l,r);if(f.length!==u.length||!f.every((S,b)=>S===u[b]))throw new Error("Content address is invalid");let p=Ne(r),g=Rb.parse(p),w=g[Ga],x=g[qa],A=g[Ka],h=pe(w),_=pe(t.value);if(h.length!==_.length||!h.every((S,b)=>S===_[b]))throw new Error("Object value does not match storage value");if(x.length!==c.length)throw new Error("Not as many channel attestations and public ids");for(let[S,b]of x.entries()){let v=c[S];if(!await this.primitives.channelAttestations.validate(b,i,v))throw new Error("Invalid channel attestation")}if(t.channels.length){if(t.channels.length!==c.length)throw new Error("Number of claimed channels does not match attestations/public IDs");let S=await this.primitives.channelAttestations.getMethod(c[0]),b=await Promise.all(t.channels.map(v=>this.primitives.channelAttestations.register(S,v)));for(let[v,O]of b.entries()){let I=c[v];if(O.length!==I.length||!O.every((z,V)=>z===I[V]))throw new Error("Channel public id does not match expected")}}if(o){if(!A)throw new Error("Object is public but thought to be private");let S,b,v;if("recipient"in o?(S=[o.recipient],b=[o.allowedTicket],v=A.filter((O,I)=>I===o.allowedIndex)):(S=[...t.allowed??[]],b=o.allowedTickets,v=A),S.length!==t.allowed?.length)throw new Error("Recipient count does not match object allowed list");if(!S.every(O=>t.allowed?.includes(O)))throw new Error("Recipient not in object allowed list");for(let[O,I]of S.entries()){let z=b.at(O),V=v.at(O);if(!z)throw new Error("Missing allowed ticket for recipient");if(!V)throw new Error("Missing allowed attestation for recipient");if(!await this.primitives.allowedAttestations.validate(V,I,z))throw new Error("Invalid allowed attestation for recipient")}}else if(A)throw new Error("Object is private but no recipient info provided")}},Ga="v",qa="c",Ka="a",gp="n",Ha=Lt(e=>e instanceof Uint8Array),Rb=ye({[Ga]:we({}),[qa]:q(Ha),[Ka]:X(q(Ha)),[gp]:Ha}),Ja="graffiti:";function hp(e){let t=e.replace(/:/g,"!").replace(/\//g,"~");return encodeURIComponent(t)}function mp(e){return decodeURIComponent(e).replace(/!/g,":").replace(/~/g,"/")}function Tb(e,t){return`${Ja}${hp(e)}:${hp(t)}`}function Wa(e){if(!e.startsWith(Ja))throw new Error("Invalid object URL");let n=e.slice(Ja.length).split(":");if(n.length!==2)throw new Error("Invalid object URL format");let[r,o]=n;return{actor:mp(r),contentAddress:mp(o)}}function Va(e){return e===void 0?null:Array.isArray(e)?e.map(Va):typeof e=="object"?Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0).map(([t,n])=>[t,Va(n)])):e}var yp=class{dialog=document.createElement("dialog");shadow;main_;useTemplateHTML;templates_;onManualClose;displayTemplateSeq=0;constructor(e){this.useTemplateHTML=e.useTemplateHTML,this.onManualClose=e.onManualClose,this.dialog.className="graffiti-modal",this.dialog.setAttribute("aria-label",e.ariaLabel??"Graffiti dialog"),this.dialog.addEventListener("cancel",()=>this.onManualClose?.()),this.dialog.addEventListener("click",n=>{if("pointerType"in n&&!n.pointerType)return;let r=this.dialog.getBoundingClientRect();(r.top>n.clientY||r.left>n.clientX||n.clientY>r.top+r.height||n.clientX>r.left+r.width)&&(this.close(),this.onManualClose?.())});let t=document.createElement("div");this.shadow=t.attachShadow({mode:"closed"}),this.shadow.appendChild(this.dialog),document.body.append(t)}get templates(){return this.templates_||(this.main_,this.templates_=new Promise(async e=>e(await this.useTemplateHTML())).then(e=>{let t=new DOMParser().parseFromString(e,"text/html"),n=new Map;return t.querySelectorAll("template").forEach(r=>{let o=r.id;o&&n.set(o,r)}),n})),this.templates_}get main(){return this.main_||(this.templates_,this.main_=Promise.all([import("./style-EDM5B7ME-CSVOYXSW.js"),import("./graffiti-KV3G3O72-QD3APAKT.js"),import("./rock-salt-LI7DAH66-M6W5PPFD.js")]).then(async([{default:e},{default:t},{default:n}])=>{let r=document.createElement("header"),o=document.createElement("button");o.className="secondary",o.textContent="Close",o?.addEventListener("click",()=>{this.close(),this.onManualClose?.()}),r.appendChild(o);let i=document.createElement("main");this.dialog.appendChild(r),this.dialog.appendChild(i);let s=new FontFace("Rock Salt",`url(${n})`,{style:"normal",weight:"400"});document.fonts.add(s),await s.load(),e=e.replace("url(graffiti.jpg)",`url(${t})`);let a=new CSSStyleSheet;return await a.replace(e),this.shadow.adoptedStyleSheets=[a],i})),this.main_}async open(){await this.main,this.dialog.open||this.dialog.showModal()}close(){this.dialog.close()}async displayTemplate(e){let t=++this.displayTemplateSeq,n=()=>{if(t!==this.displayTemplateSeq)throw new Error(`displayTemplate(${e}) overridden by concurrent call`)},r=await this.main;n();let o=(await this.templates).get(e);if(n(),!o)throw new Error(`Template not found: ${e}`);let i=o.content.cloneNode(!0);return r.replaceChildren(i),r}};var _p=Lt(e=>e instanceof Uint8Array),Qa="k",Fn="t",nc=ye({[Qa]:B(),[Fn]:X(B())}),en="id",ec="e",Kr="a",Pb=q(ye({[en]:B(),[ec]:X(Z()),[Kr]:X(Z())})),$i="s",Ci="n",Ob=at(nc,{[$i]:X(q(_p)),[Ci]:Pb}),Jr="a",tc="i",kb=at(nc,{[Jr]:_p,[tc]:nn().check(Ut())}),Ib=ct([nc,Ob,kb]),zb=0,Ya=1,Tt=2,Xa=3,$b=128,wp="graffiti-login-remembered-handle",Di=class{dids=new Go;authorization=new ai;storageBuckets=new ui;inboxes=new fi;stringEncoder=new di;contentAddresses=new hi;channelAttestations=new bi;allowedAttestations=new _i;sessions=new Pi({dids:this.dids,authorization:this.authorization,storageBuckets:this.storageBuckets,inboxes:this.inboxes});handles=new xi({dids:this.dids});objectEncoding=new zi({stringEncoder:this.stringEncoder,contentAddresses:this.contentAddresses,channelAttestations:this.channelAttestations,allowedAttestations:this.allowedAttestations});modal=typeof window>"u"?void 0:new yp({ariaLabel:"Graffiti Log In",useTemplateHTML:()=>import("./login-dialog.html-WIDO3XZF.js").then(({template:t})=>t),onManualClose:()=>{let t=new CustomEvent("login",{detail:{error:new Error("User cancelled login"),manual:!0}});this.sessionEvents.dispatchEvent(t)}});defaultInboxEndpoints;identityCreatorEndpoint;replaceInitialLoginHistoryEntry;constructor(t){this.replaceInitialLoginHistoryEntry=t?.replaceInitialLoginHistoryEntry??!1,this.replaceInitialLoginHistoryEntry&&(this.sessions.initialAuthorizationNavigation="replace"),this.defaultInboxEndpoints=t?.defaultInboxEndpoints??["https://graffiti.actor/i/shared"],this.identityCreatorEndpoint=t?.identityCreatorEndpoint??"https://graffiti.actor/create",this.sessionEvents.addEventListener("login",async n=>{if(!(n instanceof CustomEvent))return;let r=n.detail;if(r.error!==void 0){if("manual"in r&&r.manual)return;alert("Login failed: "+r.error.message);let s=r.session?.actor,a;if(s)try{a=await this.actorToHandle(s)}catch(c){console.error("Failed to handle actor:",c)}this.login_(a);return}this.modal?.close();let o=r.session.actor,i;try{i=await this.actorToHandle(o)}catch(s){console.error("Failed to load handle from actor:",s)}i&&this.rememberHandleInBrowserStorage(i)});for(let n of["post","get","delete","postMedia","getMedia","deleteMedia"]){let r=this[n];this[n]=async(...o)=>{try{return await r(...o)}catch(i){let s=o[o.length-1];throw await this.tryLogoutIfUnauthorized(i,s),i}}}}actorToHandle=this.handles.actorToHandle.bind(this.handles);handleToActor=this.handles.handleToActor.bind(this.handles);sessionEvents=this.sessions.sessionEvents;login=async t=>{try{let n;try{n=t?await this.actorToHandle(t):void 0}catch(r){console.error("Error fetching handle for actor:",r)}await this.login_(n)}catch(n){let r=new CustomEvent("login",{detail:{error:n instanceof Error?n:new Error(String(n))}});this.sessionEvents.dispatchEvent(r)}};async login_(t){if(typeof window<"u"){let n,r=null;if(t!==void 0){n=await this.modal?.displayTemplate("graffiti-login-handle");let s=n?.querySelector("#username"),a=t||this.getRememberedHandleFromBrowserStorage();s&&(s.value=a??""),s?.addEventListener("focus",()=>s?.select()),r=s,n?.querySelector("#graffiti-login-handle-form")?.addEventListener("submit",async c=>{c.preventDefault(),s?.setAttribute("disabled","true");let u=n?.querySelector("#graffiti-login-handle-submit");if(u?.setAttribute("disabled","true"),u&&(u.innerHTML="Logging in..."),!s?.value){alert("No handle provided"),this.login_("");return}let l=s.value;if(!l.includes(".")&&!l.startsWith("localhost")){let p=new URL(this.identityCreatorEndpoint).host;l=`${l}.${p}`}let f;try{f=await this.handleToActor(l)}catch{alert("Could not find an identity associated with that handle."),this.login_(l);return}try{await this.sessions.login(f)}catch(p){alert("Error logging in."),console.error(p),this.login_(l)}}),n?.querySelector("#graffiti-login-forgot")?.addEventListener("click",c=>{c.preventDefault(),this.loginWithoutHandle()})}else n=await this.modal?.displayTemplate("graffiti-login-welcome"),n?.querySelector("#graffiti-login-existing")?.addEventListener("click",s=>{s.preventDefault(),this.login_("")});let o=new URL(this.identityCreatorEndpoint);o.searchParams.set("redirect_uri",encodeURIComponent(window.location.toString()));let i=n?.querySelector("#graffiti-login-new");i?.setAttribute("href",o.toString()),t===void 0&&(r=i??null),this.replaceInitialLoginHistoryEntry&&i?.addEventListener("click",s=>{s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||(s.preventDefault(),window.location.replace(o.toString()))}),await this.modal?.open(),r?.focus()}else{let n=await import("readline").catch(s=>{throw new Error("Unrecognized environment: neither window nor readline")});console.log("If you do not already have a Graffiti handle, you can create one here:"),console.log(this.identityCreatorEndpoint);let r=n.createInterface({input:process.stdin,output:process.stdout}),o=await new Promise(s=>{r.question(`Please enter your handle${t?` (default: ${t})`:""}: `,a=>{r.close(),s(a||t)})});if(!o)throw new Error("No handle provided");let i=await this.handleToActor(o);await this.sessions.login(i)}}async loginWithoutHandle(){let t=await this.modal?.displayTemplate("graffiti-login-provider"),n=new URL("/",this.identityCreatorEndpoint),r=t?.querySelector("#graffiti-provider");r&&(r.value=n.host),r?.addEventListener("focus",()=>r.select()),t?.querySelector("#graffiti-login-provider-form")?.addEventListener("submit",o=>{o.preventDefault();try{let i=r?.value.trim()??"",s=i===n.host?n:new URL(`https://${i}`);if(!s.hostname||s.username||s.password||s.pathname!=="/"||s.search||s.hash)throw new Error("Invalid provider domain");let a=new URL("/forgot-handle",s);a.searchParams.set("redirect_uri",window.location.toString()),this.replaceInitialLoginHistoryEntry?window.location.replace(a.toString()):window.location.assign(a.toString())}catch{alert("Enter a valid provider domain.")}}),t?.querySelector("#graffiti-login-provider-back")?.addEventListener("click",o=>{o.preventDefault(),this.login_("")}),await this.modal?.open(),r?.focus()}rememberHandleInBrowserStorage(t){if(!(typeof window>"u"))try{window.localStorage.setItem(wp,t)}catch(n){console.error("Failed to remember handle in browser storage:",n)}}getRememberedHandleFromBrowserStorage(){if(!(typeof window>"u"))try{return window.localStorage.getItem(wp)??void 0}catch(t){console.error("Failed to load handle from browser storage:",t);return}}logout=async t=>{await this.sessions.logout(t.actor)};post=async(...t)=>{let[n,r]=t,o=this.sessions.resolveSession(r),{object:i,tags:s,objectBytes:a,allowedTickets:c}=await this.objectEncoding.encode(n,r.actor),u=Mt(),l=await this.stringEncoder.encode(Bn,u);return await this.storageBuckets.put(o.storageBucket.serviceEndpoint,l,a,o.storageBucket.token),await this.announceObject(i,s,c,l,r),i};get=async(...t)=>{let[n,r,o]=t,i,s=await so(r);if(o){let u=this.sessions.resolveSession(o);i=[u.personalInbox,...u.sharedInboxes]}else i=this.defaultInboxEndpoints.map(u=>({serviceEndpoint:u}));let a=ns(n),c=[new TextEncoder().encode(a)];for(let u of i){let l,f=this.querySingleEndpoint(u.serviceEndpoint,{tags:c,objectSchema:{}},u.token,o?.actor);for await(let p of f)p.object.url===a&&(p.tombstone?l=void 0:l=p.object);if(l){if(!s(l))throw new oo("Object exists but does not match the supplied schema");return l}}throw new Q("Object not found")};delete=async(t,n)=>{let r=this.sessions.resolveSession(n),o=ns(t),{actor:i}=Wa(o);if(i!==n.actor)throw new mt("Cannot delete someone else's actor");let s=this.querySingleEndpoint(r.personalInbox.serviceEndpoint,{tags:[new TextEncoder().encode(o)],objectSchema:{}},r.personalInbox.token),a;for await(let w of s)w.object.url===o&&(w.tombstone?a=void 0:a=w);if(!a)throw new Q(`Object ${o} not found`);let{object:c,storageBucketKey:u,tags:l,allowedTickets:f,announcements:p,messageId:g}=a;return await this.storageBuckets.delete(r.storageBucket.serviceEndpoint,u,r.storageBucket.token),await this.announceObject(c,l,f,u,n,[...p??[],{[Kr]:n.actor,[en]:g}]),c};postMedia=async(...t)=>{let[n,r]=t,o=n.data.type,i=this.sessions.resolveSession(r),s=Mt(),a=await this.stringEncoder.encode(Bn,s);await this.storageBuckets.put(i.storageBucket.serviceEndpoint,a,new Uint8Array(await n.data.arrayBuffer()),i.storageBucket.token);let{url:c}=await this.post({value:{key:a,type:o,size:n.data.size},channels:[],allowed:n.allowed},r);return c};getMedia=async(...t)=>{let[n,r,o]=t;if(r?.maxBytes!==void 0&&(!Number.isSafeInteger(r.maxBytes)||r.maxBytes<0))throw new TypeError("maxBytes must be a nonnegative safe integer");let i=await this.get(n,Cb,o),{key:s,type:a,size:c}=i.value;if(r?.maxBytes!==void 0&&c>r.maxBytes)throw new gt("File size exceeds limit");if(r?.types&&!Ou(a,r.types))throw new io(`Unacceptable media type, ${a}`);let l=(await this.dids.resolve(i.actor))?.service?.find(w=>w.id===ki&&w.type===Oi);if(!l)throw new Q(`Actor ${i.actor} has no storage bucket service`);if(typeof l.serviceEndpoint!="string")throw new Q(`Actor ${i.actor} does not have a valid storage bucket endpoint`);let f=l.serviceEndpoint,p=await this.storageBuckets.get(f,s,c);return{data:new Blob([p.slice()],{type:a}),actor:i.actor,allowed:i.allowed}};deleteMedia=async(...t)=>{let[n,r]=t,o=this.sessions.resolveSession(r),i=await this.delete(n,r);if(!("key"in i.value&&typeof i.value.key=="string"))throw new Error("Deleted object was not media: "+JSON.stringify(i,null,2));await this.storageBuckets.delete(o.storageBucket.serviceEndpoint,i.value.key,o.storageBucket.token)};async*discoverMeta(t,n,r,o){let i=new Map,s;if(o){let f=this.sessions.resolveSession(o);s=[f.personalInbox,...f.sharedInboxes]}else s=this.defaultInboxEndpoints.map(f=>({serviceEndpoint:f}));for(let f in r)if(!s.some(p=>p.serviceEndpoint===f))throw new mt("Cursor does not match actor's inboxes");let a=await Promise.all(t.map(f=>this.channelAttestations.register(Qt,f))),c=s.map(f=>{let p=r[f.serviceEndpoint];return this.querySingleEndpoint(f.serviceEndpoint,p?{cursor:p}:{tags:a,objectSchema:n},f.token,o?.actor)}),u=c.map(async(f,p)=>bp(f,p)),l=u.length;try{for(;l>0;){let f=await Promise.race(u);if(f.error!==void 0)u[f.index]=new Promise(()=>{}),l--,yield{error:f.error,origin:s[f.index].serviceEndpoint},this.tryLogoutIfUnauthorized(f.error,o);else if(f.result.done){let p=s[f.index];r[p.serviceEndpoint]=f.result.value,u[f.index]=new Promise(()=>{}),l--}else{u[f.index]=bp(c[f.index],f.index);let{object:p,tombstone:g,tags:w}=f.result.value;if(g){if(i.get(p.url)===!0)continue;i.set(p.url,!0),yield{tombstone:g,object:{url:p.url}}}else{if(i.get(p.url)===!1)continue;let A=a.reduce((h,_,S)=>{for(let b of w)if(_.length===b.length&&_.every((v,O)=>b[O]===v)){h.push(S);break}return h},[]).map(h=>t[h]);A.length===0&&(yield{error:new Error("Inbox returned object without matching channels"),origin:s[f.index].serviceEndpoint}),i.set(p.url,!1),yield{object:{...p,channels:A}}}}}}catch(f){throw this.tryLogoutIfUnauthorized(f,o),f}finally{await Promise.all(c.map(async f=>{await f.return("")}))}return{cursor:JSON.stringify({channels:t,cursors:r})}}discover=(...t)=>{let[n,r,o]=t;return this.discoverMeta(n,r,{},o)};continueDiscover=(...t)=>{let[n,r]=t,o,i;try{let s=JSON.parse(n),a=Db.parse(s);o=a.channels,i=a.cursors}catch{return(async function*(){throw new Le("Invalid cursor")})()}return this.discoverMeta(o,{},i,r)};async tryLogoutIfUnauthorized(t,n){t instanceof Vt&&n&&await this.sessions.logout(n.actor)}async announceObject(t,n,r,o,i,s){let a=this.sessions.resolveSession(i),c={[Qa]:o},u=[],l=t.allowed;if(Array.isArray(l)){if(!r||r.length!==l.length)throw new Error("If allowed actors are specified, there must be a corresponding ticket for each allowed actor");let g=await Promise.allSettled(l.map(async(w,x)=>{let A=JSON.parse(JSON.stringify(t)),h=rs(A,[],w),S=(await this.dids.resolve(w)).service?.find(I=>I.type===Ti&&I.id===Fa);if(!S)throw new Error(`Recipient ${w} does not have a personal inbox`);if(typeof S.serviceEndpoint!="string")throw new Error(`Recipient ${w} does not have a valid personal inbox endpoint`);let b=s?s.find(I=>I[Kr]===w)?.[en]:void 0,v={...c,...b?{[Fn]:b}:{},[Jr]:r[x],[tc]:x},O=await this.inboxes.send(S.serviceEndpoint,{[Mn]:n,[Ze]:h,[Nn]:pe(v)});u.push({[en]:O,[Kr]:w})}));for(let[w,x]of g.entries())if(x.status==="rejected"){let A=l[w];console.error("Error sending to recipient:",A),console.error(x.reason)}}else{let g=JSON.parse(JSON.stringify(t)),w=rs(g,[]),x=a.sharedInboxes,A=await Promise.allSettled(x.map(async h=>{let _=s?s.find(v=>v[ec]===h.serviceEndpoint)?.[en]:void 0,S={...c,..._?{[Fn]:_}:{}},b=await this.inboxes.send(h.serviceEndpoint,{..._?{[Fn]:_}:{},[Mn]:n,[Ze]:w,[Nn]:pe(S)});u.push({[en]:b,[ec]:h.serviceEndpoint})}));for(let[h,_]of A.entries())if(_.status==="rejected"){let S=x[h];console.error("Error sending to inbox:",S),console.error(_.reason)}}let f=s?s.find(g=>g[Kr]===i.actor)?.[en]:void 0,p={...c,...r?{[$i]:r}:{},...f?{[Fn]:f}:{},[Ci]:u};await this.inboxes.send(a.personalInbox.serviceEndpoint,{[Mn]:n,[Ze]:t,[Nn]:pe(p)})}async*querySingleEndpoint(t,n,r,o){let i="tags"in n?this.inboxes.query(t,n.tags,n.objectSchema,r):this.inboxes.continueQuery(t,n.cursor,r),s=[],a=null;try{for(;;){for(;a===null&&s.length<$b;){let l=await i.next();if(l.done){a=l.value;break}let f=this.processOneLabeledMessage(t,l.value,r,o).catch(p=>{throw p});s.push(f)}let c=s.shift();if(!c){if(a!==null)return a;throw new Error("Process queue empty but no return value")}let u=await c;u&&(yield u)}}finally{await i.return("")}}labelInboxMessage(t,n,r,o){this.inboxes.label(t,n,r,o).catch(i=>console.error("Could not label inbox message:",i))}async processOneLabeledMessage(t,n,r,o){let i=n.l;if(i!==Ya&&i!==zb&&i!==Tt)return;let s=n.id,{o:a,m:c,t:u}=n.m,l;try{let A=Ne(c);l=Ib.parse(A)}catch{this.labelInboxMessage(t,s,Xa,r);return}let{[Qa]:f,[Fn]:p}=l,g=$i in l?l[$i]:void 0,w=Ci in l?l[Ci]:void 0;if(i===Ya)return{messageId:s,object:a,storageBucketKey:f,allowedTickets:g,tags:u,announcements:w};if(i===Tt){if(!p)return;let A=await this.inboxes.get(t,p,r);return!A||A[ft][Ze].url!==a.url?void 0:(A[Zr]!==Tt&&this.labelInboxMessage(t,p,Tt,r),{messageId:s,tombstone:!0,object:a,storageBucketKey:f,allowedTickets:g,tags:u,announcements:w})}let x;try{let A=a.actor,_=(await this.dids.resolve(A))?.service?.find(O=>O.id===ki&&O.type===Oi);if(!_)throw new Q(`Actor ${A} has no storage bucket service`);if(typeof _.serviceEndpoint!="string")throw new Q(`Actor ${A} does not have a valid storage bucket endpoint`);let S=_.serviceEndpoint,b=await this.storageBuckets.get(S,f,Ii);if(Jr in l&&!o)throw new mt("Recipient is required when allowed ticket is present");let v=g?{allowedTickets:g}:Jr in l?{recipient:o??"null",allowedTicket:l[Jr],allowedIndex:l[tc]}:void 0;await this.objectEncoding.validate(a,u,b,v)}catch(A){x=A}if(p){if(x instanceof Q)return this.inboxes.get(t,p,r).then(A=>{A&&A[ft][Ze].url===a.url&&A[Zr]!==Tt&&this.labelInboxMessage(t,p,Tt,r),this.labelInboxMessage(t,s,Tt,r)}).catch(A=>console.error("Could not inspect tombstone message:",A)),{messageId:s,tombstone:!0,object:a,storageBucketKey:f,allowedTickets:g,tags:u,announcements:w};console.error("Recieved an incorrect tombstone object"),console.error(x),this.labelInboxMessage(t,s,Xa,r)}else{if(x===void 0)return this.labelInboxMessage(t,s,Ya,r),{messageId:s,object:a,storageBucketKey:f,tags:u,allowedTickets:g,announcements:w};x instanceof Q?this.labelInboxMessage(t,s,Tt,r):(console.error("Recieved an incorrect object"),console.error(x),this.labelInboxMessage(t,s,Xa,r))}}},Cb={properties:{value:{properties:{type:{type:"string"},size:{type:"number"},key:{type:"string"}},required:["type","size","key"]}}},Db=ye({cursors:Su(Z(),B()),channels:q(B())});async function bp(e,t){try{return{index:t,result:await e.next()}}catch(n){if(n instanceof Le||n instanceof an)throw n;return{index:t,error:n instanceof Error?n:new Error(String(n))}}}var xp=class extends ro{constructor(t){let n=new Di(t);super(n)}};export{xp as GraffitiDecentralized};
|
|
11
11
|
/*! Bundled license information:
|
|
12
12
|
|
|
13
13
|
@noble/ed25519/index.js:
|