@powerhousedao/connect 4.1.0-dev.105 → 4.1.0-dev.107
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-C2fZqOQI.js +1 -0
- package/dist/assets/ClearStorageModal-DjjEBXBS.js +1 -0
- package/dist/assets/CookiesPolicyModal-BrOPPvzy.js +1 -0
- package/dist/assets/CreateDocumentModal-C09c_nGK.js +1 -0
- package/dist/assets/DebugSettingsModal-PbDxwRkN.js +1 -0
- package/dist/assets/DeleteDriveModal-x5WgUnZq.js +1 -0
- package/dist/assets/DeleteItemModal-BBYKOKsF.js +1 -0
- package/dist/assets/DisclaimerModal-CteySYvG.js +1 -0
- package/dist/assets/DriveSettingsModal-B18X9rkK.js +1 -0
- package/dist/assets/ExportDocumentWithErrorsModal-B7IfIoUE.js +1 -0
- package/dist/assets/SettingsModal-BrdAtrxz.js +1 -0
- package/dist/assets/UpgradeDriveModal-fqiiEuOr.js +1 -0
- package/dist/assets/common-8r_LaZs4.css +1 -0
- package/dist/assets/common-n2B-GsjO.js +1 -0
- package/dist/assets/config-CU-aFfVJ.js +1 -0
- package/dist/assets/design_system-CZfmC8Ij.js +45 -0
- package/dist/assets/design_system_connect-DHQbQvgv.js +53 -0
- package/dist/assets/document_drive-CP6paqKN.js +305 -0
- package/dist/assets/document_engineering-DojqH50p.js +1 -0
- package/dist/assets/document_model-DLxR7ZLO.js +230 -0
- package/dist/assets/document_model_editor-ButtI7kP.js +2 -0
- package/dist/assets/drive_explorer-IB_BS5Au.js +2 -0
- package/dist/assets/editor-CgH7LMsL.js +105 -0
- package/dist/assets/editor-ClAkqmdQ.js +1 -0
- package/dist/assets/graphql-BS4Brs_E.js +75 -0
- package/dist/assets/graphql_request-9RNJ00DB.js +3 -0
- package/dist/assets/hmr-LMNkvzP7.js +1 -0
- package/dist/assets/index-BSTajiPh.js +18 -0
- package/dist/assets/index-Br7E7qjt.css +1 -0
- package/dist/assets/reactor_browser-BbZdm6Aa.js +25 -0
- package/dist/assets/sentry_browser-BFJlXALZ.js +498 -0
- package/dist/assets/sentry_react-C4W8xEsl.js +3 -0
- package/dist/assets/virtual_ph_external-packages-CM1tCR4L.js +1 -0
- package/dist/assets/zod-C6yxFxyo.js +1 -0
- package/dist/index.html +17 -2
- package/heroku/config/nginx.conf.template +7 -18
- package/lib/package.copy.json +27 -57
- package/lib/src/components/analytics.js +1 -1
- package/lib/src/components/analytics.js.map +1 -1
- package/lib/src/components/app-loader.d.ts +1 -1
- package/lib/src/components/app-loader.d.ts.map +1 -1
- package/lib/src/components/app-loader.js +2 -5
- package/lib/src/components/app-loader.js.map +1 -1
- package/lib/src/components/app-skeleton.d.ts.map +1 -1
- package/lib/src/components/app-skeleton.js +1 -1
- package/lib/src/components/app-skeleton.js.map +1 -1
- package/lib/src/components/app.d.ts.map +1 -1
- package/lib/src/components/app.js +3 -4
- package/lib/src/components/app.js.map +1 -1
- package/lib/src/components/cookie-banner.d.ts.map +1 -1
- package/lib/src/components/cookie-banner.js +3 -4
- package/lib/src/components/cookie-banner.js.map +1 -1
- package/lib/src/components/document-editor-container.js +2 -2
- package/lib/src/components/document-editor-container.js.map +1 -1
- package/lib/src/components/drive-editor-container.js +2 -2
- package/lib/src/components/drive-editor-container.js.map +1 -1
- package/lib/src/components/editor-loader.d.ts +1 -1
- package/lib/src/components/editor-loader.d.ts.map +1 -1
- package/lib/src/components/editor-loader.js +1 -1
- package/lib/src/components/editor-loader.js.map +1 -1
- package/lib/src/components/editors.js +2 -2
- package/lib/src/components/editors.js.map +1 -1
- package/lib/src/components/footer.js +3 -2
- package/lib/src/components/footer.js.map +1 -1
- package/lib/src/components/index.d.ts +1 -2
- package/lib/src/components/index.d.ts.map +1 -1
- package/lib/src/components/index.js +1 -2
- package/lib/src/components/index.js.map +1 -1
- package/lib/src/components/login.js +1 -1
- package/lib/src/components/login.js.map +1 -1
- package/lib/src/components/modal/index.d.ts +17 -1
- package/lib/src/components/modal/index.d.ts.map +1 -1
- package/lib/src/components/modal/index.js +17 -1
- package/lib/src/components/modal/index.js.map +1 -1
- package/lib/src/components/modal/modals/AddDriveModal.d.ts.map +1 -1
- package/lib/src/components/modal/modals/AddDriveModal.js +2 -1
- package/lib/src/components/modal/modals/AddDriveModal.js.map +1 -1
- package/lib/src/components/modal/modals/ClearStorageModal.js +2 -2
- package/lib/src/components/modal/modals/ClearStorageModal.js.map +1 -1
- package/lib/src/components/modal/modals/CookiesPolicyModal.js +1 -1
- package/lib/src/components/modal/modals/CookiesPolicyModal.js.map +1 -1
- package/lib/src/components/modal/modals/CreateDocumentModal.js +1 -1
- package/lib/src/components/modal/modals/CreateDocumentModal.js.map +1 -1
- package/lib/src/components/modal/modals/DebugSettingsModal.d.ts.map +1 -1
- package/lib/src/components/modal/modals/DebugSettingsModal.js +3 -2
- package/lib/src/components/modal/modals/DebugSettingsModal.js.map +1 -1
- package/lib/src/components/modal/modals/DeleteDriveModal.d.ts.map +1 -1
- package/lib/src/components/modal/modals/DeleteDriveModal.js +2 -1
- package/lib/src/components/modal/modals/DeleteDriveModal.js.map +1 -1
- package/lib/src/components/modal/modals/DeleteItemModal.d.ts.map +1 -1
- package/lib/src/components/modal/modals/DeleteItemModal.js +2 -1
- package/lib/src/components/modal/modals/DeleteItemModal.js.map +1 -1
- package/lib/src/components/modal/modals/DisclaimerModal.js +1 -1
- package/lib/src/components/modal/modals/DisclaimerModal.js.map +1 -1
- package/lib/src/components/modal/modals/DriveSettingsModal.js +2 -2
- package/lib/src/components/modal/modals/DriveSettingsModal.js.map +1 -1
- package/lib/src/components/modal/modals/ExportDocumentWithErrorsModal.js +1 -1
- package/lib/src/components/modal/modals/ExportDocumentWithErrorsModal.js.map +1 -1
- package/lib/src/components/modal/modals/SettingsModal.d.ts.map +1 -1
- package/lib/src/components/modal/modals/SettingsModal.js +4 -6
- package/lib/src/components/modal/modals/SettingsModal.js.map +1 -1
- package/lib/src/components/modal/modals/UpgradeDriveModal.js +1 -1
- package/lib/src/components/modal/modals/UpgradeDriveModal.js.map +1 -1
- package/lib/src/components/modal/modals/settings/about.js +1 -1
- package/lib/src/components/modal/modals/settings/about.js.map +1 -1
- package/lib/src/components/modal/modals/settings/danger-zone.js +1 -1
- package/lib/src/components/modal/modals/settings/danger-zone.js.map +1 -1
- package/lib/src/components/modal/modals/settings/default-editor.js +1 -1
- package/lib/src/components/modal/modals/settings/default-editor.js.map +1 -1
- package/lib/src/components/modal/modals/settings/package-manager.d.ts +1 -1
- package/lib/src/components/modal/modals/settings/package-manager.d.ts.map +1 -1
- package/lib/src/components/modal/modals/settings/package-manager.js +4 -5
- package/lib/src/components/modal/modals/settings/package-manager.js.map +1 -1
- package/lib/src/components/ph-logo.js +1 -1
- package/lib/src/components/ph-logo.js.map +1 -1
- package/lib/src/components/reload-connect-toast.d.ts.map +1 -0
- package/lib/src/components/reload-connect-toast.js.map +1 -0
- package/lib/src/components/root.d.ts.map +1 -1
- package/lib/src/components/root.js +3 -4
- package/lib/src/components/root.js.map +1 -1
- package/lib/src/components/router.js +1 -1
- package/lib/src/components/router.js.map +1 -1
- package/lib/src/components/search-bar.d.ts.map +1 -1
- package/lib/src/components/search-bar.js +2 -1
- package/lib/src/components/search-bar.js.map +1 -1
- package/lib/src/components/sidebar.d.ts.map +1 -1
- package/lib/src/components/sidebar.js +3 -2
- package/lib/src/components/sidebar.js.map +1 -1
- package/lib/src/context/sentry-provider.js +1 -1
- package/lib/src/context/sentry-provider.js.map +1 -1
- package/lib/src/feature-flags.d.ts.map +1 -0
- package/lib/src/feature-flags.js.map +1 -0
- package/lib/src/globals.d.ts +1 -1
- package/lib/src/globals.d.ts.map +1 -1
- package/lib/src/hooks/useCheckLatestVersion.js +3 -3
- package/lib/src/hooks/useCheckLatestVersion.js.map +1 -1
- package/lib/src/index.d.ts +1 -8
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +1 -8
- package/lib/src/index.js.map +1 -1
- package/lib/src/main.js +1 -1
- package/lib/src/main.js.map +1 -1
- package/lib/src/pages/content.d.ts.map +1 -1
- package/lib/src/pages/content.js +2 -3
- package/lib/src/pages/content.js.map +1 -1
- package/lib/src/pages/index.d.ts +2 -1
- package/lib/src/pages/index.d.ts.map +1 -1
- package/lib/src/pages/index.js +2 -1
- package/lib/src/pages/index.js.map +1 -1
- package/lib/src/services/index.d.ts +6 -2
- package/lib/src/services/index.d.ts.map +1 -1
- package/lib/src/services/index.js +5 -2
- package/lib/src/services/index.js.map +1 -1
- package/lib/src/services/toast.d.ts +2 -2
- package/lib/src/services/toast.d.ts.map +1 -1
- package/lib/src/services/toast.js +1 -1
- package/lib/src/services/toast.js.map +1 -1
- package/lib/src/store/document-model.d.ts.map +1 -1
- package/lib/src/store/document-model.js +3 -3
- package/lib/src/store/document-model.js.map +1 -1
- package/lib/src/store/editor.d.ts +2 -2
- package/lib/src/store/editor.d.ts.map +1 -1
- package/lib/src/store/editor.js +6 -6
- package/lib/src/store/editor.js.map +1 -1
- package/lib/src/store/reactor.d.ts.map +1 -1
- package/lib/src/store/reactor.js +6 -21
- package/lib/src/store/reactor.js.map +1 -1
- package/lib/src/utils/drive-sections.d.ts +1 -1
- package/lib/src/utils/drive-sections.d.ts.map +1 -1
- package/lib/src/utils/drive-sections.js +1 -1
- package/lib/src/utils/drive-sections.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/vite.config.d.ts.map +1 -1
- package/lib/vite.config.js +23 -0
- package/lib/vite.config.js.map +1 -1
- package/package.copy.json +27 -57
- package/package.json +34 -64
- package/dist/assets/AddDriveModal-07mDwuqC.js +0 -248
- package/dist/assets/AddDriveModal-07mDwuqC.js.map +0 -1
- package/dist/assets/ClearStorageModal-NS7l69ap.js +0 -46
- package/dist/assets/ClearStorageModal-NS7l69ap.js.map +0 -1
- package/dist/assets/CookiesPolicyModal-C6dI4RKZ.js +0 -34
- package/dist/assets/CookiesPolicyModal-C6dI4RKZ.js.map +0 -1
- package/dist/assets/CreateDocumentModal-KKbJcBSL.js +0 -65
- package/dist/assets/CreateDocumentModal-KKbJcBSL.js.map +0 -1
- package/dist/assets/DebugSettingsModal-DXtCp24I.js +0 -5134
- package/dist/assets/DebugSettingsModal-DXtCp24I.js.map +0 -1
- package/dist/assets/DeleteDriveModal-MSDNucFy.js +0 -55
- package/dist/assets/DeleteDriveModal-MSDNucFy.js.map +0 -1
- package/dist/assets/DeleteItemModal-DW8_baau.js +0 -47
- package/dist/assets/DeleteItemModal-DW8_baau.js.map +0 -1
- package/dist/assets/DisclaimerModal-C6UyAzGM.js +0 -21
- package/dist/assets/DisclaimerModal-C6UyAzGM.js.map +0 -1
- package/dist/assets/DriveSettingsModal-DfM8Gfc9.js +0 -103
- package/dist/assets/DriveSettingsModal-DfM8Gfc9.js.map +0 -1
- package/dist/assets/ExportDocumentWithErrorsModal-cWlxN3T_.js +0 -44
- package/dist/assets/ExportDocumentWithErrorsModal-cWlxN3T_.js.map +0 -1
- package/dist/assets/SettingsModal-BlWJfQsu.js +0 -1723
- package/dist/assets/SettingsModal-BlWJfQsu.js.map +0 -1
- package/dist/assets/UpgradeDriveModal-BL7i2apX.js +0 -40
- package/dist/assets/UpgradeDriveModal-BL7i2apX.js.map +0 -1
- package/dist/assets/ccip-DhNdZlh7.js +0 -168
- package/dist/assets/ccip-DhNdZlh7.js.map +0 -1
- package/dist/assets/confirmation-modal-DM5tMFeL.js +0 -16
- package/dist/assets/confirmation-modal-DM5tMFeL.js.map +0 -1
- package/dist/assets/disclosure-iERpR3s0.js +0 -9
- package/dist/assets/disclosure-iERpR3s0.js.map +0 -1
- package/dist/assets/drive-by-id-BanyjI1t.js +0 -14
- package/dist/assets/drive-by-id-BanyjI1t.js.map +0 -1
- package/dist/assets/dropdown-menu-CXmhaaui.js +0 -1026
- package/dist/assets/dropdown-menu-CXmhaaui.js.map +0 -1
- package/dist/assets/editor-BKLE2wdL.js +0 -416
- package/dist/assets/editor-BKLE2wdL.js.map +0 -1
- package/dist/assets/editor-DO3KuTx4.js +0 -47585
- package/dist/assets/editor-DO3KuTx4.js.map +0 -1
- package/dist/assets/form-input-DTWcBXOv.js +0 -11
- package/dist/assets/form-input-DTWcBXOv.js.map +0 -1
- package/dist/assets/hmr-DO4QUuY_.js +0 -5
- package/dist/assets/hmr-DO4QUuY_.js.map +0 -1
- package/dist/assets/hoist-non-react-statics.cjs-BXLrPRPo.js +0 -224
- package/dist/assets/hoist-non-react-statics.cjs-BXLrPRPo.js.map +0 -1
- package/dist/assets/index-BRK2SPwe.js +0 -92924
- package/dist/assets/index-BRK2SPwe.js.map +0 -1
- package/dist/assets/index-CwYYkw3b.js +0 -183
- package/dist/assets/index-CwYYkw3b.js.map +0 -1
- package/dist/assets/index-D9xz2aln.js +0 -25570
- package/dist/assets/index-D9xz2aln.js.map +0 -1
- package/dist/assets/index-DOrl22sv.css +0 -6263
- package/dist/assets/index-DrtoT5He.js +0 -45
- package/dist/assets/index-DrtoT5He.js.map +0 -1
- package/dist/assets/index-ZC6AHfIK.js +0 -285
- package/dist/assets/index-ZC6AHfIK.js.map +0 -1
- package/dist/assets/index.esm-BaENpqse.js +0 -1801
- package/dist/assets/index.esm-BaENpqse.js.map +0 -1
- package/dist/assets/options-x29vXcTw.js +0 -81
- package/dist/assets/options-x29vXcTw.js.map +0 -1
- package/dist/assets/read-required-modal-CywEDaia.js +0 -44
- package/dist/assets/read-required-modal-CywEDaia.js.map +0 -1
- package/dist/assets/toggle-CFuMlRt5.js +0 -33
- package/dist/assets/toggle-CFuMlRt5.js.map +0 -1
- package/dist/assets/virtual_ph_external-packages-DawtJ3DU.js +0 -8
- package/dist/assets/virtual_ph_external-packages-DawtJ3DU.js.map +0 -1
- package/lib/feature-flags.d.ts.map +0 -1
- package/lib/feature-flags.js.map +0 -1
- package/lib/src/components/modal/modals/settings/index.d.ts +0 -5
- package/lib/src/components/modal/modals/settings/index.d.ts.map +0 -1
- package/lib/src/components/modal/modals/settings/index.js +0 -5
- package/lib/src/components/modal/modals/settings/index.js.map +0 -1
- package/lib/src/components/toast/index.d.ts +0 -2
- package/lib/src/components/toast/index.d.ts.map +0 -1
- package/lib/src/components/toast/index.js +0 -2
- package/lib/src/components/toast/index.js.map +0 -1
- package/lib/src/components/toast/reload-connect-toast.d.ts.map +0 -1
- package/lib/src/components/toast/reload-connect-toast.js.map +0 -1
- package/lib/src/pages/demo/index.d.ts +0 -2
- package/lib/src/pages/demo/index.d.ts.map +0 -1
- package/lib/src/pages/demo/index.js +0 -2
- package/lib/src/pages/demo/index.js.map +0 -1
- package/lib/src/services/renown/index.d.ts +0 -4
- package/lib/src/services/renown/index.d.ts.map +0 -1
- package/lib/src/services/renown/index.js +0 -4
- package/lib/src/services/renown/index.js.map +0 -1
- package/lib/src/services/storage/index.d.ts +0 -4
- package/lib/src/services/storage/index.d.ts.map +0 -1
- package/lib/src/services/storage/index.js +0 -4
- package/lib/src/services/storage/index.js.map +0 -1
- /package/lib/src/components/{toast/reload-connect-toast.d.ts → reload-connect-toast.d.ts} +0 -0
- /package/lib/src/components/{toast/reload-connect-toast.js → reload-connect-toast.js} +0 -0
- /package/lib/{feature-flags.d.ts → src/feature-flags.d.ts} +0 -0
- /package/lib/{feature-flags.js → src/feature-flags.js} +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import{l as K,d as Ra,a as Oa,i as Qt,b as Ua,c as Na,g as Ma,h as Pa,e as Ha,m as ja,u as La,s as Fa,f as Va,j as za,r as Ka,P as qa,k as Ja,S as Wa,D as Za,n as Ga}from"./document_drive-CP6paqKN.js";import{C as Ya,D as Xa,d as Qa,E as ec,g as Ce,k as en,w as tc,e as nc,F as rc,G as oc,H as sc,I as ic,j as ac,h as cc}from"./document_model-DLxR7ZLO.js";import{r as Ne,g as or,a as tn}from"./sentry_react-C4W8xEsl.js";var hn={exports:{}},tt={};var Kr;function dc(){if(Kr)return tt;Kr=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,o,s){var i=null;if(s!==void 0&&(i=""+s),o.key!==void 0&&(i=""+o.key),"key"in o){s={};for(var a in o)a!=="key"&&(s[a]=o[a])}else s=o;return o=s.ref,{$$typeof:e,type:r,key:i,ref:o!==void 0?o:null,props:s}}return tt.Fragment=t,tt.jsx=n,tt.jsxs=n,tt}var qr;function uc(){return qr||(qr=1,hn.exports=dc()),hn.exports}var F1=uc();async function be(e,t){if(!t){K.error("No actions found");return}const n=Array.isArray(t)?t:[t];if(n.length===0){K.error("No actions found");return}const r=window.ph?.reactor;if(!r)return;if(!e){K.error("No document found");return}const o=await r.queueActions(e.header.id,n);return o.status!=="SUCCESS"&&K.error(o.error),o.document}async function bs(e,t){if(!t){K.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"&&K.error(o.error),o.document}async function ps(e,t,n,r){const o=r?.operationsLimit||50,s=r?.onProgress;K.verbose(`uploadDocumentOperations(documentId:${e}, ops: ${Object.keys(t).join(",")}, limit:${o})`);const i=Object.values(t).filter(d=>d!==void 0),a=i.reduce((d,f)=>d+f.length,0);let c=0;for(const d of i)for(let f=0;f<d.length;f+=o){K.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),c+=l.length,s){const h=Math.round(c/a*100);s({stage:"uploading",progress:h,totalOperations:a,uploadedOperations:c})}K.verbose(`uploadDocumentOperations:for:waitForUpdate(${e}:${b} rev ${u.index}): NEXT`)}K.verbose(`uploadDocumentOperations:for:waitForUpdate(${e}): END`)}async function fc(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 K.error(`Document model '${t.header.documentType}' not found`),e;const s=o.reducer,i=window.ph?.user,a=window.ph?.connectCrypto;if(!i||!a||!e.context?.signer)return e;const c=e.context.signer;return await Ya(e,s,t,c,a.sign)}function lc(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 hc(e,t){if(!e){K.error("No action found");return}if(!t){K.error("No document found");return}const n=await fc(e,t);return lc(n)}async function bc(e,t){if(!e){K.error("No actions found");return}const n=Array.isArray(e)?e:[e];return(await Promise.all(n.map(o=>hc(o,t)))).filter(o=>o!==void 0)}async function pc(e){try{return await window.ph?.reactor?.getDocument(e)}catch(t){K.debug(`Failed to get document with id ${e}:`,t);return}}async function wc(e,t){const n=typeof t=="string"?await pc(t):t;if(!n){K.error(`Document with id ${JSON.stringify(t)} not found`);return}const r=await bc(e,n);if(!r){K.error("No signed actions with context found");return}return await be(n,r)}class Jr extends Error{constructor(t){super(`Document type ${t} is not supported`),this.name="UnsupportedDocumentTypeError"}}class yc extends Error{constructor(t,n,r){super(`Document ${t} is not of type ${n}. Actual type: ${r}`)}}class gc extends Error{constructor(){super("There is no selected document. Call 'setSelectedNode' to select a document.")}}function mc(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 xc(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(a=>a.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(a=>Qt(a)&&a.name===e.header.name&&a.documentType===e.header.documentType&&a.parentFolder===(n??null));return i?{isDuplicate:!0,duplicateType:"name",nodeId:i.id}:{isDuplicate:!1}}catch{return{isDuplicate:!1}}}function Ec(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 Dc(e,t){ec(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(K.error)}async function vc(e,t){if(!window.ph?.reactor)return;let r="";if(e.header.documentType===Xa){const i=e.state.global.extension.replace(/^\.+|\.+$/g,"");r=i!==""?`.${i}`:""}const o=`${e.header.name||"Untitled"}${r}.phd`;if(!window.showSaveFilePicker)return Dc(e,o);try{const s=await window.showSaveFilePicker({suggestedName:o});return await Qa(e,s),s}catch(s){if(!(s instanceof DOMException&&s.name==="AbortError"))throw s}}async function ws(e){const t=window.ph?.reactor;if(!t)return;const n=t.getDocumentModelModules(),r=await nc(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 ys(e,t,n,r,o,s,i){const a=window.ph?.reactor;if(!a)return;const{isAllowedToCreateDocuments:c}=ue();if(!c)throw new Error("User is not allowed to create documents");const d=await a.getDrive(e),f=s??Ce(),u=a.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=en(f,n),b.header.name=t;const h=i?{preferredEditor:i}:void 0;await a.addDocument(b,h);const p=Oa({id:f,name:t,documentType:n,parentFolder:r??null}),w=(await be(d,p)).state.global.nodes.find(g=>g.id===f);if(!w||!Qt(w))throw new Error("There was an error adding document");return w}async function Sc(e,t,n,r){K.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 ws(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 c=!1;try{await o.getDocument(i.header.id),c=!0}catch{}const d=c?Ce():i.header.id,f=en(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 ys(t,n||i.header.name,i.header.documentType,r,l,d,i.header.meta?.preferredEditor))throw new Error("There was an error adding file");ps(d,i.operations,bs).catch(b=>{throw b})}async function Ac(e,t,n,r,o,s,i){K.verbose(`addFileWithProgress(drive: ${t}, name: ${n}, folder: ${r})`);const a=window.ph?.reactor;if(!a)return;const{isAllowedToCreateDocuments:c}=ue();if(!c)throw new Error("User is not allowed to create files");try{o?.({stage:"loading",progress:0});const d=await ws(e);if(!d)throw new Error("No document loaded");const f=await xc(d,t,r);if(f.isDuplicate&&!i){o?.({stage:"conflict",progress:0,duplicateType:f.duplicateType});return}f.isDuplicate&&i==="replace"&&f.nodeId&&await Tc(t,f.nodeId);const l=Ec(d);if(o?.(l?{stage:"loading",progress:10,documentType:l}:{stage:"loading",progress:10}),!mc(d.header.documentType,s))throw o?.({stage:"unsupported-document-type",progress:100,error:`Document type ${d.header.documentType} is not supported`}),new Jr(d.header.documentType);if(!a.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 a.getDocument(d.header.id),b=!0}catch{}const h=b?Ce():d.header.id,p=en(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 ys(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 ps(h,d.operations,bs,{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 Jr)){const f=d instanceof Error?d.message:"Unknown error occurred";o?.({stage:"failed",progress:100,error:f})}throw d}}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 create folders");const s=Ce(),i=await r.getDrive(e),c=(await be(i,Ua({id:s,name:t,parentFolder:n}))).state.global.nodes.find(d=>d.id===s);if(!c||!Na(c))throw new Error("There was an error adding folder");return c}async function Tc(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,Ra({id:t}))}async function Ic(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),a=(await be(s,La({id:t,name:n}))).state.global.nodes.find(c=>c.id===t);if(!a)throw new Error("There was an error renaming node");return a}async function Cc(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,ja({srcFolder:t.id,targetParentFolder:n?.id}))}function _c(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 tc(t.initialState,t.operations,r.reducer,void 0,en(n,t.header.documentType))}async function Wr(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=Ma({srcId:t.id,targetParentFolder:n?.id,targetName:t.name},()=>Ce(),s.state.global.nodes),a=new Map;for(const f of i){const l=s.state.global.nodes.find(u=>u.id===f.srcId);if(l){const u=Pa({nodes:s.state.global.nodes,srcName:f.targetName||l.name,targetParentFolder:f.targetParentFolder||null});a.set(f.targetId,u)}}const c=i.filter(f=>{const l=s.state.global.nodes.find(u=>u.id===f.srcId);return l!==void 0&&Qt(l)});for(const f of c)try{const l=await r.getDocument(f.srcId),u=_c(r,l,f.targetId),b=a.get(f.targetId);b&&(u.header.name=b),await r.addDocument(u)}catch(l){K.error(`Error copying document ${f.srcId}: ${String(l)}`)}const d=i.map(f=>Ha(f));return await be(s,d)}async function V1(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 K1(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 q1(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,za({name:t}))}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 change drive availability");const o=await n.getDrive(e);return await be(o,Va({availableOffline: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({type:t}))}async function Z1(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 G1(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 qa(s,i);try{await i.setListener(e,s)}catch(a){throw new Error(`Listener couldn't be registered: ${a}`)}return{driveId:e,filter:s.filter,data:{interval:`${n.pullInterval}`||"1000",listenerId:o,url:t},id:o,type:"PullResponder"}}async function Y1(e,t){const n=window.ph?.reactor;if(!n)return;const r=await n.getDrive(e);if(!(await be(r,Ja({trigger:t}))).state.local.triggers.find(i=>i.id===i.id))throw new Error(`There was an error adding the trigger ${t.id}`)}const Bc="powerhouse/generic-drive-explorer",X1="powerhouse/common";function _(e){const t=`ph:set${rc(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 a(f){return window.addEventListener(n,f),()=>{window.removeEventListener(n,f)}}function c(){if(!window.ph)throw new Error("ph global store is not defined");return window.ph[e]}function d(){return Ne.useSyncExternalStore(a,c)}return{useValue:d,setValue:r,addEventHandler:i}}const gs=_("isExternalControlsEnabled"),$c=gs.setValue,Rc=gs.addEventHandler,sr=_("isDragAndDropEnabled"),Oc=sr.setValue,Q1=sr.useValue,Uc=sr.addEventHandler,ir=_("allowedDocumentTypes"),Nc=ir.setValue;function Mc(){return ir.useValue()}const Pc=ir.addEventHandler,Hc={allowedDocumentTypes:Nc,isDragAndDropEnabled:Oc},jc={isExternalControlsEnabled:$c},ar=_("vetraPackages"),cr=ar.useValue,Lc=ar.addEventHandler;function ew(e){ar.setValue(e);const t=e?.flatMap(n=>n.modules.documentModelModules).filter(n=>n!==void 0);window.ph?.reactor?.setDocumentModelModules(t)}function ms(){return cr()?.flatMap(t=>t.modules.documentModelModules||[])}function Fc(e){return ms()?.find(n=>n.id===e)}function Zr(e){return e.toSorted((t,n)=>t.name.localeCompare(n.name))}function tw(e){return e?e.kind.toUpperCase()==="FILE":!1}function xs(e){return e?e.kind.toUpperCase()==="FOLDER":!1}function dr(e){function t(n){wc(n,e).catch(K.error)}return[e,t]}function ur(e){return globalThis.Buffer!=null?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function Es(e=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?ur(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function Ds(e,t){t||(t=e.reduce((o,s)=>o+s.length,0));const n=Es(t);let r=0;for(const o of e)n.set(o,r),r+=o.length;return ur(n)}const Vc=Object.freeze(Object.defineProperty({__proto__:null,concat:Ds},Symbol.toStringTag,{value:"Module"}));function zc(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 a=e.length,c=e.charAt(0),d=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);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 x=h[w],m=0,k=y-1;(x!==0||m<E)&&k!==-1;k--,m++)x+=256*S[k]>>>0,S[k]=x%a>>>0,x=x/a>>>0;if(x!==0)throw new Error("Non-zero carry");E=m,w++}for(var A=y-E;A!==y&&S[A]===0;)A++;for(var T=c.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]===c;)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 x=0,m=g-1;(S!==0||x<w)&&m!==-1;m--,x++)S+=a*y[m]>>>0,y[m]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");w=x,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 Kc=zc,qc=Kc;const vs=new Uint8Array(0),Jc=e=>e.reduce((t,n)=>t+n.toString(16).padStart(2,"0"),""),Wc=e=>{const t=e.match(/../g);return t?new Uint8Array(t.map(n=>parseInt(n,16))):vs},Ss=(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")},Zc=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),As=e=>new TextEncoder().encode(e),ks=e=>new TextDecoder().decode(e),Gc=Object.freeze(Object.defineProperty({__proto__:null,coerce:Ve,empty:vs,equals:Ss,fromHex:Wc,fromString:As,isBinary:Zc,toHex:Jc,toString:ks},Symbol.toStringTag,{value:"Module"}));let Yc=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")}},Xc=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 Ts(this,t)}},Qc=class{constructor(t){this.decoders=t}or(t){return Ts(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 Ts=(e,t)=>new Qc({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});let ed=class{constructor(t,n,r,o){this.name=t,this.prefix=n,this.baseEncode=r,this.baseDecode=o,this.encoder=new Yc(t,n,r),this.decoder=new Xc(t,n,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};const nn=({name:e,prefix:t,encode:n,decode:r})=>new ed(e,t,n,r),Et=({prefix:e,name:t,alphabet:n})=>{const{encode:r,decode:o}=qc(n,t);return nn({prefix:e,name:t,encode:r,decode:s=>Ve(o(s))})},td=(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 a=0,c=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`);c=c<<n|l,a+=n,a>=8&&(a-=8,i[d++]=255&c>>a)}if(a>=n||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i},nd=(e,t,n)=>{const r=t[t.length-1]==="=",o=(1<<n)-1;let s="",i=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],i+=8;i>n;)i-=n,s+=t[o&a>>i];if(i&&(s+=t[o&a<<n-i]),r)for(;s.length*n&7;)s+="=";return s},ee=({name:e,prefix:t,bitsPerChar:n,alphabet:r})=>nn({prefix:t,name:e,encode(o){return nd(o,r,n)},decode(o){return td(o,r,n,e)}}),rd=nn({prefix:"\0",name:"identity",encode:e=>ks(e),decode:e=>As(e)}),od=Object.freeze(Object.defineProperty({__proto__:null,identity:rd},Symbol.toStringTag,{value:"Module"})),sd=ee({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),id=Object.freeze(Object.defineProperty({__proto__:null,base2:sd},Symbol.toStringTag,{value:"Module"})),ad=ee({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),cd=Object.freeze(Object.defineProperty({__proto__:null,base8:ad},Symbol.toStringTag,{value:"Module"})),dd=Et({prefix:"9",name:"base10",alphabet:"0123456789"}),ud=Object.freeze(Object.defineProperty({__proto__:null,base10:dd},Symbol.toStringTag,{value:"Module"})),fd=ee({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ld=ee({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),hd=Object.freeze(Object.defineProperty({__proto__:null,base16:fd,base16upper:ld},Symbol.toStringTag,{value:"Module"})),at=ee({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),bd=ee({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),pd=ee({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wd=ee({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),yd=ee({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),gd=ee({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),md=ee({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xd=ee({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ed=ee({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Dd=Object.freeze(Object.defineProperty({__proto__:null,base32:at,base32hex:yd,base32hexpad:md,base32hexpadupper:xd,base32hexupper:gd,base32pad:pd,base32padupper:wd,base32upper:bd,base32z:Ed},Symbol.toStringTag,{value:"Module"})),vd=Et({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Sd=Et({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Ad=Object.freeze(Object.defineProperty({__proto__:null,base36:vd,base36upper:Sd},Symbol.toStringTag,{value:"Module"})),me=Et({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),kd=Et({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Td=Object.freeze(Object.defineProperty({__proto__:null,base58btc:me,base58flickr:kd},Symbol.toStringTag,{value:"Module"})),Id=ee({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Cd=ee({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_d=ee({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Bd=ee({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),$d=Object.freeze(Object.defineProperty({__proto__:null,base64:Id,base64pad:Cd,base64url:_d,base64urlpad:Bd},Symbol.toStringTag,{value:"Module"})),Is=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),Rd=Is.reduce((e,t,n)=>(e[n]=t,e),[]),Od=Is.reduce((e,t,n)=>(e[t.codePointAt(0)]=n,e),[]);function Ud(e){return e.reduce((t,n)=>(t+=Rd[n],t),"")}function Nd(e){const t=[];for(const n of e){const r=Od[n.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${n}`);t.push(r)}return new Uint8Array(t)}const Md=nn({prefix:"🚀",name:"base256emoji",encode:Ud,decode:Nd}),Pd=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:Md},Symbol.toStringTag,{value:"Module"}));var Hd=Cs,Gr=128,jd=-128,Ld=Math.pow(2,31);function Cs(e,t,n){t=t||[],n=n||0;for(var r=n;e>=Ld;)t[n++]=e&255|Gr,e/=128;for(;e&jd;)t[n++]=e&255|Gr,e>>>=7;return t[n]=e|0,Cs.bytes=n-r+1,t}var Fd=qn,Vd=128,Yr=127;function qn(e,r){var n=0,r=r||0,o=0,s=r,i,a=e.length;do{if(s>=a)throw qn.bytes=0,new RangeError("Could not decode varint");i=e[s++],n+=o<28?(i&Yr)<<o:(i&Yr)*Math.pow(2,o),o+=7}while(i>=Vd);return qn.bytes=s-r,n}var zd=Math.pow(2,7),Kd=Math.pow(2,14),qd=Math.pow(2,21),Jd=Math.pow(2,28),Wd=Math.pow(2,35),Zd=Math.pow(2,42),Gd=Math.pow(2,49),Yd=Math.pow(2,56),Xd=Math.pow(2,63),Qd=function(e){return e<zd?1:e<Kd?2:e<qd?3:e<Jd?4:e<Wd?5:e<Zd?6:e<Gd?7:e<Yd?8:e<Xd?9:10},eu={encode:Hd,decode:Fd,encodingLength:Qd},Kt=eu;const ct=(e,t=0)=>[Kt.decode(e,t),Kt.decode.bytes],dt=(e,t,n=0)=>(Kt.encode(e,t,n),t),ut=e=>Kt.encodingLength(e),tu=Object.freeze(Object.defineProperty({__proto__:null,decode:ct,encodeTo:dt,encodingLength:ut},Symbol.toStringTag,{value:"Module"})),ft=(e,t)=>{const n=t.byteLength,r=ut(e),o=r+ut(n),s=new Uint8Array(o+n);return dt(e,s,0),dt(n,s,r),s.set(t,o),new rn(e,n,t,s)},_s=e=>{const t=Ve(e),[n,r]=ct(t),[o,s]=ct(t.subarray(r)),i=t.subarray(r+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new rn(n,o,i,t)},Bs=(e,t)=>e===t?!0:e.code===t.code&&e.size===t.size&&Ss(e.bytes,t.bytes);class rn{constructor(t,n,r,o){this.code=t,this.size=n,this.digest=r,this.bytes=o}}const nu=Object.freeze(Object.defineProperty({__proto__:null,Digest:rn,create:ft,decode:_s,equals:Bs},Symbol.toStringTag,{value:"Module"})),fr=({name:e,code:t,encode:n})=>new $s(e,t,n);class $s{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?ft(this.code,n):n.then(r=>ft(this.code,r))}else throw Error("Unknown type, must be binary type")}}const ru=Object.freeze(Object.defineProperty({__proto__:null,Hasher:$s,from:fr},Symbol.toStringTag,{value:"Module"})),Rs=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),ou=fr({name:"sha2-256",code:18,encode:Rs("SHA-256")}),su=fr({name:"sha2-512",code:19,encode:Rs("SHA-512")}),iu=Object.freeze(Object.defineProperty({__proto__:null,sha256:ou,sha512:su},Symbol.toStringTag,{value:"Module"})),Os=0,au="identity",Us=Ve,cu=e=>ft(Os,Us(e)),du={code:Os,name:au,encode:Us,digest:cu},uu=Object.freeze(Object.defineProperty({__proto__:null,identity:du},Symbol.toStringTag,{value:"Module"})),fu="raw",lu=85,hu=e=>Ve(e),bu=e=>Ve(e),pu=Object.freeze(Object.defineProperty({__proto__:null,code:lu,decode:bu,encode:hu,name:fu},Symbol.toStringTag,{value:"Module"})),wu=new TextEncoder,yu=new TextDecoder,gu="json",mu=512,xu=e=>wu.encode(JSON.stringify(e)),Eu=e=>JSON.parse(yu.decode(e)),Du=Object.freeze(Object.defineProperty({__proto__:null,code:mu,decode:Eu,encode:xu,name:gu},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:Bt,byteLength:Bt,code:_t,version:_t,multihash:_t,bytes:_t,_baseCache:Bt,asCID:Bt})}toV0(){switch(this.version){case 0:return this;default:{const{code:t,multihash:n}=this;if(t!==nt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(n.code!==ku)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=ft(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&&Bs(this.multihash,t.multihash)}toString(t){const{bytes:n,version:r,_baseCache:o}=this;switch(r){case 0:return Su(n,o,t||me.encoder);default:return Au(n,o,t||at.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 Iu(/^0\.0/,Cu),!!(t&&(t[Qr]||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||Xr(n,r,o.bytes))}else if(t!=null&&t[Qr]===!0){const{version:n,multihash:r,code:o}=t,s=_s(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!==nt)throw new Error(`Version 0 CID must use dag-pb (code: ${nt}) block encoding`);return new se(t,n,r,r.bytes)}case 1:{const o=Xr(t,n,r.bytes);return new se(t,n,r,o)}default:throw new Error("Invalid version")}}static createV0(t){return se.create(0,nt,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 rn(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]=ct(t.subarray(n));return n+=u,l};let o=r(),s=nt;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,a=r(),c=r(),d=n+c,f=d-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:f,size:d}}static parse(t,n){const[r,o]=vu(t,n),s=se.decode(o);return s._baseCache.set(r,t),s}}const vu=(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 at.prefix:{const n=t||at;return[at.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)]}}},Su=(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},Au=(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},nt=112,ku=18,Xr=(e,t,n)=>{const r=ut(e),o=r+ut(t),s=new Uint8Array(o+n.byteLength);return dt(e,s,0),dt(t,s,r),s.set(n,o),s},Qr=Symbol.for("@ipld/js-cid/CID"),_t={writable:!1,configurable:!1,enumerable:!0},Bt={writable:!1,enumerable:!1,configurable:!1},Tu="0.0.0-dev",Iu=(e,t)=>{if(e.test(Tu))console.warn(t);else throw new Error(t)},Cu=`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
|
+
`,Jn={...od,...id,...cd,...ud,...hd,...Dd,...Ad,...Td,...$d,...Pd},_u={...iu,...uu},Bu={raw:pu,json:Du},$u=Object.freeze(Object.defineProperty({__proto__:null,CID:se,bases:Jn,bytes:Gc,codecs:Bu,digest:nu,hasher:ru,hashes:_u,varint:tu},Symbol.toStringTag,{value:"Module"}));function Ns(e,t,n,r){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:n},decoder:{decode:r}}}const eo=Ns("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),bn=Ns("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=Es(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}),Ms={utf8:eo,"utf-8":eo,hex:Jn.base16,latin1:bn,ascii:bn,binary:bn,...Jn};function on(e,t="utf8"){const n=Ms[t];if(!n)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ur(globalThis.Buffer.from(e,"utf-8")):n.decoder.decode(`${n.prefix}${e}`)}const Ru=Object.freeze(Object.defineProperty({__proto__:null,fromString:on},Symbol.toStringTag,{value:"Module"}));function lr(e,t="utf8"){const n=Ms[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 Ou=Object.freeze(Object.defineProperty({__proto__:null,toString:lr},Symbol.toStringTag,{value:"Module"})),ze=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Dt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function lt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ie(e,...t){if(!Dt(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 Ps(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");lt(e.outputLen),lt(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 Hs(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 Uu(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 pn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ye(e,t){return e<<32-t|e>>>t}function $t(e,t){return e<<t|e>>>32-t>>>0}const Nu=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Mu(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Pu(e){for(let t=0;t<e.length;t++)e[t]=Mu(e[t]);return e}const to=Nu?e=>e:Pu,js=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Hu=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function je(e){if(Ie(e),js)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Hu[e[n]];return t}const Se={_0:48,_9:57,A:65,F:70,a:97,f:102};function no(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 ht(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(js)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=no(e.charCodeAt(s)),a=no(e.charCodeAt(s+1));if(i===void 0||a===void 0){const c=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}r[o]=i*16+a}return r}function ju(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function sn(e){return typeof e=="string"&&(e=ju(e)),Ie(e),e}function xe(...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 hr{}function vt(e){const t=r=>e().update(sn(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function br(e=32){if(ze&&typeof ze.getRandomValues=="function")return ze.getRandomValues(new Uint8Array(e));if(ze&&typeof ze.randomBytes=="function")return Uint8Array.from(ze.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function Lu(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),a=Number(n&s),c=r?4:0,d=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+d,a,r)}function Fu(e,t,n){return e&t^~e&n}function Vu(e,t,n){return e&t^e&n^t&n}class pr extends hr{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=pn(this.buffer)}update(t){Ye(this),t=sn(t),Ie(t);const{view:n,buffer:r,blockLen:o}=this,s=t.length;for(let i=0;i<s;){const a=Math.min(o-this.pos,s-i);if(a===o){const c=pn(t);for(;o<=s-i;i+=o)this.process(c,i);continue}r.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ye(this),Hs(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;Lu(r,o-8,BigInt(this.length*8),s),this.process(r,0);const a=pn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=c/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<d;l++)a.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:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,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]),Rt=BigInt(2**32-1),ro=BigInt(32);function zu(e,t=!1){return t?{h:Number(e&Rt),l:Number(e>>ro&Rt)}:{h:Number(e>>ro&Rt)|0,l:Number(e&Rt)|0}}function Ls(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:a}=zu(e[s],t);[r[s],o[s]]=[i,a]}return[r,o]}const oo=(e,t,n)=>e>>>n,so=(e,t,n)=>e<<32-n|t>>>n,Ke=(e,t,n)=>e>>>n|t<<32-n,qe=(e,t,n)=>e<<32-n|t>>>n,Ot=(e,t,n)=>e<<64-n|t>>>n-32,Ut=(e,t,n)=>e>>>n-32|t<<64-n,Ku=(e,t,n)=>e<<n|t>>>32-n,qu=(e,t,n)=>t<<n|e>>>32-n,Ju=(e,t,n)=>t<<n-32|e>>>64-n,Wu=(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 Zu=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Gu=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Yu=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Xu=(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,Qu=(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0),ef=(e,t,n,r,o,s)=>t+n+r+o+s+(e/2**32|0)|0,tf=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 nf extends pr{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:a,H:c}=this;return[t,n,r,o,s,i,a,c]}set(t,n,r,o,s,i,a,c){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=a|0,this.H=c|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:a,F:c,G:d,H:f}=this;for(let l=0;l<64;l++){const u=ye(a,6)^ye(a,11)^ye(a,25),b=f+u+Fu(a,c,d)+tf[l]+Be[l]|0,p=(ye(r,2)^ye(r,13)^ye(r,22))+Vu(r,o,s)|0;f=d,d=c,c=a,a=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,a=a+this.E|0,c=c+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(r,o,s,i,a,c,d,f)}roundClean(){Ee(Be)}destroy(){this.set(0,0,0,0,0,0,0,0),Ee(this.buffer)}}const Fs=Ls(["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))),rf=Fs[0],of=Fs[1],$e=new Uint32Array(80),Re=new Uint32Array(80);class Vs extends pr{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:a,Dl:c,Eh:d,El:f,Fh:l,Fl:u,Gh:b,Gl:h,Hh:p,Hl:E}=this;return[t,n,r,o,s,i,a,c,d,f,l,u,b,h,p,E]}set(t,n,r,o,s,i,a,c,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=a|0,this.Dl=c|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,x=Re[y-15]|0,m=Ke(S,x,1)^Ke(S,x,8)^oo(S,x,7),k=qe(S,x,1)^qe(S,x,8)^so(S,x,7),A=$e[y-2]|0,T=Re[y-2]|0,O=Ke(A,T,19)^Ot(A,T,61)^oo(A,T,6),P=qe(A,T,19)^Ut(A,T,61)^so(A,T,6),U=Yu(k,P,Re[y-7],Re[y-16]),I=Xu(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:a,Cl:c,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=Ke(l,u,14)^Ke(l,u,18)^Ot(l,u,41),x=qe(l,u,14)^qe(l,u,18)^Ut(l,u,41),m=l&b^~l&p,k=u&h^~u&E,A=Qu(g,x,k,of[y],Re[y]),T=ef(A,w,S,m,rf[y],$e[y]),O=A|0,P=Ke(r,o,28)^Ot(r,o,34)^Ot(r,o,39),U=qe(r,o,28)^Ut(r,o,34)^Ut(r,o,39),I=r&s^r&a^s&a,D=o&i^o&c^i&c;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=a|0,f=c|0,a=s|0,c=i|0,s=r|0,i=o|0;const v=Zu(O,U,D);r=Gu(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:a,l:c}=Ae(this.Ch|0,this.Cl|0,a|0,c|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,a,c,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 sf extends Vs{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 wr=vt(()=>new nf),zs=vt(()=>new Vs),af=vt(()=>new sf);const yr=BigInt(0),Wn=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=Dt(e),o=e?.length,s=t!==void 0;if(!r||s&&o!==t){const i=n&&`"${n}" `,a=s?` of length ${t}`:"",c=r?`length=${o}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+a+", got "+c)}return e}function st(e){const t=e.toString(16);return t.length&1?"0"+t:t}function Ks(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?yr:BigInt("0x"+e)}function an(e){return Ks(je(e))}function bt(e){return Ie(e),Ks(je(Uint8Array.from(e).reverse()))}function gr(e,t){return ht(e.toString(16).padStart(t*2,"0"))}function qs(e,t){return gr(e,t).reverse()}function cf(e){return ht(st(e))}function z(e,t,n){let r;if(typeof t=="string")try{r=ht(t)}catch(s){throw new Error(e+" must be hex string or Uint8Array, cause: "+s)}else if(Dt(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 io(e){return Uint8Array.from(e)}const wn=e=>typeof e=="bigint"&&yr<=e;function df(e,t,n){return wn(e)&&wn(t)&&wn(n)&&t<=e&&e<n}function Zn(e,t,n,r){if(!df(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function Js(e){let t;for(t=0;e>yr;e>>=Wn,t+=1);return t}const St=e=>(Wn<<BigInt(e))-Wn;function uf(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),a=0;const c=()=>{s.fill(1),i.fill(0),a=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(a++>=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 xe(...h)};return(b,h)=>{c(),f(b);let p;for(;!(p=h(l()));)f();return c(),p}}function At(e,t,n={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function r(o,s,i){const a=e[o];if(i&&a===void 0)return;const c=typeof a;if(c!==s||a===null)throw new Error(`param "${o}" is invalid: expected ${s}, got ${c}`)}Object.entries(t).forEach(([o,s])=>r(o,s,!1)),Object.entries(n).forEach(([o,s])=>r(o,s,!0))}function qt(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),Ws=BigInt(3),Zs=BigInt(4),Gs=BigInt(5),ff=BigInt(7),Ys=BigInt(8),lf=BigInt(9),Xs=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 ao(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 a=r/n,c=r%n,d=o-s*a;r=n,n=c,o=s,s=d}if(r!==Q)throw new Error("invert: does not exist");return G(o,t)}function mr(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function Qs(e,t){const n=(e.ORDER+Q)/Zs,r=e.pow(t,n);return mr(e,r,t),r}function hf(e,t){const n=(e.ORDER-Gs)/Ys,r=e.mul(t,Me),o=e.pow(r,n),s=e.mul(t,o),i=e.mul(e.mul(s,Me),o),a=e.mul(s,e.sub(i,e.ONE));return mr(e,a,t),a}function bf(e){const t=ve(e),n=ei(e),r=n(t,t.neg(t.ONE)),o=n(t,r),s=n(t,t.neg(r)),i=(e+ff)/Xs;return(a,c)=>{let d=a.pow(c,i),f=a.mul(d,r);const l=a.mul(d,o),u=a.mul(d,s),b=a.eql(a.sqr(f),c),h=a.eql(a.sqr(l),c);d=a.cmov(d,f,b),f=a.cmov(u,l,h);const p=a.eql(a.sqr(f),c),E=a.cmov(d,f,p);return mr(a,E,c),E}}function ei(e){if(e<Ws)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(;co(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Qs;let s=o.pow(r,t);const i=(t+Q)/Me;return function(c,d){if(c.is0(d))return d;if(co(c,d)!==1)throw new Error("Cannot find square root");let f=n,l=c.mul(c.ONE,s),u=c.pow(d,t),b=c.pow(d,i);for(;!c.eql(u,c.ONE);){if(c.is0(u))return c.ZERO;let h=1,p=c.sqr(u);for(;!c.eql(p,c.ONE);)if(h++,p=c.sqr(p),h===f)throw new Error("Cannot find square root");const E=Q<<BigInt(f-h-1),w=c.pow(l,E);f=h,l=c.sqr(w),u=c.mul(u,l),b=c.mul(b,w)}return b}}function pf(e){return e%Zs===Ws?Qs:e%Ys===Gs?hf:e%Xs===lf?bf(e):ei(e)}const wf=(e,t)=>(G(e,t)&Q)===Q,yf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function gf(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=yf.reduce((r,o)=>(r[o]="function",r),t);return At(e,n),e}function mf(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 ti(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce((i,a,c)=>e.is0(a)?i:(r[c]=i,e.mul(i,a)),e.ONE),s=e.inv(o);return t.reduceRight((i,a,c)=>e.is0(a)?i:(r[c]=e.mul(i,r[c]),e.mul(i,a)),s),r}function co(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 ni(e,t){t!==void 0&<(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,a;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),a=u.allowedLengths}else typeof t=="number"&&(o=t),r.sqrt&&(s=r.sqrt);const{nBitLength:c,nByteLength:d}=ni(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:c,BYTES:d,MASK:St(c),ZERO:de,ONE:Q,allowedLengths:a,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)=>mf(l,u,b),div:(u,b)=>G(u*ao(b,e),e),sqrN:u=>u*u,addN:(u,b)=>u+b,subN:(u,b)=>u-b,mulN:(u,b)=>u*b,inv:u=>ao(u,e),sqrt:s||(u=>(f||(f=pf(e)),f(l,u))),toBytes:u=>n?qs(u,d):gr(u,d),fromBytes:(u,b=!0)=>{if(a){if(!a.includes(u.length)||u.length>d)throw new Error("Field.fromBytes: expected "+a+" 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?bt(u):an(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=>ti(l,u),cmov:(u,b,h)=>h?b:u});return Object.freeze(l)}function ri(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 oi(e){const t=ri(e);return t+Math.ceil(t/2)}function xf(e,t,n=!1){const r=e.length,o=ri(t),s=oi(t);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const i=n?bt(e):an(e),a=G(i,t-Q)+Q;return n?qs(a,o):gr(a,o)}const Xe=BigInt(0),Pe=BigInt(1);function Jt(e,t){const n=t.negate();return e?n:t}function He(e,t){const n=ti(e.Fp,t.map(r=>r.Z));return t.map((r,o)=>e.fromAffine(r.toAffine(n[o])))}function si(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function yn(e,t){si(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1),o=2**e,s=St(e),i=BigInt(e);return{windows:n,windowSize:r,mask:s,maxNumber:o,shiftBy:i}}function uo(e,t,n){const{windowSize:r,mask:o,maxNumber:s,shiftBy:i}=n;let a=Number(e&o),c=e>>i;a>r&&(a-=s,c+=Pe);const d=t*r,f=d+Math.abs(a)-1,l=a===0,u=a<0,b=t%2!==0;return{nextN:c,offset:f,isZero:l,isNeg:u,isNegF:b,offsetF:d}}function Ef(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 Df(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 gn=new WeakMap,ii=new WeakMap;function mn(e){return ii.get(e)||1}function fo(e){if(e!==Xe)throw new Error("invalid wNAF")}class ai{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}=yn(n,this.bits),s=[];let i=t,a=i;for(let c=0;c<r;c++){a=i,s.push(a);for(let d=1;d<o;d++)a=a.add(i),s.push(a);i=a.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=yn(t,this.bits);for(let a=0;a<i.windows;a++){const{nextN:c,offset:d,isZero:f,isNeg:l,isNegF:u,offsetF:b}=uo(r,a,i);r=c,f?s=s.add(Jt(u,n[b])):o=o.add(Jt(l,n[d]))}return fo(r),{p:o,f:s}}wNAFUnsafe(t,n,r,o=this.ZERO){const s=yn(t,this.bits);for(let i=0;i<s.windows&&r!==Xe;i++){const{nextN:a,offset:c,isZero:d,isNeg:f}=uo(r,i,s);if(r=a,!d){const l=n[c];o=o.add(f?l.negate():l)}}return fo(r),o}getPrecomputes(t,n,r){let o=gn.get(n);return o||(o=this.precomputeWindow(n,t),t!==1&&(typeof r=="function"&&(o=r(o)),gn.set(n,o))),o}cached(t,n,r){const o=mn(t);return this.wNAF(o,this.getPrecomputes(o,t,r),n)}unsafe(t,n,r,o){const s=mn(t);return s===1?this._unsafeLadder(t,n,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,r),n,o)}createCache(t,n){si(n,this.bits),ii.set(t,n),gn.delete(t)}hasCache(t){return mn(t)!==1}}function vf(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 ci(e,t,n,r){Ef(n,e),Df(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,a=Js(BigInt(o));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const d=St(c),f=new Array(Number(d)+1).fill(i),l=Math.floor((t.BITS-1)/c)*c;let u=i;for(let b=l;b>=0;b-=c){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<c;p++)u=u.double()}return u}function lo(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return gf(t),t}else return ve(e,{isLE:n})}function di(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 c of["p","n","h"]){const d=t[c];if(!(typeof d=="bigint"&&d>Xe))throw new Error(`CURVE.${c} must be positive bigint`)}const o=lo(t.p,n.Fp,r),s=lo(t.n,n.Fn,r),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(const c of a)if(!o.isValid(t[c]))throw new Error(`CURVE.${c} 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),xn=BigInt(2),Sf=BigInt(8);function Af(e,t,n,r){const o=e.sqr(n),s=e.sqr(r),i=e.add(e.mul(t.a,o),s),a=e.add(e.ONE,e.mul(t.d,e.mul(o,s)));return e.eql(i,a)}function kf(e,t={}){const n=di("edwards",e,t,t.FpFnLE),{Fp:r,Fn:o}=n;let s=n.CURVE;const{h:i}=s;At(t,{},{uvRatio:"function"});const a=xn<<BigInt(o.BYTES*8)-X,c=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(!Af(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 Zn("coordinate "+E,w,y,a),w}function l(E){if(!(E instanceof h))throw new Error("ExtendedPoint expected")}const u=qt((E,w)=>{const{X:g,Y:y,Z:S}=E,x=E.is0();w==null&&(w=x?Sf:r.inv(S));const m=c(g*w),k=c(y*w),A=r.mul(S,w);if(x)return{x:Oe,y:X};if(A!==X)throw new Error("invZ was invalid");return{x:m,y:k}}),b=qt(E=>{const{a:w,d:g}=s;if(E.is0())throw new Error("bad point: ZERO");const{X:y,Y:S,Z:x,T:m}=E,k=c(y*y),A=c(S*S),T=c(x*x),O=c(T*T),P=c(k*w),U=c(T*c(P+A)),I=c(O+c(g*c(k*A)));if(U!==I)throw new Error("bad point: equation left != right (1)");const D=c(y*S),v=c(x*m);if(D!==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,c(g*y))}static fromBytes(w,g=!1){const y=r.BYTES,{a:S,d:x}=s;w=io(we(w,y,"point")),Fe(g,"zip215");const m=io(w),k=w[y-1];m[y-1]=k&-129;const A=bt(m),T=g?a:r.ORDER;Zn("point.y",A,Oe,T);const O=c(A*A),P=c(O-X),U=c(x*O-S);let{isValid:I,value:D}=d(P,U);if(!I)throw new Error("bad point: invalid y coordinate");const v=(D&X)===X,C=(k&128)!==0;if(!g&&D===Oe&&C)throw new Error("bad point: x=0 and x_0=1");return C!==v&&(D=c(-D)),h.fromAffine({x:D,y:A})}static fromHex(w,g=!1){return h.fromBytes(z("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(xn),this}assertValidity(){b(this)}equals(w){l(w);const{X:g,Y:y,Z:S}=this,{X:x,Y:m,Z:k}=w,A=c(g*k),T=c(x*S),O=c(y*k),P=c(m*S);return A===T&&O===P}is0(){return this.equals(h.ZERO)}negate(){return new h(c(-this.X),this.Y,this.Z,c(-this.T))}double(){const{a:w}=s,{X:g,Y:y,Z:S}=this,x=c(g*g),m=c(y*y),k=c(xn*c(S*S)),A=c(w*x),T=g+y,O=c(c(T*T)-x-m),P=A+m,U=P-k,I=A-m,D=c(O*U),v=c(P*I),C=c(O*I),B=c(U*P);return new h(D,v,B,C)}add(w){l(w);const{a:g,d:y}=s,{X:S,Y:x,Z:m,T:k}=this,{X:A,Y:T,Z:O,T:P}=w,U=c(S*A),I=c(x*T),D=c(k*y*P),v=c(m*O),C=c((S+x)*(A+T)-U-I),B=v-D,N=v+D,$=c(I-g*U),R=c(C*B),M=c(N*$),H=c(C*$),q=c(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 ci(h,o,w,g)}_setWindowSize(w){this.precompute(w)}toRawBytes(){return this.toBytes()}}h.BASE=new h(s.Gx,s.Gy,X,c(s.Gx*s.Gy)),h.ZERO=new h(Oe,X,X,Oe),h.Fp=r,h.Fn=o;const p=new ai(h,o.BITS);return h.BASE.precompute(8),h}function Tf(e,t,n={}){if(typeof t!="function")throw new Error('"hash" function param is required');At(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:r}=n,{BASE:o,Fp:s,Fn:i}=e,a=n.randomBytes||br,c=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(bt(T))}function l(T){const O=y.secretKey;T=z("private key",T,O);const P=z("hashed private key",t(T),2*O),U=c(P.slice(0,O)),I=P.slice(O,2*O),D=f(U);return{head:U,prefix:I,scalar:D}}function u(T){const{head:O,prefix:P,scalar:U}=l(T),I=o.multiply(U),D=I.toBytes();return{head:O,prefix:P,scalar:U,point:I,pointBytes:D}}function b(T){return u(T).pointBytes}function h(T=Uint8Array.of(),...O){const P=xe(...O);return f(t(d(P,z("context",T),!!r)))}function p(T,O,P={}){T=z("message",T),r&&(T=r(T));const{prefix:U,scalar:I,pointBytes:D}=u(O),v=h(P.context,U,T),C=o.multiply(v).toBytes(),B=h(P.context,C,D,T),N=i.create(v+B*I);if(!i.isValid(N))throw new Error("sign failed: invalid s");const $=xe(C,i.toBytes(N));return we($,y.signature,"result")}const E={zip215:!0};function w(T,O,P,U=E){const{context:I,zip215:D}=U,v=y.signature;T=z("signature",T,v),O=z("message",O),P=z("publicKey",P,y.publicKey),D!==void 0&&Fe(D,"zip215"),r&&(O=r(O));const C=v/2,B=T.subarray(0,C),N=bt(T.subarray(C,v));let $,R,M;try{$=e.fromBytes(P,D),R=e.fromBytes(B,D),M=o.multiplyUnsafe(N)}catch{return!1}if(!D&&$.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=a(y.seed)){return we(T,y.seed,"seed")}function x(T){const O=A.randomSecretKey(T);return{secretKey:O,publicKey:b(O)}}function m(T){return Dt(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 c(P).subarray(0,O)},randomPrivateKey:S,precompute(T=8,O=e.BASE){return O.precompute(T,!1)}};return Object.freeze({keygen:x,getPublicKey:b,sign:p,verify:w,utils:A,Point:e,lengths:y})}function If(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 Cf(e,t){const n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:e,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function _f(e){const{CURVE:t,curveOpts:n,hash:r,eddsaOpts:o}=If(e),s=kf(t,n),i=Tf(s,r,o);return Cf(e,i)}const Bf=BigInt(1),ho=BigInt(2);BigInt(3);const $f=BigInt(5),Rf=BigInt(8),xr=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),ui={p:xr,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Rf,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Of(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),s=xr,a=e*e%s*e%s,c=Z(a,ho,s)*a%s,d=Z(c,Bf,s)*e%s,f=Z(d,$f,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,ho,s)*e%s,b2:a}}function Uf(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}const bo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Nf(e,t){const n=xr,r=G(t*t*t,n),o=G(r*r*t,n),s=Of(e*o).pow_p_5_8;let i=G(e*r*s,n);const a=G(t*i*i,n),c=i,d=G(i*bo,n),f=a===e,l=a===G(-e,n),u=a===G(-e*bo,n);return f&&(i=c),(l||u)&&(i=d),wf(i,n)&&(i=G(-i,n)),{isValid:f||l,value:i}}const Mf=ve(ui.p,{isLE:!0}),Pf={...ui,Fp:Mf,hash:zs,adjustScalarBytes:Uf,uvRatio:Nf},fi=_f(Pf);function Hf(e){return fi.utils.toMontgomery(z("pub",e))}var Nt={exports:{}},En,po;function jf(){if(po)return En;po=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 a=t.length,c=t.charAt(0),d=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);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 x=h[w],m=0,k=y-1;(x!==0||m<E)&&k!==-1;k--,m++)x+=256*S[k]>>>0,S[k]=x%a>>>0,x=x/a>>>0;if(x!==0)throw new Error("Non-zero carry");E=m,w++}for(var A=y-E;A!==y&&S[A]===0;)A++;for(var T=c.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]===c;)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 x=0,m=g-1;(S!==0||x<w)&&m!==-1;m--,x++)S+=a*y[m]>>>0,y[m]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");w=x,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"+a+" character")}return{encode:l,decodeUnsafe:u,decode:b}}return En=e,En}var Dn,wo;function Er(){if(wo)return Dn;wo=1;const e=new TextDecoder,t=s=>e.decode(s),n=new TextEncoder,r=s=>n.encode(s);function o(s,i){const a=new Uint8Array(i);let c=0;for(const d of s)a.set(d,c),c+=d.length;return a}return Dn={decodeText:t,encodeText:r,concat:o},Dn}var vn,yo;function Lf(){if(yo)return vn;yo=1;const{encodeText:e}=Er();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 vn=t,vn}var Sn,go;function Ff(){if(go)return Sn;go=1;const e=(r,o,s)=>{const i={};for(let u=0;u<o.length;++u)i[o[u]]=u;let a=r.length;for(;r[a-1]==="=";)--a;const c=new Uint8Array(a*s/8|0);let d=0,f=0,l=0;for(let u=0;u<a;++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,c[l++]=255&f>>d)}if(d>=s||255&f<<8-d)throw new SyntaxError("Unexpected end of data");return c},t=(r,o,s)=>{const i=o[o.length-1]==="=",a=(1<<s)-1;let c="",d=0,f=0;for(let l=0;l<r.length;++l)for(f=f<<8|r[l],d+=8;d>s;)d-=s,c+=o[a&f>>d];if(d&&(c+=o[a&f<<s-d]),i)for(;c.length*s&7;)c+="=";return c};return Sn={rfc4648:r=>o=>({encode(s){return t(s,o,r)},decode(s){return e(s,o,r)}})},Sn}var An,mo;function Vf(){if(mo)return An;mo=1;const e=jf(),t=Lf(),{rfc4648:n}=Ff(),{decodeText:r,encodeText:o}=Er(),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-_="]],a=i.reduce((d,f)=>(d[f[0]]=new t(f[0],f[1],f[2],f[3]),d),{}),c=i.reduce((d,f)=>(d[f[1]]=a[f[0]],d),{});return An={names:a,codes:c},An}var xo;function zf(){return xo||(xo=1,(function(e,t){const n=Vf(),{encodeText:r,decodeText:o,concat:s}=Er();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 a(p,E){const w=l(p),g=r(w.encode(E));return s([w.codeBuf,g],w.codeBuf.length+g.length)}function c(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=a,t.decode=c,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})(Nt,Nt.exports)),Nt.exports}var Kf=zf();class li extends hr{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,Ps(t);const r=sn(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:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,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 hi=(e,t,n)=>new li(e,t).update(n).digest();hi.create=(e,t)=>new li(e,t);const Eo=(e,t)=>(e+(e>=0?t:-t)/bi)/t;function qf(e,t,n){const[[r,o],[s,i]]=t,a=Eo(i*e,n),c=Eo(-o*e,n);let d=e-a*r-c*s,f=-a*o-c*i;const l=d<Te,u=f<Te;l&&(d=-d),u&&(f=-f);const b=St(Math.ceil(Js(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 Gn(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function kn(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&&Gn(n.format),n}class Jf extends Error{constructor(t=""){super(t)}}const ke={Err:Jf,_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=st(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const s=r>127?st(o.length/2|128):"";return st(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 c=o&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");const d=t.subarray(r,r+c);if(d.length!==c)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+=c,i<128)throw new n("tlv.decode(long): not minimal encoding")}const a=t.subarray(r,r+i);if(a.length!==i)throw new n("tlv.decode: wrong value length");return{v:a,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=st(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 an(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=ke,o=z("signature",e),{v:s,l:i}=r.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,s),{v:d,l:f}=r.decode(2,c);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(a),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),bi=BigInt(2),Mt=BigInt(3),Wf=BigInt(4);function We(e,t){const{BYTES:n}=e;let r;if(typeof t=="bigint")r=t;else{let o=z("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 Zf(e,t={}){const n=di("weierstrass",e,t),{Fp:r,Fn:o}=n;let s=n.CURVE;const{h:i,n:a}=s;At(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:c}=t;if(c&&(!r.is0(s.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const d=wi(r,o);function f(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(U,I,D){const{x:v,y:C}=I.toAffine(),B=r.toBytes(v);if(Fe(D,"isCompressed"),D){f();const N=!r.isOdd(C);return xe(pi(N),B)}else return xe(Uint8Array.of(4),B,r.toBytes(C))}function u(U){we(U,void 0,"Point");const{publicKey:I,publicKeyUncompressed:D}=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===D&&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=${D}`)}const b=t.toBytes||l,h=t.fromBytes||u;function p(U){const I=r.sqr(U),D=r.mul(I,U);return r.add(r.add(D,r.mul(U,s.a)),s.b)}function E(U,I){const D=r.sqr(I),v=p(U);return r.eql(D,v)}if(!E(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const w=r.mul(r.pow(s.a,Mt),Wf),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,D=!1){if(!r.isValid(I)||D&&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 x(U){if(!c||!c.basises)throw new Error("no endo");return qf(U,c.basises,o.ORDER)}const m=qt((U,I)=>{const{X:D,Y:v,Z:C}=U;if(r.eql(C,r.ONE))return{x:D,y:v};const B=U.is0();I==null&&(I=B?r.ONE:r.inv(C));const N=r.mul(D,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=qt(U=>{if(U.is0()){if(t.allowInfinityPoint&&!r.is0(U.Y))return;throw new Error("bad point: ZERO")}const{x:I,y:D}=U.toAffine();if(!r.isValid(I)||!r.isValid(D))throw new Error("bad point: x or y not field elements");if(!E(I,D))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,D,v,C){return D=new T(r.mul(D.X,U),D.Y,D.Z),I=Jt(v,I),D=Jt(C,D),I.add(D)}class T{constructor(I,D,v){this.X=y("x",I),this.Y=y("y",D,!0),this.Z=y("z",v),Object.freeze(this)}static CURVE(){return s}static fromAffine(I){const{x:D,y:v}=I||{};if(!I||!r.isValid(D)||!r.isValid(v))throw new Error("invalid affine point");if(I instanceof T)throw new Error("projective point not allowed");return r.is0(D)&&r.is0(v)?T.ZERO:new T(D,v,r.ONE)}static fromBytes(I){const D=T.fromAffine(h(we(I,void 0,"point")));return D.assertValidity(),D}static fromHex(I){return T.fromBytes(z("pointHex",I))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(I=8,D=!0){return P.createCache(this,I),D||this.multiply(Mt),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:D,Y:v,Z:C}=this,{X:B,Y:N,Z:$}=I,R=r.eql(r.mul(D,$),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:D}=s,v=r.mul(D,Mt),{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:D,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,Mt);let j=r.mul(D,B),J=r.mul(v,N),Y=r.mul(C,$),ce=r.add(D,v),W=r.add(B,N);ce=r.mul(ce,W),W=r.add(j,J),ce=r.sub(ce,W),W=r.add(D,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:D}=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(D){const{k1neg:N,k1:$,k2neg:R,k2:M}=x(I),{p:H,f:q}=B($),{p:V,f:j}=B(M);C=q.add(j),v=A(D.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:D}=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(D){const{k1neg:C,k1:B,k2neg:N,k2:$}=x(I),{p1:R,p2:M}=vf(T,v,B,$);return A(D.beta,R,M,C,N)}else return P.unsafe(v,I)}multiplyAndAddUnsafe(I,D,v){const C=this.multiplyUnsafe(D).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,a).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,D){return ci(T,o,I,D)}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 ai(T,t.endo?Math.ceil(O/2):O);return T.BASE.precompute(8),T}function pi(e){return Uint8Array.of(e?2:3)}function wi(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Gf(e,t={}){const{Fn:n}=e,r=t.randomBytes||br,o=Object.assign(wi(e.Fp,n),{seed:oi(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 a(b=r(o.seed)){return xf(we(b,o.seed,"seed"),n.ORDER)}function c(b,h=!0){return e.BASE.multiply(We(n,b)).toBytes(h)}function d(b){const h=a(b);return{secretKey:h,publicKey:c(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=z("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:c,getSharedSecret:l,keygen:d,Point:e,utils:{isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:a,isValidPrivateKey:s,randomPrivateKey:a,normPrivateKeyToScalar:b=>We(n,b),precompute(b=8,h=e.BASE){return h.precompute(b,!1)}},lengths:o})}function Yf(e,t,n={}){Ps(t),At(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||br,o=n.hmac||((D,...v)=>hi(t,D,xe(...v))),{Fp:s,Fn:i}=e,{ORDER:a,BITS:c}=i,{keygen:d,getPublicKey:f,getSharedSecret:l,utils:u,lengths:b}=Gf(e,n),h={prehash:!1,lowS:typeof n.lowS=="boolean"?n.lowS:!1,format:void 0,extraEntropy:!1},p="compact";function E(D){const v=a>>Ge;return D>v}function w(D,v){if(!i.isValidNot0(v))throw new Error(`invalid signature ${D}: out of range 1..Point.Fn.ORDER`);return v}function g(D,v){Gn(v);const C=b.signature,B=v==="compact"?C:v==="recovered"?C+1:void 0;return we(D,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(ht(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(a*bi<C&&$>1)throw new Error("recovery id is ambiguous for h>1 curve");const M=$===2||$===3?B+a:B;if(!s.isValid(M))throw new Error("recovery id 2 or 3 invalid");const H=s.toBytes(M),q=e.fromBytes(xe(pi(($&1)===0),H)),V=i.inv(M),j=x(z("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(Gn(v),v==="der")return ht(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 xe(Uint8Array.of(this.recovery),C,B)}return xe(C,B)}toHex(v){return je(this.toBytes(v))}assertValidity(){}static fromCompact(v){return y.fromBytes(z("sig",v),"compact")}static fromDER(v){return y.fromBytes(z("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=an(v),B=v.length*8-c;return B>0?C>>BigInt(B):C},x=n.bits2int_modN||function(v){return i.create(S(v))},m=St(c);function k(D){return Zn("num < 2^"+c,D,Te,m),i.toBytes(D)}function A(D,v){return we(D,void 0,"message"),v?we(t(D),void 0,"prehashed message"):D}function T(D,v,C){if(["recovered","canonical"].some(J=>J in C))throw new Error("sign() legacy options not supported");const{lowS:B,prehash:N,extraEntropy:$}=kn(C,h);D=A(D,N);const R=x(D),M=We(i,v),H=[k(M),k(R)];if($!=null&&$!==!1){const J=$===!0?r(b.secretKey):$;H.push(z("extraEntropy",J))}const q=xe(...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 Ct=i.create(ce*i.create(V+ne*M));if(Ct===Te)return;let Vr=(W.x===ne?0:2)|Number(W.y&Ge),zr=Ct;return B&&E(Ct)&&(zr=i.neg(Ct),Vr^=1),new y(ne,zr,Vr)}return{seed:q,k2sig:j}}function O(D,v,C={}){D=z("message",D);const{seed:B,k2sig:N}=T(D,v,C);return uf(t.outputLen,i.BYTES,o)(B,N)}function P(D){let v;const C=typeof D=="string"||Dt(D),B=!C&&D!==null&&typeof D=="object"&&typeof D.r=="bigint"&&typeof D.s=="bigint";if(!C&&!B)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(B)v=new y(D.r,D.s);else if(C){try{v=y.fromBytes(z("sig",D),"der")}catch(N){if(!(N instanceof ke.Err))throw N}if(!v)try{v=y.fromBytes(z("sig",D),"compact")}catch{return!1}}return v||!1}function U(D,v,C,B={}){const{lowS:N,prehash:$,format:R}=kn(B,h);if(C=z("publicKey",C),v=A(z("message",v),$),"strict"in B)throw new Error("options.strict was renamed to lowS");const M=R===void 0?P(D):y.fromBytes(z("sig",D),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=x(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(D,v,C={}){const{prehash:B}=kn(C,h);return v=A(v,B),y.fromBytes(D,"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 Xf(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 Qf(e){const{CURVE:t,curveOpts:n}=Xf(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 el(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,ni(n.Fn.ORDER,n.Fn.BITS))})}function tl(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=Qf(e),s=Zf(t,n),i=Yf(s,r,o);return el(e,i)}function cn(e,t){const n=r=>tl({...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")},nl={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Do=BigInt(2);function rl(e){const t=Dr.p,n=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=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,Do,t)*d%t,h=Z(b,o,t)*b%t,p=Z(h,s,t)*h%t,E=Z(p,a,t)*p%t,w=Z(E,c,t)*E%t,g=Z(w,a,t)*p%t,y=Z(g,n,t)*f%t,S=Z(y,i,t)*h%t,x=Z(S,r,t)*d%t,m=Z(x,Do,t);if(!Yn.eql(Yn.sqr(m),e))throw new Error("Cannot find square root");return m}const Yn=ve(Dr.p,{sqrt:rl}),pt=cn({...Dr,Fp:Yn,lowS:!0,endo:nl},wr);const yi={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},gi={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},mi={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},ol=ve(yi.p),sl=ve(gi.p),il=ve(mi.p),al=cn({...yi,Fp:ol,lowS:!1},wr),cl=cn({...gi,Fp:sl,lowS:!1},af),dl=cn({...mi,Fp:il,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},zs);const Wt=al,ul=wr,fl=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),xi=Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)),ll=xi.map(e=>(9*e+5)%16),Ei=(()=>{const n=[[xi],[ll]];for(let r=0;r<4;r++)for(let o of n)o.push(o[r].map(s=>fl[s]));return n})(),Di=Ei[0],vi=Ei[1],Si=[[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)),hl=Di.map((e,t)=>e.map(n=>Si[t][n])),bl=vi.map((e,t)=>e.map(n=>Si[t][n])),pl=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),wl=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function vo(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 Pt=new Uint32Array(16);class yl extends pr{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)Pt[b]=t.getUint32(n,!0);let r=this.h0|0,o=r,s=this.h1|0,i=s,a=this.h2|0,c=a,d=this.h3|0,f=d,l=this.h4|0,u=l;for(let b=0;b<5;b++){const h=4-b,p=pl[b],E=wl[b],w=Di[b],g=vi[b],y=hl[b],S=bl[b];for(let x=0;x<16;x++){const m=$t(r+vo(b,s,a,d)+Pt[w[x]]+p,y[x])+l|0;r=l,l=d,d=$t(a,10)|0,a=s,s=m}for(let x=0;x<16;x++){const m=$t(o+vo(h,i,c,f)+Pt[g[x]]+E,S[x])+u|0;o=u,u=f,f=$t(c,10)|0,c=i,i=m}}this.set(this.h1+a+f|0,this.h2+d+u|0,this.h3+l+o|0,this.h4+r+i|0,this.h0+s+c|0)}roundClean(){Ee(Pt)}destroy(){this.destroyed=!0,Ee(this.buffer),this.set(0,0,0,0,0)}}const gl=vt(()=>new yl),Ai=gl,ml=BigInt(0),rt=BigInt(1),xl=BigInt(2),El=BigInt(7),Dl=BigInt(256),vl=BigInt(113),ki=[],Ti=[],Ii=[];for(let e=0,t=rt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],ki.push(2*(5*r+n)),Ti.push((e+1)*(e+2)/2%64);let o=ml;for(let s=0;s<7;s++)t=(t<<rt^(t>>El)*vl)%Dl,t&xl&&(o^=rt<<(rt<<BigInt(s))-rt);Ii.push(o)}const Ci=Ls(Ii,!0),Sl=Ci[0],Al=Ci[1],So=(e,t,n)=>n>32?Ju(e,t,n):Ku(e,t,n),Ao=(e,t,n)=>n>32?Wu(e,t,n):qu(e,t,n);function kl(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 a=(i+8)%10,c=(i+2)%10,d=n[c],f=n[c+1],l=So(d,f,1)^n[a],u=Ao(d,f,1)^n[a+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 a=Ti[i],c=So(o,s,a),d=Ao(o,s,a),f=ki[i];o=e[f],s=e[f+1],e[f]=c,e[f+1]=d}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)n[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=Sl[r],e[1]^=Al[r]}Ee(n)}class vr extends hr{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,lt(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Uu(this.state)}clone(){return this._cloneInto()}keccak(){to(this.state32),kl(this.state32,this.rounds),to(this.state32),this.posOut=0,this.pos=0}update(t){Ye(this),t=sn(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 a=0;a<i;a++)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 lt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Hs(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 vr(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 Tl=(e,t,n)=>vt(()=>new vr(t,e,n)),Il=Tl(1,136,256/8);var Tn,ko;function Cl(){return ko||(ko=1,Tn=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])}`},"")}}`}),Tn}var _l=Cl();const Bl=or(_l);function $l(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function Rl(){const e=new Map;return function(t,n){try{let o=function(i){if(r)return i;const a=e.get(t.didUrl);return a!==void 0?a:Promise.resolve(n()).then(function(c){var d;return((d=c.didResolutionMetadata)==null?void 0:d.error)!=="notFound"&&e.set(t.didUrl,c),c})},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 Ol(e,t){return t()}const Ul="(?:%[0-9a-fA-F]{2})",To=`(?:[a-zA-Z0-9._-]|${Ul})`,Nl="([a-z0-9]+)",Ml=`((?:${To}*:)*(${To}+))`,Io="[a-zA-Z0-9_.:%-]",Pl=`;${Io}+=${Io}*`,Hl=`((${Pl})*)`,jl="(/[^#?]*)?",Ll="([?][^#]*)?",Fl="(#.*)?",Vl=new RegExp(`^did:${Nl}:${Ml}${Hl}${jl}${Ll}${Fl}$`);function _i(e){if(e===""||!e)return null;const t=e.match(Vl);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 Zt={didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};function zl(e){return function(t,n,r){try{return Promise.resolve($l(function(){return Promise.resolve(e(t,n,r)).then(function(o){return{...Zt,didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:o}})},function(o){return{...Zt,didResolutionMetadata:{error:"notFound",message:o.toString()}}}))}catch(o){return Promise.reject(o)}}}class Kl{constructor(t={},n={}){this.registry=void 0,this.cache=void 0,this.registry=t,this.cache=n.cache===!0?Rl():n.cache||Ol,n.legacyResolvers&&Object.keys(n.legacyResolvers).map(r=>{this.registry[r]||(this.registry[r]=zl(n.legacyResolvers[r]))})}resolve(t,n={}){try{const r=this,o=_i(t);if(o===null)return Promise.resolve({...Zt,didResolutionMetadata:{error:"invalidDid"}});const s=r.registry[o.method];return s?Promise.resolve(r.cache(o,()=>s(o.did,o,r,n))):Promise.resolve({...Zt,didResolutionMetadata:{error:"unsupportedDidMethod"}})}catch(r){return Promise.reject(r)}}}function Bi(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function $i(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 ql(e){if(typeof e!="function")throw new Error("function expected");return!0}function wt(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Ri(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Xn(e){if(!Array.isArray(e))throw new Error("array expected")}function Oi(e,t){if(!$i(!0,t))throw new Error(`${e}: array of strings expected`)}function Ui(e,t){if(!$i(!1,t))throw new Error(`${e}: array of numbers expected`)}function Jl(...e){const t=s=>s,n=(s,i)=>a=>s(i(a)),r=e.map(s=>s.encode).reduceRight(n,t),o=e.map(s=>s.decode).reduce(n,t);return{encode:r,decode:o}}function Wl(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Oi("alphabet",t);const r=new Map(t.map((o,s)=>[o,s]));return{encode:o=>(Xn(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=>(Xn(o),o.map(s=>{wt("alphabet.decode",s);const i=r.get(s);if(i===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${e}`);return i}))}}function Zl(e=""){return wt("join",e),{encode:t=>(Oi("join.decode",t),t.join(e)),decode:t=>(wt("join.decode",t),t.split(e))}}const Ni=(e,t)=>t===0?e:Ni(t,e%t),Gt=(e,t)=>e+(t-Ni(e,t)),Lt=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Qn(e,t,n,r){if(Xn(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(Gt(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Gt(t,n)}`);let o=0,s=0;const i=Lt[t],a=Lt[n]-1,c=[];for(const d of e){if(Ri(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)c.push((o>>s-n&a)>>>0);const f=Lt[s];if(f===void 0)throw new Error("invalid carry");o&=f-1}if(o=o<<n-s&a,!r&&s>=t)throw new Error("Excess padding");if(!r&&o>0)throw new Error(`Non-zero padding: ${o}`);return r&&s>0&&c.push(o>>>0),c}function Gl(e,t=!1){if(Ri(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Gt(8,e)>32||Gt(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Bi(n))throw new Error("radix2.encode input should be Uint8Array");return Qn(Array.from(n),8,e,!t)},decode:n=>(Ui("radix2.decode",n),Uint8Array.from(Qn(n,e,8,t)))}}function Co(e){return ql(e),function(...t){try{return e.apply(null,t)}catch{}}}const er=Jl(Wl("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Zl("")),_o=[996825010,642813549,513874426,1027748829,705979059];function ot(e){const t=e>>25;let n=(e&33554431)<<5;for(let r=0;r<_o.length;r++)(t>>r&1)===1&&(n^=_o[r]);return n}function Bo(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=ot(o)^i>>5}o=ot(o);for(let s=0;s<r;s++)o=ot(o)^e.charCodeAt(s)&31;for(let s of t)o=ot(o)^s;for(let s=0;s<6;s++)o=ot(o);return o^=n,er.encode(Qn([o%Lt[30]],30,5,!1))}function Yl(e){const t=e==="bech32"?1:734539939,n=Gl(5),r=n.decode,o=n.encode,s=Co(r);function i(l,u,b=90){wt("bech32.encode prefix",l),Bi(u)&&(u=Array.from(u)),Ui("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=Bo(E,u,t);return`${E}1${er.encode(u)}${w}`}function a(l,u=90){wt("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=er.decode(w).slice(0,-6),y=Bo(E,g,t);if(!w.endsWith(y))throw new Error(`Invalid checksum in ${l}: expected "${y}"`);return{prefix:E,words:g}}const c=Co(a);function d(l){const{prefix:u,words:b}=a(l,!1);return{prefix:u,words:b,bytes:r(b)}}function f(l,u){return i(l,o(u))}return{encode:i,decode:a,encodeFromBytes:f,decodeToBytes:d,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:s,toWords:o}}const $o=Yl("bech32"),he={toString:lr,fromString:on,concat:Ds};function Sr(e){return he.toString(e,"base64url")}function fe(e){const t=e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");return he.fromString(t,"base64url")}function Mi(e){return he.fromString(e,"base58btc")}function Xl(e){return he.toString(e,"base58btc")}const Ql={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"]},Ht={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},eh={"ed25519-pub":237,"x25519-pub":236,"secp256k1-pub":231,"bls12_381-g1-pub":234,"bls12_381-g2-pub":235,"p256-pub":4608},th={"bls12_381-g1-pub":"Bls12381G1","bls12_381-g2-pub":"Bls12381G2","ed25519-pub":"Ed25519","p256-pub":"P-256","secp256k1-pub":"Secp256k1","x25519-pub":"X25519"};function dn(e){if(e.publicKeyBase58)return{keyBytes:Mi(e.publicKeyBase58),keyType:Ht[e.type]};if(e.publicKeyBase64)return{keyBytes:fe(e.publicKeyBase64),keyType:Ht[e.type]};if(e.publicKeyHex)return{keyBytes:Ft(e.publicKeyHex),keyType:Ht[e.type]};if(e.publicKeyJwk&&e.publicKeyJwk.crv==="secp256k1"&&e.publicKeyJwk.x&&e.publicKeyJwk.y)return{keyBytes:pt.ProjectivePoint.fromAffine({x:jt(fe(e.publicKeyJwk.x)),y:jt(fe(e.publicKeyJwk.y))}).toRawBytes(!1),keyType:"Secp256k1"};if(e.publicKeyJwk&&e.publicKeyJwk.crv==="P-256"&&e.publicKeyJwk.x&&e.publicKeyJwk.y)return{keyBytes:Wt.ProjectivePoint.fromAffine({x:jt(fe(e.publicKeyJwk.x)),y:jt(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}=nh(e.publicKeyMultibase);return{keyBytes:t,keyType:n??Ht[e.type]}}return{keyBytes:new Uint8Array}}function nh(e){const t=Kf.decode(e);if([32,33,48,64,65,96].includes(t.length))return{keyBytes:t};try{const[n,r]=ct(t),o=Object.entries(eh).filter(([,s])=>s===n)?.[0][0]??"";return{keyBytes:t.slice(r),keyType:th[o]}}catch{return{keyBytes:t}}}function Ft(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 Ro(e){return Sr(he.fromString(e))}function Pi(e){return he.toString(fe(e))}function Ue(e){return he.toString(e,"base16")}function jt(e){return BigInt("0x"+he.toString(e,"base16"))}function rh(e){return he.fromString(e,"utf-8")}function Hi({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 Sr(o)}function oh(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"?on(e):e;return ul(t)}const sh=Il;function ji(e){const t=on(e.slice(2),"base16");return`0x${lr(sh(t).slice(-20),"base16")}`}function Ar(e){return typeof e=="object"&&"r"in e&&"s"in e}function ih(){return function(t,n){try{return Promise.resolve(n(t)).then(function(r){return Ar(r)?Hi(r):r})}catch(r){return Promise.reject(r)}}}function Oo(e){return function(n,r){try{return Promise.resolve(r(n)).then(function(o){if(Ar(o))return Hi(o,e);if(e&&typeof oh(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 Uo(){return function(t,n){try{return Promise.resolve(n(t)).then(function(r){if(Ar(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 ah={ES256:ih(),ES256K:Oo(),"ES256K-R":Oo(!0),Ed25519:Uo(),EdDSA:Uo()};function ch(e){const t=ah[e];if(!t)throw new Error(`not_supported: Unsupported algorithm ${e}`);return t}function dh(e,t){const n=Ue(Mi(t).slice(0,1)),r=Ft(e),o=Ai(Le(r)),s=n+Ue(o),i=Le(Ft(s)),a=Le(i),c=Ue(a).substring(0,8),d=s+c;return Xl(Ft(d))}function uh(e,t){const n=pt.ProjectivePoint.fromHex(e).toRawBytes(),r=Ai(Le(n)),o=$o.toWords(r);return $o.encode(t,o).replace(t,"")}function fh(e,t){if(t){const n=t.split(":");switch(n[0]){case"bip122":n[n.length-1]=dh(e,n[n.length-1]);break;case"cosmos":n[n.length-1]=uh(e,n[1]);break;case"eip155":n[n.length-1]=ji(e);break;default:return!1}return n.join(":").toLowerCase()===t.toLowerCase()}return!1}function lh(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 tr(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 hh(e,t,n){const r=Le(e),o=Wt.Signature.fromCompact(tr(t).compact),i=n.filter(a=>!a.ethereumAddress&&!a.blockchainAccountId).find(a=>{try{const{keyBytes:c}=dn(a);return Wt.verify(o,r,c)}catch{return!1}});if(!i)throw new Error("invalid_signature: Signature invalid for JWT");return i}function bh(e,t,n){const r=Le(e),o=pt.Signature.fromCompact(fe(t)).normalizeS(),s=n.filter(c=>!c.ethereumAddress&&!c.blockchainAccountId),i=n.filter(c=>c.ethereumAddress||c.blockchainAccountId);let a=s.find(c=>{try{const{keyBytes:d}=dn(c);return pt.verify(o,r,d)}catch{return!1}});if(!a&&i.length>0&&(a=Li(e,t,i)),!a)throw new Error("invalid_signature: Signature invalid for JWT");return a}function Li(e,t,n){const r=[];if(t.length>86)r.push(tr(t,!0));else{const i=tr(t,!1);r.push({...i,recovery:0}),r.push({...i,recovery:1})}const o=Le(e),s=i=>{const c=pt.Signature.fromCompact(i.compact).addRecoveryBit(i.recovery||0).recoverPublicKey(o),d=ji(c.toHex(!1)).toLowerCase(),f=c.toHex(!1),l=c.toHex(!0);return n.find(u=>{const{keyBytes:b}=dn(u),h=Ue(b);return h===f||h===l||u.ethereumAddress?.toLowerCase()===d||u.blockchainAccountId?.split("@eip155")?.[0].toLowerCase()===d||fh(f,u.blockchainAccountId)})};for(const i of r){const a=s(i);if(a)return a}throw new Error("invalid_signature: Signature invalid for JWT")}function No(e,t,n){const r=rh(e),o=fe(t),s=n.find(i=>{const{keyBytes:a,keyType:c}=dn(i);return c==="Ed25519"?fi.verify(o,r,a):!1});if(!s)throw new Error("invalid_signature: Signature invalid for JWT");return s}const ph={ES256:hh,ES256K:bh,"ES256K-R":Li,Ed25519:No,EdDSA:No};function Fi(e){const t=ph[e];if(!t)throw new Error(`not_supported: Unsupported algorithm ${e}`);return t}Fi.toSignatureObject=lh;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 wh(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}const yh=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 a;const c=s.conditionDelegated;return Promise.resolve(zi(i.resolver,t.alg,c,i.proofPurpose)).then(function(d){let f;function l(p){if(a)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 ${c}.`);const b=d.authenticators.find(p=>p.id===c);if(!b)throw new Error(`${L.NO_SUITABLE_KEYS}: Could not find delegated authenticator ${c} in it's DID Document`);const h=(function(){if(b.type===kr)return Promise.resolve(Tr(e,{...i,didAuthenticator:{didResolutionResult:u,authenticators:[b],issuer:b.id}})).then(function({verified:p}){p&&(a=b)});try{a=Ir({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(a){return Promise.reject(a)}},Mo=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 Vi(e){return e instanceof Qe&&e.s&1}function gh(e,t,n){var r=-1,o,s;function i(a){try{for(;++r<e.length&&(!n||!n());)if(a=t(r),a&&a.then)if(Vi(a))a=a.v;else{a.then(i,s||(s=ae.bind(null,o=new Qe,2)));return}o?ae(o,1,a):o=a}catch(c){ae(o||(o=new Qe),2,c)}}return i(),o}const mh=function(e,{header:t,payload:n,data:r,signature:o},s,i){try{let a=function(b){if(c)return b;throw new Error(`${L.INVALID_SIGNATURE}: condition for authenticator ${s.id} is not met.`)},c;if(!s.conditionWeightedThreshold||!s.threshold)throw new Error("Expected conditionWeightedThreshold and threshold");const d=[],f=s.threshold;let l=0;const u=xh(s.conditionWeightedThreshold,function(b){function h(g){if(c)return g;if(E&&!d.includes(E.id)&&(d.push(E.id),l+=b.weight,l>=f))return c=1,s}const p=b.condition;let E;const w=wh(function(){if(p.type===kr){if(!i.didAuthenticator)throw new Error("Expected didAuthenticator");const g={...i,didAuthenticator:{didResolutionResult:i.didAuthenticator?.didResolutionResult,authenticators:[p],issuer:p.id}};return Promise.resolve(Tr(e,g)).then(function({verified:y}){y&&(E=p)})}else return Promise.resolve(Ir({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 c});return Promise.resolve(u&&u.then?u.then(a):a(u))}catch(a){return Promise.reject(a)}};function xh(e,t,n){if(typeof e[Mo]=="function"){let f=function(l){try{for(;!(o=r.next()).done&&(!n||!n());)if(l=t(o.value),l&&l.then)if(Vi(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[Mo](),o,s,i;if(f(),r.return){var a=function(l){try{o.done||r.return()}catch{}return l};if(s&&s.then)return s.then(a,function(l){throw a(l)});a()}return s}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],d=0;d<e.length;d++)c.push(e[d]);return gh(c,function(f){return t(c[f])},n)}const Eh=function(e,{header:t,payload:n,signature:r,data:o},s,i){try{if(s.conditionWeightedThreshold)return mh(e,{header:t,payload:n,data:o,signature:r},s,i);if(s.conditionDelegated)return yh(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(a){return Promise.reject(a)}},Po=function(e,{header:t,payload:n,signature:r,data:o},s,i){try{return s.type===kr?Eh(e,{payload:n,header:t,signature:r,data:o},s,i):Promise.resolve(Ir({header:t,payload:n,data:o,signature:r},[s]))}catch(a){return Promise.reject(a)}},kr="ConditionalProof2022";function ie(e,t,n){if(!e.s){if(n instanceof yt)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 yt=(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 it(e){return e instanceof yt&&e.s&1}function Dh(e,t,n){var r=-1,o,s;function i(a){try{for(;++r<e.length&&(!n||!n());)if(a=t(r),a&&a.then)if(it(a))a=a.v;else{a.then(i,s||(s=ie.bind(null,o=new yt,2)));return}o?ie(o,1,a):o=a}catch(c){ie(o||(o=new yt),2,c)}}return i(),o}function vh(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function Sh(e,t,n){for(var r;;){var o=e();if(it(o)&&(o=o.v),!o)return s;if(o.then){r=0;break}var s=n();if(s&&s.then)if(it(s))s=s.s;else{r=1;break}var i}var a=new yt,c=ie.bind(null,a,2);return(r===0?o.then(f):r===1?s.then(d):i.then(l)).then(void 0,c),a;function d(u){s=u;do{if(o=e(),!o||it(o)&&!o.v){ie(a,1,s);return}if(o.then){o.then(f).then(void 0,c);return}s=n(),it(s)&&(s=s.v)}while(!s||!s.then);s.then(d).then(void 0,c)}function f(u){u?(s=n(),s&&s.then?s.then(d).then(void 0,c):d(s)):ie(a,1,s)}function l(){(o=e())?o.then?o.then(f).then(void 0,c):f(o):ie(a,1,s)}}const zi=function(e,t,n,r){try{const o=Ql[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:Ho})).then(function(i){if(Object.getOwnPropertyNames(i).indexOf("didDocument")===-1?s={didDocument:i,didDocumentMetadata:{},didResolutionMetadata:{contentType:Ho}}: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 a=(f,l)=>{const u=f.filter(({id:b})=>l===b);return u.length>0?u[0]:null};let c=[...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=[...c.map(f=>f.id)]),c=(s.didDocument[r]||[]).map(f=>typeof f=="string"?a(c,f):typeof f.publicKey=="string"?a(c,f.publicKey):f).filter(f=>f!=null));const d=c.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)}},Tr=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:Bh,x=y+S;if(t.policies?.nbf!==!1&&r.nbf){if(r.nbf>x)throw new Error(`${L.INVALID_JWT}: JWT not valid before nbf: ${r.nbf}`)}else if(t.policies?.iat!==!1&&r.iat&&r.iat>x)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}=_i(c);let E=null;const w=(function(){if(p!==c){const g=d.find(y=>y.id===c);if(!g)throw new Error(`${L.INVALID_JWT}: No authenticator found for did URL ${c}`);return Promise.resolve(Po(e,{payload:r,header:o,signature:s,data:i},g,t)).then(function(y){E=y})}else{let g=0;return Sh(function(){return!b&&!E&&g<d.length},void 0,function(){function y(m){g++}const S=d[g],x=vh(function(){return Promise.resolve(Po(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 x&&x.then?x.then(y):y(x)})}})();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}=un(e,!1),a=Object.prototype.hasOwnProperty.call(t,"auth")?t.auth?"authentication":void 0:t.proofPurpose;let c;if(!r.iss&&!r.client_id)throw new Error(`${L.INVALID_JWT}: JWT iss or client_id are required`);if(t.didAuthenticator)c=t.didAuthenticator.issuer;else if(r.iss===Th||r.iss===Ih){if(!r.sub)throw new Error(`${L.INVALID_JWT}: JWT sub is required`);typeof r.sub_jwk>"u"?c=r.sub:c=(o.kid||"").split("#")[0]}else if(r.iss===Ch){if(!r.did)throw new Error(`${L.INVALID_JWT}: JWT did is required`);c=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`);c=r.client_id}else c=r.iss;if(!c)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(zi(t.resolver,o.alg,c,a)).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)}},Ah=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=Dh(r,function(a){const c=r[a],d={typ:"JWT",alg:c.alg};return a!==0&&(d.cty="JWT"),Promise.resolve(Ki(o,{...c,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)}},Ki=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 a={iat:Math.floor(Date.now()/1e3),exp:void 0};if(o)if(typeof o=="number")a.exp=(e.nbf||a.iat)+Math.floor(o);else throw new Error("invalid_argument: JWT expiresIn is not a number");const c={...a,...e,iss:t};return kh(c,n,i,{canonicalize:s})}catch(a){return Promise.reject(a)}},kh=function(e,t,n={},r={}){try{n.alg||(n.alg=_h);const o=typeof e=="string"?e:jo(e,r.canonicalize),s=[jo(n,r.canonicalize),o].join("."),i=ch(n.alg);return Promise.resolve(i(s,t)).then(function(a){return[s,a].join(".")})}catch(o){return Promise.reject(o)}},Th="https://self-issued.me/v2",Ih="https://self-issued.me/v2/openid-vc",Ch="https://self-issued.me",_h="ES256K",Ho="application/did+json";function jo(e,t=!1){return Ro(t?Bl(e):JSON.stringify(e))}const Bh=300;function $h(e){const t=e.match(/^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)$/);if(t)return{header:JSON.parse(Pi(t[1])),payload:t[2],signature:t[3],data:`${t[1]}.${t[2]}`};throw new Error("invalid_argument: Incorrect format JWS")}function un(e,t=!0){if(!e)throw new Error("invalid_argument: no JWT passed into decodeJWT");try{const n=$h(e),r=Object.assign(n,{payload:JSON.parse(Pi(n.payload))}),o=r.payload.iss;if(r.header.cty==="JWT"&&t){const s=un(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 Ir({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 Fi(e.alg)(n,r,o)}catch(a){if(!a.message.startsWith(L.INVALID_SIGNATURE))throw a}e.cty!=="JWT"?i=!1:{payload:t,header:e,signature:r,data:n}=un(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 In,Lo;function Rh(){if(Lo)return In;Lo=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 In=e,In}var Cn,Fo;function Oh(){if(Fo)return Cn;Fo=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 Cn=e,Cn}var _n,Vo;function Uh(){if(Vo)return _n;Vo=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 _n=e,_n}const Nh=tn($u);var Bn,zo;function qi(){if(zo)return Bn;zo=1;const{bases:e}=Nh;function t(s,i,a,c){return{name:s,prefix:i,encoder:{name:s,prefix:i,encode:a},decoder:{decode:c}}}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 a=0;a<s.length;a++)i+=String.fromCharCode(s[a]);return i},s=>{s=s.substring(1);const i=new Uint8Array(s.length);for(let a=0;a<s.length;a++)i[a]=s.charCodeAt(a);return i});return Bn={utf8:n,"utf-8":n,hex:e.base16,latin1:r,ascii:r,binary:r,...e},Bn}var $n,Ko;function Mh(){if(Ko)return $n;Ko=1;const e=qi();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 Rn,qo;function Ph(){if(qo)return Rn;qo=1;const e=qi();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 Rn=t,Rn}var On,Jo;function Hh(){if(Jo)return On;Jo=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 On=e,On}var Un,Wo;function jh(){if(Wo)return Un;Wo=1;const e=Rh(),t=Oh(),n=Uh(),r=Mh(),o=Ph(),s=Hh();return Un={compare:e,concat:t,equals:n,fromString:r,toString:o,xor:s},Un}var Vt=jh(),Nn,Zo;function Lh(){if(Zo)return Nn;Zo=1,Nn=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 a=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-a+1,s}return Nn}var Mn,Go;function Fh(){if(Go)return Mn;Go=1,Mn=n;var e=128,t=127;function n(r,i){var s=0,i=i||0,a=0,c=i,d,f=r.length;do{if(c>=f||a>49)throw n.bytes=0,new RangeError("Could not decode varint");d=r[c++],s+=a<28?(d&t)<<a:(d&t)*Math.pow(2,a),a+=7}while(d>=e);return n.bytes=c-i,s}return Mn}var Pn,Yo;function Vh(){if(Yo)return Pn;Yo=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),a=Math.pow(2,56),c=Math.pow(2,63);return Pn=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<a?8:d<c?9:10},Pn}var Hn,Xo;function Cr(){return Xo||(Xo=1,Hn={encode:Lh(),decode:Fh(),encodingLength:Vh()}),Hn}const zh=tn(Vc),Kh=tn(Ou),qh=tn(Ru);var jn,Qo;function Ji(){if(Qo)return jn;Qo=1;const e=Cr(),{toString:t}=Kh,{fromString:n}=qh;jn={numberToUint8Array:o,uint8ArrayToNumber:r,varintUint8ArrayEncode:s,varintEncode:i};function r(a){return parseInt(t(a,"base16"),16)}function o(a){let c=a.toString(16);return c.length%2===1&&(c="0"+c),n(c,"base16")}function s(a){return Uint8Array.from(e.encode(r(a)))}function i(a){return Uint8Array.from(e.encode(a))}return jn}var Ln,es;function Jh(){return es||(es=1,Ln={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})}),Ln}var Fn,ts;function Wh(){if(ts)return Fn;ts=1;const{baseTable:e}=Jh(),t=Ji().varintEncode,n={},r={},o={};for(const i in e){const a=i,c=e[a];n[a]=t(c);const d=a.toUpperCase().replace(/-/g,"_");r[d]=c,o[c]||(o[c]=a)}Object.freeze(n),Object.freeze(r),Object.freeze(o);const s=Object.freeze(e);return Fn={nameToVarint:n,constantToCode:r,nameToCode:s,codeToName:o},Fn}var Vn,ns;function Zh(){if(ns)return Vn;ns=1;const e=Cr(),{concat:t}=zh,n=Ji(),{nameToVarint:r,constantToCode:o,nameToCode:s,codeToName:i}=Wh();function a(x,m){let k;if(x instanceof Uint8Array)k=n.varintUint8ArrayEncode(x);else if(r[x])k=r[x];else throw new Error("multicodec not recognized");return t([k,m],k.length+m.length)}function c(x){return e.decode(x),x.slice(e.decode.bytes)}function d(x){const m=e.decode(x),k=i[m];if(k===void 0)throw new Error(`Code "${m}" not found`);return k}function f(x){return i[x]}function l(x){const m=s[x];if(m===void 0)throw new Error(`Codec "${x}" not found`);return m}function u(x){return e.decode(x)}function b(x){const m=r[x];if(m===void 0)throw new Error(`Codec "${x}" not found`);return m}function h(x){return n.varintEncode(x)}function p(x){return d(x)}function E(x){return f(x)}function w(x){return l(x)}function g(x){return u(x)}function y(x){return b(x)}function S(x){return Array.from(h(x))}return Vn={addPrefix:a,rmPrefix:c,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},Vn}var Gh=Zh();const Yh=or(Gh);function Xh(e,t){const n=new Uint8Array(e.length+1);return n[0]=2+(t[t.length-1]&1),n.set(e,1),n}function Qh(e){const t=e.slice(0,e.length/2),n=e.slice(e.length/2,e.length),r=Vt.fromString(t,"base16"),o=Vt.fromString(n,"base16"),s=Xh(r,o);return Vt.toString(s,"base16")}function e0(e){return e.slice(2)}function t0(e,t){const n=Vt.fromString(t,"base16");return n0(e,n)}function n0(e,t){const n=Yh.addPrefix(e,t);return`did:key:${me.encode(n)}`}function Wi(e=0){return new Uint8Array(e)}function Zi(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));const n=Wi(t);let r=0;for(const o of e)n.set(o,r),r+=o.length;return n}function r0(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 o0(e){return new TextEncoder().encode(e)}function s0(e){return new TextDecoder().decode(e)}function i0(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 a=e.length,c=e.charAt(0),d=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);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 x=h[w],m=0,k=y-1;(x!==0||m<E)&&k!==-1;k--,m++)x+=256*S[k]>>>0,S[k]=x%a>>>0,x=x/a>>>0;if(x!==0)throw new Error("Non-zero carry");E=m,w++}for(var A=y-E;A!==y&&S[A]===0;)A++;for(var T=c.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]===c;)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 x=0,m=g-1;(S!==0||x<w)&&m!==-1;m--,x++)S+=a*y[m]>>>0,y[m]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");w=x,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 a0=i0,c0=a0;class d0{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 u0{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 Gi(this,t)}}class f0{decoders;constructor(t){this.decoders=t}or(t){return Gi(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 Gi(e,t){return new f0({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class l0{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 d0(t,n,r),this.decoder=new u0(t,n,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}function fn({name:e,prefix:t,encode:n,decode:r}){return new l0(e,t,n,r)}function kt({name:e,prefix:t,alphabet:n}){const{encode:r,decode:o}=c0(n,e);return fn({prefix:t,name:e,encode:r,decode:s=>r0(o(s))})}function h0(e,t,n,r){let o=e.length;for(;e[o-1]==="=";)--o;const s=new Uint8Array(o*n/8|0);let i=0,a=0,c=0;for(let d=0;d<o;++d){const f=t[e[d]];if(f===void 0)throw new SyntaxError(`Non-${r} character`);a=a<<n|f,i+=n,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=n||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function b0(e,t,n){const r=t[t.length-1]==="=",o=(1<<n)-1;let s="",i=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],i+=8;i>n;)i-=n,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<n-i]),r)for(;(s.length*n&7)!==0;)s+="=";return s}function p0(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=p0(r);return fn({prefix:t,name:e,encode(s){return b0(s,r,n)},decode(s){return h0(s,o,n,e)}})}const w0=kt({prefix:"9",name:"base10",alphabet:"0123456789"}),y0=Object.freeze(Object.defineProperty({__proto__:null,base10:w0},Symbol.toStringTag,{value:"Module"})),g0=te({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),m0=te({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),x0=Object.freeze(Object.defineProperty({__proto__:null,base16:g0,base16upper:m0},Symbol.toStringTag,{value:"Module"})),E0=te({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),D0=Object.freeze(Object.defineProperty({__proto__:null,base2:E0},Symbol.toStringTag,{value:"Module"})),Yi=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),v0=Yi.reduce((e,t,n)=>(e[n]=t,e),[]),S0=Yi.reduce((e,t,n)=>{const r=t.codePointAt(0);if(r==null)throw new Error(`Invalid character: ${t}`);return e[r]=n,e},[]);function A0(e){return e.reduce((t,n)=>(t+=v0[n],t),"")}function k0(e){const t=[];for(const n of e){const r=n.codePointAt(0);if(r==null)throw new Error(`Invalid character: ${n}`);const o=S0[r];if(o==null)throw new Error(`Non-base256emoji character: ${n}`);t.push(o)}return new Uint8Array(t)}const T0=fn({prefix:"🚀",name:"base256emoji",encode:A0,decode:k0}),I0=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:T0},Symbol.toStringTag,{value:"Module"})),C0=te({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),_0=te({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),B0=te({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),$0=te({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),R0=te({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),O0=te({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),U0=te({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),N0=te({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),M0=te({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),P0=Object.freeze(Object.defineProperty({__proto__:null,base32:C0,base32hex:R0,base32hexpad:U0,base32hexpadupper:N0,base32hexupper:O0,base32pad:B0,base32padupper:$0,base32upper:_0,base32z:M0},Symbol.toStringTag,{value:"Module"})),H0=kt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),j0=kt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),L0=Object.freeze(Object.defineProperty({__proto__:null,base36:H0,base36upper:j0},Symbol.toStringTag,{value:"Module"})),Xi=kt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),F0=kt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),V0=Object.freeze(Object.defineProperty({__proto__:null,base58btc:Xi,base58flickr:F0},Symbol.toStringTag,{value:"Module"})),z0=te({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),K0=te({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),q0=te({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),J0=te({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),W0=Object.freeze(Object.defineProperty({__proto__:null,base64:z0,base64pad:K0,base64url:q0,base64urlpad:J0},Symbol.toStringTag,{value:"Module"})),Z0=te({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),G0=Object.freeze(Object.defineProperty({__proto__:null,base8:Z0},Symbol.toStringTag,{value:"Module"})),Y0=fn({prefix:"\0",name:"identity",encode:e=>s0(e),decode:e=>o0(e)}),X0=Object.freeze(Object.defineProperty({__proto__:null,identity:Y0},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const rs={...X0,...D0,...G0,...y0,...x0,...P0,...L0,...V0,...W0,...I0};function Qi(e,t,n,r){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:n},decoder:{decode:r}}}const os=Qi("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),zn=Qi("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=Wi(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}),ea={utf8:os,"utf-8":os,hex:rs.base16,latin1:zn,ascii:zn,binary:zn,...rs};function Q0(e,t="utf8"){const n=ea[t];if(n==null)throw new Error(`Unsupported encoding "${t}"`);return n.decoder.decode(`${n.prefix}${e}`)}function De(e,t="utf8"){const n=ea[t];if(n==null)throw new Error(`Unsupported encoding "${t}"`);return n.encoder.encode(e).substring(1)}var eb=Cr();const ss=or(eb);function tb(e,t){const n=`did:key:${t}`,r=`${n}#${t}`;return{id:n,verificationMethod:[{id:r,type:"Secp256k1VerificationKey2018",controller:n,publicKeyBase58:De(e,"base58btc")}],authentication:[r],assertionMethod:[r],capabilityDelegation:[r],capabilityInvocation:[r]}}const nb=Object.freeze(Object.defineProperty({__proto__:null,keyToDidDoc:tb},Symbol.toStringTag,{value:"Module"}));function rb(e){const t=new Uint8Array(e.length+2);return t[0]=236,t[1]=1,t.set(e,2),`z${De(t,"base58btc")}`}function ob(e,t){const n=`did:key:${t}`,r=`${n}#${t}`,o=Hf(e),s=`${n}#${rb(o)}`;return{id:n,verificationMethod:[{id:r,type:"Ed25519VerificationKey2018",controller:n,publicKeyBase58:De(e,"base58btc")}],authentication:[r],assertionMethod:[r],capabilityDelegation:[r],capabilityInvocation:[r],keyAgreement:[{id:s,type:"X25519KeyAgreementKey2019",controller:n,publicKeyBase58:De(o,"base58btc")}]}}const sb=Object.freeze(Object.defineProperty({__proto__:null,keyToDidDoc:ob},Symbol.toStringTag,{value:"Module"})),et=cf;function ib(e,t){const n=`did:key:${t}`,r=`${n}#${t}`,o=Wt.ProjectivePoint.fromHex(ab(e));return{id:n,verificationMethod:[{id:r,type:"JsonWebKey2020",controller:n,publicKeyJwk:{kty:"EC",crv:"P-256",x:De(et(o.x),"base64url"),y:De(et(o.y),"base64url")}}],authentication:[r],assertionMethod:[r],capabilityDelegation:[r],capabilityInvocation:[r]}}function ab(e){return e.length===64?Zi([new Uint8Array([4]),e]):e}const cb=Object.freeze(Object.defineProperty({__proto__:null,keyToDidDoc:ib},Symbol.toStringTag,{value:"Module"}));const db=cl;function ub(e,t){const n=`did:key:${t}`,r=`${n}#${t}`,o=db.ProjectivePoint.fromHex(fb(e));return{id:n,verificationMethod:[{id:r,type:"JsonWebKey2020",controller:n,publicKeyJwk:{kty:"EC",crv:"P-384",x:De(et(o.x),"base64url"),y:De(et(o.y),"base64url")}}],authentication:[r],assertionMethod:[r],capabilityDelegation:[r],capabilityInvocation:[r]}}function fb(e){return e.length===96?Zi([new Uint8Array([4]),e]):e}const lb=Object.freeze(Object.defineProperty({__proto__:null,keyToDidDoc:ub},Symbol.toStringTag,{value:"Module"}));const hb=dl;function bb(e,t){const n=`did:key:${t}`,r=`${n}#${t}`,o=hb.ProjectivePoint.fromHex(e);return{id:n,verificationMethod:[{id:r,type:"JsonWebKey2020",controller:n,publicKeyJwk:{kty:"EC",crv:"P-521",x:De(et(o.x),"base64url"),y:De(et(o.y),"base64url")}}],authentication:[r],assertionMethod:[r],capabilityDelegation:[r],capabilityInvocation:[r]}}const pb=Object.freeze(Object.defineProperty({__proto__:null,keyToDidDoc:bb},Symbol.toStringTag,{value:"Module"})),wb="application/did+ld+json",is="application/did+json",yb={231:nb,237:sb,4608:cb,4609:lb,4610:pb};function gb(){return{key:async(e,t,n,r)=>{const o=r.accept||is,s={didResolutionMetadata:{contentType:o},didDocument:null,didDocumentMetadata:{}};try{const i=Xi.decode(t.id),a=ss.decode(i),c=i.slice(ss.decode.bytes),d=await yb[a].keyToDidDoc(c,t.id);o===wb?(d["@context"]="https://w3id.org/did/v1",s.didDocument=d):o===is?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 as="ES256K",mb=/^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*$/,nr="https://www.w3.org/2018/credentials/v1",rr="VerifiableCredential",xb="JwtProof2020",ta=["evidence","termsOfUse","refreshService","credentialSchema","credentialStatus"];function le(e){return Array.isArray(e)?e:[e]}function gt(e){return Array.isArray(e)?e.map(t=>gt(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]=gt(e[n]),t),Object.create(Object.getPrototypeOf(e))):e}function Yt(e){return e!=null}function Eb(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 Db(e){return typeof e=="object"&&e.sub&&e.iss&&e.claim&&e.iat}function vb(e){const{iat:t,nbf:n,claim:r,vc:o,...s}=e,i={...s,nbf:n||t,vc:{"@context":[nr],type:[rr],credentialSubject:r}};return o&&(e.issVc=o),i}function na(e,t=!0){let n=gt(e);Db(e)&&(n=vb(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=Eb({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(Yt);n.type=[...new Set(r)],t&&delete n.vc?.type;for(const s of ta)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(Yt);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 cs(e,t=!0){let n;try{n=un(e)}catch{throw new TypeError("unknown credential format")}return{...na(n.payload,t),proof:{type:xb,jwt:e}}}function ra(e,t=!0){if(typeof e=="string"){if(mb.test(e))return cs(e,t);{let n;try{n=JSON.parse(e)}catch{throw new TypeError("unknown credential format")}return ra(n,t)}}else return e.proof?.jwt?gt({...cs(e.proof.jwt,t),proof:e.proof}):{proof:{},...na(e,t)}}function Sb(e,t=!0){if(Array.isArray(e.credentialSubject))throw Error("credentialSubject of type array not supported");const n=gt({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(Yt);n.vc["@context"]=[...new Set(o)],t&&(delete n.context,delete n["@context"]);const s=[...le(e.type),...le(e.vc?.type)].filter(Yt);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 ta)e[i]&&(n.vc[i]||(n.vc[i]=e[i]),t&&delete n[i]);return n}const mt={SCHEMA_ERROR:"schema_error"};function Ab(e){return e&&!isNaN(e)&&Object.prototype.toString.call(e)==="[object Date]"}function xt(e){if(typeof e=="number"){if(!(Number.isInteger(e)&&e<1e11))throw new TypeError(`${mt.SCHEMA_ERROR}: "${e}" is not a unix timestamp in seconds`)}else if(typeof e=="string")xt(Math.floor(new Date(e).valueOf()/1e3));else if(!Ab(e))throw new TypeError(`${mt.SCHEMA_ERROR}: "${e}" is not a valid time`)}function oa(e){const t=le(e);if(t.length<1||t.indexOf(nr)===-1)throw new TypeError(`${mt.SCHEMA_ERROR}: @context is missing default context "${nr}"`)}function sa(e){const t=le(e);if(t.length<1||t.indexOf(rr)===-1)throw new TypeError(`${mt.SCHEMA_ERROR}: type is missing default "${rr}"`)}function ia(e){if(Object.keys(e).length===0)throw new TypeError(`${mt.SCHEMA_ERROR}: credentialSubject must not be empty`)}const kb=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(Tr(e,{resolver:t,...n})).then(function(s){return s.verifiableCredential=ra(s.jwt,n?.removeOriginalFields),n?.policies?.format!==!1&&Cb(s.verifiableCredential),s})}catch(r){return Promise.reject(r)}},Tb=function(e,t,n={}){try{const r={iat:void 0,...Sb(e,n.removeOriginalFields)};if(Ib(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||as})}return Promise.resolve(Ah(r,{...n},s))}else return Promise.resolve(Ki(r,{...n,issuer:t.did||r.iss||"",signer:t.signer},{...n.header,alg:t.alg||n.header?.alg||as}))}catch(r){return Promise.reject(r)}};function Ib(e){oa(e.vc["@context"]),sa(e.vc.type),ia(e.vc.credentialSubject),e.nbf&&xt(e.nbf),e.exp&&xt(e.exp)}function Cb(e){oa(e["@context"]),sa(e.type),ia(e.credentialSubject),e.issuanceDate&&xt(e.issuanceDate),e.expirationDate&&xt(e.expirationDate)}function _b(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 Bb(e){try{const t=parseInt(String(Date.now()/1e3)),n=await kb(e,$b(),{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 aa(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 Tb(s,r,{expiresIn:o?.expiresIn})}const $b=()=>{const e=gb();if(!e)throw new Error("Failed to get key resolver");return new Kl(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 Rb="eip155",Ob=1;function Ub(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 aa(Number(Ob),Rb,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=e0(Ub(t)),o=Qh(r);return t0(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 Q0(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 Sr(n)},alg:"ES256"}}}const Nb="https://auth.renown.id";class Mb{#e;#t;#n;#o;constructor(t,n,r,o=Nb){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=_b(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 Bb(t)}async createBearerToken(t,n,r,o){if(!this.user)throw new Error("User not found");return aa(n,this.#n,t,r,o)}}class ds extends CustomEvent{constructor(t,n){super(t,{detail:n})}}class Pb{#e=new EventTarget;on(t,n){const r=o=>{o instanceof ds&&n(o.detail)};return this.#e.addEventListener(t.toString(),r),()=>{this.#e.removeEventListener(t.toString(),r)}}emit(t,n){const r=new ds(t.toString(),n);this.#e.dispatchEvent(r)}}class Hb{namespace;constructor(t){this.namespace=t}}class jb extends Hb{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 iw(e,t,n){return new Mb(new jb("renown",t),new Pb,e,n)}const _r=_("drives"),ca=_r.useValue,Lb=_r.setValue,Fb=_r.addEventHandler;function Vb(e){return e.reduce((t,n)=>(n.status==="fulfilled"?t.push(n.value):console.warn(n.reason),t),[])}function aw(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 cw(e){if(!e)return!1;const t="readContext"in e,{availableOffline:n}=t?{availableOffline:!1}:e.state.local;return n??!1}async function zb(e){if(!e)return[];const t=await e.getDrives(),n=await Promise.allSettled(t.map(r=>e.getDrive(r)));return Vb(n)}function dw(e,t){if(t==="LOCAL")return;const n=window.ph?.reactor;if(n)try{const r=n.getSyncStatus(e);return r instanceof Wa?"INITIAL_SYNC":r}catch(r){return console.error(r),"ERROR"}}function Kb(e){return e?.state.local.triggers.find(t=>t.type==="PullResponder")}function da(e){return Kb(e)?.data?.url}function ua(e){if(!e)return;const t=da(e);if("remoteUrl"in e.state.global){const n=e.state.global.remoteUrl;if(typeof n=="string")return n}return t}function qb(e){const t=ua(e),n=da(e);return t!==void 0||n!==void 0}const uw=(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"}}}},Jb=200,Wb=1e3;async function us(e){if(!e)return;const t=await zb(e);Lb(t)}function Zb(e=Jb,t=Wb){let n=null,r=0;return(o,s=!1)=>{const i=Date.now(),a=i-r;return n!==null&&clearTimeout(n),s||a>=t?(r=i,us(o)):new Promise(c=>{n=setTimeout(()=>{r=Date.now(),us(o).then(c)},e)})}}const fw=Zb();async function lw(e,t,n){await Gb(e,t,n);const o=(await e.initialize())?.at(0);if(o)throw o}async function Gb(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 hw(){const e=new Ze(new pe);return await e.did(),e}function fa(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}),fa(e)}}function bw(e){const t=new Map;return e.on("documentDeleted",n=>{t.delete(n)}),{get(n,r){const o=t.get(n);if(o&&(fa(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 Br=_("documentCache"),Yb=Br.useValue,pw=Br.setValue,Xb=Br.addEventHandler;function Qb(e){const t=Yb(),n=Ne.useSyncExternalStore(r=>e&&t?t.subscribe(e,r):()=>{},()=>e?t?.get(e):void 0);return n?Ne.use(n):void 0}function la(e){const t=Qb(e),[,n]=dr(t);return[t,n]}let zt;typeof window<"u"?window.btoa?zt=function(e){return btoa(unescape(encodeURIComponent(e)))}:zt=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}:zt=function(e){return Buffer.from(e).toString("base64")};function F(e,t){let n=fs(e,t);return(t&&t.fallback!==void 0?t.fallback:F.defaults.fallback)===!0&&n===""&&(n=fs(zt(e),t)),n}const ha={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 fs(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 c,d=0,f=r.length;d<f;d++)c=r[d],t[c]=c in t?t[c]:n[c];const o=ha[t.locale]||$r;let s=[];for(const c in t.multicharmap){if(!Object.prototype.hasOwnProperty.call(t.multicharmap,c))continue;const d=c.length;s.indexOf(d)===-1&&s.push(d)}s=s.sort(function(c,d){return d-c});const i=t.mode==="rfc3986"?/[^\w\s\-.~]/:/[^A-Za-z0-9\s]/;let a="";for(let c,d=0,f=e.length;d<f;d++){c=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,c=t.multicharmap[h],l=!0;break}}l||(o[c]?c=o[c]:t.charmap[c]?c=t.charmap[c].replace(t.replacement," "):c.includes(t.replacement)?c=c.replace(t.replacement," "):c=c.replace(i,"")),a+=c}return t.remove&&(a=a.replace(t.remove,"")),t.trim&&(a=a.trim()),a=a.replace(/\s+/g,t.replacement),t.lower&&(a=a.toLowerCase()),a}const ba={फ़:"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"},pa={À:"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({},pa);F.multicharmap=Object.assign({},ba);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({},pa),F.defaults.modes.rfc3986.multicharmap=F.defaults.modes.pretty.multicharmap=F.multicharmap=F.defaults.multicharmap=Object.assign({},ba),$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=ha[e]||{}};function Xt(e){return new URL(e.replace(/^\/+/,""),window.location.origin+(window.ph?.basePath??"/")).pathname}function wa(e){const t=window.ph?.basePath??"/";return e.replace(t,t.endsWith("/")?"/":"")}function e2(e){if(!e)return"";const t=e.name;return F(t?`${t}-${e.id}`:e.id)}function ww(e){const t=wa(e);return/^\/d\/[^/]+\/([^/]+)$/.exec(t)?.[1]??""}function t2(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 n2(e){return t2(e)}function r2(e){const t=wa(e);return/^\/d\/([^/]+)/.exec(t)?.[1]??""}const Rr=_("selectedDriveId"),ya=Rr.useValue,o2=Rr.setValue,s2=Rr.addEventHandler;function i2(){const e=Or();if(!e[0])throw new Error("There is no drive selected. Did you mean to call 'useSelectedDriveSafe'?");return e}function Or(){const e=ya(),n=ca()?.find(s=>s.header.id===e),[r,o]=dr(n);return n?[r,o]:[void 0,void 0]}function yw(e){const t=typeof e=="string"?e:e?.header.slug,r=window.ph?.drives?.find(o=>o.header.slug===t)?.header.id;if(o2(r),!r){window.history.pushState(null,"",Xt("/"));return}window.history.pushState(null,"",Xt(`/d/${t}`))}function Tt(){const[e]=Or();return e?.state.global.nodes}function a2(){return Tt()?.filter(t=>xs(t))}const Ur=_("selectedNodeId"),c2=Ur.useValue,ga=Ur.setValue,d2=Ur.addEventHandler;function It(){const e=c2();return Tt()?.find(n=>n.id===e)}function u2(e){const t=typeof e=="string"?e:e2(e),n=n2(t);ga(n);const r=r2(window.location.pathname);if(r){if(!t){window.history.pushState(null,"",Xt(`/d/${r}`));return}window.history.pushState(null,"",Xt(`/d/${r}/${t}`))}}function f2(){window.addEventListener("ph:selectedDriveIdUpdated",()=>{ga(void 0)})}function Nr(){const e=It();if(xs(e))return e}function gw(){const e=Tt(),n=Nr()?.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:x2,addEventHandler:E2}=_("studioMode"),{setValue:D2,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:z2,addEventHandler:K2}=_("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:xp,addEventHandler:Ep}=_("sentryRelease"),{setValue:Dp,addEventHandler:vp}=_("sentryDsn"),{setValue:Sp,addEventHandler:Ap}=_("sentryEnv"),{setValue:kp,addEventHandler:Tp}=_("isSentryTracingEnabled"),{setValue:Ip,addEventHandler:Cp}=_("isExternalProcessorsEnabled"),{setValue:_p,addEventHandler:Bp}=_("isExternalPackagesEnabled"),ma=_("enabledEditors"),$p=ma.setValue,Rp=ma.addEventHandler,xa=_("disabledEditors"),Op=xa.setValue,Up=xa.addEventHandler,Ea=_("isRelationalProcessorsEnabled"),Np=Ea.setValue,Mp=Ea.addEventHandler,Da=_("isExternalRelationalProcessorsEnabled"),Pp=Da.setValue,Hp=Da.addEventHandler,va=_("isAnalyticsEnabled"),jp=va.setValue,Lp=va.addEventHandler,Sa=_("isAnalyticsExternalProcessorsEnabled"),Fp=Sa.setValue,Vp=Sa.addEventHandler,Aa=_("analyticsDatabaseName"),zp=Aa.setValue,Kp=Aa.addEventHandler,ka=_("logLevel"),qp=ka.setValue,Jp=ka.addEventHandler,Mr=_("allowList"),Wp=Mr.setValue,Zp=Mr.useValue,Gp=Mr.addEventHandler,Yp={routerBasename:l2,version:b2,requiresHardRefresh:w2,warnOutdatedApp:g2,studioMode:x2,basePath:D2,versionCheckInterval:S2,cliVersion:k2,fileUploadOperationsChunkSize:I2,isDocumentModelSelectionSettingsEnabled:_2,gaTrackingId:$2,defaultDrivesUrl:O2,drivesPreserveStrategy:N2,isLocalDrivesEnabled:P2,isAddDriveEnabled:j2,isPublicDrivesEnabled:F2,isAddPublicDrivesEnabled:z2,isDeletePublicDrivesEnabled:q2,isCloudDrivesEnabled:W2,isAddCloudDrivesEnabled:G2,isDeleteCloudDrivesEnabled:X2,isAddLocalDrivesEnabled:ep,isDeleteLocalDrivesEnabled:np,isEditorDebugModeEnabled:op,isEditorReadModeEnabled:ip,isRelationalProcessorsEnabled:Np,isExternalRelationalProcessorsEnabled:Pp,isAnalyticsEnabled:jp,analyticsDatabaseName:zp,isAnalyticsExternalProcessorsEnabled:Fp,isAnalyticsDatabaseWorkerEnabled:cp,isDiffAnalyticsEnabled:up,isDriveAnalyticsEnabled:lp,renownUrl:bp,renownNetworkId:wp,renownChainId:gp,sentryRelease:xp,sentryDsn:Dp,sentryEnv:Sp,isSentryTracingEnabled:kp,isExternalProcessorsEnabled:Ip,isExternalPackagesEnabled:_p,allowList:Wp,logLevel:qp,disabledEditors:Op,enabledEditors:$p},Xp={...Hc,...jc,...Yp};function Pr(e,t){const n=Xp[e];n(t)}function mw(e){for(const t of Object.keys(e))Pr(t,e[t])}function Qp(e){for(const t of Object.keys(e))Pr(t,e[t])}function e1(e){for(const t of Object.keys(e))Pr(t,e[t])}function xw(e){const[t,n]=Ne.useState(!1);Ne.useEffect(()=>{t||(Qp(e),n(!0))},[e,t])}function Ew(e){const[t,n]=Ne.useState(!1);Ne.useEffect(()=>{t||(e1(e),n(!0))},[e,t])}function t1(e,t){const[n,r]=la(e),o=Fc(t);if(!e||!t)return[];if(!n)throw new Za(e);if(!o)throw new Ga(t);if(n.header.documentType!==t)throw new yc(e,t,n.header.documentType);return[n,r]}function n1(){return ms()?.map(t=>t.documentModel.global.id)}function r1(){const e=Mc(),t=n1();return e??t}function Dw(e){const n=ca()?.find(s=>s.header.id===e),[r,o]=dr(n);if(!n)throw new Error(`Drive with id ${e} not found`);return[r,o]}function Ta(){return cr()?.flatMap(t=>t.modules.editorModules||[]).filter(t=>!t.documentTypes.includes("powerhouse/document-drive"))}function o1(){return cr()?.flatMap(t=>t.modules.editorModules||[]).filter(t=>t.documentTypes.includes("powerhouse/document-drive"))}function vw(e){const t=Ta();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 Sw(){return s1(Bc)}function Aw(e){return Ta()?.find(n=>n.id===e)}function Ia(e){return a2()?.find(n=>n.id===e)}const Hr=_("modal"),kw=Hr.useValue,ln=Hr.setValue,i1=Hr.addEventHandler;function a1(e){ln(e)}function Tw(){ln(void 0)}function Iw(e){ln({type:"createDocument",documentType:e})}function Cw(e){const t=typeof e=="string"?e:e.id;ln({type:"deleteItem",id:t})}function ge(e,t){return t?.id!==e?t:void 0}function _w(){const[e]=Or(),t=Nr(),n=It(),r=Ia(n?.parentFolder),o=e?.header.id;async function s(u,b){if(!o)return;const h=u.name.replace(/\..+/gim,"");return Sc(u,o,h,ge(o,b)?.id)}async function i(u,b){if(o)return kc(o,u,ge(o,b)?.id)}async function a(u,b){if(!o)return;if(!ge(o,b)){console.error(`Node ${b.id} not found`);return}return await Ic(o,b.id,u)}async function c(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 Wr(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 Cc(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 Wr(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&&u2(h)}return{onAddFile:s,onAddFolder:i,onRenameNode:a,onCopyNode:c,onMoveNode:d,onDuplicateNode:f,onAddAndSelectNewFolder:l}}function c1(e){return Tt()?.find(n=>n.id===e)}function d1(e){const t=Tt();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 Bw(){const e=It();return d1(e?.id)}function u1(e){const t=c1(e);return Ia(t?.parentFolder)}function $w(){const e=It();return u1(e?.id)}const jr=_("revisionHistoryVisible"),Rw=jr.useValue,f1=jr.setValue,l1=jr.addEventHandler;function Ow(){f1(!0)}function Ca(){const e=It();return e&&Qt(e)?e.id:void 0}function Uw(){const e=Ca();return la(e)}function Nw(e){const t=Ca();if(!t)throw new gc;return t1(t,e)}const Lr=_("selectedTimelineItem"),Mw=Lr.useValue,Pw=Lr.setValue,h1=Lr.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((a,c)=>{const d=c;return[...a,...oc(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((a,c)=>{const d=c,f=d==="global";return[...a,...sc(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=ic(r.modules);return[...o,...s,...i]},Hw=e=>{if(!e)return;if(w1(e).length)a1({type:"exportDocumentWithErrors",documentId:e.header.id});else return vc(e)},jw=(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 Kn={exports:{}},ls;function y1(){return ls||(ls=1,(function(e){var t=(function(){var n=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",s={};function i(c,d){if(!s[c]){s[c]={};for(var f=0;f<c.length;f++)s[c][c.charAt(f)]=f}return s[c][d]}var a={compressToBase64:function(c){if(c==null)return"";var d=a._compress(c,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(c){return c==null?"":c==""?null:a._decompress(c.length,32,function(d){return i(r,c.charAt(d))})},compressToUTF16:function(c){return c==null?"":a._compress(c,15,function(d){return n(d+32)})+" "},decompressFromUTF16:function(c){return c==null?"":c==""?null:a._decompress(c.length,16384,function(d){return c.charCodeAt(d)-32})},compressToUint8Array:function(c){for(var d=a.compress(c),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(c){if(c==null)return a.decompress(c);for(var d=new Array(c.length/2),f=0,l=d.length;f<l;f++)d[f]=c[f*2]*256+c[f*2+1];var u=[];return d.forEach(function(b){u.push(n(b))}),a.decompress(u.join(""))},compressToEncodedURIComponent:function(c){return c==null?"":a._compress(c,6,function(d){return o.charAt(d)})},decompressFromEncodedURIComponent:function(c){return c==null?"":c==""?null:(c=c.replace(/ /g,"+"),a._decompress(c.length,32,function(d){return i(o,c.charAt(d))}))},compress:function(c){return a._compress(c,16,function(d){return n(d)})},_compress:function(c,d,f){if(c==null)return"";var l,u,b={},h={},p="",E="",w="",g=2,y=3,S=2,x=[],m=0,k=0,A;for(A=0;A<c.length;A+=1)if(p=c.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,x.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,x.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,x.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,x.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,x.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,x.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,x.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,x.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,x.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,x.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,x.push(f(m)),m=0):k++,u=u>>1;for(;;)if(m=m<<1,k==d-1){x.push(f(m));break}else k++;return x.join("")},decompress:function(c){return c==null?"":c==""?null:a._decompress(c.length,32768,function(d){return c.charCodeAt(d)})},_decompress:function(c,d,f){var l=[],u=4,b=4,h=3,p="",E=[],w,g,y,S,x,m,k,A={val:f(0),position:d,index:1};for(w=0;w<3;w+=1)l[w]=w;for(y=0,x=Math.pow(2,2),m=1;m!=x;)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,x=Math.pow(2,8),m=1;m!=x;)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,x=Math.pow(2,16),m=1;m!=x;)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>c)return"";for(y=0,x=Math.pow(2,h),m=1;m!=x;)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,x=Math.pow(2,8),m=1;m!=x;)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,x=Math.pow(2,16),m=1;m!=x;)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 a})();e!=null?e.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})})(Kn)),Kn.exports}var g1=y1();function m1(e){return e.split("/").pop()}function x1(){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=x1(),s={documentId:t,driveId:r},i=n?{Authorization:`Bearer ${n}`}:void 0,a={document:o.trim(),variables:JSON.stringify(s,null,2)};return i&&(a.headers=JSON.stringify(i)),g1.compressToEncodedURIComponent(JSON.stringify(a))}function D1(e,t,n){const r=E1(e,t,n);return`${e}?explorerURLState=${r}`}function Lw(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,a=e.reducer,c=e.actions,d=e.utils;return{id:o,name:n,documentType:r,extension:s,documentModel:ac(cc(),t),specifications:i,reducer:a,actions:c,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,a=e.Component;return{id:r,name:s,documentTypes:i,Component:a}}function Fw(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:Vw,addEventHandler:T1}=_("connectCrypto"),{setValue:zw,addEventHandler:I1}=_("did"),{addEventHandler:C1}=_("loading"),{setValue:Je,addEventHandler:_1}=_("loginStatus"),_a=_("processorManager"),Kw=_a.setValue,B1=_a.addEventHandler,Fr=_("reactor"),qw=Fr.useValue,Jw=Fr.setValue,$1=Fr.addEventHandler,Ba=_("renown"),Ww=Ba.setValue,R1=Ba.addEventHandler,{useValue:$a,setValue:hs,addEventHandler:O1}=_("user"),U1={loading:C1,reactor:$1,modal:i1,connectCrypto:T1,did:I1,renown:R1,loginStatus:_1,user:O1,processorManager:B1,drives:Fb,documentCache:Xb,selectedDriveId:()=>{s2(),f2()},selectedNodeId:d2,vetraPackages:Lc,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:Pc,enabledEditors:Rp,disabledEditors:Up,isAddDriveEnabled:L2,isLocalDrivesEnabled:H2,isPublicDrivesEnabled:V2,isAddPublicDrivesEnabled:K2,isDeletePublicDrivesEnabled:J2,isCloudDrivesEnabled:Z2,isAddCloudDrivesEnabled:Y2,isDeleteCloudDrivesEnabled:Q2,isAddLocalDrivesEnabled:tp,isDeleteLocalDrivesEnabled:rp,isDragAndDropEnabled:Uc,isExternalControlsEnabled:Rc,isEditorDebugModeEnabled:sp,isEditorReadModeEnabled:ap,isRelationalProcessorsEnabled:Mp,isExternalRelationalProcessorsEnabled:Hp,isAnalyticsEnabled:Lp,isAnalyticsExternalProcessorsEnabled:Vp,analyticsDatabaseName:Kp,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 Zw(){for(const e of Object.values(U1))e()}function Gw(e){const[t]=i2(),n=qb(t),r=ua(t),o=k1(),s=$a();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 D1(r,e.header.id,i)},[n,r,e,s,o])}const Yw=e=>{const t=ya(),n=Nr(),r=r1();return async(s,i,a)=>{if(!t){console.warn("No selected drive - upload skipped");return}const c=s.name.replace(/\..+/gim,""),d=n?.id;return await Ac(s,t,c,d,i,r,a)}};function Xw(){const e=$a(),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 Qw(){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 ey(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"),hs(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"),hs(s),t.setGenerateJwtHandler(async i=>r.getBearerToken(i,s.address,!0,{expiresIn:10}))):Je("not-authorized")}catch(o){Je("not-authorized"),K.error(o)}}async function ty(){const e=window.ph?.renown,t=window.ph?.reactor;Je("initial"),await e?.logout(),t?.removeJwtHandler()}export{ww as $,ua as A,k1 as B,$a as C,D1 as D,w1 as E,vc as F,s1 as G,Sw as H,aw as I,Mw as J,Rw as K,Fc as L,Aw as M,vw as N,f1 as O,jw as P,kw as Q,Bc as R,X1 as S,Zw as T,hw as U,iw as V,uw as W,lw as X,bw as Y,zb as Z,r2 as _,Or as a,ey as a0,mw as a1,Jw as a2,pw as a3,Vw as a4,zw as a5,Ww as a6,Kw as a7,Lb as a8,fw as a9,Nw as aA,Ew as aB,ms as aC,Iw as aD,gw as aE,tw as aF,xs as aG,xw as aH,Nr as aa,e1 as ab,Qp as ac,ca as ad,qw as ae,z1 as af,ty as ag,Qw as ah,o1 as ai,Tw as aj,V1 as ak,$w as al,ys as am,Z1 as an,G1 as ao,Y1 as ap,Dw as aq,K1 as ar,c1 as as,Tc as at,cw as au,W1 as av,J1 as aw,q1 as ax,cr as ay,Fw as az,ya as b,Bw as c,u2 as d,kc as e,la as f,Uw as g,u1 as h,Gw as i,F1 as j,Ow as k,Pw as l,Hw as m,_w as n,Q1 as o,Yw as p,Il as q,dw as r,yw as s,Cw as t,Xw as u,a1 as v,Lw as w,ew as x,i2 as y,qb as z};
|