@powerhousedao/connect 5.1.0-staging.0 → 5.1.0
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/assets/AddDriveModal-_XSf2ZlN.js +1 -0
- package/dist/assets/ClearStorageModal-CbfJTlAo.js +1 -0
- package/dist/assets/CookiesPolicyModal-DTRuUeM_.js +1 -0
- package/dist/assets/CreateDocumentModal-DUTbfZYr.js +1 -0
- package/dist/assets/{DebugSettingsModal-BLV4d9N1.js → DebugSettingsModal-CooFY-Go.js} +1 -1
- package/dist/assets/{DeleteDriveModal-CQq-0aWd.js → DeleteDriveModal-BOdu1bg5.js} +1 -1
- package/dist/assets/DeleteItemModal-D8MlQS3W.js +1 -0
- package/dist/assets/DisclaimerModal-RBBaiKyO.js +1 -0
- package/dist/assets/DriveSettingsModal-BHBZfzaY.js +1 -0
- package/dist/assets/{ExportDocumentWithErrorsModal-CPfizBgB.js → ExportDocumentWithErrorsModal-BzgGSmxg.js} +1 -1
- package/dist/assets/SettingsModal-BXDXscnR.js +1 -0
- package/dist/assets/UpgradeDriveModal-15TBzq11.js +1 -0
- package/dist/assets/{design_system-pnKFY6jM.js → design_system-DGYPpUGa.js} +1 -1
- package/dist/assets/design_system_connect-Vb8XBnLs.js +45 -0
- package/dist/assets/design_system_ui-Dnwc_Xm9.js +1 -0
- package/dist/assets/{document_drive-CVkeqJ3l.js → document_drive-BEIKnuGM.js} +2 -2
- package/dist/assets/{document_engineering-BAszqzBd.js → document_engineering-B49PhCDR.js} +1 -1
- package/dist/assets/{document_model-LXEZCDPq.js → document_model-DXcLJEjZ.js} +1 -1
- package/dist/assets/{document_model_editor-D5oPro82.js → document_model_editor-lmHQ6HZy.js} +4 -4
- package/dist/assets/{drive_explorer-C6clT2Df.js → drive_explorer-d0kn77Nx.js} +2 -2
- package/dist/assets/{graphql-editor-C6f63OmN.js → graphql-editor-CSkqTexL.js} +2 -2
- package/dist/assets/{hooks-BySGfjQp.js → hooks-D4Uas2SG.js} +1 -1
- package/dist/assets/index-Br7E7qjt.css +1 -0
- package/dist/assets/index-CK2Jk_ho.js +18 -0
- package/dist/assets/json-editor-CQKAVxat.js +1 -0
- package/dist/assets/reactor_browser-BGn_P-dn.js +25 -0
- package/dist/assets/state-schemas-36mF-wEI.js +2 -0
- package/dist/index.html +10 -10
- package/heroku/Dockerfile +1 -4
- package/lib/package.copy.json +2 -7
- package/lib/src/components/app-skeleton.js +1 -1
- package/lib/src/components/app-skeleton.js.map +1 -1
- package/lib/src/components/root.js +1 -1
- package/lib/src/components/root.js.map +1 -1
- package/lib/src/feature-flags.d.ts +3 -17
- package/lib/src/feature-flags.d.ts.map +1 -1
- package/lib/src/feature-flags.js +3 -32
- package/lib/src/feature-flags.js.map +1 -1
- package/lib/src/pages/demo/atlas-import.js +2 -2
- package/lib/src/pages/demo/atlas-import.js.map +1 -1
- package/lib/src/store/reactor.d.ts.map +1 -1
- package/lib/src/store/reactor.js +30 -33
- package/lib/src/store/reactor.js.map +1 -1
- package/lib/src/utils/reactor.d.ts +0 -7
- package/lib/src/utils/reactor.d.ts.map +1 -1
- package/lib/src/utils/reactor.js +2 -30
- package/lib/src/utils/reactor.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/nginx.conf +0 -7
- package/package.copy.json +2 -7
- package/package.json +10 -15
- package/dist/assets/AddDriveModal-CGnuKCkz.js +0 -1
- package/dist/assets/ClearStorageModal-tHn6sdVv.js +0 -1
- package/dist/assets/CookiesPolicyModal-D5y1O9wD.js +0 -1
- package/dist/assets/CreateDocumentModal-DU4C2Y6P.js +0 -1
- package/dist/assets/DeleteItemModal-JV0AvuwF.js +0 -1
- package/dist/assets/DisclaimerModal-DQZyl_zf.js +0 -1
- package/dist/assets/DriveSettingsModal-yXsOiCLy.js +0 -1
- package/dist/assets/SettingsModal-GeNqOEFN.js +0 -1
- package/dist/assets/UpgradeDriveModal-BCRmp5F4.js +0 -1
- package/dist/assets/design_system_connect-BrlN-7x3.js +0 -104
- package/dist/assets/design_system_ui-Cz-kMJRJ.js +0 -1
- package/dist/assets/index-BYfBva47.js +0 -20
- package/dist/assets/index-XUlAOLkX.css +0 -1
- package/dist/assets/json-editor-D27WLv4C.js +0 -1
- package/dist/assets/nodefs-AYr2EwM_.js +0 -1
- package/dist/assets/opfs-ahp-rEGVoJkP.js +0 -3
- package/dist/assets/postgres-CkP7QCDB.data +0 -0
- package/dist/assets/postgres-CyuUVpXN.wasm +0 -0
- package/dist/assets/reactor_browser-D4maXKS-.js +0 -25
- package/dist/assets/state-schemas-DGMOULa-.js +0 -2
- package/lib/src/utils/signer.d.ts +0 -18
- package/lib/src/utils/signer.d.ts.map +0 -1
- package/lib/src/utils/signer.js +0 -215
- package/lib/src/utils/signer.js.map +0 -1
- package/lib/test/utils/signer.test.d.ts +0 -2
- package/lib/test/utils/signer.test.d.ts.map +0 -1
- package/lib/test/utils/signer.test.js +0 -319
- package/lib/test/utils/signer.test.js.map +0 -1
- package/lib/vitest.config.d.ts +0 -3
- package/lib/vitest.config.d.ts.map +0 -1
- package/lib/vitest.config.js +0 -8
- package/lib/vitest.config.js.map +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import{l as z,d as $a,a as Ra,i as Xt,b as Oa,c as Ua,g as Na,h as Ma,e as Pa,m as Ha,u as ja,s as La,f as Fa,j as Va,r as Ka,P as za,k as qa,S as Ja,D as Wa,n as Za}from"./document_drive-BEIKnuGM.js";import{Y as Ga,Z as Ya,d as Xa,_ as Qa,g as Ce,k as Qt,w as ec,e as tc,$ as nc,a0 as rc,a1 as oc,a2 as sc,j as ic,h as ac}from"./document_model-DXcLJEjZ.js";import"./document_model_editor-lmHQ6HZy.js";import{r as Ne}from"./sentry_react-cODD7zWc.js";import{g as nr,a as en}from"./react-DQSxOgtG.js";async function be(e,t){if(!t){z.error("No actions found");return}const n=Array.isArray(t)?t:[t];if(n.length===0){z.error("No actions found");return}const r=window.ph?.reactor;if(!r)return;if(!e){z.error("No document found");return}const o=await r.queueActions(e.header.id,n);return o.status!=="SUCCESS"&&z.error(o.error),o.document}async function us(e,t){if(!t){z.error("No operations found");return}const n=Array.isArray(t)?t:[t],r=window.ph?.reactor;if(!r)return;const o=await r.queueOperations(e,n);return o.status!=="SUCCESS"&&z.error(o.error),o.document}async function fs(e,t,n,r){const o=r?.operationsLimit||50,s=r?.onProgress;z.verbose(`uploadDocumentOperations(documentId:${e}, ops: ${Object.keys(t).join(",")}, limit:${o})`);const i=Object.values(t).filter(d=>d!==void 0),c=i.reduce((d,f)=>d+f.length,0);let a=0;for(const d of i)for(let f=0;f<d.length;f+=o){z.verbose(`uploadDocumentOperations:for(i:${f}, ops:${d.length}, limit:${o}): START`);const l=d.slice(f,f+o),u=l.at(-1);if(!u)break;const b=u.action.scope;if(await n(e,l),a+=l.length,s){const h=Math.round(a/c*100);s({stage:"uploading",progress:h,totalOperations:c,uploadedOperations:a})}z.verbose(`uploadDocumentOperations:for:waitForUpdate(${e}:${b} rev ${u.index}): NEXT`)}z.verbose(`uploadDocumentOperations:for:waitForUpdate(${e}): END`)}async function cc(e,t){const n=window.ph?.reactor;if(!n)return e;const o=n.getDocumentModelModules().find(f=>f.documentModel.global.id===t.header.documentType);if(!o)return z.error(`Document model '${t.header.documentType}' not found`),e;const s=o.reducer,i=window.ph?.user,c=window.ph?.connectCrypto;if(!i||!c||!e.context?.signer)return e;const a=e.context.signer;return await Ga(e,s,t,a,c.sign)}function dc(e){const t=window.ph?.user,n=window.ph?.did;return t?{context:{signer:{app:{name:"Connect",key:n||""},user:{address:t.address,networkId:t.networkId,chainId:t.chainId},signatures:[]}},...e}:e}async function uc(e,t){if(!e){z.error("No action found");return}if(!t){z.error("No document found");return}const n=await cc(e,t);return dc(n)}async function fc(e,t){if(!e){z.error("No actions found");return}const n=Array.isArray(e)?e:[e];return(await Promise.all(n.map(o=>uc(o,t)))).filter(o=>o!==void 0)}async function lc(e){try{return await window.ph?.reactor?.getDocument(e)}catch(t){z.debug(`Failed to get document with id ${e}:`,t);return}}async function hc(e,t){const n=typeof t=="string"?await lc(t):t;if(!n){z.error(`Document with id ${JSON.stringify(t)} not found`);return}const r=await fc(e,n);if(!r){z.error("No signed actions with context found");return}return await be(n,r)}class Vr extends Error{constructor(t){super(`Document type ${t} is not supported`),this.name="UnsupportedDocumentTypeError"}}class bc extends Error{constructor(t,n,r){super(`Document ${t} is not of type ${n}. Actual type: ${r}`)}}class pc extends Error{constructor(){super("There is no selected document. Call 'setSelectedNode' to select a document.")}}function wc(e,t){return t?.length?t.some(n=>{if(n.endsWith("/*")){const r=n.slice(0,-2);return e.startsWith(r+"/")}if(n.endsWith("*")&&!n.endsWith("/*")){const r=n.slice(0,-1);return e.startsWith(r)}return n===e}):!0}function ue(){const e=window.ph?.user,t=window.ph?.allowList;return t?{isAllowedToCreateDocuments:t.includes(e?.address??""),isAllowedToEditDocuments:t.includes(e?.address??"")}:{isAllowedToCreateDocuments:!0,isAllowedToEditDocuments:!0}}async function yc(e,t,n){const r=window.ph?.reactor;if(!r)return{isDuplicate:!1};try{const o=await r.getDrive(t),s=o.state.global.nodes.find(c=>c.id===e.header.id);if(s&&s.parentFolder===(n??null))return{isDuplicate:!0,duplicateType:"id",nodeId:s.id};const i=o.state.global.nodes.find(c=>Xt(c)&&c.name===e.header.name&&c.documentType===e.header.documentType&&c.parentFolder===(n??null));return i?{isDuplicate:!0,duplicateType:"name",nodeId:i.id}:{isDuplicate:!1}}catch{return{isDuplicate:!1}}}function gc(e){switch(e.header.documentType){case"powerhouse/document-model":return"document-model";case"powerhouse/app":return"app";case"powerhouse/document-editor":return"editor";case"powerhouse/subgraph":return"subgraph";case"powerhouse/package":return"package";case"powerhouse/processor":{const r=e.state.global?.type;return r==="analytics"?"analytics-processor":r==="relational"?"relational-processor":r==="codegen"?"codegen-processor":void 0}default:return}}function mc(e,t){Qa(e).generateAsync({type:"blob"}).then(r=>{const o=window.document.createElement("a");o.style.display="none",o.href=URL.createObjectURL(r),o.download=t,window.document.body.appendChild(o),o.click(),window.document.body.removeChild(o)}).catch(z.error)}async function Dc(e,t){if(!window.ph?.reactor)return;let r="";if(e.header.documentType===Ya){const i=e.state.global.extension.replace(/^\.+|\.+$/g,"");r=i!==""?`.${i}`:""}const o=`${e.header.name||"Untitled"}${r}.phd`;if(!window.showSaveFilePicker)return mc(e,o);try{const s=await window.showSaveFilePicker({suggestedName:o});return await Xa(e,s),s}catch(s){if(!(s instanceof DOMException&&s.name==="AbortError"))throw s}}async function ls(e){const t=window.ph?.reactor;if(!t)return;const n=t.getDocumentModelModules(),r=await tc(e,s=>s,{checkHashes:!0}),o=n.find(s=>s.documentModel.global.id===r.header.documentType);if(!o)throw new Error(`Document "${r.header.documentType}" is not supported`);return o.utils.loadFromInput(e)}async function hs(e,t,n,r,o,s,i){const c=window.ph?.reactor;if(!c)return;const{isAllowedToCreateDocuments:a}=ue();if(!a)throw new Error("User is not allowed to create documents");const d=await c.getDrive(e),f=s??Ce(),u=c.getDocumentModelModules().find(g=>g.documentModel.global.id===n);if(!u)throw new Error(`Document model module for type ${n} not found`);const b=u.utils.createDocument({...o?.state});b.header=Qt(f,n),b.header.name=t;const h=i?{preferredEditor:i}:void 0;await c.addDocument(b,h);const p=Ra({id:f,name:t,documentType:n,parentFolder:r??null}),w=(await be(d,p)).state.global.nodes.find(g=>g.id===f);if(!w||!Xt(w))throw new Error("There was an error adding document");return w}async function Ec(e,t,n,r){z.verbose(`addFile(drive: ${t}, name: ${n}, folder: ${r})`);const o=window.ph?.reactor;if(!o)return;const{isAllowedToCreateDocuments:s}=ue();if(!s)throw new Error("User is not allowed to create files");const i=await ls(e);if(!i)throw new Error("No document loaded");if(!o.getDocumentModelModules().find(b=>b.documentModel.global.id===i.header.documentType))throw new Error(`Document model module for type ${i.header.documentType} not found`);let a=!1;try{await o.getDocument(i.header.id),a=!0}catch{}const d=a?Ce():i.header.id,f=Qt(d,i.header.documentType);f.lastModifiedAtUtcIso=i.header.createdAtUtcIso,f.meta=i.header.meta,f.name=n||i.header.name;const l={...i,state:i.initialState,operations:Object.keys(i.operations).reduce((b,h)=>(b[h]=[],b),{})};if(!await hs(t,n||i.header.name,i.header.documentType,r,l,d,i.header.meta?.preferredEditor))throw new Error("There was an error adding file");fs(d,i.operations,us).catch(b=>{throw b})}async function xc(e,t,n,r,o,s,i){z.verbose(`addFileWithProgress(drive: ${t}, name: ${n}, folder: ${r})`);const c=window.ph?.reactor;if(!c)return;const{isAllowedToCreateDocuments:a}=ue();if(!a)throw new Error("User is not allowed to create files");try{o?.({stage:"loading",progress:0});const d=await ls(e);if(!d)throw new Error("No document loaded");const f=await yc(d,t,r);if(f.isDuplicate&&!i){o?.({stage:"conflict",progress:0,duplicateType:f.duplicateType});return}f.isDuplicate&&i==="replace"&&f.nodeId&&await Sc(t,f.nodeId);const l=gc(d);if(o?.(l?{stage:"loading",progress:10,documentType:l}:{stage:"loading",progress:10}),!wc(d.header.documentType,s))throw o?.({stage:"unsupported-document-type",progress:100,error:`Document type ${d.header.documentType} is not supported`}),new Vr(d.header.documentType);if(!c.getDocumentModelModules().find(g=>g.documentModel.global.id===d.header.documentType))throw new Error(`Document model module for type ${d.header.documentType} not found`);o?.({stage:"initializing",progress:10});let b=!1;try{await c.getDocument(d.header.id),b=!0}catch{}const h=b?Ce():d.header.id,p=Qt(h,d.header.documentType);p.lastModifiedAtUtcIso=d.header.createdAtUtcIso,p.meta=d.header.meta,p.name=n||d.header.name;const E={...d,header:p,state:d.initialState,operations:Object.keys(d.operations).reduce((g,y)=>(g[y]=[],g),{})},w=await hs(t,n||d.header.name,d.header.documentType,r,E,h,d.header.meta?.preferredEditor);if(!w)throw new Error("There was an error adding file");return o?.({stage:"initializing",progress:20}),await fs(h,d.operations,us,{onProgress:g=>{if(g.totalOperations&&g.uploadedOperations!==void 0){const y=g.totalOperations>0?g.uploadedOperations/g.totalOperations:0,S=20+Math.round(y*80);o?.({stage:"uploading",progress:S,totalOperations:g.totalOperations,uploadedOperations:g.uploadedOperations})}}}),o?.({stage:"complete",progress:100}),w}catch(d){if(!(d instanceof Vr)){const f=d instanceof Error?d.message:"Unknown error occurred";o?.({stage:"failed",progress:100,error:f})}throw d}}async function vc(e,t,n){const r=window.ph?.reactor;if(!r)return;const{isAllowedToCreateDocuments:o}=ue();if(!o)throw new Error("User is not allowed to create folders");const s=Ce(),i=await r.getDrive(e),a=(await be(i,Oa({id:s,name:t,parentFolder:n}))).state.global.nodes.find(d=>d.id===s);if(!a||!Ua(a))throw new Error("There was an error adding folder");return a}async function Sc(e,t){const n=window.ph?.reactor;if(!n)return;const{isAllowedToCreateDocuments:r}=ue();if(!r)throw new Error("User is not allowed to delete documents");const o=await n.getDrive(e);await be(o,$a({id:t}))}async function Ac(e,t,n){const r=window.ph?.reactor;if(!r)return;const{isAllowedToCreateDocuments:o}=ue();if(!o)throw new Error("User is not allowed to rename documents");const s=await r.getDrive(e),c=(await be(s,ja({id:t,name:n}))).state.global.nodes.find(a=>a.id===t);if(!c)throw new Error("There was an error renaming node");return c}async function kc(e,t,n){const r=window.ph?.reactor;if(!r)return;const{isAllowedToCreateDocuments:o}=ue();if(!o)throw new Error("User is not allowed to move documents");const s=await r.getDrive(e);return await be(s,Ha({srcFolder:t.id,targetParentFolder:n?.id}))}function Tc(e,t,n=Ce()){const r=e.getDocumentModelModules().find(o=>o.documentModel.global.id===t.header.documentType);if(!r)throw new Error(`Document model module for type ${t.header.documentType} not found`);return ec(t.initialState,t.operations,r.reducer,void 0,Qt(n,t.header.documentType))}async function Kr(e,t,n){const r=window.ph?.reactor;if(!r)return;const{isAllowedToCreateDocuments:o}=ue();if(!o)throw new Error("User is not allowed to copy documents");const s=await r.getDrive(e),i=Na({srcId:t.id,targetParentFolder:n?.id,targetName:t.name},()=>Ce(),s.state.global.nodes),c=new Map;for(const f of i){const l=s.state.global.nodes.find(u=>u.id===f.srcId);if(l){const u=Ma({nodes:s.state.global.nodes,srcName:f.targetName||l.name,targetParentFolder:f.targetParentFolder||null});c.set(f.targetId,u)}}const a=i.filter(f=>{const l=s.state.global.nodes.find(u=>u.id===f.srcId);return l!==void 0&&Xt(l)});for(const f of a)try{const l=await r.getDocument(f.srcId),u=Tc(r,l,f.targetId),b=c.get(f.targetId);b&&(u.header.name=b),await r.addDocument(u)}catch(l){z.error(`Error copying document ${f.srcId}: ${String(l)}`)}const d=i.map(f=>Pa(f));return await be(s,d)}async function K1(e,t){const n=window.ph?.reactor;if(!n)return;const{isAllowedToCreateDocuments:r}=ue();if(!r)throw new Error("User is not allowed to create drives");const o=Ce();return await n.addDrive({global:e.global,local:e.local,id:o},t)}async function z1(e,t){const n=window.ph?.reactor;return n?await n.addRemoteDrive(e,t):void 0}async function q1(e){const t=window.ph?.reactor;if(!t)return;const{isAllowedToCreateDocuments:n}=ue();if(!n)throw new Error("User is not allowed to delete drives");await t.deleteDrive(e)}async function J1(e,t){const n=window.ph?.reactor;if(!n)return;const{isAllowedToCreateDocuments:r}=ue();if(!r)throw new Error("User is not allowed to rename drives");const o=await n.getDrive(e);return await be(o,Va({name:t}))}async function W1(e,t){const n=window.ph?.reactor;if(!n)return;const{isAllowedToCreateDocuments:r}=ue();if(!r)throw new Error("User is not allowed to change drive availability");const o=await n.getDrive(e);return await be(o,Fa({availableOffline:t}))}async function Z1(e,t){const n=window.ph?.reactor;if(!n)return;const{isAllowedToCreateDocuments:r}=ue();if(!r)throw new Error("User is not allowed to change drive availability");const o=await n.getDrive(e);return await be(o,La({type:t}))}async function G1(e,t){const n=window.ph?.reactor;if(!n)return;const r=await n.getDrive(e);if((await be(r,Ka({triggerId:t}))).state.local.triggers.find(i=>i.id===t))throw new Error(`There was an error removing trigger ${t}`)}async function Y1(e,t,n){const r=window.ph?.reactor;if(!r)return;const o=Ce(),s={driveId:e,listenerId:o,block:!1,filter:{branch:n.pullFilter?.branch??[],documentId:n.pullFilter?.documentId??[],documentType:n.pullFilter?.documentType??[],scope:n.pullFilter?.scope??[]},system:!1,label:`Pullresponder #${o}`,callInfo:{data:"",name:"PullResponder",transmitterType:"PullResponder"}},i=r.listeners;s.transmitter=new za(s,i);try{await i.setListener(e,s)}catch(c){throw new Error(`Listener couldn't be registered: ${c}`)}return{driveId:e,filter:s.filter,data:{interval:`${n.pullInterval}`||"1000",listenerId:o,url:t},id:o,type:"PullResponder"}}async function X1(e,t){const n=window.ph?.reactor;if(!n)return;const r=await n.getDrive(e);if(!(await be(r,qa({trigger:t}))).state.local.triggers.find(i=>i.id===i.id))throw new Error(`There was an error adding the trigger ${t.id}`)}const Ic="powerhouse/generic-drive-explorer",Q1="powerhouse/common";function _(e){const t=`ph:set${nc(e)}`,n=`ph:${e}Updated`;function r(f){const l=new CustomEvent(t,{detail:{[e]:f}});window.dispatchEvent(l)}function o(){const f=new CustomEvent(n);window.dispatchEvent(f)}function s(f){const l=f.detail[e];if(!window.ph)throw new Error("ph global store is not defined");window.ph[e]=l,o()}function i(){window.addEventListener(t,s)}function c(f){return window.addEventListener(n,f),()=>{window.removeEventListener(n,f)}}function a(){if(!window.ph)throw new Error("ph global store is not defined");return window.ph[e]}function d(){return Ne.useSyncExternalStore(c,a)}return{useValue:d,setValue:r,addEventHandler:i}}const bs=_("isExternalControlsEnabled"),Cc=bs.setValue,_c=bs.addEventHandler,rr=_("isDragAndDropEnabled"),Bc=rr.setValue,ew=rr.useValue,$c=rr.addEventHandler,or=_("allowedDocumentTypes"),Rc=or.setValue;function Oc(){return or.useValue()}const Uc=or.addEventHandler,Nc={allowedDocumentTypes:Rc,isDragAndDropEnabled:Bc},Mc={isExternalControlsEnabled:Cc},sr=_("vetraPackages"),ir=sr.useValue,Pc=sr.addEventHandler;function tw(e){sr.setValue(e);const t=e?.flatMap(n=>n.modules.documentModelModules).filter(n=>n!==void 0);window.ph?.reactor?.setDocumentModelModules(t)}function ps(){return ir()?.flatMap(t=>t.modules.documentModelModules||[])}function Hc(e){return ps()?.find(n=>n.id===e)}function zr(e){return e.toSorted((t,n)=>t.name.localeCompare(n.name))}function nw(e){return e?e.kind.toUpperCase()==="FILE":!1}function ws(e){return e?e.kind.toUpperCase()==="FOLDER":!1}function ar(e){function t(n){hc(n,e).catch(z.error)}return[e,t]}function cr(e){return globalThis.Buffer!=null?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function ys(e=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?cr(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function gs(e,t){t||(t=e.reduce((o,s)=>o+s.length,0));const n=ys(t);let r=0;for(const o of e)n.set(o,r),r+=o.length;return cr(n)}const jc=Object.freeze(Object.defineProperty({__proto__:null,concat:gs},Symbol.toStringTag,{value:"Module"}));function Lc(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(n[i]!==255)throw new TypeError(s+" is ambiguous");n[i]=o}var c=e.length,a=e.charAt(0),d=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var p=0,E=0,w=0,g=h.length;w!==g&&h[w]===0;)w++,p++;for(var y=(g-w)*f+1>>>0,S=new Uint8Array(y);w!==g;){for(var D=h[w],m=0,k=y-1;(D!==0||m<E)&&k!==-1;k--,m++)D+=256*S[k]>>>0,S[k]=D%c>>>0,D=D/c>>>0;if(D!==0)throw new Error("Non-zero carry");E=m,w++}for(var A=y-E;A!==y&&S[A]===0;)A++;for(var T=a.repeat(p);A<y;++A)T+=e.charAt(S[A]);return T}function u(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var p=0;if(h[p]!==" "){for(var E=0,w=0;h[p]===a;)E++,p++;for(var g=(h.length-p)*d+1>>>0,y=new Uint8Array(g);h[p];){var S=n[h.charCodeAt(p)];if(S===255)return;for(var D=0,m=g-1;(S!==0||D<w)&&m!==-1;m--,D++)S+=c*y[m]>>>0,y[m]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");w=D,p++}if(h[p]!==" "){for(var k=g-w;k!==g&&y[k]===0;)k++;for(var A=new Uint8Array(E+(g-k)),T=E;k!==g;)A[T++]=y[k++];return A}}}function b(h){var p=u(h);if(p)return p;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:u,decode:b}}var Fc=Lc,Vc=Fc;const ms=new Uint8Array(0),Kc=e=>e.reduce((t,n)=>t+n.toString(16).padStart(2,"0"),""),zc=e=>{const t=e.match(/../g);return t?new Uint8Array(t.map(n=>parseInt(n,16))):ms},Ds=(e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0},Ve=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")},qc=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),Es=e=>new TextEncoder().encode(e),xs=e=>new TextDecoder().decode(e),Jc=Object.freeze(Object.defineProperty({__proto__:null,coerce:Ve,empty:ms,equals:Ds,fromHex:zc,fromString:Es,isBinary:qc,toHex:Kc,toString:xs},Symbol.toStringTag,{value:"Module"}));let Wc=class{constructor(t,n,r){this.name=t,this.prefix=n,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Zc=class{constructor(t,n,r){if(this.name=t,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=r}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return vs(this,t)}},Gc=class{constructor(t){this.decoders=t}or(t){return vs(this,t)}decode(t){const n=t[0],r=this.decoders[n];if(r)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const vs=(e,t)=>new Gc({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});let Yc=class{constructor(t,n,r,o){this.name=t,this.prefix=n,this.baseEncode=r,this.baseDecode=o,this.encoder=new Wc(t,n,r),this.decoder=new Zc(t,n,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};const tn=({name:e,prefix:t,encode:n,decode:r})=>new Yc(e,t,n,r),Dt=({prefix:e,name:t,alphabet:n})=>{const{encode:r,decode:o}=Vc(n,t);return tn({prefix:e,name:t,encode:r,decode:s=>Ve(o(s))})},Xc=(e,t,n,r)=>{const o={};for(let f=0;f<t.length;++f)o[t[f]]=f;let s=e.length;for(;e[s-1]==="=";)--s;const i=new Uint8Array(s*n/8|0);let c=0,a=0,d=0;for(let f=0;f<s;++f){const l=o[e[f]];if(l===void 0)throw new SyntaxError(`Non-${r} character`);a=a<<n|l,c+=n,c>=8&&(c-=8,i[d++]=255&a>>c)}if(c>=n||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return i},Qc=(e,t,n)=>{const r=t[t.length-1]==="=",o=(1<<n)-1;let s="",i=0,c=0;for(let a=0;a<e.length;++a)for(c=c<<8|e[a],i+=8;i>n;)i-=n,s+=t[o&c>>i];if(i&&(s+=t[o&c<<n-i]),r)for(;s.length*n&7;)s+="=";return s},ee=({name:e,prefix:t,bitsPerChar:n,alphabet:r})=>tn({prefix:t,name:e,encode(o){return Qc(o,r,n)},decode(o){return Xc(o,r,n,e)}}),ed=tn({prefix:"\0",name:"identity",encode:e=>xs(e),decode:e=>Es(e)}),td=Object.freeze(Object.defineProperty({__proto__:null,identity:ed},Symbol.toStringTag,{value:"Module"})),nd=ee({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),rd=Object.freeze(Object.defineProperty({__proto__:null,base2:nd},Symbol.toStringTag,{value:"Module"})),od=ee({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),sd=Object.freeze(Object.defineProperty({__proto__:null,base8:od},Symbol.toStringTag,{value:"Module"})),id=Dt({prefix:"9",name:"base10",alphabet:"0123456789"}),ad=Object.freeze(Object.defineProperty({__proto__:null,base10:id},Symbol.toStringTag,{value:"Module"})),cd=ee({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),dd=ee({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),ud=Object.freeze(Object.defineProperty({__proto__:null,base16:cd,base16upper:dd},Symbol.toStringTag,{value:"Module"})),it=ee({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),fd=ee({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ld=ee({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),hd=ee({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bd=ee({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),pd=ee({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),wd=ee({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),yd=ee({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),gd=ee({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),md=Object.freeze(Object.defineProperty({__proto__:null,base32:it,base32hex:bd,base32hexpad:wd,base32hexpadupper:yd,base32hexupper:pd,base32pad:ld,base32padupper:hd,base32upper:fd,base32z:gd},Symbol.toStringTag,{value:"Module"})),Dd=Dt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ed=Dt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),xd=Object.freeze(Object.defineProperty({__proto__:null,base36:Dd,base36upper:Ed},Symbol.toStringTag,{value:"Module"})),me=Dt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),vd=Dt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Sd=Object.freeze(Object.defineProperty({__proto__:null,base58btc:me,base58flickr:vd},Symbol.toStringTag,{value:"Module"})),Ad=ee({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),kd=ee({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Td=ee({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Id=ee({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Cd=Object.freeze(Object.defineProperty({__proto__:null,base64:Ad,base64pad:kd,base64url:Td,base64urlpad:Id},Symbol.toStringTag,{value:"Module"})),Ss=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),_d=Ss.reduce((e,t,n)=>(e[n]=t,e),[]),Bd=Ss.reduce((e,t,n)=>(e[t.codePointAt(0)]=n,e),[]);function $d(e){return e.reduce((t,n)=>(t+=_d[n],t),"")}function Rd(e){const t=[];for(const n of e){const r=Bd[n.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${n}`);t.push(r)}return new Uint8Array(t)}const Od=tn({prefix:"🚀",name:"base256emoji",encode:$d,decode:Rd}),Ud=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:Od},Symbol.toStringTag,{value:"Module"}));var Nd=As,qr=128,Md=-128,Pd=Math.pow(2,31);function As(e,t,n){t=t||[],n=n||0;for(var r=n;e>=Pd;)t[n++]=e&255|qr,e/=128;for(;e&Md;)t[n++]=e&255|qr,e>>>=7;return t[n]=e|0,As.bytes=n-r+1,t}var Hd=Kn,jd=128,Jr=127;function Kn(e,r){var n=0,r=r||0,o=0,s=r,i,c=e.length;do{if(s>=c)throw Kn.bytes=0,new RangeError("Could not decode varint");i=e[s++],n+=o<28?(i&Jr)<<o:(i&Jr)*Math.pow(2,o),o+=7}while(i>=jd);return Kn.bytes=s-r,n}var Ld=Math.pow(2,7),Fd=Math.pow(2,14),Vd=Math.pow(2,21),Kd=Math.pow(2,28),zd=Math.pow(2,35),qd=Math.pow(2,42),Jd=Math.pow(2,49),Wd=Math.pow(2,56),Zd=Math.pow(2,63),Gd=function(e){return e<Ld?1:e<Fd?2:e<Vd?3:e<Kd?4:e<zd?5:e<qd?6:e<Jd?7:e<Wd?8:e<Zd?9:10},Yd={encode:Nd,decode:Hd,encodingLength:Gd},Kt=Yd;const at=(e,t=0)=>[Kt.decode(e,t),Kt.decode.bytes],ct=(e,t,n=0)=>(Kt.encode(e,t,n),t),dt=e=>Kt.encodingLength(e),Xd=Object.freeze(Object.defineProperty({__proto__:null,decode:at,encodeTo:ct,encodingLength:dt},Symbol.toStringTag,{value:"Module"})),ut=(e,t)=>{const n=t.byteLength,r=dt(e),o=r+dt(n),s=new Uint8Array(o+n);return ct(e,s,0),ct(n,s,r),s.set(t,o),new nn(e,n,t,s)},ks=e=>{const t=Ve(e),[n,r]=at(t),[o,s]=at(t.subarray(r)),i=t.subarray(r+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new nn(n,o,i,t)},Ts=(e,t)=>e===t?!0:e.code===t.code&&e.size===t.size&&Ds(e.bytes,t.bytes);class nn{constructor(t,n,r,o){this.code=t,this.size=n,this.digest=r,this.bytes=o}}const Qd=Object.freeze(Object.defineProperty({__proto__:null,Digest:nn,create:ut,decode:ks,equals:Ts},Symbol.toStringTag,{value:"Module"})),dr=({name:e,code:t,encode:n})=>new Is(e,t,n);class Is{constructor(t,n,r){this.name=t,this.code=n,this.encode=r}digest(t){if(t instanceof Uint8Array){const n=this.encode(t);return n instanceof Uint8Array?ut(this.code,n):n.then(r=>ut(this.code,r))}else throw Error("Unknown type, must be binary type")}}const eu=Object.freeze(Object.defineProperty({__proto__:null,Hasher:Is,from:dr},Symbol.toStringTag,{value:"Module"})),Cs=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),tu=dr({name:"sha2-256",code:18,encode:Cs("SHA-256")}),nu=dr({name:"sha2-512",code:19,encode:Cs("SHA-512")}),ru=Object.freeze(Object.defineProperty({__proto__:null,sha256:tu,sha512:nu},Symbol.toStringTag,{value:"Module"})),_s=0,ou="identity",Bs=Ve,su=e=>ut(_s,Bs(e)),iu={code:_s,name:ou,encode:Bs,digest:su},au=Object.freeze(Object.defineProperty({__proto__:null,identity:iu},Symbol.toStringTag,{value:"Module"})),cu="raw",du=85,uu=e=>Ve(e),fu=e=>Ve(e),lu=Object.freeze(Object.defineProperty({__proto__:null,code:du,decode:fu,encode:uu,name:cu},Symbol.toStringTag,{value:"Module"})),hu=new TextEncoder,bu=new TextDecoder,pu="json",wu=512,yu=e=>hu.encode(JSON.stringify(e)),gu=e=>JSON.parse(bu.decode(e)),mu=Object.freeze(Object.defineProperty({__proto__:null,code:wu,decode:gu,encode:yu,name:pu},Symbol.toStringTag,{value:"Module"}));class se{constructor(t,n,r,o){this.code=n,this.version=t,this.multihash=r,this.bytes=o,this.byteOffset=o.byteOffset,this.byteLength=o.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:_t,byteLength:_t,code:Ct,version:Ct,multihash:Ct,bytes:Ct,_baseCache:_t,asCID:_t})}toV0(){switch(this.version){case 0:return this;default:{const{code:t,multihash:n}=this;if(t!==tt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(n.code!==vu)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return se.createV0(n)}}}toV1(){switch(this.version){case 0:{const{code:t,digest:n}=this.multihash,r=ut(t,n);return se.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(t){return t&&this.code===t.code&&this.version===t.version&&Ts(this.multihash,t.multihash)}toString(t){const{bytes:n,version:r,_baseCache:o}=this;switch(r){case 0:return Eu(n,o,t||me.encoder);default:return xu(n,o,t||it.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(t){return Au(/^0\.0/,ku),!!(t&&(t[Zr]||t.asCID===t))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(t){if(t instanceof se)return t;if(t!=null&&t.asCID===t){const{version:n,code:r,multihash:o,bytes:s}=t;return new se(n,r,o,s||Wr(n,r,o.bytes))}else if(t!=null&&t[Zr]===!0){const{version:n,multihash:r,code:o}=t,s=ks(r);return se.create(n,o,s)}else return null}static create(t,n,r){if(typeof n!="number")throw new Error("String codecs are no longer supported");switch(t){case 0:{if(n!==tt)throw new Error(`Version 0 CID must use dag-pb (code: ${tt}) block encoding`);return new se(t,n,r,r.bytes)}case 1:{const o=Wr(t,n,r.bytes);return new se(t,n,r,o)}default:throw new Error("Invalid version")}}static createV0(t){return se.create(0,tt,t)}static createV1(t,n){return se.create(1,t,n)}static decode(t){const[n,r]=se.decodeFirst(t);if(r.length)throw new Error("Incorrect length");return n}static decodeFirst(t){const n=se.inspectBytes(t),r=n.size-n.multihashSize,o=Ve(t.subarray(r,r+n.multihashSize));if(o.byteLength!==n.multihashSize)throw new Error("Incorrect length");const s=o.subarray(n.multihashSize-n.digestSize),i=new nn(n.multihashCode,n.digestSize,s,o);return[n.version===0?se.createV0(i):se.createV1(n.codec,i),t.subarray(n.size)]}static inspectBytes(t){let n=0;const r=()=>{const[l,u]=at(t.subarray(n));return n+=u,l};let o=r(),s=tt;if(o===18?(o=0,n=0):o===1&&(s=r()),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);const i=n,c=r(),a=r(),d=n+a,f=d-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:f,size:d}}static parse(t,n){const[r,o]=Du(t,n),s=se.decode(o);return s._baseCache.set(r,t),s}}const Du=(e,t)=>{switch(e[0]){case"Q":{const n=t||me;return[me.prefix,n.decode(`${me.prefix}${e}`)]}case me.prefix:{const n=t||me;return[me.prefix,n.decode(e)]}case it.prefix:{const n=t||it;return[it.prefix,n.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}},Eu=(e,t,n)=>{const{prefix:r}=n;if(r!==me.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);const o=t.get(r);if(o==null){const s=n.encode(e).slice(1);return t.set(r,s),s}else return o},xu=(e,t,n)=>{const{prefix:r}=n,o=t.get(r);if(o==null){const s=n.encode(e);return t.set(r,s),s}else return o},tt=112,vu=18,Wr=(e,t,n)=>{const r=dt(e),o=r+dt(t),s=new Uint8Array(o+n.byteLength);return ct(e,s,0),ct(t,s,r),s.set(n,o),s},Zr=Symbol.for("@ipld/js-cid/CID"),Ct={writable:!1,configurable:!1,enumerable:!0},_t={writable:!1,enumerable:!1,configurable:!1},Su="0.0.0-dev",Au=(e,t)=>{if(e.test(Su))console.warn(t);else throw new Error(t)},ku=`CID.isCID(v) is deprecated and will be removed in the next major release.
|
|
2
|
+
Following code pattern:
|
|
3
|
+
|
|
4
|
+
if (CID.isCID(value)) {
|
|
5
|
+
doSomethingWithCID(value)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
Is replaced with:
|
|
9
|
+
|
|
10
|
+
const cid = CID.asCID(value)
|
|
11
|
+
if (cid) {
|
|
12
|
+
// Make sure to use cid instead of value
|
|
13
|
+
doSomethingWithCID(cid)
|
|
14
|
+
}
|
|
15
|
+
`,zn={...td,...rd,...sd,...ad,...ud,...md,...xd,...Sd,...Cd,...Ud},Tu={...ru,...au},Iu={raw:lu,json:mu},Cu=Object.freeze(Object.defineProperty({__proto__:null,CID:se,bases:zn,bytes:Jc,codecs:Iu,digest:Qd,hasher:eu,hashes:Tu,varint:Xd},Symbol.toStringTag,{value:"Module"}));function $s(e,t,n,r){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:n},decoder:{decode:r}}}const Gr=$s("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),ln=$s("ascii","a",e=>{let t="a";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t},e=>{e=e.substring(1);const t=ys(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}),Rs={utf8:Gr,"utf-8":Gr,hex:zn.base16,latin1:ln,ascii:ln,binary:ln,...zn};function rn(e,t="utf8"){const n=Rs[t];if(!n)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?cr(globalThis.Buffer.from(e,"utf-8")):n.decoder.decode(`${n.prefix}${e}`)}const _u=Object.freeze(Object.defineProperty({__proto__:null,fromString:rn},Symbol.toStringTag,{value:"Module"}));function ur(e,t="utf8"){const n=Rs[t];if(!n)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):n.encoder.encode(e).substring(1)}const Bu=Object.freeze(Object.defineProperty({__proto__:null,toString:ur},Symbol.toStringTag,{value:"Module"})),Ke=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Et(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ft(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ie(e,...t){if(!Et(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Os(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");ft(e.outputLen),ft(e.blockLen)}function Ye(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Us(e,t){Ie(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function $u(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ee(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function hn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ye(e,t){return e<<32-t|e>>>t}function Bt(e,t){return e<<t|e>>>32-t>>>0}const Ru=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Ou(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Uu(e){for(let t=0;t<e.length;t++)e[t]=Ou(e[t]);return e}const Yr=Ru?e=>e:Uu,Ns=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Nu=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function je(e){if(Ie(e),Ns)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Nu[e[n]];return t}const Se={_0:48,_9:57,A:65,F:70,a:97,f:102};function Xr(e){if(e>=Se._0&&e<=Se._9)return e-Se._0;if(e>=Se.A&&e<=Se.F)return e-(Se.A-10);if(e>=Se.a&&e<=Se.f)return e-(Se.a-10)}function lt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Ns)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let o=0,s=0;o<n;o++,s+=2){const i=Xr(e.charCodeAt(s)),c=Xr(e.charCodeAt(s+1));if(i===void 0||c===void 0){const a=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}r[o]=i*16+c}return r}function Mu(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function on(e){return typeof e=="string"&&(e=Mu(e)),Ie(e),e}function De(...e){let t=0;for(let r=0;r<e.length;r++){const o=e[r];Ie(o),t+=o.length}const n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const s=e[r];n.set(s,o),o+=s.length}return n}class fr{}function xt(e){const t=r=>e().update(on(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function lr(e=32){if(Ke&&typeof Ke.getRandomValues=="function")return Ke.getRandomValues(new Uint8Array(e));if(Ke&&typeof Ke.randomBytes=="function")return Uint8Array.from(Ke.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function Pu(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),c=Number(n&s),a=r?4:0,d=r?0:4;e.setUint32(t+a,i,r),e.setUint32(t+d,c,r)}function Hu(e,t,n){return e&t^~e&n}function ju(e,t,n){return e&t^e&n^t&n}class hr extends fr{constructor(t,n,r,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(t),this.view=hn(this.buffer)}update(t){Ye(this),t=on(t),Ie(t);const{view:n,buffer:r,blockLen:o}=this,s=t.length;for(let i=0;i<s;){const c=Math.min(o-this.pos,s-i);if(c===o){const a=hn(t);for(;o<=s-i;i+=o)this.process(a,i);continue}r.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ye(this),Us(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:s}=this;let{pos:i}=this;n[i++]=128,Ee(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(r,0),i=0);for(let l=i;l<o;l++)n[l]=0;Pu(r,o-8,BigInt(this.length*8),s),this.process(r,0);const c=hn(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=a/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<d;l++)c.setUint32(4*l,f[l],s)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:s,destroyed:i,pos:c}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=c,o%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const _e=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),re=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),oe=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),$t=BigInt(2**32-1),Qr=BigInt(32);function Lu(e,t=!1){return t?{h:Number(e&$t),l:Number(e>>Qr&$t)}:{h:Number(e>>Qr&$t)|0,l:Number(e&$t)|0}}function Ms(e,t=!1){const n=e.length;let r=new Uint32Array(n),o=new Uint32Array(n);for(let s=0;s<n;s++){const{h:i,l:c}=Lu(e[s],t);[r[s],o[s]]=[i,c]}return[r,o]}const eo=(e,t,n)=>e>>>n,to=(e,t,n)=>e<<32-n|t>>>n,ze=(e,t,n)=>e>>>n|t<<32-n,qe=(e,t,n)=>e<<32-n|t>>>n,Rt=(e,t,n)=>e<<64-n|t>>>n-32,Ot=(e,t,n)=>e>>>n-32|t<<64-n,Fu=(e,t,n)=>e<<n|t>>>32-n,Vu=(e,t,n)=>t<<n|e>>>32-n,Ku=(e,t,n)=>t<<n-32|e>>>64-n,zu=(e,t,n)=>e<<n-32|t>>>64-n;function Ae(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const qu=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Ju=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Wu=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Zu=(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,Gu=(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0),Yu=(e,t,n,r,o,s)=>t+n+r+o+s+(e/2**32|0)|0,Xu=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Be=new Uint32Array(64);class Qu extends hr{constructor(t=32){super(64,t,8,!1),this.A=_e[0]|0,this.B=_e[1]|0,this.C=_e[2]|0,this.D=_e[3]|0,this.E=_e[4]|0,this.F=_e[5]|0,this.G=_e[6]|0,this.H=_e[7]|0}get(){const{A:t,B:n,C:r,D:o,E:s,F:i,G:c,H:a}=this;return[t,n,r,o,s,i,c,a]}set(t,n,r,o,s,i,c,a){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,n){for(let l=0;l<16;l++,n+=4)Be[l]=t.getUint32(n,!1);for(let l=16;l<64;l++){const u=Be[l-15],b=Be[l-2],h=ye(u,7)^ye(u,18)^u>>>3,p=ye(b,17)^ye(b,19)^b>>>10;Be[l]=p+Be[l-7]+h+Be[l-16]|0}let{A:r,B:o,C:s,D:i,E:c,F:a,G:d,H:f}=this;for(let l=0;l<64;l++){const u=ye(c,6)^ye(c,11)^ye(c,25),b=f+u+Hu(c,a,d)+Xu[l]+Be[l]|0,p=(ye(r,2)^ye(r,13)^ye(r,22))+ju(r,o,s)|0;f=d,d=a,a=c,c=i+b|0,i=s,s=o,o=r,r=b+p|0}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(r,o,s,i,c,a,d,f)}roundClean(){Ee(Be)}destroy(){this.set(0,0,0,0,0,0,0,0),Ee(this.buffer)}}const Ps=Ms(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),ef=Ps[0],tf=Ps[1],$e=new Uint32Array(80),Re=new Uint32Array(80);class Hs extends hr{constructor(t=64){super(128,t,16,!1),this.Ah=oe[0]|0,this.Al=oe[1]|0,this.Bh=oe[2]|0,this.Bl=oe[3]|0,this.Ch=oe[4]|0,this.Cl=oe[5]|0,this.Dh=oe[6]|0,this.Dl=oe[7]|0,this.Eh=oe[8]|0,this.El=oe[9]|0,this.Fh=oe[10]|0,this.Fl=oe[11]|0,this.Gh=oe[12]|0,this.Gl=oe[13]|0,this.Hh=oe[14]|0,this.Hl=oe[15]|0}get(){const{Ah:t,Al:n,Bh:r,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:d,El:f,Fh:l,Fl:u,Gh:b,Gl:h,Hh:p,Hl:E}=this;return[t,n,r,o,s,i,c,a,d,f,l,u,b,h,p,E]}set(t,n,r,o,s,i,c,a,d,f,l,u,b,h,p,E){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=d|0,this.El=f|0,this.Fh=l|0,this.Fl=u|0,this.Gh=b|0,this.Gl=h|0,this.Hh=p|0,this.Hl=E|0}process(t,n){for(let y=0;y<16;y++,n+=4)$e[y]=t.getUint32(n),Re[y]=t.getUint32(n+=4);for(let y=16;y<80;y++){const S=$e[y-15]|0,D=Re[y-15]|0,m=ze(S,D,1)^ze(S,D,8)^eo(S,D,7),k=qe(S,D,1)^qe(S,D,8)^to(S,D,7),A=$e[y-2]|0,T=Re[y-2]|0,O=ze(A,T,19)^Rt(A,T,61)^eo(A,T,6),P=qe(A,T,19)^Ot(A,T,61)^to(A,T,6),U=Wu(k,P,Re[y-7],Re[y-16]),I=Zu(U,m,O,$e[y-7],$e[y-16]);$e[y]=I|0,Re[y]=U|0}let{Ah:r,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:d,Dl:f,Eh:l,El:u,Fh:b,Fl:h,Gh:p,Gl:E,Hh:w,Hl:g}=this;for(let y=0;y<80;y++){const S=ze(l,u,14)^ze(l,u,18)^Rt(l,u,41),D=qe(l,u,14)^qe(l,u,18)^Ot(l,u,41),m=l&b^~l&p,k=u&h^~u&E,A=Gu(g,D,k,tf[y],Re[y]),T=Yu(A,w,S,m,ef[y],$e[y]),O=A|0,P=ze(r,o,28)^Rt(r,o,34)^Rt(r,o,39),U=qe(r,o,28)^Ot(r,o,34)^Ot(r,o,39),I=r&s^r&c^s&c,x=o&i^o&a^i&a;w=p|0,g=E|0,p=b|0,E=h|0,b=l|0,h=u|0,{h:l,l:u}=Ae(d|0,f|0,T|0,O|0),d=c|0,f=a|0,c=s|0,a=i|0,s=r|0,i=o|0;const v=qu(O,U,x);r=Ju(v,T,P,I),o=v|0}({h:r,l:o}=Ae(this.Ah|0,this.Al|0,r|0,o|0)),{h:s,l:i}=Ae(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=Ae(this.Ch|0,this.Cl|0,c|0,a|0),{h:d,l:f}=Ae(this.Dh|0,this.Dl|0,d|0,f|0),{h:l,l:u}=Ae(this.Eh|0,this.El|0,l|0,u|0),{h:b,l:h}=Ae(this.Fh|0,this.Fl|0,b|0,h|0),{h:p,l:E}=Ae(this.Gh|0,this.Gl|0,p|0,E|0),{h:w,l:g}=Ae(this.Hh|0,this.Hl|0,w|0,g|0),this.set(r,o,s,i,c,a,d,f,l,u,b,h,p,E,w,g)}roundClean(){Ee($e,Re)}destroy(){Ee(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class nf extends Hs{constructor(){super(48),this.Ah=re[0]|0,this.Al=re[1]|0,this.Bh=re[2]|0,this.Bl=re[3]|0,this.Ch=re[4]|0,this.Cl=re[5]|0,this.Dh=re[6]|0,this.Dl=re[7]|0,this.Eh=re[8]|0,this.El=re[9]|0,this.Fh=re[10]|0,this.Fl=re[11]|0,this.Gh=re[12]|0,this.Gl=re[13]|0,this.Hh=re[14]|0,this.Hl=re[15]|0}}const br=xt(()=>new Qu),js=xt(()=>new Hs),rf=xt(()=>new nf);const pr=BigInt(0),qn=BigInt(1);function Fe(e,t=""){if(typeof e!="boolean"){const n=t&&`"${t}"`;throw new Error(n+"expected boolean, got type="+typeof e)}return e}function we(e,t,n=""){const r=Et(e),o=e?.length,s=t!==void 0;if(!r||s&&o!==t){const i=n&&`"${n}" `,c=s?` of length ${t}`:"",a=r?`length=${o}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+c+", got "+a)}return e}function ot(e){const t=e.toString(16);return t.length&1?"0"+t:t}function Ls(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?pr:BigInt("0x"+e)}function sn(e){return Ls(je(e))}function ht(e){return Ie(e),Ls(je(Uint8Array.from(e).reverse()))}function wr(e,t){return lt(e.toString(16).padStart(t*2,"0"))}function Fs(e,t){return wr(e,t).reverse()}function of(e){return lt(ot(e))}function K(e,t,n){let r;if(typeof t=="string")try{r=lt(t)}catch(s){throw new Error(e+" must be hex string or Uint8Array, cause: "+s)}else if(Et(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}function no(e){return Uint8Array.from(e)}const bn=e=>typeof e=="bigint"&&pr<=e;function sf(e,t,n){return bn(e)&&bn(t)&&bn(n)&&t<=e&&e<n}function Jn(e,t,n,r){if(!sf(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function Vs(e){let t;for(t=0;e>pr;e>>=qn,t+=1);return t}const vt=e=>(qn<<BigInt(e))-qn;function af(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");const r=b=>new Uint8Array(b),o=b=>Uint8Array.of(b);let s=r(e),i=r(e),c=0;const a=()=>{s.fill(1),i.fill(0),c=0},d=(...b)=>n(i,s,...b),f=(b=r(0))=>{i=d(o(0),b),s=d(),b.length!==0&&(i=d(o(1),b),s=d())},l=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let b=0;const h=[];for(;b<t;){s=d();const p=s.slice();h.push(p),b+=s.length}return De(...h)};return(b,h)=>{a(),f(b);let p;for(;!(p=h(l()));)f();return a(),p}}function St(e,t,n={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function r(o,s,i){const c=e[o];if(i&&c===void 0)return;const a=typeof c;if(a!==s||c===null)throw new Error(`param "${o}" is invalid: expected ${s}, got ${a}`)}Object.entries(t).forEach(([o,s])=>r(o,s,!1)),Object.entries(n).forEach(([o,s])=>r(o,s,!0))}function zt(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(o!==void 0)return o;const s=e(n,...r);return t.set(n,s),s}}const de=BigInt(0),Q=BigInt(1),Me=BigInt(2),Ks=BigInt(3),zs=BigInt(4),qs=BigInt(5),cf=BigInt(7),Js=BigInt(8),df=BigInt(9),Ws=BigInt(16);function G(e,t){const n=e%t;return n>=de?n:t+n}function Z(e,t,n){let r=e;for(;t-- >de;)r*=r,r%=n;return r}function ro(e,t){if(e===de)throw new Error("invert: expected non-zero number");if(t<=de)throw new Error("invert: expected positive modulus, got "+t);let n=G(e,t),r=t,o=de,s=Q;for(;n!==de;){const c=r/n,a=r%n,d=o-s*c;r=n,n=a,o=s,s=d}if(r!==Q)throw new Error("invert: does not exist");return G(o,t)}function yr(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function Zs(e,t){const n=(e.ORDER+Q)/zs,r=e.pow(t,n);return yr(e,r,t),r}function uf(e,t){const n=(e.ORDER-qs)/Js,r=e.mul(t,Me),o=e.pow(r,n),s=e.mul(t,o),i=e.mul(e.mul(s,Me),o),c=e.mul(s,e.sub(i,e.ONE));return yr(e,c,t),c}function ff(e){const t=ve(e),n=Gs(e),r=n(t,t.neg(t.ONE)),o=n(t,r),s=n(t,t.neg(r)),i=(e+cf)/Ws;return(c,a)=>{let d=c.pow(a,i),f=c.mul(d,r);const l=c.mul(d,o),u=c.mul(d,s),b=c.eql(c.sqr(f),a),h=c.eql(c.sqr(l),a);d=c.cmov(d,f,b),f=c.cmov(u,l,h);const p=c.eql(c.sqr(f),a),E=c.cmov(d,f,p);return yr(c,E,a),E}}function Gs(e){if(e<Ks)throw new Error("sqrt is not defined for small field");let t=e-Q,n=0;for(;t%Me===de;)t/=Me,n++;let r=Me;const o=ve(e);for(;oo(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Zs;let s=o.pow(r,t);const i=(t+Q)/Me;return function(a,d){if(a.is0(d))return d;if(oo(a,d)!==1)throw new Error("Cannot find square root");let f=n,l=a.mul(a.ONE,s),u=a.pow(d,t),b=a.pow(d,i);for(;!a.eql(u,a.ONE);){if(a.is0(u))return a.ZERO;let h=1,p=a.sqr(u);for(;!a.eql(p,a.ONE);)if(h++,p=a.sqr(p),h===f)throw new Error("Cannot find square root");const E=Q<<BigInt(f-h-1),w=a.pow(l,E);f=h,l=a.sqr(w),u=a.mul(u,l),b=a.mul(b,w)}return b}}function lf(e){return e%zs===Ks?Zs:e%Js===qs?uf:e%Ws===df?ff(e):Gs(e)}const hf=(e,t)=>(G(e,t)&Q)===Q,bf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function pf(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=bf.reduce((r,o)=>(r[o]="function",r),t);return St(e,n),e}function wf(e,t,n){if(n<de)throw new Error("invalid exponent, negatives unsupported");if(n===de)return e.ONE;if(n===Q)return t;let r=e.ONE,o=t;for(;n>de;)n&Q&&(r=e.mul(r,o)),o=e.sqr(o),n>>=Q;return r}function Ys(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce((i,c,a)=>e.is0(c)?i:(r[a]=i,e.mul(i,c)),e.ONE),s=e.inv(o);return t.reduceRight((i,c,a)=>e.is0(c)?i:(r[a]=e.mul(i,r[a]),e.mul(i,c)),s),r}function oo(e,t){const n=(e.ORDER-Q)/Me,r=e.pow(t,n),o=e.eql(r,e.ONE),s=e.eql(r,e.ZERO),i=e.eql(r,e.neg(e.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function Xs(e,t){t!==void 0&&ft(t);const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function ve(e,t,n=!1,r={}){if(e<=de)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,s,i=!1,c;if(typeof t=="object"&&t!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const u=t;u.BITS&&(o=u.BITS),u.sqrt&&(s=u.sqrt),typeof u.isLE=="boolean"&&(n=u.isLE),typeof u.modFromBytes=="boolean"&&(i=u.modFromBytes),c=u.allowedLengths}else typeof t=="number"&&(o=t),r.sqrt&&(s=r.sqrt);const{nBitLength:a,nByteLength:d}=Xs(e,o);if(d>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let f;const l=Object.freeze({ORDER:e,isLE:n,BITS:a,BYTES:d,MASK:vt(a),ZERO:de,ONE:Q,allowedLengths:c,create:u=>G(u,e),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return de<=u&&u<e},is0:u=>u===de,isValidNot0:u=>!l.is0(u)&&l.isValid(u),isOdd:u=>(u&Q)===Q,neg:u=>G(-u,e),eql:(u,b)=>u===b,sqr:u=>G(u*u,e),add:(u,b)=>G(u+b,e),sub:(u,b)=>G(u-b,e),mul:(u,b)=>G(u*b,e),pow:(u,b)=>wf(l,u,b),div:(u,b)=>G(u*ro(b,e),e),sqrN:u=>u*u,addN:(u,b)=>u+b,subN:(u,b)=>u-b,mulN:(u,b)=>u*b,inv:u=>ro(u,e),sqrt:s||(u=>(f||(f=lf(e)),f(l,u))),toBytes:u=>n?Fs(u,d):wr(u,d),fromBytes:(u,b=!0)=>{if(c){if(!c.includes(u.length)||u.length>d)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+u.length);const p=new Uint8Array(d);p.set(u,n?0:p.length-u.length),u=p}if(u.length!==d)throw new Error("Field.fromBytes: expected "+d+" bytes, got "+u.length);let h=n?ht(u):sn(u);if(i&&(h=G(h,e)),!b&&!l.isValid(h))throw new Error("invalid field element: outside of range 0..ORDER");return h},invertBatch:u=>Ys(l,u),cmov:(u,b,h)=>h?b:u});return Object.freeze(l)}function Qs(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function ei(e){const t=Qs(e);return t+Math.ceil(t/2)}function yf(e,t,n=!1){const r=e.length,o=Qs(t),s=ei(t);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const i=n?ht(e):sn(e),c=G(i,t-Q)+Q;return n?Fs(c,o):wr(c,o)}const Xe=BigInt(0),Pe=BigInt(1);function qt(e,t){const n=t.negate();return e?n:t}function He(e,t){const n=Ys(e.Fp,t.map(r=>r.Z));return t.map((r,o)=>e.fromAffine(r.toAffine(n[o])))}function ti(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function pn(e,t){ti(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1),o=2**e,s=vt(e),i=BigInt(e);return{windows:n,windowSize:r,mask:s,maxNumber:o,shiftBy:i}}function so(e,t,n){const{windowSize:r,mask:o,maxNumber:s,shiftBy:i}=n;let c=Number(e&o),a=e>>i;c>r&&(c-=s,a+=Pe);const d=t*r,f=d+Math.abs(c)-1,l=c===0,u=c<0,b=t%2!==0;return{nextN:a,offset:f,isZero:l,isNeg:u,isNegF:b,offsetF:d}}function gf(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function mf(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}const wn=new WeakMap,ni=new WeakMap;function yn(e){return ni.get(e)||1}function io(e){if(e!==Xe)throw new Error("invalid wNAF")}class ri{constructor(t,n){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=n}_unsafeLadder(t,n,r=this.ZERO){let o=t;for(;n>Xe;)n&Pe&&(r=r.add(o)),o=o.double(),n>>=Pe;return r}precomputeWindow(t,n){const{windows:r,windowSize:o}=pn(n,this.bits),s=[];let i=t,c=i;for(let a=0;a<r;a++){c=i,s.push(c);for(let d=1;d<o;d++)c=c.add(i),s.push(c);i=c.double()}return s}wNAF(t,n,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE;const i=pn(t,this.bits);for(let c=0;c<i.windows;c++){const{nextN:a,offset:d,isZero:f,isNeg:l,isNegF:u,offsetF:b}=so(r,c,i);r=a,f?s=s.add(qt(u,n[b])):o=o.add(qt(l,n[d]))}return io(r),{p:o,f:s}}wNAFUnsafe(t,n,r,o=this.ZERO){const s=pn(t,this.bits);for(let i=0;i<s.windows&&r!==Xe;i++){const{nextN:c,offset:a,isZero:d,isNeg:f}=so(r,i,s);if(r=c,!d){const l=n[a];o=o.add(f?l.negate():l)}}return io(r),o}getPrecomputes(t,n,r){let o=wn.get(n);return o||(o=this.precomputeWindow(n,t),t!==1&&(typeof r=="function"&&(o=r(o)),wn.set(n,o))),o}cached(t,n,r){const o=yn(t);return this.wNAF(o,this.getPrecomputes(o,t,r),n)}unsafe(t,n,r,o){const s=yn(t);return s===1?this._unsafeLadder(t,n,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,r),n,o)}createCache(t,n){ti(n,this.bits),ni.set(t,n),wn.delete(t)}hasCache(t){return yn(t)!==1}}function Df(e,t,n,r){let o=t,s=e.ZERO,i=e.ZERO;for(;n>Xe||r>Xe;)n&Pe&&(s=s.add(o)),r&Pe&&(i=i.add(o)),o=o.double(),n>>=Pe,r>>=Pe;return{p1:s,p2:i}}function oi(e,t,n,r){gf(n,e),mf(r,t);const o=n.length,s=r.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");const i=e.ZERO,c=Vs(BigInt(o));let a=1;c>12?a=c-3:c>4?a=c-2:c>0&&(a=2);const d=vt(a),f=new Array(Number(d)+1).fill(i),l=Math.floor((t.BITS-1)/a)*a;let u=i;for(let b=l;b>=0;b-=a){f.fill(i);for(let p=0;p<s;p++){const E=r[p],w=Number(E>>BigInt(b)&d);f[w]=f[w].add(n[p])}let h=i;for(let p=f.length-1,E=i;p>0;p--)E=E.add(f[p]),h=h.add(E);if(u=u.add(h),b!==0)for(let p=0;p<a;p++)u=u.double()}return u}function ao(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return pf(t),t}else return ve(e,{isLE:n})}function si(e,t,n={},r){if(r===void 0&&(r=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(const a of["p","n","h"]){const d=t[a];if(!(typeof d=="bigint"&&d>Xe))throw new Error(`CURVE.${a} must be positive bigint`)}const o=ao(t.p,n.Fp,r),s=ao(t.n,n.Fn,r),c=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(const a of c)if(!o.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}const Oe=BigInt(0),X=BigInt(1),gn=BigInt(2),Ef=BigInt(8);function xf(e,t,n,r){const o=e.sqr(n),s=e.sqr(r),i=e.add(e.mul(t.a,o),s),c=e.add(e.ONE,e.mul(t.d,e.mul(o,s)));return e.eql(i,c)}function vf(e,t={}){const n=si("edwards",e,t,t.FpFnLE),{Fp:r,Fn:o}=n;let s=n.CURVE;const{h:i}=s;St(t,{},{uvRatio:"function"});const c=gn<<BigInt(o.BYTES*8)-X,a=E=>r.create(E),d=t.uvRatio||((E,w)=>{try{return{isValid:!0,value:r.sqrt(r.div(E,w))}}catch{return{isValid:!1,value:Oe}}});if(!xf(r,s,s.Gx,s.Gy))throw new Error("bad curve params: generator point");function f(E,w,g=!1){const y=g?X:Oe;return Jn("coordinate "+E,w,y,c),w}function l(E){if(!(E instanceof h))throw new Error("ExtendedPoint expected")}const u=zt((E,w)=>{const{X:g,Y:y,Z:S}=E,D=E.is0();w==null&&(w=D?Ef:r.inv(S));const m=a(g*w),k=a(y*w),A=r.mul(S,w);if(D)return{x:Oe,y:X};if(A!==X)throw new Error("invZ was invalid");return{x:m,y:k}}),b=zt(E=>{const{a:w,d:g}=s;if(E.is0())throw new Error("bad point: ZERO");const{X:y,Y:S,Z:D,T:m}=E,k=a(y*y),A=a(S*S),T=a(D*D),O=a(T*T),P=a(k*w),U=a(T*a(P+A)),I=a(O+a(g*a(k*A)));if(U!==I)throw new Error("bad point: equation left != right (1)");const x=a(y*S),v=a(D*m);if(x!==v)throw new Error("bad point: equation left != right (2)");return!0});class h{constructor(w,g,y,S){this.X=f("x",w),this.Y=f("y",g),this.Z=f("z",y,!0),this.T=f("t",S),Object.freeze(this)}static CURVE(){return s}static fromAffine(w){if(w instanceof h)throw new Error("extended point not allowed");const{x:g,y}=w||{};return f("x",g),f("y",y),new h(g,y,X,a(g*y))}static fromBytes(w,g=!1){const y=r.BYTES,{a:S,d:D}=s;w=no(we(w,y,"point")),Fe(g,"zip215");const m=no(w),k=w[y-1];m[y-1]=k&-129;const A=ht(m),T=g?c:r.ORDER;Jn("point.y",A,Oe,T);const O=a(A*A),P=a(O-X),U=a(D*O-S);let{isValid:I,value:x}=d(P,U);if(!I)throw new Error("bad point: invalid y coordinate");const v=(x&X)===X,C=(k&128)!==0;if(!g&&x===Oe&&C)throw new Error("bad point: x=0 and x_0=1");return C!==v&&(x=a(-x)),h.fromAffine({x,y:A})}static fromHex(w,g=!1){return h.fromBytes(K("point",w),g)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,g=!0){return p.createCache(this,w),g||this.multiply(gn),this}assertValidity(){b(this)}equals(w){l(w);const{X:g,Y:y,Z:S}=this,{X:D,Y:m,Z:k}=w,A=a(g*k),T=a(D*S),O=a(y*k),P=a(m*S);return A===T&&O===P}is0(){return this.equals(h.ZERO)}negate(){return new h(a(-this.X),this.Y,this.Z,a(-this.T))}double(){const{a:w}=s,{X:g,Y:y,Z:S}=this,D=a(g*g),m=a(y*y),k=a(gn*a(S*S)),A=a(w*D),T=g+y,O=a(a(T*T)-D-m),P=A+m,U=P-k,I=A-m,x=a(O*U),v=a(P*I),C=a(O*I),B=a(U*P);return new h(x,v,B,C)}add(w){l(w);const{a:g,d:y}=s,{X:S,Y:D,Z:m,T:k}=this,{X:A,Y:T,Z:O,T:P}=w,U=a(S*A),I=a(D*T),x=a(k*y*P),v=a(m*O),C=a((S+D)*(A+T)-U-I),B=v-x,N=v+x,$=a(I-g*U),R=a(C*B),M=a(N*$),H=a(C*$),q=a(B*N);return new h(R,M,q,H)}subtract(w){return this.add(w.negate())}multiply(w){if(!o.isValidNot0(w))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:g,f:y}=p.cached(this,w,S=>He(h,S));return He(h,[g,y])[0]}multiplyUnsafe(w,g=h.ZERO){if(!o.isValid(w))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return w===Oe?h.ZERO:this.is0()||w===X?this:p.unsafe(this,w,y=>He(h,y),g)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return p.unsafe(this,s.n).is0()}toAffine(w){return u(this,w)}clearCofactor(){return i===X?this:this.multiplyUnsafe(i)}toBytes(){const{x:w,y:g}=this.toAffine(),y=r.toBytes(g);return y[y.length-1]|=w&X?128:0,y}toHex(){return je(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(w){return He(h,w)}static msm(w,g){return oi(h,o,w,g)}_setWindowSize(w){this.precompute(w)}toRawBytes(){return this.toBytes()}}h.BASE=new h(s.Gx,s.Gy,X,a(s.Gx*s.Gy)),h.ZERO=new h(Oe,X,X,Oe),h.Fp=r,h.Fn=o;const p=new ri(h,o.BITS);return h.BASE.precompute(8),h}function Sf(e,t,n={}){if(typeof t!="function")throw new Error('"hash" function param is required');St(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:r}=n,{BASE:o,Fp:s,Fn:i}=e,c=n.randomBytes||lr,a=n.adjustScalarBytes||(T=>T),d=n.domain||((T,O,P)=>{if(Fe(P,"phflag"),O.length||P)throw new Error("Contexts/pre-hash are not supported");return T});function f(T){return i.create(ht(T))}function l(T){const O=y.secretKey;T=K("private key",T,O);const P=K("hashed private key",t(T),2*O),U=a(P.slice(0,O)),I=P.slice(O,2*O),x=f(U);return{head:U,prefix:I,scalar:x}}function u(T){const{head:O,prefix:P,scalar:U}=l(T),I=o.multiply(U),x=I.toBytes();return{head:O,prefix:P,scalar:U,point:I,pointBytes:x}}function b(T){return u(T).pointBytes}function h(T=Uint8Array.of(),...O){const P=De(...O);return f(t(d(P,K("context",T),!!r)))}function p(T,O,P={}){T=K("message",T),r&&(T=r(T));const{prefix:U,scalar:I,pointBytes:x}=u(O),v=h(P.context,U,T),C=o.multiply(v).toBytes(),B=h(P.context,C,x,T),N=i.create(v+B*I);if(!i.isValid(N))throw new Error("sign failed: invalid s");const $=De(C,i.toBytes(N));return we($,y.signature,"result")}const E={zip215:!0};function w(T,O,P,U=E){const{context:I,zip215:x}=U,v=y.signature;T=K("signature",T,v),O=K("message",O),P=K("publicKey",P,y.publicKey),x!==void 0&&Fe(x,"zip215"),r&&(O=r(O));const C=v/2,B=T.subarray(0,C),N=ht(T.subarray(C,v));let $,R,M;try{$=e.fromBytes(P,x),R=e.fromBytes(B,x),M=o.multiplyUnsafe(N)}catch{return!1}if(!x&&$.isSmallOrder())return!1;const H=h(I,R.toBytes(),$.toBytes(),O);return R.add($.multiplyUnsafe(H)).subtract(M).clearCofactor().is0()}const g=s.BYTES,y={secretKey:g,publicKey:g,signature:2*g,seed:g};function S(T=c(y.seed)){return we(T,y.seed,"seed")}function D(T){const O=A.randomSecretKey(T);return{secretKey:O,publicKey:b(O)}}function m(T){return Et(T)&&T.length===i.BYTES}function k(T,O){try{return!!e.fromBytes(T,O)}catch{return!1}}const A={getExtendedPublicKey:u,randomSecretKey:S,isValidSecretKey:m,isValidPublicKey:k,toMontgomery(T){const{y:O}=e.fromBytes(T),P=y.publicKey,U=P===32;if(!U&&P!==57)throw new Error("only defined for 25519 and 448");const I=U?s.div(X+O,X-O):s.div(O-X,O+X);return s.toBytes(I)},toMontgomerySecret(T){const O=y.secretKey;we(T,O);const P=t(T.subarray(0,O));return a(P).subarray(0,O)},randomPrivateKey:S,precompute(T=8,O=e.BASE){return O.precompute(T,!1)}};return Object.freeze({keygen:D,getPublicKey:b,sign:p,verify:w,utils:A,Point:e,lengths:y})}function Af(e){const t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp,r=ve(t.n,e.nBitLength,!0),o={Fp:n,Fn:r,uvRatio:e.uvRatio},s={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:o,hash:e.hash,eddsaOpts:s}}function kf(e,t){const n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:e,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function Tf(e){const{CURVE:t,curveOpts:n,hash:r,eddsaOpts:o}=Af(e),s=vf(t,n),i=Sf(s,r,o);return kf(e,i)}const If=BigInt(1),co=BigInt(2);BigInt(3);const Cf=BigInt(5),_f=BigInt(8),gr=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),ii={p:gr,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:_f,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Bf(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),s=gr,c=e*e%s*e%s,a=Z(c,co,s)*c%s,d=Z(a,If,s)*e%s,f=Z(d,Cf,s)*d%s,l=Z(f,t,s)*f%s,u=Z(l,n,s)*l%s,b=Z(u,r,s)*u%s,h=Z(b,o,s)*b%s,p=Z(h,o,s)*b%s,E=Z(p,t,s)*f%s;return{pow_p_5_8:Z(E,co,s)*e%s,b2:c}}function $f(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}const uo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Rf(e,t){const n=gr,r=G(t*t*t,n),o=G(r*r*t,n),s=Bf(e*o).pow_p_5_8;let i=G(e*r*s,n);const c=G(t*i*i,n),a=i,d=G(i*uo,n),f=c===e,l=c===G(-e,n),u=c===G(-e*uo,n);return f&&(i=a),(l||u)&&(i=d),hf(i,n)&&(i=G(-i,n)),{isValid:f||l,value:i}}const Of=ve(ii.p,{isLE:!0}),Uf={...ii,Fp:Of,hash:js,adjustScalarBytes:$f,uvRatio:Rf},ai=Tf(Uf);function Nf(e){return ai.utils.toMontgomery(K("pub",e))}var Ut={exports:{}},mn,fo;function Mf(){if(fo)return mn;fo=1;function e(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(n[i]!==255)throw new TypeError(s+" is ambiguous");n[i]=o}var c=t.length,a=t.charAt(0),d=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var p=0,E=0,w=0,g=h.length;w!==g&&h[w]===0;)w++,p++;for(var y=(g-w)*f+1>>>0,S=new Uint8Array(y);w!==g;){for(var D=h[w],m=0,k=y-1;(D!==0||m<E)&&k!==-1;k--,m++)D+=256*S[k]>>>0,S[k]=D%c>>>0,D=D/c>>>0;if(D!==0)throw new Error("Non-zero carry");E=m,w++}for(var A=y-E;A!==y&&S[A]===0;)A++;for(var T=a.repeat(p);A<y;++A)T+=t.charAt(S[A]);return T}function u(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var p=0;if(h[p]!==" "){for(var E=0,w=0;h[p]===a;)E++,p++;for(var g=(h.length-p)*d+1>>>0,y=new Uint8Array(g);h[p];){var S=n[h.charCodeAt(p)];if(S===255)return;for(var D=0,m=g-1;(S!==0||D<w)&&m!==-1;m--,D++)S+=c*y[m]>>>0,y[m]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");w=D,p++}if(h[p]!==" "){for(var k=g-w;k!==g&&y[k]===0;)k++;for(var A=new Uint8Array(E+(g-k)),T=E;k!==g;)A[T++]=y[k++];return A}}}function b(h){var p=u(h);if(p)return p;throw new Error("Non-base"+c+" character")}return{encode:l,decodeUnsafe:u,decode:b}}return mn=e,mn}var Dn,lo;function mr(){if(lo)return Dn;lo=1;const e=new TextDecoder,t=s=>e.decode(s),n=new TextEncoder,r=s=>n.encode(s);function o(s,i){const c=new Uint8Array(i);let a=0;for(const d of s)c.set(d,a),a+=d.length;return c}return Dn={decodeText:t,encodeText:r,concat:o},Dn}var En,ho;function Pf(){if(ho)return En;ho=1;const{encodeText:e}=mr();class t{constructor(r,o,s,i){this.name=r,this.code=o,this.codeBuf=e(this.code),this.alphabet=i,this.codec=s(i)}encode(r){return this.codec.encode(r)}decode(r){for(const o of r)if(this.alphabet&&this.alphabet.indexOf(o)<0)throw new Error(`invalid character '${o}' in '${r}'`);return this.codec.decode(r)}}return En=t,En}var xn,bo;function Hf(){if(bo)return xn;bo=1;const e=(r,o,s)=>{const i={};for(let u=0;u<o.length;++u)i[o[u]]=u;let c=r.length;for(;r[c-1]==="=";)--c;const a=new Uint8Array(c*s/8|0);let d=0,f=0,l=0;for(let u=0;u<c;++u){const b=i[r[u]];if(b===void 0)throw new SyntaxError("Invalid character "+r[u]);f=f<<s|b,d+=s,d>=8&&(d-=8,a[l++]=255&f>>d)}if(d>=s||255&f<<8-d)throw new SyntaxError("Unexpected end of data");return a},t=(r,o,s)=>{const i=o[o.length-1]==="=",c=(1<<s)-1;let a="",d=0,f=0;for(let l=0;l<r.length;++l)for(f=f<<8|r[l],d+=8;d>s;)d-=s,a+=o[c&f>>d];if(d&&(a+=o[c&f<<s-d]),i)for(;a.length*s&7;)a+="=";return a};return xn={rfc4648:r=>o=>({encode(s){return t(s,o,r)},decode(s){return e(s,o,r)}})},xn}var vn,po;function jf(){if(po)return vn;po=1;const e=Mf(),t=Pf(),{rfc4648:n}=Hf(),{decodeText:r,encodeText:o}=mr(),i=[["identity","\0",()=>({encode:r,decode:o}),""],["base2","0",n(1),"01"],["base8","7",n(3),"01234567"],["base10","9",e,"0123456789"],["base16","f",n(4),"0123456789abcdef"],["base16upper","F",n(4),"0123456789ABCDEF"],["base32hex","v",n(5),"0123456789abcdefghijklmnopqrstuv"],["base32hexupper","V",n(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV"],["base32hexpad","t",n(5),"0123456789abcdefghijklmnopqrstuv="],["base32hexpadupper","T",n(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV="],["base32","b",n(5),"abcdefghijklmnopqrstuvwxyz234567"],["base32upper","B",n(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],["base32pad","c",n(5),"abcdefghijklmnopqrstuvwxyz234567="],["base32padupper","C",n(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567="],["base32z","h",n(5),"ybndrfg8ejkmcpqxot1uwisza345h769"],["base36","k",e,"0123456789abcdefghijklmnopqrstuvwxyz"],["base36upper","K",e,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["base58btc","z",e,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base58flickr","Z",e,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base64","m",n(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",n(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",n(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",n(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],c=i.reduce((d,f)=>(d[f[0]]=new t(f[0],f[1],f[2],f[3]),d),{}),a=i.reduce((d,f)=>(d[f[1]]=c[f[0]],d),{});return vn={names:c,codes:a},vn}var wo;function Lf(){return wo||(wo=1,(function(e,t){const n=jf(),{encodeText:r,decodeText:o,concat:s}=mr();function i(p,E){if(!E)throw new Error("requires an encoded Uint8Array");const{name:w,codeBuf:g}=l(p);return f(w,E),s([g,E],g.length+E.length)}function c(p,E){const w=l(p),g=r(w.encode(E));return s([w.codeBuf,g],w.codeBuf.length+g.length)}function a(p){p instanceof Uint8Array&&(p=o(p));const E=p[0];return["f","F","v","V","t","T","b","B","c","C","h","k","K"].includes(E)&&(p=p.toLowerCase()),l(p[0]).decode(p.substring(1))}function d(p){if(p instanceof Uint8Array&&(p=o(p)),Object.prototype.toString.call(p)!=="[object String]")return!1;try{return l(p[0]).name}catch{return!1}}function f(p,E){l(p).decode(o(E))}function l(p){if(Object.prototype.hasOwnProperty.call(n.names,p))return n.names[p];if(Object.prototype.hasOwnProperty.call(n.codes,p))return n.codes[p];throw new Error(`Unsupported encoding: ${p}`)}function u(p){return p instanceof Uint8Array&&(p=o(p)),l(p[0])}t=e.exports=i,t.encode=c,t.decode=a,t.isEncoded=d,t.encoding=l,t.encodingFromData=u;const b=Object.freeze(n.names),h=Object.freeze(n.codes);t.names=b,t.codes=h})(Ut,Ut.exports)),Ut.exports}var Ff=Lf();class ci extends fr{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,Os(t);const r=on(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?t.create().update(r).digest():r);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),Ee(s)}update(t){return Ye(this),this.iHash.update(t),this}digestInto(t){Ye(this),Ie(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const di=(e,t,n)=>new ci(e,t).update(n).digest();di.create=(e,t)=>new ci(e,t);const yo=(e,t)=>(e+(e>=0?t:-t)/ui)/t;function Vf(e,t,n){const[[r,o],[s,i]]=t,c=yo(i*e,n),a=yo(-o*e,n);let d=e-c*r-a*s,f=-c*o-a*i;const l=d<Te,u=f<Te;l&&(d=-d),u&&(f=-f);const b=vt(Math.ceil(Vs(n)/2))+Ge;if(d<Te||d>=b||f<Te||f>=b)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:l,k1:d,k2neg:u,k2:f}}function Wn(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Sn(e,t){const n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return Fe(n.lowS,"lowS"),Fe(n.prehash,"prehash"),n.format!==void 0&&Wn(n.format),n}class Kf extends Error{constructor(t=""){super(t)}}const ke={Err:Kf,_tlv:{encode:(e,t)=>{const{Err:n}=ke;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const r=t.length/2,o=ot(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const s=r>127?ot(o.length/2|128):"";return ot(e)+s+o+t},decode(e,t){const{Err:n}=ke;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const o=t[r++],s=!!(o&128);let i=0;if(!s)i=o;else{const a=o&127;if(!a)throw new n("tlv.decode(long): indefinite length not supported");if(a>4)throw new n("tlv.decode(long): byte length is too big");const d=t.subarray(r,r+a);if(d.length!==a)throw new n("tlv.decode: length bytes not complete");if(d[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const f of d)i=i<<8|f;if(r+=a,i<128)throw new n("tlv.decode(long): not minimal encoding")}const c=t.subarray(r,r+i);if(c.length!==i)throw new n("tlv.decode: wrong value length");return{v:c,l:t.subarray(r+i)}}},_int:{encode(e){const{Err:t}=ke;if(e<Te)throw new t("integer: negative integers are not allowed");let n=ot(e);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=ke;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return sn(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=ke,o=K("signature",e),{v:s,l:i}=r.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");const{v:c,l:a}=r.decode(2,s),{v:d,l:f}=r.decode(2,a);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(c),s:n.decode(d)}},hexFromSig(e){const{_tlv:t,_int:n}=ke,r=t.encode(2,n.encode(e.r)),o=t.encode(2,n.encode(e.s)),s=r+o;return t.encode(48,s)}},Te=BigInt(0),Ge=BigInt(1),ui=BigInt(2),Nt=BigInt(3),zf=BigInt(4);function We(e,t){const{BYTES:n}=e;let r;if(typeof t=="bigint")r=t;else{let o=K("private key",t);try{r=e.fromBytes(o)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function qf(e,t={}){const n=si("weierstrass",e,t),{Fp:r,Fn:o}=n;let s=n.CURVE;const{h:i,n:c}=s;St(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:a}=t;if(a&&(!r.is0(s.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const d=li(r,o);function f(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(U,I,x){const{x:v,y:C}=I.toAffine(),B=r.toBytes(v);if(Fe(x,"isCompressed"),x){f();const N=!r.isOdd(C);return De(fi(N),B)}else return De(Uint8Array.of(4),B,r.toBytes(C))}function u(U){we(U,void 0,"Point");const{publicKey:I,publicKeyUncompressed:x}=d,v=U.length,C=U[0],B=U.subarray(1);if(v===I&&(C===2||C===3)){const N=r.fromBytes(B);if(!r.isValid(N))throw new Error("bad point: is not on curve, wrong x");const $=p(N);let R;try{R=r.sqrt($)}catch(q){const V=q instanceof Error?": "+q.message:"";throw new Error("bad point: is not on curve, sqrt error"+V)}f();const M=r.isOdd(R);return(C&1)===1!==M&&(R=r.neg(R)),{x:N,y:R}}else if(v===x&&C===4){const N=r.BYTES,$=r.fromBytes(B.subarray(0,N)),R=r.fromBytes(B.subarray(N,N*2));if(!E($,R))throw new Error("bad point: is not on curve");return{x:$,y:R}}else throw new Error(`bad point: got length ${v}, expected compressed=${I} or uncompressed=${x}`)}const b=t.toBytes||l,h=t.fromBytes||u;function p(U){const I=r.sqr(U),x=r.mul(I,U);return r.add(r.add(x,r.mul(U,s.a)),s.b)}function E(U,I){const x=r.sqr(I),v=p(U);return r.eql(x,v)}if(!E(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const w=r.mul(r.pow(s.a,Nt),zf),g=r.mul(r.sqr(s.b),BigInt(27));if(r.is0(r.add(w,g)))throw new Error("bad curve params: a or b");function y(U,I,x=!1){if(!r.isValid(I)||x&&r.is0(I))throw new Error(`bad point coordinate ${U}`);return I}function S(U){if(!(U instanceof T))throw new Error("ProjectivePoint expected")}function D(U){if(!a||!a.basises)throw new Error("no endo");return Vf(U,a.basises,o.ORDER)}const m=zt((U,I)=>{const{X:x,Y:v,Z:C}=U;if(r.eql(C,r.ONE))return{x,y:v};const B=U.is0();I==null&&(I=B?r.ONE:r.inv(C));const N=r.mul(x,I),$=r.mul(v,I),R=r.mul(C,I);if(B)return{x:r.ZERO,y:r.ZERO};if(!r.eql(R,r.ONE))throw new Error("invZ was invalid");return{x:N,y:$}}),k=zt(U=>{if(U.is0()){if(t.allowInfinityPoint&&!r.is0(U.Y))return;throw new Error("bad point: ZERO")}const{x:I,y:x}=U.toAffine();if(!r.isValid(I)||!r.isValid(x))throw new Error("bad point: x or y not field elements");if(!E(I,x))throw new Error("bad point: equation left != right");if(!U.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function A(U,I,x,v,C){return x=new T(r.mul(x.X,U),x.Y,x.Z),I=qt(v,I),x=qt(C,x),I.add(x)}class T{constructor(I,x,v){this.X=y("x",I),this.Y=y("y",x,!0),this.Z=y("z",v),Object.freeze(this)}static CURVE(){return s}static fromAffine(I){const{x,y:v}=I||{};if(!I||!r.isValid(x)||!r.isValid(v))throw new Error("invalid affine point");if(I instanceof T)throw new Error("projective point not allowed");return r.is0(x)&&r.is0(v)?T.ZERO:new T(x,v,r.ONE)}static fromBytes(I){const x=T.fromAffine(h(we(I,void 0,"point")));return x.assertValidity(),x}static fromHex(I){return T.fromBytes(K("pointHex",I))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(I=8,x=!0){return P.createCache(this,I),x||this.multiply(Nt),this}assertValidity(){k(this)}hasEvenY(){const{y:I}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(I)}equals(I){S(I);const{X:x,Y:v,Z:C}=this,{X:B,Y:N,Z:$}=I,R=r.eql(r.mul(x,$),r.mul(B,C)),M=r.eql(r.mul(v,$),r.mul(N,C));return R&&M}negate(){return new T(this.X,r.neg(this.Y),this.Z)}double(){const{a:I,b:x}=s,v=r.mul(x,Nt),{X:C,Y:B,Z:N}=this;let $=r.ZERO,R=r.ZERO,M=r.ZERO,H=r.mul(C,C),q=r.mul(B,B),V=r.mul(N,N),j=r.mul(C,B);return j=r.add(j,j),M=r.mul(C,N),M=r.add(M,M),$=r.mul(I,M),R=r.mul(v,V),R=r.add($,R),$=r.sub(q,R),R=r.add(q,R),R=r.mul($,R),$=r.mul(j,$),M=r.mul(v,M),V=r.mul(I,V),j=r.sub(H,V),j=r.mul(I,j),j=r.add(j,M),M=r.add(H,H),H=r.add(M,H),H=r.add(H,V),H=r.mul(H,j),R=r.add(R,H),V=r.mul(B,N),V=r.add(V,V),H=r.mul(V,j),$=r.sub($,H),M=r.mul(V,q),M=r.add(M,M),M=r.add(M,M),new T($,R,M)}add(I){S(I);const{X:x,Y:v,Z:C}=this,{X:B,Y:N,Z:$}=I;let R=r.ZERO,M=r.ZERO,H=r.ZERO;const q=s.a,V=r.mul(s.b,Nt);let j=r.mul(x,B),J=r.mul(v,N),Y=r.mul(C,$),ce=r.add(x,v),W=r.add(B,N);ce=r.mul(ce,W),W=r.add(j,J),ce=r.sub(ce,W),W=r.add(x,C);let ne=r.add(B,$);return W=r.mul(W,ne),ne=r.add(j,Y),W=r.sub(W,ne),ne=r.add(v,C),R=r.add(N,$),ne=r.mul(ne,R),R=r.add(J,Y),ne=r.sub(ne,R),H=r.mul(q,W),R=r.mul(V,Y),H=r.add(R,H),R=r.sub(J,H),H=r.add(J,H),M=r.mul(R,H),J=r.add(j,j),J=r.add(J,j),Y=r.mul(q,Y),W=r.mul(V,W),J=r.add(J,Y),Y=r.sub(j,Y),Y=r.mul(q,Y),W=r.add(W,Y),j=r.mul(J,W),M=r.add(M,j),j=r.mul(ne,W),R=r.mul(ce,R),R=r.sub(R,j),j=r.mul(ce,J),H=r.mul(ne,H),H=r.add(H,j),new T(R,M,H)}subtract(I){return this.add(I.negate())}is0(){return this.equals(T.ZERO)}multiply(I){const{endo:x}=t;if(!o.isValidNot0(I))throw new Error("invalid scalar: out of range");let v,C;const B=N=>P.cached(this,N,$=>He(T,$));if(x){const{k1neg:N,k1:$,k2neg:R,k2:M}=D(I),{p:H,f:q}=B($),{p:V,f:j}=B(M);C=q.add(j),v=A(x.beta,H,V,N,R)}else{const{p:N,f:$}=B(I);v=N,C=$}return He(T,[v,C])[0]}multiplyUnsafe(I){const{endo:x}=t,v=this;if(!o.isValid(I))throw new Error("invalid scalar: out of range");if(I===Te||v.is0())return T.ZERO;if(I===Ge)return v;if(P.hasCache(this))return this.multiply(I);if(x){const{k1neg:C,k1:B,k2neg:N,k2:$}=D(I),{p1:R,p2:M}=Df(T,v,B,$);return A(x.beta,R,M,C,N)}else return P.unsafe(v,I)}multiplyAndAddUnsafe(I,x,v){const C=this.multiplyUnsafe(x).add(I.multiplyUnsafe(v));return C.is0()?void 0:C}toAffine(I){return m(this,I)}isTorsionFree(){const{isTorsionFree:I}=t;return i===Ge?!0:I?I(T,this):P.unsafe(this,c).is0()}clearCofactor(){const{clearCofactor:I}=t;return i===Ge?this:I?I(T,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(I=!0){return Fe(I,"isCompressed"),this.assertValidity(),b(T,this,I)}toHex(I=!0){return je(this.toBytes(I))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(I=!0){return this.toBytes(I)}_setWindowSize(I){this.precompute(I)}static normalizeZ(I){return He(T,I)}static msm(I,x){return oi(T,o,I,x)}static fromPrivateKey(I){return T.BASE.multiply(We(o,I))}}T.BASE=new T(s.Gx,s.Gy,r.ONE),T.ZERO=new T(r.ZERO,r.ONE,r.ZERO),T.Fp=r,T.Fn=o;const O=o.BITS,P=new ri(T,t.endo?Math.ceil(O/2):O);return T.BASE.precompute(8),T}function fi(e){return Uint8Array.of(e?2:3)}function li(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Jf(e,t={}){const{Fn:n}=e,r=t.randomBytes||lr,o=Object.assign(li(e.Fp,n),{seed:ei(n.ORDER)});function s(b){try{return!!We(n,b)}catch{return!1}}function i(b,h){const{publicKey:p,publicKeyUncompressed:E}=o;try{const w=b.length;return h===!0&&w!==p||h===!1&&w!==E?!1:!!e.fromBytes(b)}catch{return!1}}function c(b=r(o.seed)){return yf(we(b,o.seed,"seed"),n.ORDER)}function a(b,h=!0){return e.BASE.multiply(We(n,b)).toBytes(h)}function d(b){const h=c(b);return{secretKey:h,publicKey:a(h)}}function f(b){if(typeof b=="bigint")return!1;if(b instanceof e)return!0;const{secretKey:h,publicKey:p,publicKeyUncompressed:E}=o;if(n.allowedLengths||h===p)return;const w=K("key",b).length;return w===p||w===E}function l(b,h,p=!0){if(f(b)===!0)throw new Error("first arg must be private key");if(f(h)===!1)throw new Error("second arg must be public key");const E=We(n,b);return e.fromHex(h).multiply(E).toBytes(p)}return Object.freeze({getPublicKey:a,getSharedSecret:l,keygen:d,Point:e,utils:{isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:c,isValidPrivateKey:s,randomPrivateKey:c,normPrivateKeyToScalar:b=>We(n,b),precompute(b=8,h=e.BASE){return h.precompute(b,!1)}},lengths:o})}function Wf(e,t,n={}){Os(t),St(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||lr,o=n.hmac||((x,...v)=>di(t,x,De(...v))),{Fp:s,Fn:i}=e,{ORDER:c,BITS:a}=i,{keygen:d,getPublicKey:f,getSharedSecret:l,utils:u,lengths:b}=Jf(e,n),h={prehash:!1,lowS:typeof n.lowS=="boolean"?n.lowS:!1,format:void 0,extraEntropy:!1},p="compact";function E(x){const v=c>>Ge;return x>v}function w(x,v){if(!i.isValidNot0(v))throw new Error(`invalid signature ${x}: out of range 1..Point.Fn.ORDER`);return v}function g(x,v){Wn(v);const C=b.signature,B=v==="compact"?C:v==="recovered"?C+1:void 0;return we(x,B,`${v} signature`)}class y{constructor(v,C,B){this.r=w("r",v),this.s=w("s",C),B!=null&&(this.recovery=B),Object.freeze(this)}static fromBytes(v,C=p){g(v,C);let B;if(C==="der"){const{r:M,s:H}=ke.toSig(we(v));return new y(M,H)}C==="recovered"&&(B=v[0],C="compact",v=v.subarray(1));const N=i.BYTES,$=v.subarray(0,N),R=v.subarray(N,N*2);return new y(i.fromBytes($),i.fromBytes(R),B)}static fromHex(v,C){return this.fromBytes(lt(v),C)}addRecoveryBit(v){return new y(this.r,this.s,v)}recoverPublicKey(v){const C=s.ORDER,{r:B,s:N,recovery:$}=this;if($==null||![0,1,2,3].includes($))throw new Error("recovery id invalid");if(c*ui<C&&$>1)throw new Error("recovery id is ambiguous for h>1 curve");const M=$===2||$===3?B+c:B;if(!s.isValid(M))throw new Error("recovery id 2 or 3 invalid");const H=s.toBytes(M),q=e.fromBytes(De(fi(($&1)===0),H)),V=i.inv(M),j=D(K("msgHash",v)),J=i.create(-j*V),Y=i.create(N*V),ce=e.BASE.multiplyUnsafe(J).add(q.multiplyUnsafe(Y));if(ce.is0())throw new Error("point at infinify");return ce.assertValidity(),ce}hasHighS(){return E(this.s)}toBytes(v=p){if(Wn(v),v==="der")return lt(ke.hexFromSig(this));const C=i.toBytes(this.r),B=i.toBytes(this.s);if(v==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return De(Uint8Array.of(this.recovery),C,B)}return De(C,B)}toHex(v){return je(this.toBytes(v))}assertValidity(){}static fromCompact(v){return y.fromBytes(K("sig",v),"compact")}static fromDER(v){return y.fromBytes(K("sig",v),"der")}normalizeS(){return this.hasHighS()?new y(this.r,i.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return je(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return je(this.toBytes("compact"))}}const S=n.bits2int||function(v){if(v.length>8192)throw new Error("input is too large");const C=sn(v),B=v.length*8-a;return B>0?C>>BigInt(B):C},D=n.bits2int_modN||function(v){return i.create(S(v))},m=vt(a);function k(x){return Jn("num < 2^"+a,x,Te,m),i.toBytes(x)}function A(x,v){return we(x,void 0,"message"),v?we(t(x),void 0,"prehashed message"):x}function T(x,v,C){if(["recovered","canonical"].some(J=>J in C))throw new Error("sign() legacy options not supported");const{lowS:B,prehash:N,extraEntropy:$}=Sn(C,h);x=A(x,N);const R=D(x),M=We(i,v),H=[k(M),k(R)];if($!=null&&$!==!1){const J=$===!0?r(b.secretKey):$;H.push(K("extraEntropy",J))}const q=De(...H),V=R;function j(J){const Y=S(J);if(!i.isValidNot0(Y))return;const ce=i.inv(Y),W=e.BASE.multiply(Y).toAffine(),ne=i.create(W.x);if(ne===Te)return;const It=i.create(ce*i.create(V+ne*M));if(It===Te)return;let Lr=(W.x===ne?0:2)|Number(W.y&Ge),Fr=It;return B&&E(It)&&(Fr=i.neg(It),Lr^=1),new y(ne,Fr,Lr)}return{seed:q,k2sig:j}}function O(x,v,C={}){x=K("message",x);const{seed:B,k2sig:N}=T(x,v,C);return af(t.outputLen,i.BYTES,o)(B,N)}function P(x){let v;const C=typeof x=="string"||Et(x),B=!C&&x!==null&&typeof x=="object"&&typeof x.r=="bigint"&&typeof x.s=="bigint";if(!C&&!B)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(B)v=new y(x.r,x.s);else if(C){try{v=y.fromBytes(K("sig",x),"der")}catch(N){if(!(N instanceof ke.Err))throw N}if(!v)try{v=y.fromBytes(K("sig",x),"compact")}catch{return!1}}return v||!1}function U(x,v,C,B={}){const{lowS:N,prehash:$,format:R}=Sn(B,h);if(C=K("publicKey",C),v=A(K("message",v),$),"strict"in B)throw new Error("options.strict was renamed to lowS");const M=R===void 0?P(x):y.fromBytes(K("sig",x),R);if(M===!1)return!1;try{const H=e.fromBytes(C);if(N&&M.hasHighS())return!1;const{r:q,s:V}=M,j=D(v),J=i.inv(V),Y=i.create(j*J),ce=i.create(q*J),W=e.BASE.multiplyUnsafe(Y).add(H.multiplyUnsafe(ce));return W.is0()?!1:i.create(W.x)===q}catch{return!1}}function I(x,v,C={}){const{prehash:B}=Sn(C,h);return v=A(v,B),y.fromBytes(x,"recovered").recoverPublicKey(v).toBytes()}return Object.freeze({keygen:d,getPublicKey:f,getSharedSecret:l,utils:u,lengths:b,Point:e,sign:O,verify:U,recoverPublicKey:I,Signature:y,hash:t})}function Zf(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(i=>Math.ceil(i/2)))):void 0;const o=ve(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),s={Fp:n,Fn:o,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:s}}function Gf(e){const{CURVE:t,curveOpts:n}=Zf(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function Yf(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,Xs(n.Fn.ORDER,n.Fn.BITS))})}function Xf(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=Gf(e),s=qf(t,n),i=Wf(s,r,o);return Yf(e,i)}function an(e,t){const n=r=>Xf({...e,hash:r});return{...n(t),create:n}}const Dr={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Qf={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},go=BigInt(2);function el(e){const t=Dr.p,n=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),d=e*e*e%t,f=d*d*e%t,l=Z(f,n,t)*f%t,u=Z(l,n,t)*f%t,b=Z(u,go,t)*d%t,h=Z(b,o,t)*b%t,p=Z(h,s,t)*h%t,E=Z(p,c,t)*p%t,w=Z(E,a,t)*E%t,g=Z(w,c,t)*p%t,y=Z(g,n,t)*f%t,S=Z(y,i,t)*h%t,D=Z(S,r,t)*d%t,m=Z(D,go,t);if(!Zn.eql(Zn.sqr(m),e))throw new Error("Cannot find square root");return m}const Zn=ve(Dr.p,{sqrt:el}),bt=an({...Dr,Fp:Zn,lowS:!0,endo:Qf},br);const hi={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},bi={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},pi={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},tl=ve(hi.p),nl=ve(bi.p),rl=ve(pi.p),ol=an({...hi,Fp:tl,lowS:!1},br),sl=an({...bi,Fp:nl,lowS:!1},rf),il=an({...pi,Fp:rl,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},js);const Jt=ol,al=br,cl=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),wi=Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)),dl=wi.map(e=>(9*e+5)%16),yi=(()=>{const n=[[wi],[dl]];for(let r=0;r<4;r++)for(let o of n)o.push(o[r].map(s=>cl[s]));return n})(),gi=yi[0],mi=yi[1],Di=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>Uint8Array.from(e)),ul=gi.map((e,t)=>e.map(n=>Di[t][n])),fl=mi.map((e,t)=>e.map(n=>Di[t][n])),ll=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),hl=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function mo(e,t,n,r){return e===0?t^n^r:e===1?t&n|~t&r:e===2?(t|~n)^r:e===3?t&r|n&~r:t^(n|~r)}const Mt=new Uint32Array(16);class bl extends hr{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:n,h2:r,h3:o,h4:s}=this;return[t,n,r,o,s]}set(t,n,r,o,s){this.h0=t|0,this.h1=n|0,this.h2=r|0,this.h3=o|0,this.h4=s|0}process(t,n){for(let b=0;b<16;b++,n+=4)Mt[b]=t.getUint32(n,!0);let r=this.h0|0,o=r,s=this.h1|0,i=s,c=this.h2|0,a=c,d=this.h3|0,f=d,l=this.h4|0,u=l;for(let b=0;b<5;b++){const h=4-b,p=ll[b],E=hl[b],w=gi[b],g=mi[b],y=ul[b],S=fl[b];for(let D=0;D<16;D++){const m=Bt(r+mo(b,s,c,d)+Mt[w[D]]+p,y[D])+l|0;r=l,l=d,d=Bt(c,10)|0,c=s,s=m}for(let D=0;D<16;D++){const m=Bt(o+mo(h,i,a,f)+Mt[g[D]]+E,S[D])+u|0;o=u,u=f,f=Bt(a,10)|0,a=i,i=m}}this.set(this.h1+c+f|0,this.h2+d+u|0,this.h3+l+o|0,this.h4+r+i|0,this.h0+s+a|0)}roundClean(){Ee(Mt)}destroy(){this.destroyed=!0,Ee(this.buffer),this.set(0,0,0,0,0)}}const pl=xt(()=>new bl),Ei=pl,wl=BigInt(0),nt=BigInt(1),yl=BigInt(2),gl=BigInt(7),ml=BigInt(256),Dl=BigInt(113),xi=[],vi=[],Si=[];for(let e=0,t=nt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],xi.push(2*(5*r+n)),vi.push((e+1)*(e+2)/2%64);let o=wl;for(let s=0;s<7;s++)t=(t<<nt^(t>>gl)*Dl)%ml,t&yl&&(o^=nt<<(nt<<BigInt(s))-nt);Si.push(o)}const Ai=Ms(Si,!0),El=Ai[0],xl=Ai[1],Do=(e,t,n)=>n>32?Ku(e,t,n):Fu(e,t,n),Eo=(e,t,n)=>n>32?zu(e,t,n):Vu(e,t,n);function vl(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,a=(i+2)%10,d=n[a],f=n[a+1],l=Do(d,f,1)^n[c],u=Eo(d,f,1)^n[c+1];for(let b=0;b<50;b+=10)e[i+b]^=l,e[i+b+1]^=u}let o=e[2],s=e[3];for(let i=0;i<24;i++){const c=vi[i],a=Do(o,s,c),d=Eo(o,s,c),f=xi[i];o=e[f],s=e[f+1],e[f]=a,e[f+1]=d}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=El[r],e[1]^=xl[r]}Ee(n)}class Er extends fr{constructor(t,n,r,o=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=s,ft(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=$u(this.state)}clone(){return this._cloneInto()}keccak(){Yr(this.state32),vl(this.state32,this.rounds),Yr(this.state32),this.posOut=0,this.pos=0}update(t){Ye(this),t=on(t),Ie(t);const{blockLen:n,state:r}=this,o=t.length;for(let s=0;s<o;){const i=Math.min(n-this.pos,o-s);for(let c=0;c<i;c++)r[this.pos++]^=t[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:o}=this;t[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){Ye(this,!1),Ie(t),this.finish();const n=this.state,{blockLen:r}=this;for(let o=0,s=t.length;o<s;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,s-o);t.set(n.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return ft(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Us(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Ee(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:o,rounds:s,enableXOF:i}=this;return t||(t=new Er(n,r,o,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=o,t.enableXOF=i,t.destroyed=this.destroyed,t}}const Sl=(e,t,n)=>xt(()=>new Er(t,e,n)),Al=Sl(1,136,256/8);var An,xo;function kl(){return xo||(xo=1,An=function e(t){if(typeof t=="number"&&isNaN(t))throw new Error("NaN is not allowed");if(typeof t=="number"&&!isFinite(t))throw new Error("Infinity is not allowed");return t===null||typeof t!="object"?JSON.stringify(t):t.toJSON instanceof Function?e(t.toJSON()):Array.isArray(t)?`[${t.reduce((o,s,i)=>`${o}${i===0?"":","}${e(s===void 0||typeof s=="symbol"?null:s)}`,"")}]`:`{${Object.keys(t).sort().reduce((r,o)=>{if(t[o]===void 0||typeof t[o]=="symbol")return r;const s=r.length===0?"":",";return`${r}${s}${e(o)}:${e(t[o])}`},"")}}`}),An}var Tl=kl();const Il=nr(Tl);function Cl(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function _l(){const e=new Map;return function(t,n){try{let o=function(i){if(r)return i;const c=e.get(t.didUrl);return c!==void 0?c:Promise.resolve(n()).then(function(a){var d;return((d=a.didResolutionMetadata)==null?void 0:d.error)!=="notFound"&&e.set(t.didUrl,a),a})},r;const s=(function(){if(t.params&&t.params["no-cache"]==="true")return Promise.resolve(n()).then(function(i){return r=1,i})})();return Promise.resolve(s&&s.then?s.then(o):o(s))}catch(r){return Promise.reject(r)}}}function Bl(e,t){return t()}const $l="(?:%[0-9a-fA-F]{2})",vo=`(?:[a-zA-Z0-9._-]|${$l})`,Rl="([a-z0-9]+)",Ol=`((?:${vo}*:)*(${vo}+))`,So="[a-zA-Z0-9_.:%-]",Ul=`;${So}+=${So}*`,Nl=`((${Ul})*)`,Ml="(/[^#?]*)?",Pl="([?][^#]*)?",Hl="(#.*)?",jl=new RegExp(`^did:${Rl}:${Ol}${Nl}${Ml}${Pl}${Hl}$`);function ki(e){if(e===""||!e)return null;const t=e.match(jl);if(t){const n={did:`did:${t[1]}:${t[2]}`,method:t[1],id:t[2],didUrl:e};if(t[4]){const r=t[4].slice(1).split(";");n.params={};for(const o of r){const s=o.split("=");n.params[s[0]]=s[1]}}return t[6]&&(n.path=t[6]),t[7]&&(n.query=t[7].slice(1)),t[8]&&(n.fragment=t[8].slice(1)),n}return null}const Wt={didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};function Ll(e){return function(t,n,r){try{return Promise.resolve(Cl(function(){return Promise.resolve(e(t,n,r)).then(function(o){return{...Wt,didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:o}})},function(o){return{...Wt,didResolutionMetadata:{error:"notFound",message:o.toString()}}}))}catch(o){return Promise.reject(o)}}}class Fl{constructor(t={},n={}){this.registry=void 0,this.cache=void 0,this.registry=t,this.cache=n.cache===!0?_l():n.cache||Bl,n.legacyResolvers&&Object.keys(n.legacyResolvers).map(r=>{this.registry[r]||(this.registry[r]=Ll(n.legacyResolvers[r]))})}resolve(t,n={}){try{const r=this,o=ki(t);if(o===null)return Promise.resolve({...Wt,didResolutionMetadata:{error:"invalidDid"}});const s=r.registry[o.method];return s?Promise.resolve(r.cache(o,()=>s(o.did,o,r,n))):Promise.resolve({...Wt,didResolutionMetadata:{error:"unsupportedDidMethod"}})}catch(r){return Promise.reject(r)}}}function Ti(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ii(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function Vl(e){if(typeof e!="function")throw new Error("function expected");return!0}function pt(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Ci(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Gn(e){if(!Array.isArray(e))throw new Error("array expected")}function _i(e,t){if(!Ii(!0,t))throw new Error(`${e}: array of strings expected`)}function Bi(e,t){if(!Ii(!1,t))throw new Error(`${e}: array of numbers expected`)}function Kl(...e){const t=s=>s,n=(s,i)=>c=>s(i(c)),r=e.map(s=>s.encode).reduceRight(n,t),o=e.map(s=>s.decode).reduce(n,t);return{encode:r,decode:o}}function zl(e){const t=typeof e=="string"?e.split(""):e,n=t.length;_i("alphabet",t);const r=new Map(t.map((o,s)=>[o,s]));return{encode:o=>(Gn(o),o.map(s=>{if(!Number.isSafeInteger(s)||s<0||s>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${e}`);return t[s]})),decode:o=>(Gn(o),o.map(s=>{pt("alphabet.decode",s);const i=r.get(s);if(i===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${e}`);return i}))}}function ql(e=""){return pt("join",e),{encode:t=>(_i("join.decode",t),t.join(e)),decode:t=>(pt("join.decode",t),t.split(e))}}const $i=(e,t)=>t===0?e:$i(t,e%t),Zt=(e,t)=>e+(t-$i(e,t)),jt=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Yn(e,t,n,r){if(Gn(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Zt(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Zt(t,n)}`);let o=0,s=0;const i=jt[t],c=jt[n]-1,a=[];for(const d of e){if(Ci(d),d>=i)throw new Error(`convertRadix2: invalid data word=${d} from=${t}`);if(o=o<<t|d,s+t>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)a.push((o>>s-n&c)>>>0);const f=jt[s];if(f===void 0)throw new Error("invalid carry");o&=f-1}if(o=o<<n-s&c,!r&&s>=t)throw new Error("Excess padding");if(!r&&o>0)throw new Error(`Non-zero padding: ${o}`);return r&&s>0&&a.push(o>>>0),a}function Jl(e,t=!1){if(Ci(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Zt(8,e)>32||Zt(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Ti(n))throw new Error("radix2.encode input should be Uint8Array");return Yn(Array.from(n),8,e,!t)},decode:n=>(Bi("radix2.decode",n),Uint8Array.from(Yn(n,e,8,t)))}}function Ao(e){return Vl(e),function(...t){try{return e.apply(null,t)}catch{}}}const Xn=Kl(zl("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),ql("")),ko=[996825010,642813549,513874426,1027748829,705979059];function rt(e){const t=e>>25;let n=(e&33554431)<<5;for(let r=0;r<ko.length;r++)(t>>r&1)===1&&(n^=ko[r]);return n}function To(e,t,n=1){const r=e.length;let o=1;for(let s=0;s<r;s++){const i=e.charCodeAt(s);if(i<33||i>126)throw new Error(`Invalid prefix (${e})`);o=rt(o)^i>>5}o=rt(o);for(let s=0;s<r;s++)o=rt(o)^e.charCodeAt(s)&31;for(let s of t)o=rt(o)^s;for(let s=0;s<6;s++)o=rt(o);return o^=n,Xn.encode(Yn([o%jt[30]],30,5,!1))}function Wl(e){const t=e==="bech32"?1:734539939,n=Jl(5),r=n.decode,o=n.encode,s=Ao(r);function i(l,u,b=90){pt("bech32.encode prefix",l),Ti(u)&&(u=Array.from(u)),Bi("bech32.encode",u);const h=l.length;if(h===0)throw new TypeError(`Invalid prefix length ${h}`);const p=h+7+u.length;if(b!==!1&&p>b)throw new TypeError(`Length ${p} exceeds limit ${b}`);const E=l.toLowerCase(),w=To(E,u,t);return`${E}1${Xn.encode(u)}${w}`}function c(l,u=90){pt("bech32.decode input",l);const b=l.length;if(b<8||u!==!1&&b>u)throw new TypeError(`invalid string length: ${b} (${l}). Expected (8..${u})`);const h=l.toLowerCase();if(l!==h&&l!==l.toUpperCase())throw new Error("String must be lowercase or uppercase");const p=h.lastIndexOf("1");if(p===0||p===-1)throw new Error('Letter "1" must be present between prefix and data only');const E=h.slice(0,p),w=h.slice(p+1);if(w.length<6)throw new Error("Data must be at least 6 characters long");const g=Xn.decode(w).slice(0,-6),y=To(E,g,t);if(!w.endsWith(y))throw new Error(`Invalid checksum in ${l}: expected "${y}"`);return{prefix:E,words:g}}const a=Ao(c);function d(l){const{prefix:u,words:b}=c(l,!1);return{prefix:u,words:b,bytes:r(b)}}function f(l,u){return i(l,o(u))}return{encode:i,decode:c,encodeFromBytes:f,decodeToBytes:d,decodeUnsafe:a,fromWords:r,fromWordsUnsafe:s,toWords:o}}const Io=Wl("bech32"),he={toString:ur,fromString:rn,concat:gs};function xr(e){return he.toString(e,"base64url")}function fe(e){const t=e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");return he.fromString(t,"base64url")}function Ri(e){return he.fromString(e,"base58btc")}function Zl(e){return he.toString(e,"base58btc")}const Gl={ES256:["JsonWebKey2020","Multikey","EcdsaSecp256r1VerificationKey2019"],ES256K:["EcdsaSecp256k1VerificationKey2019","EcdsaSecp256k1RecoveryMethod2020","Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1","JsonWebKey2020","Multikey"],"ES256K-R":["EcdsaSecp256k1VerificationKey2019","EcdsaSecp256k1RecoveryMethod2020","Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1","ConditionalProof2022","JsonWebKey2020","Multikey"],Ed25519:["ED25519SignatureVerification","Ed25519VerificationKey2018","Ed25519VerificationKey2020","JsonWebKey2020","Multikey"],EdDSA:["ED25519SignatureVerification","Ed25519VerificationKey2018","Ed25519VerificationKey2020","JsonWebKey2020","Multikey"]},Pt={Secp256k1SignatureVerificationKey2018:"Secp256k1",Secp256k1VerificationKey2018:"Secp256k1",EcdsaSecp256k1VerificationKey2019:"Secp256k1",EcdsaPublicKeySecp256k1:"Secp256k1",EcdsaSecp256k1RecoveryMethod2020:"Secp256k1",EcdsaSecp256r1VerificationKey2019:"P-256",Ed25519VerificationKey2018:"Ed25519",Ed25519VerificationKey2020:"Ed25519",ED25519SignatureVerification:"Ed25519",X25519KeyAgreementKey2019:"X25519",X25519KeyAgreementKey2020:"X25519",ConditionalProof2022:void 0,JsonWebKey2020:void 0,Multikey:void 0},Yl={"ed25519-pub":237,"x25519-pub":236,"secp256k1-pub":231,"bls12_381-g1-pub":234,"bls12_381-g2-pub":235,"p256-pub":4608},Xl={"bls12_381-g1-pub":"Bls12381G1","bls12_381-g2-pub":"Bls12381G2","ed25519-pub":"Ed25519","p256-pub":"P-256","secp256k1-pub":"Secp256k1","x25519-pub":"X25519"};function cn(e){if(e.publicKeyBase58)return{keyBytes:Ri(e.publicKeyBase58),keyType:Pt[e.type]};if(e.publicKeyBase64)return{keyBytes:fe(e.publicKeyBase64),keyType:Pt[e.type]};if(e.publicKeyHex)return{keyBytes:Lt(e.publicKeyHex),keyType:Pt[e.type]};if(e.publicKeyJwk&&e.publicKeyJwk.crv==="secp256k1"&&e.publicKeyJwk.x&&e.publicKeyJwk.y)return{keyBytes:bt.ProjectivePoint.fromAffine({x:Ht(fe(e.publicKeyJwk.x)),y:Ht(fe(e.publicKeyJwk.y))}).toRawBytes(!1),keyType:"Secp256k1"};if(e.publicKeyJwk&&e.publicKeyJwk.crv==="P-256"&&e.publicKeyJwk.x&&e.publicKeyJwk.y)return{keyBytes:Jt.ProjectivePoint.fromAffine({x:Ht(fe(e.publicKeyJwk.x)),y:Ht(fe(e.publicKeyJwk.y))}).toRawBytes(!1),keyType:"P-256"};if(e.publicKeyJwk&&e.publicKeyJwk.kty==="OKP"&&["Ed25519","X25519"].includes(e.publicKeyJwk.crv??"")&&e.publicKeyJwk.x)return{keyBytes:fe(e.publicKeyJwk.x),keyType:e.publicKeyJwk.crv};if(e.publicKeyMultibase){const{keyBytes:t,keyType:n}=Ql(e.publicKeyMultibase);return{keyBytes:t,keyType:n??Pt[e.type]}}return{keyBytes:new Uint8Array}}function Ql(e){const t=Ff.decode(e);if([32,33,48,64,65,96].includes(t.length))return{keyBytes:t};try{const[n,r]=at(t),o=Object.entries(Yl).filter(([,s])=>s===n)?.[0][0]??"";return{keyBytes:t.slice(r),keyType:Xl[o]}}catch{return{keyBytes:t}}}function Lt(e,t){let n=e.startsWith("0x")?e.substring(2):e;return n.length%2!==0&&(n=`0${n}`),he.fromString(n.toLowerCase(),"base16")}function Co(e){return xr(he.fromString(e))}function Oi(e){return he.toString(fe(e))}function Ue(e){return he.toString(e,"base16")}function Ht(e){return BigInt("0x"+he.toString(e,"base16"))}function eh(e){return he.fromString(e,"utf-8")}function Ui({r:e,s:t,recoveryParam:n},r){const o=new Uint8Array(r?65:64);if(o.set(he.fromString(e,"base16"),0),o.set(he.fromString(t,"base16"),32),r){if(typeof n>"u")throw new Error("Signer did not return a recoveryParam");o[64]=n}return xr(o)}function th(e){const t=fe(e);if(t.length<64||t.length>65)throw new TypeError(`Wrong size for signature. Expected 64 or 65 bytes, but got ${t.length}`);const n=Ue(t.slice(0,32)),r=Ue(t.slice(32,64)),o=t.length===65?t[64]:void 0;return{r:n,s:r,recoveryParam:o}}function Le(e){const t=typeof e=="string"?rn(e):e;return al(t)}const nh=Al;function Ni(e){const t=rn(e.slice(2),"base16");return`0x${ur(nh(t).slice(-20),"base16")}`}function vr(e){return typeof e=="object"&&"r"in e&&"s"in e}function rh(){return function(t,n){try{return Promise.resolve(n(t)).then(function(r){return vr(r)?Ui(r):r})}catch(r){return Promise.reject(r)}}}function _o(e){return function(n,r){try{return Promise.resolve(r(n)).then(function(o){if(vr(o))return Ui(o,e);if(e&&typeof th(o).recoveryParam>"u")throw new Error("not_supported: ES256K-R not supported when signer doesn't provide a recovery param");return o})}catch(o){return Promise.reject(o)}}}function Bo(){return function(t,n){try{return Promise.resolve(n(t)).then(function(r){if(vr(r))throw new Error("invalid_config: expected a signer function that returns a string instead of signature object");return r})}catch(r){return Promise.reject(r)}}}const oh={ES256:rh(),ES256K:_o(),"ES256K-R":_o(!0),Ed25519:Bo(),EdDSA:Bo()};function sh(e){const t=oh[e];if(!t)throw new Error(`not_supported: Unsupported algorithm ${e}`);return t}function ih(e,t){const n=Ue(Ri(t).slice(0,1)),r=Lt(e),o=Ei(Le(r)),s=n+Ue(o),i=Le(Lt(s)),c=Le(i),a=Ue(c).substring(0,8),d=s+a;return Zl(Lt(d))}function ah(e,t){const n=bt.ProjectivePoint.fromHex(e).toRawBytes(),r=Ei(Le(n)),o=Io.toWords(r);return Io.encode(t,o).replace(t,"")}function ch(e,t){if(t){const n=t.split(":");switch(n[0]){case"bip122":n[n.length-1]=ih(e,n[n.length-1]);break;case"cosmos":n[n.length-1]=ah(e,n[1]);break;case"eip155":n[n.length-1]=Ni(e);break;default:return!1}return n.join(":").toLowerCase()===t.toLowerCase()}return!1}function dh(e,t=!1){const n=fe(e);if(n.length!==(t?65:64))throw new Error("wrong signature length");const r=Ue(n.slice(0,32)),o=Ue(n.slice(32,64)),s={r,s:o};return t&&(s.recoveryParam=n[64]),s}function Qn(e,t=!1){const n=fe(e);if(n.length!==(t?65:64))throw new Error("wrong signature length");return{compact:n.slice(0,64),recovery:n[64]}}function uh(e,t,n){const r=Le(e),o=Jt.Signature.fromCompact(Qn(t).compact),i=n.filter(c=>!c.ethereumAddress&&!c.blockchainAccountId).find(c=>{try{const{keyBytes:a}=cn(c);return Jt.verify(o,r,a)}catch{return!1}});if(!i)throw new Error("invalid_signature: Signature invalid for JWT");return i}function fh(e,t,n){const r=Le(e),o=bt.Signature.fromCompact(fe(t)).normalizeS(),s=n.filter(a=>!a.ethereumAddress&&!a.blockchainAccountId),i=n.filter(a=>a.ethereumAddress||a.blockchainAccountId);let c=s.find(a=>{try{const{keyBytes:d}=cn(a);return bt.verify(o,r,d)}catch{return!1}});if(!c&&i.length>0&&(c=Mi(e,t,i)),!c)throw new Error("invalid_signature: Signature invalid for JWT");return c}function Mi(e,t,n){const r=[];if(t.length>86)r.push(Qn(t,!0));else{const i=Qn(t,!1);r.push({...i,recovery:0}),r.push({...i,recovery:1})}const o=Le(e),s=i=>{const a=bt.Signature.fromCompact(i.compact).addRecoveryBit(i.recovery||0).recoverPublicKey(o),d=Ni(a.toHex(!1)).toLowerCase(),f=a.toHex(!1),l=a.toHex(!0);return n.find(u=>{const{keyBytes:b}=cn(u),h=Ue(b);return h===f||h===l||u.ethereumAddress?.toLowerCase()===d||u.blockchainAccountId?.split("@eip155")?.[0].toLowerCase()===d||ch(f,u.blockchainAccountId)})};for(const i of r){const c=s(i);if(c)return c}throw new Error("invalid_signature: Signature invalid for JWT")}function $o(e,t,n){const r=eh(e),o=fe(t),s=n.find(i=>{const{keyBytes:c,keyType:a}=cn(i);return a==="Ed25519"?ai.verify(o,r,c):!1});if(!s)throw new Error("invalid_signature: Signature invalid for JWT");return s}const lh={ES256:uh,ES256K:fh,"ES256K-R":Mi,Ed25519:$o,EdDSA:$o};function Pi(e){const t=lh[e];if(!t)throw new Error(`not_supported: Unsupported algorithm ${e}`);return t}Pi.toSignatureObject=dh;const L={INVALID_JWT:"invalid_jwt",INVALID_AUDIENCE:"invalid_config",INVALID_SIGNATURE:"invalid_signature",NO_SUITABLE_KEYS:"no_suitable_keys",NOT_SUPPORTED:"not_supported",RESOLVER_ERROR:"resolver_error"};function hh(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}const bh=function(e,{header:t,payload:n,data:r,signature:o},s,i){try{if(!s.conditionDelegated)throw new Error("Expected conditionDelegated");if(!i.resolver)throw new Error("Expected resolver");let c;const a=s.conditionDelegated;return Promise.resolve(ji(i.resolver,t.alg,a,i.proofPurpose)).then(function(d){let f;function l(p){if(c)return s;throw new Error(`${L.INVALID_SIGNATURE}: condition for authenticator ${s.id} is not met.`)}const u=d.didResolutionResult;if(!u?.didDocument)throw new Error(`${L.RESOLVER_ERROR}: Could not resolve delegated DID ${a}.`);const b=d.authenticators.find(p=>p.id===a);if(!b)throw new Error(`${L.NO_SUITABLE_KEYS}: Could not find delegated authenticator ${a} in it's DID Document`);const h=(function(){if(b.type===Sr)return Promise.resolve(Ar(e,{...i,didAuthenticator:{didResolutionResult:u,authenticators:[b],issuer:b.id}})).then(function({verified:p}){p&&(c=b)});try{c=kr({header:t,payload:n,data:r,signature:o},b)}catch(p){if(!p.message.startsWith("invalid_signature:"))throw p}})();return h&&h.then?h.then(l):l(h)})}catch(c){return Promise.reject(c)}},Ro=typeof Symbol<"u"?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function ae(e,t,n){if(!e.s){if(n instanceof Qe)if(n.s)t&1&&(t=n.s),n=n.v;else{n.o=ae.bind(null,e,t);return}if(n&&n.then){n.then(ae.bind(null,e,t),ae.bind(null,e,2));return}e.s=t,e.v=n;const r=e.o;r&&r(e)}}const Qe=(function(){function e(){}return e.prototype.then=function(t,n){const r=new e,o=this.s;if(o){const s=o&1?t:n;if(s){try{ae(r,1,s(this.v))}catch(i){ae(r,2,i)}return r}else return this}return this.o=function(s){try{const i=s.v;s.s&1?ae(r,1,t?t(i):i):n?ae(r,1,n(i)):ae(r,2,i)}catch(i){ae(r,2,i)}},r},e})();function Hi(e){return e instanceof Qe&&e.s&1}function ph(e,t,n){var r=-1,o,s;function i(c){try{for(;++r<e.length&&(!n||!n());)if(c=t(r),c&&c.then)if(Hi(c))c=c.v;else{c.then(i,s||(s=ae.bind(null,o=new Qe,2)));return}o?ae(o,1,c):o=c}catch(a){ae(o||(o=new Qe),2,a)}}return i(),o}const wh=function(e,{header:t,payload:n,data:r,signature:o},s,i){try{let c=function(b){if(a)return b;throw new Error(`${L.INVALID_SIGNATURE}: condition for authenticator ${s.id} is not met.`)},a;if(!s.conditionWeightedThreshold||!s.threshold)throw new Error("Expected conditionWeightedThreshold and threshold");const d=[],f=s.threshold;let l=0;const u=yh(s.conditionWeightedThreshold,function(b){function h(g){if(a)return g;if(E&&!d.includes(E.id)&&(d.push(E.id),l+=b.weight,l>=f))return a=1,s}const p=b.condition;let E;const w=hh(function(){if(p.type===Sr){if(!i.didAuthenticator)throw new Error("Expected didAuthenticator");const g={...i,didAuthenticator:{didResolutionResult:i.didAuthenticator?.didResolutionResult,authenticators:[p],issuer:p.id}};return Promise.resolve(Ar(e,g)).then(function({verified:y}){y&&(E=p)})}else return Promise.resolve(kr({header:t,payload:n,data:r,signature:o},p)).then(function(g){E=g})},function(g){if(!g.message.startsWith(L.INVALID_SIGNATURE))throw g});return w&&w.then?w.then(h):h(w)},function(){return a});return Promise.resolve(u&&u.then?u.then(c):c(u))}catch(c){return Promise.reject(c)}};function yh(e,t,n){if(typeof e[Ro]=="function"){let f=function(l){try{for(;!(o=r.next()).done&&(!n||!n());)if(l=t(o.value),l&&l.then)if(Hi(l))l=l.v;else{l.then(f,i||(i=ae.bind(null,s=new Qe,2)));return}s?ae(s,1,l):s=l}catch(u){ae(s||(s=new Qe),2,u)}};var r=e[Ro](),o,s,i;if(f(),r.return){var c=function(l){try{o.done||r.return()}catch{}return l};if(s&&s.then)return s.then(c,function(l){throw c(l)});c()}return s}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],d=0;d<e.length;d++)a.push(e[d]);return ph(a,function(f){return t(a[f])},n)}const gh=function(e,{header:t,payload:n,signature:r,data:o},s,i){try{if(s.conditionWeightedThreshold)return wh(e,{header:t,payload:n,data:o,signature:r},s,i);if(s.conditionDelegated)return bh(e,{header:t,payload:n,data:o,signature:r},s,i);throw new Error(`${L.INVALID_JWT}: conditional proof type did not find condition for authenticator ${s.id}.`)}catch(c){return Promise.reject(c)}},Oo=function(e,{header:t,payload:n,signature:r,data:o},s,i){try{return s.type===Sr?gh(e,{payload:n,header:t,signature:r,data:o},s,i):Promise.resolve(kr({header:t,payload:n,data:o,signature:r},[s]))}catch(c){return Promise.reject(c)}},Sr="ConditionalProof2022";function ie(e,t,n){if(!e.s){if(n instanceof wt)if(n.s)t&1&&(t=n.s),n=n.v;else{n.o=ie.bind(null,e,t);return}if(n&&n.then){n.then(ie.bind(null,e,t),ie.bind(null,e,2));return}e.s=t,e.v=n;const r=e.o;r&&r(e)}}const wt=(function(){function e(){}return e.prototype.then=function(t,n){const r=new e,o=this.s;if(o){const s=o&1?t:n;if(s){try{ie(r,1,s(this.v))}catch(i){ie(r,2,i)}return r}else return this}return this.o=function(s){try{const i=s.v;s.s&1?ie(r,1,t?t(i):i):n?ie(r,1,n(i)):ie(r,2,i)}catch(i){ie(r,2,i)}},r},e})();function st(e){return e instanceof wt&&e.s&1}function mh(e,t,n){var r=-1,o,s;function i(c){try{for(;++r<e.length&&(!n||!n());)if(c=t(r),c&&c.then)if(st(c))c=c.v;else{c.then(i,s||(s=ie.bind(null,o=new wt,2)));return}o?ie(o,1,c):o=c}catch(a){ie(o||(o=new wt),2,a)}}return i(),o}function Dh(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function Eh(e,t,n){for(var r;;){var o=e();if(st(o)&&(o=o.v),!o)return s;if(o.then){r=0;break}var s=n();if(s&&s.then)if(st(s))s=s.s;else{r=1;break}var i}var c=new wt,a=ie.bind(null,c,2);return(r===0?o.then(f):r===1?s.then(d):i.then(l)).then(void 0,a),c;function d(u){s=u;do{if(o=e(),!o||st(o)&&!o.v){ie(c,1,s);return}if(o.then){o.then(f).then(void 0,a);return}s=n(),st(s)&&(s=s.v)}while(!s||!s.then);s.then(d).then(void 0,a)}function f(u){u?(s=n(),s&&s.then?s.then(d).then(void 0,a):d(s)):ie(c,1,s)}function l(){(o=e())?o.then?o.then(f).then(void 0,a):f(o):ie(c,1,s)}}const ji=function(e,t,n,r){try{const o=Gl[t];if(!o||o.length===0)throw new Error(`${L.NOT_SUPPORTED}: No supported signature types for algorithm ${t}`);let s;return Promise.resolve(e.resolve(n,{accept:Uo})).then(function(i){if(Object.getOwnPropertyNames(i).indexOf("didDocument")===-1?s={didDocument:i,didDocumentMetadata:{},didResolutionMetadata:{contentType:Uo}}:s=i,s.didResolutionMetadata?.error||s.didDocument==null){const{error:f,message:l}=s.didResolutionMetadata;throw new Error(`${L.RESOLVER_ERROR}: Unable to resolve DID document for ${n}: ${f}, ${l||""}`)}const c=(f,l)=>{const u=f.filter(({id:b})=>l===b);return u.length>0?u[0]:null};let a=[...s?.didDocument?.verificationMethod||[],...s?.didDocument?.publicKey||[]];typeof r=="string"&&(r.startsWith("assertion")&&!Object.getOwnPropertyNames(s?.didDocument).includes("assertionMethod")&&(s.didDocument={...s.didDocument},s.didDocument.assertionMethod=[...a.map(f=>f.id)]),a=(s.didDocument[r]||[]).map(f=>typeof f=="string"?c(a,f):typeof f.publicKey=="string"?c(a,f.publicKey):f).filter(f=>f!=null));const d=a.filter(({type:f})=>o.find(l=>l===f));if(typeof r=="string"&&(!d||d.length===0))throw new Error(`${L.NO_SUITABLE_KEYS}: DID document for ${n} does not have public keys suitable for ${t} with ${r} purpose`);if(!d||d.length===0)throw new Error(`${L.NO_SUITABLE_KEYS}: DID document for ${n} does not have public keys for ${t}`);return{authenticators:d,issuer:n,didResolutionResult:s}})}catch(o){return Promise.reject(o)}},Ar=function(e,t={resolver:void 0,auth:void 0,audience:void 0,callbackUrl:void 0,skewTime:void 0,proofPurpose:void 0,policies:{},didAuthenticator:void 0}){try{let n=function(){let b;function h(g){if(E){const y=typeof t.policies?.now=="number"?t.policies.now:Math.floor(Date.now()/1e3),S=typeof t.skewTime<"u"&&t.skewTime>=0?t.skewTime:Ih,D=y+S;if(t.policies?.nbf!==!1&&r.nbf){if(r.nbf>D)throw new Error(`${L.INVALID_JWT}: JWT not valid before nbf: ${r.nbf}`)}else if(t.policies?.iat!==!1&&r.iat&&r.iat>D)throw new Error(`${L.INVALID_JWT}: JWT not valid yet (issued in the future) iat: ${r.iat}`);if(t.policies?.exp!==!1&&r.exp&&r.exp<=y-S)throw new Error(`${L.INVALID_JWT}: JWT has expired: exp: ${r.exp} < now: ${y}`);if(t.policies?.aud!==!1&&r.aud){if(!t.audience&&!t.callbackUrl)throw new Error(`${L.INVALID_AUDIENCE}: JWT audience is required but your app address has not been configured`);if(typeof(Array.isArray(r.aud)?r.aud:[r.aud]).find(A=>t.audience===A||t.callbackUrl===A)>"u")throw new Error(`${L.INVALID_AUDIENCE}: JWT audience does not match your DID or callback url`)}return{verified:!0,payload:r,didResolutionResult:l,issuer:f,signer:E,jwt:e,policies:t.policies}}throw new Error(`${L.INVALID_SIGNATURE}: JWT not valid. issuer DID document does not contain a verificationMethod that matches the signature.`)}const{did:p}=ki(a);let E=null;const w=(function(){if(p!==a){const g=d.find(y=>y.id===a);if(!g)throw new Error(`${L.INVALID_JWT}: No authenticator found for did URL ${a}`);return Promise.resolve(Oo(e,{payload:r,header:o,signature:s,data:i},g,t)).then(function(y){E=y})}else{let g=0;return Eh(function(){return!b&&!E&&g<d.length},void 0,function(){function y(m){g++}const S=d[g],D=Dh(function(){return Promise.resolve(Oo(e,{payload:r,header:o,signature:s,data:i},S,t)).then(function(m){E=m})},function(m){if(!m.message.includes(L.INVALID_SIGNATURE)||g===d.length-1)throw m});return D&&D.then?D.then(y):y(D)})}})();return w&&w.then?w.then(h):h(w)};if(!t.resolver)throw new Error("missing_resolver: No DID resolver has been configured");const{payload:r,header:o,signature:s,data:i}=dn(e,!1),c=Object.prototype.hasOwnProperty.call(t,"auth")?t.auth?"authentication":void 0:t.proofPurpose;let a;if(!r.iss&&!r.client_id)throw new Error(`${L.INVALID_JWT}: JWT iss or client_id are required`);if(t.didAuthenticator)a=t.didAuthenticator.issuer;else if(r.iss===Sh||r.iss===Ah){if(!r.sub)throw new Error(`${L.INVALID_JWT}: JWT sub is required`);typeof r.sub_jwk>"u"?a=r.sub:a=(o.kid||"").split("#")[0]}else if(r.iss===kh){if(!r.did)throw new Error(`${L.INVALID_JWT}: JWT did is required`);a=r.did}else if(!r.iss&&r.scope==="openid"&&r.redirect_uri){if(!r.client_id)throw new Error(`${L.INVALID_JWT}: JWT client_id is required`);a=r.client_id}else a=r.iss;if(!a)throw new Error(`${L.INVALID_JWT}: No DID has been found in the JWT`);let d,f,l;const u=(function(){if(t.didAuthenticator)({didResolutionResult:l,authenticators:d,issuer:f}=t.didAuthenticator);else return Promise.resolve(ji(t.resolver,o.alg,a,c)).then(function(b){({didResolutionResult:l,authenticators:d,issuer:f}=b),t.didAuthenticator={didResolutionResult:l,authenticators:d,issuer:f}})})();return Promise.resolve(u&&u.then?u.then(n):n(u))}catch(n){return Promise.reject(n)}},xh=function(e,{expiresIn:t,canonicalize:n},r){try{if(r.length===0)throw new Error("invalid_argument: must provide one or more issuers");let o=e,s="";const i=mh(r,function(c){const a=r[c],d={typ:"JWT",alg:a.alg};return c!==0&&(d.cty="JWT"),Promise.resolve(Li(o,{...a,canonicalize:n,expiresIn:t},d)).then(function(f){s=f,o={jwt:s}})});return Promise.resolve(i&&i.then?i.then(function(){return s}):s)}catch(o){return Promise.reject(o)}},Li=function(e,{issuer:t,signer:n,alg:r,expiresIn:o,canonicalize:s},i={}){try{if(!n)throw new Error("missing_signer: No Signer functionality has been configured");if(!t)throw new Error("missing_issuer: No issuing DID has been configured");i.typ||(i.typ="JWT"),i.alg||(i.alg=r);const c={iat:Math.floor(Date.now()/1e3),exp:void 0};if(o)if(typeof o=="number")c.exp=(e.nbf||c.iat)+Math.floor(o);else throw new Error("invalid_argument: JWT expiresIn is not a number");const a={...c,...e,iss:t};return vh(a,n,i,{canonicalize:s})}catch(c){return Promise.reject(c)}},vh=function(e,t,n={},r={}){try{n.alg||(n.alg=Th);const o=typeof e=="string"?e:No(e,r.canonicalize),s=[No(n,r.canonicalize),o].join("."),i=sh(n.alg);return Promise.resolve(i(s,t)).then(function(c){return[s,c].join(".")})}catch(o){return Promise.reject(o)}},Sh="https://self-issued.me/v2",Ah="https://self-issued.me/v2/openid-vc",kh="https://self-issued.me",Th="ES256K",Uo="application/did+json";function No(e,t=!1){return Co(t?Il(e):JSON.stringify(e))}const Ih=300;function Ch(e){const t=e.match(/^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)$/);if(t)return{header:JSON.parse(Oi(t[1])),payload:t[2],signature:t[3],data:`${t[1]}.${t[2]}`};throw new Error("invalid_argument: Incorrect format JWS")}function dn(e,t=!0){if(!e)throw new Error("invalid_argument: no JWT passed into decodeJWT");try{const n=Ch(e),r=Object.assign(n,{payload:JSON.parse(Oi(n.payload))}),o=r.payload.iss;if(r.header.cty==="JWT"&&t){const s=dn(r.payload.jwt);if(s.payload.iss!==o)throw new Error(`${L.INVALID_JWT}: multiple issuers`);return s}return r}catch(n){throw new Error(`invalid_argument: ${L.INVALID_JWT}: ${n}`)}}function kr({header:e,payload:t,data:n,signature:r},o){Array.isArray(o)||(o=[o]);const s=t.iss;let i=!0;do{if(s!==t.iss)throw new Error(`${L.INVALID_JWT}: multiple issuers`);try{return Pi(e.alg)(n,r,o)}catch(c){if(!c.message.startsWith(L.INVALID_SIGNATURE))throw c}e.cty!=="JWT"?i=!1:{payload:t,header:e,signature:r,data:n}=dn(t.jwt,!1)}while(i);throw new Error(`${L.INVALID_SIGNATURE}: no matching public key found`)}typeof Symbol<"u"&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")));var kn,Mo;function _h(){if(Mo)return kn;Mo=1;function e(t,n){for(let r=0;r<t.byteLength;r++){if(t[r]<n[r])return-1;if(t[r]>n[r])return 1}return t.byteLength>n.byteLength?1:t.byteLength<n.byteLength?-1:0}return kn=e,kn}var Tn,Po;function Bh(){if(Po)return Tn;Po=1;function e(t,n){n||(n=t.reduce((s,i)=>s+i.length,0));const r=new Uint8Array(n);let o=0;for(const s of t)r.set(s,o),o+=s.length;return r}return Tn=e,Tn}var In,Ho;function $h(){if(Ho)return In;Ho=1;function e(t,n){if(t===n)return!0;if(t.byteLength!==n.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==n[r])return!1;return!0}return In=e,In}const Rh=en(Cu);var Cn,jo;function Fi(){if(jo)return Cn;jo=1;const{bases:e}=Rh;function t(s,i,c,a){return{name:s,prefix:i,encoder:{name:s,prefix:i,encode:c},decoder:{decode:a}}}const n=t("utf8","u",s=>"u"+new TextDecoder("utf8").decode(s),s=>new TextEncoder().encode(s.substring(1))),r=t("ascii","a",s=>{let i="a";for(let c=0;c<s.length;c++)i+=String.fromCharCode(s[c]);return i},s=>{s=s.substring(1);const i=new Uint8Array(s.length);for(let c=0;c<s.length;c++)i[c]=s.charCodeAt(c);return i});return Cn={utf8:n,"utf-8":n,hex:e.base16,latin1:r,ascii:r,binary:r,...e},Cn}var _n,Lo;function Oh(){if(Lo)return _n;Lo=1;const e=Fi();function t(n,r="utf8"){const o=e[r];if(!o)throw new Error(`Unsupported encoding "${r}"`);return o.decoder.decode(`${o.prefix}${n}`)}return _n=t,_n}var Bn,Fo;function Uh(){if(Fo)return Bn;Fo=1;const e=Fi();function t(n,r="utf8"){const o=e[r];if(!o)throw new Error(`Unsupported encoding "${r}"`);return o.encoder.encode(n).substring(1)}return Bn=t,Bn}var $n,Vo;function Nh(){if(Vo)return $n;Vo=1;function e(t,n){if(t.length!==n.length)throw new Error("Inputs should have the same length");const r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t[o]^n[o];return r}return $n=e,$n}var Rn,Ko;function Mh(){if(Ko)return Rn;Ko=1;const e=_h(),t=Bh(),n=$h(),r=Oh(),o=Uh(),s=Nh();return Rn={compare:e,concat:t,equals:n,fromString:r,toString:o,xor:s},Rn}var Ft=Mh(),On,zo;function Ph(){if(zo)return On;zo=1,On=r;var e=128,t=-128,n=Math.pow(2,31);function r(o,s,i){if(Number.MAX_SAFE_INTEGER&&o>Number.MAX_SAFE_INTEGER)throw r.bytes=0,new RangeError("Could not encode varint");s=s||[],i=i||0;for(var c=i;o>=n;)s[i++]=o&255|e,o/=128;for(;o&t;)s[i++]=o&255|e,o>>>=7;return s[i]=o|0,r.bytes=i-c+1,s}return On}var Un,qo;function Hh(){if(qo)return Un;qo=1,Un=n;var e=128,t=127;function n(r,i){var s=0,i=i||0,c=0,a=i,d,f=r.length;do{if(a>=f||c>49)throw n.bytes=0,new RangeError("Could not decode varint");d=r[a++],s+=c<28?(d&t)<<c:(d&t)*Math.pow(2,c),c+=7}while(d>=e);return n.bytes=a-i,s}return Un}var Nn,Jo;function jh(){if(Jo)return Nn;Jo=1;var e=Math.pow(2,7),t=Math.pow(2,14),n=Math.pow(2,21),r=Math.pow(2,28),o=Math.pow(2,35),s=Math.pow(2,42),i=Math.pow(2,49),c=Math.pow(2,56),a=Math.pow(2,63);return Nn=function(d){return d<e?1:d<t?2:d<n?3:d<r?4:d<o?5:d<s?6:d<i?7:d<c?8:d<a?9:10},Nn}var Mn,Wo;function Tr(){return Wo||(Wo=1,Mn={encode:Ph(),decode:Hh(),encodingLength:jh()}),Mn}const Lh=en(jc),Fh=en(Bu),Vh=en(_u);var Pn,Zo;function Vi(){if(Zo)return Pn;Zo=1;const e=Tr(),{toString:t}=Fh,{fromString:n}=Vh;Pn={numberToUint8Array:o,uint8ArrayToNumber:r,varintUint8ArrayEncode:s,varintEncode:i};function r(c){return parseInt(t(c,"base16"),16)}function o(c){let a=c.toString(16);return a.length%2===1&&(a="0"+a),n(a,"base16")}function s(c){return Uint8Array.from(e.encode(r(c)))}function i(c){return Uint8Array.from(e.encode(c))}return Pn}var Hn,Go;function Kh(){return Go||(Go=1,Hn={baseTable:Object.freeze({identity:0,cidv1:1,cidv2:2,cidv3:3,ip4:4,tcp:6,sha1:17,"sha2-256":18,"sha2-512":19,"sha3-512":20,"sha3-384":21,"sha3-256":22,"sha3-224":23,"shake-128":24,"shake-256":25,"keccak-224":26,"keccak-256":27,"keccak-384":28,"keccak-512":29,blake3:30,dccp:33,"murmur3-128":34,"murmur3-32":35,ip6:41,ip6zone:42,path:47,multicodec:48,multihash:49,multiaddr:50,multibase:51,dns:53,dns4:54,dns6:55,dnsaddr:56,protobuf:80,cbor:81,raw:85,"dbl-sha2-256":86,rlp:96,bencode:99,"dag-pb":112,"dag-cbor":113,"libp2p-key":114,"git-raw":120,"torrent-info":123,"torrent-file":124,"leofcoin-block":129,"leofcoin-tx":130,"leofcoin-pr":131,sctp:132,"dag-jose":133,"dag-cose":134,"eth-block":144,"eth-block-list":145,"eth-tx-trie":146,"eth-tx":147,"eth-tx-receipt-trie":148,"eth-tx-receipt":149,"eth-state-trie":150,"eth-account-snapshot":151,"eth-storage-trie":152,"eth-receipt-log-trie":153,"eth-reciept-log":154,"bitcoin-block":176,"bitcoin-tx":177,"bitcoin-witness-commitment":178,"zcash-block":192,"zcash-tx":193,"caip-50":202,streamid:206,"stellar-block":208,"stellar-tx":209,md4:212,md5:213,bmt:214,"decred-block":224,"decred-tx":225,"ipld-ns":226,"ipfs-ns":227,"swarm-ns":228,"ipns-ns":229,zeronet:230,"secp256k1-pub":231,"bls12_381-g1-pub":234,"bls12_381-g2-pub":235,"x25519-pub":236,"ed25519-pub":237,"bls12_381-g1g2-pub":238,"dash-block":240,"dash-tx":241,"swarm-manifest":250,"swarm-feed":251,udp:273,"p2p-webrtc-star":275,"p2p-webrtc-direct":276,"p2p-stardust":277,"p2p-circuit":290,"dag-json":297,udt:301,utp:302,unix:400,thread:406,p2p:421,ipfs:421,https:443,onion:444,onion3:445,garlic64:446,garlic32:447,tls:448,noise:454,quic:460,ws:477,wss:478,"p2p-websocket-star":479,http:480,"swhid-1-snp":496,json:512,messagepack:513,"libp2p-peer-record":769,"libp2p-relay-rsvp":770,"car-index-sorted":1024,"sha2-256-trunc254-padded":4114,"ripemd-128":4178,"ripemd-160":4179,"ripemd-256":4180,"ripemd-320":4181,x11:4352,"p256-pub":4608,"p384-pub":4609,"p521-pub":4610,"ed448-pub":4611,"x448-pub":4612,"ed25519-priv":4864,"secp256k1-priv":4865,"x25519-priv":4866,kangarootwelve:7425,"sm3-256":21325,"blake2b-8":45569,"blake2b-16":45570,"blake2b-24":45571,"blake2b-32":45572,"blake2b-40":45573,"blake2b-48":45574,"blake2b-56":45575,"blake2b-64":45576,"blake2b-72":45577,"blake2b-80":45578,"blake2b-88":45579,"blake2b-96":45580,"blake2b-104":45581,"blake2b-112":45582,"blake2b-120":45583,"blake2b-128":45584,"blake2b-136":45585,"blake2b-144":45586,"blake2b-152":45587,"blake2b-160":45588,"blake2b-168":45589,"blake2b-176":45590,"blake2b-184":45591,"blake2b-192":45592,"blake2b-200":45593,"blake2b-208":45594,"blake2b-216":45595,"blake2b-224":45596,"blake2b-232":45597,"blake2b-240":45598,"blake2b-248":45599,"blake2b-256":45600,"blake2b-264":45601,"blake2b-272":45602,"blake2b-280":45603,"blake2b-288":45604,"blake2b-296":45605,"blake2b-304":45606,"blake2b-312":45607,"blake2b-320":45608,"blake2b-328":45609,"blake2b-336":45610,"blake2b-344":45611,"blake2b-352":45612,"blake2b-360":45613,"blake2b-368":45614,"blake2b-376":45615,"blake2b-384":45616,"blake2b-392":45617,"blake2b-400":45618,"blake2b-408":45619,"blake2b-416":45620,"blake2b-424":45621,"blake2b-432":45622,"blake2b-440":45623,"blake2b-448":45624,"blake2b-456":45625,"blake2b-464":45626,"blake2b-472":45627,"blake2b-480":45628,"blake2b-488":45629,"blake2b-496":45630,"blake2b-504":45631,"blake2b-512":45632,"blake2s-8":45633,"blake2s-16":45634,"blake2s-24":45635,"blake2s-32":45636,"blake2s-40":45637,"blake2s-48":45638,"blake2s-56":45639,"blake2s-64":45640,"blake2s-72":45641,"blake2s-80":45642,"blake2s-88":45643,"blake2s-96":45644,"blake2s-104":45645,"blake2s-112":45646,"blake2s-120":45647,"blake2s-128":45648,"blake2s-136":45649,"blake2s-144":45650,"blake2s-152":45651,"blake2s-160":45652,"blake2s-168":45653,"blake2s-176":45654,"blake2s-184":45655,"blake2s-192":45656,"blake2s-200":45657,"blake2s-208":45658,"blake2s-216":45659,"blake2s-224":45660,"blake2s-232":45661,"blake2s-240":45662,"blake2s-248":45663,"blake2s-256":45664,"skein256-8":45825,"skein256-16":45826,"skein256-24":45827,"skein256-32":45828,"skein256-40":45829,"skein256-48":45830,"skein256-56":45831,"skein256-64":45832,"skein256-72":45833,"skein256-80":45834,"skein256-88":45835,"skein256-96":45836,"skein256-104":45837,"skein256-112":45838,"skein256-120":45839,"skein256-128":45840,"skein256-136":45841,"skein256-144":45842,"skein256-152":45843,"skein256-160":45844,"skein256-168":45845,"skein256-176":45846,"skein256-184":45847,"skein256-192":45848,"skein256-200":45849,"skein256-208":45850,"skein256-216":45851,"skein256-224":45852,"skein256-232":45853,"skein256-240":45854,"skein256-248":45855,"skein256-256":45856,"skein512-8":45857,"skein512-16":45858,"skein512-24":45859,"skein512-32":45860,"skein512-40":45861,"skein512-48":45862,"skein512-56":45863,"skein512-64":45864,"skein512-72":45865,"skein512-80":45866,"skein512-88":45867,"skein512-96":45868,"skein512-104":45869,"skein512-112":45870,"skein512-120":45871,"skein512-128":45872,"skein512-136":45873,"skein512-144":45874,"skein512-152":45875,"skein512-160":45876,"skein512-168":45877,"skein512-176":45878,"skein512-184":45879,"skein512-192":45880,"skein512-200":45881,"skein512-208":45882,"skein512-216":45883,"skein512-224":45884,"skein512-232":45885,"skein512-240":45886,"skein512-248":45887,"skein512-256":45888,"skein512-264":45889,"skein512-272":45890,"skein512-280":45891,"skein512-288":45892,"skein512-296":45893,"skein512-304":45894,"skein512-312":45895,"skein512-320":45896,"skein512-328":45897,"skein512-336":45898,"skein512-344":45899,"skein512-352":45900,"skein512-360":45901,"skein512-368":45902,"skein512-376":45903,"skein512-384":45904,"skein512-392":45905,"skein512-400":45906,"skein512-408":45907,"skein512-416":45908,"skein512-424":45909,"skein512-432":45910,"skein512-440":45911,"skein512-448":45912,"skein512-456":45913,"skein512-464":45914,"skein512-472":45915,"skein512-480":45916,"skein512-488":45917,"skein512-496":45918,"skein512-504":45919,"skein512-512":45920,"skein1024-8":45921,"skein1024-16":45922,"skein1024-24":45923,"skein1024-32":45924,"skein1024-40":45925,"skein1024-48":45926,"skein1024-56":45927,"skein1024-64":45928,"skein1024-72":45929,"skein1024-80":45930,"skein1024-88":45931,"skein1024-96":45932,"skein1024-104":45933,"skein1024-112":45934,"skein1024-120":45935,"skein1024-128":45936,"skein1024-136":45937,"skein1024-144":45938,"skein1024-152":45939,"skein1024-160":45940,"skein1024-168":45941,"skein1024-176":45942,"skein1024-184":45943,"skein1024-192":45944,"skein1024-200":45945,"skein1024-208":45946,"skein1024-216":45947,"skein1024-224":45948,"skein1024-232":45949,"skein1024-240":45950,"skein1024-248":45951,"skein1024-256":45952,"skein1024-264":45953,"skein1024-272":45954,"skein1024-280":45955,"skein1024-288":45956,"skein1024-296":45957,"skein1024-304":45958,"skein1024-312":45959,"skein1024-320":45960,"skein1024-328":45961,"skein1024-336":45962,"skein1024-344":45963,"skein1024-352":45964,"skein1024-360":45965,"skein1024-368":45966,"skein1024-376":45967,"skein1024-384":45968,"skein1024-392":45969,"skein1024-400":45970,"skein1024-408":45971,"skein1024-416":45972,"skein1024-424":45973,"skein1024-432":45974,"skein1024-440":45975,"skein1024-448":45976,"skein1024-456":45977,"skein1024-464":45978,"skein1024-472":45979,"skein1024-480":45980,"skein1024-488":45981,"skein1024-496":45982,"skein1024-504":45983,"skein1024-512":45984,"skein1024-520":45985,"skein1024-528":45986,"skein1024-536":45987,"skein1024-544":45988,"skein1024-552":45989,"skein1024-560":45990,"skein1024-568":45991,"skein1024-576":45992,"skein1024-584":45993,"skein1024-592":45994,"skein1024-600":45995,"skein1024-608":45996,"skein1024-616":45997,"skein1024-624":45998,"skein1024-632":45999,"skein1024-640":46e3,"skein1024-648":46001,"skein1024-656":46002,"skein1024-664":46003,"skein1024-672":46004,"skein1024-680":46005,"skein1024-688":46006,"skein1024-696":46007,"skein1024-704":46008,"skein1024-712":46009,"skein1024-720":46010,"skein1024-728":46011,"skein1024-736":46012,"skein1024-744":46013,"skein1024-752":46014,"skein1024-760":46015,"skein1024-768":46016,"skein1024-776":46017,"skein1024-784":46018,"skein1024-792":46019,"skein1024-800":46020,"skein1024-808":46021,"skein1024-816":46022,"skein1024-824":46023,"skein1024-832":46024,"skein1024-840":46025,"skein1024-848":46026,"skein1024-856":46027,"skein1024-864":46028,"skein1024-872":46029,"skein1024-880":46030,"skein1024-888":46031,"skein1024-896":46032,"skein1024-904":46033,"skein1024-912":46034,"skein1024-920":46035,"skein1024-928":46036,"skein1024-936":46037,"skein1024-944":46038,"skein1024-952":46039,"skein1024-960":46040,"skein1024-968":46041,"skein1024-976":46042,"skein1024-984":46043,"skein1024-992":46044,"skein1024-1000":46045,"skein1024-1008":46046,"skein1024-1016":46047,"skein1024-1024":46048,"poseidon-bls12_381-a2-fc1":46081,"poseidon-bls12_381-a2-fc1-sc":46082,"zeroxcert-imprint-256":52753,"fil-commitment-unsealed":61697,"fil-commitment-sealed":61698,"holochain-adr-v0":8417572,"holochain-adr-v1":8483108,"holochain-key-v0":9728292,"holochain-key-v1":9793828,"holochain-sig-v0":10645796,"holochain-sig-v1":10711332,"skynet-ns":11639056,"arweave-ns":11704592})}),Hn}var jn,Yo;function zh(){if(Yo)return jn;Yo=1;const{baseTable:e}=Kh(),t=Vi().varintEncode,n={},r={},o={};for(const i in e){const c=i,a=e[c];n[c]=t(a);const d=c.toUpperCase().replace(/-/g,"_");r[d]=a,o[a]||(o[a]=c)}Object.freeze(n),Object.freeze(r),Object.freeze(o);const s=Object.freeze(e);return jn={nameToVarint:n,constantToCode:r,nameToCode:s,codeToName:o},jn}var Ln,Xo;function qh(){if(Xo)return Ln;Xo=1;const e=Tr(),{concat:t}=Lh,n=Vi(),{nameToVarint:r,constantToCode:o,nameToCode:s,codeToName:i}=zh();function c(D,m){let k;if(D instanceof Uint8Array)k=n.varintUint8ArrayEncode(D);else if(r[D])k=r[D];else throw new Error("multicodec not recognized");return t([k,m],k.length+m.length)}function a(D){return e.decode(D),D.slice(e.decode.bytes)}function d(D){const m=e.decode(D),k=i[m];if(k===void 0)throw new Error(`Code "${m}" not found`);return k}function f(D){return i[D]}function l(D){const m=s[D];if(m===void 0)throw new Error(`Codec "${D}" not found`);return m}function u(D){return e.decode(D)}function b(D){const m=r[D];if(m===void 0)throw new Error(`Codec "${D}" not found`);return m}function h(D){return n.varintEncode(D)}function p(D){return d(D)}function E(D){return f(D)}function w(D){return l(D)}function g(D){return u(D)}function y(D){return b(D)}function S(D){return Array.from(h(D))}return Ln={addPrefix:c,rmPrefix:a,getNameFromData:d,getNameFromCode:f,getCodeFromName:l,getCodeFromData:u,getVarintFromName:b,getVarintFromCode:h,getCodec:p,getName:E,getNumber:w,getCode:g,getCodeVarint:y,getVarint:S,...o,nameToVarint:r,nameToCode:s,codeToName:i},Ln}var Jh=qh();const Wh=nr(Jh);function Zh(e,t){const n=new Uint8Array(e.length+1);return n[0]=2+(t[t.length-1]&1),n.set(e,1),n}function Gh(e){const t=e.slice(0,e.length/2),n=e.slice(e.length/2,e.length),r=Ft.fromString(t,"base16"),o=Ft.fromString(n,"base16"),s=Zh(r,o);return Ft.toString(s,"base16")}function Yh(e){return e.slice(2)}function Xh(e,t){const n=Ft.fromString(t,"base16");return Qh(e,n)}function Qh(e,t){const n=Wh.addPrefix(e,t);return`did:key:${me.encode(n)}`}function Ki(e=0){return new Uint8Array(e)}function zi(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));const n=Ki(t);let r=0;for(const o of e)n.set(o,r),r+=o.length;return n}function e0(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function t0(e){return new TextEncoder().encode(e)}function n0(e){return new TextDecoder().decode(e)}function r0(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(n[i]!==255)throw new TypeError(s+" is ambiguous");n[i]=o}var c=e.length,a=e.charAt(0),d=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var p=0,E=0,w=0,g=h.length;w!==g&&h[w]===0;)w++,p++;for(var y=(g-w)*f+1>>>0,S=new Uint8Array(y);w!==g;){for(var D=h[w],m=0,k=y-1;(D!==0||m<E)&&k!==-1;k--,m++)D+=256*S[k]>>>0,S[k]=D%c>>>0,D=D/c>>>0;if(D!==0)throw new Error("Non-zero carry");E=m,w++}for(var A=y-E;A!==y&&S[A]===0;)A++;for(var T=a.repeat(p);A<y;++A)T+=e.charAt(S[A]);return T}function u(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var p=0;if(h[p]!==" "){for(var E=0,w=0;h[p]===a;)E++,p++;for(var g=(h.length-p)*d+1>>>0,y=new Uint8Array(g);h[p];){var S=n[h.charCodeAt(p)];if(S===255)return;for(var D=0,m=g-1;(S!==0||D<w)&&m!==-1;m--,D++)S+=c*y[m]>>>0,y[m]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");w=D,p++}if(h[p]!==" "){for(var k=g-w;k!==g&&y[k]===0;)k++;for(var A=new Uint8Array(E+(g-k)),T=E;k!==g;)A[T++]=y[k++];return A}}}function b(h){var p=u(h);if(p)return p;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:u,decode:b}}var o0=r0,s0=o0;class i0{name;prefix;baseEncode;constructor(t,n,r){this.name=t,this.prefix=n,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class a0{name;prefix;baseDecode;prefixCodePoint;constructor(t,n,r){this.name=t,this.prefix=n;const o=n.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=r}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return qi(this,t)}}class c0{decoders;constructor(t){this.decoders=t}or(t){return qi(this,t)}decode(t){const n=t[0],r=this.decoders[n];if(r!=null)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function qi(e,t){return new c0({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class d0{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,n,r,o){this.name=t,this.prefix=n,this.baseEncode=r,this.baseDecode=o,this.encoder=new i0(t,n,r),this.decoder=new a0(t,n,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}function un({name:e,prefix:t,encode:n,decode:r}){return new d0(e,t,n,r)}function At({name:e,prefix:t,alphabet:n}){const{encode:r,decode:o}=s0(n,e);return un({prefix:t,name:e,encode:r,decode:s=>e0(o(s))})}function u0(e,t,n,r){let o=e.length;for(;e[o-1]==="=";)--o;const s=new Uint8Array(o*n/8|0);let i=0,c=0,a=0;for(let d=0;d<o;++d){const f=t[e[d]];if(f===void 0)throw new SyntaxError(`Non-${r} character`);c=c<<n|f,i+=n,i>=8&&(i-=8,s[a++]=255&c>>i)}if(i>=n||(255&c<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function f0(e,t,n){const r=t[t.length-1]==="=",o=(1<<n)-1;let s="",i=0,c=0;for(let a=0;a<e.length;++a)for(c=c<<8|e[a],i+=8;i>n;)i-=n,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<n-i]),r)for(;(s.length*n&7)!==0;)s+="=";return s}function l0(e){const t={};for(let n=0;n<e.length;++n)t[e[n]]=n;return t}function te({name:e,prefix:t,bitsPerChar:n,alphabet:r}){const o=l0(r);return un({prefix:t,name:e,encode(s){return f0(s,r,n)},decode(s){return u0(s,o,n,e)}})}const h0=At({prefix:"9",name:"base10",alphabet:"0123456789"}),b0=Object.freeze(Object.defineProperty({__proto__:null,base10:h0},Symbol.toStringTag,{value:"Module"})),p0=te({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),w0=te({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),y0=Object.freeze(Object.defineProperty({__proto__:null,base16:p0,base16upper:w0},Symbol.toStringTag,{value:"Module"})),g0=te({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),m0=Object.freeze(Object.defineProperty({__proto__:null,base2:g0},Symbol.toStringTag,{value:"Module"})),Ji=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),D0=Ji.reduce((e,t,n)=>(e[n]=t,e),[]),E0=Ji.reduce((e,t,n)=>{const r=t.codePointAt(0);if(r==null)throw new Error(`Invalid character: ${t}`);return e[r]=n,e},[]);function x0(e){return e.reduce((t,n)=>(t+=D0[n],t),"")}function v0(e){const t=[];for(const n of e){const r=n.codePointAt(0);if(r==null)throw new Error(`Invalid character: ${n}`);const o=E0[r];if(o==null)throw new Error(`Non-base256emoji character: ${n}`);t.push(o)}return new Uint8Array(t)}const S0=un({prefix:"🚀",name:"base256emoji",encode:x0,decode:v0}),A0=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:S0},Symbol.toStringTag,{value:"Module"})),k0=te({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),T0=te({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),I0=te({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),C0=te({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_0=te({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),B0=te({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),$0=te({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),R0=te({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),O0=te({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),U0=Object.freeze(Object.defineProperty({__proto__:null,base32:k0,base32hex:_0,base32hexpad:$0,base32hexpadupper:R0,base32hexupper:B0,base32pad:I0,base32padupper:C0,base32upper:T0,base32z:O0},Symbol.toStringTag,{value:"Module"})),N0=At({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),M0=At({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),P0=Object.freeze(Object.defineProperty({__proto__:null,base36:N0,base36upper:M0},Symbol.toStringTag,{value:"Module"})),Wi=At({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),H0=At({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),j0=Object.freeze(Object.defineProperty({__proto__:null,base58btc:Wi,base58flickr:H0},Symbol.toStringTag,{value:"Module"})),L0=te({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),F0=te({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),V0=te({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),K0=te({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),z0=Object.freeze(Object.defineProperty({__proto__:null,base64:L0,base64pad:F0,base64url:V0,base64urlpad:K0},Symbol.toStringTag,{value:"Module"})),q0=te({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),J0=Object.freeze(Object.defineProperty({__proto__:null,base8:q0},Symbol.toStringTag,{value:"Module"})),W0=un({prefix:"\0",name:"identity",encode:e=>n0(e),decode:e=>t0(e)}),Z0=Object.freeze(Object.defineProperty({__proto__:null,identity:W0},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const Qo={...Z0,...m0,...J0,...b0,...y0,...U0,...P0,...j0,...z0,...A0};function Zi(e,t,n,r){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:n},decoder:{decode:r}}}const es=Zi("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Fn=Zi("ascii","a",e=>{let t="a";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t},e=>{e=e.substring(1);const t=Ki(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}),Gi={utf8:es,"utf-8":es,hex:Qo.base16,latin1:Fn,ascii:Fn,binary:Fn,...Qo};function G0(e,t="utf8"){const n=Gi[t];if(n==null)throw new Error(`Unsupported encoding "${t}"`);return n.decoder.decode(`${n.prefix}${e}`)}function xe(e,t="utf8"){const n=Gi[t];if(n==null)throw new Error(`Unsupported encoding "${t}"`);return n.encoder.encode(e).substring(1)}var Y0=Tr();const ts=nr(Y0);function X0(e,t){const n=`did:key:${t}`,r=`${n}#${t}`;return{id:n,verificationMethod:[{id:r,type:"Secp256k1VerificationKey2018",controller:n,publicKeyBase58:xe(e,"base58btc")}],authentication:[r],assertionMethod:[r],capabilityDelegation:[r],capabilityInvocation:[r]}}const Q0=Object.freeze(Object.defineProperty({__proto__:null,keyToDidDoc:X0},Symbol.toStringTag,{value:"Module"}));function eb(e){const t=new Uint8Array(e.length+2);return t[0]=236,t[1]=1,t.set(e,2),`z${xe(t,"base58btc")}`}function tb(e,t){const n=`did:key:${t}`,r=`${n}#${t}`,o=Nf(e),s=`${n}#${eb(o)}`;return{id:n,verificationMethod:[{id:r,type:"Ed25519VerificationKey2018",controller:n,publicKeyBase58:xe(e,"base58btc")}],authentication:[r],assertionMethod:[r],capabilityDelegation:[r],capabilityInvocation:[r],keyAgreement:[{id:s,type:"X25519KeyAgreementKey2019",controller:n,publicKeyBase58:xe(o,"base58btc")}]}}const nb=Object.freeze(Object.defineProperty({__proto__:null,keyToDidDoc:tb},Symbol.toStringTag,{value:"Module"})),et=of;function rb(e,t){const n=`did:key:${t}`,r=`${n}#${t}`,o=Jt.ProjectivePoint.fromHex(ob(e));return{id:n,verificationMethod:[{id:r,type:"JsonWebKey2020",controller:n,publicKeyJwk:{kty:"EC",crv:"P-256",x:xe(et(o.x),"base64url"),y:xe(et(o.y),"base64url")}}],authentication:[r],assertionMethod:[r],capabilityDelegation:[r],capabilityInvocation:[r]}}function ob(e){return e.length===64?zi([new Uint8Array([4]),e]):e}const sb=Object.freeze(Object.defineProperty({__proto__:null,keyToDidDoc:rb},Symbol.toStringTag,{value:"Module"}));const ib=sl;function ab(e,t){const n=`did:key:${t}`,r=`${n}#${t}`,o=ib.ProjectivePoint.fromHex(cb(e));return{id:n,verificationMethod:[{id:r,type:"JsonWebKey2020",controller:n,publicKeyJwk:{kty:"EC",crv:"P-384",x:xe(et(o.x),"base64url"),y:xe(et(o.y),"base64url")}}],authentication:[r],assertionMethod:[r],capabilityDelegation:[r],capabilityInvocation:[r]}}function cb(e){return e.length===96?zi([new Uint8Array([4]),e]):e}const db=Object.freeze(Object.defineProperty({__proto__:null,keyToDidDoc:ab},Symbol.toStringTag,{value:"Module"}));const ub=il;function fb(e,t){const n=`did:key:${t}`,r=`${n}#${t}`,o=ub.ProjectivePoint.fromHex(e);return{id:n,verificationMethod:[{id:r,type:"JsonWebKey2020",controller:n,publicKeyJwk:{kty:"EC",crv:"P-521",x:xe(et(o.x),"base64url"),y:xe(et(o.y),"base64url")}}],authentication:[r],assertionMethod:[r],capabilityDelegation:[r],capabilityInvocation:[r]}}const lb=Object.freeze(Object.defineProperty({__proto__:null,keyToDidDoc:fb},Symbol.toStringTag,{value:"Module"})),hb="application/did+ld+json",ns="application/did+json",bb={231:Q0,237:nb,4608:sb,4609:db,4610:lb};function pb(){return{key:async(e,t,n,r)=>{const o=r.accept||ns,s={didResolutionMetadata:{contentType:o},didDocument:null,didDocumentMetadata:{}};try{const i=Wi.decode(t.id),c=ts.decode(i),a=i.slice(ts.decode.bytes),d=await bb[c].keyToDidDoc(a,t.id);o===hb?(d["@context"]="https://w3id.org/did/v1",s.didDocument=d):o===ns?s.didDocument=d:(delete s.didResolutionMetadata.contentType,s.didResolutionMetadata.error="representationNotSupported")}catch(i){s.didResolutionMetadata.error="invalidDid",s.didResolutionMetadata.message=i.toString()}return s}}}const rs="ES256K",wb=/^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*$/,er="https://www.w3.org/2018/credentials/v1",tr="VerifiableCredential",yb="JwtProof2020",Yi=["evidence","termsOfUse","refreshService","credentialSchema","credentialStatus"];function le(e){return Array.isArray(e)?e:[e]}function yt(e){return Array.isArray(e)?e.map(t=>yt(t)):e instanceof Date?new Date(e.getTime()):e&&typeof e=="object"?Object.getOwnPropertyNames(e).reduce((t,n)=>(Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n)),t[n]=yt(e[n]),t),Object.create(Object.getPrototypeOf(e))):e}function Gt(e){return e!=null}function gb(e){if(typeof e!="object"||e===null)return e;const t={...e};return Object.keys(t).forEach(n=>t[n]===void 0&&delete t[n]),t}function mb(e){return typeof e=="object"&&e.sub&&e.iss&&e.claim&&e.iat}function Db(e){const{iat:t,nbf:n,claim:r,vc:o,...s}=e,i={...s,nbf:n||t,vc:{"@context":[er],type:[tr],credentialSubject:r}};return o&&(e.issVc=o),i}function Xi(e,t=!0){let n=yt(e);mb(e)&&(n=Db(e)),n.credentialSubject={...e.credentialSubject,...e.vc?.credentialSubject},e.sub&&!e.credentialSubject?.id&&n.credentialSubject&&(n.credentialSubject.id=e.sub,t&&delete n.sub),t&&delete n.vc?.credentialSubject,(typeof e.issuer>"u"||typeof e.issuer=="object")&&(n.issuer=gb({id:e.iss,...e.issuer}),t&&!e.issuer?.id&&delete n.iss),!e.id&&e.jti&&(n.id=n.id||n.jti,t&&delete n.jti);const r=[...le(n.type),...le(n.vc?.type)].filter(Gt);n.type=[...new Set(r)],t&&delete n.vc?.type;for(const s of Yi)e.vc&&e.vc[s]&&(n[s]||(n[s]=e.vc[s]),t&&delete n.vc[s]);const o=[...le(e.context),...le(e["@context"]),...le(e.vc?.["@context"])].filter(Gt);return n["@context"]=[...new Set(o)],t&&(delete n.context,delete n.vc?.["@context"]),!e.issuanceDate&&(e.iat||e.nbf)&&(n.issuanceDate=new Date((e.nbf||e.iat)*1e3).toISOString(),t&&(e.nbf?delete n.nbf:delete n.iat)),!e.expirationDate&&e.exp&&(n.expirationDate=new Date(e.exp*1e3).toISOString(),t&&delete n.exp),t&&n.vc&&Object.keys(n.vc).length===0&&delete n.vc,n}function os(e,t=!0){let n;try{n=dn(e)}catch{throw new TypeError("unknown credential format")}return{...Xi(n.payload,t),proof:{type:yb,jwt:e}}}function Qi(e,t=!0){if(typeof e=="string"){if(wb.test(e))return os(e,t);{let n;try{n=JSON.parse(e)}catch{throw new TypeError("unknown credential format")}return Qi(n,t)}}else return e.proof?.jwt?yt({...os(e.proof.jwt,t),proof:e.proof}):{proof:{},...Xi(e,t)}}function Eb(e,t=!0){if(Array.isArray(e.credentialSubject))throw Error("credentialSubject of type array not supported");const n=yt({vc:{...e.vc},...e});n.vc=n.vc;const r={...e.credentialSubject,...e.vc?.credentialSubject};e.sub||(n.sub=e.credentialSubject?.id,t&&delete r.id);const o=[...le(e.context),...le(e["@context"]),...le(e.vc?.["@context"])].filter(Gt);n.vc["@context"]=[...new Set(o)],t&&(delete n.context,delete n["@context"]);const s=[...le(e.type),...le(e.vc?.type)].filter(Gt);if(n.vc.type=[...new Set(s)],t&&delete n.type,e.id&&Object.getOwnPropertyNames(e).indexOf("jti")===-1&&(n.jti=e.id,t&&delete n.id),e.issuanceDate&&Object.getOwnPropertyNames(e).indexOf("nbf")===-1){const i=Date.parse(e.issuanceDate);isNaN(i)||(n.nbf=Math.floor(i/1e3),t&&delete n.issuanceDate)}if(e.expirationDate&&Object.getOwnPropertyNames(e).indexOf("exp")===-1){const i=Date.parse(e.expirationDate);isNaN(i)||(n.exp=Math.floor(i/1e3),t&&delete n.expirationDate)}e.issuer&&Object.getOwnPropertyNames(e).indexOf("iss")===-1&&(typeof e.issuer=="object"?(n.iss=e.issuer?.id,t&&(delete n.issuer.id,Object.keys(n.issuer).length===0&&delete n.issuer)):typeof e.issuer=="string"&&(n.iss=e.iss||""+e.issuer,t&&delete n.issuer)),n.vc.credentialSubject=r,t&&delete n.credentialSubject;for(const i of Yi)e[i]&&(n.vc[i]||(n.vc[i]=e[i]),t&&delete n[i]);return n}const gt={SCHEMA_ERROR:"schema_error"};function xb(e){return e&&!isNaN(e)&&Object.prototype.toString.call(e)==="[object Date]"}function mt(e){if(typeof e=="number"){if(!(Number.isInteger(e)&&e<1e11))throw new TypeError(`${gt.SCHEMA_ERROR}: "${e}" is not a unix timestamp in seconds`)}else if(typeof e=="string")mt(Math.floor(new Date(e).valueOf()/1e3));else if(!xb(e))throw new TypeError(`${gt.SCHEMA_ERROR}: "${e}" is not a valid time`)}function ea(e){const t=le(e);if(t.length<1||t.indexOf(er)===-1)throw new TypeError(`${gt.SCHEMA_ERROR}: @context is missing default context "${er}"`)}function ta(e){const t=le(e);if(t.length<1||t.indexOf(tr)===-1)throw new TypeError(`${gt.SCHEMA_ERROR}: type is missing default "${tr}"`)}function na(e){if(Object.keys(e).length===0)throw new TypeError(`${gt.SCHEMA_ERROR}: credentialSubject must not be empty`)}const vb=function(e,t,n={}){try{const r=n?.policies?.issuanceDate===!1?!1:void 0,o=n?.policies?.expirationDate===!1?!1:void 0;return n={...n,policies:{...n?.policies,nbf:r,exp:o,iat:r}},Promise.resolve(Ar(e,{resolver:t,...n})).then(function(s){return s.verifiableCredential=Qi(s.jwt,n?.removeOriginalFields),n?.policies?.format!==!1&&kb(s.verifiableCredential),s})}catch(r){return Promise.reject(r)}},Sb=function(e,t,n={}){try{const r={iat:void 0,...Eb(e,n.removeOriginalFields)};if(Ab(r),Array.isArray(t)){const o=t[0].did,s=[];for(const i of t){if(i.did!==o)throw new Error("All issuers must be the same did to comply with the Verifiable Conditions spec");s.push({issuer:i.did||r.iss||"",signer:i.signer,alg:i.alg||n.header?.alg||rs})}return Promise.resolve(xh(r,{...n},s))}else return Promise.resolve(Li(r,{...n,issuer:t.did||r.iss||"",signer:t.signer},{...n.header,alg:t.alg||n.header?.alg||rs}))}catch(r){return Promise.reject(r)}};function Ab(e){ea(e.vc["@context"]),ta(e.vc.type),na(e.vc.credentialSubject),e.nbf&&mt(e.nbf),e.exp&&mt(e.exp)}function kb(e){ea(e["@context"]),ta(e.type),na(e.credentialSubject),e.issuanceDate&&mt(e.issuanceDate),e.expirationDate&&mt(e.expirationDate)}function Tb(e){const t=e.split(":");if(!e.startsWith("did:pkh:")||t.length!==5)throw new Error("Invalid pkh did");const[,,n,r,o]=t;if(!o.startsWith("0x"))throw new Error(`Invalid address: ${o}`);const s=Number(r);if(isNaN(s))throw new Error(`Invalid chain id: ${r}`);return{chainId:s,networkId:n,address:o}}async function Ib(e){try{const t=parseInt(String(Date.now()/1e3)),n=await vb(e,Cb(),{policies:{now:parseInt(String(Date.now()/1e3)),expirationDate:!0,issuanceDate:!0}});return n.payload.exp&&n.payload.exp<t?!1:n}catch(t){return console.error(t),!1}}async function ra(e,t,n,r,o){const s={sub:r.did,vc:{"@context":["https://www.w3.org/2018/credentials/v1"],type:["VerifiableCredential"],credentialSubject:{chainId:e,networkId:t,address:n}},aud:o?.aud};return await Sb(s,r,{expiresIn:o?.expiresIn})}const Cb=()=>{const e=pb();if(!e)throw new Error("Failed to get key resolver");return new Fl(e)};class pe{static#e="browserKeyDB";static#t="keyPairs";static#n="keyPair";#o;constructor(){this.#o=this.#r()}#r(){return new Promise((t,n)=>{const r=indexedDB.open(pe.#e);r.onupgradeneeded=this.#s,r.onsuccess=()=>this.#c(r.result,t,n),r.onerror=()=>n(r.error)})}#s=t=>{const n=t.target.result;this.#a(n)};#c=(t,n,r)=>{if(t.objectStoreNames.contains(pe.#t))n(t);else{const o=t.version;t.close();const s=indexedDB.open(pe.#e,o+1);s.onupgradeneeded=this.#s,s.onsuccess=()=>n(s.result),s.onerror=()=>r(s.error)}};#a(t){t.objectStoreNames.contains(pe.#t)||t.createObjectStore(pe.#t)}async#i(t="readwrite"){return(await this.#o).transaction(pe.#t,t).objectStore(pe.#t)}async saveKeyPair(t){const r=(await this.#i()).put(t,pe.#n);return new Promise((o,s)=>{r.onsuccess=()=>{o()},r.onerror=()=>{s(new Error("Failed to save key pair"))}})}async loadKeyPair(){const n=(await this.#i("readonly")).get(pe.#n);return new Promise((r,o)=>{n.onsuccess=()=>{const s=n.result;r(s)},n.onerror=()=>{o(new Error("Failed to load key pair"))}})}}const _b="eip155",Bb=1;function $b(e){return Array.prototype.map.call(new Uint8Array(e),t=>("00"+t.toString(16)).slice(-2)).join("")}class Ze{#e;#t;#n;#o;#r;static algorithm={name:"ECDSA",namedCurve:"P-256"};static signAlgorithm={name:"ECDSA",namedCurve:"P-256",hash:"SHA-256"};constructor(t,n=globalThis.crypto.subtle){this.#n=t,this.#e=n,this.#o=this.#s()}async#s(){const t=await this.#n.loadKeyPair();return t?this.#t=await this.#d(t):(this.#t=await this.#a(),await this.#n.saveKeyPair(await this.#i())),await this.#c()}async getBearerToken(t,n,r=!1,o){const s=await this.getIssuer();if((r||!this.#r)&&(this.#r=await ra(Number(Bb),_b,n||await this.#o,s,o)),!this.#r)throw new Error("Could not create bearer token");return this.#r}did(){return this.#o}async regenerateDid(){this.#t=await this.#a(),await this.#n.saveKeyPair(await this.#i())}async#c(){if(!this.#t)throw new Error("No key pair available");const t=await this.#e.exportKey("raw",this.#t.publicKey),n="p256-pub",r=Yh($b(t)),o=Gh(r);return Xh(n,o)}async#a(){return await this.#e.generateKey(Ze.algorithm,!0,["sign","verify"])}async#i(){if(!this.#t)throw new Error("No key pair available");return{publicKey:await this.#e.exportKey("jwk",this.#t.publicKey),privateKey:await this.#e.exportKey("jwk",this.#t.privateKey)}}async#d(t){return{publicKey:await this.#e.importKey("jwk",t.publicKey,Ze.algorithm,!0,["verify"]),privateKey:await this.#e.importKey("jwk",t.privateKey,Ze.algorithm,!0,["sign"])}}#f=async(...t)=>await this.#e.sign(...t);#l=async(...t)=>await this.#e.verify(...t);#u(t){return G0(t,"utf-8")}async sign(t){if(this.#t?.privateKey){const n=typeof t=="string"?this.#u(t):t,r=await this.#e.sign(Ze.signAlgorithm,this.#t.privateKey,n.buffer);return new Uint8Array(r)}else throw new Error("No private key available")}async getIssuer(){if(!this.#t?.privateKey)throw new Error("No private key available");return{did:await this.#o,signer:async t=>{const n=await this.sign(typeof t=="string"?new TextEncoder().encode(t):t);return xr(n)},alg:"ES256"}}}const Rb="https://auth.renown.id";class Ob{#e;#t;#n;#o;constructor(t,n,r,o=Rb){this.#t=t,this.#o=n,this.#n=r,this.#e=o,this.user&&this.login(this.user.did).catch(()=>{})}get user(){return this.#t.get("user")}#r(t){t?this.#t.set("user",t):this.#t.delete("user"),this.#o.emit("user",t)}set connectId(t){this.#n=t;const n=this.user;this.#r(void 0),n&&this.login(n.did).catch(r=>{console.log("User no longer authenticated:",r)})}async login(t){try{const n=Tb(t),r=await this.#s(n.address,n.chainId,this.#n);if(!r)throw this.#r(void 0),new Error("Credential not found");const o={...n,did:t,credential:r};return this.#r(o),o}catch(n){throw this.#r(void 0),n}}logout(){return this.#r(void 0),Promise.resolve()}on(t,n){return this.#o.on(t,n)}async#s(t,n,r){if(!this.#e)throw new Error("RENOWN_URL is not set");const o=new URL(`/api/auth/credential?address=${encodeURIComponent(t)}&chainId=${encodeURIComponent(n)}&connectId=${encodeURIComponent(r)}`,this.#e),s=await fetch(o,{method:"GET"});if(s.ok)return(await s.json()).credential;throw new Error("Failed to get credential")}async verifyBearerToken(t){return Ib(t)}async createBearerToken(t,n,r,o){if(!this.user)throw new Error("User not found");return ra(n,this.#n,t,r,o)}}class ss extends CustomEvent{constructor(t,n){super(t,{detail:n})}}class Ub{#e=new EventTarget;on(t,n){const r=o=>{o instanceof ss&&n(o.detail)};return this.#e.addEventListener(t.toString(),r),()=>{this.#e.removeEventListener(t.toString(),r)}}emit(t,n){const r=new ss(t.toString(),n);this.#e.dispatchEvent(r)}}class Nb{namespace;constructor(t){this.namespace=t}}class Mb extends Nb{constructor(t,n){super(`${n}:${t}`)}#e(t){return`${this.namespace}:${t.toString()}`}get(t){const n=localStorage.getItem(this.#e(t));if(n)return JSON.parse(n)}set(t,n){return n?localStorage.setItem(this.#e(t),JSON.stringify(n)):localStorage.removeItem(this.#e(t))}delete(t){return localStorage.removeItem(this.#e(t))}}function aw(e,t,n){return new Ob(new Mb("renown",t),new Ub,e,n)}const Ir=_("drives"),oa=Ir.useValue,Pb=Ir.setValue,Hb=Ir.addEventHandler;function jb(e){return e.reduce((t,n)=>(n.status==="fulfilled"?t.push(n.value):console.warn(n.reason),t),[])}function cw(e){if(!e)return"PUBLIC";const t="readContext"in e,{sharingType:n}=t?{sharingType:"PUBLIC"}:e.state.local,r=n?.toUpperCase();return r==="PRIVATE"?"LOCAL":r}function dw(e){if(!e)return!1;const t="readContext"in e,{availableOffline:n}=t?{availableOffline:!1}:e.state.local;return n??!1}async function Lb(e){if(!e)return[];const t=await e.getDrives(),n=await Promise.allSettled(t.map(r=>e.getDrive(r)));return jb(n)}function uw(e,t){if(t==="LOCAL")return;const n=window.ph?.reactor;if(n)try{const r=n.getSyncStatus(e);return r instanceof Ja?"INITIAL_SYNC":r}catch(r){return console.error(r),"ERROR"}}function Fb(e){return e?.state.local.triggers.find(t=>t.type==="PullResponder")}function sa(e){return Fb(e)?.data?.url}function ia(e){if(!e)return;const t=sa(e);if("remoteUrl"in e.state.global){const n=e.state.global.remoteUrl;if(typeof n=="string")return n}return t}function Vb(e){const t=ia(e),n=sa(e);return t!==void 0||n!==void 0}const fw=(e={})=>{const t=e.defaultDrivesUrl||[];return{defaultDrives:{remoteDrives:t.map(r=>({url:r,options:{sharingType:"PUBLIC",availableOffline:!0,listeners:[{block:!0,callInfo:{data:r,name:"switchboard-push",transmitterType:"SwitchboardPush"},filter:{branch:["main"],documentId:["*"],documentType:["*"],scope:["global"]},label:"Switchboard Sync",listenerId:"1",system:!0}],triggers:[]}})),removeOldRemoteDrives:t.length>0?{strategy:"preserve-by-url-and-detach",urls:t}:{strategy:"preserve-all"}}}},Kb=200,zb=1e3;async function is(e){if(!e)return;const t=await Lb(e);Pb(t)}function qb(e=Kb,t=zb){let n=null,r=0;return(o,s=!1)=>{const i=Date.now(),c=i-r;return n!==null&&clearTimeout(n),s||c>=t?(r=i,is(o)):new Promise(a=>{n=setTimeout(()=>{r=Date.now(),is(o).then(a)},e)})}}const lw=qb();async function hw(e,t,n){await Jb(e,t,n);const o=(await e.initialize())?.at(0);if(o)throw o}async function Jb(e,t,n){let r=t?.user;r instanceof Function&&(r=await r()),!(!n||!r)&&e.setGenerateJwtHandler(async o=>n.getBearerToken(o,r.address,!0,{expiresIn:10}))}async function bw(){const e=new Ze(new pe);return await e.did(),e}function aa(e){switch(e.status){case"pending":return{status:"pending"};case"fulfilled":return{status:"fulfilled",value:e.value};case"rejected":return{status:"rejected",reason:e.reason};default:return e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t}),e.catch(t=>{e.status="rejected",e.reason=t}),aa(e)}}function pw(e){const t=new Map;return e.on("documentDeleted",n=>{t.delete(n)}),{get(n,r){const o=t.get(n);if(o&&(aa(o).status==="pending"||!r))return o;const s=e.getDocument(n);return t.set(n,s),s},subscribe(n,r){const o=Array.isArray(n)?n:[n];return e.on("operationsAdded",s=>{o.includes(s)&&this.get(s,!0).then(()=>r()).catch(()=>{console.warn("Failed to refetch document",s)})})}}}const Cr=_("documentCache"),Wb=Cr.useValue,ww=Cr.setValue,Zb=Cr.addEventHandler;function Gb(e){const t=Wb(),n=Ne.useSyncExternalStore(r=>e&&t?t.subscribe(e,r):()=>{},()=>e?t?.get(e):void 0);return n?Ne.use(n):void 0}function ca(e){const t=Gb(e),[,n]=ar(t);return[t,n]}let Vt;typeof window<"u"?window.btoa?Vt=function(e){return btoa(unescape(encodeURIComponent(e)))}:Vt=function(e){const t=unescape(encodeURIComponent(e+""));let n="";for(let r,o,s=0,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";t.charAt(s|0)||(i="=",s%1);n+=i.charAt(63&r>>8-s%1*8)){if(o=t.charCodeAt(s+=3/4),o>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");r=r<<8|o}return n}:Vt=function(e){return Buffer.from(e).toString("base64")};function F(e,t){let n=as(e,t);return(t&&t.fallback!==void 0?t.fallback:F.defaults.fallback)===!0&&n===""&&(n=as(Vt(e),t)),n}const da={bg:{Й:"Y",й:"y",X:"H",x:"h",Ц:"Ts",ц:"ts",Щ:"Sht",щ:"sht",Ъ:"A",ъ:"a",Ь:"Y",ь:"y"},de:{Ä:"AE",ä:"ae",Ö:"OE",ö:"oe",Ü:"UE",ü:"ue"},sr:{đ:"dj",Đ:"DJ"},uk:{И:"Y",и:"y",Й:"Y",й:"y",Ц:"Ts",ц:"ts",Х:"Kh",х:"kh",Щ:"Shch",щ:"shch",Г:"H",г:"h"}};let _r={};function as(e,t){if(typeof e!="string")throw new Error("slug() requires a string argument, received "+typeof e);if(!e.isWellFormed())throw new Error("slug() received a malformed string with lone surrogates");typeof t=="string"&&(t={replacement:t}),t=t?Object.assign({},t):{},t.mode=t.mode||F.defaults.mode;const n=F.defaults.modes[t.mode],r=["replacement","multicharmap","charmap","remove","lower","trim"];for(let a,d=0,f=r.length;d<f;d++)a=r[d],t[a]=a in t?t[a]:n[a];const o=da[t.locale]||_r;let s=[];for(const a in t.multicharmap){if(!Object.prototype.hasOwnProperty.call(t.multicharmap,a))continue;const d=a.length;s.indexOf(d)===-1&&s.push(d)}s=s.sort(function(a,d){return d-a});const i=t.mode==="rfc3986"?/[^\w\s\-.~]/:/[^A-Za-z0-9\s]/;let c="";for(let a,d=0,f=e.length;d<f;d++){a=e[d];let l=!1;for(let u=0;u<s.length;u++){const b=s[u],h=e.substr(d,b);if(t.multicharmap[h]){d+=b-1,a=t.multicharmap[h],l=!0;break}}l||(o[a]?a=o[a]:t.charmap[a]?a=t.charmap[a].replace(t.replacement," "):a.includes(t.replacement)?a=a.replace(t.replacement," "):a=a.replace(i,"")),c+=a}return t.remove&&(c=c.replace(t.remove,"")),t.trim&&(c=c.trim()),c=c.replace(/\s+/g,t.replacement),t.lower&&(c=c.toLowerCase()),c}const ua={फ़:"Fi",ग़:"Ghi",ख़:"Khi",क़:"Qi",ड़:"ugDha",ढ़:"ugDhha",य़:"Yi",ज़:"Za",בִי:"i",בֵ:"e",בֵי:"e",בֶ:"e",בַ:"a",בָ:"a",בֹ:"o",וֹ:"o",בֻ:"u",וּ:"u",בּ:"b",כּ:"k",ךּ:"k",פּ:"p",שׁ:"sh",שׂ:"s",בְ:"e",חֱ:"e",חֲ:"a",חֳ:"o",בִ:"i"},fa={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",Æ:"AE",Ç:"C",È:"E",É:"E",Ê:"E",Ë:"E",Ì:"I",Í:"I",Î:"I",Ï:"I",Ð:"D",Ñ:"N",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ő:"O",Ø:"O",Ō:"O",Ù:"U",Ú:"U",Û:"U",Ü:"U",Ű:"U",Ý:"Y",Þ:"TH",ß:"ss",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",æ:"ae",ç:"c",è:"e",é:"e",ê:"e",ë:"e",ì:"i",í:"i",î:"i",ï:"i",ð:"d",ñ:"n",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ő:"o",ø:"o",ō:"o",Œ:"OE",œ:"oe",ù:"u",ú:"u",û:"u",ü:"u",ű:"u",ý:"y",þ:"th",ÿ:"y","ẞ":"SS",α:"a",β:"b",γ:"g",δ:"d",ε:"e",ζ:"z",η:"h",θ:"th",ι:"i",κ:"k",λ:"l",μ:"m",ν:"n",ξ:"3",ο:"o",π:"p",ρ:"r",σ:"s",τ:"t",υ:"y",φ:"f",χ:"x",ψ:"ps",ω:"w",ά:"a",έ:"e",ί:"i",ό:"o",ύ:"y",ή:"h",ώ:"w",ς:"s",ϊ:"i",ΰ:"y",ϋ:"y",ΐ:"i",Α:"A",Β:"B",Γ:"G",Δ:"D",Ε:"E",Ζ:"Z",Η:"H",Θ:"Th",Ι:"I",Κ:"K",Λ:"L",Μ:"M",Ν:"N",Ξ:"3",Ο:"O",Π:"P",Ρ:"R",Σ:"S",Τ:"T",Υ:"Y",Φ:"F",Χ:"X",Ψ:"PS",Ω:"W",Ά:"A",Έ:"E",Ί:"I",Ό:"O",Ύ:"Y",Ή:"H",Ώ:"W",Ϊ:"I",Ϋ:"Y",ş:"s",Ş:"S",ı:"i",İ:"I",ğ:"g",Ğ:"G",а:"a",б:"b",в:"v",г:"g",д:"d",е:"e",ё:"yo",ж:"zh",з:"z",и:"i",й:"j",к:"k",л:"l",м:"m",н:"n",о:"o",п:"p",р:"r",с:"s",т:"t",у:"u",ф:"f",х:"h",ц:"c",ч:"ch",ш:"sh",щ:"sh",ъ:"u",ы:"y",ь:"",э:"e",ю:"yu",я:"ya",А:"A",Б:"B",В:"V",Г:"G",Д:"D",Е:"E",Ё:"Yo",Ж:"Zh",З:"Z",И:"I",Й:"J",К:"K",Л:"L",М:"M",Н:"N",О:"O",П:"P",Р:"R",С:"S",Т:"T",У:"U",Ф:"F",Х:"H",Ц:"C",Ч:"Ch",Ш:"Sh",Щ:"Sh",Ъ:"U",Ы:"Y",Ь:"",Э:"E",Ю:"Yu",Я:"Ya",Є:"Ye",І:"I",Ї:"Yi",Ґ:"G",є:"ye",і:"i",ї:"yi",ґ:"g",č:"c",ď:"d",ě:"e",ň:"n",ř:"r",š:"s",ť:"t",ů:"u",ž:"z",Č:"C",Ď:"D",Ě:"E",Ň:"N",Ř:"R",Š:"S",Ť:"T",Ů:"U",Ž:"Z",ľ:"l",ĺ:"l",ŕ:"r",Ľ:"L",Ĺ:"L",Ŕ:"R",ą:"a",ć:"c",ę:"e",ł:"l",ń:"n",ś:"s",ź:"z",ż:"z",Ą:"A",Ć:"C",Ę:"E",Ł:"L",Ń:"N",Ś:"S",Ź:"Z",Ż:"Z",ā:"a",ē:"e",ģ:"g",ī:"i",ķ:"k",ļ:"l",ņ:"n",ū:"u",Ā:"A",Ē:"E",Ģ:"G",Ī:"I",Ķ:"K",Ļ:"L",Ņ:"N",Ū:"U",أ:"a",إ:"i",ب:"b",ت:"t",ث:"th",ج:"g",ح:"h",خ:"kh",د:"d",ذ:"th",ر:"r",ز:"z",س:"s",ش:"sh",ص:"s",ض:"d",ط:"t",ظ:"th",ع:"aa",غ:"gh",ف:"f",ق:"k",ك:"k",ل:"l",م:"m",ن:"n",ه:"h",و:"o",ي:"y",ء:"aa",ة:"a",آ:"a",ا:"a",پ:"p",ژ:"zh",گ:"g",چ:"ch",ک:"k",ی:"i",ė:"e",į:"i",ų:"u",Ė:"E",Į:"I",Ų:"U",ț:"t",Ț:"T",ţ:"t",Ţ:"T",ș:"s",Ș:"S",ă:"a",Ă:"A",Ạ:"A",Ả:"A",Ầ:"A",Ấ:"A",Ậ:"A",Ẩ:"A",Ẫ:"A",Ằ:"A",Ắ:"A",Ặ:"A",Ẳ:"A",Ẵ:"A",Ẹ:"E",Ẻ:"E",Ẽ:"E",Ề:"E",Ế:"E",Ệ:"E",Ể:"E",Ễ:"E",Ị:"I",Ỉ:"I",Ĩ:"I",Ọ:"O",Ỏ:"O",Ồ:"O",Ố:"O",Ộ:"O",Ổ:"O",Ỗ:"O",Ơ:"O",Ờ:"O",Ớ:"O",Ợ:"O",Ở:"O",Ỡ:"O",Ụ:"U",Ủ:"U",Ũ:"U",Ư:"U",Ừ:"U",Ứ:"U",Ự:"U",Ử:"U",Ữ:"U",Ỳ:"Y",Ỵ:"Y",Ỷ:"Y",Ỹ:"Y",Đ:"D",ạ:"a",ả:"a",ầ:"a",ấ:"a",ậ:"a",ẩ:"a",ẫ:"a",ằ:"a",ắ:"a",ặ:"a",ẳ:"a",ẵ:"a",ẹ:"e",ẻ:"e",ẽ:"e",ề:"e",ế:"e",ệ:"e",ể:"e",ễ:"e",ị:"i",ỉ:"i",ĩ:"i",ọ:"o",ỏ:"o",ồ:"o",ố:"o",ộ:"o",ổ:"o",ỗ:"o",ơ:"o",ờ:"o",ớ:"o",ợ:"o",ở:"o",ỡ:"o",ụ:"u",ủ:"u",ũ:"u",ư:"u",ừ:"u",ứ:"u",ự:"u",ử:"u",ữ:"u",ỳ:"y",ỵ:"y",ỷ:"y",ỹ:"y",đ:"d",Ә:"AE",ә:"ae",Ғ:"GH",ғ:"gh",Қ:"KH",қ:"kh",Ң:"NG",ң:"ng",Ү:"UE",ү:"ue",Ұ:"U",ұ:"u",Һ:"H",һ:"h",Ө:"OE",ө:"oe",ђ:"dj",ј:"j",љ:"lj",њ:"nj",ћ:"c",џ:"dz",Ђ:"Dj",Ј:"j",Љ:"Lj",Њ:"Nj",Ћ:"C",Џ:"Dz",nj:"nj",lj:"lj",Nj:"NJ",Lj:"LJ",अ:"a",आ:"aa",ए:"e",ई:"ii",ऍ:"ei",ऎ:"ae",ऐ:"ai",इ:"i",ओ:"o",ऑ:"oi",ऒ:"oii",ऊ:"uu",औ:"ou",उ:"u",ब:"B",भ:"Bha",च:"Ca",छ:"Chha",ड:"Da",ढ:"Dha",फ:"Fa",ग:"Ga",घ:"Gha",ग़:"Ghi",ह:"Ha",ज:"Ja",झ:"Jha",क:"Ka",ख:"Kha",ख़:"Khi",ल:"L",ळ:"Li",ऌ:"Li",ऴ:"Lii",ॡ:"Lii",म:"Ma",न:"Na",ङ:"Na",ञ:"Nia",ण:"Nae",ऩ:"Ni",ॐ:"oms",प:"Pa",क़:"Qi",र:"Ra",ऋ:"Ri",ॠ:"Ri",ऱ:"Ri",स:"Sa",श:"Sha",ष:"Shha",ट:"Ta",त:"Ta",ठ:"Tha",द:"Tha",थ:"Tha",ध:"Thha",ड़:"ugDha",ढ़:"ugDhha",व:"Va",य:"Ya",य़:"Yi",ज़:"Za",ə:"e",Ə:"E",ა:"a",ბ:"b",გ:"g",დ:"d",ე:"e",ვ:"v",ზ:"z",თ:"t",ი:"i",კ:"k",ლ:"l",მ:"m",ნ:"n",ო:"o",პ:"p",ჟ:"zh",რ:"r",ს:"s",ტ:"t",უ:"u",ფ:"p",ქ:"k",ღ:"gh",ყ:"q",შ:"sh",ჩ:"ch",ც:"ts",ძ:"dz",წ:"ts",ჭ:"ch",ხ:"kh",ჯ:"j",ჰ:"h",ב:"v",גּ:"g",ג:"g",ד:"d",דּ:"d",ה:"h",ו:"v",ז:"z",ח:"h",ט:"t",י:"y",כ:"kh",ך:"kh",ל:"l",מ:"m",ם:"m",נ:"n",ן:"n",ס:"s",פ:"f",ף:"f",ץ:"ts",צ:"ts",ק:"k",ר:"r",תּ:"t",ת:"t"};F.charmap=Object.assign({},fa);F.multicharmap=Object.assign({},ua);F.defaults={charmap:F.charmap,mode:"pretty",modes:{rfc3986:{replacement:"-",remove:null,lower:!0,charmap:F.charmap,multicharmap:F.multicharmap,trim:!0},pretty:{replacement:"-",remove:null,lower:!0,charmap:F.charmap,multicharmap:F.multicharmap,trim:!0}},multicharmap:F.multicharmap,fallback:!0};F.reset=function(){F.defaults.modes.rfc3986.charmap=F.defaults.modes.pretty.charmap=F.charmap=F.defaults.charmap=Object.assign({},fa),F.defaults.modes.rfc3986.multicharmap=F.defaults.modes.pretty.multicharmap=F.multicharmap=F.defaults.multicharmap=Object.assign({},ua),_r=""};F.extend=function(e){const t=Object.keys(e),n={},r={};for(let o=0;o<t.length;o++)t[o].length>1?n[t[o]]=e[t[o]]:r[t[o]]=e[t[o]];Object.assign(F.charmap,r),Object.assign(F.multicharmap,n)};F.setLocale=function(e){_r=da[e]||{}};function Yt(e){return new URL(e.replace(/^\/+/,""),window.location.origin+(window.ph?.basePath??"/")).pathname}function la(e){const t=window.ph?.basePath??"/";return e.replace(t,t.endsWith("/")?"/":"")}function Yb(e){if(!e)return"";const t=e.name;return F(t?`${t}-${e.id}`:e.id)}function Xb(e){const t=la(e);return/^\/d\/[^/]+\/([^/]+)$/.exec(t)?.[1]}function ha(e){return e?/\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b/.exec(e)?.[0]:void 0}function Qb(e){return ha(e)}function ba(e){const t=la(e);return/^\/d\/([^/]+)/.exec(t)?.[1]??""}function e2(e){return ha(e)}function t2(e){const t=ba(e);return e2(t)}const Br=_("selectedDriveId"),pa=Br.useValue,n2=Br.setValue,r2=Br.addEventHandler;function o2(){const e=$r();if(!e[0])throw new Error("There is no drive selected. Did you mean to call 'useSelectedDriveSafe'?");return e}function $r(){const e=pa(),n=oa()?.find(s=>s.header.id===e),[r,o]=ar(n);return n?[r,o]:[void 0,void 0]}function s2(e){const t=typeof e=="string"?e:e?.header.slug,r=window.ph?.drives?.find(s=>s.header.slug===t)?.header.id;if(n2(r),!r){const s=Yt("/");if(s===window.location.pathname)return;window.history.pushState(null,"",s);return}const o=Yt(`/d/${t}`);o!==window.location.pathname&&window.history.pushState(null,"",o)}function i2(){window.addEventListener("popstate",()=>{const e=window.location.pathname,t=t2(e),n=window.ph?.selectedDriveId;t!==n&&s2(t)})}function kt(){const[e]=$r();return e?.state.global.nodes}function a2(){return kt()?.filter(t=>ws(t))}const Rr=_("selectedNodeId"),c2=Rr.useValue,wa=Rr.setValue,d2=Rr.addEventHandler;function Tt(){const e=c2();return kt()?.find(n=>n.id===e)}function ya(e){const t=typeof e=="string"?e:Yb(e),n=Qb(t);wa(n);const r=ba(window.location.pathname);if(!r)return;if(!t){const s=Yt(`/d/${r}`);if(s===window.location.pathname)return;window.history.pushState(null,"",s);return}const o=Yt(`/d/${r}/${t}`);o!==window.location.pathname&&window.history.pushState(null,"",o)}function u2(){window.addEventListener("ph:selectedDriveIdUpdated",()=>{wa(void 0)})}function f2(){window.addEventListener("popstate",()=>{const e=window.location.pathname,t=Xb(e),n=window.ph?.selectedNodeId;t!==n&&ya(t)})}function Or(){const e=Tt();if(ws(e))return e}function yw(){const e=kt(),n=Or()?.id;return e?zr(n?e.filter(r=>r.parentFolder===n):e.filter(r=>!r.parentFolder)):[]}const{setValue:l2,addEventHandler:h2}=_("routerBasename"),{setValue:b2,addEventHandler:p2}=_("version"),{setValue:w2,addEventHandler:y2}=_("requiresHardRefresh"),{setValue:g2,addEventHandler:m2}=_("warnOutdatedApp"),{setValue:D2,addEventHandler:E2}=_("studioMode"),{setValue:x2,addEventHandler:v2}=_("basePath"),{setValue:S2,addEventHandler:A2}=_("versionCheckInterval"),{setValue:k2,addEventHandler:T2}=_("cliVersion"),{setValue:I2,addEventHandler:C2}=_("fileUploadOperationsChunkSize"),{setValue:_2,addEventHandler:B2}=_("isDocumentModelSelectionSettingsEnabled"),{setValue:$2,addEventHandler:R2}=_("gaTrackingId"),{setValue:O2,addEventHandler:U2}=_("defaultDrivesUrl"),{setValue:N2,addEventHandler:M2}=_("drivesPreserveStrategy"),{setValue:P2,addEventHandler:H2}=_("isLocalDrivesEnabled"),{setValue:j2,addEventHandler:L2}=_("isAddDriveEnabled"),{setValue:F2,addEventHandler:V2}=_("isPublicDrivesEnabled"),{setValue:K2,addEventHandler:z2}=_("isAddPublicDrivesEnabled"),{setValue:q2,addEventHandler:J2}=_("isDeletePublicDrivesEnabled"),{setValue:W2,addEventHandler:Z2}=_("isCloudDrivesEnabled"),{setValue:G2,addEventHandler:Y2}=_("isAddCloudDrivesEnabled"),{setValue:X2,addEventHandler:Q2}=_("isDeleteCloudDrivesEnabled");_("isLocalDrivesEnabled");const{setValue:ep,addEventHandler:tp}=_("isAddLocalDrivesEnabled"),{setValue:np,addEventHandler:rp}=_("isDeleteLocalDrivesEnabled"),{setValue:op,addEventHandler:sp}=_("isEditorDebugModeEnabled"),{setValue:ip,addEventHandler:ap}=_("isEditorReadModeEnabled"),{setValue:cp,addEventHandler:dp}=_("isAnalyticsDatabaseWorkerEnabled"),{setValue:up,addEventHandler:fp}=_("isDiffAnalyticsEnabled"),{setValue:lp,addEventHandler:hp}=_("isDriveAnalyticsEnabled"),{setValue:bp,addEventHandler:pp}=_("renownUrl"),{setValue:wp,addEventHandler:yp}=_("renownNetworkId"),{setValue:gp,addEventHandler:mp}=_("renownChainId"),{setValue:Dp,addEventHandler:Ep}=_("sentryRelease"),{setValue:xp,addEventHandler:vp}=_("sentryDsn"),{setValue:Sp,addEventHandler:Ap}=_("sentryEnv"),{setValue:kp,addEventHandler:Tp}=_("isSentryTracingEnabled"),{setValue:Ip,addEventHandler:Cp}=_("isExternalProcessorsEnabled"),{setValue:_p,addEventHandler:Bp}=_("isExternalPackagesEnabled"),ga=_("enabledEditors"),$p=ga.setValue,Rp=ga.addEventHandler,ma=_("disabledEditors"),Op=ma.setValue,Up=ma.addEventHandler,Da=_("isRelationalProcessorsEnabled"),Np=Da.setValue,Mp=Da.addEventHandler,Ea=_("isExternalRelationalProcessorsEnabled"),Pp=Ea.setValue,Hp=Ea.addEventHandler,xa=_("isAnalyticsEnabled"),jp=xa.setValue,Lp=xa.addEventHandler,va=_("isAnalyticsExternalProcessorsEnabled"),Fp=va.setValue,Vp=va.addEventHandler,Sa=_("analyticsDatabaseName"),Kp=Sa.setValue,zp=Sa.addEventHandler,Aa=_("logLevel"),qp=Aa.setValue,Jp=Aa.addEventHandler,Ur=_("allowList"),Wp=Ur.setValue,Zp=Ur.useValue,Gp=Ur.addEventHandler,Yp={routerBasename:l2,version:b2,requiresHardRefresh:w2,warnOutdatedApp:g2,studioMode:D2,basePath:x2,versionCheckInterval:S2,cliVersion:k2,fileUploadOperationsChunkSize:I2,isDocumentModelSelectionSettingsEnabled:_2,gaTrackingId:$2,defaultDrivesUrl:O2,drivesPreserveStrategy:N2,isLocalDrivesEnabled:P2,isAddDriveEnabled:j2,isPublicDrivesEnabled:F2,isAddPublicDrivesEnabled:K2,isDeletePublicDrivesEnabled:q2,isCloudDrivesEnabled:W2,isAddCloudDrivesEnabled:G2,isDeleteCloudDrivesEnabled:X2,isAddLocalDrivesEnabled:ep,isDeleteLocalDrivesEnabled:np,isEditorDebugModeEnabled:op,isEditorReadModeEnabled:ip,isRelationalProcessorsEnabled:Np,isExternalRelationalProcessorsEnabled:Pp,isAnalyticsEnabled:jp,analyticsDatabaseName:Kp,isAnalyticsExternalProcessorsEnabled:Fp,isAnalyticsDatabaseWorkerEnabled:cp,isDiffAnalyticsEnabled:up,isDriveAnalyticsEnabled:lp,renownUrl:bp,renownNetworkId:wp,renownChainId:gp,sentryRelease:Dp,sentryDsn:xp,sentryEnv:Sp,isSentryTracingEnabled:kp,isExternalProcessorsEnabled:Ip,isExternalPackagesEnabled:_p,allowList:Wp,logLevel:qp,disabledEditors:Op,enabledEditors:$p},Xp={...Nc,...Mc,...Yp};function Nr(e,t){const n=Xp[e];n(t)}function gw(e){for(const t of Object.keys(e))Nr(t,e[t])}function Qp(e){for(const t of Object.keys(e))Nr(t,e[t])}function e1(e){for(const t of Object.keys(e))Nr(t,e[t])}function mw(e){const[t,n]=Ne.useState(!1);Ne.useEffect(()=>{t||(Qp(e),n(!0))},[e,t])}function Dw(e){const[t,n]=Ne.useState(!1);Ne.useEffect(()=>{t||(e1(e),n(!0))},[e,t])}function t1(e,t){const[n,r]=ca(e),o=Hc(t);if(!e||!t)return[];if(!n)throw new Wa(e);if(!o)throw new Za(t);if(n.header.documentType!==t)throw new bc(e,t,n.header.documentType);return[n,r]}function n1(){return ps()?.map(t=>t.documentModel.global.id)}function r1(){const e=Oc(),t=n1();return e??t}function Ew(e){const n=oa()?.find(s=>s.header.id===e),[r,o]=ar(n);if(!n)throw new Error(`Drive with id ${e} not found`);return[r,o]}function ka(){return ir()?.flatMap(t=>t.modules.editorModules||[]).filter(t=>!t.documentTypes.includes("powerhouse/document-drive"))}function o1(){return ir()?.flatMap(t=>t.modules.editorModules||[]).filter(t=>t.documentTypes.includes("powerhouse/document-drive"))}function xw(e){const t=ka();return!e||t?.length===0?void 0:t?.filter(r=>r.documentTypes.includes(e))?.[0]}function s1(e){return o1()?.find(n=>n.id===e)}function vw(){return s1(Ic)}function Sw(e){return ka()?.find(n=>n.id===e)}function Ta(e){return a2()?.find(n=>n.id===e)}const Mr=_("modal"),Aw=Mr.useValue,fn=Mr.setValue,i1=Mr.addEventHandler;function a1(e){fn(e)}function kw(){fn(void 0)}function Tw(e){fn({type:"createDocument",documentType:e})}function Iw(e){const t=typeof e=="string"?e:e.id;fn({type:"deleteItem",id:t})}function ge(e,t){return t?.id!==e?t:void 0}function Cw(){const[e]=$r(),t=Or(),n=Tt(),r=Ta(n?.parentFolder),o=e?.header.id;async function s(u,b){if(!o)return;const h=u.name.replace(/\..+/gim,"");return Ec(u,o,h,ge(o,b)?.id)}async function i(u,b){if(o)return vc(o,u,ge(o,b)?.id)}async function c(u,b){if(!o)return;if(!ge(o,b)){console.error(`Node ${b.id} not found`);return}return await Ac(o,b.id,u)}async function a(u,b){if(!o)return;const h=ge(o,u);if(!h){console.error(`Node ${u.id} not found`);return}const p=ge(o,b);await Kr(o,h,p)}async function d(u,b){if(!o)return;const h=ge(o,u);if(!h){console.error(`Node ${u.id} not found`);return}const p=ge(o,b);!p?.id&&!u.parentFolder||p?.id===u.parentFolder||await kc(o,h,p)}async function f(u){if(!o)return;const b=ge(o,u);if(!b){console.error(`Node ${u.id} not found`);return}const h=ge(o,t??r);await Kr(o,b,h)}async function l(u){if(!u||!o)return;const b=ge(o,t??r);if(!b)return;const h=await i(u,b);h&&ya(h)}return{onAddFile:s,onAddFolder:i,onRenameNode:c,onCopyNode:a,onMoveNode:d,onDuplicateNode:f,onAddAndSelectNewFolder:l}}function c1(e){return kt()?.find(n=>n.id===e)}function d1(e){const t=kt();if(!t)return[];const n=[];let r=t.find(o=>o.id===e);for(;r&&(n.push(r),!!r.parentFolder);)r=t.find(o=>o.id===r?.parentFolder);return n.reverse()}function _w(){const e=Tt();return d1(e?.id)}function u1(e){const t=c1(e);return Ta(t?.parentFolder)}function Bw(){const e=Tt();return u1(e?.id)}const Pr=_("revisionHistoryVisible"),$w=Pr.useValue,f1=Pr.setValue,l1=Pr.addEventHandler;function Rw(){f1(!0)}function Ia(){const e=Tt();return e&&Xt(e)?e.id:void 0}function Ow(){const e=Ia();return ca(e)}function Uw(e){const t=Ia();if(!t)throw new pc;return t1(t,e)}const Hr=_("selectedTimelineItem"),Nw=Hr.useValue,Mw=Hr.setValue,h1=Hr.addEventHandler,b1=_("selectedTimelineRevision"),p1=b1.addEventHandler,w1=e=>{const t=[];if(e.header.documentType!=="powerhouse/document-model")return t;const n=e,r=n.state.global.specifications[0],o=Object.keys(r.state).reduce((c,a)=>{const d=a;return[...c,...rc(r.state[d].initialValue,d!=="global").map(f=>({...f,message:`${f.message}. Scope: ${d}`,details:{...f.details,scope:d}}))]},[]),s=Object.keys(r.state).reduce((c,a)=>{const d=a,f=d==="global";return[...c,...oc(r.state[d].schema,n.state.global?.name||n.header.name||"",f?"":d,!f).map(l=>({...l,message:`${l.message}. Scope: ${d}`,details:{...l.details,scope:d}}))]},[]),i=sc(r.modules);return[...o,...s,...i]},Pw=e=>{if(!e)return;if(w1(e).length)a1({type:"exportDocumentWithErrors",documentId:e.header.id});else return Dc(e)},Hw=(e,t,n=[])=>{if(!e||!t)return 0;const r=n.find(o=>{const s=new Date(o.timestampUtcMs);return s>=e&&s<=t});return r?r.index:0};var Vn={exports:{}},cs;function y1(){return cs||(cs=1,(function(e){var t=(function(){var n=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",s={};function i(a,d){if(!s[a]){s[a]={};for(var f=0;f<a.length;f++)s[a][a.charAt(f)]=f}return s[a][d]}var c={compressToBase64:function(a){if(a==null)return"";var d=c._compress(a,6,function(f){return r.charAt(f)});switch(d.length%4){default:case 0:return d;case 1:return d+"===";case 2:return d+"==";case 3:return d+"="}},decompressFromBase64:function(a){return a==null?"":a==""?null:c._decompress(a.length,32,function(d){return i(r,a.charAt(d))})},compressToUTF16:function(a){return a==null?"":c._compress(a,15,function(d){return n(d+32)})+" "},decompressFromUTF16:function(a){return a==null?"":a==""?null:c._decompress(a.length,16384,function(d){return a.charCodeAt(d)-32})},compressToUint8Array:function(a){for(var d=c.compress(a),f=new Uint8Array(d.length*2),l=0,u=d.length;l<u;l++){var b=d.charCodeAt(l);f[l*2]=b>>>8,f[l*2+1]=b%256}return f},decompressFromUint8Array:function(a){if(a==null)return c.decompress(a);for(var d=new Array(a.length/2),f=0,l=d.length;f<l;f++)d[f]=a[f*2]*256+a[f*2+1];var u=[];return d.forEach(function(b){u.push(n(b))}),c.decompress(u.join(""))},compressToEncodedURIComponent:function(a){return a==null?"":c._compress(a,6,function(d){return o.charAt(d)})},decompressFromEncodedURIComponent:function(a){return a==null?"":a==""?null:(a=a.replace(/ /g,"+"),c._decompress(a.length,32,function(d){return i(o,a.charAt(d))}))},compress:function(a){return c._compress(a,16,function(d){return n(d)})},_compress:function(a,d,f){if(a==null)return"";var l,u,b={},h={},p="",E="",w="",g=2,y=3,S=2,D=[],m=0,k=0,A;for(A=0;A<a.length;A+=1)if(p=a.charAt(A),Object.prototype.hasOwnProperty.call(b,p)||(b[p]=y++,h[p]=!0),E=w+p,Object.prototype.hasOwnProperty.call(b,E))w=E;else{if(Object.prototype.hasOwnProperty.call(h,w)){if(w.charCodeAt(0)<256){for(l=0;l<S;l++)m=m<<1,k==d-1?(k=0,D.push(f(m)),m=0):k++;for(u=w.charCodeAt(0),l=0;l<8;l++)m=m<<1|u&1,k==d-1?(k=0,D.push(f(m)),m=0):k++,u=u>>1}else{for(u=1,l=0;l<S;l++)m=m<<1|u,k==d-1?(k=0,D.push(f(m)),m=0):k++,u=0;for(u=w.charCodeAt(0),l=0;l<16;l++)m=m<<1|u&1,k==d-1?(k=0,D.push(f(m)),m=0):k++,u=u>>1}g--,g==0&&(g=Math.pow(2,S),S++),delete h[w]}else for(u=b[w],l=0;l<S;l++)m=m<<1|u&1,k==d-1?(k=0,D.push(f(m)),m=0):k++,u=u>>1;g--,g==0&&(g=Math.pow(2,S),S++),b[E]=y++,w=String(p)}if(w!==""){if(Object.prototype.hasOwnProperty.call(h,w)){if(w.charCodeAt(0)<256){for(l=0;l<S;l++)m=m<<1,k==d-1?(k=0,D.push(f(m)),m=0):k++;for(u=w.charCodeAt(0),l=0;l<8;l++)m=m<<1|u&1,k==d-1?(k=0,D.push(f(m)),m=0):k++,u=u>>1}else{for(u=1,l=0;l<S;l++)m=m<<1|u,k==d-1?(k=0,D.push(f(m)),m=0):k++,u=0;for(u=w.charCodeAt(0),l=0;l<16;l++)m=m<<1|u&1,k==d-1?(k=0,D.push(f(m)),m=0):k++,u=u>>1}g--,g==0&&(g=Math.pow(2,S),S++),delete h[w]}else for(u=b[w],l=0;l<S;l++)m=m<<1|u&1,k==d-1?(k=0,D.push(f(m)),m=0):k++,u=u>>1;g--,g==0&&(g=Math.pow(2,S),S++)}for(u=2,l=0;l<S;l++)m=m<<1|u&1,k==d-1?(k=0,D.push(f(m)),m=0):k++,u=u>>1;for(;;)if(m=m<<1,k==d-1){D.push(f(m));break}else k++;return D.join("")},decompress:function(a){return a==null?"":a==""?null:c._decompress(a.length,32768,function(d){return a.charCodeAt(d)})},_decompress:function(a,d,f){var l=[],u=4,b=4,h=3,p="",E=[],w,g,y,S,D,m,k,A={val:f(0),position:d,index:1};for(w=0;w<3;w+=1)l[w]=w;for(y=0,D=Math.pow(2,2),m=1;m!=D;)S=A.val&A.position,A.position>>=1,A.position==0&&(A.position=d,A.val=f(A.index++)),y|=(S>0?1:0)*m,m<<=1;switch(y){case 0:for(y=0,D=Math.pow(2,8),m=1;m!=D;)S=A.val&A.position,A.position>>=1,A.position==0&&(A.position=d,A.val=f(A.index++)),y|=(S>0?1:0)*m,m<<=1;k=n(y);break;case 1:for(y=0,D=Math.pow(2,16),m=1;m!=D;)S=A.val&A.position,A.position>>=1,A.position==0&&(A.position=d,A.val=f(A.index++)),y|=(S>0?1:0)*m,m<<=1;k=n(y);break;case 2:return""}for(l[3]=k,g=k,E.push(k);;){if(A.index>a)return"";for(y=0,D=Math.pow(2,h),m=1;m!=D;)S=A.val&A.position,A.position>>=1,A.position==0&&(A.position=d,A.val=f(A.index++)),y|=(S>0?1:0)*m,m<<=1;switch(k=y){case 0:for(y=0,D=Math.pow(2,8),m=1;m!=D;)S=A.val&A.position,A.position>>=1,A.position==0&&(A.position=d,A.val=f(A.index++)),y|=(S>0?1:0)*m,m<<=1;l[b++]=n(y),k=b-1,u--;break;case 1:for(y=0,D=Math.pow(2,16),m=1;m!=D;)S=A.val&A.position,A.position>>=1,A.position==0&&(A.position=d,A.val=f(A.index++)),y|=(S>0?1:0)*m,m<<=1;l[b++]=n(y),k=b-1,u--;break;case 2:return E.join("")}if(u==0&&(u=Math.pow(2,h),h++),l[k])p=l[k];else if(k===b)p=g+g.charAt(0);else return null;E.push(p),l[b++]=g+p.charAt(0),u--,g=p,u==0&&(u=Math.pow(2,h),h++)}}};return c})();e!=null?e.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})})(Vn)),Vn.exports}var g1=y1();function m1(e){return e.split("/").pop()}function D1(){return`query getDocument($documentId: String!) {
|
|
16
|
+
document(id: $documentId) {
|
|
17
|
+
id
|
|
18
|
+
documentType
|
|
19
|
+
createdAtUtcIso
|
|
20
|
+
lastModifiedAtUtcIso
|
|
21
|
+
name
|
|
22
|
+
revision
|
|
23
|
+
stateJSON
|
|
24
|
+
}
|
|
25
|
+
}`}function E1(e,t,n){const r=m1(e),o=D1(),s={documentId:t,driveId:r},i=n?{Authorization:`Bearer ${n}`}:void 0,c={document:o.trim(),variables:JSON.stringify(s,null,2)};return i&&(c.headers=JSON.stringify(i)),g1.compressToEncodedURIComponent(JSON.stringify(c))}function x1(e,t,n){const r=E1(e,t,n);return`${e}?explorerURLState=${r}`}function jw(e){return{id:Ce(),name:e.manifest.name,description:e.manifest.description,category:e.manifest.category,author:{name:"Powerhouse",website:"https://powerhousedao.com"},modules:{documentModelModules:e.documentModels.map(v1),editorModules:e.editors.map(r=>S1(r,e.manifest))}}}function v1(e){const t=e.documentModel.global,n=t.name,r=t.id,o=r,s=t.extension,i=t.specifications,c=e.reducer,a=e.actions,d=e.utils;return{id:o,name:n,documentType:r,extension:s,documentModel:ic(ac(),t),specifications:i,reducer:c,actions:a,utils:d}}function S1(e,t){const n=t?.apps?.find(d=>d.driveEditor===e.config.id)?.name,r=e.config.id,o=r.split("-").map(d=>d.charAt(0).toUpperCase()+d.slice(1)).join(" "),s=n||e.config.name||o,i=e.documentTypes,c=e.Component;return{id:r,name:s,documentTypes:i,Component:c}}function Lw(e){const{id:t,name:n,description:r,category:o,author:s,modules:i}=e;return{id:t,name:n,description:r,category:o,author:s,modules:A1(i)}}function A1(e){return Object.entries(e).reduce((t,[n,r])=>(t[n]=r.map(o=>({id:o.id,name:o.name})),t),{})}const{useValue:k1,setValue:Fw,addEventHandler:T1}=_("connectCrypto"),{setValue:Vw,addEventHandler:I1}=_("did"),{addEventHandler:C1}=_("loading"),{setValue:Je,addEventHandler:_1}=_("loginStatus"),Ca=_("processorManager"),Kw=Ca.setValue,B1=Ca.addEventHandler,jr=_("reactor"),zw=jr.useValue,qw=jr.setValue,$1=jr.addEventHandler,_a=_("renown"),Jw=_a.setValue,R1=_a.addEventHandler,{useValue:Ba,setValue:ds,addEventHandler:O1}=_("user"),U1={loading:C1,reactor:$1,modal:i1,connectCrypto:T1,did:I1,renown:R1,loginStatus:_1,user:O1,processorManager:B1,drives:Hb,documentCache:Zb,selectedDriveId:()=>{r2(),i2(),u2()},selectedNodeId:()=>{d2(),f2()},vetraPackages:Pc,selectedTimelineRevision:p1,revisionHistoryVisible:l1,selectedTimelineItem:h1,routerBasename:h2,version:p2,logLevel:Jp,requiresHardRefresh:y2,warnOutdatedApp:m2,studioMode:E2,basePath:v2,versionCheckInterval:A2,cliVersion:T2,fileUploadOperationsChunkSize:C2,isDocumentModelSelectionSettingsEnabled:B2,gaTrackingId:R2,allowList:Gp,defaultDrivesUrl:U2,drivesPreserveStrategy:M2,allowedDocumentTypes:Uc,enabledEditors:Rp,disabledEditors:Up,isAddDriveEnabled:L2,isLocalDrivesEnabled:H2,isPublicDrivesEnabled:V2,isAddPublicDrivesEnabled:z2,isDeletePublicDrivesEnabled:J2,isCloudDrivesEnabled:Z2,isAddCloudDrivesEnabled:Y2,isDeleteCloudDrivesEnabled:Q2,isAddLocalDrivesEnabled:tp,isDeleteLocalDrivesEnabled:rp,isDragAndDropEnabled:$c,isExternalControlsEnabled:_c,isEditorDebugModeEnabled:sp,isEditorReadModeEnabled:ap,isRelationalProcessorsEnabled:Mp,isExternalRelationalProcessorsEnabled:Hp,isAnalyticsEnabled:Lp,isAnalyticsExternalProcessorsEnabled:Vp,analyticsDatabaseName:zp,isAnalyticsDatabaseWorkerEnabled:dp,isDiffAnalyticsEnabled:fp,isDriveAnalyticsEnabled:hp,renownUrl:pp,renownNetworkId:yp,renownChainId:mp,sentryRelease:Ep,sentryDsn:vp,sentryEnv:Ap,isSentryTracingEnabled:Tp,isExternalProcessorsEnabled:Cp,isExternalPackagesEnabled:Bp};function Ww(){for(const e of Object.values(U1))e()}function Zw(e){const[t]=o2(),n=Vb(t),r=ia(t),o=k1(),s=Ba();return Ne.useMemo(()=>!n||!e?.header.id||!r?null:async()=>{const i=s?.address?await o?.getBearerToken(r,s.address,!1,{expiresIn:600}):void 0;return x1(r,e.header.id,i)},[n,r,e,s,o])}const Gw=e=>{const t=pa(),n=Or(),r=r1();return async(s,i,c)=>{if(!t){console.warn("No selected drive - upload skipped");return}const a=s.name.replace(/\..+/gim,""),d=n?.id;return await xc(s,t,a,d,i,r,c)}};function Yw(){const e=Ba(),t=Zp();return t?{isAllowedToCreateDocuments:t.includes(e?.address??""),isAllowedToEditDocuments:t.includes(e?.address??"")}:{isAllowedToCreateDocuments:!0,isAllowedToEditDocuments:!0}}const N1="https://auth.renown.id",M1="eip155",P1="1";function Xw(){const e=new URL(N1);e.searchParams.set("connect",window.ph?.did??""),e.searchParams.set("network",M1),e.searchParams.set("chain",P1);const t=new URL(window.location.pathname,window.location.origin);e.searchParams.set("returnUrl",t.toJSON()),window.open(e,"_self")?.focus()}async function Qw(e,t,n,r){if(!(!n||!r||!t))try{Je("checking");let o=n.user instanceof Function?n.user():n.user;if(o=o instanceof Promise?await o:o,o?.did&&(o.did===e||!e))return Je("authorized"),ds(o),t.setGenerateJwtHandler(async i=>r.getBearerToken(i,o.address,!0,{expiresIn:10})),o;if(!e)return;const s=await n.login(e??"");s?(Je("authorized"),ds(s),t.setGenerateJwtHandler(async i=>r.getBearerToken(i,s.address,!0,{expiresIn:10}))):Je("not-authorized")}catch(o){Je("not-authorized"),z.error(o)}}async function ey(){const e=window.ph?.renown,t=window.ph?.reactor;Je("initial"),await e?.logout(),t?.removeJwtHandler()}export{Ww as $,Vb as A,ia as B,k1 as C,Ba as D,x1 as E,w1 as F,Dc as G,s1 as H,vw as I,cw as J,Nw as K,$w as L,Hc as M,Sw as N,xw as O,f1 as P,Hw as Q,Aw as R,ps as S,Tw as T,yw as U,nw as V,Or as W,ws as X,mw as Y,Ic as Z,Q1 as _,Dw as a,bw as a0,aw as a1,fw as a2,hw as a3,pw as a4,Lb as a5,ba as a6,Xb as a7,Qw as a8,gw as a9,Sc as aA,dw as aB,Z1 as aC,W1 as aD,J1 as aE,ir as aF,Lw as aG,qw as aa,ww as ab,Fw as ac,Vw as ad,Jw as ae,Kw as af,Pb as ag,lw as ah,e1 as ai,Qp as aj,oa as ak,zw as al,z1 as am,ey as an,Xw as ao,o1 as ap,kw as aq,K1 as ar,Bw as as,hs as at,G1 as au,Y1 as av,X1 as aw,Ew as ax,q1 as ay,c1 as az,Yw as b,$r as c,pa as d,_w as e,ya as f,vc as g,ca as h,Ow as i,u1 as j,Zw as k,Rw as l,Mw as m,Pw as n,Cw as o,ew as p,Gw as q,Al as r,s2 as s,uw as t,Uw as u,Iw as v,a1 as w,jw as x,tw as y,o2 as z};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graphql-editor-CSkqTexL.js","assets/document_model_editor-lmHQ6HZy.js","assets/graphql-BS4Brs_E.js","assets/drive_explorer-d0kn77Nx.js","assets/sentry_react-cODD7zWc.js","assets/react-DQSxOgtG.js","assets/sentry_browser-B4YoBIIG.js","assets/react/jsx-runtime-DldvXD6N.js","assets/document_model-DXcLJEjZ.js","assets/zod-C6yxFxyo.js","assets/design_system-DGYPpUGa.js","assets/tailwind_merge-Dr4f9Rms.js","assets/reactor_browser-BGn_P-dn.js","assets/document_drive-BEIKnuGM.js","assets/config-CU-aFfVJ.js","assets/react-dom-D6zQJsh6.js","assets/design_system_connect-Vb8XBnLs.js","assets/design_system_ui-Dnwc_Xm9.js","assets/hooks-D4Uas2SG.js","assets/json-editor-CQKAVxat.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as k}from"./drive_explorer-d0kn77Nx.js";import{j as e,h as x,m as H,i as V,k as P,s as y,l as z,n as B,t as A}from"./document_model_editor-lmHQ6HZy.js";import{r as i}from"./sentry_react-cODD7zWc.js";import{L as F,M as L,N as T,O as E}from"./design_system_connect-Vb8XBnLs.js";import{K as C}from"./graphql-BS4Brs_E.js";import{c as J}from"./design_system-DGYPpUGa.js";import"./react/jsx-runtime-DldvXD6N.js";import"./document_model-DXcLJEjZ.js";import"./zod-C6yxFxyo.js";import"./react-DQSxOgtG.js";import"./reactor_browser-BGn_P-dn.js";import"./document_drive-BEIKnuGM.js";import"./config-CU-aFfVJ.js";import"./tailwind_merge-Dr4f9Rms.js";import"./react-dom-D6zQJsh6.js";import"./sentry_browser-B4YoBIIG.js";import"./design_system_ui-Dnwc_Xm9.js";const f=i.forwardRef((a,l)=>{const{className:s,...r}=a;return e.jsx("button",{ref:l,...r,className:x("h-10 whitespace-nowrap rounded-md border border-gray-200 bg-gray-50 px-4 py-2 text-sm font-medium text-gray-800 transition-colors hover:bg-gray-100 hover:text-gray-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",s)})}),Z=F,D=i.forwardRef(({className:a,...l},s)=>e.jsx(L,{ref:s,className:x("flex items-center justify-center rounded-xl bg-slate-50 p-1 shadow-[inset_0px_0px_2px_rgba(255,255,255,0.50)]",a),...l}));D.displayName=L.displayName;const b=i.forwardRef(({className:a,...l},s)=>e.jsx(T,{ref:s,className:x("flex w-full items-center justify-center whitespace-nowrap rounded-lg p-1 text-sm text-gray-500 transition-all disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-gray-50 data-[state=active]:text-gray-800 data-[state=active]:shadow-[0px_16px_16px_-4px_rgba(0,0,0,0.10)]",a),...l}));b.displayName=T.displayName;const g=i.forwardRef(({className:a,...l},s)=>e.jsx(E,{ref:s,className:x("",a),...l}));g.displayName=E.displayName;const _=i.lazy(()=>k(()=>import("./graphql-editor-CSkqTexL.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]))),G=i.lazy(()=>k(()=>import("./json-editor-CQKAVxat.js"),__vite__mapDeps([19,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])));function S({modelName:a,stateSchema:l,initialValue:s,setStateSchema:r,setInitialState:c,scope:t}){const o=V(),[d,h]=i.useState(!1),p=i.useCallback(n=>P(n,a,t),[a,t]),m=i.useCallback(()=>{h(n=>!n)},[]),I=i.useCallback(n=>r(n,t),[r,t]),O=i.useCallback(n=>c(n,t),[c,t]),M=i.useCallback(()=>{const n=s||"{}",j=y(o);if(!j)return;const v=y(l);if(!v)return;const N=z(a,t);if(!N)return;const u=v.definitions.find(w=>w.kind===C.OBJECT_TYPE_DEFINITION&&w.name.value===N);if(!u||u.kind!==C.OBJECT_TYPE_DEFINITION)return;const R=B({sharedSchemaDocumentNode:j,stateTypeDefinitionNode:u,existingValue:n});c(R,t)},[o,s,c,t]);return e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"mb-2 text-lg capitalize",children:[t," state schema *"]}),e.jsxs(f,{onClick:m,className:"mb-2 flex w-fit items-center gap-2",children:[d?"Hide":"Show"," standard library",e.jsx("svg",{className:J("inline-block transition-transform",d?"rotate-180":"rotate-0"),xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:e.jsx("path",{d:"M11.9883 6.01172C11.4363 6.01172 10.9883 6.45972 10.9883 7.01172V13.0117H6.98828L11.9883 18.0117L16.9883 13.0117H12.9883V7.01172C12.9883 6.45972 12.5403 6.01172 11.9883 6.01172Z",fill:"black"})})]}),d&&e.jsx(_,{doc:A,readonly:!0}),e.jsx(_,{doc:l,updateDocumentInModel:I,customLinter:p})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsxs("h3",{className:"mb-2 text-right text-lg capitalize",children:[t," state initial value *"]}),e.jsxs(f,{onClick:M,className:"mb-2 flex w-fit items-center gap-2",children:["Sync with schema"," ",e.jsx("svg",{className:"inline-block",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M8.00521 1.99219C6.63588 1.99219 5.32788 2.45152 4.27588 3.28419C3.98721 3.51219 3.94321 3.93285 4.17188 4.22151C4.40054 4.51018 4.82055 4.55418 5.10921 4.32552C5.92721 3.67819 6.93921 3.32552 8.00521 3.32552C10.5825 3.32552 12.6719 5.41485 12.6719 7.99218H11.3385L13.3385 10.6588L15.3385 7.99218H14.0052C14.0052 4.67818 11.3192 1.99219 8.00521 1.99219ZM2.67188 5.32552L0.671875 7.99218H2.00521C2.00521 11.3062 4.69121 13.9922 8.00521 13.9922C9.37521 13.9922 10.6825 13.5335 11.7345 12.7002C12.0232 12.4722 12.0672 12.0515 11.8385 11.7628C11.6099 11.4742 11.1899 11.4302 10.9012 11.6588C10.0825 12.3068 9.07188 12.6588 8.00521 12.6588C5.42788 12.6588 3.33854 10.5695 3.33854 7.99218H4.67188L2.67188 5.32552Z",fill:"#343839"})})]})]}),e.jsx(G,{doc:s,updateDocumentInModel:O})]})]})}function ce({modelName:a,globalStateSchema:l,localStateSchema:s,globalStateInitialValue:r,localStateInitialValue:c,setStateSchema:t,setInitialState:o,currentScope:d,onScopeChange:h}){const p=i.useCallback(()=>{const m=H(a,"local");t(m,"local"),o("","local")},[a,t,o]);return e.jsxs(Z,{className:"pb-8",activationMode:"manual",value:d,onValueChange:m=>h(m),children:[e.jsx("div",{className:"my-6",children:e.jsxs(D,{className:"mx-auto flex max-w-sm",children:[e.jsx(b,{value:"global",children:"Global"}),e.jsx(b,{value:"local",children:"Local"})]})}),e.jsx(g,{value:"global",tabIndex:-1,children:e.jsx(S,{modelName:a,stateSchema:l,initialValue:r,setStateSchema:t,setInitialState:o,scope:"global"})}),e.jsx(g,{value:"local",tabIndex:-1,children:s?e.jsx(S,{modelName:a,stateSchema:s,initialValue:c,setStateSchema:t,setInitialState:o,scope:"local"}):e.jsxs("div",{className:"",children:[e.jsx("h3",{className:"mb-2 text-lg capitalize",children:"local state schema *"}),e.jsx(f,{onClick:p,children:"Add local state"})]})})]})}export{ce as default};
|