@learncard/network-plugin 1.2.0 → 1.2.1
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/lcn-plugin.cjs.development.js +6 -0
- package/dist/lcn-plugin.cjs.development.js.map +3 -3
- package/dist/lcn-plugin.cjs.production.min.js +4 -4
- package/dist/lcn-plugin.cjs.production.min.js.map +3 -3
- package/dist/lcn-plugin.esm.js +6 -0
- package/dist/lcn-plugin.esm.js.map +3 -3
- package/package.json +5 -5
|
@@ -656,7 +656,7 @@ ${t.stack}`:n}s(c2,"debugString");c(c2,"debugString");function uD(t,e,r,n){let i
|
|
|
656
656
|
background-color: transparent;
|
|
657
657
|
}`)),this.container=document.createElement("div"),Lb(this.container,{position:"relative",width:"100%",height:"100%",margin:0,padding:0,display:"flex","flex-direction":"column"}),this.container.className="web-app-window-backdrop",this.iframe=document.createElement("iframe"),this.iframe.src=t,this.iframe.scrolling="auto",Lb(this.iframe,{position:"fixed",top:0,left:0,width:"100%",height:"100%",border:"none",background:"transparent",overflow:"hidden",margin:0,padding:0,"flex-grow":1,"user-select":"none"}),this.dialog.appendChild(n),this.container.appendChild(this.iframe),this.dialog.appendChild(this.container),this.dialog.addEventListener("cancel",i=>{i.preventDefault(),this.hide()}),document.body.appendChild(this.dialog),this.handle=this.iframe.contentWindow}show(){this.dialog.style.display="block",this.dialog.showModal&&this.dialog.showModal();try{this.dialog.style.pointerEvents="none"}catch{}setTimeout(()=>{try{this.dialog.style.pointerEvents=""}catch{}},32)}close(){if(this.dialog.style.display="none",this.dialog.close)try{this.dialog.close()}catch(t){console.error(t)}super.close()}destroy(){this.dialog.parentNode.removeChild(this.dialog),super.destroy()}},"WebAppWindowInlineDialog");c(jD,"WebAppWindowInlineDialog");function Lb(t,e){for(let r in e)t.style[r]=e[r]}s(Lb,"applyStyle");c(Lb,"applyStyle");var qD=s(class extends ax{constructor({url:t,handle:e,bounds:r={width:500,height:400}}){super(),this.url=t,this.handle=e,this._locationChanging=!1,e||this._openWindow({url:t,name:"web-app-window",bounds:r}),this.destroyed=!1,this._removeListeners=()=>{}}show(){}close(){this.destroy()}destroy(){this.handle&&!this.destroyed&&(this.handle.close(),super.close(),this.handle=null,this.destroyed=!0,this._removeListeners(),super.destroy())}isClosed(){return!this.handle||this.handle.closed}_openWindow({url:t,name:e,bounds:r}){let{x:n,y:i}=r,{width:o=500,height:a=400}=r;o=Math.min(o,window.innerWidth),a=Math.min(a,window.innerHeight);let f=Math.floor(n!==void 0?n:window.screenX+(window.innerWidth-o)/2),l=Math.floor(i!==void 0?i:window.screenY+(window.innerHeight-a)/2),u=`popup=yes,menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=${o},height=${a},left=${f},top=${l}`;this._locationChanging=!0,this.handle=window.open(t,e,u),this._addListeners()}setLocation(t){this.url=t,this._locationChanging=!0,this.handle.location.replace(t)}_addListeners(){let t=c(()=>this.destroy(),"destroyDialog"),e=c(()=>{this._locationChanging=!1},"loadDialog"),r=c(()=>{this._locationChanging||this.destroy()},"unloadDialog");this.handle.addEventListener("unload",r),this.handle.addEventListener("load",e),window.addEventListener("beforeUnload",t,{once:!0});let n=setInterval(()=>{this.isClosed()&&(this.destroy(),clearInterval(n))},250);this._removeListeners=()=>{clearInterval(n),this.handle.removeListener("unload",r),this.handle.removeListener("load",e),window.removeEventListener("beforeUnload",t)}}},"WebAppWindowPopupDialog");c(qD,"WebAppWindowPopupDialog");var OZ=6e4,gv=s(class{constructor(t,{timeout:e=OZ,dialog:r=null,handle:n,popup:i=!1,className:o=null,customize:a=null,bounds:f}={}){if(this.visible=!1,this.dialog=r,this.handle=null,this.popup=i,this.windowControl=null,this._destroyed=!1,this._ready=!1,this._private={},this._timeoutId=null,n&&n._dialog&&(this.dialog=r=n._dialog),this._private._readyPromise=new Promise((l,u)=>{this._timeoutId=setTimeout(()=>u(new DOMException("Loading Web application window timed out.","TimeoutError")),e),this._private._resolveReady=h=>{clearTimeout(this.timeoutId),this._timeoutId=null,l(h)},this._private._rejectReady=h=>{clearTimeout(this.timeoutId),this._timeoutId=null,u(h)}}),this._private.isReady=async()=>this._private._readyPromise,this._private.destroy=()=>{this._timeoutId&&this._private._rejectReady(new DOMException("Web application window closed before ready.","AbortError")),this._destroyed||(this.dialog.destroy(),this.dialog=null,this._destroyed=!0)},a&&!typeof a==="function")throw new TypeError("`options.customize` must be a function.");if(this.dialog||(this.popup?this.dialog=new qD({url:t,handle:n,bounds:f}):this.dialog=new jD({url:t,handle:n,className:o})),this.popup&&f){let{x:l,y:u,width:h=500,height:g=400}=f;h=Math.min(h,window.innerWidth),g=Math.min(g+30,window.innerHeight),l=Math.floor(l!==void 0?l:window.screenX+(window.innerWidth-h)/2),u=Math.floor(u!==void 0?u:window.screenY+(window.innerHeight-g)/2+15),this.dialog.handle.resizeTo(h,g),this.dialog.handle.moveTo(l,u)}if(this.handle=this.dialog.handle,a)try{a({dialog:this.dialog.dialog,container:this.dialog.container,iframe:this.dialog.iframe,webAppWindow:this})}catch(l){console.error(l)}}ready(){this._ready=!0,this._private._resolveReady(!0)}show(){if(!this.visible){this.visible=!0;let t=document.querySelector("body");this._bodyOverflowStyle=t.style.overflow,t.style.overflow="hidden",this._destroyed?this.windowControl.show&&this.windowControl.show():this.dialog.show()}}hide(){if(this.visible){this.visible=!1;let t=document.querySelector("body");this._bodyOverflowStyle?t.style.overflow=this._bodyOverflowStyle:t.style.overflow="",this._destroyed?this.windowControl.hide&&this.windowControl.hide():this.dialog.close()}}},"WebAppWindow");c(gv,"WebAppWindow");var FZ=1e4,cx=s(class{constructor(){this.client=new ix,this.server=new sx,this.injector=null,this.control=null,this.loaded=!1,this.closed=!1}async createWindow(t,{timeout:e=FZ,iframe:r,dialog:n=null,popup:i=!1,handle:o,windowControl:a,className:f,customize:l,bounds:u}={}){if(this.loaded)throw new Error("AppContext already loaded.");this.loaded=!0,this.control=new gv(t,{timeout:e,dialog:n,iframe:r,popup:i,handle:o,windowControl:a,className:f,customize:l,bounds:u}),window.addEventListener("pagehide",()=>this.close(),{once:!0}),this.server.define("core.control",this.control);let h=T1(t).origin;return this.server.listen(h,{handle:this.control.handle,ignoreUnknownApi:!0}),await this.control._private.isReady(),this.injector=await this.client.connect(h,{handle:this.control.handle}),this.injector}close(){this.closed||(this.closed=!0,this.control._private.destroy(),this.server.close(),this.client.close())}},"WebAppContext");c(cx,"WebAppContext");var HD=s(class{constructor({credentialHandler:t,credentialRequestOrigin:e,credentialRequestOptions:r,hintKey:n}){this.type="credentialrequest",this._credentialHandler=t,this.credentialRequestOrigin=e,this.credentialRequestOptions=r,this.hintKey=n}async openWindow(t){await this._credentialHandler.show();let e=new gv(t,{className:"credential-handler"});return e.ready(),e.show(),e.handle._dialog=e.dialog,e.handle}respondWith(t){this._promise=t}},"CredentialRequestEvent");c(HD,"CredentialRequestEvent");var zD=s(class{constructor({credentialHandler:t,credentialRequestOrigin:e,credential:r,hintKey:n}){this.type="credentialstore",this._credentialHandler=t,this.credentialRequestOrigin=e,this.credential=r,this.hintKey=n}async openWindow(t){await this._credentialHandler.show();let e=new gv(t);return e.ready(),e.show(),e.handle._dialog=e.dialog,e.handle}respondWith(t){this._promise=t}},"CredentialStoreEvent");c(zD,"CredentialStoreEvent");var $D=s(class{constructor(t){this._credentialHandler=t}async request(t){return await this._credentialHandler._emitter.emit(new HD(Object.assign({credentialHandler:this._credentialHandler},t)))}async store(t){return await this._credentialHandler._emitter.emit(new zD(Object.assign({credentialHandler:this._credentialHandler},t)))}},"CredentialHandlerService");c($D,"CredentialHandlerService");var xM=["credentialrequest","credentialstore"],GD=s(class extends ox{constructor(t,e=!1){if(typeof t!="string")throw new TypeError('"mediatorOrigin" must be a string.');super(t,e),this._emitter=new UD({async waitUntil(r){return r._promise||Promise.reject(new DOMException('No "credentialrequest" event handler found.',"NotFoundError"))}})}async connect(){let t=await super.connect();return this.server.define("credentialHandler",new $D(this)),await this.ready(),t}addEventListener(t,e){if(!xM.includes(t))throw new DOMException(`Unsupported event type "${t}"`,"NotSupportedError");return this._emitter.addEventListener(t,e)}removeEventListener(t,e){if(!xM.includes(t))throw new DOMException(`Unsupported event type "${t}"`,"NotSupportedError");return this._emitter.removeEventListener(t,e)}},"CredentialHandler");c(GD,"CredentialHandler");var KD=s(class{constructor(t,e){let r=e.get("credentialHints",{functions:["delete","get","keys","has","set","clear"]});for(let n in r)if(n!=="set"){let i=r[n].bind(this,t);this[n]=function(...o){return this._deprecateNotice(),i(...o)}}this._remoteSet=r.set.bind(this,t)}async set(t,e){this._deprecateNotice(),e.icons=e.icons||[];let r=e.icons.map(n=>VD(n.src).then(i=>{n.fetchedImage=i}));return await Promise.all(r),this._remoteSet(t,e)}_deprecateNotice(){console.warn("Credential hints are deprecated and no longer used.")}},"CredentialHints");c(KD,"CredentialHints");function VD(t){return new Promise(e=>{let r=new Image;r.crossOrigin="Anonymous",r.onload=()=>{let n=document.createElement("canvas"),i=n.getContext("2d");n.height=r.height,n.width=r.width,i.drawImage(r,0,0);let o=n.toDataURL();e(o),n=null},r.onerror=()=>e(null),r.src=t})}s(VD,"imageToDataUrl");c(VD,"imageToDataUrl");var f2=s(class{constructor(t,e){if(!(t&&typeof t=="string"))throw new TypeError('"url" must be a non-empty string.');this.hints=new KD(t,e)}static async requestPermission(){return(await navigator.credentialsPolyfill.permissions.request({name:"credentialhandler"})).state}},"CredentialManager");c(f2,"CredentialManager");var g5=s(class{constructor(t,e){if(!(t&&typeof t=="string"))throw new TypeError('"url" must be a non-empty string.');this.credentialManager=new f2(t,e)}},"CredentialHandlerRegistration");c(g5,"CredentialHandlerRegistration");var WD=s(class{constructor(t){this._init=(async()=>{this._injector=await t,this._remote=this._injector.get("credentialHandlers",{functions:["register","unregister","getRegistration","hasRegistration"]})})()}async register(t){return this._deprecateNotice(),await this._init,t=await this._remote.register("credential",t),new g5(t,this._injector)}async unregister(t){return this._deprecateNotice(),await this._init,this._remote.unregister("credential",t)}async getRegistration(t){return this._deprecateNotice(),await this._init,t=await this._remote.getRegistration("credential",t),t?new g5(t,this._injector):null}async hasRegistration(t){return this._deprecateNotice(),await this._init,await this._remote.hasRegistration("credential",t)}_deprecateNotice(){console.warn('Credential handler registration APIs are deprecated. The credential handler specified in "manifest.json" is now automatically registered when a user grants permission to install a credential handler via "CredentialManager.requestPermission()".')}},"CredentialHandlers");c(WD,"CredentialHandlers");var Hd=s(class{constructor(t,e,{recommendedHandlerOrigins:r=[]}={}){if(typeof t!="string")throw new TypeError('"dataType" must be a string.');this.type="web",this.dataType=t,this.data=e,this.options={recommendedHandlerOrigins:r}}},"WebCredential2");c(Hd,"WebCredential");var NZ=0,LZ=0,JD=s(class{constructor(t){this._nativeCredentialsContainer={get:navigator.credentials&&navigator.credentials.get&&navigator.credentials.get.bind(navigator.credentials),store:navigator.credentials&&navigator.credentials.store&&navigator.credentials.store.bind(navigator.credentials)},this._init=(async()=>{this._remote=(await t).get("credentialsContainer",{functions:[{name:"get",options:{timeout:NZ}},{name:"store",options:{timeout:LZ}}]})})()}async get(t={}){if(t.web){await this._init;let e=await this._remote.get(t);return e?new Hd(e.dataType,e.data):null}if(this._nativeCredentialsContainer.get)return this._nativeCredentialsContainer.get(t);throw new DOMException("Not implemented.","NotSupportedError")}async store(t){if(t instanceof Hd){await this._init;let e=await this._remote.store(t);return e?new Hd(e.dataType,e.data):null}if(this._nativeCredentialsContainer.store)return this._nativeCredentialsContainer.store(t);throw new DOMException("Not implemented.","NotSupportedError")}},"CredentialsContainer");c(JD,"CredentialsContainer");var UZ=0,YD=s(class{constructor(t){this._init=(async()=>{this._remote=(await t).get("permissionManager",{functions:["query",{name:"request",options:{timeout:UZ}},"revoke"]})})()}async query(t){return await this._init,await this._remote.query(t)}async request(t){return await this._init,await this._remote.request(t)}async revoke(t){return await this._init,await this._remote.revoke(t)}},"PermissionManager");c(YD,"PermissionManager");var jZ="https://authn.io",z4;async function ZD(t){return z4||(z4=!0,XD(t))}s(ZD,"loadOnce");c(ZD,"loadOnce");async function XD(t={mediatorOrigin:jZ}){QD();let e;if(typeof t=="string")e=t;else if(t&&typeof t=="object"&&typeof t.mediatorOrigin=="string")e=`${t.mediatorOrigin}/mediator`;else throw new Error('"options.mediatorOrigin" must be a string expressing the origin of the mediator.');let n=new cx().createWindow(e,{className:"credential-mediator",timeout:3e4}),i=document.createElement("style");i.appendChild(document.createTextNode(`dialog.web-app-window.credential-mediator > .web-app-window-backdrop {
|
|
658
658
|
background-color: rgba(0, 0, 0, 0.25);
|
|
659
|
-
}`)),document.body.appendChild(i);let o={};return o.permissions=new YD(n),o.CredentialHandlers=new WD(n),o.CredentialHandler=GD,o.CredentialManager=f2,o.credentials=new JD(n),o.WebCredential=Hd,navigator.credentialsPolyfill=o,"credentials"in navigator?(navigator.credentials.get=o.credentials.get.bind(o.credentials),navigator.credentials.store=o.credentials.store.bind(o.credentials)):navigator.credentials=o.credentials,window.CredentialManager=f2,window.WebCredential=Hd,o}s(XD,"load2");c(XD,"load");function QD(){if(!window.isSecureContext)throw new DOMException("SecurityError","The operation is insecure.")}s(QD,"_assertSecureContext");c(QD,"_assertSecureContext");var qZ=6e4,eP=s(class extends ox{constructor(){super(window.location.origin)}async receive(){let t=this;return await t.connect(),new Promise((e,r)=>{let n=setTimeout(()=>{r(new Error("Timed out waiting to receive event."))},qZ);t.server.define("credentialEventProxy",{async send(i){return e(i),clearTimeout(n),new Promise((o,a)=>{i.respondWith=f=>{try{o(f)}catch(l){a(l)}}})}}),t.ready()})}},"CredentialEventProxy");c(eP,"CredentialEventProxy");var HZ="https://authn.io";async function tP(){if(await navigator.credentialsPolyfill.CredentialManager.requestPermission()!=="granted")throw new Error("Permission denied.")}s(tP,"installHandler");c(tP,"installHandler");async function rP({mediatorOrigin:t=HZ,get:e,store:r}){if(!(e||r))throw new Error('"get" or "store" function(s) must be specified.');let n=navigator.credentialsPolyfill.CredentialHandler,i=new n(t);if(e){if(typeof e!="function")throw new TypeError('"get" must be a function.');i.addEventListener("credentialrequest",o=>b5({event:o,get:e}))}if(r){if(typeof r!="function")throw new TypeError('"store" must be a function.');i.addEventListener("credentialstore",o=>b5({event:o,store:r}))}await i.connect()}s(rP,"activateHandler");c(rP,"activateHandler");async function nP(){return new eP().receive()}s(nP,"receiveCredentialEvent");c(nP,"receiveCredentialEvent");function b5({event:t,get:e,store:r}){t.respondWith(iP({event:t,get:e,store:r}))}s(b5,"listener");c(b5,"listener");async function iP({event:t,get:e,store:r}){let n=await(e||r)({event:t});if(!(n&&typeof n=="object"))throw new TypeError('Return value of "get" or "store" hook must be an object.');if(n.type==="response")return{dataType:n.dataType,data:n.data};if(n.type==="redirect"){let i=new cx,o=await t.openWindow(n.url);return(await i.createWindow(n.url,{handle:o,popup:!1,timeout:6e5})).get("credentialEventProxy",{functions:[{name:"send",options:{timeout:0}}]}).send({type:t.type,credentialRequestOptions:t.credentialRequestOptions,credentialRequestOrigin:t.credentialRequestOrigin,credential:t.credential,hintKey:t.hintKey})}throw new Error('Return value of "get" or "store" must have a type of "response" or "redirect".')}s(iP,"createResponse");c(iP,"createResponse");var fx=c(async()=>typeof window>"u"?{name:"CHAPI",methods:{installChapiHandler:async()=>{throw new Error("CHAPI is only available inside of a browser!")},activateChapiHandler:async()=>{throw new Error("CHAPI is only available inside of a browser!")},receiveChapiEvent:async()=>{throw new Error("CHAPI is only available inside of a browser!")},storeCredentialViaChapiDidAuth:async()=>{throw new Error("CHAPI is only available inside of a browser!")},storePresentationViaChapi:async()=>{throw new Error("CHAPI is only available inside of a browser!")}}}:(await ZD(),{name:"CHAPI",displayName:"CHAPI",description:"Credential Handler API. Allows sending/retrieving credentials across wallets and issuers",methods:{installChapiHandler:async()=>tP(),activateChapiHandler:async(t,{mediatorOrigin:e=`https://authn.io/mediator?${encodeURIComponent(window.location.origin)}`,get:r,store:n})=>rP({mediatorOrigin:e,get:r,store:n}),receiveChapiEvent:async()=>nP(),storeCredentialViaChapiDidAuth:async(t,e)=>{let r=crypto.randomUUID(),n=window.location.origin,i={web:{VerifiablePresentation:{query:{type:"DIDAuthentication"},challenge:r,domain:n}}},o=await navigator.credentials.get(i);if(!o)return{success:!1,reason:"did not auth"};let a=await t.invoke.verifyPresentation(o.data,{challenge:r,domain:n,proofPurpose:"authentication"});if(a.warnings.length>0||a.errors.length>0)return{success:!1,reason:"auth failed verification"};let f=o.data?.proof?.verificationMethod?.split("#")[0];Array.isArray(e.credentialSubject)||(e.credentialSubject.id=f);let l=await t.invoke.getTestVp(await t.invoke.issueCredential(e));return await t.invoke.storePresentationViaChapi(l)?{success:!0}:{success:!1,reason:"did not store"}},storePresentationViaChapi:async(t,e)=>{let r=new WebCredential("VerifiablePresentation",e);return window.navigator.credentials.store(r)}}}),"getCHAPIPlugin"),Rr;(function(t){t.assertEqual=i=>i;function e(i){}s(e,"assertIs"),c(e,"assertIs"),t.assertIs=e;function r(i){throw new Error}s(r,"assertNever"),c(r,"assertNever"),t.assertNever=r,t.arrayToEnum=i=>{let o={};for(let a of i)o[a]=a;return o},t.getValidEnumValues=i=>{let o=t.objectKeys(i).filter(f=>typeof i[i[f]]!="number"),a={};for(let f of o)a[f]=i[f];return t.objectValues(a)},t.objectValues=i=>t.objectKeys(i).map(function(o){return i[o]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let o=[];for(let a in i)Object.prototype.hasOwnProperty.call(i,a)&&o.push(a);return o},t.find=(i,o)=>{for(let a of i)if(o(a))return a},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,o=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}s(n,"joinValues"),c(n,"joinValues"),t.joinValues=n,t.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(Rr||(Rr={}));var wt=Rr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Nf=c(t=>{switch(typeof t){case"undefined":return wt.undefined;case"string":return wt.string;case"number":return isNaN(t)?wt.nan:wt.number;case"boolean":return wt.boolean;case"function":return wt.function;case"bigint":return wt.bigint;case"symbol":return wt.symbol;case"object":return Array.isArray(t)?wt.array:t===null?wt.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?wt.promise:typeof Map<"u"&&t instanceof Map?wt.map:typeof Set<"u"&&t instanceof Set?wt.set:typeof Date<"u"&&t instanceof Date?wt.date:wt.object;default:return wt.unknown}},"getParsedType"),it=Rr.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),zZ=c(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),Oa=s(class extends Error{constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=t}get errors(){return this.issues}format(t){let e=t||function(i){return i.message},r={_errors:[]},n=c(i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(n);else if(o.code==="invalid_return_type")n(o.returnTypeError);else if(o.code==="invalid_arguments")n(o.argumentsError);else if(o.path.length===0)r._errors.push(e(o));else{let a=r,f=0;for(;f<o.path.length;){let l=o.path[f];f===o.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(e(o))):a[l]=a[l]||{_errors:[]},a=a[l],f++}}},"processError");return n(this),r}toString(){return this.message}get message(){return JSON.stringify(this.issues,Rr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=e=>e.message){let e={},r=[];for(let n of this.issues)n.path.length>0?(e[n.path[0]]=e[n.path[0]]||[],e[n.path[0]].push(t(n))):r.push(t(n));return{formErrors:r,fieldErrors:e}}get formErrors(){return this.flatten()}},"ZodError");c(Oa,"ZodError");Oa.create=t=>new Oa(t);var Vp=c((t,e)=>{let r;switch(t.code){case it.invalid_type:t.received===wt.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case it.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Rr.jsonStringifyReplacer)}`;break;case it.unrecognized_keys:r=`Unrecognized key(s) in object: ${Rr.joinValues(t.keys,", ")}`;break;case it.invalid_union:r="Invalid input";break;case it.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Rr.joinValues(t.options)}`;break;case it.invalid_enum_value:r=`Invalid enum value. Expected ${Rr.joinValues(t.options)}, received '${t.received}'`;break;case it.invalid_arguments:r="Invalid function arguments";break;case it.invalid_return_type:r="Invalid function return type";break;case it.invalid_date:r="Invalid date";break;case it.invalid_string:typeof t.validation=="object"?"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Rr.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case it.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(t.minimum)}`:r="Invalid input";break;case it.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(t.maximum)}`:r="Invalid input";break;case it.custom:r="Invalid input";break;case it.invalid_intersection_types:r="Intersection results could not be merged";break;case it.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case it.not_finite:r="Number must be finite";break;default:r=e.defaultError,Rr.assertNever(t)}return{message:r}},"errorMap"),sP=Vp;function oP(t){sP=t}s(oP,"setErrorMap");c(oP,"setErrorMap");function Wp(){return sP}s(Wp,"getErrorMap");c(Wp,"getErrorMap");var l2=c(t=>{let{data:e,path:r,errorMaps:n,issueData:i}=t,o=[...r,...i.path||[]],a={...i,path:o},f="",l=n.filter(u=>!!u).slice().reverse();for(let u of l)f=u(a,{data:e,defaultError:f}).message;return{...i,path:o,message:i.message||f}},"makeIssue"),$Z=[];function St(t,e){let r=l2({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Wp(),Vp].filter(n=>!!n)});t.common.issues.push(r)}s(St,"addIssueToContext");c(St,"addIssueToContext");var Yi=s(class{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,e){let r=[];for(let n of e){if(n.status==="aborted")return Gt;n.status==="dirty"&&t.dirty(),r.push(n.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,e){let r=[];for(let n of e)r.push({key:await n.key,value:await n.value});return Yi.mergeObjectSync(t,r)}static mergeObjectSync(t,e){let r={};for(let n of e){let{key:i,value:o}=n;if(i.status==="aborted"||o.status==="aborted")return Gt;i.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),(typeof o.value<"u"||n.alwaysSet)&&(r[i.value]=o.value)}return{status:t.value,value:r}}},"ParseStatus");c(Yi,"ParseStatus");var Gt=Object.freeze({status:"aborted"}),aP=c(t=>({status:"dirty",value:t}),"DIRTY"),Ri=c(t=>({status:"valid",value:t}),"OK"),v5=c(t=>t.status==="aborted","isAborted"),y5=c(t=>t.status==="dirty","isDirty"),u2=c(t=>t.status==="valid","isValid"),d2=c(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),mr;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(mr||(mr={}));var Ko=s(class{constructor(t,e,r,n){this.parent=t,this.data=e,this._path=r,this._key=n}get path(){return this._path.concat(this._key)}},"ParseInputLazyPath");c(Ko,"ParseInputLazyPath");var wM=c((t,e)=>{if(u2(e))return{success:!0,data:e.value};{if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");let r=new Oa(t.common.issues);return{success:!1,error:r}}},"handleResult");function er(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:c((a,f)=>a.code!=="invalid_type"?{message:f.defaultError}:typeof f.data>"u"?{message:n??f.defaultError}:{message:r??f.defaultError},"customMap"),description:i}}s(er,"processCreateParams");c(er,"processCreateParams");var cr=s(class{constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(t){return Nf(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:Nf(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Yi,ctx:{common:t.parent.common,data:t.data,parsedType:Nf(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let e=this._parse(t);if(d2(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){let e=this._parse(t);return Promise.resolve(e)}parse(t,e){let r=this.safeParse(t,e);if(r.success)return r.data;throw r.error}safeParse(t,e){var r;let n={common:{issues:[],async:(r=e?.async)!==null&&r!==void 0?r:!1,contextualErrorMap:e?.errorMap},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Nf(t)},i=this._parseSync({data:t,path:n.path,parent:n});return wM(n,i)}async parseAsync(t,e){let r=await this.safeParseAsync(t,e);if(r.success)return r.data;throw r.error}async safeParseAsync(t,e){let r={common:{issues:[],contextualErrorMap:e?.errorMap,async:!0},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Nf(t)},n=this._parse({data:t,path:r.path,parent:r}),i=await(d2(n)?n:Promise.resolve(n));return wM(r,i)}refine(t,e){let r=c(n=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(n):e,"getIssueProperties");return this._refinement((n,i)=>{let o=t(n),a=c(()=>i.addIssue({code:it.custom,...r(n)}),"setError");return typeof Promise<"u"&&o instanceof Promise?o.then(f=>f?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,e){return this._refinement((r,n)=>t(r)?!0:(n.addIssue(typeof e=="function"?e(r,n):e),!1))}_refinement(t){return new mo({schema:this,typeName:qt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}optional(){return Fa.create(this,this._def)}nullable(){return $f.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $o.create(this,this._def)}promise(){return nu.create(this,this._def)}or(t){return eh.create([this,t],this._def)}and(t){return th.create(this,t,this._def)}transform(t){return new mo({...er(this._def),schema:this,typeName:qt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let e=typeof t=="function"?t:()=>t;return new sh({...er(this._def),innerType:this,defaultValue:e,typeName:qt.ZodDefault})}brand(){return new ux({typeName:qt.ZodBranded,type:this,...er(this._def)})}catch(t){let e=typeof t=="function"?t:()=>t;return new Qp({...er(this._def),innerType:this,catchValue:e,typeName:qt.ZodCatch})}describe(t){let e=this.constructor;return new e({...this._def,description:t})}pipe(t){return R1.create(this,t)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},"ZodType");c(cr,"ZodType");var GZ=/^c[^\s-]{8,}$/i,KZ=/^[a-z][a-z0-9]*$/,VZ=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,WZ=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|([^-]([a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}))$/,JZ=c(t=>t.precision?t.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}Z$`):t.precision===0?t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"),"datetimeRegex"),Lc=s(class extends cr{constructor(){super(...arguments),this._regex=(t,e,r)=>this.refinement(n=>t.test(n),{validation:e,code:it.invalid_string,...mr.errToObj(r)}),this.nonempty=t=>this.min(1,mr.errToObj(t)),this.trim=()=>new Lc({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==wt.string){let i=this._getOrReturnCtx(t);return St(i,{code:it.invalid_type,expected:wt.string,received:i.parsedType}),Gt}let r=new Yi,n;for(let i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(n=this._getOrReturnCtx(t,n),St(n,{code:it.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")t.data.length>i.value&&(n=this._getOrReturnCtx(t,n),St(n,{code:it.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let o=t.data.length>i.value,a=t.data.length<i.value;(o||a)&&(n=this._getOrReturnCtx(t,n),o?St(n,{code:it.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&St(n,{code:it.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")WZ.test(t.data)||(n=this._getOrReturnCtx(t,n),St(n,{validation:"email",code:it.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")VZ.test(t.data)||(n=this._getOrReturnCtx(t,n),St(n,{validation:"uuid",code:it.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")GZ.test(t.data)||(n=this._getOrReturnCtx(t,n),St(n,{validation:"cuid",code:it.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")KZ.test(t.data)||(n=this._getOrReturnCtx(t,n),St(n,{validation:"cuid2",code:it.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{n=this._getOrReturnCtx(t,n),St(n,{validation:"url",code:it.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(n=this._getOrReturnCtx(t,n),St(n,{validation:"regex",code:it.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="startsWith"?t.data.startsWith(i.value)||(n=this._getOrReturnCtx(t,n),St(n,{code:it.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(n=this._getOrReturnCtx(t,n),St(n,{code:it.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?JZ(i).test(t.data)||(n=this._getOrReturnCtx(t,n),St(n,{code:it.invalid_string,validation:"datetime",message:i.message}),r.dirty()):Rr.assertNever(i);return{status:r.value,value:t.data}}_addCheck(t){return new Lc({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...mr.errToObj(t)})}url(t){return this._addCheck({kind:"url",...mr.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...mr.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...mr.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...mr.errToObj(t)})}datetime(t){var e;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(e=t?.offset)!==null&&e!==void 0?e:!1,...mr.errToObj(t?.message)})}regex(t,e){return this._addCheck({kind:"regex",regex:t,...mr.errToObj(e)})}startsWith(t,e){return this._addCheck({kind:"startsWith",value:t,...mr.errToObj(e)})}endsWith(t,e){return this._addCheck({kind:"endsWith",value:t,...mr.errToObj(e)})}min(t,e){return this._addCheck({kind:"min",value:t,...mr.errToObj(e)})}max(t,e){return this._addCheck({kind:"max",value:t,...mr.errToObj(e)})}length(t,e){return this._addCheck({kind:"length",value:t,...mr.errToObj(e)})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get minLength(){let t=null;for(let e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxLength(){let t=null;for(let e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}},"ZodString");c(Lc,"ZodString");Lc.create=t=>{var e;return new Lc({checks:[],typeName:qt.ZodString,coerce:(e=t?.coerce)!==null&&e!==void 0?e:!1,...er(t)})};function cP(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,o=parseInt(t.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return o%a/Math.pow(10,i)}s(cP,"floatSafeRemainder");c(cP,"floatSafeRemainder");var Hf=s(class extends cr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==wt.number){let i=this._getOrReturnCtx(t);return St(i,{code:it.invalid_type,expected:wt.number,received:i.parsedType}),Gt}let r,n=new Yi;for(let i of this._def.checks)i.kind==="int"?Rr.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),St(r,{code:it.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),St(r,{code:it.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),St(r,{code:it.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?cP(t.data,i.value)!==0&&(r=this._getOrReturnCtx(t,r),St(r,{code:it.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),St(r,{code:it.not_finite,message:i.message}),n.dirty()):Rr.assertNever(i);return{status:n.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,mr.toString(e))}gt(t,e){return this.setLimit("min",t,!1,mr.toString(e))}lte(t,e){return this.setLimit("max",t,!0,mr.toString(e))}lt(t,e){return this.setLimit("max",t,!1,mr.toString(e))}setLimit(t,e,r,n){return new Hf({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:mr.toString(n)}]})}_addCheck(t){return new Hf({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:mr.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:mr.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:mr.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:mr.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:mr.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:mr.toString(e)})}finite(t){return this._addCheck({kind:"finite",message:mr.toString(t)})}get minValue(){let t=null;for(let e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(let e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Rr.isInteger(t.value))}get isFinite(){let t=null,e=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(e===null||r.value>e)&&(e=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(e)&&Number.isFinite(t)}},"ZodNumber");c(Hf,"ZodNumber");Hf.create=t=>new Hf({checks:[],typeName:qt.ZodNumber,coerce:t?.coerce||!1,...er(t)});var Yd=s(class extends cr{_parse(t){if(this._def.coerce&&(t.data=BigInt(t.data)),this._getType(t)!==wt.bigint){let r=this._getOrReturnCtx(t);return St(r,{code:it.invalid_type,expected:wt.bigint,received:r.parsedType}),Gt}return Ri(t.data)}},"ZodBigInt");c(Yd,"ZodBigInt");Yd.create=t=>{var e;return new Yd({typeName:qt.ZodBigInt,coerce:(e=t?.coerce)!==null&&e!==void 0?e:!1,...er(t)})};var Zd=s(class extends cr{_parse(t){if(this._def.coerce&&(t.data=Boolean(t.data)),this._getType(t)!==wt.boolean){let r=this._getOrReturnCtx(t);return St(r,{code:it.invalid_type,expected:wt.boolean,received:r.parsedType}),Gt}return Ri(t.data)}},"ZodBoolean");c(Zd,"ZodBoolean");Zd.create=t=>new Zd({typeName:qt.ZodBoolean,coerce:t?.coerce||!1,...er(t)});var eu=s(class extends cr{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==wt.date){let i=this._getOrReturnCtx(t);return St(i,{code:it.invalid_type,expected:wt.date,received:i.parsedType}),Gt}if(isNaN(t.data.getTime())){let i=this._getOrReturnCtx(t);return St(i,{code:it.invalid_date}),Gt}let r=new Yi,n;for(let i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(n=this._getOrReturnCtx(t,n),St(n,{code:it.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(n=this._getOrReturnCtx(t,n),St(n,{code:it.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):Rr.assertNever(i);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new eu({...this._def,checks:[...this._def.checks,t]})}min(t,e){return this._addCheck({kind:"min",value:t.getTime(),message:mr.toString(e)})}max(t,e){return this._addCheck({kind:"max",value:t.getTime(),message:mr.toString(e)})}get minDate(){let t=null;for(let e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t!=null?new Date(t):null}},"ZodDate");c(eu,"ZodDate");eu.create=t=>new eu({checks:[],coerce:t?.coerce||!1,typeName:qt.ZodDate,...er(t)});var Jp=s(class extends cr{_parse(t){if(this._getType(t)!==wt.symbol){let r=this._getOrReturnCtx(t);return St(r,{code:it.invalid_type,expected:wt.symbol,received:r.parsedType}),Gt}return Ri(t.data)}},"ZodSymbol");c(Jp,"ZodSymbol");Jp.create=t=>new Jp({typeName:qt.ZodSymbol,...er(t)});var Xd=s(class extends cr{_parse(t){if(this._getType(t)!==wt.undefined){let r=this._getOrReturnCtx(t);return St(r,{code:it.invalid_type,expected:wt.undefined,received:r.parsedType}),Gt}return Ri(t.data)}},"ZodUndefined");c(Xd,"ZodUndefined");Xd.create=t=>new Xd({typeName:qt.ZodUndefined,...er(t)});var Qd=s(class extends cr{_parse(t){if(this._getType(t)!==wt.null){let r=this._getOrReturnCtx(t);return St(r,{code:it.invalid_type,expected:wt.null,received:r.parsedType}),Gt}return Ri(t.data)}},"ZodNull");c(Qd,"ZodNull");Qd.create=t=>new Qd({typeName:qt.ZodNull,...er(t)});var tu=s(class extends cr{constructor(){super(...arguments),this._any=!0}_parse(t){return Ri(t.data)}},"ZodAny");c(tu,"ZodAny");tu.create=t=>new tu({typeName:qt.ZodAny,...er(t)});var Lf=s(class extends cr{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ri(t.data)}},"ZodUnknown");c(Lf,"ZodUnknown");Lf.create=t=>new Lf({typeName:qt.ZodUnknown,...er(t)});var Na=s(class extends cr{_parse(t){let e=this._getOrReturnCtx(t);return St(e,{code:it.invalid_type,expected:wt.never,received:e.parsedType}),Gt}},"ZodNever");c(Na,"ZodNever");Na.create=t=>new Na({typeName:qt.ZodNever,...er(t)});var Yp=s(class extends cr{_parse(t){if(this._getType(t)!==wt.undefined){let r=this._getOrReturnCtx(t);return St(r,{code:it.invalid_type,expected:wt.void,received:r.parsedType}),Gt}return Ri(t.data)}},"ZodVoid");c(Yp,"ZodVoid");Yp.create=t=>new Yp({typeName:qt.ZodVoid,...er(t)});var $o=s(class extends cr{_parse(t){let{ctx:e,status:r}=this._processInputParams(t),n=this._def;if(e.parsedType!==wt.array)return St(e,{code:it.invalid_type,expected:wt.array,received:e.parsedType}),Gt;if(n.exactLength!==null){let o=e.data.length>n.exactLength.value,a=e.data.length<n.exactLength.value;(o||a)&&(St(e,{code:o?it.too_big:it.too_small,minimum:a?n.exactLength.value:void 0,maximum:o?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(n.minLength!==null&&e.data.length<n.minLength.value&&(St(e,{code:it.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),n.maxLength!==null&&e.data.length>n.maxLength.value&&(St(e,{code:it.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),e.common.async)return Promise.all([...e.data].map((o,a)=>n.type._parseAsync(new Ko(e,o,e.path,a)))).then(o=>Yi.mergeArray(r,o));let i=[...e.data].map((o,a)=>n.type._parseSync(new Ko(e,o,e.path,a)));return Yi.mergeArray(r,i)}get element(){return this._def.type}min(t,e){return new $o({...this._def,minLength:{value:t,message:mr.toString(e)}})}max(t,e){return new $o({...this._def,maxLength:{value:t,message:mr.toString(e)}})}length(t,e){return new $o({...this._def,exactLength:{value:t,message:mr.toString(e)}})}nonempty(t){return this.min(1,t)}},"ZodArray");c($o,"ZodArray");$o.create=(t,e)=>new $o({type:t,minLength:null,maxLength:null,exactLength:null,typeName:qt.ZodArray,...er(e)});var h2;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(h2||(h2={}));function Kl(t){if(t instanceof pn){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=Fa.create(Kl(n))}return new pn({...t._def,shape:()=>e})}else return t instanceof $o?$o.create(Kl(t.element)):t instanceof Fa?Fa.create(Kl(t.unwrap())):t instanceof $f?$f.create(Kl(t.unwrap())):t instanceof La?La.create(t.items.map(e=>Kl(e))):t}s(Kl,"deepPartialify");c(Kl,"deepPartialify");var pn=s(class extends cr{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),e=Rr.objectKeys(t);return this._cached={shape:t,keys:e}}_parse(t){if(this._getType(t)!==wt.object){let l=this._getOrReturnCtx(t);return St(l,{code:it.invalid_type,expected:wt.object,received:l.parsedType}),Gt}let{status:r,ctx:n}=this._processInputParams(t),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Na&&this._def.unknownKeys==="strip"))for(let l in n.data)o.includes(l)||a.push(l);let f=[];for(let l of o){let u=i[l],h=n.data[l];f.push({key:{status:"valid",value:l},value:u._parse(new Ko(n,h,n.path,l)),alwaysSet:l in n.data})}if(this._def.catchall instanceof Na){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of a)f.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(l==="strict")a.length>0&&(St(n,{code:it.unrecognized_keys,keys:a}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of a){let h=n.data[u];f.push({key:{status:"valid",value:u},value:l._parse(new Ko(n,h,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of f){let h=await u.key;l.push({key:h,value:await u.value,alwaysSet:u.alwaysSet})}return l}).then(l=>Yi.mergeObjectSync(r,l)):Yi.mergeObjectSync(r,f)}get shape(){return this._def.shape()}strict(t){return mr.errToObj,new pn({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(e,r)=>{var n,i,o,a;let f=(o=(i=(n=this._def).errorMap)===null||i===void 0?void 0:i.call(n,e,r).message)!==null&&o!==void 0?o:r.defaultError;return e.code==="unrecognized_keys"?{message:(a=mr.errToObj(t).message)!==null&&a!==void 0?a:f}:{message:f}}}:{}})}strip(){return new pn({...this._def,unknownKeys:"strip"})}passthrough(){return new pn({...this._def,unknownKeys:"passthrough"})}extend(t){return new pn({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new pn({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>h2.mergeShapes(this._def.shape(),t._def.shape()),typeName:qt.ZodObject})}setKey(t,e){return this.augment({[t]:e})}catchall(t){return new pn({...this._def,catchall:t})}pick(t){let e={};return Rr.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(e[r]=this.shape[r])}),new pn({...this._def,shape:()=>e})}omit(t){let e={};return Rr.objectKeys(this.shape).forEach(r=>{t[r]||(e[r]=this.shape[r])}),new pn({...this._def,shape:()=>e})}deepPartial(){return Kl(this)}partial(t){let e={};return Rr.objectKeys(this.shape).forEach(r=>{let n=this.shape[r];t&&!t[r]?e[r]=n:e[r]=n.optional()}),new pn({...this._def,shape:()=>e})}required(t){let e={};return Rr.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])e[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Fa;)i=i._def.innerType;e[r]=i}}),new pn({...this._def,shape:()=>e})}keyof(){return lx(Rr.objectKeys(this.shape))}},"ZodObject");c(pn,"ZodObject");pn.create=(t,e)=>new pn({shape:()=>t,unknownKeys:"strip",catchall:Na.create(),typeName:qt.ZodObject,...er(e)});pn.strictCreate=(t,e)=>new pn({shape:()=>t,unknownKeys:"strict",catchall:Na.create(),typeName:qt.ZodObject,...er(e)});pn.lazycreate=(t,e)=>new pn({shape:t,unknownKeys:"strip",catchall:Na.create(),typeName:qt.ZodObject,...er(e)});var eh=s(class extends cr{_parse(t){let{ctx:e}=this._processInputParams(t),r=this._def.options;function n(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return e.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new Oa(a.ctx.common.issues));return St(e,{code:it.invalid_union,unionErrors:o}),Gt}if(s(n,"handleResults"),c(n,"handleResults"),e.common.async)return Promise.all(r.map(async i=>{let o={...e,common:{...e.common,issues:[]},parent:null};return{result:await i._parseAsync({data:e.data,path:e.path,parent:o}),ctx:o}})).then(n);{let i,o=[];for(let f of r){let l={...e,common:{...e.common,issues:[]},parent:null},u=f._parseSync({data:e.data,path:e.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(i)return e.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(f=>new Oa(f));return St(e,{code:it.invalid_union,unionErrors:a}),Gt}}get options(){return this._def.options}},"ZodUnion");c(eh,"ZodUnion");eh.create=(t,e)=>new eh({options:t,typeName:qt.ZodUnion,...er(e)});var Ub=c(t=>t instanceof rh?Ub(t.schema):t instanceof mo?Ub(t.innerType()):t instanceof nh?[t.value]:t instanceof zf?t.options:t instanceof ih?Object.keys(t.enum):t instanceof sh?Ub(t._def.innerType):t instanceof Xd?[void 0]:t instanceof Qd?[null]:null,"getDiscriminator"),bv=s(class extends cr{_parse(t){let{ctx:e}=this._processInputParams(t);if(e.parsedType!==wt.object)return St(e,{code:it.invalid_type,expected:wt.object,received:e.parsedType}),Gt;let r=this.discriminator,n=e.data[r],i=this.optionsMap.get(n);return i?e.common.async?i._parseAsync({data:e.data,path:e.path,parent:e}):i._parseSync({data:e.data,path:e.path,parent:e}):(St(e,{code:it.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Gt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,e,r){let n=new Map;for(let i of e){let o=Ub(i.shape[t]);if(!o)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let a of o){if(n.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);n.set(a,i)}}return new bv({typeName:qt.ZodDiscriminatedUnion,discriminator:t,options:e,optionsMap:n,...er(r)})}},"ZodDiscriminatedUnion");c(bv,"ZodDiscriminatedUnion");function p2(t,e){let r=Nf(t),n=Nf(e);if(t===e)return{valid:!0,data:t};if(r===wt.object&&n===wt.object){let i=Rr.objectKeys(e),o=Rr.objectKeys(t).filter(f=>i.indexOf(f)!==-1),a={...t,...e};for(let f of o){let l=p2(t[f],e[f]);if(!l.valid)return{valid:!1};a[f]=l.data}return{valid:!0,data:a}}else if(r===wt.array&&n===wt.array){if(t.length!==e.length)return{valid:!1};let i=[];for(let o=0;o<t.length;o++){let a=t[o],f=e[o],l=p2(a,f);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return r===wt.date&&n===wt.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}s(p2,"mergeValues");c(p2,"mergeValues");var th=s(class extends cr{_parse(t){let{status:e,ctx:r}=this._processInputParams(t),n=c((i,o)=>{if(v5(i)||v5(o))return Gt;let a=p2(i.value,o.value);return a.valid?((y5(i)||y5(o))&&e.dirty(),{status:e.value,value:a.data}):(St(r,{code:it.invalid_intersection_types}),Gt)},"handleParsed");return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>n(i,o)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}},"ZodIntersection");c(th,"ZodIntersection");th.create=(t,e,r)=>new th({left:t,right:e,typeName:qt.ZodIntersection,...er(r)});var La=s(class extends cr{_parse(t){let{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==wt.array)return St(r,{code:it.invalid_type,expected:wt.array,received:r.parsedType}),Gt;if(r.data.length<this._def.items.length)return St(r,{code:it.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Gt;!this._def.rest&&r.data.length>this._def.items.length&&(St(r,{code:it.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());let i=[...r.data].map((o,a)=>{let f=this._def.items[a]||this._def.rest;return f?f._parse(new Ko(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>Yi.mergeArray(e,o)):Yi.mergeArray(e,i)}get items(){return this._def.items}rest(t){return new La({...this._def,rest:t})}},"ZodTuple");c(La,"ZodTuple");La.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new La({items:t,typeName:qt.ZodTuple,rest:null,...er(e)})};var Zp=s(class extends cr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==wt.object)return St(r,{code:it.invalid_type,expected:wt.object,received:r.parsedType}),Gt;let n=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)n.push({key:i._parse(new Ko(r,a,r.path,a)),value:o._parse(new Ko(r,r.data[a],r.path,a))});return r.common.async?Yi.mergeObjectAsync(e,n):Yi.mergeObjectSync(e,n)}get element(){return this._def.valueType}static create(t,e,r){return e instanceof cr?new Zp({keyType:t,valueType:e,typeName:qt.ZodRecord,...er(r)}):new Zp({keyType:Lc.create(),valueType:t,typeName:qt.ZodRecord,...er(e)})}},"ZodRecord");c(Zp,"ZodRecord");var Xp=s(class extends cr{_parse(t){let{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==wt.map)return St(r,{code:it.invalid_type,expected:wt.map,received:r.parsedType}),Gt;let n=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,f],l)=>({key:n._parse(new Ko(r,a,r.path,[l,"key"])),value:i._parse(new Ko(r,f,r.path,[l,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let f of o){let l=await f.key,u=await f.value;if(l.status==="aborted"||u.status==="aborted")return Gt;(l.status==="dirty"||u.status==="dirty")&&e.dirty(),a.set(l.value,u.value)}return{status:e.value,value:a}})}else{let a=new Map;for(let f of o){let l=f.key,u=f.value;if(l.status==="aborted"||u.status==="aborted")return Gt;(l.status==="dirty"||u.status==="dirty")&&e.dirty(),a.set(l.value,u.value)}return{status:e.value,value:a}}}},"ZodMap");c(Xp,"ZodMap");Xp.create=(t,e,r)=>new Xp({valueType:e,keyType:t,typeName:qt.ZodMap,...er(r)});var ru=s(class extends cr{_parse(t){let{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==wt.set)return St(r,{code:it.invalid_type,expected:wt.set,received:r.parsedType}),Gt;let n=this._def;n.minSize!==null&&r.data.size<n.minSize.value&&(St(r,{code:it.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),e.dirty()),n.maxSize!==null&&r.data.size>n.maxSize.value&&(St(r,{code:it.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),e.dirty());let i=this._def.valueType;function o(f){let l=new Set;for(let u of f){if(u.status==="aborted")return Gt;u.status==="dirty"&&e.dirty(),l.add(u.value)}return{status:e.value,value:l}}s(o,"finalizeSet"),c(o,"finalizeSet");let a=[...r.data.values()].map((f,l)=>i._parse(new Ko(r,f,r.path,l)));return r.common.async?Promise.all(a).then(f=>o(f)):o(a)}min(t,e){return new ru({...this._def,minSize:{value:t,message:mr.toString(e)}})}max(t,e){return new ru({...this._def,maxSize:{value:t,message:mr.toString(e)}})}size(t,e){return this.min(t,e).max(t,e)}nonempty(t){return this.min(1,t)}},"ZodSet");c(ru,"ZodSet");ru.create=(t,e)=>new ru({valueType:t,minSize:null,maxSize:null,typeName:qt.ZodSet,...er(e)});var zd=s(class extends cr{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:e}=this._processInputParams(t);if(e.parsedType!==wt.function)return St(e,{code:it.invalid_type,expected:wt.function,received:e.parsedType}),Gt;function r(a,f){return l2({data:a,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Wp(),Vp].filter(l=>!!l),issueData:{code:it.invalid_arguments,argumentsError:f}})}s(r,"makeArgsIssue"),c(r,"makeArgsIssue");function n(a,f){return l2({data:a,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Wp(),Vp].filter(l=>!!l),issueData:{code:it.invalid_return_type,returnTypeError:f}})}s(n,"makeReturnsIssue"),c(n,"makeReturnsIssue");let i={errorMap:e.common.contextualErrorMap},o=e.data;return this._def.returns instanceof nu?Ri(async(...a)=>{let f=new Oa([]),l=await this._def.args.parseAsync(a,i).catch(g=>{throw f.addIssue(r(a,g)),f}),u=await o(...l);return await this._def.returns._def.type.parseAsync(u,i).catch(g=>{throw f.addIssue(n(u,g)),f})}):Ri((...a)=>{let f=this._def.args.safeParse(a,i);if(!f.success)throw new Oa([r(a,f.error)]);let l=o(...f.data),u=this._def.returns.safeParse(l,i);if(!u.success)throw new Oa([n(l,u.error)]);return u.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new zd({...this._def,args:La.create(t).rest(Lf.create())})}returns(t){return new zd({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,e,r){return new zd({args:t||La.create([]).rest(Lf.create()),returns:e||Lf.create(),typeName:qt.ZodFunction,...er(r)})}},"ZodFunction");c(zd,"ZodFunction");var rh=s(class extends cr{get schema(){return this._def.getter()}_parse(t){let{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}},"ZodLazy");c(rh,"ZodLazy");rh.create=(t,e)=>new rh({getter:t,typeName:qt.ZodLazy,...er(e)});var nh=s(class extends cr{_parse(t){if(t.data!==this._def.value){let e=this._getOrReturnCtx(t);return St(e,{received:e.data,code:it.invalid_literal,expected:this._def.value}),Gt}return{status:"valid",value:t.data}}get value(){return this._def.value}},"ZodLiteral");c(nh,"ZodLiteral");nh.create=(t,e)=>new nh({value:t,typeName:qt.ZodLiteral,...er(e)});function lx(t,e){return new zf({values:t,typeName:qt.ZodEnum,...er(e)})}s(lx,"createZodEnum");c(lx,"createZodEnum");var zf=s(class extends cr{_parse(t){if(typeof t.data!="string"){let e=this._getOrReturnCtx(t),r=this._def.values;return St(e,{expected:Rr.joinValues(r),received:e.parsedType,code:it.invalid_type}),Gt}if(this._def.values.indexOf(t.data)===-1){let e=this._getOrReturnCtx(t),r=this._def.values;return St(e,{received:e.data,code:it.invalid_enum_value,options:r}),Gt}return Ri(t.data)}get options(){return this._def.values}get enum(){let t={};for(let e of this._def.values)t[e]=e;return t}get Values(){let t={};for(let e of this._def.values)t[e]=e;return t}get Enum(){let t={};for(let e of this._def.values)t[e]=e;return t}extract(t){return zf.create(t)}exclude(t){return zf.create(this.options.filter(e=>!t.includes(e)))}},"ZodEnum");c(zf,"ZodEnum");zf.create=lx;var ih=s(class extends cr{_parse(t){let e=Rr.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==wt.string&&r.parsedType!==wt.number){let n=Rr.objectValues(e);return St(r,{expected:Rr.joinValues(n),received:r.parsedType,code:it.invalid_type}),Gt}if(e.indexOf(t.data)===-1){let n=Rr.objectValues(e);return St(r,{received:r.data,code:it.invalid_enum_value,options:n}),Gt}return Ri(t.data)}get enum(){return this._def.values}},"ZodNativeEnum");c(ih,"ZodNativeEnum");ih.create=(t,e)=>new ih({values:t,typeName:qt.ZodNativeEnum,...er(e)});var nu=s(class extends cr{unwrap(){return this._def.type}_parse(t){let{ctx:e}=this._processInputParams(t);if(e.parsedType!==wt.promise&&e.common.async===!1)return St(e,{code:it.invalid_type,expected:wt.promise,received:e.parsedType}),Gt;let r=e.parsedType===wt.promise?e.data:Promise.resolve(e.data);return Ri(r.then(n=>this._def.type.parseAsync(n,{path:e.path,errorMap:e.common.contextualErrorMap})))}},"ZodPromise");c(nu,"ZodPromise");nu.create=(t,e)=>new nu({type:t,typeName:qt.ZodPromise,...er(e)});var mo=s(class extends cr{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===qt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:e,ctx:r}=this._processInputParams(t),n=this._def.effect||null;if(n.type==="preprocess"){let o=n.transform(r.data);return r.common.async?Promise.resolve(o).then(a=>this._def.schema._parseAsync({data:a,path:r.path,parent:r})):this._def.schema._parseSync({data:o,path:r.path,parent:r})}let i={addIssue:o=>{St(r,o),o.fatal?e.abort():e.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),n.type==="refinement"){let o=c(a=>{let f=n.refinement(a,i);if(r.common.async)return Promise.resolve(f);if(f instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a},"executeRefinement");if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Gt:(a.status==="dirty"&&e.dirty(),o(a.value),{status:e.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Gt:(a.status==="dirty"&&e.dirty(),o(a.value).then(()=>({status:e.value,value:a.value}))))}if(n.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!u2(o))return o;let a=n.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>u2(o)?Promise.resolve(n.transform(o.value,i)).then(a=>({status:e.value,value:a})):o);Rr.assertNever(n)}},"ZodEffects");c(mo,"ZodEffects");mo.create=(t,e,r)=>new mo({schema:t,typeName:qt.ZodEffects,effect:e,...er(r)});mo.createWithPreprocess=(t,e,r)=>new mo({schema:e,effect:{type:"preprocess",transform:t},typeName:qt.ZodEffects,...er(r)});var Fa=s(class extends cr{_parse(t){return this._getType(t)===wt.undefined?Ri(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}},"ZodOptional");c(Fa,"ZodOptional");Fa.create=(t,e)=>new Fa({innerType:t,typeName:qt.ZodOptional,...er(e)});var $f=s(class extends cr{_parse(t){return this._getType(t)===wt.null?Ri(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}},"ZodNullable");c($f,"ZodNullable");$f.create=(t,e)=>new $f({innerType:t,typeName:qt.ZodNullable,...er(e)});var sh=s(class extends cr{_parse(t){let{ctx:e}=this._processInputParams(t),r=e.data;return e.parsedType===wt.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:e.path,parent:e})}removeDefault(){return this._def.innerType}},"ZodDefault");c(sh,"ZodDefault");sh.create=(t,e)=>new sh({innerType:t,typeName:qt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...er(e)});var Qp=s(class extends cr{_parse(t){let{ctx:e}=this._processInputParams(t),r=this._def.innerType._parse({data:e.data,path:e.path,parent:{...e,common:{...e.common,issues:[]}}});return d2(r)?r.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue()})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue()}}removeCatch(){return this._def.innerType}},"ZodCatch");c(Qp,"ZodCatch");Qp.create=(t,e)=>new Qp({innerType:t,typeName:qt.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...er(e)});var e1=s(class extends cr{_parse(t){if(this._getType(t)!==wt.nan){let r=this._getOrReturnCtx(t);return St(r,{code:it.invalid_type,expected:wt.nan,received:r.parsedType}),Gt}return{status:"valid",value:t.data}}},"ZodNaN");c(e1,"ZodNaN");e1.create=t=>new e1({typeName:qt.ZodNaN,...er(t)});var YZ=Symbol("zod_brand"),ux=s(class extends cr{_parse(t){let{ctx:e}=this._processInputParams(t),r=e.data;return this._def.type._parse({data:r,path:e.path,parent:e})}unwrap(){return this._def.type}},"ZodBranded");c(ux,"ZodBranded");var R1=s(class extends cr{_parse(t){let{status:e,ctx:r}=this._processInputParams(t);if(r.common.async)return c(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Gt:i.status==="dirty"?(e.dirty(),aP(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})},"handleAsync")();{let n=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return n.status==="aborted"?Gt:n.status==="dirty"?(e.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:r.path,parent:r})}}static create(t,e){return new R1({in:t,out:e,typeName:qt.ZodPipeline})}},"ZodPipeline");c(R1,"ZodPipeline");var fP=c((t,e={},r)=>t?tu.create().superRefine((n,i)=>{if(!t(n)){let o=typeof e=="function"?e(n):e,a=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...a,fatal:r})}}):tu.create(),"custom"),ZZ={object:pn.lazycreate},qt;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline"})(qt||(qt={}));var XZ=c((t,e={message:`Input not instance of ${t.name}`})=>fP(r=>r instanceof t,e,!0),"instanceOfType"),lP=Lc.create,uP=Hf.create,QZ=e1.create,eX=Yd.create,dP=Zd.create,tX=eu.create,rX=Jp.create,nX=Xd.create,iX=Qd.create,sX=tu.create,oX=Lf.create,aX=Na.create,cX=Yp.create,fX=$o.create,lX=pn.create,uX=pn.strictCreate,dX=eh.create,hX=bv.create,pX=th.create,mX=La.create,gX=Zp.create,bX=Xp.create,vX=ru.create,yX=zd.create,xX=rh.create,wX=nh.create,_X=zf.create,AX=ih.create,EX=nu.create,_M=mo.create,CX=Fa.create,SX=$f.create,IX=mo.createWithPreprocess,kX=R1.create,TX=c(()=>lP().optional(),"ostring"),MX=c(()=>uP().optional(),"onumber"),RX=c(()=>dP().optional(),"oboolean"),BX={string:t=>Lc.create({...t,coerce:!0}),number:t=>Hf.create({...t,coerce:!0}),boolean:t=>Zd.create({...t,coerce:!0}),bigint:t=>Yd.create({...t,coerce:!0}),date:t=>eu.create({...t,coerce:!0})},DX=Gt,we=Object.freeze({__proto__:null,defaultErrorMap:Vp,setErrorMap:oP,getErrorMap:Wp,makeIssue:l2,EMPTY_PATH:$Z,addIssueToContext:St,ParseStatus:Yi,INVALID:Gt,DIRTY:aP,OK:Ri,isAborted:v5,isDirty:y5,isValid:u2,isAsync:d2,get util(){return Rr},ZodParsedType:wt,getParsedType:Nf,ZodType:cr,ZodString:Lc,ZodNumber:Hf,ZodBigInt:Yd,ZodBoolean:Zd,ZodDate:eu,ZodSymbol:Jp,ZodUndefined:Xd,ZodNull:Qd,ZodAny:tu,ZodUnknown:Lf,ZodNever:Na,ZodVoid:Yp,ZodArray:$o,get objectUtil(){return h2},ZodObject:pn,ZodUnion:eh,ZodDiscriminatedUnion:bv,ZodIntersection:th,ZodTuple:La,ZodRecord:Zp,ZodMap:Xp,ZodSet:ru,ZodFunction:zd,ZodLazy:rh,ZodLiteral:nh,ZodEnum:zf,ZodNativeEnum:ih,ZodPromise:nu,ZodEffects:mo,ZodTransformer:mo,ZodOptional:Fa,ZodNullable:$f,ZodDefault:sh,ZodCatch:Qp,ZodNaN:e1,BRAND:YZ,ZodBranded:ux,ZodPipeline:R1,custom:fP,Schema:cr,ZodSchema:cr,late:ZZ,get ZodFirstPartyTypeKind(){return qt},coerce:BX,any:sX,array:fX,bigint:eX,boolean:dP,date:tX,discriminatedUnion:hX,effect:_M,enum:_X,function:yX,instanceof:XZ,intersection:pX,lazy:xX,literal:wX,map:bX,nan:QZ,nativeEnum:AX,never:aX,null:iX,nullable:SX,number:uP,object:lX,oboolean:RX,onumber:MX,optional:CX,ostring:TX,pipeline:kX,preprocess:IX,promise:EX,record:gX,set:vX,strictObject:uX,string:lP,symbol:rX,transformer:_M,tuple:mX,undefined:nX,union:dX,unknown:oX,void:cX,NEVER:DX,ZodIssueCode:it,quotelessJson:zZ,ZodError:Oa}),hP=we.array(we.string().or(we.record(we.any()))),Ape=we.object({type:we.string().optional(),narrative:we.string().optional()}),vv=we.string().or(we.object({id:we.string(),type:we.string(),caption:we.string().optional()})),PX=we.object({type:we.string().min(1).or(we.string().array().nonempty()),latitude:we.number(),longitude:we.number()}),OX=we.object({type:we.string().min(1).or(we.string().array().nonempty()),addressCountry:we.string().optional(),addressCountryCode:we.string().optional(),addressRegion:we.string().optional(),addressLocality:we.string().optional(),streetAddress:we.string().optional(),postOfficeBoxNumber:we.string().optional(),postalCode:we.string().optional(),geo:PX.optional()}),FX=we.enum(["sourcedId","systemId","productId","userName","accountId","emailAddress","nationalIdentityNumber","isbn","issn","lisSourcedId","oneRosterSourcedId","sisSourcedId","ltiContextId","ltiDeploymentId","ltiToolId","ltiPlatformId","ltiUserId","identifier"]).or(we.string()),pP=we.object({type:we.string().min(1).or(we.string().array().nonempty()),identifier:we.string(),identifierType:FX}),t1=we.string().or(we.object({id:we.string().optional(),type:we.string().or(we.string().array().nonempty().optional()),name:we.string().optional(),url:we.string().optional(),phone:we.string().optional(),description:we.string().optional(),endorsement:we.any().array().optional(),image:vv.optional(),email:we.string().email().optional(),address:OX.optional(),otherIdentifier:pP.array().optional(),official:we.string().optional(),parentOrg:we.any().optional(),familyName:we.string().optional(),givenName:we.string().optional(),additionalName:we.string().optional(),patronymicName:we.string().optional(),honorificPrefix:we.string().optional(),honorificSuffix:we.string().optional(),familyNamePrefix:we.string().optional(),dateOfBirth:we.string().optional()}).catchall(we.any())),x5=we.object({id:we.string().optional()}).catchall(we.any()),NX=we.object({type:we.string(),id:we.string()}),LX=we.object({id:we.string(),type:we.string()}),UX=we.object({id:we.string(),type:we.string()}).catchall(we.any()),r1=we.object({"@context":hP,id:we.string().optional(),type:we.string().array().nonempty(),issuer:t1,issuanceDate:we.string(),expirationDate:we.string().optional(),credentialSubject:x5.or(x5.array()),credentialStatus:NX.optional(),credentialSchema:LX.array().optional(),refreshService:UX.optional()}).catchall(we.any()),Gf=we.object({type:we.string(),created:we.string(),challenge:we.string().optional(),domain:we.string().optional(),nonce:we.string().optional(),proofPurpose:we.string(),verificationMethod:we.string(),jws:we.string().optional()}).catchall(we.any()),Fc=r1.extend({proof:Gf.or(Gf.array())}),mP=we.object({"@context":hP,id:we.string().optional(),type:we.string().array().nonempty(),verifiableCredential:Fc.or(Fc.array()).optional(),holder:we.string().optional()}).catchall(we.any()),m2=mP.extend({proof:Gf.or(Gf.array())}),jX=we.enum(["ceasn:Competency","ceterms:Credential","CFItem","CFRubric","CFRubricCriterion","CFRubricCriterionLevel","CTDL"]).or(we.string()),yv=we.object({type:we.string().array().nonempty(),targetCode:we.string().optional(),targetDescription:we.string().optional(),targetName:we.string(),targetFramework:we.string().optional(),targetType:jX.optional(),targetUrl:we.string()}),qX=we.enum(["Achievement","ApprenticeshipCertificate","Assessment","Assignment","AssociateDegree","Award","Badge","BachelorDegree","Certificate","CertificateOfCompletion","Certification","CommunityService","Competency","Course","CoCurricular","Degree","Diploma","DoctoralDegree","Fieldwork","GeneralEducationDevelopment","JourneymanCertificate","LearningProgram","License","Membership","ProfessionalDoctorate","QualityAssuranceCredential","MasterCertificate","MasterDegree","MicroCredential","ResearchDoctorate","SecondarySchoolDiploma"]),HX=qX.or(we.string()),zX=we.object({id:we.string().optional(),narrative:we.string().optional()}).catchall(we.any()),$X=we.object({id:we.string(),type:we.string().array().nonempty(),endorsementComment:we.string().optional()}),GX=r1.extend({credentialSubject:$X,proof:Gf.or(Gf.array()).optional()}),KX=we.object({id:we.string(),"@language":we.string().optional(),version:we.string().optional()}),VX=we.enum(["GradePointAverage","LetterGrade","Percent","PerformanceLevel","PredictedScore","RawScore","Result","RubricCriterion","RubricCriterionLevel","RubricScore","ScaledScore","Status"]).or(we.string()),WX=we.object({id:we.string(),type:we.string().array().nonempty(),alignment:yv.array().optional(),description:we.string().optional(),level:we.string().optional(),name:we.string(),points:we.string().optional()}).catchall(we.any()),JX=we.object({id:we.string(),type:we.string().array().nonempty(),alignment:yv.array().optional(),allowedValue:we.string().array().optional(),name:we.string(),requiredLevel:we.string().optional(),requiredValue:we.string().optional(),resultType:VX,rubricCriterionLevel:WX.array().optional(),valueMax:we.string().optional(),valueMin:we.string().optional()}).catchall(we.any()),YX=we.object({id:we.string().optional(),type:we.string().array().nonempty(),alignment:yv.array().optional(),achievementType:HX.optional(),creator:t1.optional(),creditsAvailable:we.number().optional(),criteria:zX,description:we.string(),endorsement:GX.array().optional(),fieldOfStudy:we.string().optional(),humanCode:we.string().optional(),image:vv.optional(),"@language":we.string().optional(),name:we.string(),otherIdentifier:pP.array().optional(),related:KX.array().optional(),resultDescription:JX.array().optional(),specialization:we.string().optional(),tag:we.string().array().optional(),version:we.string().optional()}).catchall(we.any()),ZX=we.object({type:we.string(),hashed:we.boolean(),identityHash:we.string(),identityType:we.string(),salt:we.string().optional()}),XX=we.enum(["Completed","Enrolled","Failed","InProgress","OnHold","Withdrew"]),QX=we.object({type:we.string().array().nonempty(),achievedLevel:we.string().optional(),alignment:yv.array().optional(),resultDescription:we.string().optional(),status:XX.optional(),value:we.string().optional()}).catchall(we.any()),AM=we.object({id:we.string().optional(),type:we.string().array().nonempty(),activityEndDate:we.string().optional(),activityStartDate:we.string().optional(),creditsEarned:we.number().optional(),achievement:YX.optional(),identifier:ZX.array().optional(),image:vv.optional(),licenseNumber:we.string().optional(),narrative:we.string().optional(),result:QX.array().optional(),role:we.string().optional(),source:t1.optional(),term:we.string().optional()}).catchall(we.any()),eQ=we.object({id:we.string().optional(),type:we.string().array().nonempty(),narrative:we.string().optional(),name:we.string().optional(),description:we.string().optional(),genre:we.string().optional(),audience:we.string().optional()}).catchall(we.any()),tQ=r1.extend({name:we.string().optional(),description:we.string().optional(),image:vv.optional(),credentialSubject:AM.or(AM.array()),endorsement:r1.array().optional(),evidence:eQ.array().optional()}),Epe=tQ.extend({proof:Gf.or(Gf.array())}),EM=we.object({checks:we.string().array(),warnings:we.string().array(),errors:we.string().array()}),gP=we.enum(["Success","Failed","Error"]),$4=gP.enum,Cpe=we.object({check:we.string(),status:gP,message:we.string().optional(),details:we.string().optional()}),Spe=we.object({title:we.string().optional(),createdAt:we.string().optional(),issuer:t1.optional(),issuee:t1.optional(),credentialSubject:x5.optional()}),Up=we.object({id:we.string(),uri:we.string()}).catchall(we.any()),rQ=we.object({profileId:we.string().min(3).max(40),displayName:we.string().default(""),did:we.string(),email:we.string().optional(),image:we.string().optional(),isServiceProfile:we.boolean().default(!1).optional()}),Ipe=we.object({uri:we.string(),to:we.string(),from:we.string(),sent:we.string().datetime(),received:we.string().datetime().optional()}),kpe=we.object({uri:we.string(),name:we.string().optional(),type:we.string().optional(),category:we.string().optional()}),Tpe=we.object({to:rQ,from:we.string(),received:we.string()}),nQ=we.object({kty:we.string(),crv:we.string(),x:we.string(),y:we.string().optional(),n:we.string().optional(),d:we.string()}),iQ=we.object({alg:we.string(),iv:we.string(),tag:we.string(),epk:nQ.partial().optional(),kid:we.string().optional(),apv:we.string().optional(),apu:we.string().optional()}),sQ=we.object({header:iQ,encrypted_key:we.string()}),Mpe=we.object({protected:we.string(),iv:we.string(),ciphertext:we.string(),tag:we.string(),aad:we.string().optional(),recipients:sQ.array().optional()});function Kf(t){if(t===null||t===!0||t===!1)return NaN;var e=Number(t);return isNaN(e)?e:e<0?Math.ceil(e):Math.floor(e)}s(Kf,"toInteger");c(Kf,"toInteger");function Di(t,e){if(e.length<t)throw new TypeError(t+" argument"+(t>1?"s":"")+" required, but only "+e.length+" present")}s(Di,"requiredArgs");c(Di,"requiredArgs");function jp(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?jp=c(s(function(r){return typeof r},"_typeof3"),"_typeof"):jp=c(s(function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},"_typeof3"),"_typeof"),jp(t)}s(jp,"_typeof");c(jp,"_typeof");function Yo(t){Di(1,arguments);var e=Object.prototype.toString.call(t);return t instanceof Date||jp(t)==="object"&&e==="[object Date]"?new Date(t.getTime()):typeof t=="number"||e==="[object Number]"?new Date(t):((typeof t=="string"||e==="[object String]")&&typeof console<"u"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}s(Yo,"toDate");c(Yo,"toDate");function bP(t,e){Di(2,arguments);var r=Yo(t).getTime(),n=Kf(e);return new Date(r+n)}s(bP,"addMilliseconds");c(bP,"addMilliseconds");var oQ={};function B1(){return oQ}s(B1,"getDefaultOptions");c(B1,"getDefaultOptions");function vP(t){var e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return e.setUTCFullYear(t.getFullYear()),t.getTime()-e.getTime()}s(vP,"getTimezoneOffsetInMilliseconds");c(vP,"getTimezoneOffsetInMilliseconds");function qp(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?qp=c(s(function(r){return typeof r},"_typeof3"),"_typeof"):qp=c(s(function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},"_typeof3"),"_typeof"),qp(t)}s(qp,"_typeof2");c(qp,"_typeof");function yP(t){return Di(1,arguments),t instanceof Date||qp(t)==="object"&&Object.prototype.toString.call(t)==="[object Date]"}s(yP,"isDate");c(yP,"isDate");function xP(t){if(Di(1,arguments),!yP(t)&&typeof t!="number")return!1;var e=Yo(t);return!isNaN(Number(e))}s(xP,"isValid2");c(xP,"isValid");function wP(t,e){Di(2,arguments);var r=Kf(e);return bP(t,-r)}s(wP,"subMilliseconds");c(wP,"subMilliseconds");var aQ=864e5;function _P(t){Di(1,arguments);var e=Yo(t),r=e.getTime();e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0);var n=e.getTime(),i=r-n;return Math.floor(i/aQ)+1}s(_P,"getUTCDayOfYear");c(_P,"getUTCDayOfYear");function n1(t){Di(1,arguments);var e=1,r=Yo(t),n=r.getUTCDay(),i=(n<e?7:0)+n-e;return r.setUTCDate(r.getUTCDate()-i),r.setUTCHours(0,0,0,0),r}s(n1,"startOfUTCISOWeek");c(n1,"startOfUTCISOWeek");function dx(t){Di(1,arguments);var e=Yo(t),r=e.getUTCFullYear(),n=new Date(0);n.setUTCFullYear(r+1,0,4),n.setUTCHours(0,0,0,0);var i=n1(n),o=new Date(0);o.setUTCFullYear(r,0,4),o.setUTCHours(0,0,0,0);var a=n1(o);return e.getTime()>=i.getTime()?r+1:e.getTime()>=a.getTime()?r:r-1}s(dx,"getUTCISOWeekYear");c(dx,"getUTCISOWeekYear");function AP(t){Di(1,arguments);var e=dx(t),r=new Date(0);r.setUTCFullYear(e,0,4),r.setUTCHours(0,0,0,0);var n=n1(r);return n}s(AP,"startOfUTCISOWeekYear");c(AP,"startOfUTCISOWeekYear");var cQ=6048e5;function EP(t){Di(1,arguments);var e=Yo(t),r=n1(e).getTime()-AP(e).getTime();return Math.round(r/cQ)+1}s(EP,"getUTCISOWeek");c(EP,"getUTCISOWeek");function i1(t,e){var r,n,i,o,a,f,l,u;Di(1,arguments);var h=B1(),g=Kf((r=(n=(i=(o=e?.weekStartsOn)!==null&&o!==void 0?o:e==null||(a=e.locale)===null||a===void 0||(f=a.options)===null||f===void 0?void 0:f.weekStartsOn)!==null&&i!==void 0?i:h.weekStartsOn)!==null&&n!==void 0?n:(l=h.locale)===null||l===void 0||(u=l.options)===null||u===void 0?void 0:u.weekStartsOn)!==null&&r!==void 0?r:0);if(!(g>=0&&g<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var x=Yo(t),_=x.getUTCDay(),E=(_<g?7:0)+_-g;return x.setUTCDate(x.getUTCDate()-E),x.setUTCHours(0,0,0,0),x}s(i1,"startOfUTCWeek");c(i1,"startOfUTCWeek");function hx(t,e){var r,n,i,o,a,f,l,u;Di(1,arguments);var h=Yo(t),g=h.getUTCFullYear(),x=B1(),_=Kf((r=(n=(i=(o=e?.firstWeekContainsDate)!==null&&o!==void 0?o:e==null||(a=e.locale)===null||a===void 0||(f=a.options)===null||f===void 0?void 0:f.firstWeekContainsDate)!==null&&i!==void 0?i:x.firstWeekContainsDate)!==null&&n!==void 0?n:(l=x.locale)===null||l===void 0||(u=l.options)===null||u===void 0?void 0:u.firstWeekContainsDate)!==null&&r!==void 0?r:1);if(!(_>=1&&_<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var E=new Date(0);E.setUTCFullYear(g+1,0,_),E.setUTCHours(0,0,0,0);var T=i1(E,e),B=new Date(0);B.setUTCFullYear(g,0,_),B.setUTCHours(0,0,0,0);var F=i1(B,e);return h.getTime()>=T.getTime()?g+1:h.getTime()>=F.getTime()?g:g-1}s(hx,"getUTCWeekYear");c(hx,"getUTCWeekYear");function CP(t,e){var r,n,i,o,a,f,l,u;Di(1,arguments);var h=B1(),g=Kf((r=(n=(i=(o=e?.firstWeekContainsDate)!==null&&o!==void 0?o:e==null||(a=e.locale)===null||a===void 0||(f=a.options)===null||f===void 0?void 0:f.firstWeekContainsDate)!==null&&i!==void 0?i:h.firstWeekContainsDate)!==null&&n!==void 0?n:(l=h.locale)===null||l===void 0||(u=l.options)===null||u===void 0?void 0:u.firstWeekContainsDate)!==null&&r!==void 0?r:1),x=hx(t,e),_=new Date(0);_.setUTCFullYear(x,0,g),_.setUTCHours(0,0,0,0);var E=i1(_,e);return E}s(CP,"startOfUTCWeekYear");c(CP,"startOfUTCWeekYear");var fQ=6048e5;function SP(t,e){Di(1,arguments);var r=Yo(t),n=i1(r,e).getTime()-CP(r,e).getTime();return Math.round(n/fQ)+1}s(SP,"getUTCWeek");c(SP,"getUTCWeek");function Br(t,e){for(var r=t<0?"-":"",n=Math.abs(t).toString();n.length<e;)n="0"+n;return r+n}s(Br,"addLeadingZeros");c(Br,"addLeadingZeros");var lQ={y:c(s(function(e,r){var n=e.getUTCFullYear(),i=n>0?n:1-n;return Br(r==="yy"?i%100:i,r.length)},"y"),"y"),M:c(s(function(e,r){var n=e.getUTCMonth();return r==="M"?String(n+1):Br(n+1,2)},"M"),"M"),d:c(s(function(e,r){return Br(e.getUTCDate(),r.length)},"d"),"d"),a:c(s(function(e,r){var n=e.getUTCHours()/12>=1?"pm":"am";switch(r){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},"a"),"a"),h:c(s(function(e,r){return Br(e.getUTCHours()%12||12,r.length)},"h"),"h"),H:c(s(function(e,r){return Br(e.getUTCHours(),r.length)},"H"),"H"),m:c(s(function(e,r){return Br(e.getUTCMinutes(),r.length)},"m"),"m"),s:c(s(function(e,r){return Br(e.getUTCSeconds(),r.length)},"s"),"s"),S:c(s(function(e,r){var n=r.length,i=e.getUTCMilliseconds(),o=Math.floor(i*Math.pow(10,n-3));return Br(o,r.length)},"S"),"S")},Bf=lQ,Rd={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},uQ={G:c(s(function(e,r,n){var i=e.getUTCFullYear()>0?1:0;switch(r){case"G":case"GG":case"GGG":return n.era(i,{width:"abbreviated"});case"GGGGG":return n.era(i,{width:"narrow"});case"GGGG":default:return n.era(i,{width:"wide"})}},"G"),"G"),y:c(s(function(e,r,n){if(r==="yo"){var i=e.getUTCFullYear(),o=i>0?i:1-i;return n.ordinalNumber(o,{unit:"year"})}return Bf.y(e,r)},"y2"),"y"),Y:c(s(function(e,r,n,i){var o=hx(e,i),a=o>0?o:1-o;if(r==="YY"){var f=a%100;return Br(f,2)}return r==="Yo"?n.ordinalNumber(a,{unit:"year"}):Br(a,r.length)},"Y"),"Y"),R:c(s(function(e,r){var n=dx(e);return Br(n,r.length)},"R"),"R"),u:c(s(function(e,r){var n=e.getUTCFullYear();return Br(n,r.length)},"u"),"u"),Q:c(s(function(e,r,n){var i=Math.ceil((e.getUTCMonth()+1)/3);switch(r){case"Q":return String(i);case"QQ":return Br(i,2);case"Qo":return n.ordinalNumber(i,{unit:"quarter"});case"QQQ":return n.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(i,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(i,{width:"wide",context:"formatting"})}},"Q"),"Q"),q:c(s(function(e,r,n){var i=Math.ceil((e.getUTCMonth()+1)/3);switch(r){case"q":return String(i);case"qq":return Br(i,2);case"qo":return n.ordinalNumber(i,{unit:"quarter"});case"qqq":return n.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(i,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(i,{width:"wide",context:"standalone"})}},"q"),"q"),M:c(s(function(e,r,n){var i=e.getUTCMonth();switch(r){case"M":case"MM":return Bf.M(e,r);case"Mo":return n.ordinalNumber(i+1,{unit:"month"});case"MMM":return n.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(i,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(i,{width:"wide",context:"formatting"})}},"M2"),"M"),L:c(s(function(e,r,n){var i=e.getUTCMonth();switch(r){case"L":return String(i+1);case"LL":return Br(i+1,2);case"Lo":return n.ordinalNumber(i+1,{unit:"month"});case"LLL":return n.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(i,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(i,{width:"wide",context:"standalone"})}},"L"),"L"),w:c(s(function(e,r,n,i){var o=SP(e,i);return r==="wo"?n.ordinalNumber(o,{unit:"week"}):Br(o,r.length)},"w"),"w"),I:c(s(function(e,r,n){var i=EP(e);return r==="Io"?n.ordinalNumber(i,{unit:"week"}):Br(i,r.length)},"I"),"I"),d:c(s(function(e,r,n){return r==="do"?n.ordinalNumber(e.getUTCDate(),{unit:"date"}):Bf.d(e,r)},"d2"),"d"),D:c(s(function(e,r,n){var i=_P(e);return r==="Do"?n.ordinalNumber(i,{unit:"dayOfYear"}):Br(i,r.length)},"D"),"D"),E:c(s(function(e,r,n){var i=e.getUTCDay();switch(r){case"E":case"EE":case"EEE":return n.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(i,{width:"short",context:"formatting"});case"EEEE":default:return n.day(i,{width:"wide",context:"formatting"})}},"E"),"E"),e:c(s(function(e,r,n,i){var o=e.getUTCDay(),a=(o-i.weekStartsOn+8)%7||7;switch(r){case"e":return String(a);case"ee":return Br(a,2);case"eo":return n.ordinalNumber(a,{unit:"day"});case"eee":return n.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(o,{width:"short",context:"formatting"});case"eeee":default:return n.day(o,{width:"wide",context:"formatting"})}},"e"),"e"),c:c(s(function(e,r,n,i){var o=e.getUTCDay(),a=(o-i.weekStartsOn+8)%7||7;switch(r){case"c":return String(a);case"cc":return Br(a,r.length);case"co":return n.ordinalNumber(a,{unit:"day"});case"ccc":return n.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(o,{width:"narrow",context:"standalone"});case"cccccc":return n.day(o,{width:"short",context:"standalone"});case"cccc":default:return n.day(o,{width:"wide",context:"standalone"})}},"c"),"c"),i:c(s(function(e,r,n){var i=e.getUTCDay(),o=i===0?7:i;switch(r){case"i":return String(o);case"ii":return Br(o,r.length);case"io":return n.ordinalNumber(o,{unit:"day"});case"iii":return n.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(i,{width:"short",context:"formatting"});case"iiii":default:return n.day(i,{width:"wide",context:"formatting"})}},"i"),"i"),a:c(s(function(e,r,n){var i=e.getUTCHours(),o=i/12>=1?"pm":"am";switch(r){case"a":case"aa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},"a2"),"a"),b:c(s(function(e,r,n){var i=e.getUTCHours(),o;switch(i===12?o=Rd.noon:i===0?o=Rd.midnight:o=i/12>=1?"pm":"am",r){case"b":case"bb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},"b"),"b"),B:c(s(function(e,r,n){var i=e.getUTCHours(),o;switch(i>=17?o=Rd.evening:i>=12?o=Rd.afternoon:i>=4?o=Rd.morning:o=Rd.night,r){case"B":case"BB":case"BBB":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},"B"),"B"),h:c(s(function(e,r,n){if(r==="ho"){var i=e.getUTCHours()%12;return i===0&&(i=12),n.ordinalNumber(i,{unit:"hour"})}return Bf.h(e,r)},"h2"),"h"),H:c(s(function(e,r,n){return r==="Ho"?n.ordinalNumber(e.getUTCHours(),{unit:"hour"}):Bf.H(e,r)},"H2"),"H"),K:c(s(function(e,r,n){var i=e.getUTCHours()%12;return r==="Ko"?n.ordinalNumber(i,{unit:"hour"}):Br(i,r.length)},"K"),"K"),k:c(s(function(e,r,n){var i=e.getUTCHours();return i===0&&(i=24),r==="ko"?n.ordinalNumber(i,{unit:"hour"}):Br(i,r.length)},"k"),"k"),m:c(s(function(e,r,n){return r==="mo"?n.ordinalNumber(e.getUTCMinutes(),{unit:"minute"}):Bf.m(e,r)},"m2"),"m"),s:c(s(function(e,r,n){return r==="so"?n.ordinalNumber(e.getUTCSeconds(),{unit:"second"}):Bf.s(e,r)},"s2"),"s"),S:c(s(function(e,r){return Bf.S(e,r)},"S2"),"S"),X:c(s(function(e,r,n,i){var o=i._originalDate||e,a=o.getTimezoneOffset();if(a===0)return"Z";switch(r){case"X":return _5(a);case"XXXX":case"XX":return Of(a);case"XXXXX":case"XXX":default:return Of(a,":")}},"X"),"X"),x:c(s(function(e,r,n,i){var o=i._originalDate||e,a=o.getTimezoneOffset();switch(r){case"x":return _5(a);case"xxxx":case"xx":return Of(a);case"xxxxx":case"xxx":default:return Of(a,":")}},"x"),"x"),O:c(s(function(e,r,n,i){var o=i._originalDate||e,a=o.getTimezoneOffset();switch(r){case"O":case"OO":case"OOO":return"GMT"+w5(a,":");case"OOOO":default:return"GMT"+Of(a,":")}},"O"),"O"),z:c(s(function(e,r,n,i){var o=i._originalDate||e,a=o.getTimezoneOffset();switch(r){case"z":case"zz":case"zzz":return"GMT"+w5(a,":");case"zzzz":default:return"GMT"+Of(a,":")}},"z"),"z"),t:c(s(function(e,r,n,i){var o=i._originalDate||e,a=Math.floor(o.getTime()/1e3);return Br(a,r.length)},"t"),"t"),T:c(s(function(e,r,n,i){var o=i._originalDate||e,a=o.getTime();return Br(a,r.length)},"T"),"T")};function w5(t,e){var r=t>0?"-":"+",n=Math.abs(t),i=Math.floor(n/60),o=n%60;if(o===0)return r+String(i);var a=e||"";return r+String(i)+a+Br(o,2)}s(w5,"formatTimezoneShort");c(w5,"formatTimezoneShort");function _5(t,e){if(t%60===0){var r=t>0?"-":"+";return r+Br(Math.abs(t)/60,2)}return Of(t,e)}s(_5,"formatTimezoneWithOptionalMinutes");c(_5,"formatTimezoneWithOptionalMinutes");function Of(t,e){var r=e||"",n=t>0?"-":"+",i=Math.abs(t),o=Br(Math.floor(i/60),2),a=Br(i%60,2);return n+o+r+a}s(Of,"formatTimezone");c(Of,"formatTimezone");var dQ=uQ,CM=c(s(function(e,r){switch(e){case"P":return r.date({width:"short"});case"PP":return r.date({width:"medium"});case"PPP":return r.date({width:"long"});case"PPPP":default:return r.date({width:"full"})}},"dateLongFormatter2"),"dateLongFormatter"),IP=c(s(function(e,r){switch(e){case"p":return r.time({width:"short"});case"pp":return r.time({width:"medium"});case"ppp":return r.time({width:"long"});case"pppp":default:return r.time({width:"full"})}},"timeLongFormatter2"),"timeLongFormatter"),hQ=c(s(function(e,r){var n=e.match(/(P+)(p+)?/)||[],i=n[1],o=n[2];if(!o)return CM(e,r);var a;switch(i){case"P":a=r.dateTime({width:"short"});break;case"PP":a=r.dateTime({width:"medium"});break;case"PPP":a=r.dateTime({width:"long"});break;case"PPPP":default:a=r.dateTime({width:"full"});break}return a.replace("{{date}}",CM(i,r)).replace("{{time}}",IP(o,r))},"dateTimeLongFormatter2"),"dateTimeLongFormatter"),pQ={p:IP,P:hQ},mQ=pQ,gQ=["D","DD"],bQ=["YY","YYYY"];function kP(t){return gQ.indexOf(t)!==-1}s(kP,"isProtectedDayOfYearToken");c(kP,"isProtectedDayOfYearToken");function TP(t){return bQ.indexOf(t)!==-1}s(TP,"isProtectedWeekYearToken");c(TP,"isProtectedWeekYearToken");function A5(t,e,r){if(t==="YYYY")throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(e,"`) for formatting years to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(t==="YY")throw new RangeError("Use `yy` instead of `YY` (in `".concat(e,"`) for formatting years to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(t==="D")throw new RangeError("Use `d` instead of `D` (in `".concat(e,"`) for formatting days of the month to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(t==="DD")throw new RangeError("Use `dd` instead of `DD` (in `".concat(e,"`) for formatting days of the month to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"))}s(A5,"throwProtectedError");c(A5,"throwProtectedError");var vQ={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},yQ=c(s(function(e,r,n){var i,o=vQ[e];return typeof o=="string"?i=o:r===1?i=o.one:i=o.other.replace("{{count}}",r.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+i:i+" ago":i},"formatDistance2"),"formatDistance"),xQ=yQ;function jb(t){return function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=e.width?String(e.width):t.defaultWidth,n=t.formats[r]||t.formats[t.defaultWidth];return n}}s(jb,"buildFormatLongFn");c(jb,"buildFormatLongFn");var wQ={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},_Q={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},AQ={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},EQ={date:jb({formats:wQ,defaultWidth:"full"}),time:jb({formats:_Q,defaultWidth:"full"}),dateTime:jb({formats:AQ,defaultWidth:"full"})},CQ=EQ,SQ={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},IQ=c(s(function(e,r,n,i){return SQ[e]},"formatRelative2"),"formatRelative"),kQ=IQ;function Od(t){return function(e,r){var n=r!=null&&r.context?String(r.context):"standalone",i;if(n==="formatting"&&t.formattingValues){var o=t.defaultFormattingWidth||t.defaultWidth,a=r!=null&&r.width?String(r.width):o;i=t.formattingValues[a]||t.formattingValues[o]}else{var f=t.defaultWidth,l=r!=null&&r.width?String(r.width):t.defaultWidth;i=t.values[l]||t.values[f]}var u=t.argumentCallback?t.argumentCallback(e):e;return i[u]}}s(Od,"buildLocalizeFn");c(Od,"buildLocalizeFn");var TQ={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},MQ={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},RQ={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},BQ={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},DQ={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},PQ={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},OQ=c(s(function(e,r){var n=Number(e),i=n%100;if(i>20||i<10)switch(i%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},"ordinalNumber2"),"ordinalNumber"),FQ={ordinalNumber:OQ,era:Od({values:TQ,defaultWidth:"wide"}),quarter:Od({values:MQ,defaultWidth:"wide",argumentCallback:c(s(function(e){return e-1},"argumentCallback"),"argumentCallback")}),month:Od({values:RQ,defaultWidth:"wide"}),day:Od({values:BQ,defaultWidth:"wide"}),dayPeriod:Od({values:DQ,defaultWidth:"wide",formattingValues:PQ,defaultFormattingWidth:"wide"})},NQ=FQ;function Fd(t){return function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=r.width,i=n&&t.matchPatterns[n]||t.matchPatterns[t.defaultMatchWidth],o=e.match(i);if(!o)return null;var a=o[0],f=n&&t.parsePatterns[n]||t.parsePatterns[t.defaultParseWidth],l=Array.isArray(f)?RP(f,function(g){return g.test(a)}):MP(f,function(g){return g.test(a)}),u;u=t.valueCallback?t.valueCallback(l):l,u=r.valueCallback?r.valueCallback(u):u;var h=e.slice(a.length);return{value:u,rest:h}}}s(Fd,"buildMatchFn");c(Fd,"buildMatchFn");function MP(t,e){for(var r in t)if(t.hasOwnProperty(r)&&e(t[r]))return r}s(MP,"findKey");c(MP,"findKey");function RP(t,e){for(var r=0;r<t.length;r++)if(e(t[r]))return r}s(RP,"findIndex");c(RP,"findIndex");function BP(t){return function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=e.match(t.matchPattern);if(!n)return null;var i=n[0],o=e.match(t.parsePattern);if(!o)return null;var a=t.valueCallback?t.valueCallback(o[0]):o[0];a=r.valueCallback?r.valueCallback(a):a;var f=e.slice(i.length);return{value:a,rest:f}}}s(BP,"buildMatchPatternFn");c(BP,"buildMatchPatternFn");var LQ=/^(\d+)(th|st|nd|rd)?/i,UQ=/\d+/i,jQ={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},qQ={any:[/^b/i,/^(a|c)/i]},HQ={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},zQ={any:[/1/i,/2/i,/3/i,/4/i]},$Q={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},GQ={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},KQ={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},VQ={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},WQ={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},JQ={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},YQ={ordinalNumber:BP({matchPattern:LQ,parsePattern:UQ,valueCallback:c(s(function(e){return parseInt(e,10)},"valueCallback"),"valueCallback")}),era:Fd({matchPatterns:jQ,defaultMatchWidth:"wide",parsePatterns:qQ,defaultParseWidth:"any"}),quarter:Fd({matchPatterns:HQ,defaultMatchWidth:"wide",parsePatterns:zQ,defaultParseWidth:"any",valueCallback:c(s(function(e){return e+1},"valueCallback2"),"valueCallback")}),month:Fd({matchPatterns:$Q,defaultMatchWidth:"wide",parsePatterns:GQ,defaultParseWidth:"any"}),day:Fd({matchPatterns:KQ,defaultMatchWidth:"wide",parsePatterns:VQ,defaultParseWidth:"any"}),dayPeriod:Fd({matchPatterns:WQ,defaultMatchWidth:"any",parsePatterns:JQ,defaultParseWidth:"any"})},ZQ=YQ,XQ={code:"en-US",formatDistance:xQ,formatLong:CQ,formatRelative:kQ,localize:NQ,match:ZQ,options:{weekStartsOn:0,firstWeekContainsDate:1}},QQ=XQ,eee=QQ,tee=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,ree=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,nee=/^'([^]*?)'?$/,iee=/''/g,see=/[a-zA-Z]/;function px(t,e,r){var n,i,o,a,f,l,u,h,g,x,_,E,T,B,F,H,U,q;Di(2,arguments);var K=String(e),W=B1(),N=(n=(i=r?.locale)!==null&&i!==void 0?i:W.locale)!==null&&n!==void 0?n:eee,G=Kf((o=(a=(f=(l=r?.firstWeekContainsDate)!==null&&l!==void 0?l:r==null||(u=r.locale)===null||u===void 0||(h=u.options)===null||h===void 0?void 0:h.firstWeekContainsDate)!==null&&f!==void 0?f:W.firstWeekContainsDate)!==null&&a!==void 0?a:(g=W.locale)===null||g===void 0||(x=g.options)===null||x===void 0?void 0:x.firstWeekContainsDate)!==null&&o!==void 0?o:1);if(!(G>=1&&G<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var ce=Kf((_=(E=(T=(B=r?.weekStartsOn)!==null&&B!==void 0?B:r==null||(F=r.locale)===null||F===void 0||(H=F.options)===null||H===void 0?void 0:H.weekStartsOn)!==null&&T!==void 0?T:W.weekStartsOn)!==null&&E!==void 0?E:(U=W.locale)===null||U===void 0||(q=U.options)===null||q===void 0?void 0:q.weekStartsOn)!==null&&_!==void 0?_:0);if(!(ce>=0&&ce<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!N.localize)throw new RangeError("locale must contain localize property");if(!N.formatLong)throw new RangeError("locale must contain formatLong property");var re=Yo(t);if(!xP(re))throw new RangeError("Invalid time value");var ae=vP(re),J=wP(re,ae),S={firstWeekContainsDate:G,weekStartsOn:ce,locale:N,_originalDate:re},m=K.match(ree).map(function(b){var p=b[0];if(p==="p"||p==="P"){var v=mQ[p];return v(b,N.formatLong)}return b}).join("").match(tee).map(function(b){if(b==="''")return"'";var p=b[0];if(p==="'")return DP(b);var v=dQ[p];if(v)return!(r!=null&&r.useAdditionalWeekYearTokens)&&TP(b)&&A5(b,e,String(t)),!(r!=null&&r.useAdditionalDayOfYearTokens)&&kP(b)&&A5(b,e,String(t)),v(J,b,N.localize,S);if(p.match(see))throw new RangeError("Format string contains an unescaped latin alphabet character `"+p+"`");return b}).join("");return m}s(px,"format");c(px,"format");function DP(t){var e=t.match(nee);return e?e[1].replace(iee,"'"):t}s(DP,"cleanEscapedString");c(DP,"cleanEscapedString");var oee=c((t,e)=>t.split(" error")[0]||t,"transformErrorCheck"),aee=c((t,e)=>t.startsWith("expiration")?e.expirationDate?`Invalid \u2022 Expired ${px(new Date(e.expirationDate),"dd MMM yyyy").toUpperCase()}`:"Invalid \u2022 Expired":t,"transformErrorMessage"),cee=c((t,e)=>({proof:"Valid",expiration:e.expirationDate?`Valid \u2022 Expires ${px(new Date(e.expirationDate),"dd MMM yyyy").toUpperCase()}`:"Valid \u2022 Does Not Expire"})[t]||t,"transformCheckMessage"),fee=c(t=>async(e,r,n,i=!1)=>{let o=await t.invoke.verifyCredential(r,n);if(!i)return o;let a=[];return o.errors.forEach(f=>{a.push({status:$4.Failed,check:oee(f,r),details:aee(f,r)})}),o.warnings.forEach(f=>{a.push({status:$4.Error,check:"hmm",message:f})}),o.checks.forEach(f=>{a.push({status:$4.Success,check:f,message:cee(f,r)})}),a},"verifyCredential"),mx=c(t=>({name:"LearnCard",displayName:"LearnCard",description:"Adds opinionated logic to a LearnCard",methods:{verifyCredential:fee(t)}}),"getLearnCardPlugin"),lee=c(async({didkit:t,debug:e}={})=>{let r=await(await k1({debug:e})).addPlugin(await TD(t)),o=await(await(await r.addPlugin(ex(r))).addPlugin(tx())).addPlugin(await fx());return o.addPlugin(mx(o))},"emptyLearnCard");function gx(t){var e=0,r=t.length,n=[];if(r%2)throw new Error("invalid hex:"+t);for(;e<r;e+=2)n.push(parseInt(t.substr(e,2),16));return new Uint8Array(n)}s(gx,"toUint8Array");c(gx,"toUint8Array");var uee=Object.defineProperty,dee=c((t,e)=>uee(t,"name",{value:e,configurable:!0}),"__name"),hee=dee(t=>/^[0-9a-f]+$/i.test(t),"isHex"),pee=["key","tz","pkh:tz","pkh:tezos","pkh:sol","pkh:solana"],mee=["key","tz","ethr","pkh:tz","pkh:tezos","pkh:eth","pkh:celo","pkh:poly","pkh:btc","pkh:doge","pkh:eip155","pkh:bip122"],gee=c(t=>{if(pee.includes(t))return"ed25519";if(mee.includes(t)||t.startsWith("pkh:eip155:")||t.startsWith("pkh:bip122:"))return"secp256k1";throw new Error("Unspported Did Method")},"getAlgorithmForDidMethod"),bee=c(async(t,e,r)=>{if(e.length===0)throw new Error("Please don't use an empty string for a key!");if(!hee(e))throw new Error("Key must be a hexadecimal string!");if(e.length>64)throw new Error("Key must be less than 64 characters");e.length<64&&(console.warn("Warning: A LearnCard has been initialized with a seed that is less than 32 bytes, and will be padded with zeroes"),console.warn("Please instantiate LearnCards using 32 bytes that have been randomly generated in a cryptographically secure fashion!"),console.warn("See https://app.gitbook.com/o/6uDv1QDlxaaZC7i8EaGb/s/FXvEJ9j3Vf3FW5Nc557n/learn-card-packages/learncard-core/instantiation#key-generation for details"));let n=e.padStart(64,"0"),i=gx(n),o={},a={ed25519:t.invoke.generateEd25519KeyFromBytes(i),secp256k1:t.invoke.generateSecp256k1KeyFromBytes(i)},f=c((u=r)=>{if(!o[u]){let h=gee(u);o[u]=t.invoke.keyToDid(u,a[h])}return o[u]},"did"),l=c((u="ed25519")=>{if(!a[u])throw new Error("Unsupported algorithm");return a[u]},"keypair");return{name:"DID Key",displayName:"DID Key",description:"Generates dids and JWKs using 32 Secure Random Bytes of Entropy",id:{did:(u,h)=>f(h),keypair:(u,h)=>l(h)},methods:{getSubjectDid:(u,h=r)=>f(h),getSubjectKeypair:(u,h="ed25519")=>l(h),getKey:()=>n}}},"getDidKeyPlugin"),vee=c(t=>async(e,r,n={})=>{let i=e.id.keypair();if(!i)throw new Error("Cannot issue credential: Could not get subject keypair");let a={verificationMethod:await e.invoke.didToVerificationMethod(typeof r.issuer=="string"?r.issuer:r.issuer.id),proofPurpose:"assertionMethod",type:"Ed25519Signature2020",...n};return t.invoke.issueCredential(r,a,i)},"issueCredential"),yee=c(t=>async(e,r,n={})=>t.invoke.verifyCredential(r,n),"verifyCredential"),xee=c(t=>async(e,r,n={})=>{let i=e.id.keypair();if(!i)throw new Error("Cannot issue credential: Could not get subject keypair");let a={verificationMethod:await e.invoke.didToVerificationMethod(e.id.did()),...n.proofFormat==="jwt"?{}:{proofPurpose:"assertionMethod"},...n.proofFormat==="jwt"?{}:{type:"Ed25519Signature2020"},...n};return t.invoke.issuePresentation(r,a,i)},"issuePresentation"),wee=c(t=>async(e,r,n={})=>t.invoke.verifyPresentation(r,n),"verifyPresentation"),_ee=c(t=>({name:"VC",displayName:"VC",description:"Handles the infrastructure needed to issue and verify credentials and presentations",methods:{issueCredential:vee(t),verifyCredential:yee(t),issuePresentation:xee(t),verifyPresentation:wee(t),getTestVc:(e,r="did:example:d23dd687a7dc6787646f2eb98d0")=>{let n=e.id.did();return{"@context":["https://www.w3.org/2018/credentials/v1"],id:"http://example.org/credentials/3731",type:["VerifiableCredential"],issuer:n,issuanceDate:"2020-08-19T21:41:50Z",credentialSubject:{id:r}}},getTestVp:async(e,r)=>{let n=r||await e.invoke.issueCredential(e.invoke.getTestVc()),i=e.id.did();return{"@context":["https://www.w3.org/2018/credentials/v1"],type:["VerifiablePresentation"],holder:i,verifiableCredential:n}},getDidAuthVp:async(e,r={})=>{let n=e.invoke.getSubjectDid("key"),i={"@context":["https://www.w3.org/2018/credentials/v1"],type:["VerifiablePresentation"],holder:n};return e.invoke.issuePresentation(i,{proofPurpose:"authentication",...r})}}}),"getVCPlugin"),Aee={name:"VC Resolution",displayName:"VC Resolution",description:"[Deprecated] Allows for a fallback mechanism of resolving credentials",methods:{resolveCredential:async(t,e)=>{throw new Error(`No Credential Resolution Plugins found that can resolve ${e}`)}}},Eee=wr(UJ());function PP(t,e){try{var r=t()}catch(n){return e(n)}return r&&r.then?r.then(void 0,e):r}s(PP,"_catch");c(PP,"_catch");function OP(){let t=new Map;return function(e,r){try{let n=s(function(a){if(i)return a;let f=t.get(e.didUrl);return f!==void 0?f:Promise.resolve(r()).then(function(l){var u;return((u=l.didResolutionMetadata)==null?void 0:u.error)!=="notFound"&&t.set(e.didUrl,l),l})},"_temp2");c(n,"_temp2");let i,o=function(){if(e.params&&e.params["no-cache"]==="true")return Promise.resolve(r()).then(function(a){return i=1,a})}();return Promise.resolve(o&&o.then?o.then(n):n(o))}catch(n){return Promise.reject(n)}}}s(OP,"inMemoryCache");c(OP,"inMemoryCache");function FP(t,e){return e()}s(FP,"noCache");c(FP,"noCache");var Cee="(?:%[0-9a-fA-F]{2})",SM=`(?:[a-zA-Z0-9._-]|${Cee})`,See="([a-z0-9]+)",Iee=`((?:${SM}*:)*(${SM}+))`,IM="[a-zA-Z0-9_.:%-]",kee=`;${IM}+=${IM}*`,Tee=`((${kee})*)`,Mee="(/[^#?]*)?",Ree="([?][^#]*)?",Bee="(#.*)?",Dee=new RegExp(`^did:${See}:${Iee}${Tee}${Mee}${Ree}${Bee}$`);function bx(t){if(t===""||!t)return null;let e=t.match(Dee);if(e){let r={did:`did:${e[1]}:${e[2]}`,method:e[1],id:e[2],didUrl:t};if(e[4]){let n=e[4].slice(1).split(";");r.params={};for(let i of n){let o=i.split("=");r.params[o[0]]=o[1]}}return e[6]&&(r.path=e[6]),e[7]&&(r.query=e[7].slice(1)),e[8]&&(r.fragment=e[8].slice(1)),r}return null}s(bx,"parse");c(bx,"parse");var g2={didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};function NP(t){return function(e,r,n){try{return Promise.resolve(PP(function(){return Promise.resolve(t(e,r,n)).then(function(i){return{...g2,didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:i}})},function(i){return{...g2,didResolutionMetadata:{error:"notFound",message:i.toString()}}}))}catch(i){return Promise.reject(i)}}}s(NP,"wrapLegacyResolver");c(NP,"wrapLegacyResolver");var LP=s(class{constructor(t={},e={}){this.registry=void 0,this.cache=void 0,this.registry=t,this.cache=e.cache===!0?OP():e.cache||FP,e.legacyResolvers&&Object.keys(e.legacyResolvers).map(r=>{this.registry[r]||(this.registry[r]=NP(e.legacyResolvers[r]))})}resolve(t,e={}){try{let r=this,n=bx(t);if(n===null)return Promise.resolve({...g2,didResolutionMetadata:{error:"invalidDid"}});let i=r.registry[n.method];return i?Promise.resolve(r.cache(n,()=>i(n.did,n,r,e))):Promise.resolve({...g2,didResolutionMetadata:{error:"unsupportedDidMethod"}})}catch(r){return Promise.reject(r)}}},"Resolver");c(LP,"Resolver");JR();V8();E1();q8();av();zB();var UP=wr(tY()),Pee=wr(VB()),jP=wr(xY()),qP=wr(J8()),Oee=wr(CY()),E5=wr(SY()),HP=wr(MY()),zP=wr(ph());function Fs(t){return en(t,"base64url")}s(Fs,"bytesToBase64url");c(Fs,"bytesToBase64url");function Wi(t){let e=t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");return Zr(e,"base64url")}s(Wi,"base64ToBytes");c(Wi,"base64ToBytes");function xv(t){return Zr(t,"base58btc")}s(xv,"base58ToBytes");c(xv,"base58ToBytes");function b2(t){let e=t.startsWith("0x")?t.substring(2):t;return Zr(e.toLowerCase(),"base16")}s(b2,"hexToBytes");c(b2,"hexToBytes");function v2(t){return Fs(Zr(t))}s(v2,"encodeBase64url");c(v2,"encodeBase64url");function vx(t){return en(Wi(t))}s(vx,"decodeBase64url");c(vx,"decodeBase64url");function Vf(t){return en(t,"base16")}s(Vf,"bytesToHex");c(Vf,"bytesToHex");function yx(t){return Zr(t)}s(yx,"stringToBytes");c(yx,"stringToBytes");function $P({r:t,s:e,recoveryParam:r},n){let i=new Uint8Array(n?65:64);if(i.set(Zr(t,"base16"),0),i.set(Zr(e,"base16"),32),n){if(typeof r>"u")throw new Error("Signer did not return a recoveryParam");i[64]=r}return Fs(i)}s($P,"toJose");c($P,"toJose");function GP(t){let e=Wi(t);if(e.length<64||e.length>65)throw new TypeError(`Wrong size for signature. Expected 64 or 65 bytes, but got ${e.length}`);let r=Vf(e.slice(0,32)),n=Vf(e.slice(32,64)),i=e.length===65?e[64]:void 0;return{r,s:n,recoveryParam:i}}s(GP,"fromJose");c(GP,"fromJose");function xx(t,e){return qf([Wi(t),Wi(e)])}s(xx,"toSealed");c(xx,"toSealed");var Fee=/^(0x)?([a-fA-F0-9]{64}|[a-fA-F0-9]{128})$/,Nee=/^([1-9A-HJ-NP-Za-km-z]{44}|[1-9A-HJ-NP-Za-km-z]{88})$/,Lee=/^([0-9a-zA-Z=\-_+/]{43}|[0-9a-zA-Z=\-_+/]{86})(={0,2})$/;function KP(t){if(typeof t=="string"){if(Fee.test(t))return b2(t);if(Nee.test(t))return xv(t);if(Lee.test(t))return Wi(t);throw TypeError("bad_key: Invalid private key format")}else{if(t instanceof Uint8Array)return t;throw TypeError("bad_key: Invalid private key format")}}s(KP,"parseKey");c(KP,"parseKey");function wx(t){let e=typeof t=="string"?Zr(t):t;return(0,UP.hash)(e)}s(wx,"sha2562");c(wx,"sha256");function VP(t){return new Uint8Array(Pee.keccak_256.arrayBuffer(t))}s(VP,"keccak");c(VP,"keccak");function WP(t){let e=Zr(t.slice(2),"base16");return`0x${en(VP(e).slice(-20),"base16")}`}s(WP,"toEthereumAddress");c(WP,"toEthereumAddress");function y2(t,e=new Uint8Array(4)){let r=Zr(t.toString(),"base10");return e.set(r,4-r.length),e}s(y2,"writeUint32BE");c(y2,"writeUint32BE");var G4=c(t=>qf([y2(t.length),t]),"lengthAndInput");function _x(t,e,r,n,i){if(e!==256)throw new Error(`Unsupported key length: ${e}`);let o=qf([G4(Zr(r)),G4(typeof n>"u"?new Uint8Array(0):n),G4(typeof i>"u"?new Uint8Array(0):i),y2(e)]),a=1;return(0,UP.hash)(qf([y2(a),t,o]))}s(_x,"concatKDF");c(_x,"concatKDF");var Rpe=new jP.ec("secp256k1");function JP(t){let e=KP(t);if(e.length!==64)throw new Error(`bad_key: Invalid private key format. Expecting 64 bytes, but got ${e.length}`);return function(r){try{let n=typeof r=="string"?yx(r):r,i=(0,qP.sign)(e,n);return Promise.resolve(Fs(i))}catch(n){return Promise.reject(n)}}}s(JP,"EdDSASigner");c(JP,"EdDSASigner");function Ax(t){return typeof t=="object"&&"r"in t&&"s"in t}s(Ax,"instanceOfEcdsaSignature");c(Ax,"instanceOfEcdsaSignature");function C5(t){return c(s(function(r,n){try{return Promise.resolve(n(r)).then(function(i){if(Ax(i))return $P(i,t);if(t&&typeof GP(i).recoveryParam>"u")throw new Error("not_supported: ES256K-R not supported when signer doesn't provide a recovery param");return i})}catch(i){return Promise.reject(i)}},"sign5"),"sign")}s(C5,"ES256KSignerAlg");c(C5,"ES256KSignerAlg");function S5(){return c(s(function(e,r){try{return Promise.resolve(r(e)).then(function(n){if(Ax(n))throw new Error("invalid_config: expected a signer function that returns a string instead of signature object");return n})}catch(n){return Promise.reject(n)}},"sign5"),"sign")}s(S5,"Ed25519SignerAlg");c(S5,"Ed25519SignerAlg");var Uee={ES256K:C5(),"ES256K-R":C5(!0),Ed25519:S5(),EdDSA:S5()};function YP(t){let e=Uee[t];if(!e)throw new Error(`not_supported: Unsupported algorithm ${t}`);return e}s(YP,"SignerAlg");c(YP,"SignerAlg");var Ex=new jP.ec("secp256k1");function s1(t,e=!1){let r=Wi(t);if(r.length!==(e?65:64))throw new Error("wrong signature length");let n=Vf(r.slice(0,32)),i=Vf(r.slice(32,64)),o={r:n,s:i};return e&&(o.recoveryParam=r[64]),o}s(s1,"toSignatureObject");c(s1,"toSignatureObject");function wv(t){if(t.publicKeyBase58)return xv(t.publicKeyBase58);if(t.publicKeyBase64)return Wi(t.publicKeyBase64);if(t.publicKeyHex)return b2(t.publicKeyHex);if(t.publicKeyJwk&&t.publicKeyJwk.crv==="secp256k1"&&t.publicKeyJwk.x&&t.publicKeyJwk.y)return b2(Ex.keyFromPublic({x:Vf(Wi(t.publicKeyJwk.x)),y:Vf(Wi(t.publicKeyJwk.y))}).getPublic("hex"));if(t.publicKeyMultibase){let{base16:e,base58btc:r,base64:n,base64url:i}=a2;return e.decoder.or(r.decoder.or(n.decoder.or(i.decoder))).decode(t.publicKeyMultibase)}return new Uint8Array}s(wv,"extractPublicKeyBytes");c(wv,"extractPublicKeyBytes");function ZP(t,e,r){let n=wx(t),i=s1(e),o=r.filter(({ethereumAddress:l,blockchainAccountId:u})=>typeof l>"u"&&typeof u>"u"),a=r.filter(({ethereumAddress:l,blockchainAccountId:u})=>typeof l<"u"||typeof u!==void 0),f=o.find(l=>{try{let u=wv(l);return Ex.keyFromPublic(u).verify(n,i)}catch{return!1}});if(!f&&a.length>0&&(f=Cx(t,e,a)),!f)throw new Error("invalid_signature: Signature invalid for JWT");return f}s(ZP,"verifyES256K");c(ZP,"verifyES256K");function Cx(t,e,r){let n;if(e.length>86)n=[s1(e,!0)];else{let a=s1(e,!1);n=[{...a,recoveryParam:0},{...a,recoveryParam:1}]}let i=c(a=>{let f=wx(t),l=Ex.recoverPubKey(f,a,a.recoveryParam),u=l.encode("hex"),h=l.encode("hex",!0),g=WP(u);return r.find(_=>{var E,T,B;let F=Vf(wv(_));return F===u||F===h||((E=_.ethereumAddress)==null?void 0:E.toLowerCase())===g||((T=_.blockchainAccountId)==null||(B=T.split("@eip155"))==null?void 0:B[0].toLowerCase())===g})},"checkSignatureAgainstSigner"),o=n.map(i).filter(a=>typeof a<"u");if(o.length===0)throw new Error("invalid_signature: Signature invalid for JWT");return o[0]}s(Cx,"verifyRecoverableES256K");c(Cx,"verifyRecoverableES256K");function I5(t,e,r){let n=yx(t),i=Wi(e),o=r.find(a=>(0,qP.verify)(wv(a),n,i));if(!o)throw new Error("invalid_signature: Signature invalid for JWT");return o}s(I5,"verifyEd25519");c(I5,"verifyEd25519");var jee={ES256K:ZP,"ES256K-R":Cx,Ed25519:I5,EdDSA:I5};function Sx(t){let e=jee[t];if(!e)throw new Error(`not_supported: Unsupported algorithm ${t}`);return e}s(Sx,"VerifierAlgorithm");c(Sx,"VerifierAlgorithm");Sx.toSignatureObject=s1;var qee=c(function(t,e,r={},n={}){try{r.alg||(r.alg=Hee);let i=typeof t=="string"?t:k5(t,n.canonicalize),o=[k5(r,n.canonicalize),i].join("."),a=YP(r.alg);return Promise.resolve(a(o,e)).then(function(f){return[o,f].join(".")})}catch(i){return Promise.reject(i)}},"createJWS"),Hee="ES256K";function k5(t,e=!1){return v2(e?(0,Oee.default)(t):JSON.stringify(t))}s(k5,"encodeSection");c(k5,"encodeSection");function XP(t){let e=t.match(/^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)$/);if(e)return{header:JSON.parse(vx(e[1])),payload:e[2],signature:e[3],data:`${e[1]}.${e[2]}`};throw new Error("invalid_argument: Incorrect format JWS")}s(XP,"decodeJWS");c(XP,"decodeJWS");function QP({header:t,data:e,signature:r},n){return Array.isArray(n)||(n=[n]),Sx(t.alg)(e,r,n)}s(QP,"verifyJWSDecoded");c(QP,"verifyJWSDecoded");function eO(t,e){let r=XP(t);return QP(r,e)}s(eO,"verifyJWS");c(eO,"verifyJWS");function tO(t,e,r){for(var n;;){var i=t();if(Pc(i)&&(i=i.v),!i)return o;if(i.then){n=0;break}var o=r();if(o&&o.then)if(Pc(o))o=o.s;else{n=1;break}if(e){var a=e();if(a&&a.then&&!Pc(a)){n=2;break}}}var f=new iu,l=Dn.bind(null,f,2);return(n===0?i.then(h):n===1?o.then(u):a.then(g)).then(void 0,l),f;function u(x){o=x;do{if(e&&(a=e(),a&&a.then&&!Pc(a))){a.then(g).then(void 0,l);return}if(i=t(),!i||Pc(i)&&!i.v){Dn(f,1,o);return}if(i.then){i.then(h).then(void 0,l);return}o=r(),Pc(o)&&(o=o.v)}while(!o||!o.then);o.then(u).then(void 0,l)}s(u,"_resumeAfterBody"),c(u,"_resumeAfterBody");function h(x){x?(o=r(),o&&o.then?o.then(u).then(void 0,l):u(o)):Dn(f,1,o)}s(h,"_resumeAfterTest"),c(h,"_resumeAfterTest");function g(){(i=t())?i.then?i.then(h).then(void 0,l):h(i):Dn(f,1,o)}s(g,"_resumeAfterUpdate"),c(g,"_resumeAfterUpdate")}s(tO,"_for");c(tO,"_for");var zee=c(function(t,e){try{let r=s(function(u){if(f===null)throw new Error("failure: Failed to decrypt");return f},"_temp5");c(r,"_temp5");let n;iO(t);let i=JSON.parse(vx(t.protected));if(i.enc!==e.enc)throw new Error(`not_supported: Decrypter does not supported: '${i.enc}'`);let o=xx(t.ciphertext,t.tag),a=new Uint8Array(Buffer.from(t.aad?`${t.protected}.${t.aad}`:t.protected)),f=null,l=function(){return i.alg==="dir"&&e.alg==="dir"?Promise.resolve(e.decrypt(o,Wi(t.iv),a)).then(function(u){f=u}):function(){if(!t.recipients||t.recipients.length===0)throw new Error("bad_jwe: missing recipients");{let u=0;return tO(function(){return!f&&u<t.recipients.length},function(){return u++},function(){let h=t.recipients[u];Object.assign(h.header,i);let g=function(){if(h.header.alg===e.alg)return Promise.resolve(e.decrypt(o,Wi(t.iv),a,h)).then(function(x){f=x})}();if(g&&g.then)return g.then(function(){})})}}()}();return Promise.resolve(l&&l.then?l.then(r):r(l))}catch(r){return Promise.reject(r)}},"decryptJWE"),kM=typeof Symbol<"u"?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Dn(t,e,r){if(!t.s){if(r instanceof iu)if(r.s)e&1&&(e=r.s),r=r.v;else{r.o=Dn.bind(null,t,e);return}if(r&&r.then){r.then(Dn.bind(null,t,e),Dn.bind(null,t,2));return}t.s=e,t.v=r;let n=t.o;n&&n(t)}}s(Dn,"_settle");c(Dn,"_settle");var iu=function(){function t(){}return s(t,"_Pact2"),c(t,"_Pact"),t.prototype.then=function(e,r){let n=new t,i=this.s;if(i){let o=i&1?e:r;if(o){try{Dn(n,1,o(this.v))}catch(a){Dn(n,2,a)}return n}else return this}return this.o=function(o){try{let a=o.v;o.s&1?Dn(n,1,e?e(a):a):r?Dn(n,1,r(a)):Dn(n,2,a)}catch(a){Dn(n,2,a)}},n},t}();function Pc(t){return t instanceof iu&&t.s&1}s(Pc,"_isSettledPact");c(Pc,"_isSettledPact");function rO(t,e,r){var n=-1,i,o;function a(f){try{for(;++n<t.length&&(!r||!r());)if(f=e(n),f&&f.then)if(Pc(f))f=f.v;else{f.then(a,o||(o=Dn.bind(null,i=new iu,2)));return}i?Dn(i,1,f):i=f}catch(l){Dn(i||(i=new iu),2,l)}}return s(a,"_cycle"),c(a,"_cycle"),a(),i}s(rO,"_forTo");c(rO,"_forTo");function nO(t,e,r){if(typeof t[kM]=="function"){let h=s(function(g){try{for(;!(i=n.next()).done&&(!r||!r());)if(g=e(i.value),g&&g.then)if(Pc(g))g=g.v;else{g.then(h,a||(a=Dn.bind(null,o=new iu,2)));return}o?Dn(o,1,g):o=g}catch(x){Dn(o||(o=new iu),2,x)}},"_cycle");c(h,"_cycle");var n=t[kM](),i,o,a;if(h(),n.return){var f=c(function(g){try{i.done||n.return()}catch{}return g},"_fixup");if(o&&o.then)return o.then(f,function(g){throw f(g)});f()}return o}if(!("length"in t))throw new TypeError("Object is not iterable");for(var l=[],u=0;u<t.length;u++)l.push(t[u]);return rO(l,function(h){return e(l[h])},r)}s(nO,"_forOf");c(nO,"_forOf");function iO(t){if(!(t.protected&&t.iv&&t.ciphertext&&t.tag))throw new Error("bad_jwe: missing properties");t.recipients&&t.recipients.map(e=>{if(!(e.header&&e.encrypted_key))throw new Error("bad_jwe: malformed recipients")})}s(iO,"validateJWE");c(iO,"validateJWE");function T5({ciphertext:t,tag:e,iv:r,protectedHeader:n,recipient:i},o){let a={protected:n,iv:Fs(r),ciphertext:Fs(t),tag:Fs(e)};return o&&(a.aad=Fs(o)),i&&(a.recipients=[i]),a}s(T5,"encodeJWE");c(T5,"encodeJWE");var $ee=c(function(t,e,r={},n){try{if(e[0].alg==="dir"){if(e.length>1)throw new Error('not_supported: Can only do "dir" encryption to one key.');return Promise.resolve(e[0].encrypt(t,r,n)).then(function(i){return T5(i,n)})}else{let i=e[0].enc;if(!e.reduce((l,u)=>l&&u.enc===i,!0))throw new Error("invalid_argument: Incompatible encrypters passed");let o,a,f=nO(e,function(l){let u=function(){return o?Promise.resolve(l.encryptCek==null?void 0:l.encryptCek(o)).then(function(h){if(h){var g,x;(g=a)==null||(x=g.recipients)==null||x.push(h)}}):Promise.resolve(l.encrypt(t,r,n)).then(function(h){o=h.cek,a=T5(h,n)})}();if(u&&u.then)return u.then(function(){})});return Promise.resolve(f&&f.then?f.then(function(){return a}):a)}}catch(i){return Promise.reject(i)}},"createJWE"),Gee=c(function(t,e){try{let r=c(function(i){try{return Promise.resolve(e.resolve(i)).then(function({didResolutionMetadata:o,didDocument:a}){var f;if(o!=null&&o.error||a==null)throw new Error(`resolver_error: Could not resolve ${i}: ${o.error}, ${o.message}`);if(!a.keyAgreement)throw new Error(`no_suitable_keys: Could not find x25519 key for ${i}`);let u=((f=a.keyAgreement)==null?void 0:f.map(h=>typeof h=="string"?[...a.publicKey||[],...a.verificationMethod||[]].find(g=>g.id===h):h).filter(h=>typeof h<"u")).filter(h=>h.type==="X25519KeyAgreementKey2019"&&Boolean(h.publicKeyBase58));if(!u.length)throw new Error(`no_suitable_keys: Could not find x25519 key for ${i}`);return u.map(h=>oO(xv(h.publicKeyBase58),h.id))})}catch(o){return Promise.reject(o)}},"encryptersForDID"),n=t.map(i=>r(i));return Promise.resolve(Promise.all(n)).then(function(i){return[].concat(...i)})}catch(r){return Promise.reject(r)}},"resolveX25519Encrypters");function Ix(t){let e=new HP.XChaCha20Poly1305(t);return(r,n)=>{let i=(0,zP.randomBytes)(e.nonceLength),o=e.seal(i,r,n);return{ciphertext:o.subarray(0,o.length-e.tagLength),tag:o.subarray(o.length-e.tagLength),iv:i}}}s(Ix,"xc20pEncrypter");c(Ix,"xc20pEncrypter");function sO(t){let e=c(function(o,a={},f){try{let l=v2(JSON.stringify(Object.assign({alg:i},a,{enc:n}))),u=new Uint8Array(Buffer.from(f?`${l}.${Fs(f)}`:l));return Promise.resolve({...r(o,u),protectedHeader:l})}catch(l){return Promise.reject(l)}},"encrypt"),r=Ix(t),n="XC20P",i="dir";return{alg:i,enc:n,encrypt:e}}s(sO,"xc20pDirEncrypter");c(sO,"xc20pDirEncrypter");function M5(t){let e=c(function(n,i,o){try{return Promise.resolve(r.open(i,n,o))}catch(a){return Promise.reject(a)}},"decrypt"),r=new HP.XChaCha20Poly1305(t);return{alg:"dir",enc:"XC20P",decrypt:e}}s(M5,"xc20pDirDecrypter");c(M5,"xc20pDirDecrypter");function oO(t,e){let r=c(function(f,l={},u){try{Object.assign(l,{alg:void 0});let h=(0,zP.randomBytes)(32);return Promise.resolve(sO(h).encrypt(f,l,u)).then(function(g){return Promise.resolve(n(h)).then(function(x){return{...g,recipient:x,cek:h}})})}catch(h){return Promise.reject(h)}},"encrypt"),n=c(function(f){try{let l=(0,E5.generateKeyPair)(),u=(0,E5.sharedKey)(l.secretKey,t),h=_x(u,o,i),g=Ix(h)(f),x={encrypted_key:Fs(g.ciphertext),header:{alg:i,iv:Fs(g.iv),tag:Fs(g.tag),epk:{kty:"OKP",crv:a,x:Fs(l.publicKey)}}};return e&&(x.header.kid=e),Promise.resolve(x)}catch(l){return Promise.reject(l)}},"encryptCek"),i="ECDH-ES+XC20PKW",o=256,a="X25519";return{alg:i,enc:"XC20P",encrypt:r,encryptCek:n}}s(oO,"x25519Encrypter");c(oO,"x25519Encrypter");function aO(t){if(!(t&&t.epk&&t.iv&&t.tag))throw new Error("bad_jwe: malformed header")}s(aO,"validateHeader");c(aO,"validateHeader");function cO(t){let e=c(function(o,a,f,l){try{let g=s(function(){let T=_x(_,n,r),B=xx(l.encrypted_key,l.header.tag);return Promise.resolve(M5(T).decrypt(B,Wi(l.header.iv))).then(function(F){return F===null?null:M5(F).decrypt(o,a,f)})},"_temp4");c(g,"_temp4");var u,h;if(aO((u=l)==null?void 0:u.header),l=l,((h=l.header.epk)==null?void 0:h.crv)!==i||typeof l.header.epk.x>"u")return Promise.resolve(null);let x=Wi(l.header.epk.x),_,E=function(){if(t instanceof Uint8Array)_=(0,E5.sharedKey)(t,x);else return Promise.resolve(t(x)).then(function(T){_=T})}();return Promise.resolve(E&&E.then?E.then(g):g(E))}catch(g){return Promise.reject(g)}},"decrypt"),r="ECDH-ES+XC20PKW",n=256,i="X25519";return{alg:r,enc:"XC20P",decrypt:e}}s(cO,"x25519Decrypter");c(cO,"x25519Decrypter");HB();var Cb=c(({enumerable:t=!0,configurable:e=!1}={})=>({enumerable:t,configurable:e,writable:!1}),"readonly"),R5=c(function*(t,e){if(t!=null&&!(t instanceof Uint8Array))for(let[r,n]of Object.entries(t)){let i=[...e,r];if(n!=null&&typeof n=="object")if(Array.isArray(n))for(let[o,a]of n.entries()){let f=[...i,o],l=fr.asCID(a);l?yield[f.join("/"),l]:typeof a=="object"&&(yield*R5(a,f))}else{let o=fr.asCID(n);o?yield[i.join("/"),o]:yield*R5(n,i)}}},"links"),B5=c(function*(t,e){if(t!=null)for(let[r,n]of Object.entries(t)){let i=[...e,r];if(yield i.join("/"),n!=null&&!(n instanceof Uint8Array)&&typeof n=="object"&&!fr.asCID(n))if(Array.isArray(n))for(let[o,a]of n.entries()){let f=[...i,o];yield f.join("/"),typeof a=="object"&&!fr.asCID(a)&&(yield*B5(a,f))}else yield*B5(n,i)}},"tree"),Kee=c((t,e)=>{let r=t;for(let[n,i]of e.entries()){if(r=r[i],r==null)throw new Error(`Object has no property at ${e.slice(0,n+1).map(a=>`[${JSON.stringify(a)}]`).join("")}`);let o=fr.asCID(r);if(o)return{value:o,remaining:e.slice(n+1).join("/")}}return{value:r}},"get"),kx=s(class{constructor({cid:t,bytes:e,value:r}){if(!t||!e||typeof r>"u")throw new Error("Missing required argument");this.cid=t,this.bytes=e,this.value=r,this.asBlock=this,Object.defineProperties(this,{cid:Cb(),bytes:Cb(),value:Cb(),asBlock:Cb()})}links(){return R5(this.value,[])}tree(){return B5(this.value,[])}get(t="/"){return Kee(this.value,t.split("/").filter(Boolean))}},"Block");c(kx,"Block");var _v=c(async({value:t,codec:e,hasher:r})=>{if(typeof t>"u")throw new Error('Missing required argument "value"');if(!e||!r)throw new Error("Missing required argument: codec or hasher");let n=e.encode(t),i=await r.digest(n),o=fr.create(1,e.code,i);return new kx({value:t,bytes:n,cid:o})},"encode"),Vee=c(async({bytes:t,codec:e,hasher:r})=>{if(!t)throw new Error('Missing required argument "bytes"');if(!e||!r)throw new Error("Missing required argument: codec or hasher");let n=e.decode(t),i=await r.digest(t),o=fr.create(1,e.code,i);return new kx({value:n,bytes:t,cid:o})},"decode");Ga();cv();qB();z8();var bh={};Kr(bh,{code:()=>w2,decode:()=>xF,encode:()=>Pv,name:()=>ute});var Wee=["string","number","bigint","symbol"],Jee=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function fO(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(Wee.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(lO(t))return"Buffer";let r=uO(t);return r||"Object"}s(fO,"is");c(fO,"is");function lO(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}s(lO,"isBuffer");c(lO,"isBuffer");function uO(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(Jee.includes(e))return e}s(uO,"getObjectType");c(uO,"getObjectType");var Ue=s(class{constructor(t,e,r){this.major=t,this.majorEncoded=t<<5,this.name=e,this.terminal=r}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}},"Type");c(Ue,"Type");Ue.uint=new Ue(0,"uint",!0);Ue.negint=new Ue(1,"negint",!0);Ue.bytes=new Ue(2,"bytes",!0);Ue.string=new Ue(3,"string",!0);Ue.array=new Ue(4,"array",!1);Ue.map=new Ue(5,"map",!1);Ue.tag=new Ue(6,"tag",!1);Ue.float=new Ue(7,"float",!0);Ue.false=new Ue(7,"false",!0);Ue.true=new Ue(7,"true",!0);Ue.null=new Ue(7,"null",!0);Ue.undefined=new Ue(7,"undefined",!0);Ue.break=new Ue(7,"break",!0);var st=s(class{constructor(t,e,r){this.type=t,this.value=e,this.encodedLength=r,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}},"Token");c(st,"Token");var vh=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Yee=new TextDecoder,Zee=new TextEncoder;function o1(t){return vh&&globalThis.Buffer.isBuffer(t)}s(o1,"isBuffer2");c(o1,"isBuffer");function Tx(t){return t instanceof Uint8Array?o1(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}s(Tx,"asU8A");c(Tx,"asU8A");var Xee=vh?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):P5(t,e,r):(t,e,r)=>r-e>64?Yee.decode(t.subarray(e,r)):P5(t,e,r),Qee=vh?t=>t.length>64?globalThis.Buffer.from(t):D5(t):t=>t.length>64?Zee.encode(t):D5(t),Tc=c(t=>Uint8Array.from(t),"fromArray"),Mx=vh?(t,e,r)=>o1(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),ete=vh?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Tx(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let i of t)n+i.length>r.length&&(i=i.subarray(0,r.length-n)),r.set(i,n),n+=i.length;return r},tte=vh?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function dO(t,e){if(o1(t)&&o1(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}s(dO,"compare2");c(dO,"compare");function D5(t,e=1/0){let r,n=t.length,i=null,o=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}s(D5,"utf8ToBytes");c(D5,"utf8ToBytes");function P5(t,e,r){let n=[];for(;e<r;){let i=t[e],o=null,a=i>239?4:i>223?3:i>191?2:1;if(e+a<=r){let f,l,u,h;switch(a){case 1:i<128&&(o=i);break;case 2:f=t[e+1],(f&192)===128&&(h=(i&31)<<6|f&63,h>127&&(o=h));break;case 3:f=t[e+1],l=t[e+2],(f&192)===128&&(l&192)===128&&(h=(i&15)<<12|(f&63)<<6|l&63,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:f=t[e+1],l=t[e+2],u=t[e+3],(f&192)===128&&(l&192)===128&&(u&192)===128&&(h=(i&15)<<18|(f&63)<<12|(l&63)<<6|u&63,h>65535&&h<1114112&&(o=h))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),e+=a}return hO(n)}s(P5,"utf8Slice");c(P5,"utf8Slice");var TM=4096;function hO(t){let e=t.length;if(e<=TM)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=TM));return r}s(hO,"decodeCodePointsArray");c(hO,"decodeCodePointsArray");var rte=256,Rx=s(class{constructor(t=rte){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)}push(t){let e=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let n=e.length-(this.maxCursor-this.cursor)-1;e.set(t,n)}else{if(e){let n=e.length-(this.maxCursor-this.cursor)-1;n<e.length&&(this.chunks[this.chunks.length-1]=e.subarray(0,n),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(e=tte(this.chunkSize),this.chunks.push(e),this.maxCursor+=e.length,this._initReuseChunk===null&&(this._initReuseChunk=e),e.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let e;if(this.chunks.length===1){let r=this.chunks[0];t&&this.cursor>r.length/2?(e=this.cursor===r.length?r:r.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):e=Mx(r,0,this.cursor)}else e=ete(this.chunks,this.cursor);return t&&this.reset(),e}},"Bl");c(Rx,"Bl");var yr="CBOR decode error:",pO="CBOR encode error:",D1=[];D1[23]=1;D1[24]=2;D1[25]=3;D1[26]=5;D1[27]=9;function hu(t,e,r){if(t.length-e<r)throw new Error(`${yr} not enough data for type`)}s(hu,"assertEnoughData");c(hu,"assertEnoughData");var ai=[24,256,65536,4294967296,BigInt("18446744073709551616")];function el(t,e,r){hu(t,e,1);let n=t[e];if(r.strict===!0&&n<ai[0])throw new Error(`${yr} integer encoded in more bytes than necessary (strict decode)`);return n}s(el,"readUint8");c(el,"readUint8");function tl(t,e,r){hu(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<ai[1])throw new Error(`${yr} integer encoded in more bytes than necessary (strict decode)`);return n}s(tl,"readUint16");c(tl,"readUint16");function rl(t,e,r){hu(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<ai[2])throw new Error(`${yr} integer encoded in more bytes than necessary (strict decode)`);return n}s(rl,"readUint32");c(rl,"readUint32");function nl(t,e,r){hu(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],i=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],o=(BigInt(n)<<BigInt(32))+BigInt(i);if(r.strict===!0&&o<ai[3])throw new Error(`${yr} integer encoded in more bytes than necessary (strict decode)`);if(o<=Number.MAX_SAFE_INTEGER)return Number(o);if(r.allowBigInt===!0)return o;throw new Error(`${yr} integers outside of the safe integer range are not supported`)}s(nl,"readUint64");c(nl,"readUint64");function mO(t,e,r,n){return new st(Ue.uint,el(t,e+1,n),2)}s(mO,"decodeUint8");c(mO,"decodeUint8");function gO(t,e,r,n){return new st(Ue.uint,tl(t,e+1,n),3)}s(gO,"decodeUint16");c(gO,"decodeUint16");function bO(t,e,r,n){return new st(Ue.uint,rl(t,e+1,n),5)}s(bO,"decodeUint32");c(bO,"decodeUint32");function vO(t,e,r,n){return new st(Ue.uint,nl(t,e+1,n),9)}s(vO,"decodeUint64");c(vO,"decodeUint64");function il(t,e){return js(t,0,e.value)}s(il,"encodeUint");c(il,"encodeUint");function js(t,e,r){if(r<ai[0]){let n=Number(r);t.push([e|n])}else if(r<ai[1]){let n=Number(r);t.push([e|24,n])}else if(r<ai[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<ai[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<ai[4]){let i=[e|27,0,0,0,0,0,0,0],o=Number(n&BigInt(4294967295)),a=Number(n>>BigInt(32)&BigInt(4294967295));i[8]=o&255,o=o>>8,i[7]=o&255,o=o>>8,i[6]=o&255,o=o>>8,i[5]=o&255,i[4]=a&255,a=a>>8,i[3]=a&255,a=a>>8,i[2]=a&255,a=a>>8,i[1]=a&255,t.push(i)}else throw new Error(`${yr} encountered BigInt larger than allowable range`)}}s(js,"encodeUintValue");c(js,"encodeUintValue");il.encodedSize=c(s(function(e){return js.encodedSize(e.value)},"encodedSize"),"encodedSize");js.encodedSize=c(s(function(e){return e<ai[0]?1:e<ai[1]?2:e<ai[2]?3:e<ai[3]?5:9},"encodedSize2"),"encodedSize");il.compareTokens=c(s(function(e,r){return e.value<r.value?-1:e.value>r.value?1:0},"compareTokens"),"compareTokens");function yO(t,e,r,n){return new st(Ue.negint,-1-el(t,e+1,n),2)}s(yO,"decodeNegint8");c(yO,"decodeNegint8");function xO(t,e,r,n){return new st(Ue.negint,-1-tl(t,e+1,n),3)}s(xO,"decodeNegint16");c(xO,"decodeNegint16");function wO(t,e,r,n){return new st(Ue.negint,-1-rl(t,e+1,n),5)}s(wO,"decodeNegint32");c(wO,"decodeNegint32");var Bx=BigInt(-1),_O=BigInt(1);function AO(t,e,r,n){let i=nl(t,e+1,n);if(typeof i!="bigint"){let o=-1-i;if(o>=Number.MIN_SAFE_INTEGER)return new st(Ue.negint,o,9)}if(n.allowBigInt!==!0)throw new Error(`${yr} integers outside of the safe integer range are not supported`);return new st(Ue.negint,Bx-BigInt(i),9)}s(AO,"decodeNegint64");c(AO,"decodeNegint64");function Av(t,e){let r=e.value,n=typeof r=="bigint"?r*Bx-_O:r*-1-1;js(t,e.type.majorEncoded,n)}s(Av,"encodeNegint");c(Av,"encodeNegint");Av.encodedSize=c(s(function(e){let r=e.value,n=typeof r=="bigint"?r*Bx-_O:r*-1-1;return n<ai[0]?1:n<ai[1]?2:n<ai[2]?3:n<ai[3]?5:9},"encodedSize3"),"encodedSize");Av.compareTokens=c(s(function(e,r){return e.value<r.value?1:e.value>r.value?-1:0},"compareTokens2"),"compareTokens");function yh(t,e,r,n){hu(t,e,r+n);let i=Mx(t,e+r,e+r+n);return new st(Ue.bytes,i,r+n)}s(yh,"toToken");c(yh,"toToken");function EO(t,e,r,n){return yh(t,e,1,r)}s(EO,"decodeBytesCompact");c(EO,"decodeBytesCompact");function CO(t,e,r,n){return yh(t,e,2,el(t,e+1,n))}s(CO,"decodeBytes8");c(CO,"decodeBytes8");function SO(t,e,r,n){return yh(t,e,3,tl(t,e+1,n))}s(SO,"decodeBytes16");c(SO,"decodeBytes16");function IO(t,e,r,n){return yh(t,e,5,rl(t,e+1,n))}s(IO,"decodeBytes32");c(IO,"decodeBytes32");function kO(t,e,r,n){let i=nl(t,e+1,n);if(typeof i=="bigint")throw new Error(`${yr} 64-bit integer bytes lengths not supported`);return yh(t,e,9,i)}s(kO,"decodeBytes64");c(kO,"decodeBytes64");function a1(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===Ue.string?Qee(t.value):t.value),t.encodedBytes}s(a1,"tokenBytes");c(a1,"tokenBytes");function P1(t,e){let r=a1(e);js(t,e.type.majorEncoded,r.length),t.push(r)}s(P1,"encodeBytes");c(P1,"encodeBytes");P1.encodedSize=c(s(function(e){let r=a1(e);return js.encodedSize(r.length)+r.length},"encodedSize4"),"encodedSize");P1.compareTokens=c(s(function(e,r){return TO(a1(e),a1(r))},"compareTokens3"),"compareTokens");function TO(t,e){return t.length<e.length?-1:t.length>e.length?1:dO(t,e)}s(TO,"compareBytes");c(TO,"compareBytes");function xh(t,e,r,n,i){let o=r+n;hu(t,e,o);let a=new st(Ue.string,Xee(t,e+r,e+o),o);return i.retainStringBytes===!0&&(a.byteValue=Mx(t,e+r,e+o)),a}s(xh,"toToken2");c(xh,"toToken");function MO(t,e,r,n){return xh(t,e,1,r,n)}s(MO,"decodeStringCompact");c(MO,"decodeStringCompact");function RO(t,e,r,n){return xh(t,e,2,el(t,e+1,n),n)}s(RO,"decodeString8");c(RO,"decodeString8");function BO(t,e,r,n){return xh(t,e,3,tl(t,e+1,n),n)}s(BO,"decodeString16");c(BO,"decodeString16");function DO(t,e,r,n){return xh(t,e,5,rl(t,e+1,n),n)}s(DO,"decodeString32");c(DO,"decodeString32");function PO(t,e,r,n){let i=nl(t,e+1,n);if(typeof i=="bigint")throw new Error(`${yr} 64-bit integer string lengths not supported`);return xh(t,e,9,i,n)}s(PO,"decodeString64");c(PO,"decodeString64");var nte=P1;function pu(t,e,r,n){return new st(Ue.array,n,r)}s(pu,"toToken3");c(pu,"toToken");function OO(t,e,r,n){return pu(t,e,1,r)}s(OO,"decodeArrayCompact");c(OO,"decodeArrayCompact");function FO(t,e,r,n){return pu(t,e,2,el(t,e+1,n))}s(FO,"decodeArray8");c(FO,"decodeArray8");function NO(t,e,r,n){return pu(t,e,3,tl(t,e+1,n))}s(NO,"decodeArray16");c(NO,"decodeArray16");function LO(t,e,r,n){return pu(t,e,5,rl(t,e+1,n))}s(LO,"decodeArray32");c(LO,"decodeArray32");function UO(t,e,r,n){let i=nl(t,e+1,n);if(typeof i=="bigint")throw new Error(`${yr} 64-bit integer array lengths not supported`);return pu(t,e,9,i)}s(UO,"decodeArray64");c(UO,"decodeArray64");function jO(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${yr} indefinite length items not allowed`);return pu(t,e,1,1/0)}s(jO,"decodeArrayIndefinite");c(jO,"decodeArrayIndefinite");function Ev(t,e){js(t,Ue.array.majorEncoded,e.value)}s(Ev,"encodeArray");c(Ev,"encodeArray");Ev.compareTokens=il.compareTokens;Ev.encodedSize=c(s(function(e){return js.encodedSize(e.value)},"encodedSize5"),"encodedSize");function mu(t,e,r,n){return new st(Ue.map,n,r)}s(mu,"toToken4");c(mu,"toToken");function qO(t,e,r,n){return mu(t,e,1,r)}s(qO,"decodeMapCompact");c(qO,"decodeMapCompact");function HO(t,e,r,n){return mu(t,e,2,el(t,e+1,n))}s(HO,"decodeMap8");c(HO,"decodeMap8");function zO(t,e,r,n){return mu(t,e,3,tl(t,e+1,n))}s(zO,"decodeMap16");c(zO,"decodeMap16");function $O(t,e,r,n){return mu(t,e,5,rl(t,e+1,n))}s($O,"decodeMap32");c($O,"decodeMap32");function GO(t,e,r,n){let i=nl(t,e+1,n);if(typeof i=="bigint")throw new Error(`${yr} 64-bit integer map lengths not supported`);return mu(t,e,9,i)}s(GO,"decodeMap64");c(GO,"decodeMap64");function KO(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${yr} indefinite length items not allowed`);return mu(t,e,1,1/0)}s(KO,"decodeMapIndefinite");c(KO,"decodeMapIndefinite");function Cv(t,e){js(t,Ue.map.majorEncoded,e.value)}s(Cv,"encodeMap");c(Cv,"encodeMap");Cv.compareTokens=il.compareTokens;Cv.encodedSize=c(s(function(e){return js.encodedSize(e.value)},"encodedSize6"),"encodedSize");function VO(t,e,r,n){return new st(Ue.tag,r,1)}s(VO,"decodeTagCompact");c(VO,"decodeTagCompact");function WO(t,e,r,n){return new st(Ue.tag,el(t,e+1,n),2)}s(WO,"decodeTag8");c(WO,"decodeTag8");function JO(t,e,r,n){return new st(Ue.tag,tl(t,e+1,n),3)}s(JO,"decodeTag16");c(JO,"decodeTag16");function YO(t,e,r,n){return new st(Ue.tag,rl(t,e+1,n),5)}s(YO,"decodeTag32");c(YO,"decodeTag32");function ZO(t,e,r,n){return new st(Ue.tag,nl(t,e+1,n),9)}s(ZO,"decodeTag64");c(ZO,"decodeTag64");function Sv(t,e){js(t,Ue.tag.majorEncoded,e.value)}s(Sv,"encodeTag");c(Sv,"encodeTag");Sv.compareTokens=il.compareTokens;Sv.encodedSize=c(s(function(e){return js.encodedSize(e.value)},"encodedSize7"),"encodedSize");var ite=20,ste=21,ote=22,ate=23;function XO(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${yr} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new st(Ue.null,null,1):new st(Ue.undefined,void 0,1)}s(XO,"decodeUndefined");c(XO,"decodeUndefined");function QO(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${yr} indefinite length items not allowed`);return new st(Ue.break,void 0,1)}s(QO,"decodeBreak");c(QO,"decodeBreak");function Iv(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${yr} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${yr} Infinity values are not supported`)}return new st(Ue.float,t,e)}s(Iv,"createToken");c(Iv,"createToken");function eF(t,e,r,n){return Iv(Tv(t,e+1),3,n)}s(eF,"decodeFloat16");c(eF,"decodeFloat16");function tF(t,e,r,n){return Iv(Mv(t,e+1),5,n)}s(tF,"decodeFloat32");c(tF,"decodeFloat32");function rF(t,e,r,n){return Iv(Ox(t,e+1),9,n)}s(rF,"decodeFloat64");c(rF,"decodeFloat64");function kv(t,e,r){let n=e.value;if(n===!1)t.push([Ue.float.majorEncoded|ite]);else if(n===!0)t.push([Ue.float.majorEncoded|ste]);else if(n===null)t.push([Ue.float.majorEncoded|ote]);else if(n===void 0)t.push([Ue.float.majorEncoded|ate]);else{let i,o=!1;(!r||r.float64!==!0)&&(Dx(n),i=Tv(Lo,1),n===i||Number.isNaN(n)?(Lo[0]=249,t.push(Lo.slice(0,3)),o=!0):(Px(n),i=Mv(Lo,1),n===i&&(Lo[0]=250,t.push(Lo.slice(0,5)),o=!0))),o||(iF(n),i=Ox(Lo,1),Lo[0]=251,t.push(Lo.slice(0,9)))}}s(kv,"encodeFloat");c(kv,"encodeFloat");kv.encodedSize=c(s(function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Dx(n);let i=Tv(Lo,1);if(n===i||Number.isNaN(n))return 3;if(Px(n),i=Mv(Lo,1),n===i)return 5}return 9},"encodedSize8"),"encodedSize");var nF=new ArrayBuffer(9),fo=new DataView(nF,1),Lo=new Uint8Array(nF,0);function Dx(t){if(t===1/0)fo.setUint16(0,31744,!1);else if(t===-1/0)fo.setUint16(0,64512,!1);else if(Number.isNaN(t))fo.setUint16(0,32256,!1);else{fo.setFloat32(0,t);let e=fo.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)fo.setUint16(0,31744,!1);else if(r===0)fo.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let i=r-127;i<-24?fo.setUint16(0,0):i<-14?fo.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):fo.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}s(Dx,"encodeFloat16");c(Dx,"encodeFloat16");function Tv(t,e){if(t.length-e<2)throw new Error(`${yr} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,i=r&1023,o;return n===0?o=i*2**-24:n!==31?o=(i+1024)*2**(n-25):o=i===0?1/0:NaN,r&32768?-o:o}s(Tv,"readFloat16");c(Tv,"readFloat16");function Px(t){fo.setFloat32(0,t,!1)}s(Px,"encodeFloat32");c(Px,"encodeFloat32");function Mv(t,e){if(t.length-e<4)throw new Error(`${yr} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}s(Mv,"readFloat32");c(Mv,"readFloat32");function iF(t){fo.setFloat64(0,t,!1)}s(iF,"encodeFloat64");c(iF,"encodeFloat64");function Ox(t,e){if(t.length-e<8)throw new Error(`${yr} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}s(Ox,"readFloat64");c(Ox,"readFloat64");kv.compareTokens=il.compareTokens;function Cr(t,e,r){throw new Error(`${yr} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}s(Cr,"invalidMinor");c(Cr,"invalidMinor");function O1(t){return()=>{throw new Error(`${yr} ${t}`)}}s(O1,"errorer");c(O1,"errorer");var ct=[];for(let t=0;t<=23;t++)ct[t]=Cr;ct[24]=mO;ct[25]=gO;ct[26]=bO;ct[27]=vO;ct[28]=Cr;ct[29]=Cr;ct[30]=Cr;ct[31]=Cr;for(let t=32;t<=55;t++)ct[t]=Cr;ct[56]=yO;ct[57]=xO;ct[58]=wO;ct[59]=AO;ct[60]=Cr;ct[61]=Cr;ct[62]=Cr;ct[63]=Cr;for(let t=64;t<=87;t++)ct[t]=EO;ct[88]=CO;ct[89]=SO;ct[90]=IO;ct[91]=kO;ct[92]=Cr;ct[93]=Cr;ct[94]=Cr;ct[95]=O1("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)ct[t]=MO;ct[120]=RO;ct[121]=BO;ct[122]=DO;ct[123]=PO;ct[124]=Cr;ct[125]=Cr;ct[126]=Cr;ct[127]=O1("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)ct[t]=OO;ct[152]=FO;ct[153]=NO;ct[154]=LO;ct[155]=UO;ct[156]=Cr;ct[157]=Cr;ct[158]=Cr;ct[159]=jO;for(let t=160;t<=183;t++)ct[t]=qO;ct[184]=HO;ct[185]=zO;ct[186]=$O;ct[187]=GO;ct[188]=Cr;ct[189]=Cr;ct[190]=Cr;ct[191]=KO;for(let t=192;t<=215;t++)ct[t]=VO;ct[216]=WO;ct[217]=JO;ct[218]=YO;ct[219]=ZO;ct[220]=Cr;ct[221]=Cr;ct[222]=Cr;ct[223]=Cr;for(let t=224;t<=243;t++)ct[t]=O1("simple values are not supported");ct[244]=Cr;ct[245]=Cr;ct[246]=Cr;ct[247]=XO;ct[248]=O1("simple values are not supported");ct[249]=eF;ct[250]=tF;ct[251]=rF;ct[252]=Cr;ct[253]=Cr;ct[254]=Cr;ct[255]=QO;var Wa=[];for(let t=0;t<24;t++)Wa[t]=new st(Ue.uint,t,1);for(let t=-1;t>=-24;t--)Wa[31-t]=new st(Ue.negint,t,1);Wa[64]=new st(Ue.bytes,new Uint8Array(0),1);Wa[96]=new st(Ue.string,"",1);Wa[128]=new st(Ue.array,0,1);Wa[160]=new st(Ue.map,0,1);Wa[244]=new st(Ue.false,!1,1);Wa[245]=new st(Ue.true,!0,1);Wa[246]=new st(Ue.null,null,1);function sF(t){switch(t.type){case Ue.false:return Tc([244]);case Ue.true:return Tc([245]);case Ue.null:return Tc([246]);case Ue.bytes:return t.value.length?void 0:Tc([64]);case Ue.string:return t.value===""?Tc([96]):void 0;case Ue.array:return t.value===0?Tc([128]):void 0;case Ue.map:return t.value===0?Tc([160]):void 0;case Ue.uint:return t.value<24?Tc([Number(t.value)]):void 0;case Ue.negint:if(t.value>=-24)return Tc([31-Number(t.value)])}}s(sF,"quickEncodeToken");c(sF,"quickEncodeToken");var cte={float64:!1,mapSorter:fF,quickEncodeToken:sF};function oF(){let t=[];return t[Ue.uint.major]=il,t[Ue.negint.major]=Av,t[Ue.bytes.major]=P1,t[Ue.string.major]=nte,t[Ue.array.major]=Ev,t[Ue.map.major]=Cv,t[Ue.tag.major]=Sv,t[Ue.float.major]=kv,t}s(oF,"makeCborEncoders");c(oF,"makeCborEncoders");var aF=oF(),K4=new Rx,x2=s(class{constructor(t,e){this.obj=t,this.parent=e}includes(t){let e=this;do if(e.obj===t)return!0;while(e=e.parent);return!1}static createCheck(t,e){if(t&&t.includes(e))throw new Error(`${pO} object contains circular references`);return new x2(e,t)}},"Ref");c(x2,"Ref");var Df={null:new st(Ue.null,null),undefined:new st(Ue.undefined,void 0),true:new st(Ue.true,!0),false:new st(Ue.false,!1),emptyArray:new st(Ue.array,0),emptyMap:new st(Ue.map,0)},Wf={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new st(Ue.float,t):t>=0?new st(Ue.uint,t):new st(Ue.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new st(Ue.uint,t):new st(Ue.negint,t)},Uint8Array(t,e,r,n){return new st(Ue.bytes,t)},string(t,e,r,n){return new st(Ue.string,t)},boolean(t,e,r,n){return t?Df.true:Df.false},null(t,e,r,n){return Df.null},undefined(t,e,r,n){return Df.undefined},ArrayBuffer(t,e,r,n){return new st(Ue.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new st(Ue.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[Df.emptyArray,new st(Ue.break)]:Df.emptyArray;n=x2.createCheck(n,t);let i=[],o=0;for(let a of t)i[o++]=Hp(a,r,n);return r.addBreakTokens?[new st(Ue.array,t.length),i,new st(Ue.break)]:[new st(Ue.array,t.length),i]},Object(t,e,r,n){let i=e!=="Object",o=i?t.keys():Object.keys(t),a=i?t.size:o.length;if(!a)return r.addBreakTokens===!0?[Df.emptyMap,new st(Ue.break)]:Df.emptyMap;n=x2.createCheck(n,t);let f=[],l=0;for(let u of o)f[l++]=[Hp(u,r,n),Hp(i?t.get(u):t[u],r,n)];return cF(f,r),r.addBreakTokens?[new st(Ue.map,a),f,new st(Ue.break)]:[new st(Ue.map,a),f]}};Wf.Map=Wf.Object;Wf.Buffer=Wf.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Wf[`${t}Array`]=Wf.DataView;function Hp(t,e={},r){let n=fO(t),i=e&&e.typeEncoders&&e.typeEncoders[n]||Wf[n];if(typeof i=="function"){let a=i(t,n,e,r);if(a!=null)return a}let o=Wf[n];if(!o)throw new Error(`${pO} unsupported type: ${n}`);return o(t,n,e,r)}s(Hp,"objectToTokens");c(Hp,"objectToTokens");function cF(t,e){e.mapSorter&&t.sort(e.mapSorter)}s(cF,"sortMapEntries");c(cF,"sortMapEntries");function fF(t,e){let r=Array.isArray(t[0])?t[0][0]:t[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(r.type!==n.type)return r.type.compare(n.type);let i=r.type.major,o=aF[i].compareTokens(r,n);return o===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),o}s(fF,"mapSorter");c(fF,"mapSorter");function Fx(t,e,r,n){if(Array.isArray(e))for(let i of e)Fx(t,i,r,n);else r[e.type.major](t,e,n)}s(Fx,"tokensToEncoded");c(Fx,"tokensToEncoded");function lF(t,e,r){let n=Hp(t,r);if(!Array.isArray(n)&&r.quickEncodeToken){let i=r.quickEncodeToken(n);if(i)return i;let o=e[n.type.major];if(o.encodedSize){let a=o.encodedSize(n,r),f=new Rx(a);if(o(f,n,r),f.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Tx(f.chunks[0])}}return K4.reset(),Fx(K4,n,e,r),K4.toBytes(!0)}s(lF,"encodeCustom");c(lF,"encodeCustom");function Rv(t,e){return e=Object.assign({},cte,e),lF(t,aF,e)}s(Rv,"encode6");c(Rv,"encode");var fte={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},uF=s(class{constructor(t,e={}){this.pos=0,this.data=t,this.options=e}done(){return this.pos>=this.data.length}next(){let t=this.data[this.pos],e=Wa[t];if(e===void 0){let r=ct[t];if(!r)throw new Error(`${yr} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let n=t&31;e=r(this.data,this.pos,n,this.options)}return this.pos+=e.encodedLength,e}},"Tokeniser");c(uF,"Tokeniser");var c1=Symbol.for("DONE"),Bv=Symbol.for("BREAK");function dF(t,e,r){let n=[];for(let i=0;i<t.value;i++){let o=oh(e,r);if(o===Bv){if(t.value===1/0)break;throw new Error(`${yr} got unexpected break to lengthed array`)}if(o===c1)throw new Error(`${yr} found array but not enough entries (got ${i}, expected ${t.value})`);n[i]=o}return n}s(dF,"tokenToArray");c(dF,"tokenToArray");function hF(t,e,r){let n=r.useMaps===!0,i=n?void 0:{},o=n?new Map:void 0;for(let a=0;a<t.value;a++){let f=oh(e,r);if(f===Bv){if(t.value===1/0)break;throw new Error(`${yr} got unexpected break to lengthed map`)}if(f===c1)throw new Error(`${yr} found map but not enough entries (got ${a} [no key], expected ${t.value})`);if(n!==!0&&typeof f!="string")throw new Error(`${yr} non-string keys not supported (got ${typeof f})`);if(r.rejectDuplicateMapKeys===!0&&(n&&o.has(f)||!n&&f in i))throw new Error(`${yr} found repeat map key "${f}"`);let l=oh(e,r);if(l===c1)throw new Error(`${yr} found map but not enough entries (got ${a} [no value], expected ${t.value})`);n?o.set(f,l):i[f]=l}return n?o:i}s(hF,"tokenToMap");c(hF,"tokenToMap");function oh(t,e){if(t.done())return c1;let r=t.next();if(r.type===Ue.break)return Bv;if(r.type.terminal)return r.value;if(r.type===Ue.array)return dF(r,t,e);if(r.type===Ue.map)return hF(r,t,e);if(r.type===Ue.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=oh(t,e);return e.tags[r.value](n)}throw new Error(`${yr} tag not supported (${r.value})`)}throw new Error("unsupported")}s(oh,"tokensToObject");c(oh,"tokensToObject");function Dv(t,e){if(!(t instanceof Uint8Array))throw new Error(`${yr} data to decode must be a Uint8Array`);e=Object.assign({},fte,e);let r=e.tokenizer||new uF(t,e),n=oh(r,e);if(n===c1)throw new Error(`${yr} did not find any content to decode`);if(n===Bv)throw new Error(`${yr} got unexpected break`);if(!r.done())throw new Error(`${yr} too many terminals, data makes no sense`);return n}s(Dv,"decode7");c(Dv,"decode");Ga();var pF=42;function mF(t){if(t.asCID!==t)return null;let e=fr.asCID(t);if(!e)return null;let r=new Uint8Array(e.bytes.byteLength+1);return r.set(e.bytes,1),[new st(Ue.tag,pF),new st(Ue.bytes,r)]}s(mF,"cidEncoder");c(mF,"cidEncoder");function gF(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}s(gF,"undefinedEncoder");c(gF,"undefinedEncoder");function bF(t){if(Number.isNaN(t))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(t===1/0||t===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}s(bF,"numberEncoder");c(bF,"numberEncoder");var lte={float64:!0,typeEncoders:{Object:mF,undefined:gF,number:bF}};function vF(t){if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return fr.decode(t.subarray(1))}s(vF,"cidDecoder");c(vF,"cidDecoder");var yF={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};yF.tags[pF]=vF;var ute="dag-cbor",w2=113,Pv=c(t=>Rv(t,lte),"encode"),xF=c(t=>Dv(t,yF),"decode"),dte=24;async function wF(t){let e=await _v({value:t,codec:bh,hasher:dh});return{cid:e.cid,linkedBlock:e.bytes}}s(wF,"encodePayload");c(wF,"encodePayload");function _F(t,e=dte){let r=(e-t.length%e)%e,n=new Uint8Array(t.length+r);return n.set(t,0),n}s(_F,"pad");c(_F,"pad");async function AF(t){return(await _v({value:t,codec:bh,hasher:fv})).cid}s(AF,"encodeIdentityCID");c(AF,"encodeIdentityCID");function EF(t){if(t=fr.asCID(t),t.code!==w2)throw new Error("CID codec must be dag-cbor");if(t.multihash.code!==fv.code)throw new Error("CID must use identity multihash");return xF(t.multihash.digest)}s(EF,"decodeIdentityCID");c(EF,"decodeIdentityCID");async function CF(t,e){return _F((await AF(t)).bytes,e)}s(CF,"prepareCleartext");c(CF,"prepareCleartext");function SF(t){return EF(fr.decodeFirst(t)[0])}s(SF,"decodeCleartext");c(SF,"decodeCleartext");var hte=Symbol("abortable"),O5=Symbol("aborted");function IF(t,e){if(e.aborted)return Promise.reject(O5);let r,n=new Promise((i,o)=>{r=o});return e.addEventListener("abort",()=>{r(O5)}),Promise.race([t,n])}s(IF,"abortable");c(IF,"abortable");var pte=c((t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),""),"nanoid"),kF="utils_abort_request",hs;(function(t){t[t.PARSE_ERROR=-32700]="PARSE_ERROR",t[t.INVALID_REQUEST=-32600]="INVALID_REQUEST",t[t.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",t[t.INVALID_PARAMS=-32602]="INVALID_PARAMS",t[t.INTERNAL_ERROR=-32603]="INTERNAL_ERROR"})(hs||(hs={}));var TF={[hs.PARSE_ERROR]:"Parse error",[hs.INVALID_REQUEST]:"Invalid request",[hs.METHOD_NOT_FOUND]:"Method not found",[hs.INVALID_PARAMS]:"Invalid params",[hs.INTERNAL_ERROR]:"Internal error"};function MF(t){return-32e3>=t&&t>=-32099}s(MF,"isServerError");c(MF,"isServerError");function Ov(t){return TF[t.toString()]??(MF(t)?"Server error":"Application error")}s(Ov,"getErrorMessage");c(Ov,"getErrorMessage");var Jf=s(class extends Error{static fromObject(t){return new Jf(t.code,t.message,t.data)}toObject(){return{code:this.code,data:this.data,message:this.message}}constructor(t,e,r){super(),Object.setPrototypeOf(this,Jf.prototype),this.code=t,this.data=r,this.message=e??Ov(t)}},"RPCError");c(Jf,"RPCError");function wh(t){let e=TF[t];return c(s(function(n){return new Jf(t,e,n)},"createError"),"createError")}s(wh,"createErrorFactory");c(wh,"createErrorFactory");var Bpe=wh(hs.PARSE_ERROR),Dpe=wh(hs.INVALID_REQUEST),Ppe=wh(hs.METHOD_NOT_FOUND),Ope=wh(hs.INVALID_PARAMS),Fpe=wh(hs.INTERNAL_ERROR);function RF(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}s(RF,"_checkPrivateRedeclaration");c(RF,"_checkPrivateRedeclaration");function BF(t,e){return e.get?e.get.call(t):e.value}s(BF,"_classApplyDescriptorGet");c(BF,"_classApplyDescriptorGet");function DF(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}s(DF,"_classApplyDescriptorSet");c(DF,"_classApplyDescriptorSet");function Nx(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}s(Nx,"_classExtractFieldDescriptor");c(Nx,"_classExtractFieldDescriptor");function qb(t,e){var r=Nx(t,e,"get");return BF(t,r)}s(qb,"_classPrivateFieldGet");c(qb,"_classPrivateFieldGet");function PF(t,e,r){RF(t,e),e.set(t,r)}s(PF,"_classPrivateFieldInit");c(PF,"_classPrivateFieldInit");function OF(t,e,r){var n=Nx(t,e,"set");return DF(t,n,r),r}s(OF,"_classPrivateFieldSet");c(OF,"_classPrivateFieldSet");var Sp=new WeakMap,F5=s(class{get connection(){return qb(this,Sp)}createID(){return pte()}request(t,e=void 0,r={}){let{signal:n}=r;if(n?.aborted)return Promise.reject(O5);let i=this.createID(),o=qb(this,Sp).send({jsonrpc:"2.0",id:i,method:t,params:e}).then(a=>{if(a==null)throw new Error("Missing response");if(a.error!=null)throw Jf.fromObject(a.error);return a.result});return n==null?o:(n.addEventListener("abort",()=>{this.notify(kF,{id:i})}),IF(o,n))}async notify(t,e=void 0){await qb(this,Sp).send({jsonrpc:"2.0",method:t,params:e})}constructor(t){PF(this,Sp,{writable:!0,value:void 0}),OF(this,Sp,t)}},"RPCClient");c(F5,"RPCClient");function N5(t,e){return{jsonrpc:"2.0",id:t,error:{code:e,message:Ov(e)}}}s(N5,"createErrorResponse");c(N5,"createErrorResponse");function FF(t,e,r){console.warn("Unhandled handler error",e,r)}s(FF,"fallbackOnHandlerError");c(FF,"fallbackOnHandlerError");function NF(t,e){console.warn("Unhandled invalid message",e)}s(NF,"fallbackOnInvalidMessage");c(NF,"fallbackOnInvalidMessage");function LF(t,e){console.warn("Unhandled notification",e)}s(LF,"fallbackOnNotification");c(LF,"fallbackOnNotification");function UF(t,e={}){let r=e.onHandlerError??FF,n=e.onInvalidMessage??NF,i=e.onNotification??LF,o={};function a(f,l){if(l.method===kF){let u=l.params?.id;u!=null&&o[u]?.abort()}else i(f,l)}return s(a,"handleNotification"),c(a,"handleNotification"),c(s(async function(l,u){let h=u.id;if(u.jsonrpc!=="2.0"||u.method==null)return h==null?(n(l,u),null):N5(h,hs.INVALID_REQUEST);let g=t[u.method];if(g==null)return h==null?(a(l,u),null):N5(h,hs.METHOD_NOT_FOUND);try{let x;if(h!=null&&g[hte]){let E=new AbortController;o[h]=E,x=g(l,u.params,{signal:E.signal})}else x=g(l,u.params,{});let _=x==null?x:typeof x.then=="function"?await x:x;return h==null||o[h]?.signal.aborted?null:{jsonrpc:"2.0",id:h,result:_}}catch(x){if(h==null||o[h]?.signal.aborted)return r(l,u,x),null;let _;if(x instanceof Jf)_=x.toObject();else{r(l,u,x);let E=x.code??-32e3;_={code:E,message:x.message||Ov(E)}}return{jsonrpc:"2.0",id:h,error:_}}finally{h!=null&&delete o[h]}},"handleRequest"),"handleRequest")}s(UF,"createHandler");c(UF,"createHandler");Ga();var mte=wr(VY(),1),Gi=wr(gh(),1),gte=`
|
|
659
|
+
}`)),document.body.appendChild(i);let o={};return o.permissions=new YD(n),o.CredentialHandlers=new WD(n),o.CredentialHandler=GD,o.CredentialManager=f2,o.credentials=new JD(n),o.WebCredential=Hd,navigator.credentialsPolyfill=o,"credentials"in navigator?(navigator.credentials.get=o.credentials.get.bind(o.credentials),navigator.credentials.store=o.credentials.store.bind(o.credentials)):navigator.credentials=o.credentials,window.CredentialManager=f2,window.WebCredential=Hd,o}s(XD,"load2");c(XD,"load");function QD(){if(!window.isSecureContext)throw new DOMException("SecurityError","The operation is insecure.")}s(QD,"_assertSecureContext");c(QD,"_assertSecureContext");var qZ=6e4,eP=s(class extends ox{constructor(){super(window.location.origin)}async receive(){let t=this;return await t.connect(),new Promise((e,r)=>{let n=setTimeout(()=>{r(new Error("Timed out waiting to receive event."))},qZ);t.server.define("credentialEventProxy",{async send(i){return e(i),clearTimeout(n),new Promise((o,a)=>{i.respondWith=f=>{try{o(f)}catch(l){a(l)}}})}}),t.ready()})}},"CredentialEventProxy");c(eP,"CredentialEventProxy");var HZ="https://authn.io";async function tP(){if(await navigator.credentialsPolyfill.CredentialManager.requestPermission()!=="granted")throw new Error("Permission denied.")}s(tP,"installHandler");c(tP,"installHandler");async function rP({mediatorOrigin:t=HZ,get:e,store:r}){if(!(e||r))throw new Error('"get" or "store" function(s) must be specified.');let n=navigator.credentialsPolyfill.CredentialHandler,i=new n(t);if(e){if(typeof e!="function")throw new TypeError('"get" must be a function.');i.addEventListener("credentialrequest",o=>b5({event:o,get:e}))}if(r){if(typeof r!="function")throw new TypeError('"store" must be a function.');i.addEventListener("credentialstore",o=>b5({event:o,store:r}))}await i.connect()}s(rP,"activateHandler");c(rP,"activateHandler");async function nP(){return new eP().receive()}s(nP,"receiveCredentialEvent");c(nP,"receiveCredentialEvent");function b5({event:t,get:e,store:r}){t.respondWith(iP({event:t,get:e,store:r}))}s(b5,"listener");c(b5,"listener");async function iP({event:t,get:e,store:r}){let n=await(e||r)({event:t});if(!(n&&typeof n=="object"))throw new TypeError('Return value of "get" or "store" hook must be an object.');if(n.type==="response")return{dataType:n.dataType,data:n.data};if(n.type==="redirect"){let i=new cx,o=await t.openWindow(n.url);return(await i.createWindow(n.url,{handle:o,popup:!1,timeout:6e5})).get("credentialEventProxy",{functions:[{name:"send",options:{timeout:0}}]}).send({type:t.type,credentialRequestOptions:t.credentialRequestOptions,credentialRequestOrigin:t.credentialRequestOrigin,credential:t.credential,hintKey:t.hintKey})}throw new Error('Return value of "get" or "store" must have a type of "response" or "redirect".')}s(iP,"createResponse");c(iP,"createResponse");var fx=c(async()=>typeof window>"u"?{name:"CHAPI",methods:{installChapiHandler:async()=>{throw new Error("CHAPI is only available inside of a browser!")},activateChapiHandler:async()=>{throw new Error("CHAPI is only available inside of a browser!")},receiveChapiEvent:async()=>{throw new Error("CHAPI is only available inside of a browser!")},storeCredentialViaChapiDidAuth:async()=>{throw new Error("CHAPI is only available inside of a browser!")},storePresentationViaChapi:async()=>{throw new Error("CHAPI is only available inside of a browser!")}}}:(await ZD(),{name:"CHAPI",displayName:"CHAPI",description:"Credential Handler API. Allows sending/retrieving credentials across wallets and issuers",methods:{installChapiHandler:async()=>tP(),activateChapiHandler:async(t,{mediatorOrigin:e=`https://authn.io/mediator?${encodeURIComponent(window.location.origin)}`,get:r,store:n})=>rP({mediatorOrigin:e,get:r,store:n}),receiveChapiEvent:async()=>nP(),storeCredentialViaChapiDidAuth:async(t,e)=>{let r=crypto.randomUUID(),n=window.location.origin,i={web:{VerifiablePresentation:{query:{type:"DIDAuthentication"},challenge:r,domain:n}}},o=await navigator.credentials.get(i);if(!o)return{success:!1,reason:"did not auth"};let a=await t.invoke.verifyPresentation(o.data,{challenge:r,domain:n,proofPurpose:"authentication"});if(a.warnings.length>0||a.errors.length>0)return{success:!1,reason:"auth failed verification"};let f=o.data?.proof?.verificationMethod?.split("#")[0];Array.isArray(e.credentialSubject)||(e.credentialSubject.id=f);let l=await t.invoke.getTestVp(await t.invoke.issueCredential(e));return await t.invoke.storePresentationViaChapi(l)?{success:!0}:{success:!1,reason:"did not store"}},storePresentationViaChapi:async(t,e)=>{let r=new WebCredential("VerifiablePresentation",e);return window.navigator.credentials.store(r)}}}),"getCHAPIPlugin"),Rr;(function(t){t.assertEqual=i=>i;function e(i){}s(e,"assertIs"),c(e,"assertIs"),t.assertIs=e;function r(i){throw new Error}s(r,"assertNever"),c(r,"assertNever"),t.assertNever=r,t.arrayToEnum=i=>{let o={};for(let a of i)o[a]=a;return o},t.getValidEnumValues=i=>{let o=t.objectKeys(i).filter(f=>typeof i[i[f]]!="number"),a={};for(let f of o)a[f]=i[f];return t.objectValues(a)},t.objectValues=i=>t.objectKeys(i).map(function(o){return i[o]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let o=[];for(let a in i)Object.prototype.hasOwnProperty.call(i,a)&&o.push(a);return o},t.find=(i,o)=>{for(let a of i)if(o(a))return a},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,o=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}s(n,"joinValues"),c(n,"joinValues"),t.joinValues=n,t.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(Rr||(Rr={}));var wt=Rr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Nf=c(t=>{switch(typeof t){case"undefined":return wt.undefined;case"string":return wt.string;case"number":return isNaN(t)?wt.nan:wt.number;case"boolean":return wt.boolean;case"function":return wt.function;case"bigint":return wt.bigint;case"symbol":return wt.symbol;case"object":return Array.isArray(t)?wt.array:t===null?wt.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?wt.promise:typeof Map<"u"&&t instanceof Map?wt.map:typeof Set<"u"&&t instanceof Set?wt.set:typeof Date<"u"&&t instanceof Date?wt.date:wt.object;default:return wt.unknown}},"getParsedType"),it=Rr.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),zZ=c(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),Oa=s(class extends Error{constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=t}get errors(){return this.issues}format(t){let e=t||function(i){return i.message},r={_errors:[]},n=c(i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(n);else if(o.code==="invalid_return_type")n(o.returnTypeError);else if(o.code==="invalid_arguments")n(o.argumentsError);else if(o.path.length===0)r._errors.push(e(o));else{let a=r,f=0;for(;f<o.path.length;){let l=o.path[f];f===o.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(e(o))):a[l]=a[l]||{_errors:[]},a=a[l],f++}}},"processError");return n(this),r}toString(){return this.message}get message(){return JSON.stringify(this.issues,Rr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=e=>e.message){let e={},r=[];for(let n of this.issues)n.path.length>0?(e[n.path[0]]=e[n.path[0]]||[],e[n.path[0]].push(t(n))):r.push(t(n));return{formErrors:r,fieldErrors:e}}get formErrors(){return this.flatten()}},"ZodError");c(Oa,"ZodError");Oa.create=t=>new Oa(t);var Vp=c((t,e)=>{let r;switch(t.code){case it.invalid_type:t.received===wt.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case it.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Rr.jsonStringifyReplacer)}`;break;case it.unrecognized_keys:r=`Unrecognized key(s) in object: ${Rr.joinValues(t.keys,", ")}`;break;case it.invalid_union:r="Invalid input";break;case it.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Rr.joinValues(t.options)}`;break;case it.invalid_enum_value:r=`Invalid enum value. Expected ${Rr.joinValues(t.options)}, received '${t.received}'`;break;case it.invalid_arguments:r="Invalid function arguments";break;case it.invalid_return_type:r="Invalid function return type";break;case it.invalid_date:r="Invalid date";break;case it.invalid_string:typeof t.validation=="object"?"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Rr.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case it.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(t.minimum)}`:r="Invalid input";break;case it.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(t.maximum)}`:r="Invalid input";break;case it.custom:r="Invalid input";break;case it.invalid_intersection_types:r="Intersection results could not be merged";break;case it.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case it.not_finite:r="Number must be finite";break;default:r=e.defaultError,Rr.assertNever(t)}return{message:r}},"errorMap"),sP=Vp;function oP(t){sP=t}s(oP,"setErrorMap");c(oP,"setErrorMap");function Wp(){return sP}s(Wp,"getErrorMap");c(Wp,"getErrorMap");var l2=c(t=>{let{data:e,path:r,errorMaps:n,issueData:i}=t,o=[...r,...i.path||[]],a={...i,path:o},f="",l=n.filter(u=>!!u).slice().reverse();for(let u of l)f=u(a,{data:e,defaultError:f}).message;return{...i,path:o,message:i.message||f}},"makeIssue"),$Z=[];function St(t,e){let r=l2({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Wp(),Vp].filter(n=>!!n)});t.common.issues.push(r)}s(St,"addIssueToContext");c(St,"addIssueToContext");var Yi=s(class{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,e){let r=[];for(let n of e){if(n.status==="aborted")return Gt;n.status==="dirty"&&t.dirty(),r.push(n.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,e){let r=[];for(let n of e)r.push({key:await n.key,value:await n.value});return Yi.mergeObjectSync(t,r)}static mergeObjectSync(t,e){let r={};for(let n of e){let{key:i,value:o}=n;if(i.status==="aborted"||o.status==="aborted")return Gt;i.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),(typeof o.value<"u"||n.alwaysSet)&&(r[i.value]=o.value)}return{status:t.value,value:r}}},"ParseStatus");c(Yi,"ParseStatus");var Gt=Object.freeze({status:"aborted"}),aP=c(t=>({status:"dirty",value:t}),"DIRTY"),Ri=c(t=>({status:"valid",value:t}),"OK"),v5=c(t=>t.status==="aborted","isAborted"),y5=c(t=>t.status==="dirty","isDirty"),u2=c(t=>t.status==="valid","isValid"),d2=c(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),mr;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(mr||(mr={}));var Ko=s(class{constructor(t,e,r,n){this.parent=t,this.data=e,this._path=r,this._key=n}get path(){return this._path.concat(this._key)}},"ParseInputLazyPath");c(Ko,"ParseInputLazyPath");var wM=c((t,e)=>{if(u2(e))return{success:!0,data:e.value};{if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");let r=new Oa(t.common.issues);return{success:!1,error:r}}},"handleResult");function er(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:c((a,f)=>a.code!=="invalid_type"?{message:f.defaultError}:typeof f.data>"u"?{message:n??f.defaultError}:{message:r??f.defaultError},"customMap"),description:i}}s(er,"processCreateParams");c(er,"processCreateParams");var cr=s(class{constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(t){return Nf(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:Nf(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Yi,ctx:{common:t.parent.common,data:t.data,parsedType:Nf(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let e=this._parse(t);if(d2(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){let e=this._parse(t);return Promise.resolve(e)}parse(t,e){let r=this.safeParse(t,e);if(r.success)return r.data;throw r.error}safeParse(t,e){var r;let n={common:{issues:[],async:(r=e?.async)!==null&&r!==void 0?r:!1,contextualErrorMap:e?.errorMap},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Nf(t)},i=this._parseSync({data:t,path:n.path,parent:n});return wM(n,i)}async parseAsync(t,e){let r=await this.safeParseAsync(t,e);if(r.success)return r.data;throw r.error}async safeParseAsync(t,e){let r={common:{issues:[],contextualErrorMap:e?.errorMap,async:!0},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Nf(t)},n=this._parse({data:t,path:r.path,parent:r}),i=await(d2(n)?n:Promise.resolve(n));return wM(r,i)}refine(t,e){let r=c(n=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(n):e,"getIssueProperties");return this._refinement((n,i)=>{let o=t(n),a=c(()=>i.addIssue({code:it.custom,...r(n)}),"setError");return typeof Promise<"u"&&o instanceof Promise?o.then(f=>f?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,e){return this._refinement((r,n)=>t(r)?!0:(n.addIssue(typeof e=="function"?e(r,n):e),!1))}_refinement(t){return new mo({schema:this,typeName:qt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}optional(){return Fa.create(this,this._def)}nullable(){return $f.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $o.create(this,this._def)}promise(){return nu.create(this,this._def)}or(t){return eh.create([this,t],this._def)}and(t){return th.create(this,t,this._def)}transform(t){return new mo({...er(this._def),schema:this,typeName:qt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let e=typeof t=="function"?t:()=>t;return new sh({...er(this._def),innerType:this,defaultValue:e,typeName:qt.ZodDefault})}brand(){return new ux({typeName:qt.ZodBranded,type:this,...er(this._def)})}catch(t){let e=typeof t=="function"?t:()=>t;return new Qp({...er(this._def),innerType:this,catchValue:e,typeName:qt.ZodCatch})}describe(t){let e=this.constructor;return new e({...this._def,description:t})}pipe(t){return R1.create(this,t)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},"ZodType");c(cr,"ZodType");var GZ=/^c[^\s-]{8,}$/i,KZ=/^[a-z][a-z0-9]*$/,VZ=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,WZ=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|([^-]([a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}))$/,JZ=c(t=>t.precision?t.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}Z$`):t.precision===0?t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"),"datetimeRegex"),Lc=s(class extends cr{constructor(){super(...arguments),this._regex=(t,e,r)=>this.refinement(n=>t.test(n),{validation:e,code:it.invalid_string,...mr.errToObj(r)}),this.nonempty=t=>this.min(1,mr.errToObj(t)),this.trim=()=>new Lc({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==wt.string){let i=this._getOrReturnCtx(t);return St(i,{code:it.invalid_type,expected:wt.string,received:i.parsedType}),Gt}let r=new Yi,n;for(let i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(n=this._getOrReturnCtx(t,n),St(n,{code:it.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")t.data.length>i.value&&(n=this._getOrReturnCtx(t,n),St(n,{code:it.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let o=t.data.length>i.value,a=t.data.length<i.value;(o||a)&&(n=this._getOrReturnCtx(t,n),o?St(n,{code:it.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&St(n,{code:it.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")WZ.test(t.data)||(n=this._getOrReturnCtx(t,n),St(n,{validation:"email",code:it.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")VZ.test(t.data)||(n=this._getOrReturnCtx(t,n),St(n,{validation:"uuid",code:it.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")GZ.test(t.data)||(n=this._getOrReturnCtx(t,n),St(n,{validation:"cuid",code:it.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")KZ.test(t.data)||(n=this._getOrReturnCtx(t,n),St(n,{validation:"cuid2",code:it.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{n=this._getOrReturnCtx(t,n),St(n,{validation:"url",code:it.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(n=this._getOrReturnCtx(t,n),St(n,{validation:"regex",code:it.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="startsWith"?t.data.startsWith(i.value)||(n=this._getOrReturnCtx(t,n),St(n,{code:it.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(n=this._getOrReturnCtx(t,n),St(n,{code:it.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?JZ(i).test(t.data)||(n=this._getOrReturnCtx(t,n),St(n,{code:it.invalid_string,validation:"datetime",message:i.message}),r.dirty()):Rr.assertNever(i);return{status:r.value,value:t.data}}_addCheck(t){return new Lc({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...mr.errToObj(t)})}url(t){return this._addCheck({kind:"url",...mr.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...mr.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...mr.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...mr.errToObj(t)})}datetime(t){var e;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(e=t?.offset)!==null&&e!==void 0?e:!1,...mr.errToObj(t?.message)})}regex(t,e){return this._addCheck({kind:"regex",regex:t,...mr.errToObj(e)})}startsWith(t,e){return this._addCheck({kind:"startsWith",value:t,...mr.errToObj(e)})}endsWith(t,e){return this._addCheck({kind:"endsWith",value:t,...mr.errToObj(e)})}min(t,e){return this._addCheck({kind:"min",value:t,...mr.errToObj(e)})}max(t,e){return this._addCheck({kind:"max",value:t,...mr.errToObj(e)})}length(t,e){return this._addCheck({kind:"length",value:t,...mr.errToObj(e)})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get minLength(){let t=null;for(let e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxLength(){let t=null;for(let e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}},"ZodString");c(Lc,"ZodString");Lc.create=t=>{var e;return new Lc({checks:[],typeName:qt.ZodString,coerce:(e=t?.coerce)!==null&&e!==void 0?e:!1,...er(t)})};function cP(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,o=parseInt(t.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return o%a/Math.pow(10,i)}s(cP,"floatSafeRemainder");c(cP,"floatSafeRemainder");var Hf=s(class extends cr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==wt.number){let i=this._getOrReturnCtx(t);return St(i,{code:it.invalid_type,expected:wt.number,received:i.parsedType}),Gt}let r,n=new Yi;for(let i of this._def.checks)i.kind==="int"?Rr.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),St(r,{code:it.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),St(r,{code:it.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),St(r,{code:it.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?cP(t.data,i.value)!==0&&(r=this._getOrReturnCtx(t,r),St(r,{code:it.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),St(r,{code:it.not_finite,message:i.message}),n.dirty()):Rr.assertNever(i);return{status:n.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,mr.toString(e))}gt(t,e){return this.setLimit("min",t,!1,mr.toString(e))}lte(t,e){return this.setLimit("max",t,!0,mr.toString(e))}lt(t,e){return this.setLimit("max",t,!1,mr.toString(e))}setLimit(t,e,r,n){return new Hf({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:mr.toString(n)}]})}_addCheck(t){return new Hf({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:mr.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:mr.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:mr.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:mr.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:mr.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:mr.toString(e)})}finite(t){return this._addCheck({kind:"finite",message:mr.toString(t)})}get minValue(){let t=null;for(let e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(let e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Rr.isInteger(t.value))}get isFinite(){let t=null,e=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(e===null||r.value>e)&&(e=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(e)&&Number.isFinite(t)}},"ZodNumber");c(Hf,"ZodNumber");Hf.create=t=>new Hf({checks:[],typeName:qt.ZodNumber,coerce:t?.coerce||!1,...er(t)});var Yd=s(class extends cr{_parse(t){if(this._def.coerce&&(t.data=BigInt(t.data)),this._getType(t)!==wt.bigint){let r=this._getOrReturnCtx(t);return St(r,{code:it.invalid_type,expected:wt.bigint,received:r.parsedType}),Gt}return Ri(t.data)}},"ZodBigInt");c(Yd,"ZodBigInt");Yd.create=t=>{var e;return new Yd({typeName:qt.ZodBigInt,coerce:(e=t?.coerce)!==null&&e!==void 0?e:!1,...er(t)})};var Zd=s(class extends cr{_parse(t){if(this._def.coerce&&(t.data=Boolean(t.data)),this._getType(t)!==wt.boolean){let r=this._getOrReturnCtx(t);return St(r,{code:it.invalid_type,expected:wt.boolean,received:r.parsedType}),Gt}return Ri(t.data)}},"ZodBoolean");c(Zd,"ZodBoolean");Zd.create=t=>new Zd({typeName:qt.ZodBoolean,coerce:t?.coerce||!1,...er(t)});var eu=s(class extends cr{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==wt.date){let i=this._getOrReturnCtx(t);return St(i,{code:it.invalid_type,expected:wt.date,received:i.parsedType}),Gt}if(isNaN(t.data.getTime())){let i=this._getOrReturnCtx(t);return St(i,{code:it.invalid_date}),Gt}let r=new Yi,n;for(let i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(n=this._getOrReturnCtx(t,n),St(n,{code:it.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(n=this._getOrReturnCtx(t,n),St(n,{code:it.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):Rr.assertNever(i);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new eu({...this._def,checks:[...this._def.checks,t]})}min(t,e){return this._addCheck({kind:"min",value:t.getTime(),message:mr.toString(e)})}max(t,e){return this._addCheck({kind:"max",value:t.getTime(),message:mr.toString(e)})}get minDate(){let t=null;for(let e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t!=null?new Date(t):null}},"ZodDate");c(eu,"ZodDate");eu.create=t=>new eu({checks:[],coerce:t?.coerce||!1,typeName:qt.ZodDate,...er(t)});var Jp=s(class extends cr{_parse(t){if(this._getType(t)!==wt.symbol){let r=this._getOrReturnCtx(t);return St(r,{code:it.invalid_type,expected:wt.symbol,received:r.parsedType}),Gt}return Ri(t.data)}},"ZodSymbol");c(Jp,"ZodSymbol");Jp.create=t=>new Jp({typeName:qt.ZodSymbol,...er(t)});var Xd=s(class extends cr{_parse(t){if(this._getType(t)!==wt.undefined){let r=this._getOrReturnCtx(t);return St(r,{code:it.invalid_type,expected:wt.undefined,received:r.parsedType}),Gt}return Ri(t.data)}},"ZodUndefined");c(Xd,"ZodUndefined");Xd.create=t=>new Xd({typeName:qt.ZodUndefined,...er(t)});var Qd=s(class extends cr{_parse(t){if(this._getType(t)!==wt.null){let r=this._getOrReturnCtx(t);return St(r,{code:it.invalid_type,expected:wt.null,received:r.parsedType}),Gt}return Ri(t.data)}},"ZodNull");c(Qd,"ZodNull");Qd.create=t=>new Qd({typeName:qt.ZodNull,...er(t)});var tu=s(class extends cr{constructor(){super(...arguments),this._any=!0}_parse(t){return Ri(t.data)}},"ZodAny");c(tu,"ZodAny");tu.create=t=>new tu({typeName:qt.ZodAny,...er(t)});var Lf=s(class extends cr{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ri(t.data)}},"ZodUnknown");c(Lf,"ZodUnknown");Lf.create=t=>new Lf({typeName:qt.ZodUnknown,...er(t)});var Na=s(class extends cr{_parse(t){let e=this._getOrReturnCtx(t);return St(e,{code:it.invalid_type,expected:wt.never,received:e.parsedType}),Gt}},"ZodNever");c(Na,"ZodNever");Na.create=t=>new Na({typeName:qt.ZodNever,...er(t)});var Yp=s(class extends cr{_parse(t){if(this._getType(t)!==wt.undefined){let r=this._getOrReturnCtx(t);return St(r,{code:it.invalid_type,expected:wt.void,received:r.parsedType}),Gt}return Ri(t.data)}},"ZodVoid");c(Yp,"ZodVoid");Yp.create=t=>new Yp({typeName:qt.ZodVoid,...er(t)});var $o=s(class extends cr{_parse(t){let{ctx:e,status:r}=this._processInputParams(t),n=this._def;if(e.parsedType!==wt.array)return St(e,{code:it.invalid_type,expected:wt.array,received:e.parsedType}),Gt;if(n.exactLength!==null){let o=e.data.length>n.exactLength.value,a=e.data.length<n.exactLength.value;(o||a)&&(St(e,{code:o?it.too_big:it.too_small,minimum:a?n.exactLength.value:void 0,maximum:o?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(n.minLength!==null&&e.data.length<n.minLength.value&&(St(e,{code:it.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),n.maxLength!==null&&e.data.length>n.maxLength.value&&(St(e,{code:it.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),e.common.async)return Promise.all([...e.data].map((o,a)=>n.type._parseAsync(new Ko(e,o,e.path,a)))).then(o=>Yi.mergeArray(r,o));let i=[...e.data].map((o,a)=>n.type._parseSync(new Ko(e,o,e.path,a)));return Yi.mergeArray(r,i)}get element(){return this._def.type}min(t,e){return new $o({...this._def,minLength:{value:t,message:mr.toString(e)}})}max(t,e){return new $o({...this._def,maxLength:{value:t,message:mr.toString(e)}})}length(t,e){return new $o({...this._def,exactLength:{value:t,message:mr.toString(e)}})}nonempty(t){return this.min(1,t)}},"ZodArray");c($o,"ZodArray");$o.create=(t,e)=>new $o({type:t,minLength:null,maxLength:null,exactLength:null,typeName:qt.ZodArray,...er(e)});var h2;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(h2||(h2={}));function Kl(t){if(t instanceof pn){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=Fa.create(Kl(n))}return new pn({...t._def,shape:()=>e})}else return t instanceof $o?$o.create(Kl(t.element)):t instanceof Fa?Fa.create(Kl(t.unwrap())):t instanceof $f?$f.create(Kl(t.unwrap())):t instanceof La?La.create(t.items.map(e=>Kl(e))):t}s(Kl,"deepPartialify");c(Kl,"deepPartialify");var pn=s(class extends cr{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),e=Rr.objectKeys(t);return this._cached={shape:t,keys:e}}_parse(t){if(this._getType(t)!==wt.object){let l=this._getOrReturnCtx(t);return St(l,{code:it.invalid_type,expected:wt.object,received:l.parsedType}),Gt}let{status:r,ctx:n}=this._processInputParams(t),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Na&&this._def.unknownKeys==="strip"))for(let l in n.data)o.includes(l)||a.push(l);let f=[];for(let l of o){let u=i[l],h=n.data[l];f.push({key:{status:"valid",value:l},value:u._parse(new Ko(n,h,n.path,l)),alwaysSet:l in n.data})}if(this._def.catchall instanceof Na){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of a)f.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(l==="strict")a.length>0&&(St(n,{code:it.unrecognized_keys,keys:a}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of a){let h=n.data[u];f.push({key:{status:"valid",value:u},value:l._parse(new Ko(n,h,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of f){let h=await u.key;l.push({key:h,value:await u.value,alwaysSet:u.alwaysSet})}return l}).then(l=>Yi.mergeObjectSync(r,l)):Yi.mergeObjectSync(r,f)}get shape(){return this._def.shape()}strict(t){return mr.errToObj,new pn({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(e,r)=>{var n,i,o,a;let f=(o=(i=(n=this._def).errorMap)===null||i===void 0?void 0:i.call(n,e,r).message)!==null&&o!==void 0?o:r.defaultError;return e.code==="unrecognized_keys"?{message:(a=mr.errToObj(t).message)!==null&&a!==void 0?a:f}:{message:f}}}:{}})}strip(){return new pn({...this._def,unknownKeys:"strip"})}passthrough(){return new pn({...this._def,unknownKeys:"passthrough"})}extend(t){return new pn({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new pn({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>h2.mergeShapes(this._def.shape(),t._def.shape()),typeName:qt.ZodObject})}setKey(t,e){return this.augment({[t]:e})}catchall(t){return new pn({...this._def,catchall:t})}pick(t){let e={};return Rr.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(e[r]=this.shape[r])}),new pn({...this._def,shape:()=>e})}omit(t){let e={};return Rr.objectKeys(this.shape).forEach(r=>{t[r]||(e[r]=this.shape[r])}),new pn({...this._def,shape:()=>e})}deepPartial(){return Kl(this)}partial(t){let e={};return Rr.objectKeys(this.shape).forEach(r=>{let n=this.shape[r];t&&!t[r]?e[r]=n:e[r]=n.optional()}),new pn({...this._def,shape:()=>e})}required(t){let e={};return Rr.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])e[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Fa;)i=i._def.innerType;e[r]=i}}),new pn({...this._def,shape:()=>e})}keyof(){return lx(Rr.objectKeys(this.shape))}},"ZodObject");c(pn,"ZodObject");pn.create=(t,e)=>new pn({shape:()=>t,unknownKeys:"strip",catchall:Na.create(),typeName:qt.ZodObject,...er(e)});pn.strictCreate=(t,e)=>new pn({shape:()=>t,unknownKeys:"strict",catchall:Na.create(),typeName:qt.ZodObject,...er(e)});pn.lazycreate=(t,e)=>new pn({shape:t,unknownKeys:"strip",catchall:Na.create(),typeName:qt.ZodObject,...er(e)});var eh=s(class extends cr{_parse(t){let{ctx:e}=this._processInputParams(t),r=this._def.options;function n(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return e.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new Oa(a.ctx.common.issues));return St(e,{code:it.invalid_union,unionErrors:o}),Gt}if(s(n,"handleResults"),c(n,"handleResults"),e.common.async)return Promise.all(r.map(async i=>{let o={...e,common:{...e.common,issues:[]},parent:null};return{result:await i._parseAsync({data:e.data,path:e.path,parent:o}),ctx:o}})).then(n);{let i,o=[];for(let f of r){let l={...e,common:{...e.common,issues:[]},parent:null},u=f._parseSync({data:e.data,path:e.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(i)return e.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(f=>new Oa(f));return St(e,{code:it.invalid_union,unionErrors:a}),Gt}}get options(){return this._def.options}},"ZodUnion");c(eh,"ZodUnion");eh.create=(t,e)=>new eh({options:t,typeName:qt.ZodUnion,...er(e)});var Ub=c(t=>t instanceof rh?Ub(t.schema):t instanceof mo?Ub(t.innerType()):t instanceof nh?[t.value]:t instanceof zf?t.options:t instanceof ih?Object.keys(t.enum):t instanceof sh?Ub(t._def.innerType):t instanceof Xd?[void 0]:t instanceof Qd?[null]:null,"getDiscriminator"),bv=s(class extends cr{_parse(t){let{ctx:e}=this._processInputParams(t);if(e.parsedType!==wt.object)return St(e,{code:it.invalid_type,expected:wt.object,received:e.parsedType}),Gt;let r=this.discriminator,n=e.data[r],i=this.optionsMap.get(n);return i?e.common.async?i._parseAsync({data:e.data,path:e.path,parent:e}):i._parseSync({data:e.data,path:e.path,parent:e}):(St(e,{code:it.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Gt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,e,r){let n=new Map;for(let i of e){let o=Ub(i.shape[t]);if(!o)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let a of o){if(n.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);n.set(a,i)}}return new bv({typeName:qt.ZodDiscriminatedUnion,discriminator:t,options:e,optionsMap:n,...er(r)})}},"ZodDiscriminatedUnion");c(bv,"ZodDiscriminatedUnion");function p2(t,e){let r=Nf(t),n=Nf(e);if(t===e)return{valid:!0,data:t};if(r===wt.object&&n===wt.object){let i=Rr.objectKeys(e),o=Rr.objectKeys(t).filter(f=>i.indexOf(f)!==-1),a={...t,...e};for(let f of o){let l=p2(t[f],e[f]);if(!l.valid)return{valid:!1};a[f]=l.data}return{valid:!0,data:a}}else if(r===wt.array&&n===wt.array){if(t.length!==e.length)return{valid:!1};let i=[];for(let o=0;o<t.length;o++){let a=t[o],f=e[o],l=p2(a,f);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return r===wt.date&&n===wt.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}s(p2,"mergeValues");c(p2,"mergeValues");var th=s(class extends cr{_parse(t){let{status:e,ctx:r}=this._processInputParams(t),n=c((i,o)=>{if(v5(i)||v5(o))return Gt;let a=p2(i.value,o.value);return a.valid?((y5(i)||y5(o))&&e.dirty(),{status:e.value,value:a.data}):(St(r,{code:it.invalid_intersection_types}),Gt)},"handleParsed");return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>n(i,o)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}},"ZodIntersection");c(th,"ZodIntersection");th.create=(t,e,r)=>new th({left:t,right:e,typeName:qt.ZodIntersection,...er(r)});var La=s(class extends cr{_parse(t){let{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==wt.array)return St(r,{code:it.invalid_type,expected:wt.array,received:r.parsedType}),Gt;if(r.data.length<this._def.items.length)return St(r,{code:it.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Gt;!this._def.rest&&r.data.length>this._def.items.length&&(St(r,{code:it.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());let i=[...r.data].map((o,a)=>{let f=this._def.items[a]||this._def.rest;return f?f._parse(new Ko(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>Yi.mergeArray(e,o)):Yi.mergeArray(e,i)}get items(){return this._def.items}rest(t){return new La({...this._def,rest:t})}},"ZodTuple");c(La,"ZodTuple");La.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new La({items:t,typeName:qt.ZodTuple,rest:null,...er(e)})};var Zp=s(class extends cr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==wt.object)return St(r,{code:it.invalid_type,expected:wt.object,received:r.parsedType}),Gt;let n=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)n.push({key:i._parse(new Ko(r,a,r.path,a)),value:o._parse(new Ko(r,r.data[a],r.path,a))});return r.common.async?Yi.mergeObjectAsync(e,n):Yi.mergeObjectSync(e,n)}get element(){return this._def.valueType}static create(t,e,r){return e instanceof cr?new Zp({keyType:t,valueType:e,typeName:qt.ZodRecord,...er(r)}):new Zp({keyType:Lc.create(),valueType:t,typeName:qt.ZodRecord,...er(e)})}},"ZodRecord");c(Zp,"ZodRecord");var Xp=s(class extends cr{_parse(t){let{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==wt.map)return St(r,{code:it.invalid_type,expected:wt.map,received:r.parsedType}),Gt;let n=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,f],l)=>({key:n._parse(new Ko(r,a,r.path,[l,"key"])),value:i._parse(new Ko(r,f,r.path,[l,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let f of o){let l=await f.key,u=await f.value;if(l.status==="aborted"||u.status==="aborted")return Gt;(l.status==="dirty"||u.status==="dirty")&&e.dirty(),a.set(l.value,u.value)}return{status:e.value,value:a}})}else{let a=new Map;for(let f of o){let l=f.key,u=f.value;if(l.status==="aborted"||u.status==="aborted")return Gt;(l.status==="dirty"||u.status==="dirty")&&e.dirty(),a.set(l.value,u.value)}return{status:e.value,value:a}}}},"ZodMap");c(Xp,"ZodMap");Xp.create=(t,e,r)=>new Xp({valueType:e,keyType:t,typeName:qt.ZodMap,...er(r)});var ru=s(class extends cr{_parse(t){let{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==wt.set)return St(r,{code:it.invalid_type,expected:wt.set,received:r.parsedType}),Gt;let n=this._def;n.minSize!==null&&r.data.size<n.minSize.value&&(St(r,{code:it.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),e.dirty()),n.maxSize!==null&&r.data.size>n.maxSize.value&&(St(r,{code:it.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),e.dirty());let i=this._def.valueType;function o(f){let l=new Set;for(let u of f){if(u.status==="aborted")return Gt;u.status==="dirty"&&e.dirty(),l.add(u.value)}return{status:e.value,value:l}}s(o,"finalizeSet"),c(o,"finalizeSet");let a=[...r.data.values()].map((f,l)=>i._parse(new Ko(r,f,r.path,l)));return r.common.async?Promise.all(a).then(f=>o(f)):o(a)}min(t,e){return new ru({...this._def,minSize:{value:t,message:mr.toString(e)}})}max(t,e){return new ru({...this._def,maxSize:{value:t,message:mr.toString(e)}})}size(t,e){return this.min(t,e).max(t,e)}nonempty(t){return this.min(1,t)}},"ZodSet");c(ru,"ZodSet");ru.create=(t,e)=>new ru({valueType:t,minSize:null,maxSize:null,typeName:qt.ZodSet,...er(e)});var zd=s(class extends cr{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:e}=this._processInputParams(t);if(e.parsedType!==wt.function)return St(e,{code:it.invalid_type,expected:wt.function,received:e.parsedType}),Gt;function r(a,f){return l2({data:a,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Wp(),Vp].filter(l=>!!l),issueData:{code:it.invalid_arguments,argumentsError:f}})}s(r,"makeArgsIssue"),c(r,"makeArgsIssue");function n(a,f){return l2({data:a,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Wp(),Vp].filter(l=>!!l),issueData:{code:it.invalid_return_type,returnTypeError:f}})}s(n,"makeReturnsIssue"),c(n,"makeReturnsIssue");let i={errorMap:e.common.contextualErrorMap},o=e.data;return this._def.returns instanceof nu?Ri(async(...a)=>{let f=new Oa([]),l=await this._def.args.parseAsync(a,i).catch(g=>{throw f.addIssue(r(a,g)),f}),u=await o(...l);return await this._def.returns._def.type.parseAsync(u,i).catch(g=>{throw f.addIssue(n(u,g)),f})}):Ri((...a)=>{let f=this._def.args.safeParse(a,i);if(!f.success)throw new Oa([r(a,f.error)]);let l=o(...f.data),u=this._def.returns.safeParse(l,i);if(!u.success)throw new Oa([n(l,u.error)]);return u.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new zd({...this._def,args:La.create(t).rest(Lf.create())})}returns(t){return new zd({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,e,r){return new zd({args:t||La.create([]).rest(Lf.create()),returns:e||Lf.create(),typeName:qt.ZodFunction,...er(r)})}},"ZodFunction");c(zd,"ZodFunction");var rh=s(class extends cr{get schema(){return this._def.getter()}_parse(t){let{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}},"ZodLazy");c(rh,"ZodLazy");rh.create=(t,e)=>new rh({getter:t,typeName:qt.ZodLazy,...er(e)});var nh=s(class extends cr{_parse(t){if(t.data!==this._def.value){let e=this._getOrReturnCtx(t);return St(e,{received:e.data,code:it.invalid_literal,expected:this._def.value}),Gt}return{status:"valid",value:t.data}}get value(){return this._def.value}},"ZodLiteral");c(nh,"ZodLiteral");nh.create=(t,e)=>new nh({value:t,typeName:qt.ZodLiteral,...er(e)});function lx(t,e){return new zf({values:t,typeName:qt.ZodEnum,...er(e)})}s(lx,"createZodEnum");c(lx,"createZodEnum");var zf=s(class extends cr{_parse(t){if(typeof t.data!="string"){let e=this._getOrReturnCtx(t),r=this._def.values;return St(e,{expected:Rr.joinValues(r),received:e.parsedType,code:it.invalid_type}),Gt}if(this._def.values.indexOf(t.data)===-1){let e=this._getOrReturnCtx(t),r=this._def.values;return St(e,{received:e.data,code:it.invalid_enum_value,options:r}),Gt}return Ri(t.data)}get options(){return this._def.values}get enum(){let t={};for(let e of this._def.values)t[e]=e;return t}get Values(){let t={};for(let e of this._def.values)t[e]=e;return t}get Enum(){let t={};for(let e of this._def.values)t[e]=e;return t}extract(t){return zf.create(t)}exclude(t){return zf.create(this.options.filter(e=>!t.includes(e)))}},"ZodEnum");c(zf,"ZodEnum");zf.create=lx;var ih=s(class extends cr{_parse(t){let e=Rr.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==wt.string&&r.parsedType!==wt.number){let n=Rr.objectValues(e);return St(r,{expected:Rr.joinValues(n),received:r.parsedType,code:it.invalid_type}),Gt}if(e.indexOf(t.data)===-1){let n=Rr.objectValues(e);return St(r,{received:r.data,code:it.invalid_enum_value,options:n}),Gt}return Ri(t.data)}get enum(){return this._def.values}},"ZodNativeEnum");c(ih,"ZodNativeEnum");ih.create=(t,e)=>new ih({values:t,typeName:qt.ZodNativeEnum,...er(e)});var nu=s(class extends cr{unwrap(){return this._def.type}_parse(t){let{ctx:e}=this._processInputParams(t);if(e.parsedType!==wt.promise&&e.common.async===!1)return St(e,{code:it.invalid_type,expected:wt.promise,received:e.parsedType}),Gt;let r=e.parsedType===wt.promise?e.data:Promise.resolve(e.data);return Ri(r.then(n=>this._def.type.parseAsync(n,{path:e.path,errorMap:e.common.contextualErrorMap})))}},"ZodPromise");c(nu,"ZodPromise");nu.create=(t,e)=>new nu({type:t,typeName:qt.ZodPromise,...er(e)});var mo=s(class extends cr{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===qt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:e,ctx:r}=this._processInputParams(t),n=this._def.effect||null;if(n.type==="preprocess"){let o=n.transform(r.data);return r.common.async?Promise.resolve(o).then(a=>this._def.schema._parseAsync({data:a,path:r.path,parent:r})):this._def.schema._parseSync({data:o,path:r.path,parent:r})}let i={addIssue:o=>{St(r,o),o.fatal?e.abort():e.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),n.type==="refinement"){let o=c(a=>{let f=n.refinement(a,i);if(r.common.async)return Promise.resolve(f);if(f instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a},"executeRefinement");if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Gt:(a.status==="dirty"&&e.dirty(),o(a.value),{status:e.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Gt:(a.status==="dirty"&&e.dirty(),o(a.value).then(()=>({status:e.value,value:a.value}))))}if(n.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!u2(o))return o;let a=n.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>u2(o)?Promise.resolve(n.transform(o.value,i)).then(a=>({status:e.value,value:a})):o);Rr.assertNever(n)}},"ZodEffects");c(mo,"ZodEffects");mo.create=(t,e,r)=>new mo({schema:t,typeName:qt.ZodEffects,effect:e,...er(r)});mo.createWithPreprocess=(t,e,r)=>new mo({schema:e,effect:{type:"preprocess",transform:t},typeName:qt.ZodEffects,...er(r)});var Fa=s(class extends cr{_parse(t){return this._getType(t)===wt.undefined?Ri(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}},"ZodOptional");c(Fa,"ZodOptional");Fa.create=(t,e)=>new Fa({innerType:t,typeName:qt.ZodOptional,...er(e)});var $f=s(class extends cr{_parse(t){return this._getType(t)===wt.null?Ri(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}},"ZodNullable");c($f,"ZodNullable");$f.create=(t,e)=>new $f({innerType:t,typeName:qt.ZodNullable,...er(e)});var sh=s(class extends cr{_parse(t){let{ctx:e}=this._processInputParams(t),r=e.data;return e.parsedType===wt.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:e.path,parent:e})}removeDefault(){return this._def.innerType}},"ZodDefault");c(sh,"ZodDefault");sh.create=(t,e)=>new sh({innerType:t,typeName:qt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...er(e)});var Qp=s(class extends cr{_parse(t){let{ctx:e}=this._processInputParams(t),r=this._def.innerType._parse({data:e.data,path:e.path,parent:{...e,common:{...e.common,issues:[]}}});return d2(r)?r.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue()})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue()}}removeCatch(){return this._def.innerType}},"ZodCatch");c(Qp,"ZodCatch");Qp.create=(t,e)=>new Qp({innerType:t,typeName:qt.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...er(e)});var e1=s(class extends cr{_parse(t){if(this._getType(t)!==wt.nan){let r=this._getOrReturnCtx(t);return St(r,{code:it.invalid_type,expected:wt.nan,received:r.parsedType}),Gt}return{status:"valid",value:t.data}}},"ZodNaN");c(e1,"ZodNaN");e1.create=t=>new e1({typeName:qt.ZodNaN,...er(t)});var YZ=Symbol("zod_brand"),ux=s(class extends cr{_parse(t){let{ctx:e}=this._processInputParams(t),r=e.data;return this._def.type._parse({data:r,path:e.path,parent:e})}unwrap(){return this._def.type}},"ZodBranded");c(ux,"ZodBranded");var R1=s(class extends cr{_parse(t){let{status:e,ctx:r}=this._processInputParams(t);if(r.common.async)return c(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Gt:i.status==="dirty"?(e.dirty(),aP(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})},"handleAsync")();{let n=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return n.status==="aborted"?Gt:n.status==="dirty"?(e.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:r.path,parent:r})}}static create(t,e){return new R1({in:t,out:e,typeName:qt.ZodPipeline})}},"ZodPipeline");c(R1,"ZodPipeline");var fP=c((t,e={},r)=>t?tu.create().superRefine((n,i)=>{if(!t(n)){let o=typeof e=="function"?e(n):e,a=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...a,fatal:r})}}):tu.create(),"custom"),ZZ={object:pn.lazycreate},qt;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline"})(qt||(qt={}));var XZ=c((t,e={message:`Input not instance of ${t.name}`})=>fP(r=>r instanceof t,e,!0),"instanceOfType"),lP=Lc.create,uP=Hf.create,QZ=e1.create,eX=Yd.create,dP=Zd.create,tX=eu.create,rX=Jp.create,nX=Xd.create,iX=Qd.create,sX=tu.create,oX=Lf.create,aX=Na.create,cX=Yp.create,fX=$o.create,lX=pn.create,uX=pn.strictCreate,dX=eh.create,hX=bv.create,pX=th.create,mX=La.create,gX=Zp.create,bX=Xp.create,vX=ru.create,yX=zd.create,xX=rh.create,wX=nh.create,_X=zf.create,AX=ih.create,EX=nu.create,_M=mo.create,CX=Fa.create,SX=$f.create,IX=mo.createWithPreprocess,kX=R1.create,TX=c(()=>lP().optional(),"ostring"),MX=c(()=>uP().optional(),"onumber"),RX=c(()=>dP().optional(),"oboolean"),BX={string:t=>Lc.create({...t,coerce:!0}),number:t=>Hf.create({...t,coerce:!0}),boolean:t=>Zd.create({...t,coerce:!0}),bigint:t=>Yd.create({...t,coerce:!0}),date:t=>eu.create({...t,coerce:!0})},DX=Gt,we=Object.freeze({__proto__:null,defaultErrorMap:Vp,setErrorMap:oP,getErrorMap:Wp,makeIssue:l2,EMPTY_PATH:$Z,addIssueToContext:St,ParseStatus:Yi,INVALID:Gt,DIRTY:aP,OK:Ri,isAborted:v5,isDirty:y5,isValid:u2,isAsync:d2,get util(){return Rr},ZodParsedType:wt,getParsedType:Nf,ZodType:cr,ZodString:Lc,ZodNumber:Hf,ZodBigInt:Yd,ZodBoolean:Zd,ZodDate:eu,ZodSymbol:Jp,ZodUndefined:Xd,ZodNull:Qd,ZodAny:tu,ZodUnknown:Lf,ZodNever:Na,ZodVoid:Yp,ZodArray:$o,get objectUtil(){return h2},ZodObject:pn,ZodUnion:eh,ZodDiscriminatedUnion:bv,ZodIntersection:th,ZodTuple:La,ZodRecord:Zp,ZodMap:Xp,ZodSet:ru,ZodFunction:zd,ZodLazy:rh,ZodLiteral:nh,ZodEnum:zf,ZodNativeEnum:ih,ZodPromise:nu,ZodEffects:mo,ZodTransformer:mo,ZodOptional:Fa,ZodNullable:$f,ZodDefault:sh,ZodCatch:Qp,ZodNaN:e1,BRAND:YZ,ZodBranded:ux,ZodPipeline:R1,custom:fP,Schema:cr,ZodSchema:cr,late:ZZ,get ZodFirstPartyTypeKind(){return qt},coerce:BX,any:sX,array:fX,bigint:eX,boolean:dP,date:tX,discriminatedUnion:hX,effect:_M,enum:_X,function:yX,instanceof:XZ,intersection:pX,lazy:xX,literal:wX,map:bX,nan:QZ,nativeEnum:AX,never:aX,null:iX,nullable:SX,number:uP,object:lX,oboolean:RX,onumber:MX,optional:CX,ostring:TX,pipeline:kX,preprocess:IX,promise:EX,record:gX,set:vX,strictObject:uX,string:lP,symbol:rX,transformer:_M,tuple:mX,undefined:nX,union:dX,unknown:oX,void:cX,NEVER:DX,ZodIssueCode:it,quotelessJson:zZ,ZodError:Oa}),hP=we.array(we.string().or(we.record(we.any()))),Ape=we.object({type:we.string().optional(),narrative:we.string().optional()}),vv=we.string().or(we.object({id:we.string(),type:we.string(),caption:we.string().optional()})),PX=we.object({type:we.string().min(1).or(we.string().array().nonempty()),latitude:we.number(),longitude:we.number()}),OX=we.object({type:we.string().min(1).or(we.string().array().nonempty()),addressCountry:we.string().optional(),addressCountryCode:we.string().optional(),addressRegion:we.string().optional(),addressLocality:we.string().optional(),streetAddress:we.string().optional(),postOfficeBoxNumber:we.string().optional(),postalCode:we.string().optional(),geo:PX.optional()}),FX=we.enum(["sourcedId","systemId","productId","userName","accountId","emailAddress","nationalIdentityNumber","isbn","issn","lisSourcedId","oneRosterSourcedId","sisSourcedId","ltiContextId","ltiDeploymentId","ltiToolId","ltiPlatformId","ltiUserId","identifier"]).or(we.string()),pP=we.object({type:we.string().min(1).or(we.string().array().nonempty()),identifier:we.string(),identifierType:FX}),t1=we.string().or(we.object({id:we.string().optional(),type:we.string().or(we.string().array().nonempty().optional()),name:we.string().optional(),url:we.string().optional(),phone:we.string().optional(),description:we.string().optional(),endorsement:we.any().array().optional(),image:vv.optional(),email:we.string().email().optional(),address:OX.optional(),otherIdentifier:pP.array().optional(),official:we.string().optional(),parentOrg:we.any().optional(),familyName:we.string().optional(),givenName:we.string().optional(),additionalName:we.string().optional(),patronymicName:we.string().optional(),honorificPrefix:we.string().optional(),honorificSuffix:we.string().optional(),familyNamePrefix:we.string().optional(),dateOfBirth:we.string().optional()}).catchall(we.any())),x5=we.object({id:we.string().optional()}).catchall(we.any()),NX=we.object({type:we.string(),id:we.string()}),LX=we.object({id:we.string(),type:we.string()}),UX=we.object({id:we.string(),type:we.string()}).catchall(we.any()),r1=we.object({"@context":hP,id:we.string().optional(),type:we.string().array().nonempty(),issuer:t1,issuanceDate:we.string(),expirationDate:we.string().optional(),credentialSubject:x5.or(x5.array()),credentialStatus:NX.optional(),credentialSchema:LX.array().optional(),refreshService:UX.optional()}).catchall(we.any()),Gf=we.object({type:we.string(),created:we.string(),challenge:we.string().optional(),domain:we.string().optional(),nonce:we.string().optional(),proofPurpose:we.string(),verificationMethod:we.string(),jws:we.string().optional()}).catchall(we.any()),Fc=r1.extend({proof:Gf.or(Gf.array())}),mP=we.object({"@context":hP,id:we.string().optional(),type:we.string().array().nonempty(),verifiableCredential:Fc.or(Fc.array()).optional(),holder:we.string().optional()}).catchall(we.any()),m2=mP.extend({proof:Gf.or(Gf.array())}),jX=we.enum(["ceasn:Competency","ceterms:Credential","CFItem","CFRubric","CFRubricCriterion","CFRubricCriterionLevel","CTDL"]).or(we.string()),yv=we.object({type:we.string().array().nonempty(),targetCode:we.string().optional(),targetDescription:we.string().optional(),targetName:we.string(),targetFramework:we.string().optional(),targetType:jX.optional(),targetUrl:we.string()}),qX=we.enum(["Achievement","ApprenticeshipCertificate","Assessment","Assignment","AssociateDegree","Award","Badge","BachelorDegree","Certificate","CertificateOfCompletion","Certification","CommunityService","Competency","Course","CoCurricular","Degree","Diploma","DoctoralDegree","Fieldwork","GeneralEducationDevelopment","JourneymanCertificate","LearningProgram","License","Membership","ProfessionalDoctorate","QualityAssuranceCredential","MasterCertificate","MasterDegree","MicroCredential","ResearchDoctorate","SecondarySchoolDiploma"]),HX=qX.or(we.string()),zX=we.object({id:we.string().optional(),narrative:we.string().optional()}).catchall(we.any()),$X=we.object({id:we.string(),type:we.string().array().nonempty(),endorsementComment:we.string().optional()}),GX=r1.extend({credentialSubject:$X,proof:Gf.or(Gf.array()).optional()}),KX=we.object({id:we.string(),"@language":we.string().optional(),version:we.string().optional()}),VX=we.enum(["GradePointAverage","LetterGrade","Percent","PerformanceLevel","PredictedScore","RawScore","Result","RubricCriterion","RubricCriterionLevel","RubricScore","ScaledScore","Status"]).or(we.string()),WX=we.object({id:we.string(),type:we.string().array().nonempty(),alignment:yv.array().optional(),description:we.string().optional(),level:we.string().optional(),name:we.string(),points:we.string().optional()}).catchall(we.any()),JX=we.object({id:we.string(),type:we.string().array().nonempty(),alignment:yv.array().optional(),allowedValue:we.string().array().optional(),name:we.string(),requiredLevel:we.string().optional(),requiredValue:we.string().optional(),resultType:VX,rubricCriterionLevel:WX.array().optional(),valueMax:we.string().optional(),valueMin:we.string().optional()}).catchall(we.any()),YX=we.object({id:we.string().optional(),type:we.string().array().nonempty(),alignment:yv.array().optional(),achievementType:HX.optional(),creator:t1.optional(),creditsAvailable:we.number().optional(),criteria:zX,description:we.string(),endorsement:GX.array().optional(),fieldOfStudy:we.string().optional(),humanCode:we.string().optional(),image:vv.optional(),"@language":we.string().optional(),name:we.string(),otherIdentifier:pP.array().optional(),related:KX.array().optional(),resultDescription:JX.array().optional(),specialization:we.string().optional(),tag:we.string().array().optional(),version:we.string().optional()}).catchall(we.any()),ZX=we.object({type:we.string(),hashed:we.boolean(),identityHash:we.string(),identityType:we.string(),salt:we.string().optional()}),XX=we.enum(["Completed","Enrolled","Failed","InProgress","OnHold","Withdrew"]),QX=we.object({type:we.string().array().nonempty(),achievedLevel:we.string().optional(),alignment:yv.array().optional(),resultDescription:we.string().optional(),status:XX.optional(),value:we.string().optional()}).catchall(we.any()),AM=we.object({id:we.string().optional(),type:we.string().array().nonempty(),activityEndDate:we.string().optional(),activityStartDate:we.string().optional(),creditsEarned:we.number().optional(),achievement:YX.optional(),identifier:ZX.array().optional(),image:vv.optional(),licenseNumber:we.string().optional(),narrative:we.string().optional(),result:QX.array().optional(),role:we.string().optional(),source:t1.optional(),term:we.string().optional()}).catchall(we.any()),eQ=we.object({id:we.string().optional(),type:we.string().array().nonempty(),narrative:we.string().optional(),name:we.string().optional(),description:we.string().optional(),genre:we.string().optional(),audience:we.string().optional()}).catchall(we.any()),tQ=r1.extend({name:we.string().optional(),description:we.string().optional(),image:vv.optional(),credentialSubject:AM.or(AM.array()),endorsement:r1.array().optional(),evidence:eQ.array().optional()}),Epe=tQ.extend({proof:Gf.or(Gf.array())}),EM=we.object({checks:we.string().array(),warnings:we.string().array(),errors:we.string().array()}),gP=we.enum(["Success","Failed","Error"]),$4=gP.enum,Cpe=we.object({check:we.string(),status:gP,message:we.string().optional(),details:we.string().optional()}),Spe=we.object({title:we.string().optional(),createdAt:we.string().optional(),issuer:t1.optional(),issuee:t1.optional(),credentialSubject:x5.optional()}),Up=we.object({id:we.string(),uri:we.string()}).catchall(we.any()),rQ=we.object({profileId:we.string().min(3).max(40),displayName:we.string().default(""),did:we.string(),email:we.string().optional(),image:we.string().optional(),isServiceProfile:we.boolean().default(!1).optional()}),Ipe=we.enum(["CONNECTED","PENDING_REQUEST_SENT","PENDING_REQUEST_RECEIVED","NOT_CONNECTED"]),kpe=we.object({uri:we.string(),to:we.string(),from:we.string(),sent:we.string().datetime(),received:we.string().datetime().optional()}),Tpe=we.object({uri:we.string(),name:we.string().optional(),type:we.string().optional(),category:we.string().optional()}),Mpe=we.object({to:rQ,from:we.string(),received:we.string()}),nQ=we.object({kty:we.string(),crv:we.string(),x:we.string(),y:we.string().optional(),n:we.string().optional(),d:we.string()}),iQ=we.object({alg:we.string(),iv:we.string(),tag:we.string(),epk:nQ.partial().optional(),kid:we.string().optional(),apv:we.string().optional(),apu:we.string().optional()}),sQ=we.object({header:iQ,encrypted_key:we.string()}),Rpe=we.object({protected:we.string(),iv:we.string(),ciphertext:we.string(),tag:we.string(),aad:we.string().optional(),recipients:sQ.array().optional()});function Kf(t){if(t===null||t===!0||t===!1)return NaN;var e=Number(t);return isNaN(e)?e:e<0?Math.ceil(e):Math.floor(e)}s(Kf,"toInteger");c(Kf,"toInteger");function Di(t,e){if(e.length<t)throw new TypeError(t+" argument"+(t>1?"s":"")+" required, but only "+e.length+" present")}s(Di,"requiredArgs");c(Di,"requiredArgs");function jp(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?jp=c(s(function(r){return typeof r},"_typeof3"),"_typeof"):jp=c(s(function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},"_typeof3"),"_typeof"),jp(t)}s(jp,"_typeof");c(jp,"_typeof");function Yo(t){Di(1,arguments);var e=Object.prototype.toString.call(t);return t instanceof Date||jp(t)==="object"&&e==="[object Date]"?new Date(t.getTime()):typeof t=="number"||e==="[object Number]"?new Date(t):((typeof t=="string"||e==="[object String]")&&typeof console<"u"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}s(Yo,"toDate");c(Yo,"toDate");function bP(t,e){Di(2,arguments);var r=Yo(t).getTime(),n=Kf(e);return new Date(r+n)}s(bP,"addMilliseconds");c(bP,"addMilliseconds");var oQ={};function B1(){return oQ}s(B1,"getDefaultOptions");c(B1,"getDefaultOptions");function vP(t){var e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return e.setUTCFullYear(t.getFullYear()),t.getTime()-e.getTime()}s(vP,"getTimezoneOffsetInMilliseconds");c(vP,"getTimezoneOffsetInMilliseconds");function qp(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?qp=c(s(function(r){return typeof r},"_typeof3"),"_typeof"):qp=c(s(function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},"_typeof3"),"_typeof"),qp(t)}s(qp,"_typeof2");c(qp,"_typeof");function yP(t){return Di(1,arguments),t instanceof Date||qp(t)==="object"&&Object.prototype.toString.call(t)==="[object Date]"}s(yP,"isDate");c(yP,"isDate");function xP(t){if(Di(1,arguments),!yP(t)&&typeof t!="number")return!1;var e=Yo(t);return!isNaN(Number(e))}s(xP,"isValid2");c(xP,"isValid");function wP(t,e){Di(2,arguments);var r=Kf(e);return bP(t,-r)}s(wP,"subMilliseconds");c(wP,"subMilliseconds");var aQ=864e5;function _P(t){Di(1,arguments);var e=Yo(t),r=e.getTime();e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0);var n=e.getTime(),i=r-n;return Math.floor(i/aQ)+1}s(_P,"getUTCDayOfYear");c(_P,"getUTCDayOfYear");function n1(t){Di(1,arguments);var e=1,r=Yo(t),n=r.getUTCDay(),i=(n<e?7:0)+n-e;return r.setUTCDate(r.getUTCDate()-i),r.setUTCHours(0,0,0,0),r}s(n1,"startOfUTCISOWeek");c(n1,"startOfUTCISOWeek");function dx(t){Di(1,arguments);var e=Yo(t),r=e.getUTCFullYear(),n=new Date(0);n.setUTCFullYear(r+1,0,4),n.setUTCHours(0,0,0,0);var i=n1(n),o=new Date(0);o.setUTCFullYear(r,0,4),o.setUTCHours(0,0,0,0);var a=n1(o);return e.getTime()>=i.getTime()?r+1:e.getTime()>=a.getTime()?r:r-1}s(dx,"getUTCISOWeekYear");c(dx,"getUTCISOWeekYear");function AP(t){Di(1,arguments);var e=dx(t),r=new Date(0);r.setUTCFullYear(e,0,4),r.setUTCHours(0,0,0,0);var n=n1(r);return n}s(AP,"startOfUTCISOWeekYear");c(AP,"startOfUTCISOWeekYear");var cQ=6048e5;function EP(t){Di(1,arguments);var e=Yo(t),r=n1(e).getTime()-AP(e).getTime();return Math.round(r/cQ)+1}s(EP,"getUTCISOWeek");c(EP,"getUTCISOWeek");function i1(t,e){var r,n,i,o,a,f,l,u;Di(1,arguments);var h=B1(),g=Kf((r=(n=(i=(o=e?.weekStartsOn)!==null&&o!==void 0?o:e==null||(a=e.locale)===null||a===void 0||(f=a.options)===null||f===void 0?void 0:f.weekStartsOn)!==null&&i!==void 0?i:h.weekStartsOn)!==null&&n!==void 0?n:(l=h.locale)===null||l===void 0||(u=l.options)===null||u===void 0?void 0:u.weekStartsOn)!==null&&r!==void 0?r:0);if(!(g>=0&&g<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var x=Yo(t),_=x.getUTCDay(),E=(_<g?7:0)+_-g;return x.setUTCDate(x.getUTCDate()-E),x.setUTCHours(0,0,0,0),x}s(i1,"startOfUTCWeek");c(i1,"startOfUTCWeek");function hx(t,e){var r,n,i,o,a,f,l,u;Di(1,arguments);var h=Yo(t),g=h.getUTCFullYear(),x=B1(),_=Kf((r=(n=(i=(o=e?.firstWeekContainsDate)!==null&&o!==void 0?o:e==null||(a=e.locale)===null||a===void 0||(f=a.options)===null||f===void 0?void 0:f.firstWeekContainsDate)!==null&&i!==void 0?i:x.firstWeekContainsDate)!==null&&n!==void 0?n:(l=x.locale)===null||l===void 0||(u=l.options)===null||u===void 0?void 0:u.firstWeekContainsDate)!==null&&r!==void 0?r:1);if(!(_>=1&&_<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var E=new Date(0);E.setUTCFullYear(g+1,0,_),E.setUTCHours(0,0,0,0);var T=i1(E,e),B=new Date(0);B.setUTCFullYear(g,0,_),B.setUTCHours(0,0,0,0);var F=i1(B,e);return h.getTime()>=T.getTime()?g+1:h.getTime()>=F.getTime()?g:g-1}s(hx,"getUTCWeekYear");c(hx,"getUTCWeekYear");function CP(t,e){var r,n,i,o,a,f,l,u;Di(1,arguments);var h=B1(),g=Kf((r=(n=(i=(o=e?.firstWeekContainsDate)!==null&&o!==void 0?o:e==null||(a=e.locale)===null||a===void 0||(f=a.options)===null||f===void 0?void 0:f.firstWeekContainsDate)!==null&&i!==void 0?i:h.firstWeekContainsDate)!==null&&n!==void 0?n:(l=h.locale)===null||l===void 0||(u=l.options)===null||u===void 0?void 0:u.firstWeekContainsDate)!==null&&r!==void 0?r:1),x=hx(t,e),_=new Date(0);_.setUTCFullYear(x,0,g),_.setUTCHours(0,0,0,0);var E=i1(_,e);return E}s(CP,"startOfUTCWeekYear");c(CP,"startOfUTCWeekYear");var fQ=6048e5;function SP(t,e){Di(1,arguments);var r=Yo(t),n=i1(r,e).getTime()-CP(r,e).getTime();return Math.round(n/fQ)+1}s(SP,"getUTCWeek");c(SP,"getUTCWeek");function Br(t,e){for(var r=t<0?"-":"",n=Math.abs(t).toString();n.length<e;)n="0"+n;return r+n}s(Br,"addLeadingZeros");c(Br,"addLeadingZeros");var lQ={y:c(s(function(e,r){var n=e.getUTCFullYear(),i=n>0?n:1-n;return Br(r==="yy"?i%100:i,r.length)},"y"),"y"),M:c(s(function(e,r){var n=e.getUTCMonth();return r==="M"?String(n+1):Br(n+1,2)},"M"),"M"),d:c(s(function(e,r){return Br(e.getUTCDate(),r.length)},"d"),"d"),a:c(s(function(e,r){var n=e.getUTCHours()/12>=1?"pm":"am";switch(r){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},"a"),"a"),h:c(s(function(e,r){return Br(e.getUTCHours()%12||12,r.length)},"h"),"h"),H:c(s(function(e,r){return Br(e.getUTCHours(),r.length)},"H"),"H"),m:c(s(function(e,r){return Br(e.getUTCMinutes(),r.length)},"m"),"m"),s:c(s(function(e,r){return Br(e.getUTCSeconds(),r.length)},"s"),"s"),S:c(s(function(e,r){var n=r.length,i=e.getUTCMilliseconds(),o=Math.floor(i*Math.pow(10,n-3));return Br(o,r.length)},"S"),"S")},Bf=lQ,Rd={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},uQ={G:c(s(function(e,r,n){var i=e.getUTCFullYear()>0?1:0;switch(r){case"G":case"GG":case"GGG":return n.era(i,{width:"abbreviated"});case"GGGGG":return n.era(i,{width:"narrow"});case"GGGG":default:return n.era(i,{width:"wide"})}},"G"),"G"),y:c(s(function(e,r,n){if(r==="yo"){var i=e.getUTCFullYear(),o=i>0?i:1-i;return n.ordinalNumber(o,{unit:"year"})}return Bf.y(e,r)},"y2"),"y"),Y:c(s(function(e,r,n,i){var o=hx(e,i),a=o>0?o:1-o;if(r==="YY"){var f=a%100;return Br(f,2)}return r==="Yo"?n.ordinalNumber(a,{unit:"year"}):Br(a,r.length)},"Y"),"Y"),R:c(s(function(e,r){var n=dx(e);return Br(n,r.length)},"R"),"R"),u:c(s(function(e,r){var n=e.getUTCFullYear();return Br(n,r.length)},"u"),"u"),Q:c(s(function(e,r,n){var i=Math.ceil((e.getUTCMonth()+1)/3);switch(r){case"Q":return String(i);case"QQ":return Br(i,2);case"Qo":return n.ordinalNumber(i,{unit:"quarter"});case"QQQ":return n.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(i,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(i,{width:"wide",context:"formatting"})}},"Q"),"Q"),q:c(s(function(e,r,n){var i=Math.ceil((e.getUTCMonth()+1)/3);switch(r){case"q":return String(i);case"qq":return Br(i,2);case"qo":return n.ordinalNumber(i,{unit:"quarter"});case"qqq":return n.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(i,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(i,{width:"wide",context:"standalone"})}},"q"),"q"),M:c(s(function(e,r,n){var i=e.getUTCMonth();switch(r){case"M":case"MM":return Bf.M(e,r);case"Mo":return n.ordinalNumber(i+1,{unit:"month"});case"MMM":return n.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(i,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(i,{width:"wide",context:"formatting"})}},"M2"),"M"),L:c(s(function(e,r,n){var i=e.getUTCMonth();switch(r){case"L":return String(i+1);case"LL":return Br(i+1,2);case"Lo":return n.ordinalNumber(i+1,{unit:"month"});case"LLL":return n.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(i,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(i,{width:"wide",context:"standalone"})}},"L"),"L"),w:c(s(function(e,r,n,i){var o=SP(e,i);return r==="wo"?n.ordinalNumber(o,{unit:"week"}):Br(o,r.length)},"w"),"w"),I:c(s(function(e,r,n){var i=EP(e);return r==="Io"?n.ordinalNumber(i,{unit:"week"}):Br(i,r.length)},"I"),"I"),d:c(s(function(e,r,n){return r==="do"?n.ordinalNumber(e.getUTCDate(),{unit:"date"}):Bf.d(e,r)},"d2"),"d"),D:c(s(function(e,r,n){var i=_P(e);return r==="Do"?n.ordinalNumber(i,{unit:"dayOfYear"}):Br(i,r.length)},"D"),"D"),E:c(s(function(e,r,n){var i=e.getUTCDay();switch(r){case"E":case"EE":case"EEE":return n.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(i,{width:"short",context:"formatting"});case"EEEE":default:return n.day(i,{width:"wide",context:"formatting"})}},"E"),"E"),e:c(s(function(e,r,n,i){var o=e.getUTCDay(),a=(o-i.weekStartsOn+8)%7||7;switch(r){case"e":return String(a);case"ee":return Br(a,2);case"eo":return n.ordinalNumber(a,{unit:"day"});case"eee":return n.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(o,{width:"short",context:"formatting"});case"eeee":default:return n.day(o,{width:"wide",context:"formatting"})}},"e"),"e"),c:c(s(function(e,r,n,i){var o=e.getUTCDay(),a=(o-i.weekStartsOn+8)%7||7;switch(r){case"c":return String(a);case"cc":return Br(a,r.length);case"co":return n.ordinalNumber(a,{unit:"day"});case"ccc":return n.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(o,{width:"narrow",context:"standalone"});case"cccccc":return n.day(o,{width:"short",context:"standalone"});case"cccc":default:return n.day(o,{width:"wide",context:"standalone"})}},"c"),"c"),i:c(s(function(e,r,n){var i=e.getUTCDay(),o=i===0?7:i;switch(r){case"i":return String(o);case"ii":return Br(o,r.length);case"io":return n.ordinalNumber(o,{unit:"day"});case"iii":return n.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(i,{width:"short",context:"formatting"});case"iiii":default:return n.day(i,{width:"wide",context:"formatting"})}},"i"),"i"),a:c(s(function(e,r,n){var i=e.getUTCHours(),o=i/12>=1?"pm":"am";switch(r){case"a":case"aa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},"a2"),"a"),b:c(s(function(e,r,n){var i=e.getUTCHours(),o;switch(i===12?o=Rd.noon:i===0?o=Rd.midnight:o=i/12>=1?"pm":"am",r){case"b":case"bb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},"b"),"b"),B:c(s(function(e,r,n){var i=e.getUTCHours(),o;switch(i>=17?o=Rd.evening:i>=12?o=Rd.afternoon:i>=4?o=Rd.morning:o=Rd.night,r){case"B":case"BB":case"BBB":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},"B"),"B"),h:c(s(function(e,r,n){if(r==="ho"){var i=e.getUTCHours()%12;return i===0&&(i=12),n.ordinalNumber(i,{unit:"hour"})}return Bf.h(e,r)},"h2"),"h"),H:c(s(function(e,r,n){return r==="Ho"?n.ordinalNumber(e.getUTCHours(),{unit:"hour"}):Bf.H(e,r)},"H2"),"H"),K:c(s(function(e,r,n){var i=e.getUTCHours()%12;return r==="Ko"?n.ordinalNumber(i,{unit:"hour"}):Br(i,r.length)},"K"),"K"),k:c(s(function(e,r,n){var i=e.getUTCHours();return i===0&&(i=24),r==="ko"?n.ordinalNumber(i,{unit:"hour"}):Br(i,r.length)},"k"),"k"),m:c(s(function(e,r,n){return r==="mo"?n.ordinalNumber(e.getUTCMinutes(),{unit:"minute"}):Bf.m(e,r)},"m2"),"m"),s:c(s(function(e,r,n){return r==="so"?n.ordinalNumber(e.getUTCSeconds(),{unit:"second"}):Bf.s(e,r)},"s2"),"s"),S:c(s(function(e,r){return Bf.S(e,r)},"S2"),"S"),X:c(s(function(e,r,n,i){var o=i._originalDate||e,a=o.getTimezoneOffset();if(a===0)return"Z";switch(r){case"X":return _5(a);case"XXXX":case"XX":return Of(a);case"XXXXX":case"XXX":default:return Of(a,":")}},"X"),"X"),x:c(s(function(e,r,n,i){var o=i._originalDate||e,a=o.getTimezoneOffset();switch(r){case"x":return _5(a);case"xxxx":case"xx":return Of(a);case"xxxxx":case"xxx":default:return Of(a,":")}},"x"),"x"),O:c(s(function(e,r,n,i){var o=i._originalDate||e,a=o.getTimezoneOffset();switch(r){case"O":case"OO":case"OOO":return"GMT"+w5(a,":");case"OOOO":default:return"GMT"+Of(a,":")}},"O"),"O"),z:c(s(function(e,r,n,i){var o=i._originalDate||e,a=o.getTimezoneOffset();switch(r){case"z":case"zz":case"zzz":return"GMT"+w5(a,":");case"zzzz":default:return"GMT"+Of(a,":")}},"z"),"z"),t:c(s(function(e,r,n,i){var o=i._originalDate||e,a=Math.floor(o.getTime()/1e3);return Br(a,r.length)},"t"),"t"),T:c(s(function(e,r,n,i){var o=i._originalDate||e,a=o.getTime();return Br(a,r.length)},"T"),"T")};function w5(t,e){var r=t>0?"-":"+",n=Math.abs(t),i=Math.floor(n/60),o=n%60;if(o===0)return r+String(i);var a=e||"";return r+String(i)+a+Br(o,2)}s(w5,"formatTimezoneShort");c(w5,"formatTimezoneShort");function _5(t,e){if(t%60===0){var r=t>0?"-":"+";return r+Br(Math.abs(t)/60,2)}return Of(t,e)}s(_5,"formatTimezoneWithOptionalMinutes");c(_5,"formatTimezoneWithOptionalMinutes");function Of(t,e){var r=e||"",n=t>0?"-":"+",i=Math.abs(t),o=Br(Math.floor(i/60),2),a=Br(i%60,2);return n+o+r+a}s(Of,"formatTimezone");c(Of,"formatTimezone");var dQ=uQ,CM=c(s(function(e,r){switch(e){case"P":return r.date({width:"short"});case"PP":return r.date({width:"medium"});case"PPP":return r.date({width:"long"});case"PPPP":default:return r.date({width:"full"})}},"dateLongFormatter2"),"dateLongFormatter"),IP=c(s(function(e,r){switch(e){case"p":return r.time({width:"short"});case"pp":return r.time({width:"medium"});case"ppp":return r.time({width:"long"});case"pppp":default:return r.time({width:"full"})}},"timeLongFormatter2"),"timeLongFormatter"),hQ=c(s(function(e,r){var n=e.match(/(P+)(p+)?/)||[],i=n[1],o=n[2];if(!o)return CM(e,r);var a;switch(i){case"P":a=r.dateTime({width:"short"});break;case"PP":a=r.dateTime({width:"medium"});break;case"PPP":a=r.dateTime({width:"long"});break;case"PPPP":default:a=r.dateTime({width:"full"});break}return a.replace("{{date}}",CM(i,r)).replace("{{time}}",IP(o,r))},"dateTimeLongFormatter2"),"dateTimeLongFormatter"),pQ={p:IP,P:hQ},mQ=pQ,gQ=["D","DD"],bQ=["YY","YYYY"];function kP(t){return gQ.indexOf(t)!==-1}s(kP,"isProtectedDayOfYearToken");c(kP,"isProtectedDayOfYearToken");function TP(t){return bQ.indexOf(t)!==-1}s(TP,"isProtectedWeekYearToken");c(TP,"isProtectedWeekYearToken");function A5(t,e,r){if(t==="YYYY")throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(e,"`) for formatting years to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(t==="YY")throw new RangeError("Use `yy` instead of `YY` (in `".concat(e,"`) for formatting years to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(t==="D")throw new RangeError("Use `d` instead of `D` (in `".concat(e,"`) for formatting days of the month to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(t==="DD")throw new RangeError("Use `dd` instead of `DD` (in `".concat(e,"`) for formatting days of the month to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"))}s(A5,"throwProtectedError");c(A5,"throwProtectedError");var vQ={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},yQ=c(s(function(e,r,n){var i,o=vQ[e];return typeof o=="string"?i=o:r===1?i=o.one:i=o.other.replace("{{count}}",r.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+i:i+" ago":i},"formatDistance2"),"formatDistance"),xQ=yQ;function jb(t){return function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=e.width?String(e.width):t.defaultWidth,n=t.formats[r]||t.formats[t.defaultWidth];return n}}s(jb,"buildFormatLongFn");c(jb,"buildFormatLongFn");var wQ={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},_Q={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},AQ={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},EQ={date:jb({formats:wQ,defaultWidth:"full"}),time:jb({formats:_Q,defaultWidth:"full"}),dateTime:jb({formats:AQ,defaultWidth:"full"})},CQ=EQ,SQ={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},IQ=c(s(function(e,r,n,i){return SQ[e]},"formatRelative2"),"formatRelative"),kQ=IQ;function Od(t){return function(e,r){var n=r!=null&&r.context?String(r.context):"standalone",i;if(n==="formatting"&&t.formattingValues){var o=t.defaultFormattingWidth||t.defaultWidth,a=r!=null&&r.width?String(r.width):o;i=t.formattingValues[a]||t.formattingValues[o]}else{var f=t.defaultWidth,l=r!=null&&r.width?String(r.width):t.defaultWidth;i=t.values[l]||t.values[f]}var u=t.argumentCallback?t.argumentCallback(e):e;return i[u]}}s(Od,"buildLocalizeFn");c(Od,"buildLocalizeFn");var TQ={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},MQ={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},RQ={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},BQ={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},DQ={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},PQ={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},OQ=c(s(function(e,r){var n=Number(e),i=n%100;if(i>20||i<10)switch(i%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},"ordinalNumber2"),"ordinalNumber"),FQ={ordinalNumber:OQ,era:Od({values:TQ,defaultWidth:"wide"}),quarter:Od({values:MQ,defaultWidth:"wide",argumentCallback:c(s(function(e){return e-1},"argumentCallback"),"argumentCallback")}),month:Od({values:RQ,defaultWidth:"wide"}),day:Od({values:BQ,defaultWidth:"wide"}),dayPeriod:Od({values:DQ,defaultWidth:"wide",formattingValues:PQ,defaultFormattingWidth:"wide"})},NQ=FQ;function Fd(t){return function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=r.width,i=n&&t.matchPatterns[n]||t.matchPatterns[t.defaultMatchWidth],o=e.match(i);if(!o)return null;var a=o[0],f=n&&t.parsePatterns[n]||t.parsePatterns[t.defaultParseWidth],l=Array.isArray(f)?RP(f,function(g){return g.test(a)}):MP(f,function(g){return g.test(a)}),u;u=t.valueCallback?t.valueCallback(l):l,u=r.valueCallback?r.valueCallback(u):u;var h=e.slice(a.length);return{value:u,rest:h}}}s(Fd,"buildMatchFn");c(Fd,"buildMatchFn");function MP(t,e){for(var r in t)if(t.hasOwnProperty(r)&&e(t[r]))return r}s(MP,"findKey");c(MP,"findKey");function RP(t,e){for(var r=0;r<t.length;r++)if(e(t[r]))return r}s(RP,"findIndex");c(RP,"findIndex");function BP(t){return function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=e.match(t.matchPattern);if(!n)return null;var i=n[0],o=e.match(t.parsePattern);if(!o)return null;var a=t.valueCallback?t.valueCallback(o[0]):o[0];a=r.valueCallback?r.valueCallback(a):a;var f=e.slice(i.length);return{value:a,rest:f}}}s(BP,"buildMatchPatternFn");c(BP,"buildMatchPatternFn");var LQ=/^(\d+)(th|st|nd|rd)?/i,UQ=/\d+/i,jQ={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},qQ={any:[/^b/i,/^(a|c)/i]},HQ={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},zQ={any:[/1/i,/2/i,/3/i,/4/i]},$Q={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},GQ={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},KQ={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},VQ={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},WQ={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},JQ={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},YQ={ordinalNumber:BP({matchPattern:LQ,parsePattern:UQ,valueCallback:c(s(function(e){return parseInt(e,10)},"valueCallback"),"valueCallback")}),era:Fd({matchPatterns:jQ,defaultMatchWidth:"wide",parsePatterns:qQ,defaultParseWidth:"any"}),quarter:Fd({matchPatterns:HQ,defaultMatchWidth:"wide",parsePatterns:zQ,defaultParseWidth:"any",valueCallback:c(s(function(e){return e+1},"valueCallback2"),"valueCallback")}),month:Fd({matchPatterns:$Q,defaultMatchWidth:"wide",parsePatterns:GQ,defaultParseWidth:"any"}),day:Fd({matchPatterns:KQ,defaultMatchWidth:"wide",parsePatterns:VQ,defaultParseWidth:"any"}),dayPeriod:Fd({matchPatterns:WQ,defaultMatchWidth:"any",parsePatterns:JQ,defaultParseWidth:"any"})},ZQ=YQ,XQ={code:"en-US",formatDistance:xQ,formatLong:CQ,formatRelative:kQ,localize:NQ,match:ZQ,options:{weekStartsOn:0,firstWeekContainsDate:1}},QQ=XQ,eee=QQ,tee=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,ree=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,nee=/^'([^]*?)'?$/,iee=/''/g,see=/[a-zA-Z]/;function px(t,e,r){var n,i,o,a,f,l,u,h,g,x,_,E,T,B,F,H,U,q;Di(2,arguments);var K=String(e),W=B1(),N=(n=(i=r?.locale)!==null&&i!==void 0?i:W.locale)!==null&&n!==void 0?n:eee,G=Kf((o=(a=(f=(l=r?.firstWeekContainsDate)!==null&&l!==void 0?l:r==null||(u=r.locale)===null||u===void 0||(h=u.options)===null||h===void 0?void 0:h.firstWeekContainsDate)!==null&&f!==void 0?f:W.firstWeekContainsDate)!==null&&a!==void 0?a:(g=W.locale)===null||g===void 0||(x=g.options)===null||x===void 0?void 0:x.firstWeekContainsDate)!==null&&o!==void 0?o:1);if(!(G>=1&&G<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var ce=Kf((_=(E=(T=(B=r?.weekStartsOn)!==null&&B!==void 0?B:r==null||(F=r.locale)===null||F===void 0||(H=F.options)===null||H===void 0?void 0:H.weekStartsOn)!==null&&T!==void 0?T:W.weekStartsOn)!==null&&E!==void 0?E:(U=W.locale)===null||U===void 0||(q=U.options)===null||q===void 0?void 0:q.weekStartsOn)!==null&&_!==void 0?_:0);if(!(ce>=0&&ce<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!N.localize)throw new RangeError("locale must contain localize property");if(!N.formatLong)throw new RangeError("locale must contain formatLong property");var re=Yo(t);if(!xP(re))throw new RangeError("Invalid time value");var ae=vP(re),J=wP(re,ae),S={firstWeekContainsDate:G,weekStartsOn:ce,locale:N,_originalDate:re},m=K.match(ree).map(function(b){var p=b[0];if(p==="p"||p==="P"){var v=mQ[p];return v(b,N.formatLong)}return b}).join("").match(tee).map(function(b){if(b==="''")return"'";var p=b[0];if(p==="'")return DP(b);var v=dQ[p];if(v)return!(r!=null&&r.useAdditionalWeekYearTokens)&&TP(b)&&A5(b,e,String(t)),!(r!=null&&r.useAdditionalDayOfYearTokens)&&kP(b)&&A5(b,e,String(t)),v(J,b,N.localize,S);if(p.match(see))throw new RangeError("Format string contains an unescaped latin alphabet character `"+p+"`");return b}).join("");return m}s(px,"format");c(px,"format");function DP(t){var e=t.match(nee);return e?e[1].replace(iee,"'"):t}s(DP,"cleanEscapedString");c(DP,"cleanEscapedString");var oee=c((t,e)=>t.split(" error")[0]||t,"transformErrorCheck"),aee=c((t,e)=>t.startsWith("expiration")?e.expirationDate?`Invalid \u2022 Expired ${px(new Date(e.expirationDate),"dd MMM yyyy").toUpperCase()}`:"Invalid \u2022 Expired":t,"transformErrorMessage"),cee=c((t,e)=>({proof:"Valid",expiration:e.expirationDate?`Valid \u2022 Expires ${px(new Date(e.expirationDate),"dd MMM yyyy").toUpperCase()}`:"Valid \u2022 Does Not Expire"})[t]||t,"transformCheckMessage"),fee=c(t=>async(e,r,n,i=!1)=>{let o=await t.invoke.verifyCredential(r,n);if(!i)return o;let a=[];return o.errors.forEach(f=>{a.push({status:$4.Failed,check:oee(f,r),details:aee(f,r)})}),o.warnings.forEach(f=>{a.push({status:$4.Error,check:"hmm",message:f})}),o.checks.forEach(f=>{a.push({status:$4.Success,check:f,message:cee(f,r)})}),a},"verifyCredential"),mx=c(t=>({name:"LearnCard",displayName:"LearnCard",description:"Adds opinionated logic to a LearnCard",methods:{verifyCredential:fee(t)}}),"getLearnCardPlugin"),lee=c(async({didkit:t,debug:e}={})=>{let r=await(await k1({debug:e})).addPlugin(await TD(t)),o=await(await(await r.addPlugin(ex(r))).addPlugin(tx())).addPlugin(await fx());return o.addPlugin(mx(o))},"emptyLearnCard");function gx(t){var e=0,r=t.length,n=[];if(r%2)throw new Error("invalid hex:"+t);for(;e<r;e+=2)n.push(parseInt(t.substr(e,2),16));return new Uint8Array(n)}s(gx,"toUint8Array");c(gx,"toUint8Array");var uee=Object.defineProperty,dee=c((t,e)=>uee(t,"name",{value:e,configurable:!0}),"__name"),hee=dee(t=>/^[0-9a-f]+$/i.test(t),"isHex"),pee=["key","tz","pkh:tz","pkh:tezos","pkh:sol","pkh:solana"],mee=["key","tz","ethr","pkh:tz","pkh:tezos","pkh:eth","pkh:celo","pkh:poly","pkh:btc","pkh:doge","pkh:eip155","pkh:bip122"],gee=c(t=>{if(pee.includes(t))return"ed25519";if(mee.includes(t)||t.startsWith("pkh:eip155:")||t.startsWith("pkh:bip122:"))return"secp256k1";throw new Error("Unspported Did Method")},"getAlgorithmForDidMethod"),bee=c(async(t,e,r)=>{if(e.length===0)throw new Error("Please don't use an empty string for a key!");if(!hee(e))throw new Error("Key must be a hexadecimal string!");if(e.length>64)throw new Error("Key must be less than 64 characters");e.length<64&&(console.warn("Warning: A LearnCard has been initialized with a seed that is less than 32 bytes, and will be padded with zeroes"),console.warn("Please instantiate LearnCards using 32 bytes that have been randomly generated in a cryptographically secure fashion!"),console.warn("See https://app.gitbook.com/o/6uDv1QDlxaaZC7i8EaGb/s/FXvEJ9j3Vf3FW5Nc557n/learn-card-packages/learncard-core/instantiation#key-generation for details"));let n=e.padStart(64,"0"),i=gx(n),o={},a={ed25519:t.invoke.generateEd25519KeyFromBytes(i),secp256k1:t.invoke.generateSecp256k1KeyFromBytes(i)},f=c((u=r)=>{if(!o[u]){let h=gee(u);o[u]=t.invoke.keyToDid(u,a[h])}return o[u]},"did"),l=c((u="ed25519")=>{if(!a[u])throw new Error("Unsupported algorithm");return a[u]},"keypair");return{name:"DID Key",displayName:"DID Key",description:"Generates dids and JWKs using 32 Secure Random Bytes of Entropy",id:{did:(u,h)=>f(h),keypair:(u,h)=>l(h)},methods:{getSubjectDid:(u,h=r)=>f(h),getSubjectKeypair:(u,h="ed25519")=>l(h),getKey:()=>n}}},"getDidKeyPlugin"),vee=c(t=>async(e,r,n={})=>{let i=e.id.keypair();if(!i)throw new Error("Cannot issue credential: Could not get subject keypair");let a={verificationMethod:await e.invoke.didToVerificationMethod(typeof r.issuer=="string"?r.issuer:r.issuer.id),proofPurpose:"assertionMethod",type:"Ed25519Signature2020",...n};return t.invoke.issueCredential(r,a,i)},"issueCredential"),yee=c(t=>async(e,r,n={})=>t.invoke.verifyCredential(r,n),"verifyCredential"),xee=c(t=>async(e,r,n={})=>{let i=e.id.keypair();if(!i)throw new Error("Cannot issue credential: Could not get subject keypair");let a={verificationMethod:await e.invoke.didToVerificationMethod(e.id.did()),...n.proofFormat==="jwt"?{}:{proofPurpose:"assertionMethod"},...n.proofFormat==="jwt"?{}:{type:"Ed25519Signature2020"},...n};return t.invoke.issuePresentation(r,a,i)},"issuePresentation"),wee=c(t=>async(e,r,n={})=>t.invoke.verifyPresentation(r,n),"verifyPresentation"),_ee=c(t=>({name:"VC",displayName:"VC",description:"Handles the infrastructure needed to issue and verify credentials and presentations",methods:{issueCredential:vee(t),verifyCredential:yee(t),issuePresentation:xee(t),verifyPresentation:wee(t),getTestVc:(e,r="did:example:d23dd687a7dc6787646f2eb98d0")=>{let n=e.id.did();return{"@context":["https://www.w3.org/2018/credentials/v1"],id:"http://example.org/credentials/3731",type:["VerifiableCredential"],issuer:n,issuanceDate:"2020-08-19T21:41:50Z",credentialSubject:{id:r}}},getTestVp:async(e,r)=>{let n=r||await e.invoke.issueCredential(e.invoke.getTestVc()),i=e.id.did();return{"@context":["https://www.w3.org/2018/credentials/v1"],type:["VerifiablePresentation"],holder:i,verifiableCredential:n}},getDidAuthVp:async(e,r={})=>{let n=e.invoke.getSubjectDid("key"),i={"@context":["https://www.w3.org/2018/credentials/v1"],type:["VerifiablePresentation"],holder:n};return e.invoke.issuePresentation(i,{proofPurpose:"authentication",...r})}}}),"getVCPlugin"),Aee={name:"VC Resolution",displayName:"VC Resolution",description:"[Deprecated] Allows for a fallback mechanism of resolving credentials",methods:{resolveCredential:async(t,e)=>{throw new Error(`No Credential Resolution Plugins found that can resolve ${e}`)}}},Eee=wr(UJ());function PP(t,e){try{var r=t()}catch(n){return e(n)}return r&&r.then?r.then(void 0,e):r}s(PP,"_catch");c(PP,"_catch");function OP(){let t=new Map;return function(e,r){try{let n=s(function(a){if(i)return a;let f=t.get(e.didUrl);return f!==void 0?f:Promise.resolve(r()).then(function(l){var u;return((u=l.didResolutionMetadata)==null?void 0:u.error)!=="notFound"&&t.set(e.didUrl,l),l})},"_temp2");c(n,"_temp2");let i,o=function(){if(e.params&&e.params["no-cache"]==="true")return Promise.resolve(r()).then(function(a){return i=1,a})}();return Promise.resolve(o&&o.then?o.then(n):n(o))}catch(n){return Promise.reject(n)}}}s(OP,"inMemoryCache");c(OP,"inMemoryCache");function FP(t,e){return e()}s(FP,"noCache");c(FP,"noCache");var Cee="(?:%[0-9a-fA-F]{2})",SM=`(?:[a-zA-Z0-9._-]|${Cee})`,See="([a-z0-9]+)",Iee=`((?:${SM}*:)*(${SM}+))`,IM="[a-zA-Z0-9_.:%-]",kee=`;${IM}+=${IM}*`,Tee=`((${kee})*)`,Mee="(/[^#?]*)?",Ree="([?][^#]*)?",Bee="(#.*)?",Dee=new RegExp(`^did:${See}:${Iee}${Tee}${Mee}${Ree}${Bee}$`);function bx(t){if(t===""||!t)return null;let e=t.match(Dee);if(e){let r={did:`did:${e[1]}:${e[2]}`,method:e[1],id:e[2],didUrl:t};if(e[4]){let n=e[4].slice(1).split(";");r.params={};for(let i of n){let o=i.split("=");r.params[o[0]]=o[1]}}return e[6]&&(r.path=e[6]),e[7]&&(r.query=e[7].slice(1)),e[8]&&(r.fragment=e[8].slice(1)),r}return null}s(bx,"parse");c(bx,"parse");var g2={didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};function NP(t){return function(e,r,n){try{return Promise.resolve(PP(function(){return Promise.resolve(t(e,r,n)).then(function(i){return{...g2,didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:i}})},function(i){return{...g2,didResolutionMetadata:{error:"notFound",message:i.toString()}}}))}catch(i){return Promise.reject(i)}}}s(NP,"wrapLegacyResolver");c(NP,"wrapLegacyResolver");var LP=s(class{constructor(t={},e={}){this.registry=void 0,this.cache=void 0,this.registry=t,this.cache=e.cache===!0?OP():e.cache||FP,e.legacyResolvers&&Object.keys(e.legacyResolvers).map(r=>{this.registry[r]||(this.registry[r]=NP(e.legacyResolvers[r]))})}resolve(t,e={}){try{let r=this,n=bx(t);if(n===null)return Promise.resolve({...g2,didResolutionMetadata:{error:"invalidDid"}});let i=r.registry[n.method];return i?Promise.resolve(r.cache(n,()=>i(n.did,n,r,e))):Promise.resolve({...g2,didResolutionMetadata:{error:"unsupportedDidMethod"}})}catch(r){return Promise.reject(r)}}},"Resolver");c(LP,"Resolver");JR();V8();E1();q8();av();zB();var UP=wr(tY()),Pee=wr(VB()),jP=wr(xY()),qP=wr(J8()),Oee=wr(CY()),E5=wr(SY()),HP=wr(MY()),zP=wr(ph());function Fs(t){return en(t,"base64url")}s(Fs,"bytesToBase64url");c(Fs,"bytesToBase64url");function Wi(t){let e=t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");return Zr(e,"base64url")}s(Wi,"base64ToBytes");c(Wi,"base64ToBytes");function xv(t){return Zr(t,"base58btc")}s(xv,"base58ToBytes");c(xv,"base58ToBytes");function b2(t){let e=t.startsWith("0x")?t.substring(2):t;return Zr(e.toLowerCase(),"base16")}s(b2,"hexToBytes");c(b2,"hexToBytes");function v2(t){return Fs(Zr(t))}s(v2,"encodeBase64url");c(v2,"encodeBase64url");function vx(t){return en(Wi(t))}s(vx,"decodeBase64url");c(vx,"decodeBase64url");function Vf(t){return en(t,"base16")}s(Vf,"bytesToHex");c(Vf,"bytesToHex");function yx(t){return Zr(t)}s(yx,"stringToBytes");c(yx,"stringToBytes");function $P({r:t,s:e,recoveryParam:r},n){let i=new Uint8Array(n?65:64);if(i.set(Zr(t,"base16"),0),i.set(Zr(e,"base16"),32),n){if(typeof r>"u")throw new Error("Signer did not return a recoveryParam");i[64]=r}return Fs(i)}s($P,"toJose");c($P,"toJose");function GP(t){let e=Wi(t);if(e.length<64||e.length>65)throw new TypeError(`Wrong size for signature. Expected 64 or 65 bytes, but got ${e.length}`);let r=Vf(e.slice(0,32)),n=Vf(e.slice(32,64)),i=e.length===65?e[64]:void 0;return{r,s:n,recoveryParam:i}}s(GP,"fromJose");c(GP,"fromJose");function xx(t,e){return qf([Wi(t),Wi(e)])}s(xx,"toSealed");c(xx,"toSealed");var Fee=/^(0x)?([a-fA-F0-9]{64}|[a-fA-F0-9]{128})$/,Nee=/^([1-9A-HJ-NP-Za-km-z]{44}|[1-9A-HJ-NP-Za-km-z]{88})$/,Lee=/^([0-9a-zA-Z=\-_+/]{43}|[0-9a-zA-Z=\-_+/]{86})(={0,2})$/;function KP(t){if(typeof t=="string"){if(Fee.test(t))return b2(t);if(Nee.test(t))return xv(t);if(Lee.test(t))return Wi(t);throw TypeError("bad_key: Invalid private key format")}else{if(t instanceof Uint8Array)return t;throw TypeError("bad_key: Invalid private key format")}}s(KP,"parseKey");c(KP,"parseKey");function wx(t){let e=typeof t=="string"?Zr(t):t;return(0,UP.hash)(e)}s(wx,"sha2562");c(wx,"sha256");function VP(t){return new Uint8Array(Pee.keccak_256.arrayBuffer(t))}s(VP,"keccak");c(VP,"keccak");function WP(t){let e=Zr(t.slice(2),"base16");return`0x${en(VP(e).slice(-20),"base16")}`}s(WP,"toEthereumAddress");c(WP,"toEthereumAddress");function y2(t,e=new Uint8Array(4)){let r=Zr(t.toString(),"base10");return e.set(r,4-r.length),e}s(y2,"writeUint32BE");c(y2,"writeUint32BE");var G4=c(t=>qf([y2(t.length),t]),"lengthAndInput");function _x(t,e,r,n,i){if(e!==256)throw new Error(`Unsupported key length: ${e}`);let o=qf([G4(Zr(r)),G4(typeof n>"u"?new Uint8Array(0):n),G4(typeof i>"u"?new Uint8Array(0):i),y2(e)]),a=1;return(0,UP.hash)(qf([y2(a),t,o]))}s(_x,"concatKDF");c(_x,"concatKDF");var Bpe=new jP.ec("secp256k1");function JP(t){let e=KP(t);if(e.length!==64)throw new Error(`bad_key: Invalid private key format. Expecting 64 bytes, but got ${e.length}`);return function(r){try{let n=typeof r=="string"?yx(r):r,i=(0,qP.sign)(e,n);return Promise.resolve(Fs(i))}catch(n){return Promise.reject(n)}}}s(JP,"EdDSASigner");c(JP,"EdDSASigner");function Ax(t){return typeof t=="object"&&"r"in t&&"s"in t}s(Ax,"instanceOfEcdsaSignature");c(Ax,"instanceOfEcdsaSignature");function C5(t){return c(s(function(r,n){try{return Promise.resolve(n(r)).then(function(i){if(Ax(i))return $P(i,t);if(t&&typeof GP(i).recoveryParam>"u")throw new Error("not_supported: ES256K-R not supported when signer doesn't provide a recovery param");return i})}catch(i){return Promise.reject(i)}},"sign5"),"sign")}s(C5,"ES256KSignerAlg");c(C5,"ES256KSignerAlg");function S5(){return c(s(function(e,r){try{return Promise.resolve(r(e)).then(function(n){if(Ax(n))throw new Error("invalid_config: expected a signer function that returns a string instead of signature object");return n})}catch(n){return Promise.reject(n)}},"sign5"),"sign")}s(S5,"Ed25519SignerAlg");c(S5,"Ed25519SignerAlg");var Uee={ES256K:C5(),"ES256K-R":C5(!0),Ed25519:S5(),EdDSA:S5()};function YP(t){let e=Uee[t];if(!e)throw new Error(`not_supported: Unsupported algorithm ${t}`);return e}s(YP,"SignerAlg");c(YP,"SignerAlg");var Ex=new jP.ec("secp256k1");function s1(t,e=!1){let r=Wi(t);if(r.length!==(e?65:64))throw new Error("wrong signature length");let n=Vf(r.slice(0,32)),i=Vf(r.slice(32,64)),o={r:n,s:i};return e&&(o.recoveryParam=r[64]),o}s(s1,"toSignatureObject");c(s1,"toSignatureObject");function wv(t){if(t.publicKeyBase58)return xv(t.publicKeyBase58);if(t.publicKeyBase64)return Wi(t.publicKeyBase64);if(t.publicKeyHex)return b2(t.publicKeyHex);if(t.publicKeyJwk&&t.publicKeyJwk.crv==="secp256k1"&&t.publicKeyJwk.x&&t.publicKeyJwk.y)return b2(Ex.keyFromPublic({x:Vf(Wi(t.publicKeyJwk.x)),y:Vf(Wi(t.publicKeyJwk.y))}).getPublic("hex"));if(t.publicKeyMultibase){let{base16:e,base58btc:r,base64:n,base64url:i}=a2;return e.decoder.or(r.decoder.or(n.decoder.or(i.decoder))).decode(t.publicKeyMultibase)}return new Uint8Array}s(wv,"extractPublicKeyBytes");c(wv,"extractPublicKeyBytes");function ZP(t,e,r){let n=wx(t),i=s1(e),o=r.filter(({ethereumAddress:l,blockchainAccountId:u})=>typeof l>"u"&&typeof u>"u"),a=r.filter(({ethereumAddress:l,blockchainAccountId:u})=>typeof l<"u"||typeof u!==void 0),f=o.find(l=>{try{let u=wv(l);return Ex.keyFromPublic(u).verify(n,i)}catch{return!1}});if(!f&&a.length>0&&(f=Cx(t,e,a)),!f)throw new Error("invalid_signature: Signature invalid for JWT");return f}s(ZP,"verifyES256K");c(ZP,"verifyES256K");function Cx(t,e,r){let n;if(e.length>86)n=[s1(e,!0)];else{let a=s1(e,!1);n=[{...a,recoveryParam:0},{...a,recoveryParam:1}]}let i=c(a=>{let f=wx(t),l=Ex.recoverPubKey(f,a,a.recoveryParam),u=l.encode("hex"),h=l.encode("hex",!0),g=WP(u);return r.find(_=>{var E,T,B;let F=Vf(wv(_));return F===u||F===h||((E=_.ethereumAddress)==null?void 0:E.toLowerCase())===g||((T=_.blockchainAccountId)==null||(B=T.split("@eip155"))==null?void 0:B[0].toLowerCase())===g})},"checkSignatureAgainstSigner"),o=n.map(i).filter(a=>typeof a<"u");if(o.length===0)throw new Error("invalid_signature: Signature invalid for JWT");return o[0]}s(Cx,"verifyRecoverableES256K");c(Cx,"verifyRecoverableES256K");function I5(t,e,r){let n=yx(t),i=Wi(e),o=r.find(a=>(0,qP.verify)(wv(a),n,i));if(!o)throw new Error("invalid_signature: Signature invalid for JWT");return o}s(I5,"verifyEd25519");c(I5,"verifyEd25519");var jee={ES256K:ZP,"ES256K-R":Cx,Ed25519:I5,EdDSA:I5};function Sx(t){let e=jee[t];if(!e)throw new Error(`not_supported: Unsupported algorithm ${t}`);return e}s(Sx,"VerifierAlgorithm");c(Sx,"VerifierAlgorithm");Sx.toSignatureObject=s1;var qee=c(function(t,e,r={},n={}){try{r.alg||(r.alg=Hee);let i=typeof t=="string"?t:k5(t,n.canonicalize),o=[k5(r,n.canonicalize),i].join("."),a=YP(r.alg);return Promise.resolve(a(o,e)).then(function(f){return[o,f].join(".")})}catch(i){return Promise.reject(i)}},"createJWS"),Hee="ES256K";function k5(t,e=!1){return v2(e?(0,Oee.default)(t):JSON.stringify(t))}s(k5,"encodeSection");c(k5,"encodeSection");function XP(t){let e=t.match(/^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)$/);if(e)return{header:JSON.parse(vx(e[1])),payload:e[2],signature:e[3],data:`${e[1]}.${e[2]}`};throw new Error("invalid_argument: Incorrect format JWS")}s(XP,"decodeJWS");c(XP,"decodeJWS");function QP({header:t,data:e,signature:r},n){return Array.isArray(n)||(n=[n]),Sx(t.alg)(e,r,n)}s(QP,"verifyJWSDecoded");c(QP,"verifyJWSDecoded");function eO(t,e){let r=XP(t);return QP(r,e)}s(eO,"verifyJWS");c(eO,"verifyJWS");function tO(t,e,r){for(var n;;){var i=t();if(Pc(i)&&(i=i.v),!i)return o;if(i.then){n=0;break}var o=r();if(o&&o.then)if(Pc(o))o=o.s;else{n=1;break}if(e){var a=e();if(a&&a.then&&!Pc(a)){n=2;break}}}var f=new iu,l=Dn.bind(null,f,2);return(n===0?i.then(h):n===1?o.then(u):a.then(g)).then(void 0,l),f;function u(x){o=x;do{if(e&&(a=e(),a&&a.then&&!Pc(a))){a.then(g).then(void 0,l);return}if(i=t(),!i||Pc(i)&&!i.v){Dn(f,1,o);return}if(i.then){i.then(h).then(void 0,l);return}o=r(),Pc(o)&&(o=o.v)}while(!o||!o.then);o.then(u).then(void 0,l)}s(u,"_resumeAfterBody"),c(u,"_resumeAfterBody");function h(x){x?(o=r(),o&&o.then?o.then(u).then(void 0,l):u(o)):Dn(f,1,o)}s(h,"_resumeAfterTest"),c(h,"_resumeAfterTest");function g(){(i=t())?i.then?i.then(h).then(void 0,l):h(i):Dn(f,1,o)}s(g,"_resumeAfterUpdate"),c(g,"_resumeAfterUpdate")}s(tO,"_for");c(tO,"_for");var zee=c(function(t,e){try{let r=s(function(u){if(f===null)throw new Error("failure: Failed to decrypt");return f},"_temp5");c(r,"_temp5");let n;iO(t);let i=JSON.parse(vx(t.protected));if(i.enc!==e.enc)throw new Error(`not_supported: Decrypter does not supported: '${i.enc}'`);let o=xx(t.ciphertext,t.tag),a=new Uint8Array(Buffer.from(t.aad?`${t.protected}.${t.aad}`:t.protected)),f=null,l=function(){return i.alg==="dir"&&e.alg==="dir"?Promise.resolve(e.decrypt(o,Wi(t.iv),a)).then(function(u){f=u}):function(){if(!t.recipients||t.recipients.length===0)throw new Error("bad_jwe: missing recipients");{let u=0;return tO(function(){return!f&&u<t.recipients.length},function(){return u++},function(){let h=t.recipients[u];Object.assign(h.header,i);let g=function(){if(h.header.alg===e.alg)return Promise.resolve(e.decrypt(o,Wi(t.iv),a,h)).then(function(x){f=x})}();if(g&&g.then)return g.then(function(){})})}}()}();return Promise.resolve(l&&l.then?l.then(r):r(l))}catch(r){return Promise.reject(r)}},"decryptJWE"),kM=typeof Symbol<"u"?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Dn(t,e,r){if(!t.s){if(r instanceof iu)if(r.s)e&1&&(e=r.s),r=r.v;else{r.o=Dn.bind(null,t,e);return}if(r&&r.then){r.then(Dn.bind(null,t,e),Dn.bind(null,t,2));return}t.s=e,t.v=r;let n=t.o;n&&n(t)}}s(Dn,"_settle");c(Dn,"_settle");var iu=function(){function t(){}return s(t,"_Pact2"),c(t,"_Pact"),t.prototype.then=function(e,r){let n=new t,i=this.s;if(i){let o=i&1?e:r;if(o){try{Dn(n,1,o(this.v))}catch(a){Dn(n,2,a)}return n}else return this}return this.o=function(o){try{let a=o.v;o.s&1?Dn(n,1,e?e(a):a):r?Dn(n,1,r(a)):Dn(n,2,a)}catch(a){Dn(n,2,a)}},n},t}();function Pc(t){return t instanceof iu&&t.s&1}s(Pc,"_isSettledPact");c(Pc,"_isSettledPact");function rO(t,e,r){var n=-1,i,o;function a(f){try{for(;++n<t.length&&(!r||!r());)if(f=e(n),f&&f.then)if(Pc(f))f=f.v;else{f.then(a,o||(o=Dn.bind(null,i=new iu,2)));return}i?Dn(i,1,f):i=f}catch(l){Dn(i||(i=new iu),2,l)}}return s(a,"_cycle"),c(a,"_cycle"),a(),i}s(rO,"_forTo");c(rO,"_forTo");function nO(t,e,r){if(typeof t[kM]=="function"){let h=s(function(g){try{for(;!(i=n.next()).done&&(!r||!r());)if(g=e(i.value),g&&g.then)if(Pc(g))g=g.v;else{g.then(h,a||(a=Dn.bind(null,o=new iu,2)));return}o?Dn(o,1,g):o=g}catch(x){Dn(o||(o=new iu),2,x)}},"_cycle");c(h,"_cycle");var n=t[kM](),i,o,a;if(h(),n.return){var f=c(function(g){try{i.done||n.return()}catch{}return g},"_fixup");if(o&&o.then)return o.then(f,function(g){throw f(g)});f()}return o}if(!("length"in t))throw new TypeError("Object is not iterable");for(var l=[],u=0;u<t.length;u++)l.push(t[u]);return rO(l,function(h){return e(l[h])},r)}s(nO,"_forOf");c(nO,"_forOf");function iO(t){if(!(t.protected&&t.iv&&t.ciphertext&&t.tag))throw new Error("bad_jwe: missing properties");t.recipients&&t.recipients.map(e=>{if(!(e.header&&e.encrypted_key))throw new Error("bad_jwe: malformed recipients")})}s(iO,"validateJWE");c(iO,"validateJWE");function T5({ciphertext:t,tag:e,iv:r,protectedHeader:n,recipient:i},o){let a={protected:n,iv:Fs(r),ciphertext:Fs(t),tag:Fs(e)};return o&&(a.aad=Fs(o)),i&&(a.recipients=[i]),a}s(T5,"encodeJWE");c(T5,"encodeJWE");var $ee=c(function(t,e,r={},n){try{if(e[0].alg==="dir"){if(e.length>1)throw new Error('not_supported: Can only do "dir" encryption to one key.');return Promise.resolve(e[0].encrypt(t,r,n)).then(function(i){return T5(i,n)})}else{let i=e[0].enc;if(!e.reduce((l,u)=>l&&u.enc===i,!0))throw new Error("invalid_argument: Incompatible encrypters passed");let o,a,f=nO(e,function(l){let u=function(){return o?Promise.resolve(l.encryptCek==null?void 0:l.encryptCek(o)).then(function(h){if(h){var g,x;(g=a)==null||(x=g.recipients)==null||x.push(h)}}):Promise.resolve(l.encrypt(t,r,n)).then(function(h){o=h.cek,a=T5(h,n)})}();if(u&&u.then)return u.then(function(){})});return Promise.resolve(f&&f.then?f.then(function(){return a}):a)}}catch(i){return Promise.reject(i)}},"createJWE"),Gee=c(function(t,e){try{let r=c(function(i){try{return Promise.resolve(e.resolve(i)).then(function({didResolutionMetadata:o,didDocument:a}){var f;if(o!=null&&o.error||a==null)throw new Error(`resolver_error: Could not resolve ${i}: ${o.error}, ${o.message}`);if(!a.keyAgreement)throw new Error(`no_suitable_keys: Could not find x25519 key for ${i}`);let u=((f=a.keyAgreement)==null?void 0:f.map(h=>typeof h=="string"?[...a.publicKey||[],...a.verificationMethod||[]].find(g=>g.id===h):h).filter(h=>typeof h<"u")).filter(h=>h.type==="X25519KeyAgreementKey2019"&&Boolean(h.publicKeyBase58));if(!u.length)throw new Error(`no_suitable_keys: Could not find x25519 key for ${i}`);return u.map(h=>oO(xv(h.publicKeyBase58),h.id))})}catch(o){return Promise.reject(o)}},"encryptersForDID"),n=t.map(i=>r(i));return Promise.resolve(Promise.all(n)).then(function(i){return[].concat(...i)})}catch(r){return Promise.reject(r)}},"resolveX25519Encrypters");function Ix(t){let e=new HP.XChaCha20Poly1305(t);return(r,n)=>{let i=(0,zP.randomBytes)(e.nonceLength),o=e.seal(i,r,n);return{ciphertext:o.subarray(0,o.length-e.tagLength),tag:o.subarray(o.length-e.tagLength),iv:i}}}s(Ix,"xc20pEncrypter");c(Ix,"xc20pEncrypter");function sO(t){let e=c(function(o,a={},f){try{let l=v2(JSON.stringify(Object.assign({alg:i},a,{enc:n}))),u=new Uint8Array(Buffer.from(f?`${l}.${Fs(f)}`:l));return Promise.resolve({...r(o,u),protectedHeader:l})}catch(l){return Promise.reject(l)}},"encrypt"),r=Ix(t),n="XC20P",i="dir";return{alg:i,enc:n,encrypt:e}}s(sO,"xc20pDirEncrypter");c(sO,"xc20pDirEncrypter");function M5(t){let e=c(function(n,i,o){try{return Promise.resolve(r.open(i,n,o))}catch(a){return Promise.reject(a)}},"decrypt"),r=new HP.XChaCha20Poly1305(t);return{alg:"dir",enc:"XC20P",decrypt:e}}s(M5,"xc20pDirDecrypter");c(M5,"xc20pDirDecrypter");function oO(t,e){let r=c(function(f,l={},u){try{Object.assign(l,{alg:void 0});let h=(0,zP.randomBytes)(32);return Promise.resolve(sO(h).encrypt(f,l,u)).then(function(g){return Promise.resolve(n(h)).then(function(x){return{...g,recipient:x,cek:h}})})}catch(h){return Promise.reject(h)}},"encrypt"),n=c(function(f){try{let l=(0,E5.generateKeyPair)(),u=(0,E5.sharedKey)(l.secretKey,t),h=_x(u,o,i),g=Ix(h)(f),x={encrypted_key:Fs(g.ciphertext),header:{alg:i,iv:Fs(g.iv),tag:Fs(g.tag),epk:{kty:"OKP",crv:a,x:Fs(l.publicKey)}}};return e&&(x.header.kid=e),Promise.resolve(x)}catch(l){return Promise.reject(l)}},"encryptCek"),i="ECDH-ES+XC20PKW",o=256,a="X25519";return{alg:i,enc:"XC20P",encrypt:r,encryptCek:n}}s(oO,"x25519Encrypter");c(oO,"x25519Encrypter");function aO(t){if(!(t&&t.epk&&t.iv&&t.tag))throw new Error("bad_jwe: malformed header")}s(aO,"validateHeader");c(aO,"validateHeader");function cO(t){let e=c(function(o,a,f,l){try{let g=s(function(){let T=_x(_,n,r),B=xx(l.encrypted_key,l.header.tag);return Promise.resolve(M5(T).decrypt(B,Wi(l.header.iv))).then(function(F){return F===null?null:M5(F).decrypt(o,a,f)})},"_temp4");c(g,"_temp4");var u,h;if(aO((u=l)==null?void 0:u.header),l=l,((h=l.header.epk)==null?void 0:h.crv)!==i||typeof l.header.epk.x>"u")return Promise.resolve(null);let x=Wi(l.header.epk.x),_,E=function(){if(t instanceof Uint8Array)_=(0,E5.sharedKey)(t,x);else return Promise.resolve(t(x)).then(function(T){_=T})}();return Promise.resolve(E&&E.then?E.then(g):g(E))}catch(g){return Promise.reject(g)}},"decrypt"),r="ECDH-ES+XC20PKW",n=256,i="X25519";return{alg:r,enc:"XC20P",decrypt:e}}s(cO,"x25519Decrypter");c(cO,"x25519Decrypter");HB();var Cb=c(({enumerable:t=!0,configurable:e=!1}={})=>({enumerable:t,configurable:e,writable:!1}),"readonly"),R5=c(function*(t,e){if(t!=null&&!(t instanceof Uint8Array))for(let[r,n]of Object.entries(t)){let i=[...e,r];if(n!=null&&typeof n=="object")if(Array.isArray(n))for(let[o,a]of n.entries()){let f=[...i,o],l=fr.asCID(a);l?yield[f.join("/"),l]:typeof a=="object"&&(yield*R5(a,f))}else{let o=fr.asCID(n);o?yield[i.join("/"),o]:yield*R5(n,i)}}},"links"),B5=c(function*(t,e){if(t!=null)for(let[r,n]of Object.entries(t)){let i=[...e,r];if(yield i.join("/"),n!=null&&!(n instanceof Uint8Array)&&typeof n=="object"&&!fr.asCID(n))if(Array.isArray(n))for(let[o,a]of n.entries()){let f=[...i,o];yield f.join("/"),typeof a=="object"&&!fr.asCID(a)&&(yield*B5(a,f))}else yield*B5(n,i)}},"tree"),Kee=c((t,e)=>{let r=t;for(let[n,i]of e.entries()){if(r=r[i],r==null)throw new Error(`Object has no property at ${e.slice(0,n+1).map(a=>`[${JSON.stringify(a)}]`).join("")}`);let o=fr.asCID(r);if(o)return{value:o,remaining:e.slice(n+1).join("/")}}return{value:r}},"get"),kx=s(class{constructor({cid:t,bytes:e,value:r}){if(!t||!e||typeof r>"u")throw new Error("Missing required argument");this.cid=t,this.bytes=e,this.value=r,this.asBlock=this,Object.defineProperties(this,{cid:Cb(),bytes:Cb(),value:Cb(),asBlock:Cb()})}links(){return R5(this.value,[])}tree(){return B5(this.value,[])}get(t="/"){return Kee(this.value,t.split("/").filter(Boolean))}},"Block");c(kx,"Block");var _v=c(async({value:t,codec:e,hasher:r})=>{if(typeof t>"u")throw new Error('Missing required argument "value"');if(!e||!r)throw new Error("Missing required argument: codec or hasher");let n=e.encode(t),i=await r.digest(n),o=fr.create(1,e.code,i);return new kx({value:t,bytes:n,cid:o})},"encode"),Vee=c(async({bytes:t,codec:e,hasher:r})=>{if(!t)throw new Error('Missing required argument "bytes"');if(!e||!r)throw new Error("Missing required argument: codec or hasher");let n=e.decode(t),i=await r.digest(t),o=fr.create(1,e.code,i);return new kx({value:n,bytes:t,cid:o})},"decode");Ga();cv();qB();z8();var bh={};Kr(bh,{code:()=>w2,decode:()=>xF,encode:()=>Pv,name:()=>ute});var Wee=["string","number","bigint","symbol"],Jee=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function fO(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(Wee.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(lO(t))return"Buffer";let r=uO(t);return r||"Object"}s(fO,"is");c(fO,"is");function lO(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}s(lO,"isBuffer");c(lO,"isBuffer");function uO(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(Jee.includes(e))return e}s(uO,"getObjectType");c(uO,"getObjectType");var Ue=s(class{constructor(t,e,r){this.major=t,this.majorEncoded=t<<5,this.name=e,this.terminal=r}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}},"Type");c(Ue,"Type");Ue.uint=new Ue(0,"uint",!0);Ue.negint=new Ue(1,"negint",!0);Ue.bytes=new Ue(2,"bytes",!0);Ue.string=new Ue(3,"string",!0);Ue.array=new Ue(4,"array",!1);Ue.map=new Ue(5,"map",!1);Ue.tag=new Ue(6,"tag",!1);Ue.float=new Ue(7,"float",!0);Ue.false=new Ue(7,"false",!0);Ue.true=new Ue(7,"true",!0);Ue.null=new Ue(7,"null",!0);Ue.undefined=new Ue(7,"undefined",!0);Ue.break=new Ue(7,"break",!0);var st=s(class{constructor(t,e,r){this.type=t,this.value=e,this.encodedLength=r,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}},"Token");c(st,"Token");var vh=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Yee=new TextDecoder,Zee=new TextEncoder;function o1(t){return vh&&globalThis.Buffer.isBuffer(t)}s(o1,"isBuffer2");c(o1,"isBuffer");function Tx(t){return t instanceof Uint8Array?o1(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}s(Tx,"asU8A");c(Tx,"asU8A");var Xee=vh?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):P5(t,e,r):(t,e,r)=>r-e>64?Yee.decode(t.subarray(e,r)):P5(t,e,r),Qee=vh?t=>t.length>64?globalThis.Buffer.from(t):D5(t):t=>t.length>64?Zee.encode(t):D5(t),Tc=c(t=>Uint8Array.from(t),"fromArray"),Mx=vh?(t,e,r)=>o1(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),ete=vh?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Tx(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let i of t)n+i.length>r.length&&(i=i.subarray(0,r.length-n)),r.set(i,n),n+=i.length;return r},tte=vh?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function dO(t,e){if(o1(t)&&o1(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}s(dO,"compare2");c(dO,"compare");function D5(t,e=1/0){let r,n=t.length,i=null,o=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}s(D5,"utf8ToBytes");c(D5,"utf8ToBytes");function P5(t,e,r){let n=[];for(;e<r;){let i=t[e],o=null,a=i>239?4:i>223?3:i>191?2:1;if(e+a<=r){let f,l,u,h;switch(a){case 1:i<128&&(o=i);break;case 2:f=t[e+1],(f&192)===128&&(h=(i&31)<<6|f&63,h>127&&(o=h));break;case 3:f=t[e+1],l=t[e+2],(f&192)===128&&(l&192)===128&&(h=(i&15)<<12|(f&63)<<6|l&63,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:f=t[e+1],l=t[e+2],u=t[e+3],(f&192)===128&&(l&192)===128&&(u&192)===128&&(h=(i&15)<<18|(f&63)<<12|(l&63)<<6|u&63,h>65535&&h<1114112&&(o=h))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),e+=a}return hO(n)}s(P5,"utf8Slice");c(P5,"utf8Slice");var TM=4096;function hO(t){let e=t.length;if(e<=TM)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=TM));return r}s(hO,"decodeCodePointsArray");c(hO,"decodeCodePointsArray");var rte=256,Rx=s(class{constructor(t=rte){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)}push(t){let e=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let n=e.length-(this.maxCursor-this.cursor)-1;e.set(t,n)}else{if(e){let n=e.length-(this.maxCursor-this.cursor)-1;n<e.length&&(this.chunks[this.chunks.length-1]=e.subarray(0,n),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(e=tte(this.chunkSize),this.chunks.push(e),this.maxCursor+=e.length,this._initReuseChunk===null&&(this._initReuseChunk=e),e.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let e;if(this.chunks.length===1){let r=this.chunks[0];t&&this.cursor>r.length/2?(e=this.cursor===r.length?r:r.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):e=Mx(r,0,this.cursor)}else e=ete(this.chunks,this.cursor);return t&&this.reset(),e}},"Bl");c(Rx,"Bl");var yr="CBOR decode error:",pO="CBOR encode error:",D1=[];D1[23]=1;D1[24]=2;D1[25]=3;D1[26]=5;D1[27]=9;function hu(t,e,r){if(t.length-e<r)throw new Error(`${yr} not enough data for type`)}s(hu,"assertEnoughData");c(hu,"assertEnoughData");var ai=[24,256,65536,4294967296,BigInt("18446744073709551616")];function el(t,e,r){hu(t,e,1);let n=t[e];if(r.strict===!0&&n<ai[0])throw new Error(`${yr} integer encoded in more bytes than necessary (strict decode)`);return n}s(el,"readUint8");c(el,"readUint8");function tl(t,e,r){hu(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<ai[1])throw new Error(`${yr} integer encoded in more bytes than necessary (strict decode)`);return n}s(tl,"readUint16");c(tl,"readUint16");function rl(t,e,r){hu(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<ai[2])throw new Error(`${yr} integer encoded in more bytes than necessary (strict decode)`);return n}s(rl,"readUint32");c(rl,"readUint32");function nl(t,e,r){hu(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],i=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],o=(BigInt(n)<<BigInt(32))+BigInt(i);if(r.strict===!0&&o<ai[3])throw new Error(`${yr} integer encoded in more bytes than necessary (strict decode)`);if(o<=Number.MAX_SAFE_INTEGER)return Number(o);if(r.allowBigInt===!0)return o;throw new Error(`${yr} integers outside of the safe integer range are not supported`)}s(nl,"readUint64");c(nl,"readUint64");function mO(t,e,r,n){return new st(Ue.uint,el(t,e+1,n),2)}s(mO,"decodeUint8");c(mO,"decodeUint8");function gO(t,e,r,n){return new st(Ue.uint,tl(t,e+1,n),3)}s(gO,"decodeUint16");c(gO,"decodeUint16");function bO(t,e,r,n){return new st(Ue.uint,rl(t,e+1,n),5)}s(bO,"decodeUint32");c(bO,"decodeUint32");function vO(t,e,r,n){return new st(Ue.uint,nl(t,e+1,n),9)}s(vO,"decodeUint64");c(vO,"decodeUint64");function il(t,e){return js(t,0,e.value)}s(il,"encodeUint");c(il,"encodeUint");function js(t,e,r){if(r<ai[0]){let n=Number(r);t.push([e|n])}else if(r<ai[1]){let n=Number(r);t.push([e|24,n])}else if(r<ai[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<ai[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<ai[4]){let i=[e|27,0,0,0,0,0,0,0],o=Number(n&BigInt(4294967295)),a=Number(n>>BigInt(32)&BigInt(4294967295));i[8]=o&255,o=o>>8,i[7]=o&255,o=o>>8,i[6]=o&255,o=o>>8,i[5]=o&255,i[4]=a&255,a=a>>8,i[3]=a&255,a=a>>8,i[2]=a&255,a=a>>8,i[1]=a&255,t.push(i)}else throw new Error(`${yr} encountered BigInt larger than allowable range`)}}s(js,"encodeUintValue");c(js,"encodeUintValue");il.encodedSize=c(s(function(e){return js.encodedSize(e.value)},"encodedSize"),"encodedSize");js.encodedSize=c(s(function(e){return e<ai[0]?1:e<ai[1]?2:e<ai[2]?3:e<ai[3]?5:9},"encodedSize2"),"encodedSize");il.compareTokens=c(s(function(e,r){return e.value<r.value?-1:e.value>r.value?1:0},"compareTokens"),"compareTokens");function yO(t,e,r,n){return new st(Ue.negint,-1-el(t,e+1,n),2)}s(yO,"decodeNegint8");c(yO,"decodeNegint8");function xO(t,e,r,n){return new st(Ue.negint,-1-tl(t,e+1,n),3)}s(xO,"decodeNegint16");c(xO,"decodeNegint16");function wO(t,e,r,n){return new st(Ue.negint,-1-rl(t,e+1,n),5)}s(wO,"decodeNegint32");c(wO,"decodeNegint32");var Bx=BigInt(-1),_O=BigInt(1);function AO(t,e,r,n){let i=nl(t,e+1,n);if(typeof i!="bigint"){let o=-1-i;if(o>=Number.MIN_SAFE_INTEGER)return new st(Ue.negint,o,9)}if(n.allowBigInt!==!0)throw new Error(`${yr} integers outside of the safe integer range are not supported`);return new st(Ue.negint,Bx-BigInt(i),9)}s(AO,"decodeNegint64");c(AO,"decodeNegint64");function Av(t,e){let r=e.value,n=typeof r=="bigint"?r*Bx-_O:r*-1-1;js(t,e.type.majorEncoded,n)}s(Av,"encodeNegint");c(Av,"encodeNegint");Av.encodedSize=c(s(function(e){let r=e.value,n=typeof r=="bigint"?r*Bx-_O:r*-1-1;return n<ai[0]?1:n<ai[1]?2:n<ai[2]?3:n<ai[3]?5:9},"encodedSize3"),"encodedSize");Av.compareTokens=c(s(function(e,r){return e.value<r.value?1:e.value>r.value?-1:0},"compareTokens2"),"compareTokens");function yh(t,e,r,n){hu(t,e,r+n);let i=Mx(t,e+r,e+r+n);return new st(Ue.bytes,i,r+n)}s(yh,"toToken");c(yh,"toToken");function EO(t,e,r,n){return yh(t,e,1,r)}s(EO,"decodeBytesCompact");c(EO,"decodeBytesCompact");function CO(t,e,r,n){return yh(t,e,2,el(t,e+1,n))}s(CO,"decodeBytes8");c(CO,"decodeBytes8");function SO(t,e,r,n){return yh(t,e,3,tl(t,e+1,n))}s(SO,"decodeBytes16");c(SO,"decodeBytes16");function IO(t,e,r,n){return yh(t,e,5,rl(t,e+1,n))}s(IO,"decodeBytes32");c(IO,"decodeBytes32");function kO(t,e,r,n){let i=nl(t,e+1,n);if(typeof i=="bigint")throw new Error(`${yr} 64-bit integer bytes lengths not supported`);return yh(t,e,9,i)}s(kO,"decodeBytes64");c(kO,"decodeBytes64");function a1(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===Ue.string?Qee(t.value):t.value),t.encodedBytes}s(a1,"tokenBytes");c(a1,"tokenBytes");function P1(t,e){let r=a1(e);js(t,e.type.majorEncoded,r.length),t.push(r)}s(P1,"encodeBytes");c(P1,"encodeBytes");P1.encodedSize=c(s(function(e){let r=a1(e);return js.encodedSize(r.length)+r.length},"encodedSize4"),"encodedSize");P1.compareTokens=c(s(function(e,r){return TO(a1(e),a1(r))},"compareTokens3"),"compareTokens");function TO(t,e){return t.length<e.length?-1:t.length>e.length?1:dO(t,e)}s(TO,"compareBytes");c(TO,"compareBytes");function xh(t,e,r,n,i){let o=r+n;hu(t,e,o);let a=new st(Ue.string,Xee(t,e+r,e+o),o);return i.retainStringBytes===!0&&(a.byteValue=Mx(t,e+r,e+o)),a}s(xh,"toToken2");c(xh,"toToken");function MO(t,e,r,n){return xh(t,e,1,r,n)}s(MO,"decodeStringCompact");c(MO,"decodeStringCompact");function RO(t,e,r,n){return xh(t,e,2,el(t,e+1,n),n)}s(RO,"decodeString8");c(RO,"decodeString8");function BO(t,e,r,n){return xh(t,e,3,tl(t,e+1,n),n)}s(BO,"decodeString16");c(BO,"decodeString16");function DO(t,e,r,n){return xh(t,e,5,rl(t,e+1,n),n)}s(DO,"decodeString32");c(DO,"decodeString32");function PO(t,e,r,n){let i=nl(t,e+1,n);if(typeof i=="bigint")throw new Error(`${yr} 64-bit integer string lengths not supported`);return xh(t,e,9,i,n)}s(PO,"decodeString64");c(PO,"decodeString64");var nte=P1;function pu(t,e,r,n){return new st(Ue.array,n,r)}s(pu,"toToken3");c(pu,"toToken");function OO(t,e,r,n){return pu(t,e,1,r)}s(OO,"decodeArrayCompact");c(OO,"decodeArrayCompact");function FO(t,e,r,n){return pu(t,e,2,el(t,e+1,n))}s(FO,"decodeArray8");c(FO,"decodeArray8");function NO(t,e,r,n){return pu(t,e,3,tl(t,e+1,n))}s(NO,"decodeArray16");c(NO,"decodeArray16");function LO(t,e,r,n){return pu(t,e,5,rl(t,e+1,n))}s(LO,"decodeArray32");c(LO,"decodeArray32");function UO(t,e,r,n){let i=nl(t,e+1,n);if(typeof i=="bigint")throw new Error(`${yr} 64-bit integer array lengths not supported`);return pu(t,e,9,i)}s(UO,"decodeArray64");c(UO,"decodeArray64");function jO(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${yr} indefinite length items not allowed`);return pu(t,e,1,1/0)}s(jO,"decodeArrayIndefinite");c(jO,"decodeArrayIndefinite");function Ev(t,e){js(t,Ue.array.majorEncoded,e.value)}s(Ev,"encodeArray");c(Ev,"encodeArray");Ev.compareTokens=il.compareTokens;Ev.encodedSize=c(s(function(e){return js.encodedSize(e.value)},"encodedSize5"),"encodedSize");function mu(t,e,r,n){return new st(Ue.map,n,r)}s(mu,"toToken4");c(mu,"toToken");function qO(t,e,r,n){return mu(t,e,1,r)}s(qO,"decodeMapCompact");c(qO,"decodeMapCompact");function HO(t,e,r,n){return mu(t,e,2,el(t,e+1,n))}s(HO,"decodeMap8");c(HO,"decodeMap8");function zO(t,e,r,n){return mu(t,e,3,tl(t,e+1,n))}s(zO,"decodeMap16");c(zO,"decodeMap16");function $O(t,e,r,n){return mu(t,e,5,rl(t,e+1,n))}s($O,"decodeMap32");c($O,"decodeMap32");function GO(t,e,r,n){let i=nl(t,e+1,n);if(typeof i=="bigint")throw new Error(`${yr} 64-bit integer map lengths not supported`);return mu(t,e,9,i)}s(GO,"decodeMap64");c(GO,"decodeMap64");function KO(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${yr} indefinite length items not allowed`);return mu(t,e,1,1/0)}s(KO,"decodeMapIndefinite");c(KO,"decodeMapIndefinite");function Cv(t,e){js(t,Ue.map.majorEncoded,e.value)}s(Cv,"encodeMap");c(Cv,"encodeMap");Cv.compareTokens=il.compareTokens;Cv.encodedSize=c(s(function(e){return js.encodedSize(e.value)},"encodedSize6"),"encodedSize");function VO(t,e,r,n){return new st(Ue.tag,r,1)}s(VO,"decodeTagCompact");c(VO,"decodeTagCompact");function WO(t,e,r,n){return new st(Ue.tag,el(t,e+1,n),2)}s(WO,"decodeTag8");c(WO,"decodeTag8");function JO(t,e,r,n){return new st(Ue.tag,tl(t,e+1,n),3)}s(JO,"decodeTag16");c(JO,"decodeTag16");function YO(t,e,r,n){return new st(Ue.tag,rl(t,e+1,n),5)}s(YO,"decodeTag32");c(YO,"decodeTag32");function ZO(t,e,r,n){return new st(Ue.tag,nl(t,e+1,n),9)}s(ZO,"decodeTag64");c(ZO,"decodeTag64");function Sv(t,e){js(t,Ue.tag.majorEncoded,e.value)}s(Sv,"encodeTag");c(Sv,"encodeTag");Sv.compareTokens=il.compareTokens;Sv.encodedSize=c(s(function(e){return js.encodedSize(e.value)},"encodedSize7"),"encodedSize");var ite=20,ste=21,ote=22,ate=23;function XO(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${yr} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new st(Ue.null,null,1):new st(Ue.undefined,void 0,1)}s(XO,"decodeUndefined");c(XO,"decodeUndefined");function QO(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${yr} indefinite length items not allowed`);return new st(Ue.break,void 0,1)}s(QO,"decodeBreak");c(QO,"decodeBreak");function Iv(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${yr} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${yr} Infinity values are not supported`)}return new st(Ue.float,t,e)}s(Iv,"createToken");c(Iv,"createToken");function eF(t,e,r,n){return Iv(Tv(t,e+1),3,n)}s(eF,"decodeFloat16");c(eF,"decodeFloat16");function tF(t,e,r,n){return Iv(Mv(t,e+1),5,n)}s(tF,"decodeFloat32");c(tF,"decodeFloat32");function rF(t,e,r,n){return Iv(Ox(t,e+1),9,n)}s(rF,"decodeFloat64");c(rF,"decodeFloat64");function kv(t,e,r){let n=e.value;if(n===!1)t.push([Ue.float.majorEncoded|ite]);else if(n===!0)t.push([Ue.float.majorEncoded|ste]);else if(n===null)t.push([Ue.float.majorEncoded|ote]);else if(n===void 0)t.push([Ue.float.majorEncoded|ate]);else{let i,o=!1;(!r||r.float64!==!0)&&(Dx(n),i=Tv(Lo,1),n===i||Number.isNaN(n)?(Lo[0]=249,t.push(Lo.slice(0,3)),o=!0):(Px(n),i=Mv(Lo,1),n===i&&(Lo[0]=250,t.push(Lo.slice(0,5)),o=!0))),o||(iF(n),i=Ox(Lo,1),Lo[0]=251,t.push(Lo.slice(0,9)))}}s(kv,"encodeFloat");c(kv,"encodeFloat");kv.encodedSize=c(s(function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Dx(n);let i=Tv(Lo,1);if(n===i||Number.isNaN(n))return 3;if(Px(n),i=Mv(Lo,1),n===i)return 5}return 9},"encodedSize8"),"encodedSize");var nF=new ArrayBuffer(9),fo=new DataView(nF,1),Lo=new Uint8Array(nF,0);function Dx(t){if(t===1/0)fo.setUint16(0,31744,!1);else if(t===-1/0)fo.setUint16(0,64512,!1);else if(Number.isNaN(t))fo.setUint16(0,32256,!1);else{fo.setFloat32(0,t);let e=fo.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)fo.setUint16(0,31744,!1);else if(r===0)fo.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let i=r-127;i<-24?fo.setUint16(0,0):i<-14?fo.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):fo.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}s(Dx,"encodeFloat16");c(Dx,"encodeFloat16");function Tv(t,e){if(t.length-e<2)throw new Error(`${yr} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,i=r&1023,o;return n===0?o=i*2**-24:n!==31?o=(i+1024)*2**(n-25):o=i===0?1/0:NaN,r&32768?-o:o}s(Tv,"readFloat16");c(Tv,"readFloat16");function Px(t){fo.setFloat32(0,t,!1)}s(Px,"encodeFloat32");c(Px,"encodeFloat32");function Mv(t,e){if(t.length-e<4)throw new Error(`${yr} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}s(Mv,"readFloat32");c(Mv,"readFloat32");function iF(t){fo.setFloat64(0,t,!1)}s(iF,"encodeFloat64");c(iF,"encodeFloat64");function Ox(t,e){if(t.length-e<8)throw new Error(`${yr} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}s(Ox,"readFloat64");c(Ox,"readFloat64");kv.compareTokens=il.compareTokens;function Cr(t,e,r){throw new Error(`${yr} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}s(Cr,"invalidMinor");c(Cr,"invalidMinor");function O1(t){return()=>{throw new Error(`${yr} ${t}`)}}s(O1,"errorer");c(O1,"errorer");var ct=[];for(let t=0;t<=23;t++)ct[t]=Cr;ct[24]=mO;ct[25]=gO;ct[26]=bO;ct[27]=vO;ct[28]=Cr;ct[29]=Cr;ct[30]=Cr;ct[31]=Cr;for(let t=32;t<=55;t++)ct[t]=Cr;ct[56]=yO;ct[57]=xO;ct[58]=wO;ct[59]=AO;ct[60]=Cr;ct[61]=Cr;ct[62]=Cr;ct[63]=Cr;for(let t=64;t<=87;t++)ct[t]=EO;ct[88]=CO;ct[89]=SO;ct[90]=IO;ct[91]=kO;ct[92]=Cr;ct[93]=Cr;ct[94]=Cr;ct[95]=O1("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)ct[t]=MO;ct[120]=RO;ct[121]=BO;ct[122]=DO;ct[123]=PO;ct[124]=Cr;ct[125]=Cr;ct[126]=Cr;ct[127]=O1("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)ct[t]=OO;ct[152]=FO;ct[153]=NO;ct[154]=LO;ct[155]=UO;ct[156]=Cr;ct[157]=Cr;ct[158]=Cr;ct[159]=jO;for(let t=160;t<=183;t++)ct[t]=qO;ct[184]=HO;ct[185]=zO;ct[186]=$O;ct[187]=GO;ct[188]=Cr;ct[189]=Cr;ct[190]=Cr;ct[191]=KO;for(let t=192;t<=215;t++)ct[t]=VO;ct[216]=WO;ct[217]=JO;ct[218]=YO;ct[219]=ZO;ct[220]=Cr;ct[221]=Cr;ct[222]=Cr;ct[223]=Cr;for(let t=224;t<=243;t++)ct[t]=O1("simple values are not supported");ct[244]=Cr;ct[245]=Cr;ct[246]=Cr;ct[247]=XO;ct[248]=O1("simple values are not supported");ct[249]=eF;ct[250]=tF;ct[251]=rF;ct[252]=Cr;ct[253]=Cr;ct[254]=Cr;ct[255]=QO;var Wa=[];for(let t=0;t<24;t++)Wa[t]=new st(Ue.uint,t,1);for(let t=-1;t>=-24;t--)Wa[31-t]=new st(Ue.negint,t,1);Wa[64]=new st(Ue.bytes,new Uint8Array(0),1);Wa[96]=new st(Ue.string,"",1);Wa[128]=new st(Ue.array,0,1);Wa[160]=new st(Ue.map,0,1);Wa[244]=new st(Ue.false,!1,1);Wa[245]=new st(Ue.true,!0,1);Wa[246]=new st(Ue.null,null,1);function sF(t){switch(t.type){case Ue.false:return Tc([244]);case Ue.true:return Tc([245]);case Ue.null:return Tc([246]);case Ue.bytes:return t.value.length?void 0:Tc([64]);case Ue.string:return t.value===""?Tc([96]):void 0;case Ue.array:return t.value===0?Tc([128]):void 0;case Ue.map:return t.value===0?Tc([160]):void 0;case Ue.uint:return t.value<24?Tc([Number(t.value)]):void 0;case Ue.negint:if(t.value>=-24)return Tc([31-Number(t.value)])}}s(sF,"quickEncodeToken");c(sF,"quickEncodeToken");var cte={float64:!1,mapSorter:fF,quickEncodeToken:sF};function oF(){let t=[];return t[Ue.uint.major]=il,t[Ue.negint.major]=Av,t[Ue.bytes.major]=P1,t[Ue.string.major]=nte,t[Ue.array.major]=Ev,t[Ue.map.major]=Cv,t[Ue.tag.major]=Sv,t[Ue.float.major]=kv,t}s(oF,"makeCborEncoders");c(oF,"makeCborEncoders");var aF=oF(),K4=new Rx,x2=s(class{constructor(t,e){this.obj=t,this.parent=e}includes(t){let e=this;do if(e.obj===t)return!0;while(e=e.parent);return!1}static createCheck(t,e){if(t&&t.includes(e))throw new Error(`${pO} object contains circular references`);return new x2(e,t)}},"Ref");c(x2,"Ref");var Df={null:new st(Ue.null,null),undefined:new st(Ue.undefined,void 0),true:new st(Ue.true,!0),false:new st(Ue.false,!1),emptyArray:new st(Ue.array,0),emptyMap:new st(Ue.map,0)},Wf={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new st(Ue.float,t):t>=0?new st(Ue.uint,t):new st(Ue.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new st(Ue.uint,t):new st(Ue.negint,t)},Uint8Array(t,e,r,n){return new st(Ue.bytes,t)},string(t,e,r,n){return new st(Ue.string,t)},boolean(t,e,r,n){return t?Df.true:Df.false},null(t,e,r,n){return Df.null},undefined(t,e,r,n){return Df.undefined},ArrayBuffer(t,e,r,n){return new st(Ue.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new st(Ue.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[Df.emptyArray,new st(Ue.break)]:Df.emptyArray;n=x2.createCheck(n,t);let i=[],o=0;for(let a of t)i[o++]=Hp(a,r,n);return r.addBreakTokens?[new st(Ue.array,t.length),i,new st(Ue.break)]:[new st(Ue.array,t.length),i]},Object(t,e,r,n){let i=e!=="Object",o=i?t.keys():Object.keys(t),a=i?t.size:o.length;if(!a)return r.addBreakTokens===!0?[Df.emptyMap,new st(Ue.break)]:Df.emptyMap;n=x2.createCheck(n,t);let f=[],l=0;for(let u of o)f[l++]=[Hp(u,r,n),Hp(i?t.get(u):t[u],r,n)];return cF(f,r),r.addBreakTokens?[new st(Ue.map,a),f,new st(Ue.break)]:[new st(Ue.map,a),f]}};Wf.Map=Wf.Object;Wf.Buffer=Wf.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Wf[`${t}Array`]=Wf.DataView;function Hp(t,e={},r){let n=fO(t),i=e&&e.typeEncoders&&e.typeEncoders[n]||Wf[n];if(typeof i=="function"){let a=i(t,n,e,r);if(a!=null)return a}let o=Wf[n];if(!o)throw new Error(`${pO} unsupported type: ${n}`);return o(t,n,e,r)}s(Hp,"objectToTokens");c(Hp,"objectToTokens");function cF(t,e){e.mapSorter&&t.sort(e.mapSorter)}s(cF,"sortMapEntries");c(cF,"sortMapEntries");function fF(t,e){let r=Array.isArray(t[0])?t[0][0]:t[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(r.type!==n.type)return r.type.compare(n.type);let i=r.type.major,o=aF[i].compareTokens(r,n);return o===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),o}s(fF,"mapSorter");c(fF,"mapSorter");function Fx(t,e,r,n){if(Array.isArray(e))for(let i of e)Fx(t,i,r,n);else r[e.type.major](t,e,n)}s(Fx,"tokensToEncoded");c(Fx,"tokensToEncoded");function lF(t,e,r){let n=Hp(t,r);if(!Array.isArray(n)&&r.quickEncodeToken){let i=r.quickEncodeToken(n);if(i)return i;let o=e[n.type.major];if(o.encodedSize){let a=o.encodedSize(n,r),f=new Rx(a);if(o(f,n,r),f.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Tx(f.chunks[0])}}return K4.reset(),Fx(K4,n,e,r),K4.toBytes(!0)}s(lF,"encodeCustom");c(lF,"encodeCustom");function Rv(t,e){return e=Object.assign({},cte,e),lF(t,aF,e)}s(Rv,"encode6");c(Rv,"encode");var fte={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},uF=s(class{constructor(t,e={}){this.pos=0,this.data=t,this.options=e}done(){return this.pos>=this.data.length}next(){let t=this.data[this.pos],e=Wa[t];if(e===void 0){let r=ct[t];if(!r)throw new Error(`${yr} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let n=t&31;e=r(this.data,this.pos,n,this.options)}return this.pos+=e.encodedLength,e}},"Tokeniser");c(uF,"Tokeniser");var c1=Symbol.for("DONE"),Bv=Symbol.for("BREAK");function dF(t,e,r){let n=[];for(let i=0;i<t.value;i++){let o=oh(e,r);if(o===Bv){if(t.value===1/0)break;throw new Error(`${yr} got unexpected break to lengthed array`)}if(o===c1)throw new Error(`${yr} found array but not enough entries (got ${i}, expected ${t.value})`);n[i]=o}return n}s(dF,"tokenToArray");c(dF,"tokenToArray");function hF(t,e,r){let n=r.useMaps===!0,i=n?void 0:{},o=n?new Map:void 0;for(let a=0;a<t.value;a++){let f=oh(e,r);if(f===Bv){if(t.value===1/0)break;throw new Error(`${yr} got unexpected break to lengthed map`)}if(f===c1)throw new Error(`${yr} found map but not enough entries (got ${a} [no key], expected ${t.value})`);if(n!==!0&&typeof f!="string")throw new Error(`${yr} non-string keys not supported (got ${typeof f})`);if(r.rejectDuplicateMapKeys===!0&&(n&&o.has(f)||!n&&f in i))throw new Error(`${yr} found repeat map key "${f}"`);let l=oh(e,r);if(l===c1)throw new Error(`${yr} found map but not enough entries (got ${a} [no value], expected ${t.value})`);n?o.set(f,l):i[f]=l}return n?o:i}s(hF,"tokenToMap");c(hF,"tokenToMap");function oh(t,e){if(t.done())return c1;let r=t.next();if(r.type===Ue.break)return Bv;if(r.type.terminal)return r.value;if(r.type===Ue.array)return dF(r,t,e);if(r.type===Ue.map)return hF(r,t,e);if(r.type===Ue.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=oh(t,e);return e.tags[r.value](n)}throw new Error(`${yr} tag not supported (${r.value})`)}throw new Error("unsupported")}s(oh,"tokensToObject");c(oh,"tokensToObject");function Dv(t,e){if(!(t instanceof Uint8Array))throw new Error(`${yr} data to decode must be a Uint8Array`);e=Object.assign({},fte,e);let r=e.tokenizer||new uF(t,e),n=oh(r,e);if(n===c1)throw new Error(`${yr} did not find any content to decode`);if(n===Bv)throw new Error(`${yr} got unexpected break`);if(!r.done())throw new Error(`${yr} too many terminals, data makes no sense`);return n}s(Dv,"decode7");c(Dv,"decode");Ga();var pF=42;function mF(t){if(t.asCID!==t)return null;let e=fr.asCID(t);if(!e)return null;let r=new Uint8Array(e.bytes.byteLength+1);return r.set(e.bytes,1),[new st(Ue.tag,pF),new st(Ue.bytes,r)]}s(mF,"cidEncoder");c(mF,"cidEncoder");function gF(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}s(gF,"undefinedEncoder");c(gF,"undefinedEncoder");function bF(t){if(Number.isNaN(t))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(t===1/0||t===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}s(bF,"numberEncoder");c(bF,"numberEncoder");var lte={float64:!0,typeEncoders:{Object:mF,undefined:gF,number:bF}};function vF(t){if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return fr.decode(t.subarray(1))}s(vF,"cidDecoder");c(vF,"cidDecoder");var yF={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};yF.tags[pF]=vF;var ute="dag-cbor",w2=113,Pv=c(t=>Rv(t,lte),"encode"),xF=c(t=>Dv(t,yF),"decode"),dte=24;async function wF(t){let e=await _v({value:t,codec:bh,hasher:dh});return{cid:e.cid,linkedBlock:e.bytes}}s(wF,"encodePayload");c(wF,"encodePayload");function _F(t,e=dte){let r=(e-t.length%e)%e,n=new Uint8Array(t.length+r);return n.set(t,0),n}s(_F,"pad");c(_F,"pad");async function AF(t){return(await _v({value:t,codec:bh,hasher:fv})).cid}s(AF,"encodeIdentityCID");c(AF,"encodeIdentityCID");function EF(t){if(t=fr.asCID(t),t.code!==w2)throw new Error("CID codec must be dag-cbor");if(t.multihash.code!==fv.code)throw new Error("CID must use identity multihash");return xF(t.multihash.digest)}s(EF,"decodeIdentityCID");c(EF,"decodeIdentityCID");async function CF(t,e){return _F((await AF(t)).bytes,e)}s(CF,"prepareCleartext");c(CF,"prepareCleartext");function SF(t){return EF(fr.decodeFirst(t)[0])}s(SF,"decodeCleartext");c(SF,"decodeCleartext");var hte=Symbol("abortable"),O5=Symbol("aborted");function IF(t,e){if(e.aborted)return Promise.reject(O5);let r,n=new Promise((i,o)=>{r=o});return e.addEventListener("abort",()=>{r(O5)}),Promise.race([t,n])}s(IF,"abortable");c(IF,"abortable");var pte=c((t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),""),"nanoid"),kF="utils_abort_request",hs;(function(t){t[t.PARSE_ERROR=-32700]="PARSE_ERROR",t[t.INVALID_REQUEST=-32600]="INVALID_REQUEST",t[t.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",t[t.INVALID_PARAMS=-32602]="INVALID_PARAMS",t[t.INTERNAL_ERROR=-32603]="INTERNAL_ERROR"})(hs||(hs={}));var TF={[hs.PARSE_ERROR]:"Parse error",[hs.INVALID_REQUEST]:"Invalid request",[hs.METHOD_NOT_FOUND]:"Method not found",[hs.INVALID_PARAMS]:"Invalid params",[hs.INTERNAL_ERROR]:"Internal error"};function MF(t){return-32e3>=t&&t>=-32099}s(MF,"isServerError");c(MF,"isServerError");function Ov(t){return TF[t.toString()]??(MF(t)?"Server error":"Application error")}s(Ov,"getErrorMessage");c(Ov,"getErrorMessage");var Jf=s(class extends Error{static fromObject(t){return new Jf(t.code,t.message,t.data)}toObject(){return{code:this.code,data:this.data,message:this.message}}constructor(t,e,r){super(),Object.setPrototypeOf(this,Jf.prototype),this.code=t,this.data=r,this.message=e??Ov(t)}},"RPCError");c(Jf,"RPCError");function wh(t){let e=TF[t];return c(s(function(n){return new Jf(t,e,n)},"createError"),"createError")}s(wh,"createErrorFactory");c(wh,"createErrorFactory");var Dpe=wh(hs.PARSE_ERROR),Ppe=wh(hs.INVALID_REQUEST),Ope=wh(hs.METHOD_NOT_FOUND),Fpe=wh(hs.INVALID_PARAMS),Npe=wh(hs.INTERNAL_ERROR);function RF(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}s(RF,"_checkPrivateRedeclaration");c(RF,"_checkPrivateRedeclaration");function BF(t,e){return e.get?e.get.call(t):e.value}s(BF,"_classApplyDescriptorGet");c(BF,"_classApplyDescriptorGet");function DF(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}s(DF,"_classApplyDescriptorSet");c(DF,"_classApplyDescriptorSet");function Nx(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}s(Nx,"_classExtractFieldDescriptor");c(Nx,"_classExtractFieldDescriptor");function qb(t,e){var r=Nx(t,e,"get");return BF(t,r)}s(qb,"_classPrivateFieldGet");c(qb,"_classPrivateFieldGet");function PF(t,e,r){RF(t,e),e.set(t,r)}s(PF,"_classPrivateFieldInit");c(PF,"_classPrivateFieldInit");function OF(t,e,r){var n=Nx(t,e,"set");return DF(t,n,r),r}s(OF,"_classPrivateFieldSet");c(OF,"_classPrivateFieldSet");var Sp=new WeakMap,F5=s(class{get connection(){return qb(this,Sp)}createID(){return pte()}request(t,e=void 0,r={}){let{signal:n}=r;if(n?.aborted)return Promise.reject(O5);let i=this.createID(),o=qb(this,Sp).send({jsonrpc:"2.0",id:i,method:t,params:e}).then(a=>{if(a==null)throw new Error("Missing response");if(a.error!=null)throw Jf.fromObject(a.error);return a.result});return n==null?o:(n.addEventListener("abort",()=>{this.notify(kF,{id:i})}),IF(o,n))}async notify(t,e=void 0){await qb(this,Sp).send({jsonrpc:"2.0",method:t,params:e})}constructor(t){PF(this,Sp,{writable:!0,value:void 0}),OF(this,Sp,t)}},"RPCClient");c(F5,"RPCClient");function N5(t,e){return{jsonrpc:"2.0",id:t,error:{code:e,message:Ov(e)}}}s(N5,"createErrorResponse");c(N5,"createErrorResponse");function FF(t,e,r){console.warn("Unhandled handler error",e,r)}s(FF,"fallbackOnHandlerError");c(FF,"fallbackOnHandlerError");function NF(t,e){console.warn("Unhandled invalid message",e)}s(NF,"fallbackOnInvalidMessage");c(NF,"fallbackOnInvalidMessage");function LF(t,e){console.warn("Unhandled notification",e)}s(LF,"fallbackOnNotification");c(LF,"fallbackOnNotification");function UF(t,e={}){let r=e.onHandlerError??FF,n=e.onInvalidMessage??NF,i=e.onNotification??LF,o={};function a(f,l){if(l.method===kF){let u=l.params?.id;u!=null&&o[u]?.abort()}else i(f,l)}return s(a,"handleNotification"),c(a,"handleNotification"),c(s(async function(l,u){let h=u.id;if(u.jsonrpc!=="2.0"||u.method==null)return h==null?(n(l,u),null):N5(h,hs.INVALID_REQUEST);let g=t[u.method];if(g==null)return h==null?(a(l,u),null):N5(h,hs.METHOD_NOT_FOUND);try{let x;if(h!=null&&g[hte]){let E=new AbortController;o[h]=E,x=g(l,u.params,{signal:E.signal})}else x=g(l,u.params,{});let _=x==null?x:typeof x.then=="function"?await x:x;return h==null||o[h]?.signal.aborted?null:{jsonrpc:"2.0",id:h,result:_}}catch(x){if(h==null||o[h]?.signal.aborted)return r(l,u,x),null;let _;if(x instanceof Jf)_=x.toObject();else{r(l,u,x);let E=x.code??-32e3;_={code:E,message:x.message||Ov(E)}}return{jsonrpc:"2.0",id:h,error:_}}finally{h!=null&&delete o[h]}},"handleRequest"),"handleRequest")}s(UF,"createHandler");c(UF,"createHandler");Ga();var mte=wr(VY(),1),Gi=wr(gh(),1),gte=`
|
|
660
660
|
sign-in-with-ethereum =
|
|
661
661
|
domain %s" wants you to sign in with your Ethereum account:" LF
|
|
662
662
|
address LF
|
|
@@ -818,9 +818,9 @@ HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
|
|
|
818
818
|
|
|
819
819
|
`)),[i,u].join(`
|
|
820
820
|
|
|
821
|
-
`)}s(zF,"asString");c(zF,"asString");var L5=s(class extends qF{toMessage(){return super.toMessage("Ethereum")}signMessage(){let t;switch(this.type){case A2.PERSONAL_SIGNATURE:{t=this.toMessage();break}default:{t=this.toMessage();break}}return t}},"SiweMessage");c(L5,"SiweMessage");cv();var _te=5*60,Npe=new Date("2022-09-20").valueOf(),E2;(function(t){function e(f){let l={h:{t:"eip4361"},p:{domain:f.domain,iat:f.issuedAt,iss:`did:pkh:eip155:${f.chainId}:${f.address}`,aud:f.uri,version:f.version,nonce:f.nonce}};return f.signature&&(l.s={t:"eip191",s:f.signature}),f.notBefore&&(l.p.nbf=f.notBefore),f.expirationTime&&(l.p.exp=f.expirationTime),f.statement&&(l.p.statement=f.statement),f.requestId&&(l.p.requestId=f.requestId),f.resources&&(l.p.resources=f.resources),l}s(e,"fromSiweMessage"),c(e,"fromSiweMessage"),t.fromSiweMessage=e;function r(f){let l={h:{t:"caip122"},p:{domain:f.domain,iat:f.issuedAt,iss:`did:pkh:solana:${f.chainId}:${f.address}`,aud:f.uri,version:f.version,nonce:f.nonce}};return f.signature&&(l.s={t:"solana:ed25519",s:f.signature}),f.notBefore&&(l.p.nbf=f.notBefore),f.expirationTime&&(l.p.exp=f.expirationTime),f.statement&&(l.p.statement=f.statement),f.requestId&&(l.p.requestId=f.requestId),f.resources&&(l.p.resources=f.resources),l}s(r,"fromSiwsMessage"),c(r,"fromSiwsMessage"),t.fromSiwsMessage=r;function n(f){let l={h:{t:"caip122"},p:{domain:f.domain,iat:f.issuedAt,iss:`did:pkh:tezos:${f.chainId}:${f.address}`,aud:f.uri,version:f.version,nonce:f.nonce}};return f.signature&&(l.s={t:"tezos:ed25519",s:f.signature}),f.notBefore&&(l.p.nbf=f.notBefore),f.expirationTime&&(l.p.exp=f.expirationTime),f.statement&&(l.p.statement=f.statement),f.requestId&&(l.p.requestId=f.requestId),f.resources&&(l.p.resources=f.resources),l}s(n,"fromSiwTezosMessage"),c(n,"fromSiwTezosMessage"),t.fromSiwTezosMessage=n;function i(f){let l={h:{t:"caip122"},p:{domain:f.domain,iat:f.issuedAt,iss:`did:pkh:stacks:${f.chainId}:${f.address}`,aud:f.uri,version:f.version,nonce:f.nonce}};return f.signature&&(l.s={t:"stacks:secp256k1",s:f.signature}),f.notBefore&&(l.p.nbf=f.notBefore),f.expirationTime&&(l.p.exp=f.expirationTime),f.statement&&(l.p.statement=f.statement),f.requestId&&(l.p.requestId=f.requestId),f.resources&&(l.p.resources=f.resources),l}s(i,"fromSiwStacksMessage"),c(i,"fromSiwStacksMessage"),t.fromSiwStacksMessage=i;async function o(f){return(await Vee({bytes:f,codec:bh,hasher:dh})).value}s(o,"fromBlockBytes"),c(o,"fromBlockBytes"),t.fromBlockBytes=o;async function a(f,l={}){Hx(f);let u=l.verifiers[f.s.t];if(!u)throw new Error("Unsupported CACAO signature type, register the needed verifier");return u(f,l)}s(a,"verify4"),c(a,"verify"),t.verify=a})(E2||(E2={}));var C2;(function(t){function e(r){return _v({value:r,codec:bh,hasher:dh})}s(e,"fromCacao"),c(e,"fromCacao"),t.fromCacao=e})(C2||(C2={}));function Hx(t){if(t.s===null||t.s===void 0)throw new Error("CACAO does not have a signature")}s(Hx,"assertSigned");c(Hx,"assertSigned");function $F(t,e){let r=e.atTime?e.atTime.getTime():Date.now(),n=(e.clockSkewSecs??_te)*1e3;if(Date.parse(t.p.iat)>r+n||Date.parse(t.p.nbf)>r+n)throw new Error("CACAO is not valid yet");let i=e.revocationPhaseOutSecs?e.revocationPhaseOutSecs*1e3:0;if(!e.disableExpirationCheck&&Date.parse(t.p.exp)+i+n<r)throw new Error("CACAO has expired")}s($F,"verifyTimeChecks");c($F,"verifyTimeChecks");var Ate="logger/5.7.0",RM=!1,BM=!1,Hb={debug:1,default:2,info:2,warning:3,error:4,off:5},DM=Hb.default,V4=null;function GF(){try{let t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}s(GF,"_checkNormalize");c(GF,"_checkNormalize");var PM=GF(),U5;(function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"})(U5||(U5={}));var jo;(function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"})(jo||(jo={}));var OM="0123456789abcdef",Lr=s(class{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){let r=t.toLowerCase();Hb[r]==null&&this.throwArgumentError("invalid log level name","logLevel",t),!(DM>Hb[r])&&console.log.apply(console,e)}debug(...t){this._log(Lr.levels.DEBUG,t)}info(...t){this._log(Lr.levels.INFO,t)}warn(...t){this._log(Lr.levels.WARNING,t)}makeError(t,e,r){if(BM)return this.makeError("censored error",e,{});e||(e=Lr.errors.UNKNOWN_ERROR),r||(r={});let n=[];Object.keys(r).forEach(f=>{let l=r[f];try{if(l instanceof Uint8Array){let u="";for(let h=0;h<l.length;h++)u+=OM[l[h]>>4],u+=OM[l[h]&15];n.push(f+"=Uint8Array(0x"+u+")")}else n.push(f+"="+JSON.stringify(l))}catch{n.push(f+"="+JSON.stringify(r[f].toString()))}}),n.push(`code=${e}`),n.push(`version=${this.version}`);let i=t,o="";switch(e){case jo.NUMERIC_FAULT:{o="NUMERIC_FAULT";let f=t;switch(f){case"overflow":case"underflow":case"division-by-zero":o+="-"+f;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case jo.CALL_EXCEPTION:case jo.INSUFFICIENT_FUNDS:case jo.MISSING_NEW:case jo.NONCE_EXPIRED:case jo.REPLACEMENT_UNDERPRICED:case jo.TRANSACTION_REPLACED:case jo.UNPREDICTABLE_GAS_LIMIT:o=e;break}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(t+=" ("+n.join(", ")+")");let a=new Error(t);return a.reason=i,a.code=e,Object.keys(r).forEach(function(f){a[f]=r[f]}),a}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,Lr.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){t==null&&(t="platform missing String.prototype.normalize"),PM&&this.throwError("platform missing String.prototype.normalize",Lr.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:PM})}checkSafeUint53(t,e){typeof t=="number"&&(e==null&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,Lr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,Lr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r?r=": "+r:r="",t<e&&this.throwError("missing argument"+r,Lr.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,Lr.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){(t===Object||t==null)&&this.throwError("missing new",Lr.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",Lr.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):(t===Object||t==null)&&this.throwError("missing new",Lr.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return V4||(V4=new Lr(Ate)),V4}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",Lr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),RM){if(!t)return;this.globalLogger().throwError("error censorship permanent",Lr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}BM=!!t,RM=!!e}static setLogLevel(t){let e=Hb[t.toLowerCase()];if(e==null){Lr.globalLogger().warn("invalid log level - "+t);return}DM=e}static from(t){return new Lr(t)}},"Logger");c(Lr,"Logger");Lr.errors=jo;Lr.levels=U5;var Ete="bytes/5.7.0",En=new Lr(Ete);function zx(t){return!!t.toHexString}s(zx,"isHexable");c(zx,"isHexable");function Xl(t){return t.slice||(t.slice=function(){let e=Array.prototype.slice.call(arguments);return Xl(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}s(Xl,"addSlice");c(Xl,"addSlice");function KF(t){return Go(t)&&!(t.length%2)||Fv(t)}s(KF,"isBytesLike");c(KF,"isBytesLike");function j5(t){return typeof t=="number"&&t==t&&t%1===0}s(j5,"isInteger");c(j5,"isInteger");function Fv(t){if(t==null)return!1;if(t.constructor===Uint8Array)return!0;if(typeof t=="string"||!j5(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){let r=t[e];if(!j5(r)||r<0||r>=256)return!1}return!0}s(Fv,"isBytes");c(Fv,"isBytes");function Sn(t,e){if(e||(e={}),typeof t=="number"){En.checkSafeUint53(t,"invalid arrayify value");let r=[];for(;t;)r.unshift(t&255),t=parseInt(String(t/256));return r.length===0&&r.push(0),Xl(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),zx(t)&&(t=t.toHexString()),Go(t)){let r=t.substring(2);r.length%2&&(e.hexPad==="left"?r="0"+r:e.hexPad==="right"?r+="0":En.throwArgumentError("hex data is odd-length","value",t));let n=[];for(let i=0;i<r.length;i+=2)n.push(parseInt(r.substring(i,i+2),16));return Xl(new Uint8Array(n))}return Fv(t)?Xl(new Uint8Array(t)):En.throwArgumentError("invalid arrayify value","value",t)}s(Sn,"arrayify");c(Sn,"arrayify");function VF(t){let e=t.map(i=>Sn(i)),r=e.reduce((i,o)=>i+o.length,0),n=new Uint8Array(r);return e.reduce((i,o)=>(n.set(o,i),i+o.length),0),Xl(n)}s(VF,"concat3");c(VF,"concat");function WF(t,e){t=Sn(t),t.length>e&&En.throwArgumentError("value out of range","value",arguments[0]);let r=new Uint8Array(e);return r.set(t,e-t.length),Xl(r)}s(WF,"zeroPad");c(WF,"zeroPad");function Go(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}s(Go,"isHexString");c(Go,"isHexString");var W4="0123456789abcdef";function Ki(t,e){if(e||(e={}),typeof t=="number"){En.checkSafeUint53(t,"invalid hexlify value");let r="";for(;t;)r=W4[t&15]+r,t=Math.floor(t/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if(typeof t=="bigint")return t=t.toString(16),t.length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),zx(t))return t.toHexString();if(Go(t))return t.length%2&&(e.hexPad==="left"?t="0x0"+t.substring(2):e.hexPad==="right"?t+="0":En.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(Fv(t)){let r="0x";for(let n=0;n<t.length;n++){let i=t[n];r+=W4[(i&240)>>4]+W4[i&15]}return r}return En.throwArgumentError("invalid hexlify value","value",t)}s(Ki,"hexlify");c(Ki,"hexlify");function JF(t){if(typeof t!="string")t=Ki(t);else if(!Go(t)||t.length%2)return null;return(t.length-2)/2}s(JF,"hexDataLength");c(JF,"hexDataLength");function q5(t,e,r){return typeof t!="string"?t=Ki(t):(!Go(t)||t.length%2)&&En.throwArgumentError("invalid hexData","value",t),e=2+2*e,r!=null?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}s(q5,"hexDataSlice");c(q5,"hexDataSlice");function Ql(t,e){for(typeof t!="string"?t=Ki(t):Go(t)||En.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&En.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}s(Ql,"hexZeroPad");c(Ql,"hexZeroPad");function $x(t){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(KF(t)){let r=Sn(t);r.length===64?(e.v=27+(r[32]>>7),r[32]&=127,e.r=Ki(r.slice(0,32)),e.s=Ki(r.slice(32,64))):r.length===65?(e.r=Ki(r.slice(0,32)),e.s=Ki(r.slice(32,64)),e.v=r[64]):En.throwArgumentError("invalid signature string","signature",t),e.v<27&&(e.v===0||e.v===1?e.v+=27:En.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=Ki(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,e._vs!=null){let i=WF(Sn(e._vs),32);e._vs=Ki(i);let o=i[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=o:e.recoveryParam!==o&&En.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),i[0]&=127;let a=Ki(i);e.s==null?e.s=a:e.s!==a&&En.throwArgumentError("signature v mismatch _vs","signature",t)}if(e.recoveryParam==null)e.v==null?En.throwArgumentError("signature missing v and recoveryParam","signature",t):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{let i=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==i&&En.throwArgumentError("signature recoveryParam mismatch v","signature",t)}e.r==null||!Go(e.r)?En.throwArgumentError("signature missing or invalid r","signature",t):e.r=Ql(e.r,32),e.s==null||!Go(e.s)?En.throwArgumentError("signature missing or invalid s","signature",t):e.s=Ql(e.s,32);let r=Sn(e.s);r[0]>=128&&En.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);let n=Ki(r);e._vs&&(Go(e._vs)||En.throwArgumentError("signature invalid _vs","signature",t),e._vs=Ql(e._vs,32)),e._vs==null?e._vs=n:e._vs!==n&&En.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}s($x,"splitSignature");c($x,"splitSignature");var Cte=wr(oD()),Ste="bignumber/5.7.0",Ite=Cte.default.BN,Lpe=new Lr(Ste);function YF(t){return new Ite(t,36).toString(16)}s(YF,"_base36To16");c(YF,"_base36To16");var kte=wr(VB());function Nv(t){return"0x"+kte.default.keccak_256(Sn(t))}s(Nv,"keccak256");c(Nv,"keccak256");var Tte="address/5.7.0",Mp=new Lr(Tte);function H5(t){Go(t,20)||Mp.throwArgumentError("invalid address","address",t),t=t.toLowerCase();let e=t.substring(2).split(""),r=new Uint8Array(40);for(let i=0;i<40;i++)r[i]=e[i].charCodeAt(0);let n=Sn(Nv(r));for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(n[i>>1]&15)>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}s(H5,"getChecksumAddress");c(H5,"getChecksumAddress");var Mte=9007199254740991;function ZF(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}s(ZF,"log10");c(ZF,"log10");var Gx={};for(let t=0;t<10;t++)Gx[String(t)]=String(t);for(let t=0;t<26;t++)Gx[String.fromCharCode(65+t)]=String(10+t);var FM=Math.floor(ZF(Mte));function XF(t){t=t.toUpperCase(),t=t.substring(4)+t.substring(0,2)+"00";let e=t.split("").map(n=>Gx[n]).join("");for(;e.length>=FM;){let n=e.substring(0,FM);e=parseInt(n,10)%97+e.substring(n.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}s(XF,"ibanChecksum");c(XF,"ibanChecksum");function QF(t){let e=null;if(typeof t!="string"&&Mp.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))t.substring(0,2)!=="0x"&&(t="0x"+t),e=H5(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&Mp.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==XF(t)&&Mp.throwArgumentError("bad icap checksum","address",t),e=YF(t.substring(4));e.length<40;)e="0"+e;e=H5("0x"+e)}else Mp.throwArgumentError("invalid address","address",t);return e}s(QF,"getAddress");c(QF,"getAddress");var Rte="properties/5.7.0",Upe=new Lr(Rte);function Nd(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}s(Nd,"defineReadOnly");c(Nd,"defineReadOnly");var Bte="strings/5.7.0",eN=new Lr(Bte),S2;(function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"})(S2||(S2={}));var $d;(function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"})($d||($d={}));function tN(t,e,r,n,i){return eN.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)}s(tN,"errorFunc");c(tN,"errorFunc");function Kx(t,e,r,n,i){if(t===$d.BAD_PREFIX||t===$d.UNEXPECTED_CONTINUE){let o=0;for(let a=e+1;a<r.length&&r[a]>>6===2;a++)o++;return o}return t===$d.OVERRUN?r.length-e-1:0}s(Kx,"ignoreFunc");c(Kx,"ignoreFunc");function rN(t,e,r,n,i){return t===$d.OVERLONG?(n.push(i),0):(n.push(65533),Kx(t,e,r,n,i))}s(rN,"replaceFunc");c(rN,"replaceFunc");var jpe=Object.freeze({error:tN,ignore:Kx,replace:rN});function zb(t,e=S2.current){e!=S2.current&&(eN.checkNormalize(),t=t.normalize(e));let r=[];for(let n=0;n<t.length;n++){let i=t.charCodeAt(n);if(i<128)r.push(i);else if(i<2048)r.push(i>>6|192),r.push(i&63|128);else if((i&64512)==55296){n++;let o=t.charCodeAt(n);if(n>=t.length||(o&64512)!==56320)throw new Error("invalid utf-8 string");let a=65536+((i&1023)<<10)+(o&1023);r.push(a>>18|240),r.push(a>>12&63|128),r.push(a>>6&63|128),r.push(a&63|128)}else r.push(i>>12|224),r.push(i>>6&63|128),r.push(i&63|128)}return Sn(r)}s(zb,"toUtf8Bytes");c(zb,"toUtf8Bytes");var Dte=`Ethereum Signed Message:
|
|
822
|
-
`;function nN(t){return typeof t=="string"&&(t=zb(t)),Nv(VF([zb(Dte),zb(String(t.length)),t]))}s(nN,"hashMessage");c(nN,"hashMessage");var Qt=wr(oD()),Bc=wr(dv());function bu(t,e,r){return r={path:e,exports:{},require:function(n,i){return iN(n,i??r.path)}},t(r,r.exports),r.exports}s(bu,"createCommonjsModule");c(bu,"createCommonjsModule");function iN(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}s(iN,"commonjsRequire");c(iN,"commonjsRequire");var Vx=Wx;function Wx(t,e){if(!t)throw new Error(e||"Assertion failed")}s(Wx,"assert");c(Wx,"assert");Wx.equal=c(s(function(e,r,n){if(e!=r)throw new Error(n||"Assertion failed: "+e+" != "+r)},"assertEqual"),"assertEqual");var zo=bu(function(t,e){"use strict";var r=e;function n(a,f){if(Array.isArray(a))return a.slice();if(!a)return[];var l=[];if(typeof a!="string"){for(var u=0;u<a.length;u++)l[u]=a[u]|0;return l}if(f==="hex"){a=a.replace(/[^a-z0-9]+/ig,""),a.length%2!==0&&(a="0"+a);for(var u=0;u<a.length;u+=2)l.push(parseInt(a[u]+a[u+1],16))}else for(var u=0;u<a.length;u++){var h=a.charCodeAt(u),g=h>>8,x=h&255;g?l.push(g,x):l.push(x)}return l}s(n,"toArray"),c(n,"toArray"),r.toArray=n;function i(a){return a.length===1?"0"+a:a}s(i,"zero2"),c(i,"zero2"),r.zero2=i;function o(a){for(var f="",l=0;l<a.length;l++)f+=i(a[l].toString(16));return f}s(o,"toHex"),c(o,"toHex"),r.toHex=o,r.encode=c(s(function(f,l){return l==="hex"?o(f):f},"encode16"),"encode")}),qs=bu(function(t,e){"use strict";var r=e;r.assert=Vx,r.toArray=zo.toArray,r.zero2=zo.zero2,r.toHex=zo.toHex,r.encode=zo.encode;function n(l,u,h){var g=new Array(Math.max(l.bitLength(),h)+1);g.fill(0);for(var x=1<<u+1,_=l.clone(),E=0;E<g.length;E++){var T,B=_.andln(x-1);_.isOdd()?(B>(x>>1)-1?T=(x>>1)-B:T=B,_.isubn(T)):T=0,g[E]=T,_.iushrn(1)}return g}s(n,"getNAF2"),c(n,"getNAF"),r.getNAF=n;function i(l,u){var h=[[],[]];l=l.clone(),u=u.clone();for(var g=0,x=0,_;l.cmpn(-g)>0||u.cmpn(-x)>0;){var E=l.andln(3)+g&3,T=u.andln(3)+x&3;E===3&&(E=-1),T===3&&(T=-1);var B;(E&1)===0?B=0:(_=l.andln(7)+g&7,(_===3||_===5)&&T===2?B=-E:B=E),h[0].push(B);var F;(T&1)===0?F=0:(_=u.andln(7)+x&7,(_===3||_===5)&&E===2?F=-T:F=T),h[1].push(F),2*g===B+1&&(g=1-g),2*x===F+1&&(x=1-x),l.iushrn(1),u.iushrn(1)}return h}s(i,"getJSF2"),c(i,"getJSF"),r.getJSF=i;function o(l,u,h){var g="_"+u;l.prototype[u]=c(s(function(){return this[g]!==void 0?this[g]:this[g]=h.call(this)},"cachedProperty2"),"cachedProperty")}s(o,"cachedProperty"),c(o,"cachedProperty"),r.cachedProperty=o;function a(l){return typeof l=="string"?r.toArray(l,"hex"):l}s(a,"parseBytes"),c(a,"parseBytes"),r.parseBytes=a;function f(l){return new Qt.default(l,"hex","le")}s(f,"intFromLE"),c(f,"intFromLE"),r.intFromLE=f}),I2=qs.getNAF,Pte=qs.getJSF,k2=qs.assert;function Gc(t,e){this.type=t,this.p=new Qt.default(e.p,16),this.red=e.prime?Qt.default.red(e.prime):Qt.default.mont(this.p),this.zero=new Qt.default(0).toRed(this.red),this.one=new Qt.default(1).toRed(this.red),this.two=new Qt.default(2).toRed(this.red),this.n=e.n&&new Qt.default(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}s(Gc,"BaseCurve");c(Gc,"BaseCurve");var vu=Gc;Gc.prototype.point=c(s(function(){throw new Error("Not implemented")},"point"),"point");Gc.prototype.validate=c(s(function(){throw new Error("Not implemented")},"validate"),"validate");Gc.prototype._fixedNafMul=c(s(function(e,r){k2(e.precomputed);var n=e._getDoubles(),i=I2(r,1,this._bitLength),o=(1<<n.step+1)-(n.step%2===0?2:1);o/=3;var a=[],f,l;for(f=0;f<i.length;f+=n.step){l=0;for(var u=f+n.step-1;u>=f;u--)l=(l<<1)+i[u];a.push(l)}for(var h=this.jpoint(null,null,null),g=this.jpoint(null,null,null),x=o;x>0;x--){for(f=0;f<a.length;f++)l=a[f],l===x?g=g.mixedAdd(n.points[f]):l===-x&&(g=g.mixedAdd(n.points[f].neg()));h=h.add(g)}return h.toP()},"_fixedNafMul"),"_fixedNafMul");Gc.prototype._wnafMul=c(s(function(e,r){var n=4,i=e._getNAFPoints(n);n=i.wnd;for(var o=i.points,a=I2(r,n,this._bitLength),f=this.jpoint(null,null,null),l=a.length-1;l>=0;l--){for(var u=0;l>=0&&a[l]===0;l--)u++;if(l>=0&&u++,f=f.dblp(u),l<0)break;var h=a[l];k2(h!==0),e.type==="affine"?h>0?f=f.mixedAdd(o[h-1>>1]):f=f.mixedAdd(o[-h-1>>1].neg()):h>0?f=f.add(o[h-1>>1]):f=f.add(o[-h-1>>1].neg())}return e.type==="affine"?f.toP():f},"_wnafMul"),"_wnafMul");Gc.prototype._wnafMulAdd=c(s(function(e,r,n,i,o){var a=this._wnafT1,f=this._wnafT2,l=this._wnafT3,u=0,h,g,x;for(h=0;h<i;h++){x=r[h];var _=x._getNAFPoints(e);a[h]=_.wnd,f[h]=_.points}for(h=i-1;h>=1;h-=2){var E=h-1,T=h;if(a[E]!==1||a[T]!==1){l[E]=I2(n[E],a[E],this._bitLength),l[T]=I2(n[T],a[T],this._bitLength),u=Math.max(l[E].length,u),u=Math.max(l[T].length,u);continue}var B=[r[E],null,null,r[T]];r[E].y.cmp(r[T].y)===0?(B[1]=r[E].add(r[T]),B[2]=r[E].toJ().mixedAdd(r[T].neg())):r[E].y.cmp(r[T].y.redNeg())===0?(B[1]=r[E].toJ().mixedAdd(r[T]),B[2]=r[E].add(r[T].neg())):(B[1]=r[E].toJ().mixedAdd(r[T]),B[2]=r[E].toJ().mixedAdd(r[T].neg()));var F=[-3,-1,-5,-7,0,7,5,1,3],H=Pte(n[E],n[T]);for(u=Math.max(H[0].length,u),l[E]=new Array(u),l[T]=new Array(u),g=0;g<u;g++){var U=H[0][g]|0,q=H[1][g]|0;l[E][g]=F[(U+1)*3+(q+1)],l[T][g]=0,f[E]=B}}var K=this.jpoint(null,null,null),W=this._wnafT4;for(h=u;h>=0;h--){for(var N=0;h>=0;){var G=!0;for(g=0;g<i;g++)W[g]=l[g][h]|0,W[g]!==0&&(G=!1);if(!G)break;N++,h--}if(h>=0&&N++,K=K.dblp(N),h<0)break;for(g=0;g<i;g++){var ce=W[g];ce!==0&&(ce>0?x=f[g][ce-1>>1]:ce<0&&(x=f[g][-ce-1>>1].neg()),x.type==="affine"?K=K.mixedAdd(x):K=K.add(x))}}for(h=0;h<i;h++)f[h]=null;return o?K:K.toP()},"_wnafMulAdd"),"_wnafMulAdd");function Hs(t,e){this.curve=t,this.type=e,this.precomputed=null}s(Hs,"BasePoint");c(Hs,"BasePoint");Gc.BasePoint=Hs;Hs.prototype.eq=c(s(function(){throw new Error("Not implemented")},"eq"),"eq");Hs.prototype.validate=c(s(function(){return this.curve.validate(this)},"validate2"),"validate");Gc.prototype.decodePoint=c(s(function(e,r){e=qs.toArray(e,r);var n=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*n){e[0]===6?k2(e[e.length-1]%2===0):e[0]===7&&k2(e[e.length-1]%2===1);var i=this.point(e.slice(1,1+n),e.slice(1+n,1+2*n));return i}else if((e[0]===2||e[0]===3)&&e.length-1===n)return this.pointFromX(e.slice(1,1+n),e[0]===3);throw new Error("Unknown point format")},"decodePoint"),"decodePoint");Hs.prototype.encodeCompressed=c(s(function(e){return this.encode(e,!0)},"encodeCompressed"),"encodeCompressed");Hs.prototype._encode=c(s(function(e){var r=this.curve.p.byteLength(),n=this.getX().toArray("be",r);return e?[this.getY().isEven()?2:3].concat(n):[4].concat(n,this.getY().toArray("be",r))},"_encode"),"_encode");Hs.prototype.encode=c(s(function(e,r){return qs.encode(this._encode(r),e)},"encode8"),"encode");Hs.prototype.precompute=c(s(function(e){if(this.precomputed)return this;var r={doubles:null,naf:null,beta:null};return r.naf=this._getNAFPoints(8),r.doubles=this._getDoubles(4,e),r.beta=this._getBeta(),this.precomputed=r,this},"precompute"),"precompute");Hs.prototype._hasDoubles=c(s(function(e){if(!this.precomputed)return!1;var r=this.precomputed.doubles;return r?r.points.length>=Math.ceil((e.bitLength()+1)/r.step):!1},"_hasDoubles"),"_hasDoubles");Hs.prototype._getDoubles=c(s(function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],i=this,o=0;o<r;o+=e){for(var a=0;a<e;a++)i=i.dbl();n.push(i)}return{step:e,points:n}},"_getDoubles"),"_getDoubles");Hs.prototype._getNAFPoints=c(s(function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var r=[this],n=(1<<e)-1,i=n===1?null:this.dbl(),o=1;o<n;o++)r[o]=r[o-1].add(i);return{wnd:e,points:r}},"_getNAFPoints"),"_getNAFPoints");Hs.prototype._getBeta=c(s(function(){return null},"_getBeta"),"_getBeta");Hs.prototype.dblp=c(s(function(e){for(var r=this,n=0;n<e;n++)r=r.dbl();return r},"dblp"),"dblp");var Jx=bu(function(t){typeof Object.create=="function"?t.exports=c(s(function(r,n){n&&(r.super_=n,r.prototype=Object.create(n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))},"inherits"),"inherits"):t.exports=c(s(function(r,n){if(n){r.super_=n;var i=c(function(){},"TempCtor");i.prototype=n.prototype,r.prototype=new i,r.prototype.constructor=r}},"inherits"),"inherits")}),Ote=qs.assert;function zs(t){vu.call(this,"short",t),this.a=new Qt.default(t.a,16).toRed(this.red),this.b=new Qt.default(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}s(zs,"ShortCurve");c(zs,"ShortCurve");Jx(zs,vu);var Fte=zs;zs.prototype._getEndomorphism=c(s(function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,n;if(e.beta)r=new Qt.default(e.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);r=i[0].cmp(i[1])<0?i[0]:i[1],r=r.toRed(this.red)}if(e.lambda)n=new Qt.default(e.lambda,16);else{var o=this._getEndoRoots(this.n);this.g.mul(o[0]).x.cmp(this.g.x.redMul(r))===0?n=o[0]:(n=o[1],Ote(this.g.mul(n).x.cmp(this.g.x.redMul(r))===0))}var a;return e.basis?a=e.basis.map(function(f){return{a:new Qt.default(f.a,16),b:new Qt.default(f.b,16)}}):a=this._getEndoBasis(n),{beta:r,lambda:n,basis:a}}},"_getEndomorphism"),"_getEndomorphism");zs.prototype._getEndoRoots=c(s(function(e){var r=e===this.p?this.red:Qt.default.mont(e),n=new Qt.default(2).toRed(r).redInvm(),i=n.redNeg(),o=new Qt.default(3).toRed(r).redNeg().redSqrt().redMul(n),a=i.redAdd(o).fromRed(),f=i.redSub(o).fromRed();return[a,f]},"_getEndoRoots"),"_getEndoRoots");zs.prototype._getEndoBasis=c(s(function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),n=e,i=this.n.clone(),o=new Qt.default(1),a=new Qt.default(0),f=new Qt.default(0),l=new Qt.default(1),u,h,g,x,_,E,T,B=0,F,H;n.cmpn(0)!==0;){var U=i.div(n);F=i.sub(U.mul(n)),H=f.sub(U.mul(o));var q=l.sub(U.mul(a));if(!g&&F.cmp(r)<0)u=T.neg(),h=o,g=F.neg(),x=H;else if(g&&++B===2)break;T=F,i=n,n=F,f=o,o=H,l=a,a=q}_=F.neg(),E=H;var K=g.sqr().add(x.sqr()),W=_.sqr().add(E.sqr());return W.cmp(K)>=0&&(_=u,E=h),g.negative&&(g=g.neg(),x=x.neg()),_.negative&&(_=_.neg(),E=E.neg()),[{a:g,b:x},{a:_,b:E}]},"_getEndoBasis"),"_getEndoBasis");zs.prototype._endoSplit=c(s(function(e){var r=this.endo.basis,n=r[0],i=r[1],o=i.b.mul(e).divRound(this.n),a=n.b.neg().mul(e).divRound(this.n),f=o.mul(n.a),l=a.mul(i.a),u=o.mul(n.b),h=a.mul(i.b),g=e.sub(f).sub(l),x=u.add(h).neg();return{k1:g,k2:x}},"_endoSplit"),"_endoSplit");zs.prototype.pointFromX=c(s(function(e,r){e=new Qt.default(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=n.redSqrt();if(i.redSqr().redSub(n).cmp(this.zero)!==0)throw new Error("invalid point");var o=i.fromRed().isOdd();return(r&&!o||!r&&o)&&(i=i.redNeg()),this.point(e,i)},"pointFromX"),"pointFromX");zs.prototype.validate=c(s(function(e){if(e.inf)return!0;var r=e.x,n=e.y,i=this.a.redMul(r),o=r.redSqr().redMul(r).redIAdd(i).redIAdd(this.b);return n.redSqr().redISub(o).cmpn(0)===0},"validate3"),"validate");zs.prototype._endoWnafMulAdd=c(s(function(e,r,n){for(var i=this._endoWnafT1,o=this._endoWnafT2,a=0;a<e.length;a++){var f=this._endoSplit(r[a]),l=e[a],u=l._getBeta();f.k1.negative&&(f.k1.ineg(),l=l.neg(!0)),f.k2.negative&&(f.k2.ineg(),u=u.neg(!0)),i[a*2]=l,i[a*2+1]=u,o[a*2]=f.k1,o[a*2+1]=f.k2}for(var h=this._wnafMulAdd(1,i,o,a*2,n),g=0;g<a*2;g++)i[g]=null,o[g]=null;return h},"_endoWnafMulAdd"),"_endoWnafMulAdd");function qn(t,e,r,n){vu.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new Qt.default(e,16),this.y=new Qt.default(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}s(qn,"Point");c(qn,"Point");Jx(qn,vu.BasePoint);zs.prototype.point=c(s(function(e,r,n){return new qn(this,e,r,n)},"point2"),"point");zs.prototype.pointFromJSON=c(s(function(e,r){return qn.fromJSON(this,e,r)},"pointFromJSON"),"pointFromJSON");qn.prototype._getBeta=c(s(function(){if(!!this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var r=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var n=this.curve,i=c(function(o){return n.point(o.x.redMul(n.endo.beta),o.y)},"endoMul");e.beta=r,r.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(i)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(i)}}}return r}},"_getBeta2"),"_getBeta");qn.prototype.toJSON=c(s(function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},"toJSON"),"toJSON");qn.fromJSON=c(s(function(e,r,n){typeof r=="string"&&(r=JSON.parse(r));var i=e.point(r[0],r[1],n);if(!r[2])return i;function o(f){return e.point(f[0],f[1],n)}s(o,"obj2point"),c(o,"obj2point");var a=r[2];return i.precomputed={beta:null,doubles:a.doubles&&{step:a.doubles.step,points:[i].concat(a.doubles.points.map(o))},naf:a.naf&&{wnd:a.naf.wnd,points:[i].concat(a.naf.points.map(o))}},i},"fromJSON"),"fromJSON");qn.prototype.inspect=c(s(function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},"inspect"),"inspect");qn.prototype.isInfinity=c(s(function(){return this.inf},"isInfinity"),"isInfinity");qn.prototype.add=c(s(function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var n=r.redSqr().redISub(this.x).redISub(e.x),i=r.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,i)},"add"),"add");qn.prototype.dbl=c(s(function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var r=this.curve.a,n=this.x.redSqr(),i=e.redInvm(),o=n.redAdd(n).redIAdd(n).redIAdd(r).redMul(i),a=o.redSqr().redISub(this.x.redAdd(this.x)),f=o.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,f)},"dbl"),"dbl");qn.prototype.getX=c(s(function(){return this.x.fromRed()},"getX"),"getX");qn.prototype.getY=c(s(function(){return this.y.fromRed()},"getY"),"getY");qn.prototype.mul=c(s(function(e){return e=new Qt.default(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},"mul"),"mul");qn.prototype.mulAdd=c(s(function(e,r,n){var i=[this,r],o=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,o):this.curve._wnafMulAdd(1,i,o,2)},"mulAdd"),"mulAdd");qn.prototype.jmulAdd=c(s(function(e,r,n){var i=[this,r],o=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,o,!0):this.curve._wnafMulAdd(1,i,o,2,!0)},"jmulAdd"),"jmulAdd");qn.prototype.eq=c(s(function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},"eq2"),"eq");qn.prototype.neg=c(s(function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,i=c(function(o){return o.neg()},"negate");r.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(i)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(i)}}}return r},"neg"),"neg");qn.prototype.toJ=c(s(function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e},"toJ"),"toJ");function Zn(t,e,r,n){vu.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&n===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Qt.default(0)):(this.x=new Qt.default(e,16),this.y=new Qt.default(r,16),this.z=new Qt.default(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}s(Zn,"JPoint");c(Zn,"JPoint");Jx(Zn,vu.BasePoint);zs.prototype.jpoint=c(s(function(e,r,n){return new Zn(this,e,r,n)},"jpoint"),"jpoint");Zn.prototype.toP=c(s(function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),n=this.x.redMul(r),i=this.y.redMul(r).redMul(e);return this.curve.point(n,i)},"toP"),"toP");Zn.prototype.neg=c(s(function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},"neg2"),"neg");Zn.prototype.add=c(s(function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),n=this.z.redSqr(),i=this.x.redMul(r),o=e.x.redMul(n),a=this.y.redMul(r.redMul(e.z)),f=e.y.redMul(n.redMul(this.z)),l=i.redSub(o),u=a.redSub(f);if(l.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=l.redSqr(),g=h.redMul(l),x=i.redMul(h),_=u.redSqr().redIAdd(g).redISub(x).redISub(x),E=u.redMul(x.redISub(_)).redISub(a.redMul(g)),T=this.z.redMul(e.z).redMul(l);return this.curve.jpoint(_,E,T)},"add2"),"add");Zn.prototype.mixedAdd=c(s(function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),n=this.x,i=e.x.redMul(r),o=this.y,a=e.y.redMul(r).redMul(this.z),f=n.redSub(i),l=o.redSub(a);if(f.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=f.redSqr(),h=u.redMul(f),g=n.redMul(u),x=l.redSqr().redIAdd(h).redISub(g).redISub(g),_=l.redMul(g.redISub(x)).redISub(o.redMul(h)),E=this.z.redMul(f);return this.curve.jpoint(x,_,E)},"mixedAdd"),"mixedAdd");Zn.prototype.dblp=c(s(function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var n=this;for(r=0;r<e;r++)n=n.dbl();return n}var i=this.curve.a,o=this.curve.tinv,a=this.x,f=this.y,l=this.z,u=l.redSqr().redSqr(),h=f.redAdd(f);for(r=0;r<e;r++){var g=a.redSqr(),x=h.redSqr(),_=x.redSqr(),E=g.redAdd(g).redIAdd(g).redIAdd(i.redMul(u)),T=a.redMul(x),B=E.redSqr().redISub(T.redAdd(T)),F=T.redISub(B),H=E.redMul(F);H=H.redIAdd(H).redISub(_);var U=h.redMul(l);r+1<e&&(u=u.redMul(_)),a=B,l=U,h=H}return this.curve.jpoint(a,h.redMul(o),l)},"dblp2"),"dblp");Zn.prototype.dbl=c(s(function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},"dbl2"),"dbl");Zn.prototype._zeroDbl=c(s(function(){var e,r,n;if(this.zOne){var i=this.x.redSqr(),o=this.y.redSqr(),a=o.redSqr(),f=this.x.redAdd(o).redSqr().redISub(i).redISub(a);f=f.redIAdd(f);var l=i.redAdd(i).redIAdd(i),u=l.redSqr().redISub(f).redISub(f),h=a.redIAdd(a);h=h.redIAdd(h),h=h.redIAdd(h),e=u,r=l.redMul(f.redISub(u)).redISub(h),n=this.y.redAdd(this.y)}else{var g=this.x.redSqr(),x=this.y.redSqr(),_=x.redSqr(),E=this.x.redAdd(x).redSqr().redISub(g).redISub(_);E=E.redIAdd(E);var T=g.redAdd(g).redIAdd(g),B=T.redSqr(),F=_.redIAdd(_);F=F.redIAdd(F),F=F.redIAdd(F),e=B.redISub(E).redISub(E),r=T.redMul(E.redISub(e)).redISub(F),n=this.y.redMul(this.z),n=n.redIAdd(n)}return this.curve.jpoint(e,r,n)},"_zeroDbl"),"_zeroDbl");Zn.prototype._threeDbl=c(s(function(){var e,r,n;if(this.zOne){var i=this.x.redSqr(),o=this.y.redSqr(),a=o.redSqr(),f=this.x.redAdd(o).redSqr().redISub(i).redISub(a);f=f.redIAdd(f);var l=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),u=l.redSqr().redISub(f).redISub(f);e=u;var h=a.redIAdd(a);h=h.redIAdd(h),h=h.redIAdd(h),r=l.redMul(f.redISub(u)).redISub(h),n=this.y.redAdd(this.y)}else{var g=this.z.redSqr(),x=this.y.redSqr(),_=this.x.redMul(x),E=this.x.redSub(g).redMul(this.x.redAdd(g));E=E.redAdd(E).redIAdd(E);var T=_.redIAdd(_);T=T.redIAdd(T);var B=T.redAdd(T);e=E.redSqr().redISub(B),n=this.y.redAdd(this.z).redSqr().redISub(x).redISub(g);var F=x.redSqr();F=F.redIAdd(F),F=F.redIAdd(F),F=F.redIAdd(F),r=E.redMul(T.redISub(e)).redISub(F)}return this.curve.jpoint(e,r,n)},"_threeDbl"),"_threeDbl");Zn.prototype._dbl=c(s(function(){var e=this.curve.a,r=this.x,n=this.y,i=this.z,o=i.redSqr().redSqr(),a=r.redSqr(),f=n.redSqr(),l=a.redAdd(a).redIAdd(a).redIAdd(e.redMul(o)),u=r.redAdd(r);u=u.redIAdd(u);var h=u.redMul(f),g=l.redSqr().redISub(h.redAdd(h)),x=h.redISub(g),_=f.redSqr();_=_.redIAdd(_),_=_.redIAdd(_),_=_.redIAdd(_);var E=l.redMul(x).redISub(_),T=n.redAdd(n).redMul(i);return this.curve.jpoint(g,E,T)},"_dbl"),"_dbl");Zn.prototype.trpl=c(s(function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),r=this.y.redSqr(),n=this.z.redSqr(),i=r.redSqr(),o=e.redAdd(e).redIAdd(e),a=o.redSqr(),f=this.x.redAdd(r).redSqr().redISub(e).redISub(i);f=f.redIAdd(f),f=f.redAdd(f).redIAdd(f),f=f.redISub(a);var l=f.redSqr(),u=i.redIAdd(i);u=u.redIAdd(u),u=u.redIAdd(u),u=u.redIAdd(u);var h=o.redIAdd(f).redSqr().redISub(a).redISub(l).redISub(u),g=r.redMul(h);g=g.redIAdd(g),g=g.redIAdd(g);var x=this.x.redMul(l).redISub(g);x=x.redIAdd(x),x=x.redIAdd(x);var _=this.y.redMul(h.redMul(u.redISub(h)).redISub(f.redMul(l)));_=_.redIAdd(_),_=_.redIAdd(_),_=_.redIAdd(_);var E=this.z.redAdd(f).redSqr().redISub(n).redISub(l);return this.curve.jpoint(x,_,E)},"trpl"),"trpl");Zn.prototype.mul=c(s(function(e,r){return e=new Qt.default(e,r),this.curve._wnafMul(this,e)},"mul2"),"mul");Zn.prototype.eq=c(s(function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var r=this.z.redSqr(),n=e.z.redSqr();if(this.x.redMul(n).redISub(e.x.redMul(r)).cmpn(0)!==0)return!1;var i=r.redMul(this.z),o=n.redMul(e.z);return this.y.redMul(o).redISub(e.y.redMul(i)).cmpn(0)===0},"eq3"),"eq");Zn.prototype.eqXToP=c(s(function(e){var r=this.z.redSqr(),n=e.toRed(this.curve.red).redMul(r);if(this.x.cmp(n)===0)return!0;for(var i=e.clone(),o=this.curve.redN.redMul(r);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(n.redIAdd(o),this.x.cmp(n)===0)return!0}},"eqXToP"),"eqXToP");Zn.prototype.inspect=c(s(function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},"inspect2"),"inspect");Zn.prototype.isInfinity=c(s(function(){return this.z.cmpn(0)===0},"isInfinity2"),"isInfinity");var $b=bu(function(t,e){"use strict";var r=e;r.base=vu,r.short=Fte,r.mont=null,r.edwards=null}),Gb=bu(function(t,e){"use strict";var r=e,n=qs.assert;function i(f){f.type==="short"?this.curve=new $b.short(f):f.type==="edwards"?this.curve=new $b.edwards(f):this.curve=new $b.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}s(i,"PresetCurve"),c(i,"PresetCurve"),r.PresetCurve=i;function o(f,l){Object.defineProperty(r,f,{configurable:!0,enumerable:!0,get:function(){var u=new i(l);return Object.defineProperty(r,f,{configurable:!0,enumerable:!0,value:u}),u}})}s(o,"defineCurve"),c(o,"defineCurve"),o("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Bc.default.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),o("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Bc.default.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),o("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Bc.default.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),o("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Bc.default.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),o("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Bc.default.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),o("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Bc.default.sha256,gRed:!1,g:["9"]}),o("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Bc.default.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var a;try{a=null.crash()}catch{a=void 0}o("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Bc.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",a]})});function Uc(t){if(!(this instanceof Uc))return new Uc(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=zo.toArray(t.entropy,t.entropyEnc||"hex"),r=zo.toArray(t.nonce,t.nonceEnc||"hex"),n=zo.toArray(t.pers,t.persEnc||"hex");Vx(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}s(Uc,"HmacDRBG");c(Uc,"HmacDRBG");var sN=Uc;Uc.prototype._init=c(s(function(e,r,n){var i=e.concat(r).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var o=0;o<this.V.length;o++)this.K[o]=0,this.V[o]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},"init3"),"init");Uc.prototype._hmac=c(s(function(){return new Bc.default.hmac(this.hash,this.K)},"hmac"),"hmac");Uc.prototype._update=c(s(function(e){var r=this._hmac().update(this.V).update([0]);e&&(r=r.update(e)),this.K=r.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},"update"),"update");Uc.prototype.reseed=c(s(function(e,r,n,i){typeof r!="string"&&(i=n,n=r,r=null),e=zo.toArray(e,r),n=zo.toArray(n,i),Vx(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this._reseed=1},"reseed"),"reseed");Uc.prototype.generate=c(s(function(e,r,n,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(i=n,n=r,r=null),n&&(n=zo.toArray(n,i||"hex"),this._update(n));for(var o=[];o.length<e;)this.V=this._hmac().update(this.V).digest(),o=o.concat(this.V);var a=o.slice(0,e);return this._update(n),this._reseed++,zo.encode(a,r)},"generate"),"generate");var z5=qs.assert;function ci(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}s(ci,"KeyPair");c(ci,"KeyPair");var Yx=ci;ci.fromPublic=c(s(function(e,r,n){return r instanceof ci?r:new ci(e,{pub:r,pubEnc:n})},"fromPublic"),"fromPublic");ci.fromPrivate=c(s(function(e,r,n){return r instanceof ci?r:new ci(e,{priv:r,privEnc:n})},"fromPrivate"),"fromPrivate");ci.prototype.validate=c(s(function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},"validate4"),"validate");ci.prototype.getPublic=c(s(function(e,r){return typeof e=="string"&&(r=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),r?this.pub.encode(r,e):this.pub},"getPublic"),"getPublic");ci.prototype.getPrivate=c(s(function(e){return e==="hex"?this.priv.toString(16,2):this.priv},"getPrivate"),"getPrivate");ci.prototype._importPrivate=c(s(function(e,r){this.priv=new Qt.default(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)},"_importPrivate"),"_importPrivate");ci.prototype._importPublic=c(s(function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?z5(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&z5(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,r)},"_importPublic"),"_importPublic");ci.prototype.derive=c(s(function(e){return e.validate()||z5(e.validate(),"public point not validated"),e.mul(this.priv).getX()},"derive"),"derive");ci.prototype.sign=c(s(function(e,r,n){return this.ec.sign(e,this,r,n)},"sign2"),"sign");ci.prototype.verify=c(s(function(e,r){return this.ec.verify(e,r,this)},"verify2"),"verify");ci.prototype.inspect=c(s(function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"},"inspect3"),"inspect");var Nte=qs.assert;function N1(t,e){if(t instanceof N1)return t;this._importDER(t,e)||(Nte(t.r&&t.s,"Signature without r or s"),this.r=new Qt.default(t.r,16),this.s=new Qt.default(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}s(N1,"Signature");c(N1,"Signature");var Lv=N1;function oN(){this.place=0}s(oN,"Position");c(oN,"Position");function Kb(t,e){var r=t[e.place++];if(!(r&128))return r;var n=r&15;if(n===0||n>4)return!1;for(var i=0,o=0,a=e.place;o<n;o++,a++)i<<=8,i|=t[a],i>>>=0;return i<=127?!1:(e.place=a,i)}s(Kb,"getLength");c(Kb,"getLength");function $5(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e<r;)e++;return e===0?t:t.slice(e)}s($5,"rmPadding");c($5,"rmPadding");N1.prototype._importDER=c(s(function(e,r){e=qs.toArray(e,r);var n=new oN;if(e[n.place++]!==48)return!1;var i=Kb(e,n);if(i===!1||i+n.place!==e.length||e[n.place++]!==2)return!1;var o=Kb(e,n);if(o===!1)return!1;var a=e.slice(n.place,o+n.place);if(n.place+=o,e[n.place++]!==2)return!1;var f=Kb(e,n);if(f===!1||e.length!==f+n.place)return!1;var l=e.slice(n.place,f+n.place);if(a[0]===0)if(a[1]&128)a=a.slice(1);else return!1;if(l[0]===0)if(l[1]&128)l=l.slice(1);else return!1;return this.r=new Qt.default(a),this.s=new Qt.default(l),this.recoveryParam=null,!0},"_importDER"),"_importDER");function Vb(t,e){if(e<128){t.push(e);return}var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}s(Vb,"constructLength");c(Vb,"constructLength");N1.prototype.toDER=c(s(function(e){var r=this.r.toArray(),n=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),n[0]&128&&(n=[0].concat(n)),r=$5(r),n=$5(n);!n[0]&&!(n[1]&128);)n=n.slice(1);var i=[2];Vb(i,r.length),i=i.concat(r),i.push(2),Vb(i,n.length);var o=i.concat(n),a=[48];return Vb(a,o.length),a=a.concat(o),qs.encode(a,e)},"toDER"),"toDER");var Lte=c(function(){throw new Error("unsupported")},"rand"),aN=qs.assert;function Ls(t){if(!(this instanceof Ls))return new Ls(t);typeof t=="string"&&(aN(Object.prototype.hasOwnProperty.call(Gb,t),"Unknown curve "+t),t=Gb[t]),t instanceof Gb.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}s(Ls,"EC");c(Ls,"EC");var Ute=Ls;Ls.prototype.keyPair=c(s(function(e){return new Yx(this,e)},"keyPair"),"keyPair");Ls.prototype.keyFromPrivate=c(s(function(e,r){return Yx.fromPrivate(this,e,r)},"keyFromPrivate"),"keyFromPrivate");Ls.prototype.keyFromPublic=c(s(function(e,r){return Yx.fromPublic(this,e,r)},"keyFromPublic"),"keyFromPublic");Ls.prototype.genKeyPair=c(s(function(e){e||(e={});for(var r=new sN({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||Lte(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new Qt.default(2));;){var o=new Qt.default(r.generate(n));if(!(o.cmp(i)>0))return o.iaddn(1),this.keyFromPrivate(o)}},"genKeyPair"),"genKeyPair");Ls.prototype._truncateToN=c(s(function(e,r){var n=e.byteLength()*8-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e},"_truncateToN"),"_truncateToN");Ls.prototype.sign=c(s(function(e,r,n,i){typeof n=="object"&&(i=n,n=null),i||(i={}),r=this.keyFromPrivate(r,n),e=this._truncateToN(new Qt.default(e,16));for(var o=this.n.byteLength(),a=r.getPrivate().toArray("be",o),f=e.toArray("be",o),l=new sN({hash:this.hash,entropy:a,nonce:f,pers:i.pers,persEnc:i.persEnc||"utf8"}),u=this.n.sub(new Qt.default(1)),h=0;;h++){var g=i.k?i.k(h):new Qt.default(l.generate(this.n.byteLength()));if(g=this._truncateToN(g,!0),!(g.cmpn(1)<=0||g.cmp(u)>=0)){var x=this.g.mul(g);if(!x.isInfinity()){var _=x.getX(),E=_.umod(this.n);if(E.cmpn(0)!==0){var T=g.invm(this.n).mul(E.mul(r.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var B=(x.getY().isOdd()?1:0)|(_.cmp(E)!==0?2:0);return i.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),B^=1),new Lv({r:E,s:T,recoveryParam:B})}}}}}},"sign3"),"sign");Ls.prototype.verify=c(s(function(e,r,n,i){e=this._truncateToN(new Qt.default(e,16)),n=this.keyFromPublic(n,i),r=new Lv(r,"hex");var o=r.r,a=r.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var f=a.invm(this.n),l=f.mul(e).umod(this.n),u=f.mul(o).umod(this.n),h;return this.curve._maxwellTrick?(h=this.g.jmulAdd(l,n.getPublic(),u),h.isInfinity()?!1:h.eqXToP(o)):(h=this.g.mulAdd(l,n.getPublic(),u),h.isInfinity()?!1:h.getX().umod(this.n).cmp(o)===0)},"verify3"),"verify");Ls.prototype.recoverPubKey=function(t,e,r,n){aN((3&r)===r,"The recovery param is more than two bits"),e=new Lv(e,n);var i=this.n,o=new Qt.default(t),a=e.r,f=e.s,l=r&1,u=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?a=this.curve.pointFromX(a.add(this.curve.n),l):a=this.curve.pointFromX(a,l);var h=e.r.invm(i),g=i.sub(o).mul(h).umod(i),x=f.mul(h).umod(i);return this.g.mulAdd(g,a,x)};Ls.prototype.getKeyRecoveryParam=function(t,e,r,n){if(e=new Lv(e,n),e.recoveryParam!==null)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch{continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var jte=bu(function(t,e){"use strict";var r=e;r.version="6.5.4",r.utils=qs,r.rand=function(){throw new Error("unsupported")},r.curve=$b,r.curves=Gb,r.ec=Ute,r.eddsa=null}),qte=jte.ec,Hte="signing-key/5.7.0",G5=new Lr(Hte),J4=null;function qo(){return J4||(J4=new qte("secp256k1")),J4}s(qo,"getCurve");c(qo,"getCurve");var cN=s(class{constructor(t){Nd(this,"curve","secp256k1"),Nd(this,"privateKey",Ki(t)),JF(this.privateKey)!==32&&G5.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let e=qo().keyFromPrivate(Sn(this.privateKey));Nd(this,"publicKey","0x"+e.getPublic(!1,"hex")),Nd(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),Nd(this,"_isSigningKey",!0)}_addPoint(t){let e=qo().keyFromPublic(Sn(this.publicKey)),r=qo().keyFromPublic(Sn(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){let e=qo().keyFromPrivate(Sn(this.privateKey)),r=Sn(t);r.length!==32&&G5.throwArgumentError("bad digest length","digest",t);let n=e.sign(r,{canonical:!0});return $x({recoveryParam:n.recoveryParam,r:Ql("0x"+n.r.toString(16),32),s:Ql("0x"+n.s.toString(16),32)})}computeSharedSecret(t){let e=qo().keyFromPrivate(Sn(this.privateKey)),r=qo().keyFromPublic(Sn(Zx(t)));return Ql("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!!(t&&t._isSigningKey)}},"SigningKey");c(cN,"SigningKey");function fN(t,e){let r=$x(e),n={r:Sn(r.r),s:Sn(r.s)};return"0x"+qo().recoverPubKey(Sn(t),n,r.recoveryParam).encode("hex",!1)}s(fN,"recoverPublicKey");c(fN,"recoverPublicKey");function Zx(t,e){let r=Sn(t);if(r.length===32){let n=new cN(r);return e?"0x"+qo().keyFromPrivate(r).getPublic(!0,"hex"):n.publicKey}else{if(r.length===33)return e?Ki(r):"0x"+qo().keyFromPublic(r).getPublic(!1,"hex");if(r.length===65)return e?"0x"+qo().keyFromPublic(r).getPublic(!0,"hex"):Ki(r)}return G5.throwArgumentError("invalid public or private key","key","[REDACTED]")}s(Zx,"computePublicKey");c(Zx,"computePublicKey");var zte="transactions/5.7.0",qpe=new Lr(zte),NM;(function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"})(NM||(NM={}));function lN(t){let e=Zx(t);return QF(q5(Nv(q5(e,1)),12))}s(lN,"computeAddress");c(lN,"computeAddress");function uN(t,e){return lN(fN(Sn(t),e))}s(uN,"recoverAddress");c(uN,"recoverAddress");var $te="wallet/5.7.0",Hpe=new Lr($te);function K5(t,e){return uN(nN(t),e)}s(K5,"verifyMessage");c(K5,"verifyMessage");function dN(){return{eip191:async(t,e)=>{hN(t,e)}}}s(dN,"getEIP191Verifier");c(dN,"getEIP191Verifier");var Gte=new Date("2022-09-20").valueOf();function hN(t,e){Hx(t),$F(t,e);let n=[K5(L5.fromCacao(t).toMessage(),t.s.s).toLowerCase()];if(Date.parse(t.p.iat)<=Gte){let o=K5(HF(L5.fromCacao(t),"Ethereum"),t.s.s).toLowerCase();n.push(o)}let i=f1.parse(t.p.iss.replace("did:pkh:","")).address.toLowerCase();if(!n.includes(i))throw new Error("Signature does not belong to issuer")}s(hN,"verifyEIP191Signature");c(hN,"verifyEIP191Signature");E1();V8();var Kte=wr(ph(),1);E1();function pN(){return en((0,Kte.randomBytes)(16),"base64")}s(pN,"randomString");c(pN,"randomString");var mN="base64pad",gN="base64url";function bN(t){return en(t,mN)}s(bN,"encodeBase64");c(bN,"encodeBase64");function vN(t){return en(t,gN)}s(vN,"encodeBase64Url");c(vN,"encodeBase64Url");function yN(t){return Zr(t,mN)}s(yN,"decodeBase64");c(yN,"decodeBase64");function Wb(t){return JSON.parse(en(Zr(t,gN)))}s(Wb,"base64urlToJSON");c(Wb,"base64urlToJSON");function xN(t){if(t.signatures.length>1)throw new Error("Cant convert to compact jws");return`${t.signatures[0].protected}.${t.payload}.${t.signatures[0].signature}`}s(xN,"fromDagJWS");c(xN,"fromDagJWS");function wN(t,e){if(e){let r=e.toISOString().split(".")[0]+"Z";return`${t}?versionTime=${r}`}else return t}s(wN,"didWithTime");c(wN,"didWithTime");function _N(t){return t?Array.isArray(t)?t:[t]:[]}s(_N,"extractControllers");c(_N,"extractControllers");var Vte={...dN()};function AN(t){return"registry"in t&&"cache"in t}s(AN,"isResolver");c(AN,"isResolver");var Xx=s(class{get capability(){if(!this._capability)throw new Error("DID has no capability attached");return this._capability}get hasCapability(){return this._capability!=null}get parent(){if(!this._parentId)throw new Error("DID has no parent DID");return this._parentId}get hasParent(){return this._parentId!=null}get id(){if(this._id==null)throw new Error("DID is not authenticated");return this._id}get authenticated(){return this._id!=null}withCapability(t){return new Xx({provider:this._client?.connection,resolver:this._resolver,capability:t,parent:this._parentId})}setProvider(t){if(this._client==null)this._client=new F5(t);else if(this._client.connection!==t)throw new Error("A different provider is already set, create a new DID instance to use another provider")}setResolver(t,e){this._resolver=AN(t)?t:new LP(t,e)}async authenticate({provider:t,paths:e=[],aud:r}={}){if(t!=null&&this.setProvider(t),this._client==null)throw new Error("No provider available");let n=pN(),i=await this._client.request("did_authenticate",{nonce:n,aud:r,paths:e}),{kid:o}=await this.verifyJWS(i),a=Wb(i.payload);if(!o.includes(a.did))throw new Error("Invalid authencation response, kid mismatch");if(a.nonce!==n)throw new Error("Invalid authencation response, wrong nonce");if(a.aud!==r)throw new Error("Invalid authencation response, wrong aud");if(a.exp<Date.now()/1e3)throw new Error("Invalid authencation response, expired");return this._id=a.did,this._id}async createJWS(t,e={}){if(this._client==null)throw new Error("No provider available");if(this._id==null)throw new Error("DID is not authenticated");if(this._capability){let n=this._capability.p.exp;if(n&&Date.parse(n)<Date.now())throw new Error("Capability is expired, cannot create a valid signature");let i=await C2.fromCacao(this._capability),o=fr.asCID(i.cid);if(!o)throw new Error("Capability CID of the JWS cannot be set to the capability payload cid as they are incompatible");e.protected=e.protected||{},e.protected.cap=`ipfs://${o?.toString()}`}let{jws:r}=await this._client.request("did_createJWS",{did:this._id,...e,payload:t});return r}async createDagJWS(t,e={}){let{cid:r,linkedBlock:n}=await wF(t),i=vN(r.bytes);Object.assign(e,{linkedBlock:bN(n)});let o=await this.createJWS(i,e),a=fr.asCID(r);if(!a)throw new Error("CID of the JWS cannot be set to the encoded payload cid as they are incompatible");if(o.link=a,this._capability){let f=await C2.fromCacao(this._capability);return{jws:o,linkedBlock:n,cacaoBlock:f.bytes}}return{jws:o,linkedBlock:n}}async verifyJWS(t,e={}){e=Object.assign({verifiers:Vte},e),typeof t!="string"&&(t=xN(t));let r=Wb(t.split(".")[0]).kid;if(!r)throw new Error('No "kid" found in jws');let n=await this.resolve(r);if(!e.disableTimecheck){let l=n.didDocumentMetadata?.nextUpdate;if(l){let h=e.revocationPhaseOutSecs?e.revocationPhaseOutSecs*1e3:0,g=new Date(l).valueOf()+h;if(!(e.atTime&&e.atTime.getTime()<g))throw new Error(`invalid_jws: signature authored with a revoked DID version: ${r}`)}let u=n.didDocumentMetadata?.updated;if(u&&e.atTime&&e.atTime.getTime()<new Date(u).valueOf())throw new Error(`invalid_jws: signature authored before creation of DID version: ${r}`)}let o=n.didDocument?.id;if(e.issuer&&e.issuer===e.capability?.p.iss&&o===e.capability.p.aud){if(!e.verifiers)throw new Error("Registered verifiers needed for CACAO");await E2.verify(e.capability,{disableExpirationCheck:e.disableTimecheck,atTime:e.atTime?e.atTime:void 0,revocationPhaseOutSecs:e.revocationPhaseOutSecs,verifiers:e.verifiers??{}})}else if(e.issuer&&e.issuer!==o){let l=wN(e.issuer,e.atTime),h=(await this.resolve(l)).didDocument?.controller,g=_N(h);if(e.capability?.s&&e.capability.p.aud===o&&g.includes(e.capability.p.iss))await E2.verify(e.capability,{atTime:e.atTime?e.atTime:void 0,revocationPhaseOutSecs:e.revocationPhaseOutSecs,verifiers:e.verifiers??{}});else if(!(o?g.includes(o):!1))throw new Error(`invalid_jws: not a valid verificationMethod for issuer: ${r}`)}let a=n.didDocument?.verificationMethod||[];eO(t,a);let f;try{f=Wb(t.split(".")[1])}catch{}return{kid:r,payload:f,didResolutionResult:n}}async createJWE(t,e,r={}){let n=await Gee(e,this._resolver);return $ee(t,n,r.protectedHeader,r.aad)}async createDagJWE(t,e,r={}){let n=await CF(t);return this.createJWE(n,e,r)}async decryptJWE(t,e={}){if(this._client==null)throw new Error("No provider available");if(this._id==null)throw new Error("DID is not authenticated");let{cleartext:r}=await this._client.request("did_decryptJWE",{did:this._id,...e,jwe:t});return yN(r)}async decryptDagJWE(t){let e=await this.decryptJWE(t);return SF(e)}async resolve(t){let e=await this._resolver.resolve(t);if(e.didResolutionMetadata.error){let{error:r,message:n}=e.didResolutionMetadata,i=n?`, ${n}`:"";throw new Error(`Failed to resolve ${t}: ${r}${i}`)}return e}constructor({provider:t,resolver:e={},resolverOptions:r,capability:n,parent:i}={}){if(t!=null&&(this._client=new F5(t)),n){if(this._capability=n,this._parentId=this._capability.p.iss,i&&this._parentId!==i)throw new Error("Capability issuer and parent not equal")}else i&&(this._parentId=i);this.setResolver(e,r)}},"DID");c(Xx,"DID");var LM=wr(pv(),1);H8();var EN={};Kr(EN,{keyToDidDoc:()=>CN});function CN(t,e){let r=`did:key:${e}`,n=`${r}#${e}`;return{id:r,verificationMethod:[{id:n,type:"Secp256k1VerificationKey2018",controller:r,publicKeyBase58:en(t,"base58btc")}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}s(CN,"keyToDidDoc");c(CN,"keyToDidDoc");var SN={};Kr(SN,{keyToDidDoc:()=>kN});E1();var Wte=wr(J8(),1);function IN(t){let e=new Uint8Array(t.length+2);return e[0]=236,e[1]=1,e.set(t,2),`z${en(e,"base58btc")}`}s(IN,"encodeKey");c(IN,"encodeKey");function kN(t,e){let r=`did:key:${e}`,n=`${r}#${e}`,i=(0,Wte.convertPublicKeyToX25519)(t),o=`${r}#${IN(i)}`;return{id:r,verificationMethod:[{id:n,type:"Ed25519VerificationKey2018",controller:r,publicKeyBase58:en(t,"base58btc")}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n],keyAgreement:[{id:o,type:"X25519KeyAgreementKey2019",controller:r,publicKeyBase58:en(i,"base58btc")}]}}s(kN,"keyToDidDoc2");c(kN,"keyToDidDoc");var TN={};Kr(TN,{keyToDidDoc:()=>HN,pubKeyBytesToXY:()=>tw});var MN={};Kr(MN,{ECPointDecompress:()=>NN});function RN(t){return t>=0?t:-t}s(RN,"abs");c(RN,"abs");function BN(t,e){if(typeof t=="number"&&(t=BigInt(t)),typeof e=="number"&&(e=BigInt(e)),t<=0n||e<=0n)throw new RangeError("a and b MUST be > 0");let r=0n,n=1n,i=1n,o=0n;for(;t!==0n;){let a=e/t,f=e%t,l=r-i*a,u=n-o*a;e=t,t=f,r=i,n=o,i=l,o=u}return{g:e,x:r,y:n}}s(BN,"eGcd");c(BN,"eGcd");function T2(t,e){if(typeof t=="number"&&(t=BigInt(t)),typeof e=="number"&&(e=BigInt(e)),e<=0n)throw new RangeError("n must be > 0");let r=t%e;return r<0n?r+e:r}s(T2,"toZn");c(T2,"toZn");function DN(t,e){let r=BN(T2(t,e),e);if(r.g!==1n)throw new RangeError(`${t.toString()} does not have inverse modulo ${e.toString()}`);return T2(r.x,e)}s(DN,"modInv");c(DN,"modInv");function L1(t,e,r){if(typeof t=="number"&&(t=BigInt(t)),typeof e=="number"&&(e=BigInt(e)),typeof r=="number"&&(r=BigInt(r)),r<=0n)throw new RangeError("n must be > 0");if(r===1n)return 0n;if(t=T2(t,r),e<0n)return DN(L1(t,RN(e),r),r);let n=1n;for(;e>0;)e%2n===1n&&(n=n*t%r),e=e/2n,t=t**2n%r;return n}s(L1,"modPow");c(L1,"modPow");var ps={};Kr(ps,{pubKeyBytesToHex:()=>PN,publicKeyHexToUint8ArrayPointPair:()=>Qx,publicKeyIntToUint8ArrayPointPair:()=>ew,publicKeyIntToXY:()=>FN,publicKeyToXY:()=>ON,testHexString:()=>Uv,testUint8Array:()=>Eh});z8();function PN(t){if(!Eh(t))throw new TypeError("input must be a Uint8Array");return en(t,"base16")}s(PN,"pubKeyBytesToHex");c(PN,"pubKeyBytesToHex");function ON(t){if(!Uv(t))throw new TypeError("input must be string with characters 0-9,A-F,a-f");let e=Qx(t),r=Wd.encode(e.xOctet).slice(1),n=Wd.encode(e.yOctet).slice(1);return{xm:r,ym:n}}s(ON,"publicKeyToXY");c(ON,"publicKeyToXY");function Qx(t){if(!Uv(t))throw new TypeError("input must be string with characters 0-9,A-F,a-f");let e=t.slice(0,t.length/2),r=t.slice(t.length/2,t.length),n=Zr(e,"base16"),i=Zr(r,"base16");return{xOctet:n,yOctet:i}}s(Qx,"publicKeyHexToUint8ArrayPointPair");c(Qx,"publicKeyHexToUint8ArrayPointPair");function Uv(t){let e=/^[A-Fa-f0-9]+$/i;return!!(e.exec(t)!==null&&e.test(t)&&typeof t=="string")}s(Uv,"testHexString");c(Uv,"testHexString");function Eh(t){return t==null?!1:t.constructor===Uint8Array}s(Eh,"testUint8Array");c(Eh,"testUint8Array");function FN(t){if(t==null)throw new TypeError("input cannot be null or undefined.");if(typeof t!="object")throw new TypeError("Input must be an object with properties x and y");if(!Object.prototype.hasOwnProperty.call(t,"x")||!Object.prototype.hasOwnProperty.call(t,"y"))throw new Error("Input must have properties x and y");if(typeof t.x!="bigint"&&typeof t.y!="bigint")throw new Error("Input coordinates must be BigInt");let e=ew(t),r=Wd.encode(e.xOctet).slice(1),n=Wd.encode(e.yOctet).slice(1);return{xm:r,ym:n}}s(FN,"publicKeyIntToXY");c(FN,"publicKeyIntToXY");function ew(t){if(t==null)throw new TypeError("input cannot be null or undefined.");if(typeof t!="object")throw new TypeError("Input must be an object with properties x and y");if(!Object.prototype.hasOwnProperty.call(t,"x")||!Object.prototype.hasOwnProperty.call(t,"y"))throw new Error("Input must have properties x and y");if(typeof t.x!="bigint"&&typeof t.y!="bigint")throw new Error("Input coordinates must be BigInt");let e=t.x.toString(),r=t.y.toString(),n=Zr(e,"base10"),i=Zr(r,"base10");return{xOctet:n,yOctet:i}}s(ew,"publicKeyIntToUint8ArrayPointPair");c(ew,"publicKeyIntToUint8ArrayPointPair");function NN(t){if(!Eh(t))throw new TypeError("input must be a Uint8Array");let e=BigInt(2),r=e**256n-e**224n+e**192n+e**96n-1n,n=41058363725152142129326129780047268409114441015993725554835256314039467401291n,i=(r+1n)/4n,o=BigInt(t[0]-2),a=t.subarray(1),f=BigInt(en(a,"base10")),l=f**3n-f*3n+n,u=L1(l,i,r);return u%2n!==o&&(u=r-u),{x:f,y:u}}s(NN,"ECPointDecompress");c(NN,"ECPointDecompress");var LN={};Kr(LN,{ECPointDecompress:()=>UN});function UN(t){if(!Eh(t))throw new TypeError("input must be a Uint8Array");let e=BigInt(2),r=e**384n-e**128n-e**96n+e**32n-1n,n=27580193559959705877849011840389048093056905856361568521428707301988689241309860865136260764883745107765439761230575n,i=(r+1n)/4n,o=BigInt(t[0]-2),a=t.subarray(1),f=BigInt(en(a,"base10")),l=f**3n-f*3n+n,u=L1(l,i,r);return u%2n!==o&&(u=r-u),{x:f,y:u}}s(UN,"ECPointDecompress2");c(UN,"ECPointDecompress");var jN={};Kr(jN,{ECPointDecompress:()=>qN});function qN(t){if(!Eh(t))throw new TypeError("input must be a Uint8Array");let r=BigInt(2)**521n-1n,n=1093849038073734274511112390766805569936207598951683748994586394495953116150735016013708737573759623248592132296706313309438452531591012912142327488478985984n,i=(r+1n)/4n,o=BigInt(t[0]-2),a=t.subarray(1),f=BigInt(en(a,"base10")),l=f**3n-f*3n+n,u=L1(l,i,r);return u%2n!==o&&(u=r-u),{x:f,y:u}}s(qN,"ECPointDecompress3");c(qN,"ECPointDecompress");function HN(t,e){let r=`did:key:${e}`,n=`${r}#${e}`,i=tw(t);return{id:r,verificationMethod:[{id:n,type:"JsonWebKey2020",controller:r,publicKeyJwk:{kty:"EC",crv:"P-256",x:i.xm,y:i.ym}}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}s(HN,"keyToDidDoc3");c(HN,"keyToDidDoc");function tw(t){if(!ps.testUint8Array(t))throw new TypeError("input must be a Uint8Array");let e=ps.pubKeyBytesToHex(t),r=e.length/2;if(r==64)return ps.publicKeyToXY(e);if(r==65&&e.slice(0,2)=="04"){let n=e.slice(2);return ps.publicKeyToXY(n)}if(r==33&&(e.slice(0,2)=="03"||e.slice(0,2)=="02")){let n=Zr(e,"base16"),i=MN.ECPointDecompress(n);return ps.publicKeyIntToXY(i)}throw new Error("Unexpected pubKeyBytes")}s(tw,"pubKeyBytesToXY");c(tw,"pubKeyBytesToXY");var zN={};Kr(zN,{keyToDidDoc:()=>$N,pubKeyBytesToXY:()=>rw});function $N(t,e){let r=`did:key:${e}`,n=`${r}#${e}`,i=rw(t);return{id:r,verificationMethod:[{id:n,type:"JsonWebKey2020",controller:r,publicKeyJwk:{kty:"EC",crv:"P-384",x:i.xm,y:i.ym}}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}s($N,"keyToDidDoc4");c($N,"keyToDidDoc");function rw(t){if(!ps.testUint8Array(t))throw new TypeError("input must be a Uint8Array");let e=ps.pubKeyBytesToHex(t),r=e.length/2;if(r==96)return ps.publicKeyToXY(e);if(r==97&&e.slice(0,2)=="04"){let n=e.slice(2);return ps.publicKeyToXY(n)}if(r==49&&(e.slice(0,2)=="03"||e.slice(0,2)=="02")){let n=Zr(e,"base16"),i=LN.ECPointDecompress(n);return ps.publicKeyIntToXY(i)}throw new Error("Unexpected pubKeyBytes")}s(rw,"pubKeyBytesToXY2");c(rw,"pubKeyBytesToXY");var GN={};Kr(GN,{keyToDidDoc:()=>KN,pubKeyBytesToXY:()=>nw});function KN(t,e){let r=`did:key:${e}`,n=`${r}#${e}`,i=nw(t);return{id:r,verificationMethod:[{id:n,type:"JsonWebKey2020",controller:r,publicKeyJwk:{kty:"EC",crv:"P-521",x:i.xm,y:i.ym}}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}s(KN,"keyToDidDoc5");c(KN,"keyToDidDoc");function nw(t){if(!ps.testUint8Array(t))throw new TypeError("input must be a Uint8Array");let e=ps.pubKeyBytesToHex(t);if(132<=e.length&&e.length<=134&&(e.slice(0,2)=="03"||e.slice(0,2)=="02")){let r=Zr(e,"base16"),n=jN.ECPointDecompress(r);return ps.publicKeyIntToXY(n)}throw new Error("Unexpected pubKeyBytes")}s(nw,"pubKeyBytesToXY3");c(nw,"pubKeyBytesToXY");var Jte="application/did+ld+json",UM="application/did+json",Yte={231:EN,237:SN,4608:TN,4609:zN,4610:GN};function VN(){return{key:async(t,e,r,n)=>{let i=n.accept||UM,o={didResolutionMetadata:{contentType:i},didDocument:null,didDocumentMetadata:{}};try{let a=Uo.decode(e.id),f=LM.default.decode(a),l=a.slice(LM.default.decode.bytes),u=await Yte[f].keyToDidDoc(l,e.id);i===Jte?(u["@context"]="https://w3id.org/did/v1",o.didDocument=u):i===UM?o.didDocument=u:(delete o.didResolutionMetadata.contentType,o.didResolutionMetadata.error="representationNotSupported")}catch(a){o.didResolutionMetadata.error="invalidDid",o.didResolutionMetadata.message=a.toString()}return o}}}s(VN,"getResolver");c(VN,"getResolver");var Zte={getResolver:VN},WN=wr(J8(),1),Xte=wr(ZY(),1),Qte="base64pad";function V5(t){return JSON.parse((0,Xte.default)(t))}s(V5,"toStableObject");c(V5,"toStableObject");function JN(t){let e=new Uint8Array(t.length+2);return e[0]=237,e[1]=1,e.set(t,2),`did:key:z${en(e,"base58btc")}`}s(JN,"encodeDID");c(JN,"encodeDID");function W5(t){let[e,r,n]=t.split(".");return{payload:r,signatures:[{protected:e,signature:n}]}}s(W5,"toGeneralJWS");c(W5,"toGeneralJWS");var jM=c(async(t,e,r,n={})=>{let i=`${e}#${e.split(":")[2]}`,o=JP(r),a=V5(Object.assign(n,{kid:i,alg:"EdDSA"}));return qee(typeof t=="string"?t:V5(t),o,a)},"sign"),ere={did_authenticate:async({did:t,secretKey:e},r)=>{let n=await jM({did:t,aud:r.aud,nonce:r.nonce,paths:r.paths,exp:Math.floor(Date.now()/1e3)+600},t,e);return W5(n)},did_createJWS:async({did:t,secretKey:e},r)=>{if(r.did.split("#")[0]!==t)throw new Jf(4100,`Unknown DID: ${t}`);let i=await jM(r.payload,t,e,r.protected);return{jws:W5(i)}},did_decryptJWE:async({secretKey:t},e)=>{let r=cO((0,WN.convertSecretKeyToX25519)(t));try{let n=await zee(e.jwe,r);return{cleartext:en(n,Qte)}}catch(n){throw new Jf(-32e3,n.message)}}},YN=s(class{constructor(t){let{secretKey:e,publicKey:r}=(0,WN.generateKeyPairFromSeed)(t),n=JN(r),i=UF(ere);this._handle=async o=>await i({did:n,secretKey:e},o)}get isDidProvider(){return!0}async send(t){return await this._handle(t)}},"Ed25519Provider");c(YN,"Ed25519Provider");var ZN={};Kr(ZN,{JsonPatchError:()=>yn,_areEquals:()=>ah,applyOperation:()=>Uf,applyPatch:()=>jv,applyReducer:()=>QN,deepClone:()=>nre,getValueByPointer:()=>l1,validate:()=>sw,validator:()=>u1});var tre=function(){var t=c(function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)i.hasOwnProperty(o)&&(n[o]=i[o])},t(e,r)},"extendStatics");return function(e,r){t(e,r);function n(){this.constructor=e}s(n,"__"),c(n,"__"),e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),rre=Object.prototype.hasOwnProperty;function M2(t,e){return rre.call(t,e)}s(M2,"hasOwnProperty");c(M2,"hasOwnProperty");function R2(t){if(Array.isArray(t)){for(var e=new Array(t.length),r=0;r<e.length;r++)e[r]=""+r;return e}if(Object.keys)return Object.keys(t);var n=[];for(var i in t)M2(t,i)&&n.push(i);return n}s(R2,"_objectKeys");c(R2,"_objectKeys");function ms(t){switch(typeof t){case"object":return JSON.parse(JSON.stringify(t));case"undefined":return null;default:return t}}s(ms,"_deepClone");c(ms,"_deepClone");function B2(t){for(var e=0,r=t.length,n;e<r;){if(n=t.charCodeAt(e),n>=48&&n<=57){e++;continue}return!1}return!0}s(B2,"isInteger2");c(B2,"isInteger");function Ff(t){return t.indexOf("/")===-1&&t.indexOf("~")===-1?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}s(Ff,"escapePathComponent");c(Ff,"escapePathComponent");function iw(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}s(iw,"unescapePathComponent");c(iw,"unescapePathComponent");function D2(t){if(t===void 0)return!0;if(t){if(Array.isArray(t)){for(var e=0,r=t.length;e<r;e++)if(D2(t[e]))return!0}else if(typeof t=="object"){for(var n=R2(t),i=n.length,o=0;o<i;o++)if(D2(t[n[o]]))return!0}}return!1}s(D2,"hasUndefined");c(D2,"hasUndefined");function J5(t,e){var r=[t];for(var n in e){var i=typeof e[n]=="object"?JSON.stringify(e[n],null,2):e[n];typeof i<"u"&&r.push(n+": "+i)}return r.join(`
|
|
823
|
-
`)}s(J5,"patchErrorMessageFormatter");c(J5,"patchErrorMessageFormatter");var XN=function(t){tre(e,t);function e(r,n,i,o,a){var f=this.constructor,l=t.call(this,J5(r,{name:n,index:i,operation:o,tree:a}))||this;return l.name=n,l.index=i,l.operation=o,l.tree=a,Object.setPrototypeOf(l,f.prototype),l.message=J5(r,{name:n,index:i,operation:o,tree:a}),l}return s(e,"PatchError2"),c(e,"PatchError"),e}(Error),yn=XN,nre=ms,qd={add:function(t,e,r){return t[e]=this.value,{newDocument:r}},remove:function(t,e,r){var n=t[e];return delete t[e],{newDocument:r,removed:n}},replace:function(t,e,r){var n=t[e];return t[e]=this.value,{newDocument:r,removed:n}},move:function(t,e,r){var n=l1(r,this.path);n&&(n=ms(n));var i=Uf(r,{op:"remove",path:this.from}).removed;return Uf(r,{op:"add",path:this.path,value:i}),{newDocument:r,removed:n}},copy:function(t,e,r){var n=l1(r,this.from);return Uf(r,{op:"add",path:this.path,value:ms(n)}),{newDocument:r}},test:function(t,e,r){return{newDocument:r,test:ah(t[e],this.value)}},_get:function(t,e,r){return this.value=t[e],{newDocument:r}}},ire={add:function(t,e,r){return B2(e)?t.splice(e,0,this.value):t[e]=this.value,{newDocument:r,index:e}},remove:function(t,e,r){var n=t.splice(e,1);return{newDocument:r,removed:n[0]}},replace:function(t,e,r){var n=t[e];return t[e]=this.value,{newDocument:r,removed:n}},move:qd.move,copy:qd.copy,test:qd.test,_get:qd._get};function l1(t,e){if(e=="")return t;var r={op:"_get",path:e};return Uf(t,r),r.value}s(l1,"getValueByPointer");c(l1,"getValueByPointer");function Uf(t,e,r,n,i,o){if(r===void 0&&(r=!1),n===void 0&&(n=!0),i===void 0&&(i=!0),o===void 0&&(o=0),r&&(typeof r=="function"?r(e,0,t,e.path):u1(e,0)),e.path===""){var a={newDocument:t};if(e.op==="add")return a.newDocument=e.value,a;if(e.op==="replace")return a.newDocument=e.value,a.removed=t,a;if(e.op==="move"||e.op==="copy")return a.newDocument=l1(t,e.from),e.op==="move"&&(a.removed=t),a;if(e.op==="test"){if(a.test=ah(t,e.value),a.test===!1)throw new yn("Test operation failed","TEST_OPERATION_FAILED",o,e,t);return a.newDocument=t,a}else{if(e.op==="remove")return a.removed=t,a.newDocument=null,a;if(e.op==="_get")return e.value=t,a;if(r)throw new yn("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",o,e,t);return a}}else{n||(t=ms(t));var f=e.path||"",l=f.split("/"),u=t,h=1,g=l.length,x=void 0,_=void 0,E=void 0;for(typeof r=="function"?E=r:E=u1;;){if(_=l[h],_&&_.indexOf("~")!=-1&&(_=iw(_)),i&&(_=="__proto__"||_=="prototype"&&h>0&&l[h-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(r&&x===void 0&&(u[_]===void 0?x=l.slice(0,h).join("/"):h==g-1&&(x=e.path),x!==void 0&&E(e,0,t,x)),h++,Array.isArray(u)){if(_==="-")_=u.length;else{if(r&&!B2(_))throw new yn("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",o,e,t);B2(_)&&(_=~~_)}if(h>=g){if(r&&e.op==="add"&&_>u.length)throw new yn("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",o,e,t);var a=ire[e.op].call(e,u,_,t);if(a.test===!1)throw new yn("Test operation failed","TEST_OPERATION_FAILED",o,e,t);return a}}else if(h>=g){var a=qd[e.op].call(e,u,_,t);if(a.test===!1)throw new yn("Test operation failed","TEST_OPERATION_FAILED",o,e,t);return a}if(u=u[_],r&&h<g&&(!u||typeof u!="object"))throw new yn("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",o,e,t)}}}s(Uf,"applyOperation");c(Uf,"applyOperation");function jv(t,e,r,n,i){if(n===void 0&&(n=!0),i===void 0&&(i=!0),r&&!Array.isArray(e))throw new yn("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(t=ms(t));for(var o=new Array(e.length),a=0,f=e.length;a<f;a++)o[a]=Uf(t,e[a],r,!0,i,a),t=o[a].newDocument;return o.newDocument=t,o}s(jv,"applyPatch");c(jv,"applyPatch");function QN(t,e,r){var n=Uf(t,e);if(n.test===!1)throw new yn("Test operation failed","TEST_OPERATION_FAILED",r,e,t);return n.newDocument}s(QN,"applyReducer");c(QN,"applyReducer");function u1(t,e,r,n){if(typeof t!="object"||t===null||Array.isArray(t))throw new yn("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,t,r);if(qd[t.op]){if(typeof t.path!="string")throw new yn("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,t,r);if(t.path.indexOf("/")!==0&&t.path.length>0)throw new yn('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,t,r);if((t.op==="move"||t.op==="copy")&&typeof t.from!="string")throw new yn("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,t,r);if((t.op==="add"||t.op==="replace"||t.op==="test")&&t.value===void 0)throw new yn("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,t,r);if((t.op==="add"||t.op==="replace"||t.op==="test")&&D2(t.value))throw new yn("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,t,r);if(r){if(t.op=="add"){var i=t.path.split("/").length,o=n.split("/").length;if(i!==o+1&&i!==o)throw new yn("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,t,r)}else if(t.op==="replace"||t.op==="remove"||t.op==="_get"){if(t.path!==n)throw new yn("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,t,r)}else if(t.op==="move"||t.op==="copy"){var a={op:"_get",path:t.from,value:void 0},f=sw([a],r);if(f&&f.name==="OPERATION_PATH_UNRESOLVABLE")throw new yn("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,t,r)}}}else throw new yn("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,t,r)}s(u1,"validator");c(u1,"validator");function sw(t,e,r){try{if(!Array.isArray(t))throw new yn("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)jv(ms(e),ms(t),r||!0);else{r=r||u1;for(var n=0;n<t.length;n++)r(t[n],n,e,void 0)}}catch(i){if(i instanceof yn)return i;throw i}}s(sw,"validate5");c(sw,"validate");function ah(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var r=Array.isArray(t),n=Array.isArray(e),i,o,a;if(r&&n){if(o=t.length,o!=e.length)return!1;for(i=o;i--!==0;)if(!ah(t[i],e[i]))return!1;return!0}if(r!=n)return!1;var f=Object.keys(t);if(o=f.length,o!==Object.keys(e).length)return!1;for(i=o;i--!==0;)if(!e.hasOwnProperty(f[i]))return!1;for(i=o;i--!==0;)if(a=f[i],!ah(t[a],e[a]))return!1;return!0}return t!==t&&e!==e}s(ah,"_areEquals");c(ah,"_areEquals");var eL={};Kr(eL,{compare:()=>oL,generate:()=>P2,observe:()=>sL,unobserve:()=>iL});var ow=new WeakMap,sre=function(){function t(e){this.observers=new Map,this.obj=e}return s(t,"Mirror2"),c(t,"Mirror"),t}(),ore=function(){function t(e,r){this.callback=e,this.observer=r}return s(t,"ObserverInfo2"),c(t,"ObserverInfo"),t}();function tL(t){return ow.get(t)}s(tL,"getMirror");c(tL,"getMirror");function rL(t,e){return t.observers.get(e)}s(rL,"getObserverFromMirror");c(rL,"getObserverFromMirror");function nL(t,e){t.observers.delete(e.callback)}s(nL,"removeObserverFromMirror");c(nL,"removeObserverFromMirror");function iL(t,e){e.unobserve()}s(iL,"unobserve");c(iL,"unobserve");function sL(t,e){var r=[],n,i=tL(t);if(!i)i=new sre(t),ow.set(t,i);else{var o=rL(i,e);n=o&&o.observer}if(n)return n;if(n={},i.value=ms(t),e){n.callback=e,n.next=null;var a=c(function(){P2(n)},"dirtyCheck"),f=c(function(){clearTimeout(n.next),n.next=setTimeout(a)},"fastCheck");typeof window<"u"&&(window.addEventListener("mouseup",f),window.addEventListener("keyup",f),window.addEventListener("mousedown",f),window.addEventListener("keydown",f),window.addEventListener("change",f))}return n.patches=r,n.object=t,n.unobserve=function(){P2(n),clearTimeout(n.next),nL(i,n),typeof window<"u"&&(window.removeEventListener("mouseup",f),window.removeEventListener("keyup",f),window.removeEventListener("mousedown",f),window.removeEventListener("keydown",f),window.removeEventListener("change",f))},i.observers.set(e,new ore(e,n)),n}s(sL,"observe");c(sL,"observe");function P2(t,e){e===void 0&&(e=!1);var r=ow.get(t.object);qv(r.value,t.object,t.patches,"",e),t.patches.length&&jv(r.value,t.patches);var n=t.patches;return n.length>0&&(t.patches=[],t.callback&&t.callback(n)),n}s(P2,"generate2");c(P2,"generate");function qv(t,e,r,n,i){if(e!==t){typeof e.toJSON=="function"&&(e=e.toJSON());for(var o=R2(e),a=R2(t),f=!1,l=!1,u=a.length-1;u>=0;u--){var h=a[u],g=t[h];if(M2(e,h)&&!(e[h]===void 0&&g!==void 0&&Array.isArray(e)===!1)){var x=e[h];typeof g=="object"&&g!=null&&typeof x=="object"&&x!=null&&Array.isArray(g)===Array.isArray(x)?qv(g,x,r,n+"/"+Ff(h),i):g!==x&&(f=!0,i&&r.push({op:"test",path:n+"/"+Ff(h),value:ms(g)}),r.push({op:"replace",path:n+"/"+Ff(h),value:ms(x)}))}else Array.isArray(t)===Array.isArray(e)?(i&&r.push({op:"test",path:n+"/"+Ff(h),value:ms(g)}),r.push({op:"remove",path:n+"/"+Ff(h)}),l=!0):(i&&r.push({op:"test",path:n,value:t}),r.push({op:"replace",path:n,value:e}),f=!0)}if(!(!l&&o.length==a.length))for(var u=0;u<o.length;u++){var h=o[u];!M2(t,h)&&e[h]!==void 0&&r.push({op:"add",path:n+"/"+Ff(h),value:ms(e[h])})}}}s(qv,"_generate");c(qv,"_generate");function oL(t,e,r){r===void 0&&(r=!1);var n=[];return qv(t,e,n,"",r),n}s(oL,"compare3");c(oL,"compare");var aL=Object.assign({},ZN,eL,{JsonPatchError:XN,deepClone:ms,escapePathComponent:Ff,unescapePathComponent:iw}),are=wr(S1(),1),cre=wr(ph(),1),bs;(function(t){t[t.PREFER_CACHE=0]="PREFER_CACHE",t[t.SYNC_ALWAYS=1]="SYNC_ALWAYS",t[t.NEVER_SYNC=2]="NEVER_SYNC"})(bs||(bs={}));var qM=wr(S1(),1);Ga();A1();var cL={tile:0,"caip10-link":1,model:2,MID:3,UNLOADABLE:4};function fL(t){let e=cL[t];if(typeof e<"u")return e;throw new Error(`No stream type registered for name ${t}`)}s(fL,"codeByName");c(fL,"codeByName");function lL(t){let e=Object.entries(cL).find(([,r])=>r===t);if(e)return e[0];throw new Error(`No stream type registered for index ${t}`)}s(lL,"nameByCode");c(lL,"nameByCode");var jc=s(class{},"StreamType");c(jc,"StreamType");jc.nameByCode=lL;jc.codeByName=fL;var HM=wr(pv(),1);function bo(t){let e,r,n;return typeof t=="object"?(e=t.hashFunction,r=t.expiring,n=t.tags):e=t,(i,o,a)=>{if(a.value!=null)a.value=Y5(a.value,e,r,n);else if(a.get!=null)a.get=Y5(a.get,e,r,n);else throw"Only put a Memoize() decorator on a method or get accessor."}}s(bo,"Memoize");c(bo,"Memoize");var Y4=new Map;function Y5(t,e,r=0,n){let i=Symbol("__memoized_map__");return function(...o){let a;this.hasOwnProperty(i)||Object.defineProperty(this,i,{configurable:!1,enumerable:!1,writable:!1,value:new Map});let f=this[i];if(Array.isArray(n))for(let l of n)Y4.has(l)?Y4.get(l).push(f):Y4.set(l,[f]);if(e||o.length>0||r>0){let l;e===!0?l=o.map(g=>g.toString()).join("!"):e?l=e.apply(this,o):l=o[0];let u=`${l}__timestamp`,h=!1;if(r>0)if(!f.has(u))h=!0;else{let g=f.get(u);h=Date.now()-g>r}f.has(l)&&!h?a=f.get(l):(a=t.apply(this,o),f.set(l,a),r>0&&f.set(u,Date.now()))}else{let l=this;f.has(l)?a=f.get(l):(a=t.apply(this,o),f.set(l,a))}return a}}s(Y5,"getNewFunction");c(Y5,"getNewFunction");var aw=206;Ga();A1();cv();var zM=wr(pv(),1);function U1(t){try{return t()}catch(e){return e}}s(U1,"tryCatch");c(U1,"tryCatch");Ga();var $M=wr(pv(),1);uh();function Wl(t){let e=$M.default.decode(t),r=$M.default.decode.bytes,n=t.subarray(r);return[e,n,r]}s(Wl,"readVarint");c(Wl,"readVarint");function uL(t){return t===0||t===1}s(uL,"isCidVersion");c(uL,"isCidVersion");function Z5(t){let[e,r]=Wl(t);if(!uL(e))throw new Error(`Unknown CID version ${e}`);let[n,i]=Wl(r),[,o,a]=Wl(i),[f,,l]=Wl(o),u=i.subarray(0,a+l+f),h=i.subarray(a+l+f);return[fr.create(e,n,G8(u)),h]}s(Z5,"readCid");c(Z5,"readCid");Ga();A1();function j1(t,e="StreamRef"){let[r,n]=Wl(t);if(r!==aw)throw new Error(`Invalid ${e}, does not include streamid codec`);let[i,o]=Wl(n),a=Z5(o),[f,l]=a;if(l.length===0)return{kind:"stream-id",type:i,genesis:f};if(l.length===1&&l[0]===0)return{kind:"commit-id",type:i,genesis:f,commit:null};{let[u]=Z5(l);return{kind:"commit-id",type:i,genesis:f,commit:u}}}s(j1,"fromBytes");c(j1,"fromBytes");var fre=/(ceramic:\/\/|\/ceramic\/)?([a-zA-Z0-9]+)(\?commit=([a-zA-Z0-9]+))?/;function Hv(t,e="StreamRef"){let r=fre.exec(t)||[],n=r[2];if(!n)throw new Error(`Malformed ${e} string: ${t}`);let i=Qf.decode(n),o=j1(i),a=r[4];return a?{kind:"commit-id",type:o.type,genesis:o.genesis,commit:cw(o.genesis,a)}:o}s(Hv,"fromString4");c(Hv,"fromString");function dL(t){try{return typeof t=="string"?fr.parse(t):fr.asCID(t)}catch{return null}}s(dL,"parseCID");c(dL,"parseCID");function cw(t,e=null){if(!e||e==="0")return null;let r=dL(e);if(r)return t.equals(r)?null:r;throw new Error("Cannot specify commit as a number except to request commit 0 (the genesis commit)")}s(cw,"parseCommit");c(cw,"parseCommit");var q1=s(function(t,e,r,n){var i=arguments.length,o=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,n);else for(var f=t.length-1;f>=0;f--)(a=t[f])&&(o=(i<3?a(o):i>3?a(e,r,o):a(e,r))||o);return i>3&&o&&Object.defineProperty(e,r,o),o},"__decorate"),po=s(function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},"__metadata"),hL=s(class extends Error{constructor(t){super(`Invalid StreamID bytes ${Qf.encode(t)}: contains commit`)}},"InvalidStreamIDBytesError");c(hL,"InvalidStreamIDBytesError");var pL=s(class extends Error{constructor(t){super(`Invalid StreamID string ${t}: contains commit`)}},"InvalidStreamIDStringError");c(pL,"InvalidStreamIDStringError");function fw(t){let e=j1(t,"StreamID");if(e.kind==="stream-id")return new xr(e.type,e.genesis);throw new hL(t)}s(fw,"fromBytes2");c(fw,"fromBytes");function mL(t){return U1(()=>fw(t))}s(mL,"fromBytesNoThrow");c(mL,"fromBytesNoThrow");function lw(t){let e=Hv(t,"StreamID");if(e.kind==="stream-id")return new xr(e.type,e.genesis);throw new pL(t)}s(lw,"fromString5");c(lw,"fromString");function gL(t){return U1(()=>lw(t))}s(gL,"fromStringNoThrow");c(gL,"fromStringNoThrow");var GM=Symbol.for("@ceramicnetwork/streamid/StreamID"),xr=s(class{constructor(t,e){if(this._tag=GM,!(t||t===0))throw new Error("StreamID constructor: type required");if(!e)throw new Error("StreamID constructor: cid required");this._type=typeof t=="string"?jc.codeByName(t):t,this._cid=typeof e=="string"?fr.parse(e):e}static isInstance(t){return typeof t=="object"&&"_tag"in t&&t._tag===GM}static async fromGenesis(t,e){let r=await _v({value:e,codec:bh,hasher:dh});return new xr(t,r.cid)}get type(){return this._type}get typeName(){return jc.nameByCode(this._type)}get cid(){return this._cid}get bytes(){let t=zM.default.encode(aw),e=zM.default.encode(this.type);return qf([t,e,this.cid.bytes])}get baseID(){return new xr(this._type,this._cid)}equals(t){return xr.isInstance(t)?this.type===t.type&&this.cid.equals(t.cid):!1}toString(){return Qf.encode(this.bytes)}toUrl(){return`ceramic://${this.toString()}`}[Symbol.for("nodejs.util.inspect.custom")](){return`StreamID(${this.toString()})`}[Symbol.toPrimitive](){return this.toString()}},"StreamID");c(xr,"StreamID");xr.fromBytes=fw;xr.fromBytesNoThrow=mL;xr.fromString=lw;xr.fromStringNoThrow=gL;q1([bo(),po("design:type",String),po("design:paramtypes",[])],xr.prototype,"typeName",null);q1([bo(),po("design:type",Uint8Array),po("design:paramtypes",[])],xr.prototype,"bytes",null);q1([bo(),po("design:type",xr),po("design:paramtypes",[])],xr.prototype,"baseID",null);q1([bo(),po("design:type",Function),po("design:paramtypes",[]),po("design:returntype",String)],xr.prototype,"toString",null);q1([bo(),po("design:type",Function),po("design:paramtypes",[]),po("design:returntype",String)],xr.prototype,"toUrl",null);var Ch=s(function(t,e,r,n){var i=arguments.length,o=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,n);else for(var f=t.length-1;f>=0;f--)(a=t[f])&&(o=(i<3?a(o):i>3?a(e,r,o):a(e,r))||o);return i>3&&o&&Object.defineProperty(e,r,o),o},"__decorate2"),gs=s(function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},"__metadata2"),Z4=s(function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},"__classPrivateFieldSet"),Mc=s(function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},"__classPrivateFieldGet"),Bd,zl,Ip,bL=s(class extends Error{constructor(t){super(`Error while parsing CommitID from bytes ${Qf.encode(t)}: no commit information provided`)}},"InvalidCommitIDBytesError");c(bL,"InvalidCommitIDBytesError");var vL=s(class extends Error{constructor(t){super(`Error while parsing CommitID from string ${t}: no commit information provided`)}},"InvalidCommitIDStringError");c(vL,"InvalidCommitIDStringError");function uw(t){let e=j1(t,"CommitID");if(e.kind==="commit-id")return new $r(e.type,e.genesis,e.commit);throw new bL(t)}s(uw,"fromBytes3");c(uw,"fromBytes");function yL(t){return U1(()=>uw(t))}s(yL,"fromBytesNoThrow2");c(yL,"fromBytesNoThrow");function dw(t){let e=Hv(t,"CommitID");if(e.kind==="commit-id")return new $r(e.type,e.genesis,e.commit);throw new vL(t)}s(dw,"fromString6");c(dw,"fromString");function xL(t){return U1(()=>dw(t))}s(xL,"fromStringNoThrow2");c(xL,"fromStringNoThrow");var KM=Symbol.for("@ceramicnetwork/streamid/CommitID");function wL(t,e){return new $r(t.type,t.cid,e)}s(wL,"make");c(wL,"make");var $r=s(class{constructor(t,e,r=null){if(this._tag=KM,Bd.set(this,void 0),zl.set(this,void 0),Ip.set(this,void 0),!t&&t!==0)throw new Error("constructor: type required");if(!e)throw new Error("constructor: cid required");Z4(this,Bd,typeof t=="string"?jc.codeByName(t):t,"f"),Z4(this,zl,typeof e=="string"?fr.parse(e):e,"f"),Z4(this,Ip,cw(Mc(this,zl,"f"),r),"f")}static isInstance(t){return typeof t=="object"&&"_tag"in t&&t._tag===KM}get baseID(){return new xr(Mc(this,Bd,"f"),Mc(this,zl,"f"))}get type(){return Mc(this,Bd,"f")}get typeName(){return jc.nameByCode(Mc(this,Bd,"f"))}get cid(){return Mc(this,zl,"f")}get commit(){return Mc(this,Ip,"f")||Mc(this,zl,"f")}get bytes(){let t=HM.default.encode(aw),e=HM.default.encode(this.type),r=Mc(this,Ip,"f")?.bytes||new Uint8Array([0]);return qf([t,e,this.cid.bytes,r])}equals(t){return this.type===t.type&&this.cid.equals(t.cid)&&this.commit.equals(t.commit)}toString(){return Qf.encode(this.bytes)}toUrl(){return`ceramic://${this.toString()}`}[(Bd=new WeakMap,zl=new WeakMap,Ip=new WeakMap,Symbol.for("nodejs.util.inspect.custom"))](){return`CommitID(${this.toString()})`}[Symbol.toPrimitive](){return this.toString()}},"CommitID");c($r,"CommitID");$r.fromBytes=uw;$r.fromBytesNoThrow=yL;$r.fromString=dw;$r.fromStringNoThrow=xL;$r.make=wL;Ch([bo(),gs("design:type",xr),gs("design:paramtypes",[])],$r.prototype,"baseID",null);Ch([bo(),gs("design:type",String),gs("design:paramtypes",[])],$r.prototype,"typeName",null);Ch([bo(),gs("design:type",fr),gs("design:paramtypes",[])],$r.prototype,"commit",null);Ch([bo(),gs("design:type",Uint8Array),gs("design:paramtypes",[])],$r.prototype,"bytes",null);Ch([bo(),gs("design:type",Function),gs("design:paramtypes",[]),gs("design:returntype",String)],$r.prototype,"toString",null);Ch([bo(),gs("design:type",Function),gs("design:paramtypes",[]),gs("design:returntype",String)],$r.prototype,"toUrl",null);A1();var Yf;(function(t){function e(i){let o=j1(i);switch(o.kind){case"commit-id":return new $r(o.type,o.genesis,o.commit);case"stream-id":return new xr(o.type,o.genesis);default:throw new Error(`Malformed StreamRef bytes: ${Qf.encode(i)}`)}}s(e,"fromBytes4"),c(e,"fromBytes"),t.fromBytes=e;function r(i){let o=Hv(i);switch(o.kind){case"commit-id":return new $r(o.type,o.genesis,o.commit);case"stream-id":return new xr(o.type,o.genesis);default:throw new Error(`Malformed StreamRef string: ${i}`)}}s(r,"fromString7"),c(r,"fromString"),t.fromString=r;function n(i){if(xr.isInstance(i)||$r.isInstance(i))return i;if(i instanceof Uint8Array)return e(i);if(typeof i=="string")return r(i);throw new Error(`Can not build CommitID or StreamID from ${JSON.stringify(i)}`)}s(n,"from4"),c(n,"from"),t.from=n})(Yf||(Yf={}));var lre=wr(XY(),1),{__extends:$s,__assign:zpe,__rest:$pe,__decorate:Gpe,__param:Kpe,__esDecorate:Vpe,__runInitializers:Wpe,__propKey:Jpe,__setFunctionName:Ype,__metadata:Zpe,__awaiter:ure,__generator:_L,__exportStar:Xpe,__createBinding:Qpe,__values:O2,__read:Zf,__spread:e1e,__spreadArrays:t1e,__spreadArray:su,__await:X4,__asyncGenerator:dre,__asyncDelegator:r1e,__asyncValues:hre,__makeTemplateObject:n1e,__importStar:i1e,__importDefault:s1e,__classPrivateFieldGet:o1e,__classPrivateFieldSet:a1e,__classPrivateFieldIn:c1e}=lre.default;function Gr(t){return typeof t=="function"}s(Gr,"isFunction");c(Gr,"isFunction");function zv(t){var e=c(function(n){Error.call(n),n.stack=new Error().stack},"_super"),r=t(e);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}s(zv,"createErrorClass");c(zv,"createErrorClass");var Q4=zv(function(t){return c(s(function(r){t(this),this.message=r?r.length+` errors occurred during unsubscription:
|
|
821
|
+
`)}s(zF,"asString");c(zF,"asString");var L5=s(class extends qF{toMessage(){return super.toMessage("Ethereum")}signMessage(){let t;switch(this.type){case A2.PERSONAL_SIGNATURE:{t=this.toMessage();break}default:{t=this.toMessage();break}}return t}},"SiweMessage");c(L5,"SiweMessage");cv();var _te=5*60,Lpe=new Date("2022-09-20").valueOf(),E2;(function(t){function e(f){let l={h:{t:"eip4361"},p:{domain:f.domain,iat:f.issuedAt,iss:`did:pkh:eip155:${f.chainId}:${f.address}`,aud:f.uri,version:f.version,nonce:f.nonce}};return f.signature&&(l.s={t:"eip191",s:f.signature}),f.notBefore&&(l.p.nbf=f.notBefore),f.expirationTime&&(l.p.exp=f.expirationTime),f.statement&&(l.p.statement=f.statement),f.requestId&&(l.p.requestId=f.requestId),f.resources&&(l.p.resources=f.resources),l}s(e,"fromSiweMessage"),c(e,"fromSiweMessage"),t.fromSiweMessage=e;function r(f){let l={h:{t:"caip122"},p:{domain:f.domain,iat:f.issuedAt,iss:`did:pkh:solana:${f.chainId}:${f.address}`,aud:f.uri,version:f.version,nonce:f.nonce}};return f.signature&&(l.s={t:"solana:ed25519",s:f.signature}),f.notBefore&&(l.p.nbf=f.notBefore),f.expirationTime&&(l.p.exp=f.expirationTime),f.statement&&(l.p.statement=f.statement),f.requestId&&(l.p.requestId=f.requestId),f.resources&&(l.p.resources=f.resources),l}s(r,"fromSiwsMessage"),c(r,"fromSiwsMessage"),t.fromSiwsMessage=r;function n(f){let l={h:{t:"caip122"},p:{domain:f.domain,iat:f.issuedAt,iss:`did:pkh:tezos:${f.chainId}:${f.address}`,aud:f.uri,version:f.version,nonce:f.nonce}};return f.signature&&(l.s={t:"tezos:ed25519",s:f.signature}),f.notBefore&&(l.p.nbf=f.notBefore),f.expirationTime&&(l.p.exp=f.expirationTime),f.statement&&(l.p.statement=f.statement),f.requestId&&(l.p.requestId=f.requestId),f.resources&&(l.p.resources=f.resources),l}s(n,"fromSiwTezosMessage"),c(n,"fromSiwTezosMessage"),t.fromSiwTezosMessage=n;function i(f){let l={h:{t:"caip122"},p:{domain:f.domain,iat:f.issuedAt,iss:`did:pkh:stacks:${f.chainId}:${f.address}`,aud:f.uri,version:f.version,nonce:f.nonce}};return f.signature&&(l.s={t:"stacks:secp256k1",s:f.signature}),f.notBefore&&(l.p.nbf=f.notBefore),f.expirationTime&&(l.p.exp=f.expirationTime),f.statement&&(l.p.statement=f.statement),f.requestId&&(l.p.requestId=f.requestId),f.resources&&(l.p.resources=f.resources),l}s(i,"fromSiwStacksMessage"),c(i,"fromSiwStacksMessage"),t.fromSiwStacksMessage=i;async function o(f){return(await Vee({bytes:f,codec:bh,hasher:dh})).value}s(o,"fromBlockBytes"),c(o,"fromBlockBytes"),t.fromBlockBytes=o;async function a(f,l={}){Hx(f);let u=l.verifiers[f.s.t];if(!u)throw new Error("Unsupported CACAO signature type, register the needed verifier");return u(f,l)}s(a,"verify4"),c(a,"verify"),t.verify=a})(E2||(E2={}));var C2;(function(t){function e(r){return _v({value:r,codec:bh,hasher:dh})}s(e,"fromCacao"),c(e,"fromCacao"),t.fromCacao=e})(C2||(C2={}));function Hx(t){if(t.s===null||t.s===void 0)throw new Error("CACAO does not have a signature")}s(Hx,"assertSigned");c(Hx,"assertSigned");function $F(t,e){let r=e.atTime?e.atTime.getTime():Date.now(),n=(e.clockSkewSecs??_te)*1e3;if(Date.parse(t.p.iat)>r+n||Date.parse(t.p.nbf)>r+n)throw new Error("CACAO is not valid yet");let i=e.revocationPhaseOutSecs?e.revocationPhaseOutSecs*1e3:0;if(!e.disableExpirationCheck&&Date.parse(t.p.exp)+i+n<r)throw new Error("CACAO has expired")}s($F,"verifyTimeChecks");c($F,"verifyTimeChecks");var Ate="logger/5.7.0",RM=!1,BM=!1,Hb={debug:1,default:2,info:2,warning:3,error:4,off:5},DM=Hb.default,V4=null;function GF(){try{let t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}s(GF,"_checkNormalize");c(GF,"_checkNormalize");var PM=GF(),U5;(function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"})(U5||(U5={}));var jo;(function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"})(jo||(jo={}));var OM="0123456789abcdef",Lr=s(class{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){let r=t.toLowerCase();Hb[r]==null&&this.throwArgumentError("invalid log level name","logLevel",t),!(DM>Hb[r])&&console.log.apply(console,e)}debug(...t){this._log(Lr.levels.DEBUG,t)}info(...t){this._log(Lr.levels.INFO,t)}warn(...t){this._log(Lr.levels.WARNING,t)}makeError(t,e,r){if(BM)return this.makeError("censored error",e,{});e||(e=Lr.errors.UNKNOWN_ERROR),r||(r={});let n=[];Object.keys(r).forEach(f=>{let l=r[f];try{if(l instanceof Uint8Array){let u="";for(let h=0;h<l.length;h++)u+=OM[l[h]>>4],u+=OM[l[h]&15];n.push(f+"=Uint8Array(0x"+u+")")}else n.push(f+"="+JSON.stringify(l))}catch{n.push(f+"="+JSON.stringify(r[f].toString()))}}),n.push(`code=${e}`),n.push(`version=${this.version}`);let i=t,o="";switch(e){case jo.NUMERIC_FAULT:{o="NUMERIC_FAULT";let f=t;switch(f){case"overflow":case"underflow":case"division-by-zero":o+="-"+f;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case jo.CALL_EXCEPTION:case jo.INSUFFICIENT_FUNDS:case jo.MISSING_NEW:case jo.NONCE_EXPIRED:case jo.REPLACEMENT_UNDERPRICED:case jo.TRANSACTION_REPLACED:case jo.UNPREDICTABLE_GAS_LIMIT:o=e;break}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(t+=" ("+n.join(", ")+")");let a=new Error(t);return a.reason=i,a.code=e,Object.keys(r).forEach(function(f){a[f]=r[f]}),a}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,Lr.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){t==null&&(t="platform missing String.prototype.normalize"),PM&&this.throwError("platform missing String.prototype.normalize",Lr.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:PM})}checkSafeUint53(t,e){typeof t=="number"&&(e==null&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,Lr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,Lr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r?r=": "+r:r="",t<e&&this.throwError("missing argument"+r,Lr.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,Lr.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){(t===Object||t==null)&&this.throwError("missing new",Lr.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",Lr.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):(t===Object||t==null)&&this.throwError("missing new",Lr.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return V4||(V4=new Lr(Ate)),V4}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",Lr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),RM){if(!t)return;this.globalLogger().throwError("error censorship permanent",Lr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}BM=!!t,RM=!!e}static setLogLevel(t){let e=Hb[t.toLowerCase()];if(e==null){Lr.globalLogger().warn("invalid log level - "+t);return}DM=e}static from(t){return new Lr(t)}},"Logger");c(Lr,"Logger");Lr.errors=jo;Lr.levels=U5;var Ete="bytes/5.7.0",En=new Lr(Ete);function zx(t){return!!t.toHexString}s(zx,"isHexable");c(zx,"isHexable");function Xl(t){return t.slice||(t.slice=function(){let e=Array.prototype.slice.call(arguments);return Xl(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}s(Xl,"addSlice");c(Xl,"addSlice");function KF(t){return Go(t)&&!(t.length%2)||Fv(t)}s(KF,"isBytesLike");c(KF,"isBytesLike");function j5(t){return typeof t=="number"&&t==t&&t%1===0}s(j5,"isInteger");c(j5,"isInteger");function Fv(t){if(t==null)return!1;if(t.constructor===Uint8Array)return!0;if(typeof t=="string"||!j5(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){let r=t[e];if(!j5(r)||r<0||r>=256)return!1}return!0}s(Fv,"isBytes");c(Fv,"isBytes");function Sn(t,e){if(e||(e={}),typeof t=="number"){En.checkSafeUint53(t,"invalid arrayify value");let r=[];for(;t;)r.unshift(t&255),t=parseInt(String(t/256));return r.length===0&&r.push(0),Xl(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),zx(t)&&(t=t.toHexString()),Go(t)){let r=t.substring(2);r.length%2&&(e.hexPad==="left"?r="0"+r:e.hexPad==="right"?r+="0":En.throwArgumentError("hex data is odd-length","value",t));let n=[];for(let i=0;i<r.length;i+=2)n.push(parseInt(r.substring(i,i+2),16));return Xl(new Uint8Array(n))}return Fv(t)?Xl(new Uint8Array(t)):En.throwArgumentError("invalid arrayify value","value",t)}s(Sn,"arrayify");c(Sn,"arrayify");function VF(t){let e=t.map(i=>Sn(i)),r=e.reduce((i,o)=>i+o.length,0),n=new Uint8Array(r);return e.reduce((i,o)=>(n.set(o,i),i+o.length),0),Xl(n)}s(VF,"concat3");c(VF,"concat");function WF(t,e){t=Sn(t),t.length>e&&En.throwArgumentError("value out of range","value",arguments[0]);let r=new Uint8Array(e);return r.set(t,e-t.length),Xl(r)}s(WF,"zeroPad");c(WF,"zeroPad");function Go(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}s(Go,"isHexString");c(Go,"isHexString");var W4="0123456789abcdef";function Ki(t,e){if(e||(e={}),typeof t=="number"){En.checkSafeUint53(t,"invalid hexlify value");let r="";for(;t;)r=W4[t&15]+r,t=Math.floor(t/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if(typeof t=="bigint")return t=t.toString(16),t.length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),zx(t))return t.toHexString();if(Go(t))return t.length%2&&(e.hexPad==="left"?t="0x0"+t.substring(2):e.hexPad==="right"?t+="0":En.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(Fv(t)){let r="0x";for(let n=0;n<t.length;n++){let i=t[n];r+=W4[(i&240)>>4]+W4[i&15]}return r}return En.throwArgumentError("invalid hexlify value","value",t)}s(Ki,"hexlify");c(Ki,"hexlify");function JF(t){if(typeof t!="string")t=Ki(t);else if(!Go(t)||t.length%2)return null;return(t.length-2)/2}s(JF,"hexDataLength");c(JF,"hexDataLength");function q5(t,e,r){return typeof t!="string"?t=Ki(t):(!Go(t)||t.length%2)&&En.throwArgumentError("invalid hexData","value",t),e=2+2*e,r!=null?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}s(q5,"hexDataSlice");c(q5,"hexDataSlice");function Ql(t,e){for(typeof t!="string"?t=Ki(t):Go(t)||En.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&En.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}s(Ql,"hexZeroPad");c(Ql,"hexZeroPad");function $x(t){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(KF(t)){let r=Sn(t);r.length===64?(e.v=27+(r[32]>>7),r[32]&=127,e.r=Ki(r.slice(0,32)),e.s=Ki(r.slice(32,64))):r.length===65?(e.r=Ki(r.slice(0,32)),e.s=Ki(r.slice(32,64)),e.v=r[64]):En.throwArgumentError("invalid signature string","signature",t),e.v<27&&(e.v===0||e.v===1?e.v+=27:En.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=Ki(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,e._vs!=null){let i=WF(Sn(e._vs),32);e._vs=Ki(i);let o=i[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=o:e.recoveryParam!==o&&En.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),i[0]&=127;let a=Ki(i);e.s==null?e.s=a:e.s!==a&&En.throwArgumentError("signature v mismatch _vs","signature",t)}if(e.recoveryParam==null)e.v==null?En.throwArgumentError("signature missing v and recoveryParam","signature",t):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{let i=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==i&&En.throwArgumentError("signature recoveryParam mismatch v","signature",t)}e.r==null||!Go(e.r)?En.throwArgumentError("signature missing or invalid r","signature",t):e.r=Ql(e.r,32),e.s==null||!Go(e.s)?En.throwArgumentError("signature missing or invalid s","signature",t):e.s=Ql(e.s,32);let r=Sn(e.s);r[0]>=128&&En.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);let n=Ki(r);e._vs&&(Go(e._vs)||En.throwArgumentError("signature invalid _vs","signature",t),e._vs=Ql(e._vs,32)),e._vs==null?e._vs=n:e._vs!==n&&En.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}s($x,"splitSignature");c($x,"splitSignature");var Cte=wr(oD()),Ste="bignumber/5.7.0",Ite=Cte.default.BN,Upe=new Lr(Ste);function YF(t){return new Ite(t,36).toString(16)}s(YF,"_base36To16");c(YF,"_base36To16");var kte=wr(VB());function Nv(t){return"0x"+kte.default.keccak_256(Sn(t))}s(Nv,"keccak256");c(Nv,"keccak256");var Tte="address/5.7.0",Mp=new Lr(Tte);function H5(t){Go(t,20)||Mp.throwArgumentError("invalid address","address",t),t=t.toLowerCase();let e=t.substring(2).split(""),r=new Uint8Array(40);for(let i=0;i<40;i++)r[i]=e[i].charCodeAt(0);let n=Sn(Nv(r));for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(n[i>>1]&15)>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}s(H5,"getChecksumAddress");c(H5,"getChecksumAddress");var Mte=9007199254740991;function ZF(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}s(ZF,"log10");c(ZF,"log10");var Gx={};for(let t=0;t<10;t++)Gx[String(t)]=String(t);for(let t=0;t<26;t++)Gx[String.fromCharCode(65+t)]=String(10+t);var FM=Math.floor(ZF(Mte));function XF(t){t=t.toUpperCase(),t=t.substring(4)+t.substring(0,2)+"00";let e=t.split("").map(n=>Gx[n]).join("");for(;e.length>=FM;){let n=e.substring(0,FM);e=parseInt(n,10)%97+e.substring(n.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}s(XF,"ibanChecksum");c(XF,"ibanChecksum");function QF(t){let e=null;if(typeof t!="string"&&Mp.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))t.substring(0,2)!=="0x"&&(t="0x"+t),e=H5(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&Mp.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==XF(t)&&Mp.throwArgumentError("bad icap checksum","address",t),e=YF(t.substring(4));e.length<40;)e="0"+e;e=H5("0x"+e)}else Mp.throwArgumentError("invalid address","address",t);return e}s(QF,"getAddress");c(QF,"getAddress");var Rte="properties/5.7.0",jpe=new Lr(Rte);function Nd(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}s(Nd,"defineReadOnly");c(Nd,"defineReadOnly");var Bte="strings/5.7.0",eN=new Lr(Bte),S2;(function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"})(S2||(S2={}));var $d;(function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"})($d||($d={}));function tN(t,e,r,n,i){return eN.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)}s(tN,"errorFunc");c(tN,"errorFunc");function Kx(t,e,r,n,i){if(t===$d.BAD_PREFIX||t===$d.UNEXPECTED_CONTINUE){let o=0;for(let a=e+1;a<r.length&&r[a]>>6===2;a++)o++;return o}return t===$d.OVERRUN?r.length-e-1:0}s(Kx,"ignoreFunc");c(Kx,"ignoreFunc");function rN(t,e,r,n,i){return t===$d.OVERLONG?(n.push(i),0):(n.push(65533),Kx(t,e,r,n,i))}s(rN,"replaceFunc");c(rN,"replaceFunc");var qpe=Object.freeze({error:tN,ignore:Kx,replace:rN});function zb(t,e=S2.current){e!=S2.current&&(eN.checkNormalize(),t=t.normalize(e));let r=[];for(let n=0;n<t.length;n++){let i=t.charCodeAt(n);if(i<128)r.push(i);else if(i<2048)r.push(i>>6|192),r.push(i&63|128);else if((i&64512)==55296){n++;let o=t.charCodeAt(n);if(n>=t.length||(o&64512)!==56320)throw new Error("invalid utf-8 string");let a=65536+((i&1023)<<10)+(o&1023);r.push(a>>18|240),r.push(a>>12&63|128),r.push(a>>6&63|128),r.push(a&63|128)}else r.push(i>>12|224),r.push(i>>6&63|128),r.push(i&63|128)}return Sn(r)}s(zb,"toUtf8Bytes");c(zb,"toUtf8Bytes");var Dte=`Ethereum Signed Message:
|
|
822
|
+
`;function nN(t){return typeof t=="string"&&(t=zb(t)),Nv(VF([zb(Dte),zb(String(t.length)),t]))}s(nN,"hashMessage");c(nN,"hashMessage");var Qt=wr(oD()),Bc=wr(dv());function bu(t,e,r){return r={path:e,exports:{},require:function(n,i){return iN(n,i??r.path)}},t(r,r.exports),r.exports}s(bu,"createCommonjsModule");c(bu,"createCommonjsModule");function iN(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}s(iN,"commonjsRequire");c(iN,"commonjsRequire");var Vx=Wx;function Wx(t,e){if(!t)throw new Error(e||"Assertion failed")}s(Wx,"assert");c(Wx,"assert");Wx.equal=c(s(function(e,r,n){if(e!=r)throw new Error(n||"Assertion failed: "+e+" != "+r)},"assertEqual"),"assertEqual");var zo=bu(function(t,e){"use strict";var r=e;function n(a,f){if(Array.isArray(a))return a.slice();if(!a)return[];var l=[];if(typeof a!="string"){for(var u=0;u<a.length;u++)l[u]=a[u]|0;return l}if(f==="hex"){a=a.replace(/[^a-z0-9]+/ig,""),a.length%2!==0&&(a="0"+a);for(var u=0;u<a.length;u+=2)l.push(parseInt(a[u]+a[u+1],16))}else for(var u=0;u<a.length;u++){var h=a.charCodeAt(u),g=h>>8,x=h&255;g?l.push(g,x):l.push(x)}return l}s(n,"toArray"),c(n,"toArray"),r.toArray=n;function i(a){return a.length===1?"0"+a:a}s(i,"zero2"),c(i,"zero2"),r.zero2=i;function o(a){for(var f="",l=0;l<a.length;l++)f+=i(a[l].toString(16));return f}s(o,"toHex"),c(o,"toHex"),r.toHex=o,r.encode=c(s(function(f,l){return l==="hex"?o(f):f},"encode16"),"encode")}),qs=bu(function(t,e){"use strict";var r=e;r.assert=Vx,r.toArray=zo.toArray,r.zero2=zo.zero2,r.toHex=zo.toHex,r.encode=zo.encode;function n(l,u,h){var g=new Array(Math.max(l.bitLength(),h)+1);g.fill(0);for(var x=1<<u+1,_=l.clone(),E=0;E<g.length;E++){var T,B=_.andln(x-1);_.isOdd()?(B>(x>>1)-1?T=(x>>1)-B:T=B,_.isubn(T)):T=0,g[E]=T,_.iushrn(1)}return g}s(n,"getNAF2"),c(n,"getNAF"),r.getNAF=n;function i(l,u){var h=[[],[]];l=l.clone(),u=u.clone();for(var g=0,x=0,_;l.cmpn(-g)>0||u.cmpn(-x)>0;){var E=l.andln(3)+g&3,T=u.andln(3)+x&3;E===3&&(E=-1),T===3&&(T=-1);var B;(E&1)===0?B=0:(_=l.andln(7)+g&7,(_===3||_===5)&&T===2?B=-E:B=E),h[0].push(B);var F;(T&1)===0?F=0:(_=u.andln(7)+x&7,(_===3||_===5)&&E===2?F=-T:F=T),h[1].push(F),2*g===B+1&&(g=1-g),2*x===F+1&&(x=1-x),l.iushrn(1),u.iushrn(1)}return h}s(i,"getJSF2"),c(i,"getJSF"),r.getJSF=i;function o(l,u,h){var g="_"+u;l.prototype[u]=c(s(function(){return this[g]!==void 0?this[g]:this[g]=h.call(this)},"cachedProperty2"),"cachedProperty")}s(o,"cachedProperty"),c(o,"cachedProperty"),r.cachedProperty=o;function a(l){return typeof l=="string"?r.toArray(l,"hex"):l}s(a,"parseBytes"),c(a,"parseBytes"),r.parseBytes=a;function f(l){return new Qt.default(l,"hex","le")}s(f,"intFromLE"),c(f,"intFromLE"),r.intFromLE=f}),I2=qs.getNAF,Pte=qs.getJSF,k2=qs.assert;function Gc(t,e){this.type=t,this.p=new Qt.default(e.p,16),this.red=e.prime?Qt.default.red(e.prime):Qt.default.mont(this.p),this.zero=new Qt.default(0).toRed(this.red),this.one=new Qt.default(1).toRed(this.red),this.two=new Qt.default(2).toRed(this.red),this.n=e.n&&new Qt.default(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}s(Gc,"BaseCurve");c(Gc,"BaseCurve");var vu=Gc;Gc.prototype.point=c(s(function(){throw new Error("Not implemented")},"point"),"point");Gc.prototype.validate=c(s(function(){throw new Error("Not implemented")},"validate"),"validate");Gc.prototype._fixedNafMul=c(s(function(e,r){k2(e.precomputed);var n=e._getDoubles(),i=I2(r,1,this._bitLength),o=(1<<n.step+1)-(n.step%2===0?2:1);o/=3;var a=[],f,l;for(f=0;f<i.length;f+=n.step){l=0;for(var u=f+n.step-1;u>=f;u--)l=(l<<1)+i[u];a.push(l)}for(var h=this.jpoint(null,null,null),g=this.jpoint(null,null,null),x=o;x>0;x--){for(f=0;f<a.length;f++)l=a[f],l===x?g=g.mixedAdd(n.points[f]):l===-x&&(g=g.mixedAdd(n.points[f].neg()));h=h.add(g)}return h.toP()},"_fixedNafMul"),"_fixedNafMul");Gc.prototype._wnafMul=c(s(function(e,r){var n=4,i=e._getNAFPoints(n);n=i.wnd;for(var o=i.points,a=I2(r,n,this._bitLength),f=this.jpoint(null,null,null),l=a.length-1;l>=0;l--){for(var u=0;l>=0&&a[l]===0;l--)u++;if(l>=0&&u++,f=f.dblp(u),l<0)break;var h=a[l];k2(h!==0),e.type==="affine"?h>0?f=f.mixedAdd(o[h-1>>1]):f=f.mixedAdd(o[-h-1>>1].neg()):h>0?f=f.add(o[h-1>>1]):f=f.add(o[-h-1>>1].neg())}return e.type==="affine"?f.toP():f},"_wnafMul"),"_wnafMul");Gc.prototype._wnafMulAdd=c(s(function(e,r,n,i,o){var a=this._wnafT1,f=this._wnafT2,l=this._wnafT3,u=0,h,g,x;for(h=0;h<i;h++){x=r[h];var _=x._getNAFPoints(e);a[h]=_.wnd,f[h]=_.points}for(h=i-1;h>=1;h-=2){var E=h-1,T=h;if(a[E]!==1||a[T]!==1){l[E]=I2(n[E],a[E],this._bitLength),l[T]=I2(n[T],a[T],this._bitLength),u=Math.max(l[E].length,u),u=Math.max(l[T].length,u);continue}var B=[r[E],null,null,r[T]];r[E].y.cmp(r[T].y)===0?(B[1]=r[E].add(r[T]),B[2]=r[E].toJ().mixedAdd(r[T].neg())):r[E].y.cmp(r[T].y.redNeg())===0?(B[1]=r[E].toJ().mixedAdd(r[T]),B[2]=r[E].add(r[T].neg())):(B[1]=r[E].toJ().mixedAdd(r[T]),B[2]=r[E].toJ().mixedAdd(r[T].neg()));var F=[-3,-1,-5,-7,0,7,5,1,3],H=Pte(n[E],n[T]);for(u=Math.max(H[0].length,u),l[E]=new Array(u),l[T]=new Array(u),g=0;g<u;g++){var U=H[0][g]|0,q=H[1][g]|0;l[E][g]=F[(U+1)*3+(q+1)],l[T][g]=0,f[E]=B}}var K=this.jpoint(null,null,null),W=this._wnafT4;for(h=u;h>=0;h--){for(var N=0;h>=0;){var G=!0;for(g=0;g<i;g++)W[g]=l[g][h]|0,W[g]!==0&&(G=!1);if(!G)break;N++,h--}if(h>=0&&N++,K=K.dblp(N),h<0)break;for(g=0;g<i;g++){var ce=W[g];ce!==0&&(ce>0?x=f[g][ce-1>>1]:ce<0&&(x=f[g][-ce-1>>1].neg()),x.type==="affine"?K=K.mixedAdd(x):K=K.add(x))}}for(h=0;h<i;h++)f[h]=null;return o?K:K.toP()},"_wnafMulAdd"),"_wnafMulAdd");function Hs(t,e){this.curve=t,this.type=e,this.precomputed=null}s(Hs,"BasePoint");c(Hs,"BasePoint");Gc.BasePoint=Hs;Hs.prototype.eq=c(s(function(){throw new Error("Not implemented")},"eq"),"eq");Hs.prototype.validate=c(s(function(){return this.curve.validate(this)},"validate2"),"validate");Gc.prototype.decodePoint=c(s(function(e,r){e=qs.toArray(e,r);var n=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*n){e[0]===6?k2(e[e.length-1]%2===0):e[0]===7&&k2(e[e.length-1]%2===1);var i=this.point(e.slice(1,1+n),e.slice(1+n,1+2*n));return i}else if((e[0]===2||e[0]===3)&&e.length-1===n)return this.pointFromX(e.slice(1,1+n),e[0]===3);throw new Error("Unknown point format")},"decodePoint"),"decodePoint");Hs.prototype.encodeCompressed=c(s(function(e){return this.encode(e,!0)},"encodeCompressed"),"encodeCompressed");Hs.prototype._encode=c(s(function(e){var r=this.curve.p.byteLength(),n=this.getX().toArray("be",r);return e?[this.getY().isEven()?2:3].concat(n):[4].concat(n,this.getY().toArray("be",r))},"_encode"),"_encode");Hs.prototype.encode=c(s(function(e,r){return qs.encode(this._encode(r),e)},"encode8"),"encode");Hs.prototype.precompute=c(s(function(e){if(this.precomputed)return this;var r={doubles:null,naf:null,beta:null};return r.naf=this._getNAFPoints(8),r.doubles=this._getDoubles(4,e),r.beta=this._getBeta(),this.precomputed=r,this},"precompute"),"precompute");Hs.prototype._hasDoubles=c(s(function(e){if(!this.precomputed)return!1;var r=this.precomputed.doubles;return r?r.points.length>=Math.ceil((e.bitLength()+1)/r.step):!1},"_hasDoubles"),"_hasDoubles");Hs.prototype._getDoubles=c(s(function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],i=this,o=0;o<r;o+=e){for(var a=0;a<e;a++)i=i.dbl();n.push(i)}return{step:e,points:n}},"_getDoubles"),"_getDoubles");Hs.prototype._getNAFPoints=c(s(function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var r=[this],n=(1<<e)-1,i=n===1?null:this.dbl(),o=1;o<n;o++)r[o]=r[o-1].add(i);return{wnd:e,points:r}},"_getNAFPoints"),"_getNAFPoints");Hs.prototype._getBeta=c(s(function(){return null},"_getBeta"),"_getBeta");Hs.prototype.dblp=c(s(function(e){for(var r=this,n=0;n<e;n++)r=r.dbl();return r},"dblp"),"dblp");var Jx=bu(function(t){typeof Object.create=="function"?t.exports=c(s(function(r,n){n&&(r.super_=n,r.prototype=Object.create(n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))},"inherits"),"inherits"):t.exports=c(s(function(r,n){if(n){r.super_=n;var i=c(function(){},"TempCtor");i.prototype=n.prototype,r.prototype=new i,r.prototype.constructor=r}},"inherits"),"inherits")}),Ote=qs.assert;function zs(t){vu.call(this,"short",t),this.a=new Qt.default(t.a,16).toRed(this.red),this.b=new Qt.default(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}s(zs,"ShortCurve");c(zs,"ShortCurve");Jx(zs,vu);var Fte=zs;zs.prototype._getEndomorphism=c(s(function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,n;if(e.beta)r=new Qt.default(e.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);r=i[0].cmp(i[1])<0?i[0]:i[1],r=r.toRed(this.red)}if(e.lambda)n=new Qt.default(e.lambda,16);else{var o=this._getEndoRoots(this.n);this.g.mul(o[0]).x.cmp(this.g.x.redMul(r))===0?n=o[0]:(n=o[1],Ote(this.g.mul(n).x.cmp(this.g.x.redMul(r))===0))}var a;return e.basis?a=e.basis.map(function(f){return{a:new Qt.default(f.a,16),b:new Qt.default(f.b,16)}}):a=this._getEndoBasis(n),{beta:r,lambda:n,basis:a}}},"_getEndomorphism"),"_getEndomorphism");zs.prototype._getEndoRoots=c(s(function(e){var r=e===this.p?this.red:Qt.default.mont(e),n=new Qt.default(2).toRed(r).redInvm(),i=n.redNeg(),o=new Qt.default(3).toRed(r).redNeg().redSqrt().redMul(n),a=i.redAdd(o).fromRed(),f=i.redSub(o).fromRed();return[a,f]},"_getEndoRoots"),"_getEndoRoots");zs.prototype._getEndoBasis=c(s(function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),n=e,i=this.n.clone(),o=new Qt.default(1),a=new Qt.default(0),f=new Qt.default(0),l=new Qt.default(1),u,h,g,x,_,E,T,B=0,F,H;n.cmpn(0)!==0;){var U=i.div(n);F=i.sub(U.mul(n)),H=f.sub(U.mul(o));var q=l.sub(U.mul(a));if(!g&&F.cmp(r)<0)u=T.neg(),h=o,g=F.neg(),x=H;else if(g&&++B===2)break;T=F,i=n,n=F,f=o,o=H,l=a,a=q}_=F.neg(),E=H;var K=g.sqr().add(x.sqr()),W=_.sqr().add(E.sqr());return W.cmp(K)>=0&&(_=u,E=h),g.negative&&(g=g.neg(),x=x.neg()),_.negative&&(_=_.neg(),E=E.neg()),[{a:g,b:x},{a:_,b:E}]},"_getEndoBasis"),"_getEndoBasis");zs.prototype._endoSplit=c(s(function(e){var r=this.endo.basis,n=r[0],i=r[1],o=i.b.mul(e).divRound(this.n),a=n.b.neg().mul(e).divRound(this.n),f=o.mul(n.a),l=a.mul(i.a),u=o.mul(n.b),h=a.mul(i.b),g=e.sub(f).sub(l),x=u.add(h).neg();return{k1:g,k2:x}},"_endoSplit"),"_endoSplit");zs.prototype.pointFromX=c(s(function(e,r){e=new Qt.default(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=n.redSqrt();if(i.redSqr().redSub(n).cmp(this.zero)!==0)throw new Error("invalid point");var o=i.fromRed().isOdd();return(r&&!o||!r&&o)&&(i=i.redNeg()),this.point(e,i)},"pointFromX"),"pointFromX");zs.prototype.validate=c(s(function(e){if(e.inf)return!0;var r=e.x,n=e.y,i=this.a.redMul(r),o=r.redSqr().redMul(r).redIAdd(i).redIAdd(this.b);return n.redSqr().redISub(o).cmpn(0)===0},"validate3"),"validate");zs.prototype._endoWnafMulAdd=c(s(function(e,r,n){for(var i=this._endoWnafT1,o=this._endoWnafT2,a=0;a<e.length;a++){var f=this._endoSplit(r[a]),l=e[a],u=l._getBeta();f.k1.negative&&(f.k1.ineg(),l=l.neg(!0)),f.k2.negative&&(f.k2.ineg(),u=u.neg(!0)),i[a*2]=l,i[a*2+1]=u,o[a*2]=f.k1,o[a*2+1]=f.k2}for(var h=this._wnafMulAdd(1,i,o,a*2,n),g=0;g<a*2;g++)i[g]=null,o[g]=null;return h},"_endoWnafMulAdd"),"_endoWnafMulAdd");function qn(t,e,r,n){vu.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new Qt.default(e,16),this.y=new Qt.default(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}s(qn,"Point");c(qn,"Point");Jx(qn,vu.BasePoint);zs.prototype.point=c(s(function(e,r,n){return new qn(this,e,r,n)},"point2"),"point");zs.prototype.pointFromJSON=c(s(function(e,r){return qn.fromJSON(this,e,r)},"pointFromJSON"),"pointFromJSON");qn.prototype._getBeta=c(s(function(){if(!!this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var r=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var n=this.curve,i=c(function(o){return n.point(o.x.redMul(n.endo.beta),o.y)},"endoMul");e.beta=r,r.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(i)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(i)}}}return r}},"_getBeta2"),"_getBeta");qn.prototype.toJSON=c(s(function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},"toJSON"),"toJSON");qn.fromJSON=c(s(function(e,r,n){typeof r=="string"&&(r=JSON.parse(r));var i=e.point(r[0],r[1],n);if(!r[2])return i;function o(f){return e.point(f[0],f[1],n)}s(o,"obj2point"),c(o,"obj2point");var a=r[2];return i.precomputed={beta:null,doubles:a.doubles&&{step:a.doubles.step,points:[i].concat(a.doubles.points.map(o))},naf:a.naf&&{wnd:a.naf.wnd,points:[i].concat(a.naf.points.map(o))}},i},"fromJSON"),"fromJSON");qn.prototype.inspect=c(s(function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},"inspect"),"inspect");qn.prototype.isInfinity=c(s(function(){return this.inf},"isInfinity"),"isInfinity");qn.prototype.add=c(s(function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var n=r.redSqr().redISub(this.x).redISub(e.x),i=r.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,i)},"add"),"add");qn.prototype.dbl=c(s(function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var r=this.curve.a,n=this.x.redSqr(),i=e.redInvm(),o=n.redAdd(n).redIAdd(n).redIAdd(r).redMul(i),a=o.redSqr().redISub(this.x.redAdd(this.x)),f=o.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,f)},"dbl"),"dbl");qn.prototype.getX=c(s(function(){return this.x.fromRed()},"getX"),"getX");qn.prototype.getY=c(s(function(){return this.y.fromRed()},"getY"),"getY");qn.prototype.mul=c(s(function(e){return e=new Qt.default(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},"mul"),"mul");qn.prototype.mulAdd=c(s(function(e,r,n){var i=[this,r],o=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,o):this.curve._wnafMulAdd(1,i,o,2)},"mulAdd"),"mulAdd");qn.prototype.jmulAdd=c(s(function(e,r,n){var i=[this,r],o=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,o,!0):this.curve._wnafMulAdd(1,i,o,2,!0)},"jmulAdd"),"jmulAdd");qn.prototype.eq=c(s(function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},"eq2"),"eq");qn.prototype.neg=c(s(function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,i=c(function(o){return o.neg()},"negate");r.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(i)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(i)}}}return r},"neg"),"neg");qn.prototype.toJ=c(s(function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e},"toJ"),"toJ");function Zn(t,e,r,n){vu.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&n===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Qt.default(0)):(this.x=new Qt.default(e,16),this.y=new Qt.default(r,16),this.z=new Qt.default(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}s(Zn,"JPoint");c(Zn,"JPoint");Jx(Zn,vu.BasePoint);zs.prototype.jpoint=c(s(function(e,r,n){return new Zn(this,e,r,n)},"jpoint"),"jpoint");Zn.prototype.toP=c(s(function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),n=this.x.redMul(r),i=this.y.redMul(r).redMul(e);return this.curve.point(n,i)},"toP"),"toP");Zn.prototype.neg=c(s(function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},"neg2"),"neg");Zn.prototype.add=c(s(function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),n=this.z.redSqr(),i=this.x.redMul(r),o=e.x.redMul(n),a=this.y.redMul(r.redMul(e.z)),f=e.y.redMul(n.redMul(this.z)),l=i.redSub(o),u=a.redSub(f);if(l.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=l.redSqr(),g=h.redMul(l),x=i.redMul(h),_=u.redSqr().redIAdd(g).redISub(x).redISub(x),E=u.redMul(x.redISub(_)).redISub(a.redMul(g)),T=this.z.redMul(e.z).redMul(l);return this.curve.jpoint(_,E,T)},"add2"),"add");Zn.prototype.mixedAdd=c(s(function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),n=this.x,i=e.x.redMul(r),o=this.y,a=e.y.redMul(r).redMul(this.z),f=n.redSub(i),l=o.redSub(a);if(f.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=f.redSqr(),h=u.redMul(f),g=n.redMul(u),x=l.redSqr().redIAdd(h).redISub(g).redISub(g),_=l.redMul(g.redISub(x)).redISub(o.redMul(h)),E=this.z.redMul(f);return this.curve.jpoint(x,_,E)},"mixedAdd"),"mixedAdd");Zn.prototype.dblp=c(s(function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var n=this;for(r=0;r<e;r++)n=n.dbl();return n}var i=this.curve.a,o=this.curve.tinv,a=this.x,f=this.y,l=this.z,u=l.redSqr().redSqr(),h=f.redAdd(f);for(r=0;r<e;r++){var g=a.redSqr(),x=h.redSqr(),_=x.redSqr(),E=g.redAdd(g).redIAdd(g).redIAdd(i.redMul(u)),T=a.redMul(x),B=E.redSqr().redISub(T.redAdd(T)),F=T.redISub(B),H=E.redMul(F);H=H.redIAdd(H).redISub(_);var U=h.redMul(l);r+1<e&&(u=u.redMul(_)),a=B,l=U,h=H}return this.curve.jpoint(a,h.redMul(o),l)},"dblp2"),"dblp");Zn.prototype.dbl=c(s(function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},"dbl2"),"dbl");Zn.prototype._zeroDbl=c(s(function(){var e,r,n;if(this.zOne){var i=this.x.redSqr(),o=this.y.redSqr(),a=o.redSqr(),f=this.x.redAdd(o).redSqr().redISub(i).redISub(a);f=f.redIAdd(f);var l=i.redAdd(i).redIAdd(i),u=l.redSqr().redISub(f).redISub(f),h=a.redIAdd(a);h=h.redIAdd(h),h=h.redIAdd(h),e=u,r=l.redMul(f.redISub(u)).redISub(h),n=this.y.redAdd(this.y)}else{var g=this.x.redSqr(),x=this.y.redSqr(),_=x.redSqr(),E=this.x.redAdd(x).redSqr().redISub(g).redISub(_);E=E.redIAdd(E);var T=g.redAdd(g).redIAdd(g),B=T.redSqr(),F=_.redIAdd(_);F=F.redIAdd(F),F=F.redIAdd(F),e=B.redISub(E).redISub(E),r=T.redMul(E.redISub(e)).redISub(F),n=this.y.redMul(this.z),n=n.redIAdd(n)}return this.curve.jpoint(e,r,n)},"_zeroDbl"),"_zeroDbl");Zn.prototype._threeDbl=c(s(function(){var e,r,n;if(this.zOne){var i=this.x.redSqr(),o=this.y.redSqr(),a=o.redSqr(),f=this.x.redAdd(o).redSqr().redISub(i).redISub(a);f=f.redIAdd(f);var l=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),u=l.redSqr().redISub(f).redISub(f);e=u;var h=a.redIAdd(a);h=h.redIAdd(h),h=h.redIAdd(h),r=l.redMul(f.redISub(u)).redISub(h),n=this.y.redAdd(this.y)}else{var g=this.z.redSqr(),x=this.y.redSqr(),_=this.x.redMul(x),E=this.x.redSub(g).redMul(this.x.redAdd(g));E=E.redAdd(E).redIAdd(E);var T=_.redIAdd(_);T=T.redIAdd(T);var B=T.redAdd(T);e=E.redSqr().redISub(B),n=this.y.redAdd(this.z).redSqr().redISub(x).redISub(g);var F=x.redSqr();F=F.redIAdd(F),F=F.redIAdd(F),F=F.redIAdd(F),r=E.redMul(T.redISub(e)).redISub(F)}return this.curve.jpoint(e,r,n)},"_threeDbl"),"_threeDbl");Zn.prototype._dbl=c(s(function(){var e=this.curve.a,r=this.x,n=this.y,i=this.z,o=i.redSqr().redSqr(),a=r.redSqr(),f=n.redSqr(),l=a.redAdd(a).redIAdd(a).redIAdd(e.redMul(o)),u=r.redAdd(r);u=u.redIAdd(u);var h=u.redMul(f),g=l.redSqr().redISub(h.redAdd(h)),x=h.redISub(g),_=f.redSqr();_=_.redIAdd(_),_=_.redIAdd(_),_=_.redIAdd(_);var E=l.redMul(x).redISub(_),T=n.redAdd(n).redMul(i);return this.curve.jpoint(g,E,T)},"_dbl"),"_dbl");Zn.prototype.trpl=c(s(function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),r=this.y.redSqr(),n=this.z.redSqr(),i=r.redSqr(),o=e.redAdd(e).redIAdd(e),a=o.redSqr(),f=this.x.redAdd(r).redSqr().redISub(e).redISub(i);f=f.redIAdd(f),f=f.redAdd(f).redIAdd(f),f=f.redISub(a);var l=f.redSqr(),u=i.redIAdd(i);u=u.redIAdd(u),u=u.redIAdd(u),u=u.redIAdd(u);var h=o.redIAdd(f).redSqr().redISub(a).redISub(l).redISub(u),g=r.redMul(h);g=g.redIAdd(g),g=g.redIAdd(g);var x=this.x.redMul(l).redISub(g);x=x.redIAdd(x),x=x.redIAdd(x);var _=this.y.redMul(h.redMul(u.redISub(h)).redISub(f.redMul(l)));_=_.redIAdd(_),_=_.redIAdd(_),_=_.redIAdd(_);var E=this.z.redAdd(f).redSqr().redISub(n).redISub(l);return this.curve.jpoint(x,_,E)},"trpl"),"trpl");Zn.prototype.mul=c(s(function(e,r){return e=new Qt.default(e,r),this.curve._wnafMul(this,e)},"mul2"),"mul");Zn.prototype.eq=c(s(function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var r=this.z.redSqr(),n=e.z.redSqr();if(this.x.redMul(n).redISub(e.x.redMul(r)).cmpn(0)!==0)return!1;var i=r.redMul(this.z),o=n.redMul(e.z);return this.y.redMul(o).redISub(e.y.redMul(i)).cmpn(0)===0},"eq3"),"eq");Zn.prototype.eqXToP=c(s(function(e){var r=this.z.redSqr(),n=e.toRed(this.curve.red).redMul(r);if(this.x.cmp(n)===0)return!0;for(var i=e.clone(),o=this.curve.redN.redMul(r);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(n.redIAdd(o),this.x.cmp(n)===0)return!0}},"eqXToP"),"eqXToP");Zn.prototype.inspect=c(s(function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},"inspect2"),"inspect");Zn.prototype.isInfinity=c(s(function(){return this.z.cmpn(0)===0},"isInfinity2"),"isInfinity");var $b=bu(function(t,e){"use strict";var r=e;r.base=vu,r.short=Fte,r.mont=null,r.edwards=null}),Gb=bu(function(t,e){"use strict";var r=e,n=qs.assert;function i(f){f.type==="short"?this.curve=new $b.short(f):f.type==="edwards"?this.curve=new $b.edwards(f):this.curve=new $b.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}s(i,"PresetCurve"),c(i,"PresetCurve"),r.PresetCurve=i;function o(f,l){Object.defineProperty(r,f,{configurable:!0,enumerable:!0,get:function(){var u=new i(l);return Object.defineProperty(r,f,{configurable:!0,enumerable:!0,value:u}),u}})}s(o,"defineCurve"),c(o,"defineCurve"),o("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Bc.default.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),o("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Bc.default.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),o("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Bc.default.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),o("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Bc.default.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),o("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Bc.default.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),o("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Bc.default.sha256,gRed:!1,g:["9"]}),o("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Bc.default.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var a;try{a=null.crash()}catch{a=void 0}o("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Bc.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",a]})});function Uc(t){if(!(this instanceof Uc))return new Uc(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=zo.toArray(t.entropy,t.entropyEnc||"hex"),r=zo.toArray(t.nonce,t.nonceEnc||"hex"),n=zo.toArray(t.pers,t.persEnc||"hex");Vx(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}s(Uc,"HmacDRBG");c(Uc,"HmacDRBG");var sN=Uc;Uc.prototype._init=c(s(function(e,r,n){var i=e.concat(r).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var o=0;o<this.V.length;o++)this.K[o]=0,this.V[o]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},"init3"),"init");Uc.prototype._hmac=c(s(function(){return new Bc.default.hmac(this.hash,this.K)},"hmac"),"hmac");Uc.prototype._update=c(s(function(e){var r=this._hmac().update(this.V).update([0]);e&&(r=r.update(e)),this.K=r.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},"update"),"update");Uc.prototype.reseed=c(s(function(e,r,n,i){typeof r!="string"&&(i=n,n=r,r=null),e=zo.toArray(e,r),n=zo.toArray(n,i),Vx(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this._reseed=1},"reseed"),"reseed");Uc.prototype.generate=c(s(function(e,r,n,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(i=n,n=r,r=null),n&&(n=zo.toArray(n,i||"hex"),this._update(n));for(var o=[];o.length<e;)this.V=this._hmac().update(this.V).digest(),o=o.concat(this.V);var a=o.slice(0,e);return this._update(n),this._reseed++,zo.encode(a,r)},"generate"),"generate");var z5=qs.assert;function ci(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}s(ci,"KeyPair");c(ci,"KeyPair");var Yx=ci;ci.fromPublic=c(s(function(e,r,n){return r instanceof ci?r:new ci(e,{pub:r,pubEnc:n})},"fromPublic"),"fromPublic");ci.fromPrivate=c(s(function(e,r,n){return r instanceof ci?r:new ci(e,{priv:r,privEnc:n})},"fromPrivate"),"fromPrivate");ci.prototype.validate=c(s(function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},"validate4"),"validate");ci.prototype.getPublic=c(s(function(e,r){return typeof e=="string"&&(r=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),r?this.pub.encode(r,e):this.pub},"getPublic"),"getPublic");ci.prototype.getPrivate=c(s(function(e){return e==="hex"?this.priv.toString(16,2):this.priv},"getPrivate"),"getPrivate");ci.prototype._importPrivate=c(s(function(e,r){this.priv=new Qt.default(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)},"_importPrivate"),"_importPrivate");ci.prototype._importPublic=c(s(function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?z5(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&z5(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,r)},"_importPublic"),"_importPublic");ci.prototype.derive=c(s(function(e){return e.validate()||z5(e.validate(),"public point not validated"),e.mul(this.priv).getX()},"derive"),"derive");ci.prototype.sign=c(s(function(e,r,n){return this.ec.sign(e,this,r,n)},"sign2"),"sign");ci.prototype.verify=c(s(function(e,r){return this.ec.verify(e,r,this)},"verify2"),"verify");ci.prototype.inspect=c(s(function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"},"inspect3"),"inspect");var Nte=qs.assert;function N1(t,e){if(t instanceof N1)return t;this._importDER(t,e)||(Nte(t.r&&t.s,"Signature without r or s"),this.r=new Qt.default(t.r,16),this.s=new Qt.default(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}s(N1,"Signature");c(N1,"Signature");var Lv=N1;function oN(){this.place=0}s(oN,"Position");c(oN,"Position");function Kb(t,e){var r=t[e.place++];if(!(r&128))return r;var n=r&15;if(n===0||n>4)return!1;for(var i=0,o=0,a=e.place;o<n;o++,a++)i<<=8,i|=t[a],i>>>=0;return i<=127?!1:(e.place=a,i)}s(Kb,"getLength");c(Kb,"getLength");function $5(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e<r;)e++;return e===0?t:t.slice(e)}s($5,"rmPadding");c($5,"rmPadding");N1.prototype._importDER=c(s(function(e,r){e=qs.toArray(e,r);var n=new oN;if(e[n.place++]!==48)return!1;var i=Kb(e,n);if(i===!1||i+n.place!==e.length||e[n.place++]!==2)return!1;var o=Kb(e,n);if(o===!1)return!1;var a=e.slice(n.place,o+n.place);if(n.place+=o,e[n.place++]!==2)return!1;var f=Kb(e,n);if(f===!1||e.length!==f+n.place)return!1;var l=e.slice(n.place,f+n.place);if(a[0]===0)if(a[1]&128)a=a.slice(1);else return!1;if(l[0]===0)if(l[1]&128)l=l.slice(1);else return!1;return this.r=new Qt.default(a),this.s=new Qt.default(l),this.recoveryParam=null,!0},"_importDER"),"_importDER");function Vb(t,e){if(e<128){t.push(e);return}var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}s(Vb,"constructLength");c(Vb,"constructLength");N1.prototype.toDER=c(s(function(e){var r=this.r.toArray(),n=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),n[0]&128&&(n=[0].concat(n)),r=$5(r),n=$5(n);!n[0]&&!(n[1]&128);)n=n.slice(1);var i=[2];Vb(i,r.length),i=i.concat(r),i.push(2),Vb(i,n.length);var o=i.concat(n),a=[48];return Vb(a,o.length),a=a.concat(o),qs.encode(a,e)},"toDER"),"toDER");var Lte=c(function(){throw new Error("unsupported")},"rand"),aN=qs.assert;function Ls(t){if(!(this instanceof Ls))return new Ls(t);typeof t=="string"&&(aN(Object.prototype.hasOwnProperty.call(Gb,t),"Unknown curve "+t),t=Gb[t]),t instanceof Gb.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}s(Ls,"EC");c(Ls,"EC");var Ute=Ls;Ls.prototype.keyPair=c(s(function(e){return new Yx(this,e)},"keyPair"),"keyPair");Ls.prototype.keyFromPrivate=c(s(function(e,r){return Yx.fromPrivate(this,e,r)},"keyFromPrivate"),"keyFromPrivate");Ls.prototype.keyFromPublic=c(s(function(e,r){return Yx.fromPublic(this,e,r)},"keyFromPublic"),"keyFromPublic");Ls.prototype.genKeyPair=c(s(function(e){e||(e={});for(var r=new sN({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||Lte(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new Qt.default(2));;){var o=new Qt.default(r.generate(n));if(!(o.cmp(i)>0))return o.iaddn(1),this.keyFromPrivate(o)}},"genKeyPair"),"genKeyPair");Ls.prototype._truncateToN=c(s(function(e,r){var n=e.byteLength()*8-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e},"_truncateToN"),"_truncateToN");Ls.prototype.sign=c(s(function(e,r,n,i){typeof n=="object"&&(i=n,n=null),i||(i={}),r=this.keyFromPrivate(r,n),e=this._truncateToN(new Qt.default(e,16));for(var o=this.n.byteLength(),a=r.getPrivate().toArray("be",o),f=e.toArray("be",o),l=new sN({hash:this.hash,entropy:a,nonce:f,pers:i.pers,persEnc:i.persEnc||"utf8"}),u=this.n.sub(new Qt.default(1)),h=0;;h++){var g=i.k?i.k(h):new Qt.default(l.generate(this.n.byteLength()));if(g=this._truncateToN(g,!0),!(g.cmpn(1)<=0||g.cmp(u)>=0)){var x=this.g.mul(g);if(!x.isInfinity()){var _=x.getX(),E=_.umod(this.n);if(E.cmpn(0)!==0){var T=g.invm(this.n).mul(E.mul(r.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var B=(x.getY().isOdd()?1:0)|(_.cmp(E)!==0?2:0);return i.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),B^=1),new Lv({r:E,s:T,recoveryParam:B})}}}}}},"sign3"),"sign");Ls.prototype.verify=c(s(function(e,r,n,i){e=this._truncateToN(new Qt.default(e,16)),n=this.keyFromPublic(n,i),r=new Lv(r,"hex");var o=r.r,a=r.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var f=a.invm(this.n),l=f.mul(e).umod(this.n),u=f.mul(o).umod(this.n),h;return this.curve._maxwellTrick?(h=this.g.jmulAdd(l,n.getPublic(),u),h.isInfinity()?!1:h.eqXToP(o)):(h=this.g.mulAdd(l,n.getPublic(),u),h.isInfinity()?!1:h.getX().umod(this.n).cmp(o)===0)},"verify3"),"verify");Ls.prototype.recoverPubKey=function(t,e,r,n){aN((3&r)===r,"The recovery param is more than two bits"),e=new Lv(e,n);var i=this.n,o=new Qt.default(t),a=e.r,f=e.s,l=r&1,u=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?a=this.curve.pointFromX(a.add(this.curve.n),l):a=this.curve.pointFromX(a,l);var h=e.r.invm(i),g=i.sub(o).mul(h).umod(i),x=f.mul(h).umod(i);return this.g.mulAdd(g,a,x)};Ls.prototype.getKeyRecoveryParam=function(t,e,r,n){if(e=new Lv(e,n),e.recoveryParam!==null)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch{continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var jte=bu(function(t,e){"use strict";var r=e;r.version="6.5.4",r.utils=qs,r.rand=function(){throw new Error("unsupported")},r.curve=$b,r.curves=Gb,r.ec=Ute,r.eddsa=null}),qte=jte.ec,Hte="signing-key/5.7.0",G5=new Lr(Hte),J4=null;function qo(){return J4||(J4=new qte("secp256k1")),J4}s(qo,"getCurve");c(qo,"getCurve");var cN=s(class{constructor(t){Nd(this,"curve","secp256k1"),Nd(this,"privateKey",Ki(t)),JF(this.privateKey)!==32&&G5.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let e=qo().keyFromPrivate(Sn(this.privateKey));Nd(this,"publicKey","0x"+e.getPublic(!1,"hex")),Nd(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),Nd(this,"_isSigningKey",!0)}_addPoint(t){let e=qo().keyFromPublic(Sn(this.publicKey)),r=qo().keyFromPublic(Sn(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){let e=qo().keyFromPrivate(Sn(this.privateKey)),r=Sn(t);r.length!==32&&G5.throwArgumentError("bad digest length","digest",t);let n=e.sign(r,{canonical:!0});return $x({recoveryParam:n.recoveryParam,r:Ql("0x"+n.r.toString(16),32),s:Ql("0x"+n.s.toString(16),32)})}computeSharedSecret(t){let e=qo().keyFromPrivate(Sn(this.privateKey)),r=qo().keyFromPublic(Sn(Zx(t)));return Ql("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!!(t&&t._isSigningKey)}},"SigningKey");c(cN,"SigningKey");function fN(t,e){let r=$x(e),n={r:Sn(r.r),s:Sn(r.s)};return"0x"+qo().recoverPubKey(Sn(t),n,r.recoveryParam).encode("hex",!1)}s(fN,"recoverPublicKey");c(fN,"recoverPublicKey");function Zx(t,e){let r=Sn(t);if(r.length===32){let n=new cN(r);return e?"0x"+qo().keyFromPrivate(r).getPublic(!0,"hex"):n.publicKey}else{if(r.length===33)return e?Ki(r):"0x"+qo().keyFromPublic(r).getPublic(!1,"hex");if(r.length===65)return e?"0x"+qo().keyFromPublic(r).getPublic(!0,"hex"):Ki(r)}return G5.throwArgumentError("invalid public or private key","key","[REDACTED]")}s(Zx,"computePublicKey");c(Zx,"computePublicKey");var zte="transactions/5.7.0",Hpe=new Lr(zte),NM;(function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"})(NM||(NM={}));function lN(t){let e=Zx(t);return QF(q5(Nv(q5(e,1)),12))}s(lN,"computeAddress");c(lN,"computeAddress");function uN(t,e){return lN(fN(Sn(t),e))}s(uN,"recoverAddress");c(uN,"recoverAddress");var $te="wallet/5.7.0",zpe=new Lr($te);function K5(t,e){return uN(nN(t),e)}s(K5,"verifyMessage");c(K5,"verifyMessage");function dN(){return{eip191:async(t,e)=>{hN(t,e)}}}s(dN,"getEIP191Verifier");c(dN,"getEIP191Verifier");var Gte=new Date("2022-09-20").valueOf();function hN(t,e){Hx(t),$F(t,e);let n=[K5(L5.fromCacao(t).toMessage(),t.s.s).toLowerCase()];if(Date.parse(t.p.iat)<=Gte){let o=K5(HF(L5.fromCacao(t),"Ethereum"),t.s.s).toLowerCase();n.push(o)}let i=f1.parse(t.p.iss.replace("did:pkh:","")).address.toLowerCase();if(!n.includes(i))throw new Error("Signature does not belong to issuer")}s(hN,"verifyEIP191Signature");c(hN,"verifyEIP191Signature");E1();V8();var Kte=wr(ph(),1);E1();function pN(){return en((0,Kte.randomBytes)(16),"base64")}s(pN,"randomString");c(pN,"randomString");var mN="base64pad",gN="base64url";function bN(t){return en(t,mN)}s(bN,"encodeBase64");c(bN,"encodeBase64");function vN(t){return en(t,gN)}s(vN,"encodeBase64Url");c(vN,"encodeBase64Url");function yN(t){return Zr(t,mN)}s(yN,"decodeBase64");c(yN,"decodeBase64");function Wb(t){return JSON.parse(en(Zr(t,gN)))}s(Wb,"base64urlToJSON");c(Wb,"base64urlToJSON");function xN(t){if(t.signatures.length>1)throw new Error("Cant convert to compact jws");return`${t.signatures[0].protected}.${t.payload}.${t.signatures[0].signature}`}s(xN,"fromDagJWS");c(xN,"fromDagJWS");function wN(t,e){if(e){let r=e.toISOString().split(".")[0]+"Z";return`${t}?versionTime=${r}`}else return t}s(wN,"didWithTime");c(wN,"didWithTime");function _N(t){return t?Array.isArray(t)?t:[t]:[]}s(_N,"extractControllers");c(_N,"extractControllers");var Vte={...dN()};function AN(t){return"registry"in t&&"cache"in t}s(AN,"isResolver");c(AN,"isResolver");var Xx=s(class{get capability(){if(!this._capability)throw new Error("DID has no capability attached");return this._capability}get hasCapability(){return this._capability!=null}get parent(){if(!this._parentId)throw new Error("DID has no parent DID");return this._parentId}get hasParent(){return this._parentId!=null}get id(){if(this._id==null)throw new Error("DID is not authenticated");return this._id}get authenticated(){return this._id!=null}withCapability(t){return new Xx({provider:this._client?.connection,resolver:this._resolver,capability:t,parent:this._parentId})}setProvider(t){if(this._client==null)this._client=new F5(t);else if(this._client.connection!==t)throw new Error("A different provider is already set, create a new DID instance to use another provider")}setResolver(t,e){this._resolver=AN(t)?t:new LP(t,e)}async authenticate({provider:t,paths:e=[],aud:r}={}){if(t!=null&&this.setProvider(t),this._client==null)throw new Error("No provider available");let n=pN(),i=await this._client.request("did_authenticate",{nonce:n,aud:r,paths:e}),{kid:o}=await this.verifyJWS(i),a=Wb(i.payload);if(!o.includes(a.did))throw new Error("Invalid authencation response, kid mismatch");if(a.nonce!==n)throw new Error("Invalid authencation response, wrong nonce");if(a.aud!==r)throw new Error("Invalid authencation response, wrong aud");if(a.exp<Date.now()/1e3)throw new Error("Invalid authencation response, expired");return this._id=a.did,this._id}async createJWS(t,e={}){if(this._client==null)throw new Error("No provider available");if(this._id==null)throw new Error("DID is not authenticated");if(this._capability){let n=this._capability.p.exp;if(n&&Date.parse(n)<Date.now())throw new Error("Capability is expired, cannot create a valid signature");let i=await C2.fromCacao(this._capability),o=fr.asCID(i.cid);if(!o)throw new Error("Capability CID of the JWS cannot be set to the capability payload cid as they are incompatible");e.protected=e.protected||{},e.protected.cap=`ipfs://${o?.toString()}`}let{jws:r}=await this._client.request("did_createJWS",{did:this._id,...e,payload:t});return r}async createDagJWS(t,e={}){let{cid:r,linkedBlock:n}=await wF(t),i=vN(r.bytes);Object.assign(e,{linkedBlock:bN(n)});let o=await this.createJWS(i,e),a=fr.asCID(r);if(!a)throw new Error("CID of the JWS cannot be set to the encoded payload cid as they are incompatible");if(o.link=a,this._capability){let f=await C2.fromCacao(this._capability);return{jws:o,linkedBlock:n,cacaoBlock:f.bytes}}return{jws:o,linkedBlock:n}}async verifyJWS(t,e={}){e=Object.assign({verifiers:Vte},e),typeof t!="string"&&(t=xN(t));let r=Wb(t.split(".")[0]).kid;if(!r)throw new Error('No "kid" found in jws');let n=await this.resolve(r);if(!e.disableTimecheck){let l=n.didDocumentMetadata?.nextUpdate;if(l){let h=e.revocationPhaseOutSecs?e.revocationPhaseOutSecs*1e3:0,g=new Date(l).valueOf()+h;if(!(e.atTime&&e.atTime.getTime()<g))throw new Error(`invalid_jws: signature authored with a revoked DID version: ${r}`)}let u=n.didDocumentMetadata?.updated;if(u&&e.atTime&&e.atTime.getTime()<new Date(u).valueOf())throw new Error(`invalid_jws: signature authored before creation of DID version: ${r}`)}let o=n.didDocument?.id;if(e.issuer&&e.issuer===e.capability?.p.iss&&o===e.capability.p.aud){if(!e.verifiers)throw new Error("Registered verifiers needed for CACAO");await E2.verify(e.capability,{disableExpirationCheck:e.disableTimecheck,atTime:e.atTime?e.atTime:void 0,revocationPhaseOutSecs:e.revocationPhaseOutSecs,verifiers:e.verifiers??{}})}else if(e.issuer&&e.issuer!==o){let l=wN(e.issuer,e.atTime),h=(await this.resolve(l)).didDocument?.controller,g=_N(h);if(e.capability?.s&&e.capability.p.aud===o&&g.includes(e.capability.p.iss))await E2.verify(e.capability,{atTime:e.atTime?e.atTime:void 0,revocationPhaseOutSecs:e.revocationPhaseOutSecs,verifiers:e.verifiers??{}});else if(!(o?g.includes(o):!1))throw new Error(`invalid_jws: not a valid verificationMethod for issuer: ${r}`)}let a=n.didDocument?.verificationMethod||[];eO(t,a);let f;try{f=Wb(t.split(".")[1])}catch{}return{kid:r,payload:f,didResolutionResult:n}}async createJWE(t,e,r={}){let n=await Gee(e,this._resolver);return $ee(t,n,r.protectedHeader,r.aad)}async createDagJWE(t,e,r={}){let n=await CF(t);return this.createJWE(n,e,r)}async decryptJWE(t,e={}){if(this._client==null)throw new Error("No provider available");if(this._id==null)throw new Error("DID is not authenticated");let{cleartext:r}=await this._client.request("did_decryptJWE",{did:this._id,...e,jwe:t});return yN(r)}async decryptDagJWE(t){let e=await this.decryptJWE(t);return SF(e)}async resolve(t){let e=await this._resolver.resolve(t);if(e.didResolutionMetadata.error){let{error:r,message:n}=e.didResolutionMetadata,i=n?`, ${n}`:"";throw new Error(`Failed to resolve ${t}: ${r}${i}`)}return e}constructor({provider:t,resolver:e={},resolverOptions:r,capability:n,parent:i}={}){if(t!=null&&(this._client=new F5(t)),n){if(this._capability=n,this._parentId=this._capability.p.iss,i&&this._parentId!==i)throw new Error("Capability issuer and parent not equal")}else i&&(this._parentId=i);this.setResolver(e,r)}},"DID");c(Xx,"DID");var LM=wr(pv(),1);H8();var EN={};Kr(EN,{keyToDidDoc:()=>CN});function CN(t,e){let r=`did:key:${e}`,n=`${r}#${e}`;return{id:r,verificationMethod:[{id:n,type:"Secp256k1VerificationKey2018",controller:r,publicKeyBase58:en(t,"base58btc")}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}s(CN,"keyToDidDoc");c(CN,"keyToDidDoc");var SN={};Kr(SN,{keyToDidDoc:()=>kN});E1();var Wte=wr(J8(),1);function IN(t){let e=new Uint8Array(t.length+2);return e[0]=236,e[1]=1,e.set(t,2),`z${en(e,"base58btc")}`}s(IN,"encodeKey");c(IN,"encodeKey");function kN(t,e){let r=`did:key:${e}`,n=`${r}#${e}`,i=(0,Wte.convertPublicKeyToX25519)(t),o=`${r}#${IN(i)}`;return{id:r,verificationMethod:[{id:n,type:"Ed25519VerificationKey2018",controller:r,publicKeyBase58:en(t,"base58btc")}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n],keyAgreement:[{id:o,type:"X25519KeyAgreementKey2019",controller:r,publicKeyBase58:en(i,"base58btc")}]}}s(kN,"keyToDidDoc2");c(kN,"keyToDidDoc");var TN={};Kr(TN,{keyToDidDoc:()=>HN,pubKeyBytesToXY:()=>tw});var MN={};Kr(MN,{ECPointDecompress:()=>NN});function RN(t){return t>=0?t:-t}s(RN,"abs");c(RN,"abs");function BN(t,e){if(typeof t=="number"&&(t=BigInt(t)),typeof e=="number"&&(e=BigInt(e)),t<=0n||e<=0n)throw new RangeError("a and b MUST be > 0");let r=0n,n=1n,i=1n,o=0n;for(;t!==0n;){let a=e/t,f=e%t,l=r-i*a,u=n-o*a;e=t,t=f,r=i,n=o,i=l,o=u}return{g:e,x:r,y:n}}s(BN,"eGcd");c(BN,"eGcd");function T2(t,e){if(typeof t=="number"&&(t=BigInt(t)),typeof e=="number"&&(e=BigInt(e)),e<=0n)throw new RangeError("n must be > 0");let r=t%e;return r<0n?r+e:r}s(T2,"toZn");c(T2,"toZn");function DN(t,e){let r=BN(T2(t,e),e);if(r.g!==1n)throw new RangeError(`${t.toString()} does not have inverse modulo ${e.toString()}`);return T2(r.x,e)}s(DN,"modInv");c(DN,"modInv");function L1(t,e,r){if(typeof t=="number"&&(t=BigInt(t)),typeof e=="number"&&(e=BigInt(e)),typeof r=="number"&&(r=BigInt(r)),r<=0n)throw new RangeError("n must be > 0");if(r===1n)return 0n;if(t=T2(t,r),e<0n)return DN(L1(t,RN(e),r),r);let n=1n;for(;e>0;)e%2n===1n&&(n=n*t%r),e=e/2n,t=t**2n%r;return n}s(L1,"modPow");c(L1,"modPow");var ps={};Kr(ps,{pubKeyBytesToHex:()=>PN,publicKeyHexToUint8ArrayPointPair:()=>Qx,publicKeyIntToUint8ArrayPointPair:()=>ew,publicKeyIntToXY:()=>FN,publicKeyToXY:()=>ON,testHexString:()=>Uv,testUint8Array:()=>Eh});z8();function PN(t){if(!Eh(t))throw new TypeError("input must be a Uint8Array");return en(t,"base16")}s(PN,"pubKeyBytesToHex");c(PN,"pubKeyBytesToHex");function ON(t){if(!Uv(t))throw new TypeError("input must be string with characters 0-9,A-F,a-f");let e=Qx(t),r=Wd.encode(e.xOctet).slice(1),n=Wd.encode(e.yOctet).slice(1);return{xm:r,ym:n}}s(ON,"publicKeyToXY");c(ON,"publicKeyToXY");function Qx(t){if(!Uv(t))throw new TypeError("input must be string with characters 0-9,A-F,a-f");let e=t.slice(0,t.length/2),r=t.slice(t.length/2,t.length),n=Zr(e,"base16"),i=Zr(r,"base16");return{xOctet:n,yOctet:i}}s(Qx,"publicKeyHexToUint8ArrayPointPair");c(Qx,"publicKeyHexToUint8ArrayPointPair");function Uv(t){let e=/^[A-Fa-f0-9]+$/i;return!!(e.exec(t)!==null&&e.test(t)&&typeof t=="string")}s(Uv,"testHexString");c(Uv,"testHexString");function Eh(t){return t==null?!1:t.constructor===Uint8Array}s(Eh,"testUint8Array");c(Eh,"testUint8Array");function FN(t){if(t==null)throw new TypeError("input cannot be null or undefined.");if(typeof t!="object")throw new TypeError("Input must be an object with properties x and y");if(!Object.prototype.hasOwnProperty.call(t,"x")||!Object.prototype.hasOwnProperty.call(t,"y"))throw new Error("Input must have properties x and y");if(typeof t.x!="bigint"&&typeof t.y!="bigint")throw new Error("Input coordinates must be BigInt");let e=ew(t),r=Wd.encode(e.xOctet).slice(1),n=Wd.encode(e.yOctet).slice(1);return{xm:r,ym:n}}s(FN,"publicKeyIntToXY");c(FN,"publicKeyIntToXY");function ew(t){if(t==null)throw new TypeError("input cannot be null or undefined.");if(typeof t!="object")throw new TypeError("Input must be an object with properties x and y");if(!Object.prototype.hasOwnProperty.call(t,"x")||!Object.prototype.hasOwnProperty.call(t,"y"))throw new Error("Input must have properties x and y");if(typeof t.x!="bigint"&&typeof t.y!="bigint")throw new Error("Input coordinates must be BigInt");let e=t.x.toString(),r=t.y.toString(),n=Zr(e,"base10"),i=Zr(r,"base10");return{xOctet:n,yOctet:i}}s(ew,"publicKeyIntToUint8ArrayPointPair");c(ew,"publicKeyIntToUint8ArrayPointPair");function NN(t){if(!Eh(t))throw new TypeError("input must be a Uint8Array");let e=BigInt(2),r=e**256n-e**224n+e**192n+e**96n-1n,n=41058363725152142129326129780047268409114441015993725554835256314039467401291n,i=(r+1n)/4n,o=BigInt(t[0]-2),a=t.subarray(1),f=BigInt(en(a,"base10")),l=f**3n-f*3n+n,u=L1(l,i,r);return u%2n!==o&&(u=r-u),{x:f,y:u}}s(NN,"ECPointDecompress");c(NN,"ECPointDecompress");var LN={};Kr(LN,{ECPointDecompress:()=>UN});function UN(t){if(!Eh(t))throw new TypeError("input must be a Uint8Array");let e=BigInt(2),r=e**384n-e**128n-e**96n+e**32n-1n,n=27580193559959705877849011840389048093056905856361568521428707301988689241309860865136260764883745107765439761230575n,i=(r+1n)/4n,o=BigInt(t[0]-2),a=t.subarray(1),f=BigInt(en(a,"base10")),l=f**3n-f*3n+n,u=L1(l,i,r);return u%2n!==o&&(u=r-u),{x:f,y:u}}s(UN,"ECPointDecompress2");c(UN,"ECPointDecompress");var jN={};Kr(jN,{ECPointDecompress:()=>qN});function qN(t){if(!Eh(t))throw new TypeError("input must be a Uint8Array");let r=BigInt(2)**521n-1n,n=1093849038073734274511112390766805569936207598951683748994586394495953116150735016013708737573759623248592132296706313309438452531591012912142327488478985984n,i=(r+1n)/4n,o=BigInt(t[0]-2),a=t.subarray(1),f=BigInt(en(a,"base10")),l=f**3n-f*3n+n,u=L1(l,i,r);return u%2n!==o&&(u=r-u),{x:f,y:u}}s(qN,"ECPointDecompress3");c(qN,"ECPointDecompress");function HN(t,e){let r=`did:key:${e}`,n=`${r}#${e}`,i=tw(t);return{id:r,verificationMethod:[{id:n,type:"JsonWebKey2020",controller:r,publicKeyJwk:{kty:"EC",crv:"P-256",x:i.xm,y:i.ym}}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}s(HN,"keyToDidDoc3");c(HN,"keyToDidDoc");function tw(t){if(!ps.testUint8Array(t))throw new TypeError("input must be a Uint8Array");let e=ps.pubKeyBytesToHex(t),r=e.length/2;if(r==64)return ps.publicKeyToXY(e);if(r==65&&e.slice(0,2)=="04"){let n=e.slice(2);return ps.publicKeyToXY(n)}if(r==33&&(e.slice(0,2)=="03"||e.slice(0,2)=="02")){let n=Zr(e,"base16"),i=MN.ECPointDecompress(n);return ps.publicKeyIntToXY(i)}throw new Error("Unexpected pubKeyBytes")}s(tw,"pubKeyBytesToXY");c(tw,"pubKeyBytesToXY");var zN={};Kr(zN,{keyToDidDoc:()=>$N,pubKeyBytesToXY:()=>rw});function $N(t,e){let r=`did:key:${e}`,n=`${r}#${e}`,i=rw(t);return{id:r,verificationMethod:[{id:n,type:"JsonWebKey2020",controller:r,publicKeyJwk:{kty:"EC",crv:"P-384",x:i.xm,y:i.ym}}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}s($N,"keyToDidDoc4");c($N,"keyToDidDoc");function rw(t){if(!ps.testUint8Array(t))throw new TypeError("input must be a Uint8Array");let e=ps.pubKeyBytesToHex(t),r=e.length/2;if(r==96)return ps.publicKeyToXY(e);if(r==97&&e.slice(0,2)=="04"){let n=e.slice(2);return ps.publicKeyToXY(n)}if(r==49&&(e.slice(0,2)=="03"||e.slice(0,2)=="02")){let n=Zr(e,"base16"),i=LN.ECPointDecompress(n);return ps.publicKeyIntToXY(i)}throw new Error("Unexpected pubKeyBytes")}s(rw,"pubKeyBytesToXY2");c(rw,"pubKeyBytesToXY");var GN={};Kr(GN,{keyToDidDoc:()=>KN,pubKeyBytesToXY:()=>nw});function KN(t,e){let r=`did:key:${e}`,n=`${r}#${e}`,i=nw(t);return{id:r,verificationMethod:[{id:n,type:"JsonWebKey2020",controller:r,publicKeyJwk:{kty:"EC",crv:"P-521",x:i.xm,y:i.ym}}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}s(KN,"keyToDidDoc5");c(KN,"keyToDidDoc");function nw(t){if(!ps.testUint8Array(t))throw new TypeError("input must be a Uint8Array");let e=ps.pubKeyBytesToHex(t);if(132<=e.length&&e.length<=134&&(e.slice(0,2)=="03"||e.slice(0,2)=="02")){let r=Zr(e,"base16"),n=jN.ECPointDecompress(r);return ps.publicKeyIntToXY(n)}throw new Error("Unexpected pubKeyBytes")}s(nw,"pubKeyBytesToXY3");c(nw,"pubKeyBytesToXY");var Jte="application/did+ld+json",UM="application/did+json",Yte={231:EN,237:SN,4608:TN,4609:zN,4610:GN};function VN(){return{key:async(t,e,r,n)=>{let i=n.accept||UM,o={didResolutionMetadata:{contentType:i},didDocument:null,didDocumentMetadata:{}};try{let a=Uo.decode(e.id),f=LM.default.decode(a),l=a.slice(LM.default.decode.bytes),u=await Yte[f].keyToDidDoc(l,e.id);i===Jte?(u["@context"]="https://w3id.org/did/v1",o.didDocument=u):i===UM?o.didDocument=u:(delete o.didResolutionMetadata.contentType,o.didResolutionMetadata.error="representationNotSupported")}catch(a){o.didResolutionMetadata.error="invalidDid",o.didResolutionMetadata.message=a.toString()}return o}}}s(VN,"getResolver");c(VN,"getResolver");var Zte={getResolver:VN},WN=wr(J8(),1),Xte=wr(ZY(),1),Qte="base64pad";function V5(t){return JSON.parse((0,Xte.default)(t))}s(V5,"toStableObject");c(V5,"toStableObject");function JN(t){let e=new Uint8Array(t.length+2);return e[0]=237,e[1]=1,e.set(t,2),`did:key:z${en(e,"base58btc")}`}s(JN,"encodeDID");c(JN,"encodeDID");function W5(t){let[e,r,n]=t.split(".");return{payload:r,signatures:[{protected:e,signature:n}]}}s(W5,"toGeneralJWS");c(W5,"toGeneralJWS");var jM=c(async(t,e,r,n={})=>{let i=`${e}#${e.split(":")[2]}`,o=JP(r),a=V5(Object.assign(n,{kid:i,alg:"EdDSA"}));return qee(typeof t=="string"?t:V5(t),o,a)},"sign"),ere={did_authenticate:async({did:t,secretKey:e},r)=>{let n=await jM({did:t,aud:r.aud,nonce:r.nonce,paths:r.paths,exp:Math.floor(Date.now()/1e3)+600},t,e);return W5(n)},did_createJWS:async({did:t,secretKey:e},r)=>{if(r.did.split("#")[0]!==t)throw new Jf(4100,`Unknown DID: ${t}`);let i=await jM(r.payload,t,e,r.protected);return{jws:W5(i)}},did_decryptJWE:async({secretKey:t},e)=>{let r=cO((0,WN.convertSecretKeyToX25519)(t));try{let n=await zee(e.jwe,r);return{cleartext:en(n,Qte)}}catch(n){throw new Jf(-32e3,n.message)}}},YN=s(class{constructor(t){let{secretKey:e,publicKey:r}=(0,WN.generateKeyPairFromSeed)(t),n=JN(r),i=UF(ere);this._handle=async o=>await i({did:n,secretKey:e},o)}get isDidProvider(){return!0}async send(t){return await this._handle(t)}},"Ed25519Provider");c(YN,"Ed25519Provider");var ZN={};Kr(ZN,{JsonPatchError:()=>yn,_areEquals:()=>ah,applyOperation:()=>Uf,applyPatch:()=>jv,applyReducer:()=>QN,deepClone:()=>nre,getValueByPointer:()=>l1,validate:()=>sw,validator:()=>u1});var tre=function(){var t=c(function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)i.hasOwnProperty(o)&&(n[o]=i[o])},t(e,r)},"extendStatics");return function(e,r){t(e,r);function n(){this.constructor=e}s(n,"__"),c(n,"__"),e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),rre=Object.prototype.hasOwnProperty;function M2(t,e){return rre.call(t,e)}s(M2,"hasOwnProperty");c(M2,"hasOwnProperty");function R2(t){if(Array.isArray(t)){for(var e=new Array(t.length),r=0;r<e.length;r++)e[r]=""+r;return e}if(Object.keys)return Object.keys(t);var n=[];for(var i in t)M2(t,i)&&n.push(i);return n}s(R2,"_objectKeys");c(R2,"_objectKeys");function ms(t){switch(typeof t){case"object":return JSON.parse(JSON.stringify(t));case"undefined":return null;default:return t}}s(ms,"_deepClone");c(ms,"_deepClone");function B2(t){for(var e=0,r=t.length,n;e<r;){if(n=t.charCodeAt(e),n>=48&&n<=57){e++;continue}return!1}return!0}s(B2,"isInteger2");c(B2,"isInteger");function Ff(t){return t.indexOf("/")===-1&&t.indexOf("~")===-1?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}s(Ff,"escapePathComponent");c(Ff,"escapePathComponent");function iw(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}s(iw,"unescapePathComponent");c(iw,"unescapePathComponent");function D2(t){if(t===void 0)return!0;if(t){if(Array.isArray(t)){for(var e=0,r=t.length;e<r;e++)if(D2(t[e]))return!0}else if(typeof t=="object"){for(var n=R2(t),i=n.length,o=0;o<i;o++)if(D2(t[n[o]]))return!0}}return!1}s(D2,"hasUndefined");c(D2,"hasUndefined");function J5(t,e){var r=[t];for(var n in e){var i=typeof e[n]=="object"?JSON.stringify(e[n],null,2):e[n];typeof i<"u"&&r.push(n+": "+i)}return r.join(`
|
|
823
|
+
`)}s(J5,"patchErrorMessageFormatter");c(J5,"patchErrorMessageFormatter");var XN=function(t){tre(e,t);function e(r,n,i,o,a){var f=this.constructor,l=t.call(this,J5(r,{name:n,index:i,operation:o,tree:a}))||this;return l.name=n,l.index=i,l.operation=o,l.tree=a,Object.setPrototypeOf(l,f.prototype),l.message=J5(r,{name:n,index:i,operation:o,tree:a}),l}return s(e,"PatchError2"),c(e,"PatchError"),e}(Error),yn=XN,nre=ms,qd={add:function(t,e,r){return t[e]=this.value,{newDocument:r}},remove:function(t,e,r){var n=t[e];return delete t[e],{newDocument:r,removed:n}},replace:function(t,e,r){var n=t[e];return t[e]=this.value,{newDocument:r,removed:n}},move:function(t,e,r){var n=l1(r,this.path);n&&(n=ms(n));var i=Uf(r,{op:"remove",path:this.from}).removed;return Uf(r,{op:"add",path:this.path,value:i}),{newDocument:r,removed:n}},copy:function(t,e,r){var n=l1(r,this.from);return Uf(r,{op:"add",path:this.path,value:ms(n)}),{newDocument:r}},test:function(t,e,r){return{newDocument:r,test:ah(t[e],this.value)}},_get:function(t,e,r){return this.value=t[e],{newDocument:r}}},ire={add:function(t,e,r){return B2(e)?t.splice(e,0,this.value):t[e]=this.value,{newDocument:r,index:e}},remove:function(t,e,r){var n=t.splice(e,1);return{newDocument:r,removed:n[0]}},replace:function(t,e,r){var n=t[e];return t[e]=this.value,{newDocument:r,removed:n}},move:qd.move,copy:qd.copy,test:qd.test,_get:qd._get};function l1(t,e){if(e=="")return t;var r={op:"_get",path:e};return Uf(t,r),r.value}s(l1,"getValueByPointer");c(l1,"getValueByPointer");function Uf(t,e,r,n,i,o){if(r===void 0&&(r=!1),n===void 0&&(n=!0),i===void 0&&(i=!0),o===void 0&&(o=0),r&&(typeof r=="function"?r(e,0,t,e.path):u1(e,0)),e.path===""){var a={newDocument:t};if(e.op==="add")return a.newDocument=e.value,a;if(e.op==="replace")return a.newDocument=e.value,a.removed=t,a;if(e.op==="move"||e.op==="copy")return a.newDocument=l1(t,e.from),e.op==="move"&&(a.removed=t),a;if(e.op==="test"){if(a.test=ah(t,e.value),a.test===!1)throw new yn("Test operation failed","TEST_OPERATION_FAILED",o,e,t);return a.newDocument=t,a}else{if(e.op==="remove")return a.removed=t,a.newDocument=null,a;if(e.op==="_get")return e.value=t,a;if(r)throw new yn("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",o,e,t);return a}}else{n||(t=ms(t));var f=e.path||"",l=f.split("/"),u=t,h=1,g=l.length,x=void 0,_=void 0,E=void 0;for(typeof r=="function"?E=r:E=u1;;){if(_=l[h],_&&_.indexOf("~")!=-1&&(_=iw(_)),i&&(_=="__proto__"||_=="prototype"&&h>0&&l[h-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(r&&x===void 0&&(u[_]===void 0?x=l.slice(0,h).join("/"):h==g-1&&(x=e.path),x!==void 0&&E(e,0,t,x)),h++,Array.isArray(u)){if(_==="-")_=u.length;else{if(r&&!B2(_))throw new yn("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",o,e,t);B2(_)&&(_=~~_)}if(h>=g){if(r&&e.op==="add"&&_>u.length)throw new yn("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",o,e,t);var a=ire[e.op].call(e,u,_,t);if(a.test===!1)throw new yn("Test operation failed","TEST_OPERATION_FAILED",o,e,t);return a}}else if(h>=g){var a=qd[e.op].call(e,u,_,t);if(a.test===!1)throw new yn("Test operation failed","TEST_OPERATION_FAILED",o,e,t);return a}if(u=u[_],r&&h<g&&(!u||typeof u!="object"))throw new yn("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",o,e,t)}}}s(Uf,"applyOperation");c(Uf,"applyOperation");function jv(t,e,r,n,i){if(n===void 0&&(n=!0),i===void 0&&(i=!0),r&&!Array.isArray(e))throw new yn("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(t=ms(t));for(var o=new Array(e.length),a=0,f=e.length;a<f;a++)o[a]=Uf(t,e[a],r,!0,i,a),t=o[a].newDocument;return o.newDocument=t,o}s(jv,"applyPatch");c(jv,"applyPatch");function QN(t,e,r){var n=Uf(t,e);if(n.test===!1)throw new yn("Test operation failed","TEST_OPERATION_FAILED",r,e,t);return n.newDocument}s(QN,"applyReducer");c(QN,"applyReducer");function u1(t,e,r,n){if(typeof t!="object"||t===null||Array.isArray(t))throw new yn("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,t,r);if(qd[t.op]){if(typeof t.path!="string")throw new yn("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,t,r);if(t.path.indexOf("/")!==0&&t.path.length>0)throw new yn('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,t,r);if((t.op==="move"||t.op==="copy")&&typeof t.from!="string")throw new yn("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,t,r);if((t.op==="add"||t.op==="replace"||t.op==="test")&&t.value===void 0)throw new yn("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,t,r);if((t.op==="add"||t.op==="replace"||t.op==="test")&&D2(t.value))throw new yn("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,t,r);if(r){if(t.op=="add"){var i=t.path.split("/").length,o=n.split("/").length;if(i!==o+1&&i!==o)throw new yn("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,t,r)}else if(t.op==="replace"||t.op==="remove"||t.op==="_get"){if(t.path!==n)throw new yn("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,t,r)}else if(t.op==="move"||t.op==="copy"){var a={op:"_get",path:t.from,value:void 0},f=sw([a],r);if(f&&f.name==="OPERATION_PATH_UNRESOLVABLE")throw new yn("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,t,r)}}}else throw new yn("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,t,r)}s(u1,"validator");c(u1,"validator");function sw(t,e,r){try{if(!Array.isArray(t))throw new yn("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)jv(ms(e),ms(t),r||!0);else{r=r||u1;for(var n=0;n<t.length;n++)r(t[n],n,e,void 0)}}catch(i){if(i instanceof yn)return i;throw i}}s(sw,"validate5");c(sw,"validate");function ah(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var r=Array.isArray(t),n=Array.isArray(e),i,o,a;if(r&&n){if(o=t.length,o!=e.length)return!1;for(i=o;i--!==0;)if(!ah(t[i],e[i]))return!1;return!0}if(r!=n)return!1;var f=Object.keys(t);if(o=f.length,o!==Object.keys(e).length)return!1;for(i=o;i--!==0;)if(!e.hasOwnProperty(f[i]))return!1;for(i=o;i--!==0;)if(a=f[i],!ah(t[a],e[a]))return!1;return!0}return t!==t&&e!==e}s(ah,"_areEquals");c(ah,"_areEquals");var eL={};Kr(eL,{compare:()=>oL,generate:()=>P2,observe:()=>sL,unobserve:()=>iL});var ow=new WeakMap,sre=function(){function t(e){this.observers=new Map,this.obj=e}return s(t,"Mirror2"),c(t,"Mirror"),t}(),ore=function(){function t(e,r){this.callback=e,this.observer=r}return s(t,"ObserverInfo2"),c(t,"ObserverInfo"),t}();function tL(t){return ow.get(t)}s(tL,"getMirror");c(tL,"getMirror");function rL(t,e){return t.observers.get(e)}s(rL,"getObserverFromMirror");c(rL,"getObserverFromMirror");function nL(t,e){t.observers.delete(e.callback)}s(nL,"removeObserverFromMirror");c(nL,"removeObserverFromMirror");function iL(t,e){e.unobserve()}s(iL,"unobserve");c(iL,"unobserve");function sL(t,e){var r=[],n,i=tL(t);if(!i)i=new sre(t),ow.set(t,i);else{var o=rL(i,e);n=o&&o.observer}if(n)return n;if(n={},i.value=ms(t),e){n.callback=e,n.next=null;var a=c(function(){P2(n)},"dirtyCheck"),f=c(function(){clearTimeout(n.next),n.next=setTimeout(a)},"fastCheck");typeof window<"u"&&(window.addEventListener("mouseup",f),window.addEventListener("keyup",f),window.addEventListener("mousedown",f),window.addEventListener("keydown",f),window.addEventListener("change",f))}return n.patches=r,n.object=t,n.unobserve=function(){P2(n),clearTimeout(n.next),nL(i,n),typeof window<"u"&&(window.removeEventListener("mouseup",f),window.removeEventListener("keyup",f),window.removeEventListener("mousedown",f),window.removeEventListener("keydown",f),window.removeEventListener("change",f))},i.observers.set(e,new ore(e,n)),n}s(sL,"observe");c(sL,"observe");function P2(t,e){e===void 0&&(e=!1);var r=ow.get(t.object);qv(r.value,t.object,t.patches,"",e),t.patches.length&&jv(r.value,t.patches);var n=t.patches;return n.length>0&&(t.patches=[],t.callback&&t.callback(n)),n}s(P2,"generate2");c(P2,"generate");function qv(t,e,r,n,i){if(e!==t){typeof e.toJSON=="function"&&(e=e.toJSON());for(var o=R2(e),a=R2(t),f=!1,l=!1,u=a.length-1;u>=0;u--){var h=a[u],g=t[h];if(M2(e,h)&&!(e[h]===void 0&&g!==void 0&&Array.isArray(e)===!1)){var x=e[h];typeof g=="object"&&g!=null&&typeof x=="object"&&x!=null&&Array.isArray(g)===Array.isArray(x)?qv(g,x,r,n+"/"+Ff(h),i):g!==x&&(f=!0,i&&r.push({op:"test",path:n+"/"+Ff(h),value:ms(g)}),r.push({op:"replace",path:n+"/"+Ff(h),value:ms(x)}))}else Array.isArray(t)===Array.isArray(e)?(i&&r.push({op:"test",path:n+"/"+Ff(h),value:ms(g)}),r.push({op:"remove",path:n+"/"+Ff(h)}),l=!0):(i&&r.push({op:"test",path:n,value:t}),r.push({op:"replace",path:n,value:e}),f=!0)}if(!(!l&&o.length==a.length))for(var u=0;u<o.length;u++){var h=o[u];!M2(t,h)&&e[h]!==void 0&&r.push({op:"add",path:n+"/"+Ff(h),value:ms(e[h])})}}}s(qv,"_generate");c(qv,"_generate");function oL(t,e,r){r===void 0&&(r=!1);var n=[];return qv(t,e,n,"",r),n}s(oL,"compare3");c(oL,"compare");var aL=Object.assign({},ZN,eL,{JsonPatchError:XN,deepClone:ms,escapePathComponent:Ff,unescapePathComponent:iw}),are=wr(S1(),1),cre=wr(ph(),1),bs;(function(t){t[t.PREFER_CACHE=0]="PREFER_CACHE",t[t.SYNC_ALWAYS=1]="SYNC_ALWAYS",t[t.NEVER_SYNC=2]="NEVER_SYNC"})(bs||(bs={}));var qM=wr(S1(),1);Ga();A1();var cL={tile:0,"caip10-link":1,model:2,MID:3,UNLOADABLE:4};function fL(t){let e=cL[t];if(typeof e<"u")return e;throw new Error(`No stream type registered for name ${t}`)}s(fL,"codeByName");c(fL,"codeByName");function lL(t){let e=Object.entries(cL).find(([,r])=>r===t);if(e)return e[0];throw new Error(`No stream type registered for index ${t}`)}s(lL,"nameByCode");c(lL,"nameByCode");var jc=s(class{},"StreamType");c(jc,"StreamType");jc.nameByCode=lL;jc.codeByName=fL;var HM=wr(pv(),1);function bo(t){let e,r,n;return typeof t=="object"?(e=t.hashFunction,r=t.expiring,n=t.tags):e=t,(i,o,a)=>{if(a.value!=null)a.value=Y5(a.value,e,r,n);else if(a.get!=null)a.get=Y5(a.get,e,r,n);else throw"Only put a Memoize() decorator on a method or get accessor."}}s(bo,"Memoize");c(bo,"Memoize");var Y4=new Map;function Y5(t,e,r=0,n){let i=Symbol("__memoized_map__");return function(...o){let a;this.hasOwnProperty(i)||Object.defineProperty(this,i,{configurable:!1,enumerable:!1,writable:!1,value:new Map});let f=this[i];if(Array.isArray(n))for(let l of n)Y4.has(l)?Y4.get(l).push(f):Y4.set(l,[f]);if(e||o.length>0||r>0){let l;e===!0?l=o.map(g=>g.toString()).join("!"):e?l=e.apply(this,o):l=o[0];let u=`${l}__timestamp`,h=!1;if(r>0)if(!f.has(u))h=!0;else{let g=f.get(u);h=Date.now()-g>r}f.has(l)&&!h?a=f.get(l):(a=t.apply(this,o),f.set(l,a),r>0&&f.set(u,Date.now()))}else{let l=this;f.has(l)?a=f.get(l):(a=t.apply(this,o),f.set(l,a))}return a}}s(Y5,"getNewFunction");c(Y5,"getNewFunction");var aw=206;Ga();A1();cv();var zM=wr(pv(),1);function U1(t){try{return t()}catch(e){return e}}s(U1,"tryCatch");c(U1,"tryCatch");Ga();var $M=wr(pv(),1);uh();function Wl(t){let e=$M.default.decode(t),r=$M.default.decode.bytes,n=t.subarray(r);return[e,n,r]}s(Wl,"readVarint");c(Wl,"readVarint");function uL(t){return t===0||t===1}s(uL,"isCidVersion");c(uL,"isCidVersion");function Z5(t){let[e,r]=Wl(t);if(!uL(e))throw new Error(`Unknown CID version ${e}`);let[n,i]=Wl(r),[,o,a]=Wl(i),[f,,l]=Wl(o),u=i.subarray(0,a+l+f),h=i.subarray(a+l+f);return[fr.create(e,n,G8(u)),h]}s(Z5,"readCid");c(Z5,"readCid");Ga();A1();function j1(t,e="StreamRef"){let[r,n]=Wl(t);if(r!==aw)throw new Error(`Invalid ${e}, does not include streamid codec`);let[i,o]=Wl(n),a=Z5(o),[f,l]=a;if(l.length===0)return{kind:"stream-id",type:i,genesis:f};if(l.length===1&&l[0]===0)return{kind:"commit-id",type:i,genesis:f,commit:null};{let[u]=Z5(l);return{kind:"commit-id",type:i,genesis:f,commit:u}}}s(j1,"fromBytes");c(j1,"fromBytes");var fre=/(ceramic:\/\/|\/ceramic\/)?([a-zA-Z0-9]+)(\?commit=([a-zA-Z0-9]+))?/;function Hv(t,e="StreamRef"){let r=fre.exec(t)||[],n=r[2];if(!n)throw new Error(`Malformed ${e} string: ${t}`);let i=Qf.decode(n),o=j1(i),a=r[4];return a?{kind:"commit-id",type:o.type,genesis:o.genesis,commit:cw(o.genesis,a)}:o}s(Hv,"fromString4");c(Hv,"fromString");function dL(t){try{return typeof t=="string"?fr.parse(t):fr.asCID(t)}catch{return null}}s(dL,"parseCID");c(dL,"parseCID");function cw(t,e=null){if(!e||e==="0")return null;let r=dL(e);if(r)return t.equals(r)?null:r;throw new Error("Cannot specify commit as a number except to request commit 0 (the genesis commit)")}s(cw,"parseCommit");c(cw,"parseCommit");var q1=s(function(t,e,r,n){var i=arguments.length,o=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,n);else for(var f=t.length-1;f>=0;f--)(a=t[f])&&(o=(i<3?a(o):i>3?a(e,r,o):a(e,r))||o);return i>3&&o&&Object.defineProperty(e,r,o),o},"__decorate"),po=s(function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},"__metadata"),hL=s(class extends Error{constructor(t){super(`Invalid StreamID bytes ${Qf.encode(t)}: contains commit`)}},"InvalidStreamIDBytesError");c(hL,"InvalidStreamIDBytesError");var pL=s(class extends Error{constructor(t){super(`Invalid StreamID string ${t}: contains commit`)}},"InvalidStreamIDStringError");c(pL,"InvalidStreamIDStringError");function fw(t){let e=j1(t,"StreamID");if(e.kind==="stream-id")return new xr(e.type,e.genesis);throw new hL(t)}s(fw,"fromBytes2");c(fw,"fromBytes");function mL(t){return U1(()=>fw(t))}s(mL,"fromBytesNoThrow");c(mL,"fromBytesNoThrow");function lw(t){let e=Hv(t,"StreamID");if(e.kind==="stream-id")return new xr(e.type,e.genesis);throw new pL(t)}s(lw,"fromString5");c(lw,"fromString");function gL(t){return U1(()=>lw(t))}s(gL,"fromStringNoThrow");c(gL,"fromStringNoThrow");var GM=Symbol.for("@ceramicnetwork/streamid/StreamID"),xr=s(class{constructor(t,e){if(this._tag=GM,!(t||t===0))throw new Error("StreamID constructor: type required");if(!e)throw new Error("StreamID constructor: cid required");this._type=typeof t=="string"?jc.codeByName(t):t,this._cid=typeof e=="string"?fr.parse(e):e}static isInstance(t){return typeof t=="object"&&"_tag"in t&&t._tag===GM}static async fromGenesis(t,e){let r=await _v({value:e,codec:bh,hasher:dh});return new xr(t,r.cid)}get type(){return this._type}get typeName(){return jc.nameByCode(this._type)}get cid(){return this._cid}get bytes(){let t=zM.default.encode(aw),e=zM.default.encode(this.type);return qf([t,e,this.cid.bytes])}get baseID(){return new xr(this._type,this._cid)}equals(t){return xr.isInstance(t)?this.type===t.type&&this.cid.equals(t.cid):!1}toString(){return Qf.encode(this.bytes)}toUrl(){return`ceramic://${this.toString()}`}[Symbol.for("nodejs.util.inspect.custom")](){return`StreamID(${this.toString()})`}[Symbol.toPrimitive](){return this.toString()}},"StreamID");c(xr,"StreamID");xr.fromBytes=fw;xr.fromBytesNoThrow=mL;xr.fromString=lw;xr.fromStringNoThrow=gL;q1([bo(),po("design:type",String),po("design:paramtypes",[])],xr.prototype,"typeName",null);q1([bo(),po("design:type",Uint8Array),po("design:paramtypes",[])],xr.prototype,"bytes",null);q1([bo(),po("design:type",xr),po("design:paramtypes",[])],xr.prototype,"baseID",null);q1([bo(),po("design:type",Function),po("design:paramtypes",[]),po("design:returntype",String)],xr.prototype,"toString",null);q1([bo(),po("design:type",Function),po("design:paramtypes",[]),po("design:returntype",String)],xr.prototype,"toUrl",null);var Ch=s(function(t,e,r,n){var i=arguments.length,o=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,n);else for(var f=t.length-1;f>=0;f--)(a=t[f])&&(o=(i<3?a(o):i>3?a(e,r,o):a(e,r))||o);return i>3&&o&&Object.defineProperty(e,r,o),o},"__decorate2"),gs=s(function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},"__metadata2"),Z4=s(function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},"__classPrivateFieldSet"),Mc=s(function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},"__classPrivateFieldGet"),Bd,zl,Ip,bL=s(class extends Error{constructor(t){super(`Error while parsing CommitID from bytes ${Qf.encode(t)}: no commit information provided`)}},"InvalidCommitIDBytesError");c(bL,"InvalidCommitIDBytesError");var vL=s(class extends Error{constructor(t){super(`Error while parsing CommitID from string ${t}: no commit information provided`)}},"InvalidCommitIDStringError");c(vL,"InvalidCommitIDStringError");function uw(t){let e=j1(t,"CommitID");if(e.kind==="commit-id")return new $r(e.type,e.genesis,e.commit);throw new bL(t)}s(uw,"fromBytes3");c(uw,"fromBytes");function yL(t){return U1(()=>uw(t))}s(yL,"fromBytesNoThrow2");c(yL,"fromBytesNoThrow");function dw(t){let e=Hv(t,"CommitID");if(e.kind==="commit-id")return new $r(e.type,e.genesis,e.commit);throw new vL(t)}s(dw,"fromString6");c(dw,"fromString");function xL(t){return U1(()=>dw(t))}s(xL,"fromStringNoThrow2");c(xL,"fromStringNoThrow");var KM=Symbol.for("@ceramicnetwork/streamid/CommitID");function wL(t,e){return new $r(t.type,t.cid,e)}s(wL,"make");c(wL,"make");var $r=s(class{constructor(t,e,r=null){if(this._tag=KM,Bd.set(this,void 0),zl.set(this,void 0),Ip.set(this,void 0),!t&&t!==0)throw new Error("constructor: type required");if(!e)throw new Error("constructor: cid required");Z4(this,Bd,typeof t=="string"?jc.codeByName(t):t,"f"),Z4(this,zl,typeof e=="string"?fr.parse(e):e,"f"),Z4(this,Ip,cw(Mc(this,zl,"f"),r),"f")}static isInstance(t){return typeof t=="object"&&"_tag"in t&&t._tag===KM}get baseID(){return new xr(Mc(this,Bd,"f"),Mc(this,zl,"f"))}get type(){return Mc(this,Bd,"f")}get typeName(){return jc.nameByCode(Mc(this,Bd,"f"))}get cid(){return Mc(this,zl,"f")}get commit(){return Mc(this,Ip,"f")||Mc(this,zl,"f")}get bytes(){let t=HM.default.encode(aw),e=HM.default.encode(this.type),r=Mc(this,Ip,"f")?.bytes||new Uint8Array([0]);return qf([t,e,this.cid.bytes,r])}equals(t){return this.type===t.type&&this.cid.equals(t.cid)&&this.commit.equals(t.commit)}toString(){return Qf.encode(this.bytes)}toUrl(){return`ceramic://${this.toString()}`}[(Bd=new WeakMap,zl=new WeakMap,Ip=new WeakMap,Symbol.for("nodejs.util.inspect.custom"))](){return`CommitID(${this.toString()})`}[Symbol.toPrimitive](){return this.toString()}},"CommitID");c($r,"CommitID");$r.fromBytes=uw;$r.fromBytesNoThrow=yL;$r.fromString=dw;$r.fromStringNoThrow=xL;$r.make=wL;Ch([bo(),gs("design:type",xr),gs("design:paramtypes",[])],$r.prototype,"baseID",null);Ch([bo(),gs("design:type",String),gs("design:paramtypes",[])],$r.prototype,"typeName",null);Ch([bo(),gs("design:type",fr),gs("design:paramtypes",[])],$r.prototype,"commit",null);Ch([bo(),gs("design:type",Uint8Array),gs("design:paramtypes",[])],$r.prototype,"bytes",null);Ch([bo(),gs("design:type",Function),gs("design:paramtypes",[]),gs("design:returntype",String)],$r.prototype,"toString",null);Ch([bo(),gs("design:type",Function),gs("design:paramtypes",[]),gs("design:returntype",String)],$r.prototype,"toUrl",null);A1();var Yf;(function(t){function e(i){let o=j1(i);switch(o.kind){case"commit-id":return new $r(o.type,o.genesis,o.commit);case"stream-id":return new xr(o.type,o.genesis);default:throw new Error(`Malformed StreamRef bytes: ${Qf.encode(i)}`)}}s(e,"fromBytes4"),c(e,"fromBytes"),t.fromBytes=e;function r(i){let o=Hv(i);switch(o.kind){case"commit-id":return new $r(o.type,o.genesis,o.commit);case"stream-id":return new xr(o.type,o.genesis);default:throw new Error(`Malformed StreamRef string: ${i}`)}}s(r,"fromString7"),c(r,"fromString"),t.fromString=r;function n(i){if(xr.isInstance(i)||$r.isInstance(i))return i;if(i instanceof Uint8Array)return e(i);if(typeof i=="string")return r(i);throw new Error(`Can not build CommitID or StreamID from ${JSON.stringify(i)}`)}s(n,"from4"),c(n,"from"),t.from=n})(Yf||(Yf={}));var lre=wr(XY(),1),{__extends:$s,__assign:$pe,__rest:Gpe,__decorate:Kpe,__param:Vpe,__esDecorate:Wpe,__runInitializers:Jpe,__propKey:Ype,__setFunctionName:Zpe,__metadata:Xpe,__awaiter:ure,__generator:_L,__exportStar:Qpe,__createBinding:e1e,__values:O2,__read:Zf,__spread:t1e,__spreadArrays:r1e,__spreadArray:su,__await:X4,__asyncGenerator:dre,__asyncDelegator:n1e,__asyncValues:hre,__makeTemplateObject:i1e,__importStar:s1e,__importDefault:o1e,__classPrivateFieldGet:a1e,__classPrivateFieldSet:c1e,__classPrivateFieldIn:f1e}=lre.default;function Gr(t){return typeof t=="function"}s(Gr,"isFunction");c(Gr,"isFunction");function zv(t){var e=c(function(n){Error.call(n),n.stack=new Error().stack},"_super"),r=t(e);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}s(zv,"createErrorClass");c(zv,"createErrorClass");var Q4=zv(function(t){return c(s(function(r){t(this),this.message=r?r.length+` errors occurred during unsubscription:
|
|
824
824
|
`+r.map(function(n,i){return i+1+") "+n.toString()}).join(`
|
|
825
825
|
`):"",this.name="UnsubscriptionError",this.errors=r},"UnsubscriptionErrorImpl"),"UnsubscriptionErrorImpl")});function d1(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}s(d1,"arrRemove");c(d1,"arrRemove");var H1=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return s(t,"Subscription2"),c(t,"Subscription"),t.prototype.unsubscribe=function(){var e,r,n,i,o;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var f=O2(a),l=f.next();!l.done;l=f.next()){var u=l.value;u.remove(this)}}catch(T){e={error:T}}finally{try{l&&!l.done&&(r=f.return)&&r.call(f)}finally{if(e)throw e.error}}else a.remove(this);var h=this.initialTeardown;if(Gr(h))try{h()}catch(T){o=T instanceof Q4?T.errors:[T]}var g=this._finalizers;if(g){this._finalizers=null;try{for(var x=O2(g),_=x.next();!_.done;_=x.next()){var E=_.value;try{X5(E)}catch(T){o=o??[],T instanceof Q4?o=su(su([],Zf(o)),Zf(T.errors)):o.push(T)}}}catch(T){n={error:T}}finally{try{_&&!_.done&&(i=x.return)&&i.call(x)}finally{if(n)throw n.error}}}if(o)throw new Q4(o)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)X5(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(e)}},t.prototype._hasParent=function(e){var r=this._parentage;return r===e||Array.isArray(r)&&r.includes(e)},t.prototype._addParent=function(e){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(e),r):r?[r,e]:e},t.prototype._removeParent=function(e){var r=this._parentage;r===e?this._parentage=null:Array.isArray(r)&&d1(r,e)},t.prototype.remove=function(e){var r=this._finalizers;r&&d1(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),AL=H1.EMPTY;function hw(t){return t instanceof H1||t&&"closed"in t&&Gr(t.remove)&&Gr(t.add)&&Gr(t.unsubscribe)}s(hw,"isSubscription");c(hw,"isSubscription");function X5(t){Gr(t)?t():t.unsubscribe()}s(X5,"execFinalizer");c(X5,"execFinalizer");var yu={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},F2={setTimeout:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=F2.delegate;return i?.setTimeout?i.setTimeout.apply(i,su([t,e],Zf(r))):setTimeout.apply(void 0,su([t,e],Zf(r)))},clearTimeout:function(t){var e=F2.delegate;return(e?.clearTimeout||clearTimeout)(t)},delegate:void 0};function pw(t){F2.setTimeout(function(){var e=yu.onUnhandledError;if(e)e(t);else throw t})}s(pw,"reportUnhandledError");c(pw,"reportUnhandledError");function Q5(){}s(Q5,"noop");c(Q5,"noop");var pre=function(){return $v("C",void 0,void 0)}();function EL(t){return $v("E",void 0,t)}s(EL,"errorNotification");c(EL,"errorNotification");function CL(t){return $v("N",t,void 0)}s(CL,"nextNotification");c(CL,"nextNotification");function $v(t,e,r){return{kind:t,value:e,error:r}}s($v,"createNotification");c($v,"createNotification");var Jl=null;function zp(t){if(yu.useDeprecatedSynchronousErrorHandling){var e=!Jl;if(e&&(Jl={errorThrown:!1,error:null}),t(),e){var r=Jl,n=r.errorThrown,i=r.error;if(Jl=null,n)throw i}}else t()}s(zp,"errorContext");c(zp,"errorContext");function SL(t){yu.useDeprecatedSynchronousErrorHandling&&Jl&&(Jl.errorThrown=!0,Jl.error=t)}s(SL,"captureError");c(SL,"captureError");var mw=function(t){$s(e,t);function e(r){var n=t.call(this)||this;return n.isStopped=!1,r?(n.destination=r,hw(r)&&r.add(n)):n.destination=bre,n}return s(e,"Subscriber2"),c(e,"Subscriber"),e.create=function(r,n,i){return new e8(r,n,i)},e.prototype.next=function(r){this.isStopped?Yb(CL(r),this):this._next(r)},e.prototype.error=function(r){this.isStopped?Yb(EL(r),this):(this.isStopped=!0,this._error(r))},e.prototype.complete=function(){this.isStopped?Yb(pre,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(r){this.destination.next(r)},e.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(H1),mre=Function.prototype.bind;function Jb(t,e){return mre.call(t,e)}s(Jb,"bind");c(Jb,"bind");var gre=function(){function t(e){this.partialObserver=e}return s(t,"ConsumerObserver2"),c(t,"ConsumerObserver"),t.prototype.next=function(e){var r=this.partialObserver;if(r.next)try{r.next(e)}catch(n){Rp(n)}},t.prototype.error=function(e){var r=this.partialObserver;if(r.error)try{r.error(e)}catch(n){Rp(n)}else Rp(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(r){Rp(r)}},t}(),e8=function(t){$s(e,t);function e(r,n,i){var o=t.call(this)||this,a;if(Gr(r)||!r)a={next:r??void 0,error:n??void 0,complete:i??void 0};else{var f;o&&yu.useDeprecatedNextContext?(f=Object.create(r),f.unsubscribe=function(){return o.unsubscribe()},a={next:r.next&&Jb(r.next,f),error:r.error&&Jb(r.error,f),complete:r.complete&&Jb(r.complete,f)}):a=r}return o.destination=new gre(a),o}return s(e,"SafeSubscriber2"),c(e,"SafeSubscriber"),e}(mw);function Rp(t){yu.useDeprecatedSynchronousErrorHandling?SL(t):pw(t)}s(Rp,"handleUnhandledError");c(Rp,"handleUnhandledError");function IL(t){throw t}s(IL,"defaultErrorHandler");c(IL,"defaultErrorHandler");function Yb(t,e){var r=yu.onStoppedNotification;r&&F2.setTimeout(function(){return r(t,e)})}s(Yb,"handleStoppedNotification");c(Yb,"handleStoppedNotification");var bre={closed:!0,next:Q5,error:IL,complete:Q5},gw=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Gv(t){return t}s(Gv,"identity3");c(Gv,"identity");function kL(t){return t.length===0?Gv:t.length===1?t[0]:c(s(function(r){return t.reduce(function(n,i){return i(n)},r)},"piped"),"piped")}s(kL,"pipeFromArray");c(kL,"pipeFromArray");var fi=function(){function t(e){e&&(this._subscribe=e)}return s(t,"Observable2"),c(t,"Observable"),t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(e,r,n){var i=this,o=ML(e)?e:new e8(e,r,n);return zp(function(){var a=i,f=a.operator,l=a.source;o.add(f?f.call(o,l):l?i._subscribe(o):i._trySubscribe(o))}),o},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(r){e.error(r)}},t.prototype.forEach=function(e,r){var n=this;return r=t8(r),new r(function(i,o){var a=new e8({next:function(f){try{e(f)}catch(l){o(l),a.unsubscribe()}},error:o,complete:i});n.subscribe(a)})},t.prototype._subscribe=function(e){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(e)},t.prototype[gw]=function(){return this},t.prototype.pipe=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return kL(e)(this)},t.prototype.toPromise=function(e){var r=this;return e=t8(e),new e(function(n,i){var o;r.subscribe(function(a){return o=a},function(a){return i(a)},function(){return n(o)})})},t.create=function(e){return new t(e)},t}();function t8(t){var e;return(e=t??yu.Promise)!==null&&e!==void 0?e:Promise}s(t8,"getPromiseCtor");c(t8,"getPromiseCtor");function TL(t){return t&&Gr(t.next)&&Gr(t.error)&&Gr(t.complete)}s(TL,"isObserver");c(TL,"isObserver");function ML(t){return t&&t instanceof mw||TL(t)&&hw(t)}s(ML,"isSubscriber");c(ML,"isSubscriber");function RL(t){return Gr(t?.lift)}s(RL,"hasLift");c(RL,"hasLift");function Ja(t){return function(e){if(RL(e))return e.lift(function(r){try{return t(r,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}s(Ja,"operate");c(Ja,"operate");function Vo(t,e,r,n,i){return new vre(t,e,r,n,i)}s(Vo,"createOperatorSubscriber");c(Vo,"createOperatorSubscriber");var vre=function(t){$s(e,t);function e(r,n,i,o,a,f){var l=t.call(this,r)||this;return l.onFinalize=a,l.shouldUnsubscribe=f,l._next=n?function(u){try{n(u)}catch(h){r.error(h)}}:t.prototype._next,l._error=o?function(u){try{o(u)}catch(h){r.error(h)}finally{this.unsubscribe()}}:t.prototype._error,l._complete=i?function(){try{i()}catch(u){r.error(u)}finally{this.unsubscribe()}}:t.prototype._complete,l}return s(e,"OperatorSubscriber2"),c(e,"OperatorSubscriber"),e.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;t.prototype.unsubscribe.call(this),!n&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},e}(mw),yre=zv(function(t){return c(s(function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"},"ObjectUnsubscribedErrorImpl"),"ObjectUnsubscribedErrorImpl")}),BL=function(t){$s(e,t);function e(){var r=t.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return s(e,"Subject2"),c(e,"Subject"),e.prototype.lift=function(r){var n=new VM(this,this);return n.operator=r,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new yre},e.prototype.next=function(r){var n=this;zp(function(){var i,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var a=O2(n.currentObservers),f=a.next();!f.done;f=a.next()){var l=f.value;l.next(r)}}catch(u){i={error:u}}finally{try{f&&!f.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}}})},e.prototype.error=function(r){var n=this;zp(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var i=n.observers;i.length;)i.shift().error(r)}})},e.prototype.complete=function(){var r=this;zp(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(r){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,r)},e.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},e.prototype._innerSubscribe=function(r){var n=this,i=this,o=i.hasError,a=i.isStopped,f=i.observers;return o||a?AL:(this.currentObservers=null,f.push(r),new H1(function(){n.currentObservers=null,d1(f,r)}))},e.prototype._checkFinalizedStatuses=function(r){var n=this,i=n.hasError,o=n.thrownError,a=n.isStopped;i?r.error(o):a&&r.complete()},e.prototype.asObservable=function(){var r=new fi;return r.source=this,r},e.create=function(r,n){return new VM(r,n)},e}(fi),VM=function(t){$s(e,t);function e(r,n){var i=t.call(this)||this;return i.destination=r,i.source=n,i}return s(e,"AnonymousSubject2"),c(e,"AnonymousSubject"),e.prototype.next=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,r)},e.prototype.error=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,r)},e.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},e.prototype._subscribe=function(r){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&i!==void 0?i:AL},e}(BL),xre=function(t){$s(e,t);function e(r){var n=t.call(this)||this;return n._value=r,n}return s(e,"BehaviorSubject2"),c(e,"BehaviorSubject"),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(r){var n=t.prototype._subscribe.call(this,r);return!n.closed&&r.next(this._value),n},e.prototype.getValue=function(){var r=this,n=r.hasError,i=r.thrownError,o=r._value;if(n)throw i;return this._throwIfClosed(),o},e.prototype.next=function(r){t.prototype.next.call(this,this._value=r)},e}(BL),DL={now:function(){return(DL.delegate||Date).now()},delegate:void 0},wre=function(t){$s(e,t);function e(r,n){return t.call(this)||this}return s(e,"Action2"),c(e,"Action"),e.prototype.schedule=function(r,n){return n===void 0&&(n=0),this},e}(H1),N2={setInterval:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=N2.delegate;return i?.setInterval?i.setInterval.apply(i,su([t,e],Zf(r))):setInterval.apply(void 0,su([t,e],Zf(r)))},clearInterval:function(t){var e=N2.delegate;return(e?.clearInterval||clearInterval)(t)},delegate:void 0},_re=function(t){$s(e,t);function e(r,n){var i=t.call(this,r,n)||this;return i.scheduler=r,i.work=n,i.pending=!1,i}return s(e,"AsyncAction2"),c(e,"AsyncAction"),e.prototype.schedule=function(r,n){var i;if(n===void 0&&(n=0),this.closed)return this;this.state=r;var o=this.id,a=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(a,o,n)),this.pending=!0,this.delay=n,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(a,this.id,n),this},e.prototype.requestAsyncId=function(r,n,i){return i===void 0&&(i=0),N2.setInterval(r.flush.bind(r,this),i)},e.prototype.recycleAsyncId=function(r,n,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return n;n!=null&&N2.clearInterval(n)},e.prototype.execute=function(r,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(r,n);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(r,n){var i=!1,o;try{this.work(r)}catch(a){i=!0,o=a||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),o},e.prototype.unsubscribe=function(){if(!this.closed){var r=this,n=r.id,i=r.scheduler,o=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,d1(o,this),n!=null&&(this.id=this.recycleAsyncId(i,n,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}(wre),WM=function(){function t(e,r){r===void 0&&(r=t.now),this.schedulerActionCtor=e,this.now=r}return s(t,"Scheduler2"),c(t,"Scheduler"),t.prototype.schedule=function(e,r,n){return r===void 0&&(r=0),new this.schedulerActionCtor(this,e).schedule(n,r)},t.now=DL.now,t}(),Are=function(t){$s(e,t);function e(r,n){n===void 0&&(n=WM.now);var i=t.call(this,r,n)||this;return i.actions=[],i._active=!1,i}return s(e,"AsyncScheduler2"),c(e,"AsyncScheduler"),e.prototype.flush=function(r){var n=this.actions;if(this._active){n.push(r);return}var i;this._active=!0;do if(i=r.execute(r.state,r.delay))break;while(r=n.shift());if(this._active=!1,i){for(;r=n.shift();)r.unsubscribe();throw i}},e}(WM),Ere=new Are(_re),Cre=Ere,PL=new fi(function(t){return t.complete()});function bw(t){return t&&Gr(t.schedule)}s(bw,"isScheduler");c(bw,"isScheduler");function vw(t){return t[t.length-1]}s(vw,"last");c(vw,"last");function OL(t){return bw(vw(t))?t.pop():void 0}s(OL,"popScheduler");c(OL,"popScheduler");function FL(t,e){return typeof vw(t)=="number"?t.pop():e}s(FL,"popNumber");c(FL,"popNumber");var yw=c(function(t){return t&&typeof t.length=="number"&&typeof t!="function"},"isArrayLike");function xw(t){return Gr(t?.then)}s(xw,"isPromise");c(xw,"isPromise");function ww(t){return Gr(t[gw])}s(ww,"isInteropObservable");c(ww,"isInteropObservable");function _w(t){return Symbol.asyncIterator&&Gr(t?.[Symbol.asyncIterator])}s(_w,"isAsyncIterable");c(_w,"isAsyncIterable");function Aw(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}s(Aw,"createInvalidObservableTypeError");c(Aw,"createInvalidObservableTypeError");function NL(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}s(NL,"getSymbolIterator");c(NL,"getSymbolIterator");var LL=NL();function Ew(t){return Gr(t?.[LL])}s(Ew,"isIterable");c(Ew,"isIterable");function Cw(t){return dre(this,arguments,c(s(function(){var r,n,i,o;return _L(this,function(a){switch(a.label){case 0:r=t.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,X4(r.read())];case 3:return n=a.sent(),i=n.value,o=n.done,o?[4,X4(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,X4(i)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})},"readableStreamLikeToAsyncGenerator_1"),"readableStreamLikeToAsyncGenerator_1"))}s(Cw,"readableStreamLikeToAsyncGenerator");c(Cw,"readableStreamLikeToAsyncGenerator");function Sw(t){return Gr(t?.getReader)}s(Sw,"isReadableStreamLike");c(Sw,"isReadableStreamLike");function Kc(t){if(t instanceof fi)return t;if(t!=null){if(ww(t))return UL(t);if(yw(t))return jL(t);if(xw(t))return qL(t);if(_w(t))return Iw(t);if(Ew(t))return HL(t);if(Sw(t))return zL(t)}throw Aw(t)}s(Kc,"innerFrom");c(Kc,"innerFrom");function UL(t){return new fi(function(e){var r=t[gw]();if(Gr(r.subscribe))return r.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}s(UL,"fromInteropObservable");c(UL,"fromInteropObservable");function jL(t){return new fi(function(e){for(var r=0;r<t.length&&!e.closed;r++)e.next(t[r]);e.complete()})}s(jL,"fromArrayLike");c(jL,"fromArrayLike");function qL(t){return new fi(function(e){t.then(function(r){e.closed||(e.next(r),e.complete())},function(r){return e.error(r)}).then(null,pw)})}s(qL,"fromPromise");c(qL,"fromPromise");function HL(t){return new fi(function(e){var r,n;try{for(var i=O2(t),o=i.next();!o.done;o=i.next()){var a=o.value;if(e.next(a),e.closed)return}}catch(f){r={error:f}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}e.complete()})}s(HL,"fromIterable");c(HL,"fromIterable");function Iw(t){return new fi(function(e){$L(t,e).catch(function(r){return e.error(r)})})}s(Iw,"fromAsyncIterable");c(Iw,"fromAsyncIterable");function zL(t){return Iw(Cw(t))}s(zL,"fromReadableStreamLike");c(zL,"fromReadableStreamLike");function $L(t,e){var r,n,i,o;return ure(this,void 0,void 0,function(){var a,f;return _L(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),r=hre(t),l.label=1;case 1:return[4,r.next()];case 2:if(n=l.sent(),!!n.done)return[3,4];if(a=n.value,e.next(a),e.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return f=l.sent(),i={error:f},[3,11];case 6:return l.trys.push([6,,9,10]),n&&!n.done&&(o=r.return)?[4,o.call(r)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}s($L,"process2");c($L,"process");function Nc(t,e,r,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var o=e.schedule(function(){r(),i?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(o),!i)return o}s(Nc,"executeSchedule");c(Nc,"executeSchedule");function kw(t,e){return e===void 0&&(e=0),Ja(function(r,n){r.subscribe(Vo(n,function(i){return Nc(n,t,function(){return n.next(i)},e)},function(){return Nc(n,t,function(){return n.complete()},e)},function(i){return Nc(n,t,function(){return n.error(i)},e)}))})}s(kw,"observeOn");c(kw,"observeOn");function Tw(t,e){return e===void 0&&(e=0),Ja(function(r,n){n.add(t.schedule(function(){return r.subscribe(n)},e))})}s(Tw,"subscribeOn");c(Tw,"subscribeOn");function GL(t,e){return Kc(t).pipe(Tw(e),kw(e))}s(GL,"scheduleObservable");c(GL,"scheduleObservable");function KL(t,e){return Kc(t).pipe(Tw(e),kw(e))}s(KL,"schedulePromise");c(KL,"schedulePromise");function VL(t,e){return new fi(function(r){var n=0;return e.schedule(function(){n===t.length?r.complete():(r.next(t[n++]),r.closed||this.schedule())})})}s(VL,"scheduleArray");c(VL,"scheduleArray");function WL(t,e){return new fi(function(r){var n;return Nc(r,e,function(){n=t[LL](),Nc(r,e,function(){var i,o,a;try{i=n.next(),o=i.value,a=i.done}catch(f){r.error(f);return}a?r.complete():r.next(o)},0,!0)}),function(){return Gr(n?.return)&&n.return()}})}s(WL,"scheduleIterable");c(WL,"scheduleIterable");function Mw(t,e){if(!t)throw new Error("Iterable cannot be null");return new fi(function(r){Nc(r,e,function(){var n=t[Symbol.asyncIterator]();Nc(r,e,function(){n.next().then(function(i){i.done?r.complete():r.next(i.value)})},0,!0)})})}s(Mw,"scheduleAsyncIterable");c(Mw,"scheduleAsyncIterable");function JL(t,e){return Mw(Cw(t),e)}s(JL,"scheduleReadableStreamLike");c(JL,"scheduleReadableStreamLike");function YL(t,e){if(t!=null){if(ww(t))return GL(t,e);if(yw(t))return VL(t,e);if(xw(t))return KL(t,e);if(_w(t))return Mw(t,e);if(Ew(t))return WL(t,e);if(Sw(t))return JL(t,e)}throw Aw(t)}s(YL,"scheduled");c(YL,"scheduled");function ZL(t,e){return e?YL(t,e):Kc(t)}s(ZL,"from3");c(ZL,"from");var XL=zv(function(t){return c(s(function(){t(this),this.name="EmptyError",this.message="no elements in sequence"},"EmptyErrorImpl"),"EmptyErrorImpl")});function QL(t){return t instanceof Date&&!isNaN(t)}s(QL,"isValidDate");c(QL,"isValidDate");function Rw(t,e){return Ja(function(r,n){var i=0;r.subscribe(Vo(n,function(o){n.next(t.call(e,o,i++))}))})}s(Rw,"map");c(Rw,"map");var Sre=Array.isArray;function eU(t,e){return Sre(e)?t.apply(void 0,su([],Zf(e))):t(e)}s(eU,"callOrApply");c(eU,"callOrApply");function tU(t){return Rw(function(e){return eU(t,e)})}s(tU,"mapOneOrManyArgs");c(tU,"mapOneOrManyArgs");function rU(t,e,r,n,i,o,a,f){var l=[],u=0,h=0,g=!1,x=c(function(){g&&!l.length&&!u&&e.complete()},"checkComplete"),_=c(function(T){return u<n?E(T):l.push(T)},"outerNext"),E=c(function(T){o&&e.next(T),u++;var B=!1;Kc(r(T,h++)).subscribe(Vo(e,function(F){i?.(F),o?_(F):e.next(F)},function(){B=!0},void 0,function(){if(B)try{u--;for(var F=c(function(){var H=l.shift();a?Nc(e,a,function(){return E(H)}):E(H)},"_loop_1");l.length&&u<n;)F();x()}catch(H){e.error(H)}}))},"doInnerSub");return t.subscribe(Vo(e,_,function(){g=!0,x()})),function(){f?.()}}s(rU,"mergeInternals");c(rU,"mergeInternals");function Kv(t,e,r){return r===void 0&&(r=1/0),Gr(e)?Kv(function(n,i){return Rw(function(o,a){return e(n,o,i,a)})(Kc(t(n,i)))},r):(typeof e=="number"&&(r=e),Ja(function(n,i){return rU(n,i,t,r)}))}s(Kv,"mergeMap");c(Kv,"mergeMap");function nU(t){return t===void 0&&(t=1/0),Kv(Gv,t)}s(nU,"mergeAll");c(nU,"mergeAll");var Ire=["addListener","removeListener"],kre=["addEventListener","removeEventListener"],Tre=["on","off"];function L2(t,e,r,n){if(Gr(r)&&(n=r,r=void 0),n)return L2(t,e,r).pipe(tU(n));var i=Zf(oU(t)?kre.map(function(f){return function(l){return t[f](e,l,r)}}):iU(t)?Ire.map(r8(t,e)):sU(t)?Tre.map(r8(t,e)):[],2),o=i[0],a=i[1];if(!o&&yw(t))return Kv(function(f){return L2(f,e,r)})(Kc(t));if(!o)throw new TypeError("Invalid event target");return new fi(function(f){var l=c(function(){for(var u=[],h=0;h<arguments.length;h++)u[h]=arguments[h];return f.next(1<u.length?u:u[0])},"handler");return o(l),function(){return a(l)}})}s(L2,"fromEvent");c(L2,"fromEvent");function r8(t,e){return function(r){return function(n){return t[r](e,n)}}}s(r8,"toCommonHandlerRegistry");c(r8,"toCommonHandlerRegistry");function iU(t){return Gr(t.addListener)&&Gr(t.removeListener)}s(iU,"isNodeStyleEventEmitter");c(iU,"isNodeStyleEventEmitter");function sU(t){return Gr(t.on)&&Gr(t.off)}s(sU,"isJQueryStyleEventEmitter");c(sU,"isJQueryStyleEventEmitter");function oU(t){return Gr(t.addEventListener)&&Gr(t.removeEventListener)}s(oU,"isEventTarget");c(oU,"isEventTarget");function Bw(t,e,r){t===void 0&&(t=0),r===void 0&&(r=Cre);var n=-1;return e!=null&&(bw(e)?r=e:n=e),new fi(function(i){var o=QL(t)?+t-r.now():t;o<0&&(o=0);var a=0;return r.schedule(function(){i.closed||(i.next(a++),0<=n?this.schedule(void 0,n):i.complete())},o)})}s(Bw,"timer");c(Bw,"timer");function aU(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=OL(t),n=FL(t,1/0),i=t;return i.length?i.length===1?Kc(i[0]):nU(n)(ZL(i,r)):PL}s(aU,"merge");c(aU,"merge");function cU(t,e){return Ja(function(r,n){var i=0;r.subscribe(Vo(n,function(o){return t.call(e,o,i++)&&n.next(o)}))})}s(cU,"filter");c(cU,"filter");function fU(t){return Ja(function(e,r){var n=!1;e.subscribe(Vo(r,function(i){n=!0,r.next(i)},function(){n||r.next(t),r.complete()}))})}s(fU,"defaultIfEmpty");c(fU,"defaultIfEmpty");function lU(t){return t<=0?function(){return PL}:Ja(function(e,r){var n=0;e.subscribe(Vo(r,function(i){++n<=t&&(r.next(i),t<=n&&r.complete())}))})}s(lU,"take");c(lU,"take");function uU(t){return t===void 0&&(t=dU),Ja(function(e,r){var n=!1;e.subscribe(Vo(r,function(i){n=!0,r.next(i)},function(){return n?r.complete():r.error(t())}))})}s(uU,"throwIfEmpty");c(uU,"throwIfEmpty");function dU(){return new XL}s(dU,"defaultErrorFactory");c(dU,"defaultErrorFactory");function hU(t,e){var r=arguments.length>=2;return function(n){return n.pipe(t?cU(function(i,o){return t(i,o,n)}):Gv,lU(1),r?fU(e):uU(function(){return new XL}))}}s(hU,"first");c(hU,"first");var Mre={leading:!0,trailing:!1};function pU(t,e){return e===void 0&&(e=Mre),Ja(function(r,n){var i=e.leading,o=e.trailing,a=!1,f=null,l=null,u=!1,h=c(function(){l?.unsubscribe(),l=null,o&&(_(),u&&n.complete())},"endThrottling"),g=c(function(){l=null,u&&n.complete()},"cleanupThrottling"),x=c(function(E){return l=Kc(t(E)).subscribe(Vo(n,h,g))},"startThrottle"),_=c(function(){if(a){a=!1;var E=f;f=null,n.next(E),!u&&x(E)}},"send");r.subscribe(Vo(n,function(E){a=!0,f=E,!(l&&!l.closed)&&(i?_():x(E))},function(){u=!0,!(o&&a&&l&&!l.closed)&&n.complete()}))})}s(pU,"throttle");c(pU,"throttle");var JM;(function(t){t[t.GENESIS=0]="GENESIS",t[t.PARTIAL=1]="PARTIAL",t[t.SIGNED=2]="SIGNED"})(JM||(JM={}));var U2;(function(t){t[t.NOT_REQUESTED=0]="NOT_REQUESTED",t[t.PENDING=1]="PENDING",t[t.PROCESSING=2]="PROCESSING",t[t.ANCHORED=3]="ANCHORED",t[t.FAILED=4]="FAILED"})(U2||(U2={}));var n8;(function(t){t[t.GENESIS=0]="GENESIS",t[t.SIGNED=1]="SIGNED",t[t.ANCHOR=2]="ANCHOR"})(n8||(n8={}));var Vv=s(class extends fi{constructor(t,e){super(r=>{t.subscribe(r)}),this.state$=t,this._context=e}get id(){return new xr(this.state$.value.type,this.state$.value.log[0].cid)}get api(){return this._context.api}get content(){let{next:t,content:e}=this.state$.value;return(0,qM.default)(t?.content??e)}get tip(){return this.state$.value.log[this.state$.value.log.length-1].cid}get commitId(){return $r.make(this.id,this.tip)}get allCommitIds(){return this.state$.value.log.map(({cid:t})=>$r.make(this.id,t))}get anchorCommitIds(){return this.state$.value.log.filter(({type:t})=>t===n8.ANCHOR).map(({cid:t})=>$r.make(this.id,t))}get state(){return(0,qM.default)(this.state$.value)}async sync(t={}){t={sync:bs.PREFER_CACHE,...t};let e=await this.api.loadStream(this.id,t);this.state$.next(e.state)}async requestAnchor(){return this.api.requestAnchor(this.id)}},"Stream");c(Vv,"Stream");function Wv(){return t=>{}}s(Wv,"StreamStatic");c(Wv,"StreamStatic");function gU(t){let e=new AbortController;if(t.length===0)throw Error("Need abort signals to create a merged abort signal");return t.some(r=>r.aborted)?(e.abort(),e.signal):(aU(...t.map(r=>L2(r,"abort"))).pipe(hU()).subscribe(()=>{e.abort()}),e.signal)}s(gU,"mergeAbortSignals");c(gU,"mergeAbortSignals");var bU=s(class{constructor(t){let e=new AbortController;if(this.signal=e.signal,t<=0){e.abort();return}this._subscription=Bw(t).subscribe(()=>{e.abort()})}clear(){this._subscription?.unsubscribe()}},"TimedAbortSignal");c(bU,"TimedAbortSignal");async function vU(t,e){let r=new AbortController,n=c(()=>{r.abort()},"onAbort");return t.addEventListener("abort",n),t.aborted&&r.abort(),e(r.signal).finally(()=>{t.removeEventListener("abort",n)})}s(vU,"abortable2");c(vU,"abortable");var Rre=60*1e3*3;async function Ns(t,e={}){e.body&&Object.assign(e,{body:JSON.stringify(e.body),headers:{...e.headers,"Content-Type":"application/json"}});let r=e.timeout||Rre,n=new bU(r),i=e.signal?gU([e.signal,n.signal]):n.signal,o=await vU(i,a=>(0,mU.default)(String(t),{...e,signal:a})).finally(()=>n.clear());if(!o.ok){let a=await o.text();throw new Error(`HTTP request to '${t}' failed with status '${o.statusText}': ${a}`)}return o.json()}s(Ns,"fetchJson");c(Ns,"fetchJson");var Sb=wr(S1(),1);Ga();function Dc(t){let e=fr.asCID(t);if(e)return e;if(typeof t=="string")return fr.parse(t);if(t instanceof Uint8Array)return fr.decode(t);throw new Error(`${t} cannot be converted to a CID`)}s(Dc,"toCID");c(Dc,"toCID");var YM=0,Cn=s(class{static streamIdFromState(t){return new xr(t.type,t.log[0].cid)}static serializeCommit(t){let e=(0,Sb.default)(t);return Cn.isSignedCommitContainer(e)?(e.jws.link=e.jws.link.toString(),e.linkedBlock=en(e.linkedBlock,"base64"),e.cacaoBlock&&(e.cacaoBlock=en(e.cacaoBlock,"base64")),e):(Cn.isSignedCommit(t)&&(e.link=e.link.toString()),Cn.isAnchorCommit(t)&&(e.proof=e.proof.toString()),e.id&&(e.id=e.id.toString()),e.prev&&(e.prev=e.prev.toString()),t.header?.model&&(e.header.model=en(t.header.model,"base64")),e)}static deserializeCommit(t){let e=(0,Sb.default)(t);return Cn.isSignedCommitContainer(e)?(e.jws.link=Dc(e.jws.link),e.linkedBlock=Zr(e.linkedBlock,"base64"),e.cacaoBlock&&(e.cacaoBlock=Zr(e.cacaoBlock,"base64")),e):(Cn.isSignedCommit(e)&&(e.link=Dc(e.link)),Cn.isAnchorCommit(e)&&(e.proof=Dc(e.proof)),e.id&&(e.id=Dc(e.id)),e.prev&&(e.prev=Dc(e.prev)),e.header?.model&&(e.header.model=Zr(e.header.model,"base64")),e)}static serializeState(t){let e=(0,Sb.default)(t);return e.log=e.log.map(r=>({...r,cid:r.cid.toString()})),e.anchorStatus!=null&&(e.anchorStatus=U2[e.anchorStatus]),e.anchorProof!=null&&(e.anchorProof.txHash=e.anchorProof.txHash.toString(),e.anchorProof.root=e.anchorProof.root.toString()),t.metadata?.model&&(e.metadata.model=t.metadata.model.toString()),t.next?.metadata?.model&&(e.next.metadata.model=t.next.metadata.model.toString()),t.metadata?.unique&&t.type!=YM&&(e.metadata.unique=en(e.metadata.unique,"base64")),e.doctype=jc.nameByCode(e.type),e}static deserializeState(t){if(!t)return null;let e=(0,Sb.default)(t);return e.doctype&&(e.type=jc.codeByName(e.doctype),delete e.doctype),e.log=e.log.map(r=>({...r,cid:Dc(r.cid)})),e.anchorProof&&(e.anchorProof.txHash=Dc(e.anchorProof.txHash),e.anchorProof.root=Dc(e.anchorProof.root)),e.anchorStatus&&(e.anchorStatus=U2[e.anchorStatus]),t.metadata?.model&&(e.metadata.model=xr.fromString(t.metadata.model)),t.next?.metadata?.model&&(e.next.metadata.model=xr.fromString(t.next.metadata.model)),t.metadata?.unique&&t.type!=YM&&(e.metadata.unique=Zr(t.metadata.unique,"base64")),e}static statesEqual(t,e){return JSON.stringify(Cn.serializeState(t))===JSON.stringify(Cn.serializeState(e))}static isStateSupersetOf(t,e){if(t.log.length<e.log.length)return!1;for(let r in e.log)if(!t.log[r].cid.equals(e.log[r].cid))return!1;return!(t.log.length===e.log.length&&t.anchorStatus!=e.anchorStatus)}static assertCommitLinksToState(t,e){let r=this.streamIdFromState(t);if(e.id&&!e.id.equals(t.log[0].cid))throw new Error(`Invalid genesis CID in commit for StreamID ${r.toString()}. Found: ${e.id}, expected ${t.log[0].cid}`);let n=t.log[t.log.length-1].cid;if(!e.prev.equals(n))throw new Error(`Commit doesn't properly point to previous commit in log. Expected ${n}, found 'prev' ${e.prev}`)}static async convertCommitToSignedCommitContainer(t,e){if(Cn.isSignedCommit(t)){let r=await e.block.get(t.link);return{jws:t,linkedBlock:r}}return t}static isSignedCommitContainer(t){return t&&t.jws!==void 0}static isSignedCommit(t){return t&&t.link!==void 0}static isAnchorCommit(t){return t&&t.proof!==void 0}static isSignedCommitData(t){return t&&t.envelope!==void 0}static isAnchorCommitData(t){return t&&t.proof!==void 0}},"StreamUtils");c(Cn,"StreamUtils");var yU=s(class extends xre{next(t){let e=this.value;Cn.statesEqual(e,t)||super.next(t)}},"StreamStateSubject");c(yU,"StreamStateSubject");var Bre=s(function(t,e,r,n){var i=arguments.length,o=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,n);else for(var f=t.length-1;f>=0;f--)(a=t[f])&&(o=(i<3?a(o):i>3?a(e,r,o):a(e,r))||o);return i>3&&o&&Object.defineProperty(e,r,o),o},"__decorate4"),Os,e5={anchor:!0,publish:!0,pin:!0,sync:bs.PREFER_CACHE},Dre={sync:bs.PREFER_CACHE},ZM={anchor:!0,publish:!0,throwOnInvalidCommit:!0};function Zb(t,e){if(typeof t?.schema=="string")try{$r.fromString(t.schema)}catch{throw new Error("Schema must be a CommitID")}let r={controllers:t?.controllers,family:t?.family,schema:t?.schema?.toString(),tags:t?.tags};if(e)t?.deterministic||(r.unique=en((0,cre.randomBytes)(12),"base64")),t?.forbidControllerChange&&(r.forbidControllerChange=!0);else{if(t?.deterministic!==void 0||t?.unique!==void 0)throw new Error("Cannot change 'deterministic' or 'unique' properties on existing Streams");if(t?.forbidControllerChange!==void 0)throw new Error("Cannot change 'forbidControllerChange' property on existing Streams")}return Object.keys(r).forEach(n=>r[n]===void 0&&delete r[n]),r}s(Zb,"headerFromMetadata");c(Zb,"headerFromMetadata");async function i8(t){if(!t.did)throw new Error("No DID provided");return t.did.authenticated||(await t.did.authenticate(),t.loggerProvider&&t.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${t.did.id}`)),t.did}s(i8,"getAuthenticatedDID");c(i8,"getAuthenticatedDID");async function Xb(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}s(Xb,"throwReadOnlyError");c(Xb,"throwReadOnlyError");var Ua=Os=c(s(class extends Vv{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){let{next:e,metadata:r}=this.state$.value;return(0,are.default)(e?.metadata??r)}get controllers(){return this.metadata.controllers}static async create(e,r,n,i={}){i={...e5,...i},!n?.deterministic&&i.syncTimeoutSeconds==null&&(i.syncTimeoutSeconds=0);let o=i.asDID?{did:i.asDID}:e,a=await Os.makeGenesis(o,r,n);return e.createStreamFromGenesis(Os.STREAM_TYPE_ID,a,i)}static async createFromGenesis(e,r,n={}){n={...e5,...n},r.header?.unique&&n.syncTimeoutSeconds==null&&(n.syncTimeoutSeconds=0);let i=r.data?await Os._signDagJWS(e,r):r;return e.createStreamFromGenesis(Os.STREAM_TYPE_ID,i,n)}static async deterministic(e,r,n={}){if(n={...e5,...n},r={...r,deterministic:!0},r.family==null&&r.tags==null)throw new Error("Family and/or tags are required when creating a deterministic tile document");let i=await Os.makeGenesis(e,null,r);return e.createStreamFromGenesis(Os.STREAM_TYPE_ID,i,n)}static async load(e,r,n={}){n={...Dre,...n};let i=Yf.from(r);if(i.type!=Os.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${Os.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}async update(e,r,n={}){n={...ZM,...n};let i=n.asDID?{did:n.asDID}:this.api,o=await this.makeCommit(i,e,r),a=await this.api.applyCommit(this.id,o,n);this.state$.next(a.state)}async patch(e,r={}){r={...ZM,...r};let i={header:Zb(this.metadata,!1),data:e,prev:this.tip,id:this.id.cid},o=await Os._signDagJWS(this.api,i),a=await this.api.applyCommit(this.id,o,r);this.state$.next(a.state)}makeReadOnly(){this.update=Xb,this.patch=Xb,this.sync=Xb,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}async makeCommit(e,r,n){let i=await this._makeRawCommit(r,n);return Os._signDagJWS(e,i)}async _makeRawCommit(e,r){r||(r={});let n=Zb(r,!1);if(e==null&&(e=this.content),n.controllers){if(n.controllers.length!==1)throw new Error("Exactly one controller must be specified");if(!n.controllers[0])throw new Error("Controller cannot be updated to an undefined value.")}let i=aL.compare(this.content,e),o=this.state.log[0];return{header:n,data:i,prev:this.tip,id:o.cid}}static async makeGenesis(e,r,n){if(n||(n={}),!n.controllers||n.controllers.length===0)if(e.did){let a=await i8(e);n.controllers=[a.hasParent?a.parent:a.id]}else throw new Error("No controllers specified");if(n.controllers?.length!==1)throw new Error("Exactly one controller must be specified");let i=Zb(n,!0);if(n?.deterministic&&r)throw new Error("Initial content must be null when creating a deterministic Tile document");if(r==null){let a={header:i};return Pv(a),a}let o={data:r,header:i};return Os._signDagJWS(e,o)}static async _signDagJWS(e,r){return(await i8(e)).createDagJWS(r)}},"TileDocument2"),"TileDocument");Ua.STREAM_TYPE_NAME="tile";Ua.STREAM_TYPE_ID=0;Ua=Os=Bre([Wv()],Ua);var Pre=wr(QY(),1);function xU(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}s(xU,"_checkPrivateRedeclaration2");c(xU,"_checkPrivateRedeclaration");function wU(t,e){return e.get?e.get.call(t):e.value}s(wU,"_classApplyDescriptorGet2");c(wU,"_classApplyDescriptorGet");function _U(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}s(_U,"_classApplyDescriptorSet2");c(_U,"_classApplyDescriptorSet");function Dw(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}s(Dw,"_classExtractFieldDescriptor2");c(Dw,"_classExtractFieldDescriptor");function Qb(t,e){var r=Dw(t,e,"get");return wU(t,r)}s(Qb,"_classPrivateFieldGet2");c(Qb,"_classPrivateFieldGet");function s8(t,e,r){xU(t,e),e.set(t,r)}s(s8,"_classPrivateFieldInit2");c(s8,"_classPrivateFieldInit");function o8(t,e,r){var n=Dw(t,e,"set");return _U(t,n,r),r}s(o8,"_classPrivateFieldSet2");c(o8,"_classPrivateFieldSet");function AU(t){return typeof t=="string"||$r.isInstance(t)||xr.isInstance(t)?{streamId:t}:{streamId:t.streamId,genesis:t.genesis}}s(AU,"keyToQuery");c(AU,"keyToQuery");function e2(t){return typeof t=="string"?Yf.from(t).toString():$r.isInstance(t)||xr.isInstance(t)?t.toString():t.streamId.toString()}s(e2,"keyToString");c(e2,"keyToString");async function Pw(t){let e=await Ua.makeGenesis({},null,{...t,deterministic:!0}),r=await xr.fromGenesis("tile",e);return{genesis:e,streamId:r}}s(Pw,"getDeterministicQuery");c(Pw,"getDeterministicQuery");var Ore=c(()=>Promise.resolve([]),"tempBatchLoadFn"),Ib=new WeakMap,t5=new WeakMap,Jv=s(class extends Pre.default{cache(t){if(!Qb(this,t5))return!1;let e=t.id.toString();return this.clear(e).prime(e,t),!0}async create(t,e,r){let n=await Ua.create(Qb(this,Ib),t,e,r);return this.cache(n),n}async deterministic(t,e){let r=await Pw(t);try{return await super.load(r)}catch{let i=await Ua.createFromGenesis(Qb(this,Ib),r.genesis,e);return this.cache(i),i}}async load(t){return await super.load(t)}async update(t,e,r,n){let i=e2(t);this.clear(i);let o=await this.load({streamId:i});return await o.update(e,r,n),o}constructor(t){super(Ore,{cache:!0,cacheKeyFn:e2,cacheMap:t.cache!=null&&typeof t.cache!="boolean"?t.cache:void 0}),s8(this,Ib,{writable:!0,value:void 0}),s8(this,t5,{writable:!0,value:void 0}),this._batchLoadFn=async e=>{t.cache||this.clearAll();let r=await t.ceramic.multiQuery(e.map(AU),t.multiqueryTimeout);return e.map(n=>{let i=e2(n),o=r[i];return o||new Error(`Failed to load stream: ${i}`)})},o8(this,Ib,t.ceramic),o8(this,t5,!!t.cache)}},"TileLoader");c(Jv,"TileLoader");function a8(t){return typeof t=="string"?xr.fromString(t):t}s(a8,"typeStreamID");c(a8,"typeStreamID");function EU(t,e){let r=new URL(t);for(let[n,i]of Object.entries(e))xr.isInstance(i)?r.searchParams.set(n,i.toString()):typeof i=="object"?r.searchParams.set(n,JSON.stringify(i)):r.searchParams.set(n,i);return r}s(EU,"serializeObjectToSearchParams");c(EU,"serializeObjectToSearchParams");function c8(t){let e={};for(let[r,n]of Object.entries(t))xr.isInstance(n)?e[r]=n.toString():e[r]=n;return e}s(c8,"serializeObjectForHttpPost");c(c8,"serializeObjectForHttpPost");var ho=s(class extends fi{constructor(t,e,r){super(n=>{this.state$.observers.length===0&&(this.periodicSubscription=Bw(0,r).pipe(pU(()=>this._syncState(this.id,{sync:bs.PREFER_CACHE}))).subscribe()),this.state$.subscribe(n).add(()=>{this.state$.observers.length===0&&this.periodicSubscription?.unsubscribe()})}),this.state$=new yU(t),this._apiUrl=new URL(e)}get value(){return this.state$.value}get state(){return this.state$.value}next(t){this.state$.next(t)}async _syncState(t,e){let r=await ho._load(t,this._apiUrl,e);this.state$.next(Cn.deserializeState(r))}get id(){return new xr(this.state$.value.type,this.state$.value.log[0].cid)}static async createFromGenesis(t,e,r,n,i){let o=new URL("./streams",t),{state:a}=await Ns(o,{method:"post",body:{type:e,genesis:Cn.serializeCommit(r),opts:n}});return new ho(Cn.deserializeState(a),t,i)}static async applyCommit(t,e,r,n,i){let o=new URL("./commits",t),{state:a}=await Ns(o,{method:"post",body:{streamId:e.toString(),commit:Cn.serializeCommit(r),opts:n}});return new ho(Cn.deserializeState(a),t,i)}static async _load(t,e,r){let n=EU(new URL(`./streams/${t}`,e),r),{state:i}=await Ns(n);return i}static async load(t,e,r,n){let i=await ho._load(t,e,n);return new ho(Cn.deserializeState(i),e,r)}static async loadStreamCommits(t,e){let r=new URL(`./commits/${t}`,e),{commits:n}=await Ns(r);return n.map(i=>({cid:i.cid,value:Cn.deserializeCommit(i.value)}))}complete(){this.state$.complete()}},"Document");c(ho,"Document");var h1;(function(t){t[t.PREFER_CACHE=0]="PREFER_CACHE",t[t.SYNC_ALWAYS=1]="SYNC_ALWAYS",t[t.NEVER_SYNC=2]="NEVER_SYNC",t[t.SYNC_ON_ERROR=3]="SYNC_ON_ERROR"})(h1||(h1={}));var XM=wr(S1(),1),QM;(function(t){t[t.GENESIS=0]="GENESIS",t[t.PARTIAL=1]="PARTIAL",t[t.SIGNED=2]="SIGNED"})(QM||(QM={}));var eR;(function(t){t[t.NOT_REQUESTED=0]="NOT_REQUESTED",t[t.PENDING=1]="PENDING",t[t.PROCESSING=2]="PROCESSING",t[t.ANCHORED=3]="ANCHORED",t[t.FAILED=4]="FAILED"})(eR||(eR={}));var f8;(function(t){t[t.GENESIS=0]="GENESIS",t[t.SIGNED=1]="SIGNED",t[t.ANCHOR=2]="ANCHOR"})(f8||(f8={}));var CU=s(class extends fi{constructor(t,e){super(r=>{t.subscribe(r)}),this.state$=t,this._context=e}get id(){return new xr(this.state$.value.type,this.state$.value.log[0].cid)}get api(){return this._context.api}get content(){let{next:t,content:e}=this.state$.value;return(0,XM.default)(t?.content??e)}get tip(){return this.state$.value.log[this.state$.value.log.length-1].cid}get commitId(){return $r.make(this.id,this.tip)}get allCommitIds(){return this.state$.value.log.map(({cid:t})=>$r.make(this.id,t))}get anchorCommitIds(){return this.state$.value.log.filter(({type:t})=>t===f8.ANCHOR).map(({cid:t})=>$r.make(this.id,t))}get state(){return(0,XM.default)(this.state$.value)}async sync(t={}){t={sync:h1.PREFER_CACHE,...t};let e=await this.api.loadStream(this.id,t);this.state$.next(e.state)}async requestAnchor(){return this.api.requestAnchor(this.id)}},"Stream2");c(CU,"Stream");function SU(){return t=>{}}s(SU,"StreamStatic2");c(SU,"StreamStatic");function IU(t){if(typeof t=="string"&&t.includes("@")){let[e,r]=t.split("@");if(!e||!r)throw new Error("Invalid accountId provided");return new f1({address:e,chainId:r})}return new f1(t)}s(IU,"normalizeAccountId");c(IU,"normalizeAccountId");var Fre=wr(S1(),1),Nre=s(function(t,e,r,n){var i=arguments.length,o=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,n);else for(var f=t.length-1;f>=0;f--)(a=t[f])&&(o=(i<3?a(o):i>3?a(e,r,o):a(e,r))||o);return i>3&&o&&Object.defineProperty(e,r,o),o},"__decorate5"),Gl,r5=c(()=>{throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")},"throwReadOnlyError"),tR={anchor:!1,publish:!0,pin:!0,sync:h1.PREFER_CACHE},n5={anchor:!0,publish:!0},Lre={sync:h1.PREFER_CACHE},ch=Gl=c(s(class extends CU{constructor(){super(...arguments),this._isReadOnly=!1}get did(){return this.content}get metadata(){let{next:e,metadata:r}=this.state$.value;return(0,Fre.default)(e?.metadata??r)}get controllers(){return this.metadata.controllers}static async fromAccount(e,r,n={}){n={...tR,...n};let i=IU(r),o=Gl.makeGenesis(i);return Gl.fromGenesis(e,o,n)}static async fromGenesis(e,r,n={}){return n={...tR,...n},e.createStreamFromGenesis(Gl.STREAM_TYPE_ID,r,n)}async setDid(e,r,n={}){n={...n5,...n};let i=typeof e=="string"?e.trim():e.id;if(bx(i)?.did!==i)throw new Error(`DID is not valid: '${i}'`);let a=await r.createLink(i);return this.setDidProof(a,n)}async setDidProof(e,r={}){r={...n5,...r};let n=this.makeCommit(e),i=await this.api.applyCommit(this.id,n,r);this.state$.next(i.state)}async clearDid(e,r={}){r={...n5,...r};let n=await e.createLink("");return this.setDidProof(n,r)}static async load(e,r,n={}){n={...Lre,...n};let i=Yf.from(r);if(i.type!=Gl.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${Gl.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}static makeGenesis(e){return e.chainId.namespace==="eip155"&&(e.address=e.address.toLowerCase()),{header:{controllers:[`${e.address}@${e.chainId.toString()}`],family:`caip10-${e.chainId.toString()}`}}}makeCommit(e){return{data:e,prev:this.tip,id:this.id.cid}}makeReadOnly(){this.setDidProof=r5,this.setDid=r5,this.sync=r5,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}},"Caip10Link2"),"Caip10Link");ch.STREAM_TYPE_NAME="caip10-link";ch.STREAM_TYPE_ID=1;ch=Gl=Nre([SU()],ch);Ga();uh();var Ure=wr(lZ(),1),jre=s(function(t,e,r,n){var i=arguments.length,o=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,n);else for(var f=t.length-1;f>=0;f--)(a=t[f])&&(o=(i<3?a(o):i>3?a(e,r,o):a(e,r))||o);return i>3&&o&&Object.defineProperty(e,r,o),o},"__decorate6"),Pa,qre={sync:bs.PREFER_CACHE};async function l8(t){if(t.did==null)throw new Error("No DID provided");t.did.authenticated||(await t.did.authenticate(),t.loggerProvider&&t.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${t.did.id}`))}s(l8,"_ensureAuthenticated");c(l8,"_ensureAuthenticated");async function kU(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}s(kU,"throwReadOnlyError3");c(kU,"throwReadOnlyError");var ou=Pa=c(s(class extends Vv{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){return{controller:this.state$.value.metadata.controllers[0],model:Pa.MODEL}}static async create(e,r,n){Pa.assertComplete(r);let i={publish:!0,anchor:!0,pin:!0,sync:bs.NEVER_SYNC,throwOnInvalidCommit:!0},o=await Pa._makeGenesis(e,r,n);return await e.createStreamFromGenesis(Pa.STREAM_TYPE_ID,o,i)}static assertComplete(e,r){if(!e.name)throw r?new Error(`Model with StreamID ${r.toString()} is missing a 'name' field`):new Error("Model is missing a 'name' field");if(!e.schema)throw r?new Error(`Model ${e.name} (${r.toString()}) is missing a 'schema' field`):new Error(`Model ${e.name} is missing a 'schema' field`);if(!e.accountRelation)throw r?new Error(`Model ${e.name} (${r.toString()}) is missing a 'accountRelation' field`):new Error(`Model ${e.name} is missing a 'accountRelation' field`)}static async load(e,r,n={}){n={...qre,...n};let i=Yf.from(r);if(i.type!=Pa.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${Pa.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return await e.loadStream(i,n)}static async _makeGenesis(e,r,n){let i=await this._makeRawGenesis(e,r,n);return Pa._signDagJWS(e,i)}static async _makeRawGenesis(e,r,n){if(r==null)throw new Error("Genesis content cannot be null");if(!n||!n.controller)if(e.did)await l8(e),n={controller:e.did.hasParent?e.did.parent:e.did.id};else throw new Error("No controller specified");let i={controllers:[n.controller],model:Pa.MODEL.bytes};return{data:r,header:i}}makeReadOnly(){this.sync=kU,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}static async _signDagJWS(e,r){return await l8(e),e.did.createDagJWS(r)}},"Model2"),"Model");ou.STREAM_TYPE_NAME="model";ou.STREAM_TYPE_ID=2;ou.MODEL=function(){let t=Pv("model-v1"),e=Ure.default.encode(t,"identity"),r=Jd(w2,e),n=fr.createV1(w2,r);return new xr("UNLOADABLE",n)}();ou=Pa=jre([Wv()],ou);var Hre=wr(ph(),1),zre=s(function(t,e,r,n){var i=arguments.length,o=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,n);else for(var f=t.length-1;f>=0;f--)(a=t[f])&&(o=(i<3?a(o):i>3?a(e,r,o):a(e,r))||o);return i>3&&o&&Object.defineProperty(e,r,o),o},"__decorate7"),Fo,$re={anchor:!0,publish:!0,pin:!0,sync:bs.NEVER_SYNC,syncTimeoutSeconds:0},Gre={anchor:!1,publish:!1,pin:!0,sync:bs.PREFER_CACHE},Kre={sync:bs.PREFER_CACHE},rR={anchor:!0,publish:!0,throwOnInvalidCommit:!0};async function u8(t){if(t.did==null)throw new Error("No DID provided");t.did.authenticated||(await t.did.authenticate(),t.loggerProvider&&t.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${t.did.id}`))}s(u8,"_ensureAuthenticated2");c(u8,"_ensureAuthenticated");async function t2(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}s(t2,"throwReadOnlyError4");c(t2,"throwReadOnlyError");var fh=Fo=c(s(class extends Vv{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){let e=this.state$.value.metadata;return{controller:e.controllers[0],model:e.model}}static async create(e,r,n,i={}){i={...$re,...i};let o=i.asDID?{did:i.asDID}:e,a=await Fo._makeGenesis(o,r,n);return e.createStreamFromGenesis(Fo.STREAM_TYPE_ID,a,i)}static async single(e,r,n={}){n={...Gre,...n};let i=n.asDID?{did:n.asDID}:e;r={...r,deterministic:!0};let o=await Fo._makeGenesis(i,null,r);return e.createStreamFromGenesis(Fo.STREAM_TYPE_ID,o,n)}static async load(e,r,n={}){n={...Kre,...n};let i=Yf.from(r);if(i.type!=Fo.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${Fo.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}async replace(e,r={}){r={...rR,...r};let n=r.asDID?{did:r.asDID}:this.api,i=await this._makeCommit(n,e),o=await this.api.applyCommit(this.id,i,r);this.state$.next(o.state)}async patch(e,r={}){r={...rR,...r};let n={data:e,prev:this.tip,id:this.id.cid},i=await Fo._signDagJWS(this.api,n),o=await this.api.applyCommit(this.id,i,r);this.state$.next(o.state)}makeReadOnly(){this.replace=t2,this.patch=t2,this.sync=t2,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}_makeCommit(e,r){let n=this._makeRawCommit(r);return Fo._signDagJWS(e,n)}_makeRawCommit(e){return{data:aL.compare(this.content,e||{}),prev:this.tip,id:this.state.log[0].cid}}static async _makeGenesis(e,r,n){let i=await this._makeRawGenesis(e,r,n);return n.deterministic?(Pv(i),i):Fo._signDagJWS(e,i)}static async _makeRawGenesis(e,r,n){if(!n.model)throw new Error("Must specify a 'model' when creating a ModelInstanceDocument");let i=n.controller;if(!i)if(e.did)await u8(e),i=e.did.hasParent?e.did.parent:e.did.id;else throw new Error("No controller specified");let o={controllers:[i],model:n.model.bytes};return n.deterministic||(o.unique=(0,Hre.randomBytes)(12)),{data:r,header:o}}static async _signDagJWS(e,r){return await u8(e),e.did.createDagJWS(r)}},"ModelInstanceDocument2"),"ModelInstanceDocument");fh.STREAM_TYPE_NAME="MID";fh.STREAM_TYPE_ID=3;fh=Fo=zre([Wv()],fh);var TU=s(class{constructor(t){this._apiUrl=t}async add(t,e){let r={};e&&(r.force=!0);let n=new URL(`./pins/${t}`,this._apiUrl);await Ns(n,{method:"post",body:r})}async rm(t,e){let r=new URL(`./pins/${t}`,this._apiUrl);await Ns(r,{method:"delete",body:{opts:e}})}async ls(t){let e=new URL("./pins",this._apiUrl);t&&(e=new URL(`./pins/${t.toString()}`,this._apiUrl));let r=await Ns(e),{pinnedStreamIds:n}=r;return{[Symbol.asyncIterator](){let i=0;return{next(){return i===n.length?Promise.resolve({value:null,done:!0}):Promise.resolve({value:n[i++],done:!1})}}}}}},"RemotePinApi");c(TU,"RemotePinApi");var MU=s(class{constructor(t){this._fetchJson=Ns,this._collectionURL=new URL("./collection",t),this._countURL=new URL("./collection/count",t)}async count(t){return(await this._fetchJson(this._countURL,{method:"POST",body:c8(t)})).count}async query(t){let e=await this._fetchJson(this._collectionURL,{method:"POST",body:c8(t)});return{edges:e.edges.map(n=>({cursor:n.cursor,node:Cn.deserializeState(n.node)})),pageInfo:e.pageInfo}}},"RemoteIndexApi");c(MU,"RemoteIndexApi");var RU=s(class{constructor(t,e){this._apiUrl=t,this._getDidFn=e,this._fetchJson=Ns,this.modelsPath="./admin/models",this.getCodePath="./admin/getCode"}getCodeUrl(){return new URL(this.getCodePath,this._apiUrl)}getModelsUrl(){return new URL(this.modelsPath,this._apiUrl)}async buildJWS(t,e,r){let n=r?{models:r.map(o=>o.toString())}:void 0,i=await t.createJWS({code:e,requestPath:this.getModelsUrl().pathname,requestBody:n});return`${i.signatures[0].protected}.${i.payload}.${i.signatures[0].signature}`}async generateCode(){return(await this._fetchJson(this.getCodeUrl())).code}async startIndexingModels(t){let e=await this.generateCode();await this._fetchJson(this.getModelsUrl(),{method:"post",body:{jws:await this.buildJWS(this._getDidFn(),e,t)}})}async getIndexedModels(){let t=await this.generateCode();return(await this._fetchJson(this.getModelsUrl(),{headers:{Authorization:`Basic ${await this.buildJWS(this._getDidFn(),t)}`}})).models.map(r=>xr.fromString(r))}async stopIndexingModels(t){let e=await this.generateCode();await this._fetchJson(this.getModelsUrl(),{method:"delete",body:{jws:await this.buildJWS(this._getDidFn(),e,t)}})}},"RemoteAdminApi");c(RU,"RemoteAdminApi");var Vre="/api/v0/",Wre="http://localhost:7007",Jre={syncInterval:5e3},Yre={anchor:!0,publish:!0,sync:bs.PREFER_CACHE},Zre={anchor:!0,publish:!0,sync:bs.PREFER_CACHE},nR={sync:bs.PREFER_CACHE},BU=s(class{constructor(t=Wre,e={}){this._config={...Jre,...e},this._apiUrl=new URL(Vre,t),this._streamCache=new Map,this.context={api:this},this.pin=new TU(this._apiUrl),this.index=new MU(this._apiUrl);let r=(()=>this.did).bind(this);this.admin=new RU(this._apiUrl,r),this._streamConstructors={[ch.STREAM_TYPE_ID]:ch,[ou.STREAM_TYPE_ID]:ou,[fh.STREAM_TYPE_ID]:fh,[Ua.STREAM_TYPE_ID]:Ua}}get did(){return this.context.did}set did(t){this.context.did=t}async createStreamFromGenesis(t,e,r={}){r={...Zre,...r};let n=await ho.createFromGenesis(this._apiUrl,t,e,r,this._config.syncInterval),i=this._streamCache.get(n.id.toString());return i?(Cn.statesEqual(n.state,i.state)||i.next(n.state),this.buildStreamFromDocument(i)):(this._streamCache.set(n.id.toString(),n),this.buildStreamFromDocument(n))}async loadStream(t,e={}){e={...nR,...e};let r=Yf.from(t),n=this._streamCache.get(r.baseID.toString());return n?await n._syncState(r,e):(n=await ho.load(r,this._apiUrl,this._config.syncInterval,e),this._streamCache.set(n.id.toString(),n)),this.buildStreamFromDocument(n)}async multiQuery(t,e){let r=t.map(o=>({...o,streamId:typeof o.streamId=="string"?o.streamId:o.streamId.toString()})),n=new URL("./multiqueries",this._apiUrl),i=await Ns(n,{method:"post",body:{queries:r,timeout:e}});return Object.entries(i).reduce((o,a)=>{let[f,l]=a,u=Cn.deserializeState(l),h=new ho(u,this._apiUrl,this._config.syncInterval);return o[f]=this.buildStreamFromDocument(h),o},{})}loadStreamCommits(t){let e=a8(t);return ho.loadStreamCommits(e,this._apiUrl)}async applyCommit(t,e,r={}){r={...Yre,...r};let n=a8(t),i=await ho.applyCommit(this._apiUrl,n,e,r,this._config.syncInterval),o=this._streamCache.get(n.toString());return o?(o.next(i.state),this.buildStreamFromDocument(i)):(this._streamCache.set(n.toString(),i),this.buildStreamFromDocument(i))}async requestAnchor(t,e={}){e={...nR,...e};let{anchorStatus:r}=await Ns(`${this._apiUrl}/streams/${t.toString()}/anchor`,{method:"post",body:{opts:e}});return r}addStreamHandler(t){this._streamConstructors[t.name]=t.stream_constructor}buildStreamFromState(t){let e=new ho(t,this._apiUrl,this._config.syncInterval);return this.buildStreamFromDocument(e)}buildStreamFromDocument(t){let e=t.state.type,r=this._streamConstructors[e];if(!r)throw new Error(`Failed to find constructor for stream ${e}`);return new r(t,this.context)}async setDID(t){this.context.did=t}async getSupportedChains(){if(this._supportedChains)return this._supportedChains;let{supportedChains:t}=await Ns(this._apiUrl+"/node/chains");return this._supportedChains=t,t}async close(){Array.from(this._streamCache).map(([,t])=>{t.complete()}),this._streamCache.clear()}},"CeramicClient");c(BU,"CeramicClient");var $p=c(t=>`lc:ceramic:${t}`,"streamIdToCeramicURI"),iR=we.string().refine(t=>t.split(":").length===3&&t.split(":")[0]==="lc","URI must be of the form lc:${storage}:${url}").refine(t=>t.split(":")[1]==="ceramic","URI must use storage type ceramic (i.e. must be lc:ceramic:${streamID})"),Xre=c(async(t,{ceramicEndpoint:e,defaultContentFamily:r})=>{let n=new BU(e),i=c(async(E,T,B,F)=>t.invoke.didResolver(E,F),"learnCardResolver"),o={...Zte.getResolver(),web:i},a=new Xx({resolver:o});n.did=a;let f=t.invoke.getKey(),l=new YN(gx(f));n.did.setProvider(l),await n.did.authenticate();let u=new Jv({ceramic:n}),h=c(async(E,T={},B={},F)=>{if(!E)throw new Error("content is required");if(T.controllers||(T.controllers=[n.did.id]),T.family||(T.family=r),"pin"in B||(B.pin=!0),F?.encrypt){t.debug?.("learnCard.store.Ceramic.upload.publishContentToCeramic - encrypt enabled",F);let U=F?.recipients||[];F?.controllersCanDecrypt&&(U=[...U,...T.controllers]),E=await n?.did?.createDagJWE(E,Eee.default.uniq(U))}return t.debug?.("learnCard.store.Ceramic.upload.publishContentToCeramic - content to upload",E,T,B),(await Ua.create(n,E,T,B)).id.toString()},"publishContentToCeramic"),g=c(async E=>{let T=(await u.load(E))?.content;if(t.debug?.("learnCard.read.get.readContentFromCeramic",T),T?.ciphertext)try{return await a.decryptDagJWE(T)}catch(B){throw t.debug?.("learnCard.read.get.readContentFromCeramic - Could not decrypt credential - DID not authorized.",B),new Error("Could not decrypt credential - DID not authorized.")}return T},"readContentFromCeramic"),x=c(async(E,T)=>(await Fc.or(m2).parseAsync(E),$p(await h(E,{},{},T))),"uploadCredential"),_=c(async(E="")=>{if(!E)return;if(E.startsWith("ceramic://"))return Fc.parseAsync(await g(E));let T=await iR.spa(E);if(!T.success)return t.invoke.resolveCredential(E);let B=T.data.split(":")[2];return Fc.parseAsync(await g(B))},"resolveCredential");return{name:"Ceramic",displayName:"Ceramic",description:"Uploads/resolves credentials using the Ceramic Network (https://ceramic.network/)",store:{upload:async(E,T)=>(E.debug?.("learnCard.store.Ceramic.upload"),x(T)),uploadEncrypted:async(E,T,B)=>(E.debug?.("learnCard.store.Ceramic.uploadEncrypted"),x(T,{encrypt:!0,controllersCanDecrypt:!0,...B?{recipients:B.recipients}:{}}))},read:{get:async(E,T)=>{if(E.debug?.("learnCard.read.Ceramic.get"),!T)return;let B=await iR.spa(T);if(!B.success)return;let F=B.data.split(":")[2];try{return await Fc.or(m2).parseAsync(await g(F))}catch(H){E.debug?.(H);return}}},methods:{publishContentToCeramic:async(E,T,B)=>$p(await h(T,{},{},B)),readContentFromCeramic:async(E,T)=>g(T),resolveCredential:async(E,T)=>_(T),getCeramicClient:()=>n,getDIDObject:()=>n.did}}},"getCeramicPlugin"),Qre="ceramic://k3y52l7qbv1fry1fp4s0nwdarh0vahusarpposgevy0pemiykymd2ord6swtharcw",i5="ceramic://k3y52l7qbv1fryjn62sggjh1lpn11c56qfofzmty190d62hwk1cal1c7qc5he54ow";function DU(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}s(DU,"_checkPrivateRedeclaration3");c(DU,"_checkPrivateRedeclaration");function PU(t,e){return e.get?e.get.call(t):e.value}s(PU,"_classApplyDescriptorGet3");c(PU,"_classApplyDescriptorGet");function OU(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}s(OU,"_classApplyDescriptorSet3");c(OU,"_classApplyDescriptorSet");function Ow(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}s(Ow,"_classExtractFieldDescriptor3");c(Ow,"_classExtractFieldDescriptor");function Pf(t,e){var r=Ow(t,e,"get");return PU(t,r)}s(Pf,"_classPrivateFieldGet3");c(Pf,"_classPrivateFieldGet");function d8(t,e,r){DU(t,e),e.set(t,r)}s(d8,"_classPrivateFieldInit3");c(d8,"_classPrivateFieldInit");function r2(t,e,r){var n=Ow(t,e,"set");return OU(t,n,r),r}s(r2,"_classPrivateFieldSet3");c(r2,"_classPrivateFieldSet");var Dd=new WeakMap,Pd=new WeakMap,h8=s(class{get aliases(){return Pf(this,Dd)}get loader(){return Pf(this,Pd)}getDefinitionID(t){return Pf(this,Dd).definitions[t]??null}getSchemaURL(t){return Pf(this,Dd).schemas[t]??null}getTileID(t){return Pf(this,Dd).tiles[t]??null}async loadTile(t){let e=this.getTileID(t);if(e==null)throw new Error(`Tile alias "${t}" is not defined`);return await Pf(this,Pd).load(e)}async createTile(t,e,r={}){let n=this.getSchemaURL(t);if(n==null)throw new Error(`Schema alias "${t}" is not defined`);let{controller:i,...o}=r,a={schema:n};return i!=null&&(a.controllers=[i]),await Pf(this,Pd).create(e,a,o)}constructor(t){if(d8(this,Dd,{writable:!0,value:void 0}),d8(this,Pd,{writable:!0,value:void 0}),r2(this,Dd,t.aliases),t.loader!=null)r2(this,Pd,t.loader);else{if(t.ceramic==null)throw new Error("Invalid DataModel parameters: missing ceramic or loader");r2(this,Pd,new Jv({ceramic:t.ceramic,cache:t.cache}))}}},"DataModel");c(h8,"DataModel");function FU(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}s(FU,"_checkPrivateRedeclaration4");c(FU,"_checkPrivateRedeclaration");function NU(t,e){return e.get?e.get.call(t):e.value}s(NU,"_classApplyDescriptorGet4");c(NU,"_classApplyDescriptorGet");function LU(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}s(LU,"_classApplyDescriptorSet4");c(LU,"_classApplyDescriptorSet");function Fw(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}s(Fw,"_classExtractFieldDescriptor4");c(Fw,"_classExtractFieldDescriptor");function No(t,e){var r=Fw(t,e,"get");return NU(t,r)}s(No,"_classPrivateFieldGet4");c(No,"_classPrivateFieldGet");function Bp(t,e,r){FU(t,e),e.set(t,r)}s(Bp,"_classPrivateFieldInit4");c(Bp,"_classPrivateFieldInit");function Dp(t,e,r){var n=Fw(t,e,"set");return LU(t,n,r),r}s(Dp,"_classPrivateFieldSet4");c(Dp,"_classPrivateFieldSet");var kb=new WeakMap,$l=new WeakMap,s5=new WeakMap,Tb=new WeakMap,UU=s(class{_createValuePromise(){Dp(this,s5,new Promise((t,e)=>{Dp(this,Tb,{resolve:t,reject:e})}))}change(t){return new Promise((e,r)=>{let n=c(async i=>{try{let o=await t(i);e(),this._next(o)}catch(o){r(o),this._next(i)}},"run");No(this,$l).push({reject:r,run:n}),No(this,$l).length===1&&this._start()})}async changeContent(t){let e=c(async r=>(await r.update(t(r.content),r.metadata),r),"mutation");return await this.change(e)}async get(){return No(this,$l).length===0?await No(this,kb).call(this):await No(this,s5)}async _start(){try{let t=await No(this,kb).call(this);this._next(t)}catch(t){No(this,$l).forEach(e=>{e.reject(t)}),Dp(this,$l,[]),No(this,Tb).reject(t),this._createValuePromise()}}_next(t){let e=No(this,$l).shift();e==null?this._end(t):e.run(t)}_end(t){No(this,Tb).resolve(t),this._createValuePromise()}constructor(t){Bp(this,kb,{writable:!0,value:void 0}),Bp(this,$l,{writable:!0,value:[]}),Bp(this,s5,{writable:!0,value:void 0}),Bp(this,Tb,{writable:!0,value:void 0}),Dp(this,kb,t),this._createValuePromise()}},"TileProxy");c(UU,"TileProxy");var ene=/^did:([A-Za-z0-9]+):([A-Za-z0-9.\-:_]+)$/;function jU(t){return ene.test(t)}s(jU,"isDIDstring");c(jU,"isDIDstring");function qU(t){if(!jU(t))throw new Error(`Invalid DID: ${t}`)}s(qU,"assertDIDstring");c(qU,"assertDIDstring");function p8(t){return qU(t),{controllers:[t],family:"IDX"}}s(p8,"getIDXMetadata");c(p8,"getIDXMetadata");function HU(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}s(HU,"_checkPrivateRedeclaration5");c(HU,"_checkPrivateRedeclaration");function zU(t,e){return e.get?e.get.call(t):e.value}s(zU,"_classApplyDescriptorGet5");c(zU,"_classApplyDescriptorGet");function $U(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}s($U,"_classApplyDescriptorSet5");c($U,"_classApplyDescriptorSet");function Nw(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}s(Nw,"_classExtractFieldDescriptor5");c(Nw,"_classExtractFieldDescriptor");function bn(t,e){var r=Nw(t,e,"get");return zU(t,r)}s(bn,"_classPrivateFieldGet5");c(bn,"_classPrivateFieldGet");function Ld(t,e,r){HU(t,e),e.set(t,r)}s(Ld,"_classPrivateFieldInit5");c(Ld,"_classPrivateFieldInit");function Pp(t,e,r){var n=Nw(t,e,"set");return $U(t,n,r),r}s(Pp,"_classPrivateFieldSet5");c(Pp,"_classPrivateFieldSet");var Rc=new WeakMap,Mb=new WeakMap,o5=new WeakMap,Da=new WeakMap,Rb=new WeakMap,GU=s(class{get authenticated(){return bn(this,Rc).did!=null}get ceramic(){return bn(this,Rc)}get id(){if(bn(this,Mb)!=null)return bn(this,Mb);if(bn(this,Rc).did==null)throw new Error("Ceramic instance is not authenticated");return bn(this,Rc).did.hasParent?bn(this,Rc).did.parent:bn(this,Rc).did.id}get loader(){return bn(this,Da)}get model(){return bn(this,Rb)}async has(t,e){let r=this.getDefinitionID(t);return await this.getRecordID(r,e)!=null}async get(t,e){let r=this.getDefinitionID(t);return await this.getRecord(r,e)}async getMultiple(t,e){let r=this.getDefinitionID(t),n=await Promise.all(e.map(async a=>{let{genesis:f,streamId:l}=await Pw(p8(a));return{genesis:f,streamId:l.toString(),paths:[r]}})),i=await bn(this,Rc).multiQuery(n),o=[];for(let a of n){let f=i[a.streamId]?.content?.[r],l=f?i[xr.fromString(f).toString()]:null;o.push(l?.content??null)}return o}async set(t,e,r={}){let n=this.getDefinitionID(t),[i,o]=await this._setRecordOnly(n,e,r);return i&&await this._setReference(r.controller??this.id,n,o),o}async merge(t,e,r={}){let n=this.getDefinitionID(t),i=await this.getRecord(n),o=i?{...i,...e}:e;return await this.setRecord(n,o,r)}async setAll(t,e={}){let r=Object.entries(t).map(async([o,a])=>{let f=this.getDefinitionID(o),[l,u]=await this._setRecordOnly(f,a,e);return[l,f,u]}),i=(await Promise.all(r)).reduce((o,[a,f,l])=>(a&&(o[f]=l.toUrl()),o),{});return await this._setReferences(e.controller??this.id,i),i}async setDefaults(t,e={}){let r=await this.getIndex()??{},n=Object.entries(t).map(([a,f])=>[this.getDefinitionID(a),f]).filter(a=>r[a[0]]==null).map(async([a,f])=>{let l=await this.getDefinition(a),u=await this._createRecord(l,f,e);return{[a]:u.toUrl()}}),o=(await Promise.all(n)).reduce((a,f)=>Object.assign(a,f),{});return await this._setReferences(e.controller??this.id,o),o}async remove(t,e=this.id){await this._getIndexProxy(e).changeContent(r=>(r!=null&&delete r[this.getDefinitionID(t)],r))}async getIndex(t=this.id){let e=this.authenticated&&t===this.id?await this._getIndexProxy(t).get():await this._getIDXDoc(t);return e?e.content:null}iterator(t){let e,r=0;return{[Symbol.asyncIterator](){return this},next:async()=>{if(e==null){let a=await this.getIndex(t);e=Object.entries(a??{})}if(r===e.length)return{done:!0,value:null};let[n,i]=e[r++],o=await bn(this,Da).load(i);return{done:!1,value:{key:n,id:i,record:o.content}}}}}async _createIDXDoc(t){return await bn(this,Da).deterministic(p8(t))}async _getIDXDoc(t){let e=await this._createIDXDoc(t);if(e.content==null||e.metadata.schema==null)return null;if(e.metadata.schema!==i5)throw new Error("Invalid document: schema is not IdentityIndex");return e}async _getOwnIDXDoc(t){let e=await this._createIDXDoc(t);if(e.content==null||e.metadata.schema==null)await e.update({},{schema:i5});else if(e.metadata.schema!==i5)throw new Error("Invalid document: schema is not IdentityIndex");return e}_getIndexProxy(t){let e=bn(this,o5)[t];return e==null&&(e=new UU(async()=>await this._getOwnIDXDoc(t)),bn(this,o5)[t]=e),e}getDefinitionID(t){return bn(this,Rb).getDefinitionID(t)??t}async getDefinition(t){let e=await bn(this,Da).load(t);if(e.metadata.schema!==Qre)throw new Error("Invalid document: schema is not Definition");return{...e.content,id:e.id}}async getRecordID(t,e){return(await this.getIndex(e??this.id))?.[t]??null}async getRecordDocument(t,e){let r=await this.getRecordID(t,e);return r?await bn(this,Da).load(r):null}async getRecord(t,e){let r=await this.getRecordDocument(t,e);return r?r.content:null}async setRecord(t,e,r={}){let[n,i]=await this._setRecordOnly(t,e,r);return n&&await this._setReference(r.controller??this.id,t,i),i}async _setRecordOnly(t,e,r){let n=await this.getRecordID(t,r.controller??this.id);if(n==null){let i=await this.getDefinition(t),o=await this._createRecord(i,e,r);return[!0,o]}else{let i=await bn(this,Da).update(n,e);return[!1,i.id]}}async _createRecord(t,e,{controller:r,pin:n}){let i=await bn(this,Da).deterministic({controllers:[r??this.id],family:t.id.toString()},{pin:n});return await i.update(e,{schema:t.schema}),i.id}async _setReference(t,e,r){await this._getIndexProxy(t).changeContent(n=>({...n,[e]:r.toUrl()}))}async _setReferences(t,e){Object.keys(e).length!==0&&await this._getIndexProxy(t).changeContent(r=>({...r,...e}))}constructor(t){Ld(this,Rc,{writable:!0,value:void 0}),Ld(this,Mb,{writable:!0,value:void 0}),Ld(this,o5,{writable:!0,value:{}}),Ld(this,Da,{writable:!0,value:void 0}),Ld(this,Rb,{writable:!0,value:void 0});let{cache:e,ceramic:r,id:n,loader:i,model:o}=t;Pp(this,Rc,r),Pp(this,Mb,n),Pp(this,Da,i??new Jv({ceramic:r,cache:e})),Pp(this,Rb,o instanceof h8?o:new h8({loader:bn(this,Da),aliases:o}))}},"DIDDataStore");c(GU,"DIDDataStore");var tne=we.object({credentials:Up.array()}).catchall(we.any()),rne=we.object({id:we.string(),title:we.string(),storageType:we.literal("ceramic").optional()}).catchall(we.any()),nne=we.object({credentials:Up.or(rne).array()}).strict(),ine=c(async(t,{modelData:e,credentialAlias:r})=>{let n=t.invoke.getCeramicClient(),i=new GU({ceramic:n,model:e}),o=c(async(h=r)=>{let g=await i.get(h);if(!g)return{credentials:[]};let x=await tne.spa(g);if(x.success)return x.data;let _=await nne.spa(g);if(_.success){let B={credentials:_.data.credentials.map(F=>{if("uri"in F)return F;let{title:H,id:U,storageType:q,...K}=F;return{...K,id:H,uri:`lc:ceramic:${U.replace("ceramic://","")}`}})};return await i.set(r,B),B}throw console.error(x.error),new Error("Invalid credentials list stored in IDX")},"getCredentialsListFromIdx"),a=c(async(h,g)=>{if(!h)throw new Error("Must provide id to remove");g||(g=r);let x=await o(g);return x.credentials=x.credentials.filter(_=>_.id!==h),i.set(g,x)},"removeCredentialFromIdx"),f=c(async h=>(h||(h=r),i.set(h,{credentials:[]})),"removeAllCredentialsFromIdx"),l=c(async h=>{let g=await Up.parseAsync(h);if(!g)throw new Error("record is required");if(!g.uri)throw Error("No URI provided");await t.read.get(g.uri);let x=await o(r),_=x.credentials.findIndex(E=>E.id===g.id);return _>-1?x.credentials[_]=g:x.credentials.push(g),$p(await i.set(r,x))},"addCredentialInIdx"),u=c(async h=>{let g=Up.array().parse(h),x=await o(r);return await Promise.all(g.map(async _=>{await t.read.get(_.uri);let E=x.credentials.findIndex(T=>T.id===_.id);E>-1?x.credentials[E]=_:x.credentials.push(_)})),$p(await i.set(r,x))},"addCredentialsInIdx");return{name:"IDX",displayName:"IDX",description:"Stores a bespoke index of credentials for an individual based on their did",index:{get:async h=>(h.debug?.("learnCard.index.IDX.get"),(await o()).credentials),add:async(h,g)=>{h.debug?.("learnCard.index.IDX.add");try{return await l(g),!0}catch(x){return console.error("Error adding credential with IDX:",x),!1}},addMany:async(h,g)=>{h.debug?.("learnCard.index.IDX.add");try{return await u(g),!0}catch(x){return console.error("Error adding credential with IDX:",x),!1}},update:async h=>(h.debug?.("learnCard.index.IDX.update"),!1),remove:async(h,g)=>{h.debug?.("learnCard.index.IDX.remove");try{return await a(g),!0}catch(x){return console.error("Error removing credential from IDX:",x),!1}},removeAll:async h=>{h.debug?.("learnCard.index.IDX.removeAll");try{return await f(),!0}catch(g){return console.error("Error removing credentials from IDX:",g),!1}}},methods:{getCredentialsListFromIdx:async(h,g=r)=>(await o(g)).credentials,getVerifiableCredentialFromIdx:async(h,g)=>{let _=(await o())?.credentials?.find(B=>B?.id===g),E=h.read.get(_?.uri),T=await Fc.safeParseAsync(E);return T.success?T.data:void 0},getVerifiableCredentialsFromIdx:async h=>{let x=(await o())?.credentials?.map(_=>_?.uri)??[];return(await Promise.all(x.map(async _=>h.read.get(_)))).filter(_=>!!_)},addVerifiableCredentialInIdx:async(h,g)=>{let x=Up.parse(g);if(!x)throw new Error("record is required");if(!x.uri)throw Error("No URI provided");await h.read.get(x.uri);let _=await o(r),E=_.credentials.findIndex(T=>T.id===x.id);return E>-1?_.credentials[E]=x:_.credentials.push(x),$p(await i.set(r,_))},removeVerifiableCredentialInIdx:async(h,g)=>a(g),removeAllVerifiableCredentialsInIdx:async()=>f(),getIDXIndex:async()=>i.get(r),setIDXIndex:async(h,g)=>i.set(r,g)}}},"getIDXPlugin"),sne=wr(hZ()),one=c(t=>t.startsWith("0x")&&t.length===42,"isAddress"),ane=c(async(t,e,r,n)=>{let i=await Lw(e,r,n);return $i.utils.formatUnits(t,i?.decimals)},"formatUnits"),cne=c(async(t,e,r,n)=>{let i=await Lw(e,r,n);return $i.utils.parseUnits(t,i?.decimals)},"parseUnits"),Lw=c(async(t,e,r)=>{let n;return one(t)?n=await fne(t,e,r):n=await lne(t,e,r),n},"getTokenFromSymbolOrAddress"),fne=c(async(t,e,r)=>e.find(i=>i.chainId===r&&i.address===t),"getTokenFromAddress"),lne=c(async(t,e,r)=>e.find(i=>i.chainId===r&&i.symbol.toUpperCase()===t.toUpperCase()),"getTokenFromSymbol"),a5=c(async t=>(await t.getNetwork()).chainId,"getChainIdFromProvider"),une=[{name:"USDCoin",address:"0x07865c6e87b9f70255377e024ace6630c1eaa37f",symbol:"USDC",decimals:6,chainId:5,logoURI:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",extensions:{bridgeInfo:{10:{tokenAddress:"0x7F5c764cBc14f9669B88837ca1490cCa17c31607"},137:{tokenAddress:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"},42161:{tokenAddress:"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"}}}}],dne=une,sR=pZ(),hne=c((t,e)=>{let{infuraProjectId:r,network:n="mainnet"}=e,i=t.id.keypair("secp256k1");if(!i)throw new Error("LearnCard must support secp256k1 JWK in order to add Ethereum Plugin");let o=sne.Buffer.from(i.d,"base64").toString("hex"),a=new $i.Wallet(o),f=a.address,l=c(()=>{let T;return r?T=new $i.providers.InfuraProvider(n,r):T=$i.getDefaultProvider(n),a=a.connect(T),T},"getProvider"),u=l(),g=c(()=>mZ().tokens.concat(dne),"getDefaultTokenList")(),x=c(async T=>(await Lw(T,g,await a5(u)))?.address,"getTokenAddress"),_=c(async(T,B=f)=>{let H=await new $i.Contract(T,sR,u).balanceOf(B);return ane(H,T,g,await a5(u))},"getErc20TokenBalance"),E=c(async(T=f,B="ETH")=>{if(!B||B==="ETH"){let U=await u.getBalance(T);return $i.utils.formatEther(U)}let F=await x(B);if(!F)throw new Error(`Unable to determine token address for "${B}"`);return await _(F,T)},"getBalance");return{name:"Ethereum",displayName:"Ethereum",description:"Provides access to currency",methods:{getEthereumAddress:()=>f,getBalance:async(T,B="ETH")=>E(f,B),getBalanceForAddress:async(T,B,F)=>E(B,F),transferTokens:async(T,B,F,H)=>{if(B==="ETH"){let K={to:H,value:$i.utils.parseEther(F.toString())};return(await a.sendTransaction(K)).hash}let U=await x(B);if(!U)throw new Error(`Unable to determine token address for "${B}"`);let q=new $i.Contract(U,sR,a);return(await q.transfer(H,await cne(F.toString(),q.address,g,await a5(u)))).hash},getGasPrice:async()=>$i.utils.formatUnits(await u.getGasPrice()),getCurrentNetwork:()=>n,changeNetwork:(T,B)=>{let F=n;try{n=B,u=l()}catch(H){throw n=F,u=l(),H}},addInfuraProjectId:(T,B)=>{r=B,u=l()}}}},"getEthereumPlugin"),Vi=s(class extends Error{constructor(t,e){super(),this.message=e,this.value=t,this.stack=new Error(`${t}: ${e}`).stack,this.name=this.constructor.name}},"CborldError");c(Vi,"CborldError");var Ya=s(class{decode({value:t}={}){throw new Error("Must be implemented by derived class.")}static createDecoder({value:t,transformer:e}={}){throw new Error("Must be implemented by derived class.")}},"CborldDecoder");c(Ya,"CborldDecoder");var KU=new Map,VU=new Map;Xn(16,"https://www.w3.org/ns/activitystreams");Xn(17,"https://www.w3.org/2018/credentials/v1");Xn(18,"https://www.w3.org/ns/did/v1");Xn(19,"https://w3id.org/security/suites/ed25519-2018/v1");Xn(20,"https://w3id.org/security/suites/ed25519-2020/v1");Xn(21,"https://w3id.org/cit/v1");Xn(22,"https://w3id.org/age/v1");Xn(23,"https://w3id.org/security/suites/x25519-2020/v1");Xn(24,"https://w3id.org/veres-one/v1");Xn(25,"https://w3id.org/webkms/v1");Xn(26,"https://w3id.org/zcap/v1");Xn(27,"https://w3id.org/security/suites/hmac-2019/v1");Xn(28,"https://w3id.org/security/suites/aes-2019/v1");Xn(29,"https://w3id.org/vaccination/v1");Xn(30,"https://w3id.org/vc-revocation-list-2020/v1");Xn(31,"https://w3id.org/dcc/v1c");Xn(32,"https://w3id.org/vc/status-list/v1");function Xn(t,e){VU.set(e,t),KU.set(t,e)}s(Xn,"_addRegistration");c(Xn,"_addRegistration");var j2=s(class extends Ya{constructor({reverseAppContextMap:t}={}){super(),this.reverseAppContextMap=t}decode({value:t}={}){if(typeof t!="number")return q2(t);let e=KU.get(t)||this.reverseAppContextMap.get(t);if(e===void 0)throw new Vi("ERR_UNDEFINED_COMPRESSED_CONTEXT",`Undefined compressed context "${t}".`);return e}static createDecoder({transformer:t}={}){let{reverseAppContextMap:e}=t;return new j2({reverseAppContextMap:e})}},"ContextDecoder");c(j2,"ContextDecoder");function q2(t){if(Array.isArray(t))return t.map(q2);if(!(t instanceof Map))return t;let e={};for(let[r,n]of t)e[r]=q2(n);return e}s(q2,"_mapToObject");c(q2,"_mapToObject");var WU="3.7.5",pne=WU,mne=typeof atob=="function",gne=typeof btoa=="function",Sh=typeof Buffer=="function",oR=typeof TextDecoder=="function"?new TextDecoder:void 0,aR=typeof TextEncoder=="function"?new TextEncoder:void 0,bne="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Op=Array.prototype.slice.call(bne),Bb=(t=>{let e={};return t.forEach((r,n)=>e[r]=n),e})(Op),vne=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,oi=String.fromCharCode.bind(String),cR=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):t=>new Uint8Array(Array.prototype.slice.call(t,0)),JU=c(t=>t.replace(/=/g,"").replace(/[+\/]/g,e=>e=="+"?"-":"_"),"_mkUriSafe"),YU=c(t=>t.replace(/[^A-Za-z0-9\+\/]/g,""),"_tidyB64"),ZU=c(t=>{let e,r,n,i,o="",a=t.length%3;for(let f=0;f<t.length;){if((r=t.charCodeAt(f++))>255||(n=t.charCodeAt(f++))>255||(i=t.charCodeAt(f++))>255)throw new TypeError("invalid character found");e=r<<16|n<<8|i,o+=Op[e>>18&63]+Op[e>>12&63]+Op[e>>6&63]+Op[e&63]}return a?o.slice(0,a-3)+"===".substring(a):o},"btoaPolyfill"),Uw=gne?t=>btoa(t):Sh?t=>Buffer.from(t,"binary").toString("base64"):ZU,m8=Sh?t=>Buffer.from(t).toString("base64"):t=>{let r=[];for(let n=0,i=t.length;n<i;n+=4096)r.push(oi.apply(null,t.subarray(n,n+4096)));return Uw(r.join(""))},n2=c((t,e=!1)=>e?JU(m8(t)):m8(t),"fromUint8Array"),yne=c(t=>{if(t.length<2){var e=t.charCodeAt(0);return e<128?t:e<2048?oi(192|e>>>6)+oi(128|e&63):oi(224|e>>>12&15)+oi(128|e>>>6&63)+oi(128|e&63)}else{var e=65536+(t.charCodeAt(0)-55296)*1024+(t.charCodeAt(1)-56320);return oi(240|e>>>18&7)+oi(128|e>>>12&63)+oi(128|e>>>6&63)+oi(128|e&63)}},"cb_utob"),xne=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,XU=c(t=>t.replace(xne,yne),"utob"),fR=Sh?t=>Buffer.from(t,"utf8").toString("base64"):aR?t=>m8(aR.encode(t)):t=>Uw(XU(t)),Gd=c((t,e=!1)=>e?JU(fR(t)):fR(t),"encode"),lR=c(t=>Gd(t,!0),"encodeURI"),wne=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,_ne=c(t=>{switch(t.length){case 4:var e=(7&t.charCodeAt(0))<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|63&t.charCodeAt(3),r=e-65536;return oi((r>>>10)+55296)+oi((r&1023)+56320);case 3:return oi((15&t.charCodeAt(0))<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2));default:return oi((31&t.charCodeAt(0))<<6|63&t.charCodeAt(1))}},"cb_btou"),QU=c(t=>t.replace(wne,_ne),"btou"),ej=c(t=>{if(t=t.replace(/\s+/g,""),!vne.test(t))throw new TypeError("malformed base64.");t+="==".slice(2-(t.length&3));let e,r="",n,i;for(let o=0;o<t.length;)e=Bb[t.charAt(o++)]<<18|Bb[t.charAt(o++)]<<12|(n=Bb[t.charAt(o++)])<<6|(i=Bb[t.charAt(o++)]),r+=n===64?oi(e>>16&255):i===64?oi(e>>16&255,e>>8&255):oi(e>>16&255,e>>8&255,e&255);return r},"atobPolyfill"),jw=mne?t=>atob(YU(t)):Sh?t=>Buffer.from(t,"base64").toString("binary"):ej,tj=Sh?t=>cR(Buffer.from(t,"base64")):t=>cR(jw(t).split("").map(e=>e.charCodeAt(0))),rj=c(t=>tj(nj(t)),"toUint8Array"),Ane=Sh?t=>Buffer.from(t,"base64").toString("utf8"):oR?t=>oR.decode(tj(t)):t=>QU(jw(t)),nj=c(t=>YU(t.replace(/[-_]/g,e=>e=="-"?"+":"/")),"_unURI"),g8=c(t=>Ane(nj(t)),"decode"),Ene=c(t=>{if(typeof t!="string")return!1;let e=t.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(e)||!/[^\s0-9a-zA-Z\-_]/.test(e)},"isValid"),ij=c(t=>({value:t,enumerable:!1,writable:!0,configurable:!0}),"_noEnum"),sj=c(function(){let t=c((e,r)=>Object.defineProperty(String.prototype,e,ij(r)),"_add");t("fromBase64",function(){return g8(this)}),t("toBase64",function(e){return Gd(this,e)}),t("toBase64URI",function(){return Gd(this,!0)}),t("toBase64URL",function(){return Gd(this,!0)}),t("toUint8Array",function(){return rj(this)})},"extendString"),oj=c(function(){let t=c((e,r)=>Object.defineProperty(Uint8Array.prototype,e,ij(r)),"_add");t("toBase64",function(e){return n2(this,e)}),t("toBase64URI",function(){return n2(this,!0)}),t("toBase64URL",function(){return n2(this,!0)})},"extendUint8Array"),Cne=c(()=>{sj(),oj()},"extendBuiltins"),aj={version:WU,VERSION:pne,atob:jw,atobPolyfill:ej,btoa:Uw,btoaPolyfill:ZU,fromBase64:g8,toBase64:Gd,encode:Gd,encodeURI:lR,encodeURL:lR,utob:XU,btou:QU,decode:g8,isValid:Ene,fromUint8Array:n2,toUint8Array:rj,extendString:sj,extendUint8Array:oj,extendBuiltins:Cne},uR={};function cj(t,e,r){if(!(t instanceof Uint8Array))throw new TypeError('"input" must be a Uint8Array.');if(typeof e!="string")throw new TypeError('"alphabet" must be a string.');if(r!==void 0&&typeof r!="number")throw new TypeError('"maxline" must be a number.');if(t.length===0)return"";let n="",i=0,o=e.length,a=e.charAt(0),f=[0];for(i=0;i<t.length;++i){let l=t[i];for(let u=0;u<f.length;++u)l+=f[u]<<8,f[u]=l%o,l=l/o|0;for(;l>0;)f.push(l%o),l=l/o|0}for(i=0;t[i]===0&&i<t.length-1;++i)n+=a;for(i=f.length-1;i>=0;--i)n+=e[f[i]];if(r){let l=new RegExp(".{1,"+r+"}","g");n=n.match(l).join(`\r
|
|
826
826
|
`)}return n}s(cj,"encode10");c(cj,"encode");function fj(t,e){if(typeof t!="string")throw new TypeError('"input" must be a string.');if(typeof e!="string")throw new TypeError('"alphabet" must be a string.');if(t.length===0)return new Uint8Array;let r=uR[e];if(!r){r=uR[e]=[];for(let a=0;a<e.length;++a)r[e.charCodeAt(a)]=a}t=t.replace(/\s/g,"");let n=e.length,i=e.charAt(0),o=[0];for(let a=0;a<t.length;a++){let f=r[t.charCodeAt(a)];if(f===void 0)return;let l=f;for(let u=0;u<o.length;++u)l+=o[u]*n,o[u]=l&255,l>>=8;for(;l>0;)o.push(l&255),l>>=8}for(let a=0;t[a]===i&&a<t.length-1;++a)o.push(0);return new Uint8Array(o.reverse())}s(fj,"decode10");c(fj,"decode");var lj="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function H2(t,e){return cj(t,lj,e)}s(H2,"encode11");c(H2,"encode");function qw(t){return fj(t,lj)}s(qw,"decode11");c(qw,"decode");var Hw=s(class extends Ya{decode({value:t}={}){let{buffer:e,byteOffset:r,length:n}=t,i=new Uint8Array(e,r+1,n-1);return t[0]===122?`z${H2(i)}`:t[0]===77?`M${aj.fromUint8Array(i)}`:t}static createDecoder({value:t}={}){if(!(t instanceof Uint8Array))return!1;if(t[0]===122||t[0]===77)return new Hw}},"MultibaseDecoder");c(Hw,"MultibaseDecoder");var jf=new Map([["@context",0],["@type",2],["@id",4],["@value",6],["@direction",8],["@graph",10],["@included",12],["@index",14],["@json",16],["@language",18],["@list",20],["@nest",22],["@reverse",24],["@base",26],["@container",28],["@default",30],["@embed",32],["@explicit",34],["@none",36],["@omitDefault",38],["@prefix",40],["@preserve",42],["@protected",44],["@requireAll",46],["@set",48],["@version",50],["@vocab",52]]),uj=100,zw=s(class{constructor({appContextMap:t,documentLoader:e}={}){this.appContextMap=t,this.documentLoader=e}_beforeObjectContexts(){}_afterObjectContexts(){}_beforeTypeScopedContexts(){}async _transform({obj:t,transformMap:e,contextStack:r=[]}){this._beforeObjectContexts({obj:t,transformMap:e});let n=await this._applyEmbeddedContexts({obj:t,contextStack:r});this._afterObjectContexts({obj:t,transformMap:e});let i=r.slice();this._beforeTypeScopedContexts({activeCtx:n,obj:t,transformMap:e}),n=await this._applyTypeScopedContexts({obj:t,contextStack:r});let{aliases:o,scopedContextMap:a,termMap:f}=n,l=this._getEntries({obj:t,transformMap:e,transformer:this,termMap:f});for(let[u,h]of l){let{term:g}=u;if(g==="@id"||o.id.has(g)){this._transformObjectId({obj:t,transformMap:e,termInfo:u,value:h});continue}if(g==="@type"||o.type.has(g)){this._transformObjectType({obj:t,transformMap:e,termInfo:u,value:h});continue}let x=i,_,E=a.get(g);E&&(_=await this._applyEmbeddedContexts({obj:{"@context":E},contextStack:r}),x=r.slice());let{plural:T,def:B}=u,F=this._getTermType({activeCtx:_||n,def:B}),H=T?h:[h],U=[];for(let q of H){if(q===null){U.push(null);continue}if(!this._transformTypedValue({entries:U,termType:F,value:q,termInfo:u})){if(typeof q!="object"){U.push(q);continue}if(Array.isArray(q)){await this._transformArray({entries:U,contextStack:x,value:q});continue}await this._transformObject({entries:U,contextStack:x,value:q})}}_&&_.revert(),this._assignEntries({entries:U,obj:t,transformMap:e,termInfo:u})}n.revert()}async _applyEmbeddedContexts({obj:t,contextStack:e}){let r=e.length,n=t["@context"];await this._updateContextStack({contextStack:e,contexts:n});let i=e[e.length-1];return i||(i={aliases:{id:new Set,type:new Set},context:{},scopedContextMap:new Map,termMap:new Map}),{...i,revert(){e.length=r}}}async _applyTypeScopedContexts({obj:t,contextStack:e}){let r=e.length,n=e[e.length-1];n||(n={aliases:{id:new Set,type:new Set},context:{},scopedContextMap:new Map,termMap:new Map});let{aliases:i}=n,o=[],a=["@type",...i.type];for(let l of a){let u=t[l];Array.isArray(u)?o.push(...u):o.push(u)}o=[...new Set(o)].sort();let{scopedContextMap:f}=n;for(let l of o){let u=f.get(l);u&&(await this._updateContextStack({contextStack:e,contexts:u}),n=e[e.length-1],{scopedContextMap:f}=n)}return{...n,revert(){e.length=r}}}async _updateContextStack({contextStack:t,contexts:e,transformer:r}){if(!e)return;Array.isArray(e)||(e=[e]);let{contextMap:n}=this;for(let i of e){let o=n.get(i);if(!o){let g=i,x;typeof i=="string"&&(x=i,{"@context":g}=await this._getDocument({url:x})),o=await this._addContext({context:g,contextUrl:x,transformer:r})}let a={aliases:{id:new Set(o.aliases.id),type:new Set(o.aliases.type)},context:i,scopedContextMap:new Map(o.scopedContextMap),termMap:new Map(o.termMap)},f=t[t.length-1];if(t.push(a),!f)continue;let{aliases:l,termMap:u}=a;for(let g of["id","type"])for(let x of f.aliases[g])i[x]===null||a.termMap.has(x)||l[g].add(x);let{scopedContextMap:h}=a;for(let[g,x]of f.scopedContextMap)i[g]===null||h.has(g)||h.set(g,x);for(let[g,x]of f.termMap)i[g]===null||u.has(g)||u.set(g,x)}}async _addContext({context:t,contextUrl:e}){let{contextMap:r,termToId:n,idToTerm:i}=this,o=t["@import"];if(o){let h=r.get(o);if(!h){let{"@context":g}=await this._getDocument({url:o});h=await this._addContext({context:g,contextUrl:o})}t={...h.context,...t}}let a=new Map,f=new Map,l={aliases:{id:new Set,type:new Set},context:t,scopedContextMap:a,termMap:f},u=Object.keys(t).sort();for(let h of u){let g=t[h];if(!g||(g==="@id"||g.id==="@id"?l.aliases.id.add(h):(g==="@type"||g.id==="@type")&&l.aliases.type.add(h),jf.has(h)))continue;if(!n.has(h)){let _=this.nextTermId;this.nextTermId+=2,n.set(h,_),i&&i.set(_,h)}f.set(h,g);let x=g["@context"];x&&a.set(h,x)}return r.set(e||t,l),l}async _getDocument({url:t}){let{document:e}=await this.documentLoader(t);return typeof e=="string"?JSON.parse(e):e}_getTermType({activeCtx:t,def:e}){let{"@type":r}=e;if(!r)return;let[n,...i]=r.split(":"),o=t.termMap.get(n);if(o===void 0)return r;if(typeof o=="string")return o+i.join(":");if(!(typeof o=="object"&&typeof o["@id"]=="string"))throw new Vi("ERR_INVALID_TERM_DEFINITION",'JSON-LD term definitions must be strings or objects with "@id".');return o["@id"]+i.join(":")}_getIdForTerm({term:t,plural:e}){let r=this.termToId.get(t);if(r===void 0)throw new Vi("ERR_UNDEFINED_TERM","CBOR-LD compression requires all terms to be defined in a JSON-LD context.");return e?r+1:r}_getTermForId({id:t}){let e=(t&1)===1;return{term:this.idToTerm.get(e?t-1:t),plural:e}}},"Transformer");c(zw,"Transformer");var dR=new Map([[1024,"did:v1:nym:"],[1025,"did:key:"]]),z2=s(class extends Ya{decode({value:t}={}){let e=dR.get(t[0]);return typeof t[1]=="string"?e+=t[1]:e+=`z${H2(t[1])}`,t.length>2&&(typeof t[2]=="string"?e+=`#${t[2]}`:e+=`#z${H2(t[2])}`),e}static createDecoder({value:t}={}){return!(Array.isArray(t)&&t.length>1&&t.length<=3)||!dR.has(t[0])?!1:new z2}},"Base58DidUrlDecoder");c(z2,"Base58DidUrlDecoder");var $2=s(class extends Ya{constructor({secure:t}={}){super(),this.secure=t}decode({value:t}={}){return`${this.secure?"https://":"http://"}${t[1]}`}static createDecoder({value:t}={}){return t.length===2&&typeof t[1]=="string"?new $2({secure:t[0]===2}):!1}},"HttpUrlDecoder");c($2,"HttpUrlDecoder");var Sne=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function dj(t){return typeof t=="string"&&Sne.test(t)}s(dj,"validate6");c(dj,"validate");var hj=dj,si=[];for(vn=0;vn<256;++vn)si.push((vn+256).toString(16).substr(1));var vn;function pj(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=(si[t[e+0]]+si[t[e+1]]+si[t[e+2]]+si[t[e+3]]+"-"+si[t[e+4]]+si[t[e+5]]+"-"+si[t[e+6]]+si[t[e+7]]+"-"+si[t[e+8]]+si[t[e+9]]+"-"+si[t[e+10]]+si[t[e+11]]+si[t[e+12]]+si[t[e+13]]+si[t[e+14]]+si[t[e+15]]).toLowerCase();if(!hj(r))throw TypeError("Stringified UUID is invalid");return r}s(pj,"stringify2");c(pj,"stringify");var Ine=pj;function mj(t){if(!hj(t))throw TypeError("Invalid UUID");var e,r=new Uint8Array(16);return r[0]=(e=parseInt(t.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=e&255,r[4]=(e=parseInt(t.slice(9,13),16))>>>8,r[5]=e&255,r[6]=(e=parseInt(t.slice(14,18),16))>>>8,r[7]=e&255,r[8]=(e=parseInt(t.slice(19,23),16))>>>8,r[9]=e&255,r[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=e&255,r}s(mj,"parse2");c(mj,"parse");var kne=mj,$w=s(class extends Ya{decode({value:t}={}){return`urn:uuid:${typeof t[1]=="string"?t[1]:Ine(t[1])}`}static createDecoder({value:t}={}){if(t.length===2&&(typeof t[1]=="string"||t[1]instanceof Uint8Array))return new $w}},"UuidUrnDecoder");c($w,"UuidUrnDecoder");var Tne=new Map([[1,$2],[2,$2],[3,$w],[1024,z2],[1025,z2]]),Yv=s(class extends Ya{static createDecoder({value:t}={}){if(!(Array.isArray(t)||t.length>1))return!1;let e=Tne.get(t[0]);return e&&e.createDecoder({value:t})}},"UriDecoder");c(Yv,"UriDecoder");var Kd=s(class extends Ya{constructor({term:t}={}){super(),this.term=t}decode(){return this.term}static createDecoder({value:t,transformer:e}={}){if(Array.isArray(t))return Yv.createDecoder({value:t,transformer:e});let r=e.idToTerm.get(t);if(r!==void 0)return new Kd({term:r})}},"VocabTermDecoder");c(Kd,"VocabTermDecoder");var Gw=s(class extends Ya{decode({value:t}={}){let e=new Date(t*1e3).toISOString();return e.substring(0,e.indexOf("T"))}static createDecoder({value:t}={}){if(typeof t=="number")return new Gw}},"XsdDateDecoder");c(Gw,"XsdDateDecoder");var G2=s(class extends Ya{constructor({value:t}={}){super(),this.value=t}decode({value:t}={}){return typeof t=="number"?new Date(t*1e3).toISOString().replace(".000Z","Z"):new Date(t[0]*1e3+t[1]).toISOString()}static createDecoder({value:t}={}){if(typeof t=="number")return new G2;if(Array.isArray(t)&&t.length===2&&(typeof t[0]=="number"||typeof t[1]=="number"))return new G2}},"XsdDateTimeDecoder");c(G2,"XsdDateTimeDecoder");function z1(t,e){return JSON.stringify(t,null,2)}s(z1,"inspect4");c(z1,"inspect");var Mne=new Map([["@id",Yv],["@vocab",Kd],["https://w3id.org/security#multibase",Hw],["http://www.w3.org/2001/XMLSchema#date",Gw],["http://www.w3.org/2001/XMLSchema#dateTime",G2]]),b8=jf.get("@context"),hR=b8+1,gj=s(class extends zw{constructor({documentLoader:t,appContextMap:e}={}){if(super({documentLoader:t,appContextMap:e}),this.reverseAppContextMap=new Map,e)for(let[r,n]of e)this.reverseAppContextMap.set(n,r)}async decompress({compressedBytes:t,diagnose:e}={}){this.contextMap=new Map,this.termToId=new Map(jf),this.nextTermId=uj,this.idToTerm=new Map;for(let[a,f]of this.termToId)this.idToTerm.set(f,a);let r=Dv(t,{useMaps:!0});e&&(e("Diagnostic CBOR-LD decompression transform map(s):"),e(z1(r,{depth:null,colors:!0})));let n=[],i=Array.isArray(r),o=i?r:[r];for(let a of o){let f={};await this._transform({obj:f,transformMap:a}),n.push(f)}return i?n:n[0]}_beforeObjectContexts({obj:t,transformMap:e}){let r=e.get(b8);if(r){let i=j2.createDecoder({value:r,transformer:this});t["@context"]=i?i.decode({value:r}):r}let n=e.get(hR);if(n){if(r)throw new Vi("ERR_INVALID_ENCODED_CONTEXT","Both singular and plural context IDs were found in the CBOR-LD input.");if(!Array.isArray(n))throw new Vi("ERR_INVALID_ENCODED_CONTEXT","Encoded plural context value must be an array.");let i=[];for(let o of n){let a=j2.createDecoder({value:o,transformer:this});i.push(a?a.decode({value:o}):o)}t["@context"]=i}}_beforeTypeScopedContexts({activeCtx:t,obj:e,transformMap:r}){let{termToId:n}=this,i=["@type",...t.aliases.type];for(let o of i){let a=n.get(o),f=r.get(a);if(f===void 0&&(f=r.get(a+1)),f!==void 0)if(Array.isArray(f))e[o]=f.map(l=>{let u=Kd.createDecoder({value:l,transformer:this});return u?u.decode({value:l}):l});else{let l=Kd.createDecoder({value:f,transformer:this});e[o]=l?l.decode({value:f}):f}}}_getEntries({transformMap:t,termMap:e}){let r=[];for(let[n,i]of t){if(n===b8||n===hR)continue;let{term:o,plural:a}=this._getTermForId({id:n});if(o===void 0)throw new Vi("ERR_UNKNOWN_CBORLD_TERM_ID",`Unknown term ID '${n}' was detected in the CBOR-LD input.`);let f=e.get(o);if(f===void 0&&!(o.startsWith("@")&&jf.has(o)))throw new Vi("ERR_UNKNOWN_CBORLD_TERM",`Unknown term "${o}" was detected in the CBOR-LD input.`);r.push([{term:o,termId:n,plural:a,def:f},i])}return r.sort(bj)}_getTermInfo({termMap:t,key:e}){let{term:r,plural:n}=this._getTermForId({id:e});if(r===void 0)throw new Vi("ERR_UNKNOWN_CBORLD_TERM_ID",`Unknown term ID '${e}' was detected in the CBOR-LD input.`);let i=t.get(r);if(i===void 0&&!(r.startsWith("@")&&jf.has(r)))throw new Vi("ERR_UNKNOWN_CBORLD_TERM",`Unknown term "${r}" was detected in the CBOR-LD input.`);return{term:r,termId:e,plural:n,def:i}}_transformObjectId({obj:t,termInfo:e,value:r}){let n=Yv.createDecoder({value:r});t[e.term]=n?n.decode({value:r}):r}_transformObjectType({obj:t,termInfo:e,value:r}){let{term:n,plural:i}=e,o=i?r:[r],a=[];for(let f of o){let l=Kd.createDecoder({value:f,transformer:this});a.push(l?l.decode({value:f}):f)}t[n]=i?a:a[0]}_transformTypedValue({entries:t,termType:e,value:r}){let n=Mne.get(e),i=n&&n.createDecoder({value:r,transformer:this});if(i)return t.push(i.decode({value:r})),!0}async _transformArray({entries:t,contextStack:e,value:r}){let n=[];for(let i of r){let o={};n.push(o),await this._transform({obj:o,transformMap:i,contextStack:e})}t.push(n)}async _transformObject({entries:t,contextStack:e,value:r}){let n={};return t.push(n),this._transform({obj:n,transformMap:r,contextStack:e})}_assignEntries({entries:t,obj:e,termInfo:r}){let{term:n,plural:i}=r;e[n]=i?t:t[0]}},"Decompressor");c(gj,"Decompressor");function bj([{term:t}],[{term:e}]){return t<e?-1:t>e?1:0}s(bj,"_sortEntriesByTerm");c(bj,"_sortEntriesByTerm");async function vj({cborldBytes:t,documentLoader:e,appContextMap:r=new Map,diagnose:n}){if(!(t instanceof Uint8Array))throw new TypeError('"cborldBytes" must be a Uint8Array.');let i=0;if(t[i++]!==217)throw new Vi("ERR_NOT_CBORLD",'CBOR-LD must start with a CBOR major type "Tag" header of `0xd9`.');if(t[i++]!==5)throw new Vi("ERR_NOT_CBORLD","CBOR-LD 16-bit tag must start with `0x05`.");let o=t[i];if(o===void 0)throw new Vi("ERR_NOT_CBORLD","Truncated CBOR-LD 16-bit tag.");if(!(o===0||o===1))throw new Vi("ERR_NOT_CBORLD",`Unsupported CBOR-LD compression mode "${o}".`);i++;let{buffer:a,byteOffset:f,length:l}=t,u=new Uint8Array(a,f+i,l-i);if(o===0)return Dv(u,{useMaps:!1});let g=await new gj({documentLoader:e,appContextMap:r}).decompress({compressedBytes:u,diagnose:n});return n&&(n("Diagnostic JSON-LD result:"),n(z1(g,{depth:null,colors:!0}))),g}s(vj,"decode12");c(vj,"decode");var Zo=s(class{encode(){throw new Error("Must be implemented by derived class.")}static createEncoder({value:t}={}){throw new Error("Must be implemented by derived class.")}},"CborldEncoder");c(Zo,"CborldEncoder");var Kw=s(class extends Zo{constructor({context:t,appContextMap:e}={}){super(),this.context=t,this.appContextMap=e}encode(){let{context:t}=this,e=VU.get(t)||this.appContextMap.get(t);return e===void 0?new st(Ue.string,t):new st(Ue.uint,e)}static createEncoder({value:t,transformer:e}={}){if(typeof t!="string")return!1;let{appContextMap:r}=e;return new Kw({context:t,appContextMap:r})}},"ContextEncoder");c(Kw,"ContextEncoder");var Vw=s(class extends Zo{constructor({value:t}={}){super(),this.value=t}encode(){let{value:t}=this,e,r;t[0]==="z"?(e=122,r=qw(t.substr(1))):t[0]==="M"&&(e=77,r=aj.toUint8Array(t.substr(1)));let n=new Uint8Array(1+r.length);return n[0]=e,n.set(r,1),new st(Ue.bytes,n)}static createEncoder({value:t}={}){if(typeof t!="string")return!1;if(t[0]==="z"||t[0]==="M")return new Vw({value:t})}},"MultibaseEncoder");c(Vw,"MultibaseEncoder");var pR=new Map([["did:v1:nym:",1024],["did:key:",1025]]),K2=s(class extends Zo{constructor({value:t,scheme:e}={}){super(),this.value=t,this.scheme=e}encode(){let{value:t,scheme:e}=this,r=t.substr(e.length),[n,i]=r.split("#"),o=[new st(Ue.uint,pR.get(e)),v8(n)];return i!==void 0&&o.push(v8(i)),[new st(Ue.array,o.length),o]}static createEncoder({value:t}={}){let e=[...pR.keys()];for(let r of e)if(t.startsWith(r))return new K2({value:t,scheme:r})}},"Base58DidUrlEncoder");c(K2,"Base58DidUrlEncoder");function v8(t){if(t.startsWith("z")){let e=qw(t.substr(1));if(e)return new st(Ue.bytes,e)}return new st(Ue.string,t)}s(v8,"_multibase58ToToken");c(v8,"_multibase58ToToken");var p1=s(class extends Zo{constructor({value:t,secure:e}={}){super(),this.value=t,this.secure=e}encode(){let{value:t,secure:e}=this,r=e?8:7,n=[new st(Ue.uint,e?2:1),new st(Ue.string,t.substr(r))];return[new st(Ue.array,n.length),n]}static createEncoder({value:t}={}){if(t.startsWith("https://"))return new p1({value:t,secure:!0});if(t.startsWith("http://"))return new p1({value:t,secure:!1})}},"HttpUrlEncoder");c(p1,"HttpUrlEncoder");var Ww=s(class extends Zo{constructor({value:t}={}){super(),this.value=t}encode(){let{value:t}=this,e=t.substr(9),r=[new st(Ue.uint,3)];if(e.toLowerCase()===e){let n=kne(e);r.push(new st(Ue.bytes,n))}else r.push(new st(Ue.string,e));return[new st(Ue.array,r.length),r]}static createEncoder({value:t}={}){if(t.startsWith("urn:uuid:"))return new Ww({value:t})}},"UuidUrnEncoder");c(Ww,"UuidUrnEncoder");var Rne=new Map([["http",p1],["https",p1],["urn:uuid",Ww],["did:v1:nym",K2],["did:key",K2]]),Zv=s(class extends Zo{static createEncoder({value:t}={}){if(typeof t!="string")return!1;let e;try{let{protocol:n,pathname:i}=new URL(t);e=n,i.includes(":")&&(e+=i);let o=t.split(":");o.pop(),e=o.join(":")}catch{return!1}let r=Rne.get(e);return r&&r.createEncoder({value:t})}},"UriEncoder");c(Zv,"UriEncoder");var Xv=s(class extends Zo{constructor({termId:t}={}){super(),this.termId=t}encode(){return new st(Ue.uint,this.termId)}static createEncoder({value:t,transformer:e}={}){let{termToId:r}=e,n=r.get(t);return n!==void 0?new Xv({termId:n}):Zv.createEncoder({value:t})}},"VocabTermEncoder");c(Xv,"VocabTermEncoder");var Jw=s(class extends Zo{constructor({value:t,parsed:e}={}){super(),this.value=t,this.parsed=e}encode(){let{value:t,parsed:e}=this,r=Math.floor(e/1e3),n=new Date(r*1e3).toISOString(),i=n.substring(0,n.indexOf("T"));return t!==i?new st(Ue.string,t):new st(Ue.uint,r)}static createEncoder({value:t}={}){if(t.includes("T"))return!1;let e=Date.parse(t);return isNaN(e)?!1:new Jw({value:t,parsed:e})}},"XsdDateEncoder");c(Jw,"XsdDateEncoder");var Yw=s(class extends Zo{constructor({value:t,parsed:e}={}){super(),this.value=t,this.parsed=e}encode(){let{value:t,parsed:e}=this,r=Math.floor(e/1e3),n=new st(Ue.uint,r),i=t.indexOf(".");if(i===-1){let l=new Date(r*1e3).toISOString().replace(".000Z","Z");return t!==l?new st(Ue.string,t):n}let o=parseInt(t.substr(i+1),10),a=new Date(r*1e3+o).toISOString();if(t!==a)return new st(Ue.string,t);let f=[n,new st(Ue.uint,o)];return[new st(Ue.array,f.length),f]}static createEncoder({value:t}={}){if(!t.includes("T"))return!1;let e=Date.parse(t);return isNaN(e)?!1:new Yw({value:t,parsed:e})}},"XsdDateTimeEncoder");c(Yw,"XsdDateTimeEncoder");var Bne=new Map([["@id",Zv],["@vocab",Xv],["https://w3id.org/security#multibase",Vw],["http://www.w3.org/2001/XMLSchema#date",Jw],["http://www.w3.org/2001/XMLSchema#dateTime",Yw]]),yj=jf.get("@context"),Dne=yj+1,Pne={Object(t){if(t instanceof Zo)return t.encode({obj:t})}},xj=s(class extends zw{constructor({documentLoader:t,appContextMap:e}={}){super({documentLoader:t,appContextMap:e})}async compress({jsonldDocument:t,diagnose:e}={}){let r=await this._createTransformMaps({jsonldDocument:t});return e&&(e("Diagnostic CBOR-LD compression transform map(s):"),e(z1(r,{depth:null,colors:!0}))),Rv(r,{typeEncoders:Pne})}async _createTransformMaps({jsonldDocument:t}){this.contextMap=new Map,this.termToId=new Map(jf),this.nextTermId=uj;let e=[],r=Array.isArray(t),n=r?t:[t];for(let i of n){let o=new Map;await this._transform({obj:i,transformMap:o}),e.push(o)}return r?e:e[0]}_afterObjectContexts({obj:t,transformMap:e}){let r=t["@context"];if(!r)return;let n=[],i=Array.isArray(r),o=i?r:[r];for(let f of o){let l=Kw.createEncoder({value:f,transformer:this});n.push(l||f)}let a=i?Dne:yj;e.set(a,i?n:n[0])}_getEntries({obj:t,termMap:e}){let r=[],n=Object.keys(t).sort();for(let i of n){if(i==="@context")continue;let o=e.get(i);if(o===void 0&&!(i.startsWith("@")&&jf.has(i)))throw new Vi("ERR_UNKNOWN_CBORLD_TERM",`Unknown term '${i}' was detected in the JSON-LD input.`);let a=t[i],f=Array.isArray(a),l=this._getIdForTerm({term:i,plural:f});r.push([{term:i,termId:l,plural:f,def:o},a])}return r}_transformObjectId({transformMap:t,termInfo:e,value:r}){let{termId:n}=e,i=Zv.createEncoder({value:r,transformer:this,termInfo:e});t.set(n,i||r)}_transformObjectType({transformMap:t,termInfo:e,value:r}){let{termId:n,plural:i}=e,o=i?r:[r],a=[];for(let f of o){let l=Xv.createEncoder({value:f,transformer:this,termInfo:e});a.push(l||f)}t.set(n,i?a:a[0])}_transformTypedValue({entries:t,termType:e,value:r,termInfo:n}){let i=Bne.get(e),o=i&&i.createEncoder({value:r,transformer:this,termInfo:n});if(o)return t.push(o),!0}async _transformArray({entries:t,contextStack:e,value:r}){let n=[];for(let i of r){let o=new Map;n.push(o),await this._transform({obj:i,transformMap:o,contextStack:e})}t.push(n)}async _transformObject({entries:t,contextStack:e,value:r}){let n=new Map;t.push(n),await this._transform({obj:r,transformMap:n,contextStack:e})}_assignEntries({entries:t,transformMap:e,termInfo:r}){let{termId:n,plural:i}=r;e.set(n,i?t:t[0])}},"Compressor");c(xj,"Compressor");async function wj({jsonldDocument:t,documentLoader:e,appContextMap:r=new Map,compressionMode:n=1,diagnose:i}={}){if(!(n===0||n===1))throw new TypeError('"compressionMode" must be "0" (no compression) or "1" for compression mode version 1.');let o=new Uint8Array([217,5,n]),a;n===0?a=Rv(t):a=await new xj({documentLoader:e,appContextMap:r}).compress({jsonldDocument:t,diagnose:i});let f=o.length+a.length,l=new Uint8Array(f);return l.set(o),l.set(a,o.length),i&&(i("Diagnostic CBOR-LD result:"),i(z1(l,{depth:null,colors:!0}))),l}s(wj,"encode12");c(wj,"encode");function _j(t){if(t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray)return new DataView(t.buffer,t.byteOffset,t.byteLength);if(t instanceof ArrayBuffer)return new DataView(t);throw new TypeError("Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray")}s(_j,"toDataView");c(_j,"toDataView");var One="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",Fne="0123456789ABCDEFGHIJKLMNOPQRSTUV",Nne="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function Aj(t,e,r){r=r||{};let n,i;switch(e){case"RFC3548":case"RFC4648":n=One,i=!0;break;case"RFC4648-HEX":n=Fne,i=!0;break;case"Crockford":n=Nne,i=!1;break;default:throw new Error("Unknown base32 variant: "+e)}let o=r.padding!==void 0?r.padding:i,a=_j(t),f=0,l=0,u="";for(let h=0;h<a.byteLength;h++)for(l=l<<8|a.getUint8(h),f+=8;f>=5;)u+=n[l>>>f-5&31],f-=5;if(f>0&&(u+=n[l<<5-f&31]),o)for(;u.length%8!==0;)u+="=";return u}s(Aj,"base32Encode");c(Aj,"base32Encode");var Lne=wr(gZ(),1),Wn;(function(t){t[t.Terminator=0]="Terminator",t[t.Numeric=1]="Numeric",t[t.Alphanumeric=2]="Alphanumeric",t[t.StructuredAppend=3]="StructuredAppend",t[t.Byte=4]="Byte",t[t.Kanji=8]="Kanji",t[t.ECI=7]="ECI"})(Wn||(Wn={}));var Zw=function(){function t(e,r){this.bytes=[],this.mode=e,this.data=r}return s(t,"QRData2"),c(t,"QRData"),t.prototype.getLength=function(){return this.bytes.length},t.prototype.getLengthInBits=function(e){var r=this.mode,n=new Error("illegal mode: ".concat(r));if(1<=e&&e<10)switch(r){case Wn.Numeric:return 10;case Wn.Alphanumeric:return 9;case Wn.Byte:return 8;case Wn.Kanji:return 8;default:throw n}else if(e<27)switch(r){case Wn.Numeric:return 12;case Wn.Alphanumeric:return 11;case Wn.Byte:return 16;case Wn.Kanji:return 10;default:throw n}else if(e<41)switch(r){case Wn.Numeric:return 14;case Wn.Alphanumeric:return 13;case Wn.Byte:return 16;case Wn.Kanji:return 12;default:throw n}else throw new Error("illegal version: ".concat(e))},t}();function Ej(t){for(var e=0,r=t.length,n=[],i=0;i<r;i++){var o=t.charCodeAt(i);o<128?n[e++]=o:o<2048?(n[e++]=o>>6|192,n[e++]=o&63|128):(o&64512)===55296&&i+1<r&&(t.charCodeAt(i+1)&64512)===56320?(o=65536+((o&1023)<<10)+(t.charCodeAt(++i)&1023),n[e++]=o>>18|240,n[e++]=o>>12&63|128,n[e++]=o>>6&63|128,n[e++]=o&63|128):(n[e++]=o>>12|224,n[e++]=o>>6&63|128,n[e++]=o&63|128)}return n}s(Ej,"encode13");c(Ej,"encode");var Une=function(t){$s(e,t);function e(r,n){var i=t.call(this,Wn.Byte,r)||this;if(i.encoding=-1,typeof n=="function"){var o=n(r),a=o.encoding,f=o.bytes;i.bytes=f,i.encoding=a}else i.bytes=Ej(r),i.encoding=26;return i}return s(e,"QRByte2"),c(e,"QRByte"),e.prototype.writeTo=function(r){for(var n=this.bytes,i=0,o=n;i<o.length;i++){var a=o[i];r.put(a,8)}},e}(Zw),Vl=[],Xw=[];for(vn=0;vn<256;vn++)Xw[vn]=0,Vl[vn]=vn<8?1<<vn:Vl[vn-4]^Vl[vn-5]^Vl[vn-6]^Vl[vn-8];var vn;for(vn=0;vn<255;vn++)Xw[Vl[vn]]=vn;var vn;function Ud(t){if(t<1)throw new Error("illegal log: ".concat(t));return Xw[t]}s(Ud,"glog");c(Ud,"glog");function V2(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return Vl[t]}s(V2,"gexp");c(V2,"gexp");var y8=function(){function t(e,r){r===void 0&&(r=0);for(var n=0,i=e.length;n<i&&e[n]===0;)n++;i-=n;for(var o=[],a=0;a<i;a++)o.push(e[n+a]);for(var a=0;a<r;a++)o.push(0);this.num=o}return s(t,"Polynomial2"),c(t,"Polynomial"),t.prototype.getAt=function(e){return this.num[e]},t.prototype.getLength=function(){return this.num.length},t.prototype.multiply=function(e){for(var r=[],n=e.getLength(),i=this.getLength(),o=i+n-1,a=0;a<o;a++)r.push(0);for(var a=0;a<i;a++)for(var f=0;f<n;f++)r[a+f]^=V2(Ud(this.getAt(a))+Ud(e.getAt(f)));return new t(r)},t.prototype.mod=function(e){var r=e.getLength(),n=this.getLength();if(n-r<0)return this;for(var i=Ud(this.getAt(0))-Ud(e.getAt(0)),o=[],a=0;a<n;a++)o.push(this.getAt(a));for(var a=0;a<r;a++)o[a]^=V2(Ud(e.getAt(a))+i);return new t(o).mod(e)},t}(),jne=3,qne=3,mR=40,Hne=10,zne=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],$ne=1<<14|1<<12|1<<10|1<<4|1<<1,Cj=1<<10|1<<8|1<<5|1<<4|1<<2|1<<1|1<<0,Sj=1<<12|1<<11|1<<10|1<<9|1<<8|1<<5|1<<2|1<<0;function Ij(t){return zne[t-1]}s(Ij,"getAlignmentPattern");c(Ij,"getAlignmentPattern");function kj(t){for(var e=new y8([1]),r=0;r<t;r++)e=e.multiply(new y8([1,V2(r)]));return e}s(kj,"getErrorCorrectionPolynomial");c(kj,"getErrorCorrectionPolynomial");function au(t){for(var e=0;t!==0;)e++,t>>>=1;return e}s(au,"getBCHDigit");c(au,"getBCHDigit");var gR=au(Sj);function Tj(t){for(var e=t<<12;au(e)-gR>=0;)e^=Sj<<au(e)-gR;return t<<12|e}s(Tj,"getBCHVersion");c(Tj,"getBCHVersion");var bR=au(Cj);function Mj(t){for(var e=t<<10;au(e)-bR>=0;)e^=Cj<<au(e)-bR;return(t<<10|e)^$ne}s(Mj,"getBCHVersionInfo");c(Mj,"getBCHVersionInfo");function x8(t,e){for(var r=t.getMatrixSize(),n=0,i=0;i<r;i++)for(var o=!1,a=0,f=0;f<r;f++){var l=e?t.isDark(i,f):t.isDark(f,i);l===o?(a++,a===5?n+=jne:a>5&&n++):(o=l,a=1)}return n}s(x8,"applyMaskPenaltyRule1Internal");c(x8,"applyMaskPenaltyRule1Internal");function Rj(t){return x8(t,!0)+x8(t,!1)}s(Rj,"applyMaskPenaltyRule1");c(Rj,"applyMaskPenaltyRule1");function Bj(t){for(var e=t.getMatrixSize(),r=0,n=0;n<e-1;n++)for(var i=0;i<e-1;i++){var o=t.isDark(n,i);o===t.isDark(n,i+1)&&o===t.isDark(n+1,i)&&o===t.isDark(n+1,i+1)&&(r+=qne)}return r}s(Bj,"applyMaskPenaltyRule2");c(Bj,"applyMaskPenaltyRule2");function Fp(t,e,r,n,i){r=Math.max(r,0),n=Math.min(n,t.getMatrixSize());for(var o=r;o<n;o++){var a=i?t.isDark(e,o):t.isDark(o,e);if(a)return!1}return!0}s(Fp,"isFourWhite");c(Fp,"isFourWhite");function Dj(t){for(var e=t.getMatrixSize(),r=0,n=0;n<e;n++)for(var i=0;i<e;i++)i+6<e&&t.isDark(n,i)&&!t.isDark(n,i+1)&&t.isDark(n,i+2)&&t.isDark(n,i+3)&&t.isDark(n,i+4)&&!t.isDark(n,i+5)&&t.isDark(n,i+6)&&(Fp(t,n,i-4,i,!0)||Fp(t,n,i+7,i+11,!0))&&(r+=mR),n+6<e&&t.isDark(n,i)&&!t.isDark(n+1,i)&&t.isDark(n+2,i)&&t.isDark(n+3,i)&&t.isDark(n+4,i)&&!t.isDark(n+5,i)&&t.isDark(n+6,i)&&(Fp(t,i,n-4,n,!1)||Fp(t,i,n+7,n+11,!1))&&(r+=mR);return r}s(Dj,"applyMaskPenaltyRule3");c(Dj,"applyMaskPenaltyRule3");function Pj(t){for(var e=t.getMatrixSize(),r=0,n=0;n<e;n++)for(var i=0;i<e;i++)t.isDark(n,i)&&r++;var o=e*e,a=Math.floor(Math.abs(r*20-o*10)/o);return a*Hne}s(Pj,"applyMaskPenaltyRule4");c(Pj,"applyMaskPenaltyRule4");function Oj(t){return Rj(t)+Bj(t)+Dj(t)+Pj(t)}s(Oj,"calculateMaskPenalty");c(Oj,"calculateMaskPenalty");var Ho;(function(t){t[t.L=1]="L",t[t.M=0]="M",t[t.Q=3]="Q",t[t.H=2]="H"})(Ho||(Ho={}));var Gne=function(){function t(e,r){this.dataCount=r,this.totalCount=e}return s(t,"RSBlock2"),c(t,"RSBlock"),t.prototype.getDataCount=function(){return this.dataCount},t.prototype.getTotalCount=function(){return this.totalCount},t.getRSBlocks=function(e,r){for(var n=[],i=t.getRSBlockTable(e,r),o=i.length/3,a=0;a<o;a++)for(var f=i[a*3+0],l=i[a*3+1],u=i[a*3+2],h=0;h<f;h++)n.push(new t(l,u));return n},t.getRSBlockTable=function(e,r){switch(r){case Ho.L:return t.RS_BLOCK_TABLE[(e-1)*4+0];case Ho.M:return t.RS_BLOCK_TABLE[(e-1)*4+1];case Ho.Q:return t.RS_BLOCK_TABLE[(e-1)*4+2];case Ho.H:return t.RS_BLOCK_TABLE[(e-1)*4+3];default:throw new Error("illegal error correction level: ".concat(r))}},t.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t}(),Fj=function(){function t(){this.length=0,this.buffer=[]}return s(t,"BitBuffer2"),c(t,"BitBuffer"),t.prototype.getBuffer=function(){return this.buffer},t.prototype.getLengthInBits=function(){return this.length},t.prototype.getBit=function(e){return(this.buffer[e/8>>0]>>>7-e%8&1)===1},t.prototype.put=function(e,r){for(var n=0;n<r;n++)this.putBit((e>>>r-n-1&1)===1)},t.prototype.putBit=function(e){var r=this.buffer;this.length===r.length*8&&r.push(0),e&&(r[this.length/8>>0]|=128>>>this.length%8),this.length++},t}(),Nj=function(){function t(){}return s(t,"OutputStream2"),c(t,"OutputStream"),t.prototype.writeBytes=function(e,r,n){r===void 0&&(r=0),n===void 0&&(n=e.length);for(var i=0;i<n;i++)this.writeByte(e[i+r])},t.prototype.flush=function(){},t.prototype.close=function(){this.flush()},t}(),w8=function(t){$s(e,t);function e(){var r=t!==null&&t.apply(this,arguments)||this;return r.bytes=[],r}return s(e,"ByteArrayOutputStream2"),c(e,"ByteArrayOutputStream"),e.prototype.writeByte=function(r){this.bytes.push(r)},e.prototype.writeInt16=function(r){this.bytes.push(r,r>>>8)},e.prototype.toByteArray=function(){return this.bytes},e}(Nj);function Lj(t){if(t>=0){if(t<26)return 65+t;if(t<52)return 97+(t-26);if(t<62)return 48+(t-52);if(t===62)return 43;if(t===63)return 47}throw new Error("illegal char: ".concat(String.fromCharCode(t)))}s(Lj,"encode14");c(Lj,"encode");var Kne=function(t){$s(e,t);function e(r){var n=t.call(this)||this;return n.buffer=0,n.length=0,n.bufLength=0,n.stream=r,n}return s(e,"Base64EncodeOutputStream2"),c(e,"Base64EncodeOutputStream"),e.prototype.writeByte=function(r){for(this.buffer=this.buffer<<8|r&255,this.bufLength+=8,this.length++;this.bufLength>=6;)this.writeEncoded(this.buffer>>>this.bufLength-6),this.bufLength-=6},e.prototype.flush=function(){this.bufLength>0&&(this.writeEncoded(this.buffer<<6-this.bufLength),this.buffer=0,this.bufLength=0);var r=this.stream;if(this.length%3!=0)for(var n=3-this.length%3,i=0;i<n;i++)r.writeByte(61)},e.prototype.writeEncoded=function(r){this.stream.writeByte(Lj(r&63))},e}(Nj);function Uj(t){var e=new w8,r=new Kne(e);return r.writeBytes(t),r.close(),e.close(),e.toByteArray()}s(Uj,"encodeToBase64");c(Uj,"encodeToBase64");var Vne=function(){function t(){this.size=0,this.map={}}return s(t,"LZWTable2"),c(t,"LZWTable"),t.prototype.add=function(e){this.contains(e)||(this.map[e]=this.size++)},t.prototype.getSize=function(){return this.size},t.prototype.indexOf=function(e){return this.map[e]},t.prototype.contains=function(e){return this.map[e]>=0},t}(),Wne=function(){function t(e){this.output=e,this.bitLength=0,this.bitBuffer=0}return s(t,"BitOutputStream2"),c(t,"BitOutputStream"),t.prototype.write=function(e,r){if(e>>>r!==0)throw new Error("length overflow");for(var n=this.output;this.bitLength+r>=8;)n.writeByte(255&(e<<this.bitLength|this.bitBuffer)),r-=8-this.bitLength,e>>>=8-this.bitLength,this.bitBuffer=0,this.bitLength=0;this.bitBuffer=e<<this.bitLength|this.bitBuffer,this.bitLength=this.bitLength+r},t.prototype.flush=function(){var e=this.output;this.bitLength>0&&e.writeByte(this.bitBuffer),e.flush()},t.prototype.close=function(){this.flush(),this.output.close()},t}(),Jne=function(){function t(e,r){this.data=[],this.width=e,this.height=r;for(var n=e*r,i=0;i<n;i++)this.data[i]=0}return s(t,"GIFImage2"),c(t,"GIFImage"),t.prototype.getLZWRaster=function(e){for(var r=new Vne,n=String.fromCharCode,i=1<<e,o=(1<<e)+1,a=0;a<i;a++)r.add(n(a));r.add(n(i)),r.add(n(o));var f=e+1,l=new w8,u=new Wne(l);try{var h=this.data,g=h.length,x=String.fromCharCode;u.write(i,f);for(var _=0,E=x(h[_++]);_<g;){var T=x(h[_++]);r.contains(E+T)?E+=T:(u.write(r.indexOf(E),f),r.getSize()<4095&&(r.getSize()===1<<f&&f++,r.add(E+T)),E=T)}u.write(r.indexOf(E),f),u.write(o,f)}finally{u.close()}return l.toByteArray()},t.prototype.setPixel=function(e,r,n){var i=this,o=i.width,a=i.height;if(e<0||o<=e)throw new Error("illegal x axis: ".concat(e));if(r<0||a<=r)throw new Error("illegal y axis: ".concat(r));this.data[r*o+e]=n},t.prototype.getPixel=function(e,r){var n=this,i=n.width,o=n.height;if(e<0||i<=e)throw new Error("illegal x axis: ".concat(e));if(r<0||o<=r)throw new Error("illegal y axis: ".concat(r));return this.data[r*i+e]},t.prototype.write=function(e){var r=this,n=r.width,i=r.height;e.writeByte(71),e.writeByte(73),e.writeByte(70),e.writeByte(56),e.writeByte(55),e.writeByte(97),e.writeInt16(n),e.writeInt16(i),e.writeByte(128),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(255),e.writeByte(255),e.writeByte(255),e.writeByte(44),e.writeInt16(0),e.writeInt16(0),e.writeInt16(n),e.writeInt16(i),e.writeByte(0);var o=2,a=this.getLZWRaster(o),f=a.length;e.writeByte(o);for(var l=0;f-l>255;)e.writeByte(255),e.writeBytes(a,l,255),l+=255;var u=f-l;e.writeByte(u),e.writeBytes(a,l,u),e.writeByte(0),e.writeByte(59)},t.prototype.toDataURL=function(){var e=new w8;this.write(e);var r=Uj(e.toByteArray());e.close();for(var n=r.length,i=String.fromCharCode,o="data:image/gif;base64,",a=0;a<n;a++)o+=i(r[a]);return o},t}();function jj(t){switch(t){case 0:return function(e,r){return(e+r&1)===0};case 1:return function(e,r){return(r&1)===0};case 2:return function(e,r){return e%3===0};case 3:return function(e,r){return(e+r)%3===0};case 4:return function(e,r){return((e/3>>0)+(r/2>>0)&1)===0};case 5:return function(e,r){return(e*r&1)+e*r%3===0};case 6:return function(e,r){return((e*r&1)+e*r%3&1)===0};case 7:return function(e,r){return(e*r%3+(e+r&1)&1)===0};default:throw new Error("illegal mask: ".concat(t))}}s(jj,"getMaskFunc");c(jj,"getMaskFunc");var Yne=236,Zne=17,Xne=Object.prototype.toString;function qj(t,e){if(t<0||t>=1e6)throw new Error("byte mode encoding hint out of range");e.put(Wn.ECI,4),t<1<<7?e.put(t,8):t<1<<14?(e.put(2,2),e.put(t,14)):(e.put(6,3),e.put(t,21))}s(qj,"appendECI");c(qj,"appendECI");function _8(t,e,r,n){for(var i=new Fj,o=Gne.getRSBlocks(t,e),a=0,f=n;a<f.length;a++){var l=f[a],u=l.mode;r&&u===Wn.Byte&&qj(l.encoding,i),i.put(u,4),i.put(l.getLength(),l.getLengthInBits(t)),l.writeTo(i)}for(var h=0,g=0,x=o;g<x.length;g++){var _=x[g];h+=_.getDataCount()}return h*=8,[i,o,h]}s(_8,"prepareData");c(_8,"prepareData");function Hj(t,e){for(var r=0,n=0,i=0,o=[],a=[],f=e.length,l=t.getBuffer(),u=0;u<f;u++){var h=e[u],g=h.getDataCount(),x=h.getTotalCount()-g;n=Math.max(n,g),i=Math.max(i,x),o[u]=[];for(var _=0;_<g;_++)o[u][_]=255&l[_+r];r+=g;var E=kj(x),T=E.getLength()-1,B=new y8(o[u],T),F=B.mod(E),H=F.getLength();a[u]=[];for(var _=0;_<T;_++){var U=_+H-T;a[u][_]=U>=0?F.getAt(U):0}}t=new Fj;for(var _=0;_<n;_++)for(var u=0;u<f;u++)_<o[u].length&&t.put(o[u][_],8);for(var _=0;_<i;_++)for(var u=0;u<f;u++)_<a[u].length&&t.put(a[u][_],8);return t}s(Hj,"createBytes");c(Hj,"createBytes");function zj(t,e,r){for(t.getLengthInBits()+4<=r&&t.put(0,4);t.getLengthInBits()%8!==0;)t.putBit(!1);for(;!(t.getLengthInBits()>=r||(t.put(Yne,8),t.getLengthInBits()>=r));)t.put(Zne,8);return Hj(t,e)}s(zj,"createData");c(zj,"createData");var Qne=function(){function t(e){e===void 0&&(e={}),this.matrixSize=0,this.chunks=[],this.matrix=[];var r=e.version,n=r===void 0?0:r,i=e.encodingHint,o=i===void 0?!1:i,a=e.errorCorrectionLevel,f=a===void 0?Ho.L:a;this.setVersion(n),this.setEncodingHint(o),this.setErrorCorrectionLevel(f)}return s(t,"Encoder3"),c(t,"Encoder"),t.prototype.getMatrix=function(){return this.matrix},t.prototype.getMatrixSize=function(){return this.matrixSize},t.prototype.getVersion=function(){return this.version},t.prototype.setVersion=function(e){return this.version=Math.min(40,Math.max(0,e>>0)),this.auto=this.version===0,this},t.prototype.getErrorCorrectionLevel=function(){return this.errorCorrectionLevel},t.prototype.setErrorCorrectionLevel=function(e){switch(e){case Ho.L:case Ho.M:case Ho.Q:case Ho.H:this.errorCorrectionLevel=e}return this},t.prototype.getEncodingHint=function(){return this.encodingHint},t.prototype.setEncodingHint=function(e){return this.encodingHint=e,this},t.prototype.write=function(e){var r=this.chunks;if(e instanceof Zw)r.push(e);else{var n=Xne.call(e);if(n==="[object String]")r.push(new Une(e));else throw new Error("illegal data: ".concat(e))}return this},t.prototype.isDark=function(e,r){return this.matrix[e][r]===!0},t.prototype.setupFinderPattern=function(e,r){for(var n=this.matrix,i=this.matrixSize,o=-1;o<=7;o++)for(var a=-1;a<=7;a++)e+o<=-1||i<=e+o||r+a<=-1||i<=r+a||(0<=o&&o<=6&&(a===0||a===6)||0<=a&&a<=6&&(o===0||o===6)||2<=o&&o<=4&&2<=a&&a<=4?n[e+o][r+a]=!0:n[e+o][r+a]=!1)},t.prototype.setupAlignmentPattern=function(){for(var e=this.matrix,r=Ij(this.version),n=r.length,i=0;i<n;i++)for(var o=0;o<n;o++){var a=r[i],f=r[o];if(e[a][f]===null)for(var l=-2;l<=2;l++)for(var u=-2;u<=2;u++)l===-2||l===2||u===-2||u===2||l===0&&u===0?e[a+l][f+u]=!0:e[a+l][f+u]=!1}},t.prototype.setupTimingPattern=function(){for(var e=this.matrix,r=this.matrixSize-8,n=8;n<r;n++){var i=n%2===0;e[n][6]===null&&(e[n][6]=i),e[6][n]===null&&(e[6][n]=i)}},t.prototype.setupFormatInfo=function(e){for(var r=this.matrix,n=this.errorCorrectionLevel<<3|e,i=Mj(n),o=this.matrixSize,a=0;a<15;a++){var f=(i>>a&1)===1;a<6?r[a][8]=f:a<8?r[a+1][8]=f:r[o-15+a][8]=f,a<8?r[8][o-a-1]=f:a<9?r[8][15-a-1+1]=f:r[8][15-a-1]=f}r[o-8][8]=!0},t.prototype.setupVersionInfo=function(){if(this.version>=7)for(var e=this.matrix,r=this.matrixSize,n=Tj(this.version),i=0;i<18;i++){var o=(n>>i&1)===1;e[i/3>>0][i%3+r-8-3]=o,e[i%3+r-8-3][i/3>>0]=o}},t.prototype.setupCodewords=function(e,r){for(var n=this.matrix,i=this.matrixSize,o=e.getLengthInBits(),a=jj(r),f=0,l=i-1;l>=1;l-=2){l===6&&(l=5);for(var u=0;u<i;u++)for(var h=0;h<2;h++){var g=l-h,x=(l+1&2)===0,_=x?i-1-u:u;if(n[_][g]===null){var E=!1;f<o&&(E=e.getBit(f++));var T=a(g,_);T&&(E=!E),n[_][g]=E}}}},t.prototype.buildMatrix=function(e,r){for(var n=[],i=this.matrixSize,o=0;o<i;o++){n[o]=[];for(var a=0;a<i;a++)n[o][a]=null}this.matrix=n,this.setupFinderPattern(0,0),this.setupFinderPattern(i-7,0),this.setupFinderPattern(0,i-7),this.setupAlignmentPattern(),this.setupTimingPattern(),this.setupFormatInfo(r),this.setupVersionInfo(),this.setupCodewords(e,r)},t.prototype.make=function(){var e,r,n,i,o,a=this,f=a.chunks,l=a.errorCorrectionLevel;if(this.auto){for(var u=1;u<=40&&(e=_8(u,l,this.encodingHint,f),n=e[0],i=e[1],o=e[2],!(n.getLengthInBits()<=o));u++);var h=n.getLengthInBits();if(h>o)throw new Error("data overflow: ".concat(h," > ").concat(o));this.version=u}else r=_8(this.version,l,this.encodingHint,f),n=r[0],i=r[1],o=r[2];this.matrixSize=this.version*4+17;for(var g=[],x=zj(n,i,o),_=-1,E=Number.MAX_VALUE,T=0;T<8;T++){this.buildMatrix(x,T),g.push(this.matrix);var B=Oj(this);B<E&&(E=B,_=T)}return this.matrix=g[_],this},t.prototype.toDataURL=function(e,r){e===void 0&&(e=2),r===void 0&&(r=e*4),e=Math.max(1,e>>0),r=Math.max(0,r>>0);for(var n=this.matrixSize,i=e*n+r*2,o=r,a=i-r,f=new Jne(i,i),l=0;l<i;l++)for(var u=0;u<i;u++)if(o<=u&&u<a&&o<=l&&l<a){var h=(l-o)/e>>0,g=(u-o)/e>>0;f.setPixel(u,l,this.isDark(h,g)?0:1)}else f.setPixel(u,l,1);return f.toDataURL()},t.prototype.clear=function(){this.chunks=[]},t}();function $j(t){for(var e=t.length,r=[],n=0;n<e;n++)r.push(t.charCodeAt(n));return r}s($j,"encode15");c($j,"encode");function i2(t){if(48<=t&&t<=57)return t-48;if(65<=t&&t<=90)return t-65+10;switch(t){case 32:return 36;case 36:return 37;case 37:return 38;case 42:return 39;case 43:return 40;case 45:return 41;case 46:return 42;case 47:return 43;case 58:return 44;default:throw new Error("illegal char: ".concat(String.fromCharCode(t)))}}s(i2,"getByte");c(i2,"getByte");var eie=function(t){$s(e,t);function e(r){var n=t.call(this,Wn.Alphanumeric,r)||this;return n.bytes=$j(r),n}return s(e,"QRAlphanumeric2"),c(e,"QRAlphanumeric"),e.prototype.writeTo=function(r){for(var n=0,i=this.bytes,o=i.length;n+1<o;)r.put(i2(i[n])*45+i2(i[n+1]),11),n+=2;n<o&&r.put(i2(i[n]),6)},e}(Zw),Gj="VP1",Kj="B";function Vj({bytes:t,size:e}){let r=new Qne;r.setEncodingHint(!0);let n=Aj(t,"RFC4648",{padding:!1}),i=`${Gj}-${Kj}${n}`;return r.write(new eie(i)),r.make(),{payload:i,encodedCborld:n,version:r.getVersion(),imageDataUrl:r.toDataURL(e)}}s(Vj,"_bytesToQrCodeDataUrl");c(Vj,"_bytesToQrCodeDataUrl");async function Wj({vp:t,documentLoader:e,size:r,diagnose:n}={}){let i=await wj({jsonldDocument:t,documentLoader:e,diagnose:n}),{payload:o,imageDataUrl:a,encodedCborld:f,version:l}=Vj({bytes:i,size:r});return{payload:o,imageDataUrl:a,encodedCborld:f,rawCborldBytes:i,version:l}}s(Wj,"toQrCode");c(Wj,"toQrCode");async function Jj({text:t,documentLoader:e,diagnose:r}={}){let n=Gj+"-";if(!(t&&t.startsWith(n)))throw TypeError("Unsupported VP QR format.");let i=t.slice(n.length);if(!i.startsWith(Kj))throw TypeError("Payload must be multibase base32 (RFC4648) encoded.");let o=(0,Lne.default)(i.slice(1),"RFC4648"),a=new Uint8Array(o);return{vp:await vj({cborldBytes:a,documentLoader:e,diagnose:r})}}s(Jj,"fromQrCode");c(Jj,"fromQrCode");var tie=c(t=>({name:"Vpqr",displayName:"VP QR",description:"Allows reading and creating QR codes with Verifiable Presentations in them",methods:{vpFromQrCode:async(e,r)=>(await Jj({text:r,documentLoader:async n=>({document:await t.invoke.contextLoader(n)})}))?.vp,vpToQrCode:async(e,r)=>(await Wj({vp:r,documentLoader:async n=>({document:await t.invoke.contextLoader(n)})}))?.imageDataUrl}}),"getVpqrPlugin"),rie={modelData:{definitions:{MyVerifiableCredentials:"kjzl6cwe1jw14am5tu5hh412s19o4zm8aq3g2lpd6s4paxj2nly2lj4drp3pun2"},schemas:{AchievementVerifiableCredential:"ceramic://k3y52l7qbv1frylibw2725v8gem3hxs1onoh6pvux0szdduugczh0hddxo6qsd6o0",VerifiableCredentialsList:"ceramic://k3y52l7qbv1frxkcwfpyauky3fyl4n44izridy3blvjjzgftis40sk9w8g3remghs"},tiles:{}},credentialAlias:"MyVerifiableCredentials",ceramicEndpoint:"https://ceramic-node.welibrary.io:7007",defaultContentFamily:"SuperSkills"},nie={infuraProjectId:"",network:"mainnet"},iie=c(async(t,{ceramicIdx:e=rie,didkit:r,ethereumConfig:n=nie,debug:i}={})=>{let o=await(await k1({debug:i})).addPlugin(await TD(r)),a=await o.addPlugin(await bee(o,t,"key")),u=await(await(await a.addPlugin(_ee(a))).addPlugin(tx())).addPlugin(Aee),h=await u.addPlugin(await Xre(u,e)),g=await h.addPlugin(await ine(h,e)),x=await g.addPlugin(ex(g)),_=await x.addPlugin(hne(x,n)),T=await(await _.addPlugin(tie(_))).addPlugin(await fx());return T.addPlugin(mx(T))},"learnCardFromSeed"),Db=c(async(t,e)=>fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),"post"),Pb=c(t=>t.toString().startsWith("2"),"isSuccessful"),sie=c(async({url:t,did:e})=>{let r=t.endsWith("/")?t.slice(0,-1):t,n=e;if(!n){let i=await fetch(`${r}/did`);i.status===200&&(n=await i.text())}if(!n)throw new Error("Could not retrieve did from VC API! Please suppy a did.");return{name:"VC API",displayName:"VC API",description:"Handles issuing and signing credentials/presentations using an external VC API",id:{did:()=>n,keypair:()=>{throw new Error("Cannot get keypair when using VC API")}},methods:{getSubjectDid:()=>n,issueCredential:async(i,o,a)=>{await r1.parseAsync(o);let f=await Db(`${r}/credentials/issue`,{credential:o,options:a});if(!Pb(f.status))throw new Error(`API Error: ${f.status} ${f.statusText}`);return Fc.parseAsync(await f.json())},verifyCredential:async(i,o,a)=>{await Fc.parseAsync(o);let f=await Db(`${r}/credentials/verify`,{verifiableCredential:o,options:a});if(!Pb(f.status))throw new Error(`API Error: ${f.status} ${f.statusText}`);return EM.parseAsync(await f.json())},issuePresentation:async(i,o,a)=>{await mP.parseAsync(o);let f=await Db(`${r}/presentations/issue`,{presentation:o,options:a});if(!Pb(f.status))throw new Error(`API Error: ${f.status} ${f.statusText}`);return m2.parseAsync(await f.json())},verifyPresentation:async(i,o,a)=>{await m2.parseAsync(o);let f=await Db(`${r}/presentations/verify`,{verifiablePresentation:o,options:a});if(!Pb(f.status))throw new Error(`API Error: ${f.status} ${f.statusText}`);return EM.parseAsync(await f.json())},getTestVc:(i,o="did:example:d23dd687a7dc6787646f2eb98d0")=>({"@context":["https://www.w3.org/2018/credentials/v1"],id:"http://example.org/credentials/3731",type:["VerifiableCredential"],issuer:n,issuanceDate:"2020-08-19T21:41:50Z",credentialSubject:{id:o}}),getTestVp:async(i,o)=>{let a=o||await i.invoke.issueCredential(i.invoke.getTestVc());return{"@context":["https://www.w3.org/2018/credentials/v1"],type:["VerifiablePresentation"],holder:n,verifiableCredential:a}}}}},"getVCAPIPlugin"),oie=c(async({url:t,did:e,debug:r})=>{let n=await(await k1({debug:r})).addPlugin(await sie({url:t,did:e})),a=await(await(await n.addPlugin(ex(n))).addPlugin(tx())).addPlugin(await fx());return a.addPlugin(mx(a))},"learnCardFromApiUrl");async function Qw(t={}){if("custom"in t)return kZ({debug:t.debug});if("vcApi"in t){let{vcApi:e,did:r,debug:n}=t;return oie({url:typeof e=="string"?e:"https://bridge.learncard.com",did:e===!0?"did:key:z6MkjSz4mYqcn7dePGuktJ5PxecMkXQQHWRg8Lm6okATyFVh":r,debug:n})}if("seed"in t){let{seed:e,...r}=t;return iie(e,r)}return lee(t)}s(Qw,"initLearnCard");c(Qw,"initLearnCard");var cie=s(async t=>{let{network:e="https://network.learncard.com/trpc",seed:r,trustedBoostRegistry:n,...i}=t,o=await Qw({seed:r,...i}),a=await o.addPlugin(await Qy(o,n));return a.addPlugin(await Xy(a,e))},"initNetworkLearnCard");
|