@cef-ai/widget-runtime 2.4.3 → 2.4.4

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.
@@ -302,7 +302,7 @@ ${P.stack}`),WA.warn(tl),O&&O.listenerCount("error")>0&&O.emit("error",tl)}let O
302
302
  <h2>${Dl(I.title)}</h2><p>${Dl(I.body)}</p>
303
303
  <button data-hero-cta class="dc-cta">${Dl(I.cta)}</button>
304
304
  </div>`:""}function Y(I){return new Promise(y=>{let x=document.createElement("div");x.setAttribute("data-confirm",""),x.style.cssText="position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.45);z-index:50;padding:16px;";let w=document.createElement("div");w.setAttribute("role","dialog"),w.setAttribute("aria-modal","true"),w.style.cssText="background:Canvas;color:CanvasText;border:1px solid color-mix(in srgb, currentColor 18%, transparent);border-radius:12px;padding:18px;max-width:340px;box-shadow:0 8px 28px rgba(0,0,0,0.25);",w.innerHTML=`<p style="margin:0 0 14px">${Dl(I)}</p><div style="display:flex;gap:8px;justify-content:flex-end"><button data-cancel style="padding:7px 14px;border-radius:8px;border:1px solid currentColor;background:transparent;cursor:pointer">Cancel</button><button data-ok style="padding:7px 14px;border-radius:8px;border:none;background:#ff5e8a;color:#fff;font-weight:600;cursor:pointer">Confirm</button></div>`,x.appendChild(w);let H=j=>{x.remove(),y(j)};w.querySelector("[data-cancel]").addEventListener("click",()=>H(!1)),w.querySelector("[data-ok]").addEventListener("click",()=>H(!0)),x.addEventListener("click",j=>{j.target===x&&H(!1)}),l.appendChild(x)})}function R(){l.querySelectorAll("[data-rail-item]").forEach(I=>{I.addEventListener("click",()=>{let y=I.getAttribute("data-panel");Z(d(y))||V(y)})}),l.querySelector("[data-menu-toggle]")?.addEventListener("click",()=>{let I=l.querySelector("[data-menu]");I&&I.toggleAttribute("hidden")}),A.menu?.forEach((I,y)=>{l.querySelector(`[data-menu-action="${y}"]`)?.addEventListener("click",async()=>{if(l.querySelector("[data-menu]")?.setAttribute("hidden",""),I.kind==="goto"){V(I.panel);return}I.confirm&&!await Y(I.confirm)||await G.publish(I.event.type,{schema_version:1,...I.event.payload??{}},void 0)})}),l.querySelector("[data-hero-cta]")?.addEventListener("click",()=>V(A.gating.firstRunPanel))}function V(I,y=!1){l.innerHTML=h();let x=l.querySelector("[data-content]");y&&!c&&A.gating.hero?(x.innerHTML=i(),B=A.gating.firstRunPanel):W(I),R()}async function m(I=0){if(!c){if(await $N(A,G)){c=!0,V(A.defaultPanel);return}I<5&&setTimeout(()=>void m(I+1),1500)}}V(B,!c)}var lE,g2=Gl(()=>{"use strict";LB();a2();lE=new Map});var mb=class extends Error{constructor(G,b){super(G);el(this,"code");this.code=b,this.name="TransportError"}},KB=class extends mb{constructor(G,b,t,c){super(G,t);el(this,"status");el(this,"body");this.status=b,this.body=c,this.name="HttpError"}},qB=class extends mb{constructor(G){super(`Request timed out after ${G}ms`,"TIMEOUT");el(this,"timeoutMs");this.timeoutMs=G,this.name="TimeoutError"}},_B=class extends mb{constructor(A){super(A,"NETWORK_ERROR"),this.name="NetworkError"}};function Fo(l,A){let G=A&&typeof A=="object"?A:void 0,b=G?.detail??G?.title??G?.error?.message??`Request failed with status ${l}`,t=G?.type??(G?.error?.code!=null?String(G.error.code):void 0);return new KB(b,l,t,A)}var ex=new TextEncoder;function qb(l){let A="";for(let G=0;G<l.length;G++)A+=l[G].toString(16).padStart(2,"0");return A}function Te(l){let A=It(l);if(A.length%2!==0)throw new TypeError("hexToBytes: odd-length hex string");let G=new Uint8Array(A.length/2);for(let b=0;b<G.length;b++){let t=Number.parseInt(A.slice(b*2,b*2+2),16);if(Number.isNaN(t))throw new TypeError(`hexToBytes: invalid hex at ${b*2}`);G[b]=t}return G}function gB(l){return l.startsWith("0x")?l:`0x${l}`}function It(l){return l.startsWith("0x")?l.slice(2):l}function De(l){let A="";for(let b=0;b<l.length;b++)A+=String.fromCharCode(l[b]);return(typeof btoa=="function"?btoa(A):Buffer.from(A,"binary").toString("base64")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}var WE=3e4,oE={retries:0,baseDelayMs:0};function hE(l){return l instanceof Error&&l.name==="AbortError"}function sE(l){return l instanceof KB?l.status===429||l.status>=500:l instanceof _B||l instanceof qB}var aa=class{constructor(A){el(this,"baseUrl");el(this,"fetchFn");el(this,"timeoutMs");el(this,"retry");el(this,"defaultHeaders");el(this,"sleep");if(!A.baseUrl)throw new mb("HttpClient: `baseUrl` is required");try{new URL(A.baseUrl)}catch{throw new mb(`HttpClient: invalid baseUrl ${JSON.stringify(A.baseUrl)}`)}this.baseUrl=A.baseUrl.replace(/\/$/,"");let G=A.fetch??globalThis.fetch?.bind(globalThis);if(typeof G!="function")throw new mb("HttpClient: no global fetch available \u2014 pass `config.fetch` (Node < 18?)");this.fetchFn=G,this.timeoutMs=A.timeoutMs??WE,this.retry=p2(A.retry??oE),this.defaultHeaders=A.defaultHeaders??{},this.sleep=A.sleep??(b=>new Promise(t=>setTimeout(t,b)))}async request(A,G,b={}){let t=this.buildUrl(G,b.query),c=b.retry?p2(b.retry):this.retry,{headers:B,body:e}=this.prepare(b),d=0;for(;;)try{return await this.attempt(A,t,B,e,b.signal,b.responseType??"json")}catch(Z){if(d>=c.retries||!sE(Z))throw Z;await this.sleep(rE(c,d)),d++}}prepare(A){let G={Accept:"application/json",...this.defaultHeaders,...A.headers},b;return A.body!==void 0&&(typeof A.body=="string"||A.body instanceof Uint8Array||A.body instanceof ArrayBuffer?b=A.body:(b=JSON.stringify(A.body),Object.keys(G).some(t=>t.toLowerCase()==="content-type")||(G["Content-Type"]="application/json"))),{headers:G,body:b}}async attempt(A,G,b,t,c,B="json"){let e=new AbortController,d=!1,Z=()=>e.abort();c&&(c.aborted?e.abort():c.addEventListener("abort",Z,{once:!0}));let a=setTimeout(()=>{d=!0,e.abort()},this.timeoutMs);try{let n=await this.fetchFn(G.toString(),{method:A,headers:b,body:t,signal:e.signal});if(n.status===204)return;if(B==="headers"){if(!n.ok)throw Fo(n.status,null);let W={};return n.headers.forEach((i,Y)=>{W[Y]=i}),W}if(!n.ok||B==="json"){let W=await n.text(),i=null;if(W)try{i=JSON.parse(W)}catch{let Y=n.headers.get("content-type")??"";if(n.ok&&/\bjson\b/i.test(Y))throw new mb(`Expected JSON but the ${n.status} body did not parse (content-type: ${Y||"none"})`);i=W}if(n.ok)return i;throw Fo(n.status,i)}let h=await n.arrayBuffer();return new Uint8Array(h)}catch(n){throw hE(n)?d?new qB(this.timeoutMs):n:n instanceof mb?n:new _B(n instanceof Error?n.message:"Network error")}finally{clearTimeout(a),c?.removeEventListener("abort",Z)}}buildUrl(A,G){let b=A.startsWith("/")?`${this.baseUrl}${A}`:`${this.baseUrl}/${A}`,t=new URL(b);if(G)for(let[c,B]of Object.entries(G))B==null||B===""||t.searchParams.set(c,String(B));return t}};function p2(l){if(!Number.isInteger(l.retries)||l.retries<0)throw new mb(`HttpClient: retry.retries must be a non-negative integer (got ${l.retries})`);if(!(l.baseDelayMs>=0))throw new mb(`HttpClient: retry.baseDelayMs must be >= 0 (got ${l.baseDelayMs})`);if(l.maxDelayMs!==void 0&&!(l.maxDelayMs>=0))throw new mb(`HttpClient: retry.maxDelayMs must be >= 0 (got ${l.maxDelayMs})`);return l}function rE(l,A){let G=l.baseDelayMs*2**A;return l.maxDelayMs?Math.min(G,l.maxDelayMs):G}var $G=class extends Error{constructor(G,b,t,c){super(G);el(this,"status");el(this,"code");el(this,"retryable");this.status=b,this.code=t,this.retryable=c,this.name="VaultRequestError"}},ga=class extends $G{constructor(A="Endpoint not implemented (501)"){super(A,501,"NOT_IMPLEMENTED"),this.name="VaultNotImplementedError"}};function F2(l){let A=/(?:requested|last consented) "([^"]+)"/.exec(l)?.[1],G=/now carries "([^"]+)"/.exec(l)?.[1];return{...A!==void 0?{priorCid:A}:{},...G!==void 0?{currentCid:G}:{}}}var Wa=class Wa extends $G{constructor(G,b=!1){super(G,409,Wa.code,b);el(this,"requestedCid");el(this,"currentCid");this.name="BundleChangedError";let{priorCid:t,currentCid:c}=F2(G);this.requestedCid=t,this.currentCid=c}};el(Wa,"code","BUNDLE_CHANGED");var Yd=Wa,oa=class oa extends $G{constructor(G,b=!1){super(G,409,oa.code,b);el(this,"previousCid");el(this,"currentCid");this.name="ReconsentRequiredError";let{priorCid:t,currentCid:c}=F2(G);this.previousCid=t,this.currentCid=c}};el(oa,"code","RECONSENT_REQUIRED");var Id=oa,Rt=class extends Error{constructor(A="Vault signing requires a signer that implements sign(bytes)."){super(A),this.name="VaultSignerRequiredError"}},Rd=class extends $G{constructor(G,b,t,c){super(G,t,c,!1);el(this,"memberPubkey");this.memberPubkey=b,this.name="CeilingUnknownError"}};function y2(l,A){let G=A&&typeof A=="object"?A:void 0,b=G?.error?.message??`Request failed with status ${l}`,t=G?.error?.code,c=G?.error?.retryable===!0;return l===501?new ga(b):l===409&&t===Yd.code?new Yd(b,c):l===409&&t===Id.code?new Id(b,c):new $G(b,l,t,c)}var tt=class{async authenticate(A){if(A.body!==void 0){let G=new TextEncoder().encode(JSON.stringify(A.body));return{headers:{"Content-Type":"application/json"},body:G}}return{headers:{}}}};var Q2=new TextEncoder,ha=()=>new Date().toISOString();function yo(l){return l.startsWith("0x")?l.slice(2):l}function N2(l,A=ha){let G={...l??{}};return typeof G.timestamp!="string"&&(G.timestamp=A()),{body:G,bytes:Q2.encode(JSON.stringify(G))}}function Qo(l,A,G,b=ha,t){let c={method:l.toUpperCase(),path:A,query:G,timestamp:b()};t!==void 0&&(c.contentSha256=t);let B=JSON.stringify(c);return{preamble:B,bytes:Q2.encode(B)}}function No(l){if(!/^[A-Za-z0-9+/]*={0,2}$/.test(l)||l.length%4!==0)throw new TypeError("decodeBase64: input is not valid standard base64");let A=typeof atob=="function"?atob(l):Buffer.from(l,"base64").toString("binary"),G=new Uint8Array(A.length);for(let b=0;b<A.length;b++)G[b]=A.charCodeAt(b);return G}async function E2(l){let A=await crypto.subtle.digest("SHA-256",l);return qb(new Uint8Array(A))}var iE=3e4,mE=new tt,Le=class{constructor(A){el(this,"baseUrl");el(this,"http");el(this,"defaultAuth");el(this,"timeoutMs");if(!A.url)throw new Error("VaultHttpClient: `url` is required");this.baseUrl=A.url.replace(/\/$/,""),this.defaultAuth=A.auth??mE,this.timeoutMs=A.timeoutMs??iE,this.http=new aa({baseUrl:this.baseUrl,fetch:A.fetch,timeoutMs:this.timeoutMs,retry:{retries:0,baseDelayMs:0}})}async send(A,G,b={}){let t=b.auth??this.defaultAuth,c=this.buildUrl(G,b.query),B=await t.authenticate({method:A,path:c.pathname,query:c.search.replace(/^\?/,""),body:b.body,hash:b.rawBody!==void 0?await E2(b.rawBody):void 0});try{return await this.http.request(A,G,{query:b.query,headers:{...B.headers,...b.headers},body:B.body??b.rawBody,responseType:b.responseType})}catch(e){throw VE(e,this.timeoutMs)}}buildUrl(A,G){let b=A.startsWith("/")?`${this.baseUrl}${A}`:`${this.baseUrl}/${A}`,t=new URL(b);if(G)for(let[c,B]of Object.entries(G))B==null||B===""||t.searchParams.set(c,String(B));return t}};function VE(l,A){return l instanceof KB?y2(l.status,l.body):l instanceof qB?new $G(`Request timed out after ${A}ms`,0,"TIMEOUT"):l instanceof _B?new $G(l.message,0,"NETWORK_ERROR"):l instanceof mb?new $G(l.message,0,l.code??"TRANSPORT_ERROR"):l}var iA="/api/v1",Hl=l=>encodeURIComponent(l),uE=l=>l.split("/").map(Hl).join("/"),fl={vaults:()=>`${iA}/vaults`,vault:l=>`${iA}/vaults/${Hl(l)}`,vaultDelegations:l=>`${iA}/vaults/${Hl(l)}/delegations`,scopes:l=>`${iA}/vaults/${Hl(l)}/scopes`,scope:(l,A)=>`${iA}/vaults/${Hl(l)}/scopes/${Hl(A)}`,agents:l=>`${iA}/vaults/${Hl(l)}/agents`,agent:(l,A)=>`${iA}/vaults/${Hl(l)}/agents/${Hl(A)}`,agentCeiling:(l,A)=>`${iA}/vaults/${Hl(l)}/agents/${Hl(A)}/ceiling`,agentHarvester:(l,A)=>`${iA}/vaults/${Hl(l)}/agents/${Hl(A)}/harvester`,scopeEvents:(l,A)=>`${iA}/vaults/${Hl(l)}/scopes/${Hl(A)}/events`,scopeObjects:(l,A)=>`${iA}/vaults/${Hl(l)}/scopes/${Hl(A)}/objects`,scopeObject:(l,A,G)=>`${iA}/vaults/${Hl(l)}/scopes/${Hl(A)}/objects/${uE(G)}`,scopeObjectsPresignedUrl:(l,A)=>`${iA}/vaults/${Hl(l)}/scopes/${Hl(A)}/objects/presigned-url`,scopeStreams:(l,A)=>`${iA}/vaults/${Hl(l)}/scopes/${Hl(A)}/streams`,stream:(l,A,G)=>`${iA}/vaults/${Hl(l)}/scopes/${Hl(A)}/streams/${Hl(G)}`,streamEvents:(l,A,G)=>`${iA}/vaults/${Hl(l)}/scopes/${Hl(A)}/streams/${Hl(G)}/events`,jobs:l=>`${iA}/vaults/${Hl(l)}/jobs`,job:(l,A)=>`${iA}/vaults/${Hl(l)}/jobs/${Hl(A)}`,agentJobs:(l,A)=>`${iA}/vaults/${Hl(l)}/agents/${Hl(A)}/jobs`,jobTasks:(l,A)=>`${iA}/vaults/${Hl(l)}/jobs/${Hl(A)}/tasks`,jobTask:(l,A,G)=>`${iA}/vaults/${Hl(l)}/jobs/${Hl(A)}/tasks/${Hl(G)}`,jobTaskLogs:(l,A,G)=>`${iA}/vaults/${Hl(l)}/jobs/${Hl(A)}/tasks/${Hl(G)}/logs`,cubbyQuery:(l,A,G,b)=>`${iA}/vaults/${Hl(l)}/scopes/${Hl(A)}/agents/${G}/cubbies/${Hl(b)}/query`,cubbyExec:(l,A,G,b)=>`${iA}/vaults/${Hl(l)}/scopes/${Hl(A)}/agents/${G}/cubbies/${Hl(b)}/exec`,serviceCubbies:(l,A)=>`${iA}/vaults/${Hl(l)}/services/${A}/cubbies`,serviceCubby:(l,A,G)=>`${iA}/vaults/${Hl(l)}/services/${A}/cubbies/${Hl(G)}`,serviceCubbyQuery:(l,A,G)=>`${iA}/vaults/${Hl(l)}/services/${A}/cubbies/${Hl(G)}/query`,serviceCubbyExec:(l,A,G)=>`${iA}/vaults/${Hl(l)}/services/${A}/cubbies/${Hl(G)}/exec`,serviceCubbyProvision:(l,A,G)=>`${iA}/vaults/${Hl(l)}/services/${A}/cubbies/${Hl(G)}/provision`,memoryTool:(l,A)=>`${iA}/vaults/${Hl(l)}/memory/${Hl(A)}`,connectors:()=>`${iA}/connectors`,connections:l=>`${iA}/vaults/${Hl(l)}/connections`,connection:(l,A)=>`${iA}/vaults/${Hl(l)}/connections/${Hl(A)}`,connectionActions:(l,A)=>`${iA}/vaults/${Hl(l)}/connections/${Hl(A)}/actions`,agentConnections:(l,A)=>`${iA}/vaults/${Hl(l)}/agents/${Hl(A)}/connections`,agentConnection:(l,A,G)=>`${iA}/vaults/${Hl(l)}/agents/${Hl(A)}/connections/${Hl(G)}`,agentWebhooks:(l,A)=>`${iA}/vaults/${Hl(l)}/agents/${Hl(A)}/webhooks`,agentWebhookKeys:(l,A,G)=>`${iA}/vaults/${Hl(l)}/agents/${Hl(A)}/webhooks/${Hl(G)}/keys`,agentWebhookKey:(l,A,G,b)=>`${iA}/vaults/${Hl(l)}/agents/${Hl(A)}/webhooks/${Hl(G)}/keys/${Hl(b)}`,marketplaceAgents:()=>`${iA}/marketplace/agents`,marketplaceAgent:l=>`${iA}/marketplace/agents/${Hl(l)}`,marketplaceAgentVersion:(l,A)=>`${iA}/marketplace/agents/${Hl(l)}/versions/${Hl(A)}`,delegateInfo:()=>`${iA}/delegate-info`,vaultMembers:l=>`${iA}/vaults/${Hl(l)}/members`,vaultMember:(l,A)=>`${iA}/vaults/${Hl(l)}/members/${Hl(A)}`,vaultMemberScopes:(l,A)=>`${iA}/vaults/${Hl(l)}/members/${Hl(A)}/scopes`,vaultSignedRoster:l=>`${iA}/vaults/${Hl(l)}/roster/signed`,memberships:()=>`${iA}/memberships`,health:()=>"/health",ready:()=>"/ready",metrics:()=>"/metrics"};var sa=class{constructor(A){el(this,"http");this.http=A}claim(A){return this.http.send("POST",fl.vaults(),{body:A})}current(){return this.http.send("GET",fl.vaults())}byId(A){return this.http.send("GET",fl.vault(A))}patch(A,G){return this.http.send("PATCH",fl.vault(A),{body:G})}putDelegations(A,G){return this.http.send("PUT",fl.vaultDelegations(A),{body:G})}};var xo={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:Eb,n:Eo,Gx:v2,Gy:H2,a:vo,d:Ho}=xo,YE=8n,C2=32,IE=64,Xt=(l="")=>{throw new Error(l)},RE=l=>typeof l=="bigint",S2=l=>typeof l=="string",XE=l=>l instanceof Uint8Array||ArrayBuffer.isView(l)&&l.constructor.name==="Uint8Array",Pe=(l,A)=>!XE(l)||typeof A=="number"&&A>0&&l.length!==A?Xt("Uint8Array expected"):l,ma=l=>new Uint8Array(l),ko=l=>Uint8Array.from(l),z2=(l,A)=>l.toString(16).padStart(A,"0"),wo=l=>Array.from(Pe(l)).map(A=>z2(A,2)).join(""),Qc={_0:48,_9:57,A:65,F:70,a:97,f:102},J2=l=>{if(l>=Qc._0&&l<=Qc._9)return l-Qc._0;if(l>=Qc.A&&l<=Qc.F)return l-(Qc.A-10);if(l>=Qc.a&&l<=Qc.f)return l-(Qc.a-10)},Uo=l=>{let A="hex invalid";if(!S2(l))return Xt(A);let G=l.length,b=G/2;if(G%2)return Xt(A);let t=ma(b);for(let c=0,B=0;c<b;c++,B+=2){let e=J2(l.charCodeAt(B)),d=J2(l.charCodeAt(B+1));if(e===void 0||d===void 0)return Xt(A);t[c]=e*16+d}return t},pE=(l,A)=>Pe(S2(l)?Uo(l):ko(Pe(l)),A),j2=()=>globalThis?.crypto,FE=()=>j2()?.subtle??Xt("crypto.subtle must be defined"),f2=(...l)=>{let A=ma(l.reduce((b,t)=>b+Pe(t).length,0)),G=0;return l.forEach(b=>{A.set(b,G),G+=b.length}),A},yE=(l=C2)=>j2().getRandomValues(ma(l)),ra=BigInt,$B=(l,A,G,b="bad number: out of range")=>RE(l)&&A<=l&&l<G?l:Xt(b),$l=(l,A=Eb)=>{let G=l%A;return G>=0n?G:A+G};var M2=(l,A)=>{(l===0n||A<=0n)&&Xt("no inverse n="+l+" mod="+A);let G=$l(l,A),b=A,t=0n,c=1n,B=1n,e=0n;for(;G!==0n;){let d=b/G,Z=b%G,a=t-B*d,n=c-e*d;b=G,G=Z,t=B,c=e,B=a,e=n}return b===1n?$l(t,A):Xt("no inverse")};var x2=l=>l instanceof bc?l:Xt("Point expected"),Jo=2n**256n,Gc=class Gc{constructor(A,G,b,t){el(this,"ex");el(this,"ey");el(this,"ez");el(this,"et");let c=Jo;this.ex=$B(A,0n,c),this.ey=$B(G,0n,c),this.ez=$B(b,1n,c),this.et=$B(t,0n,c),Object.freeze(this)}static fromAffine(A){return new Gc(A.x,A.y,1n,$l(A.x*A.y))}static fromBytes(A,G=!1){let b=Ho,t=ko(Pe(A,C2)),c=A[31];t[31]=c&-129;let B=NE(t);$B(B,0n,G?Jo:Eb);let d=$l(B*B),Z=$l(d-1n),a=$l(b*d+1n),{isValid:n,value:h}=vE(Z,a);n||Xt("bad point: y not sqrt");let W=(h&1n)===1n,i=(c&128)!==0;return!G&&h===0n&&i&&Xt("bad point: x==0, isLastByteOdd"),i!==W&&(h=$l(-h)),new Gc(h,B,1n,$l(h*B))}assertValidity(){let A=vo,G=Ho,b=this;if(b.is0())throw new Error("bad point: ZERO");let{ex:t,ey:c,ez:B,et:e}=b,d=$l(t*t),Z=$l(c*c),a=$l(B*B),n=$l(a*a),h=$l(d*A),W=$l(a*$l(h+Z)),i=$l(n+$l(G*$l(d*Z)));if(W!==i)throw new Error("bad point: equation left != right (1)");let Y=$l(t*c),R=$l(B*e);if(Y!==R)throw new Error("bad point: equation left != right (2)");return this}equals(A){let{ex:G,ey:b,ez:t}=this,{ex:c,ey:B,ez:e}=x2(A),d=$l(G*e),Z=$l(c*t),a=$l(b*e),n=$l(B*t);return d===Z&&a===n}is0(){return this.equals(Oe)}negate(){return new Gc($l(-this.ex),this.ey,this.ez,$l(-this.et))}double(){let{ex:A,ey:G,ez:b}=this,t=vo,c=$l(A*A),B=$l(G*G),e=$l(2n*$l(b*b)),d=$l(t*c),Z=A+G,a=$l($l(Z*Z)-c-B),n=d+B,h=n-e,W=d-B,i=$l(a*h),Y=$l(n*W),R=$l(a*W),V=$l(h*n);return new Gc(i,Y,V,R)}add(A){let{ex:G,ey:b,ez:t,et:c}=this,{ex:B,ey:e,ez:d,et:Z}=x2(A),a=vo,n=Ho,h=$l(G*B),W=$l(b*e),i=$l(c*n*Z),Y=$l(t*d),R=$l((G+b)*(B+e)-h-W),V=$l(Y-i),m=$l(Y+i),I=$l(W-a*h),y=$l(R*V),x=$l(m*I),w=$l(R*I),H=$l(V*m);return new Gc(y,x,H,w)}multiply(A,G=!0){if(!G&&(A===0n||this.is0()))return Oe;if($B(A,1n,Eo),A===1n)return this;if(this.equals(Xd))return fE(A).p;let b=Oe,t=Xd;for(let c=this;A>0n;c=c.double(),A>>=1n)A&1n?b=b.add(c):G&&(t=t.add(c));return b}toAffine(){let{ex:A,ey:G,ez:b}=this;if(this.equals(Oe))return{x:0n,y:1n};let t=M2(b,Eb);return $l(b*t)!==1n&&Xt("invalid inverse"),{x:$l(A*t),y:$l(G*t)}}toBytes(){let{x:A,y:G}=this.assertValidity().toAffine(),b=QE(G);return b[31]|=A&1n?128:0,b}toHex(){return wo(this.toBytes())}clearCofactor(){return this.multiply(ra(YE),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let A=this.multiply(Eo/2n,!1).double();return Eo%2n&&(A=A.add(this)),A.is0()}static fromHex(A,G){return Gc.fromBytes(pE(A),G)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(){return this.toBytes()}};el(Gc,"BASE"),el(Gc,"ZERO");var bc=Gc,Xd=new bc(v2,H2,1n,$l(v2*H2)),Oe=new bc(0n,1n,1n,0n);bc.BASE=Xd;bc.ZERO=Oe;var QE=l=>Uo(z2($B(l,0n,Jo),IE)).reverse(),NE=l=>ra("0x"+wo(ko(Pe(l)).reverse())),Ac=(l,A)=>{let G=l;for(;A-- >0n;)G*=G,G%=Eb;return G},EE=l=>{let G=l*l%Eb*l%Eb,b=Ac(G,2n)*G%Eb,t=Ac(b,1n)*l%Eb,c=Ac(t,5n)*t%Eb,B=Ac(c,10n)*c%Eb,e=Ac(B,20n)*B%Eb,d=Ac(e,40n)*e%Eb,Z=Ac(d,80n)*d%Eb,a=Ac(Z,80n)*d%Eb,n=Ac(a,10n)*c%Eb;return{pow_p_5_8:Ac(n,2n)*l%Eb,b2:G}},k2=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,vE=(l,A)=>{let G=$l(A*A*A),b=$l(G*G*A),t=EE(l*b).pow_p_5_8,c=$l(l*G*t),B=$l(A*c*c),e=c,d=$l(c*k2),Z=B===l,a=B===$l(-l),n=B===$l(-l*k2);return Z&&(c=e),(a||n)&&(c=d),($l(c)&1n)===1n&&(c=$l(-c)),{isValid:Z||a,value:c}};var Co={sha512Async:async(...l)=>{let A=FE(),G=f2(...l);return ma(await A.digest("SHA-512",G.buffer))},sha512Sync:void 0,bytesToHex:wo,hexToBytes:Uo,concatBytes:f2,mod:$l,invert:M2,randomBytes:yE};var ia=8,HE=256,T2=Math.ceil(HE/ia)+1,fo=2**(ia-1),JE=()=>{let l=[],A=Xd,G=A;for(let b=0;b<T2;b++){G=A,l.push(G);for(let t=1;t<fo;t++)G=G.add(A),l.push(G);A=G.double()}return l},w2,U2=(l,A)=>{let G=A.negate();return l?G:A},fE=l=>{let A=w2||(w2=JE()),G=Oe,b=Xd,t=2**ia,c=t,B=ra(t-1),e=ra(ia);for(let d=0;d<T2;d++){let Z=Number(l&B);l>>=e,Z>fo&&(Z-=c,l+=1n);let a=d*fo,n=a,h=a+Math.abs(Z)-1,W=d%2!==0,i=Z<0;Z===0?b=b.add(U2(W,A[n])):G=G.add(U2(i,A[h]))}return{p:G,f:b}};var le=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function kt(l){return l instanceof Uint8Array||ArrayBuffer.isView(l)&&l.constructor.name==="Uint8Array"}function mG(l){if(!Number.isSafeInteger(l)||l<0)throw new Error("positive integer expected, got "+l)}function kG(l,...A){if(!kt(l))throw new Error("Uint8Array expected");if(A.length>0&&!A.includes(l.length))throw new Error("Uint8Array expected of length "+A+", got length="+l.length)}function Ke(l){if(typeof l!="function"||typeof l.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");mG(l.outputLen),mG(l.blockLen)}function pt(l,A=!0){if(l.destroyed)throw new Error("Hash instance has been destroyed");if(A&&l.finished)throw new Error("Hash#digest() has already been called")}function qe(l,A){kG(l);let G=A.outputLen;if(l.length<G)throw new Error("digestInto() expects output buffer of length at least "+G)}function ct(l){return new Uint32Array(l.buffer,l.byteOffset,Math.floor(l.byteLength/4))}function TG(...l){for(let A=0;A<l.length;A++)l[A].fill(0)}function _e(l){return new DataView(l.buffer,l.byteOffset,l.byteLength)}function wt(l,A){return l<<32-A|l>>>A}function qA(l,A){return l<<A|l>>>32-A>>>0}var L2=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function O2(l){return l<<24&4278190080|l<<8&16711680|l>>>8&65280|l>>>24&255}var cc=L2?l=>l:l=>O2(l);function kE(l){for(let A=0;A<l.length;A++)l[A]=O2(l[A]);return l}var Bt=L2?l=>l:kE,P2=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",wE=Array.from({length:256},(l,A)=>A.toString(16).padStart(2,"0"));function et(l){if(kG(l),P2)return l.toHex();let A="";for(let G=0;G<l.length;G++)A+=wE[l[G]];return A}var Nc={_0:48,_9:57,A:65,F:70,a:97,f:102};function D2(l){if(l>=Nc._0&&l<=Nc._9)return l-Nc._0;if(l>=Nc.A&&l<=Nc.F)return l-(Nc.A-10);if(l>=Nc.a&&l<=Nc.f)return l-(Nc.a-10)}function WB(l){if(typeof l!="string")throw new Error("hex string expected, got "+typeof l);if(P2)return Uint8Array.fromHex(l);let A=l.length,G=A/2;if(A%2)throw new Error("hex string expected, got unpadded hex of length "+A);let b=new Uint8Array(G);for(let t=0,c=0;t<G;t++,c+=2){let B=D2(l.charCodeAt(c)),e=D2(l.charCodeAt(c+1));if(B===void 0||e===void 0){let d=l[c]+l[c+1];throw new Error('hex string expected, got non-hex character "'+d+'" at index '+c)}b[t]=B*16+e}return b}function Ec(l){if(typeof l!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(l))}function Zt(l){return typeof l=="string"&&(l=Ec(l)),kG(l),l}function So(l){return typeof l=="string"&&(l=Ec(l)),kG(l),l}function VG(...l){let A=0;for(let b=0;b<l.length;b++){let t=l[b];kG(t),A+=t.length}let G=new Uint8Array(A);for(let b=0,t=0;b<l.length;b++){let c=l[b];G.set(c,t),t+=c.length}return G}function Va(l,A){if(A!==void 0&&{}.toString.call(A)!=="[object Object]")throw new Error("options should be object or undefined");return Object.assign(l,A)}var tc=class{};function pd(l){let A=b=>l().update(Zt(b)).digest(),G=l();return A.outputLen=G.outputLen,A.blockLen=G.blockLen,A.create=()=>l(),A}function K2(l){let A=(b,t)=>l(t).update(Zt(b)).digest(),G=l({});return A.outputLen=G.outputLen,A.blockLen=G.blockLen,A.create=b=>l(b),A}function vb(l=32){if(le&&typeof le.getRandomValues=="function")return le.getRandomValues(new Uint8Array(l));if(le&&typeof le.randomBytes=="function")return Uint8Array.from(le.randomBytes(l));throw new Error("crypto.getRandomValues must be defined")}var q2=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function UE(l,A,G,b){if(typeof l.setBigUint64=="function")return l.setBigUint64(A,G,b);let t=BigInt(32),c=BigInt(4294967295),B=Number(G>>t&c),e=Number(G&c),d=b?4:0,Z=b?0:4;l.setUint32(A+d,B,b),l.setUint32(A+Z,e,b)}function _2(l,A,G){return l&A^~l&G}function $2(l,A,G){return l&A^l&G^A&G}var Fd=class extends tc{constructor(A,G,b,t){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=A,this.outputLen=G,this.padOffset=b,this.isLE=t,this.buffer=new Uint8Array(A),this.view=_e(this.buffer)}update(A){pt(this),A=Zt(A),kG(A);let{view:G,buffer:b,blockLen:t}=this,c=A.length;for(let B=0;B<c;){let e=Math.min(t-this.pos,c-B);if(e===t){let d=_e(A);for(;t<=c-B;B+=t)this.process(d,B);continue}b.set(A.subarray(B,B+e),this.pos),this.pos+=e,B+=e,this.pos===t&&(this.process(G,0),this.pos=0)}return this.length+=A.length,this.roundClean(),this}digestInto(A){pt(this),qe(A,this),this.finished=!0;let{buffer:G,view:b,blockLen:t,isLE:c}=this,{pos:B}=this;G[B++]=128,TG(this.buffer.subarray(B)),this.padOffset>t-B&&(this.process(b,0),B=0);for(let n=B;n<t;n++)G[n]=0;UE(b,t-8,BigInt(this.length*8),c),this.process(b,0);let e=_e(A),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let Z=d/4,a=this.get();if(Z>a.length)throw new Error("_sha2: outputLen bigger than state");for(let n=0;n<Z;n++)e.setUint32(4*n,a[n],c)}digest(){let{buffer:A,outputLen:G}=this;this.digestInto(A);let b=A.slice(0,G);return this.destroy(),b}_cloneInto(A){A||(A=new this.constructor),A.set(...this.get());let{blockLen:G,buffer:b,length:t,finished:c,destroyed:B,pos:e}=this;return A.destroyed=B,A.finished=c,A.length=t,A.pos=e,t%G&&A.buffer.set(b),A}clone(){return this._cloneInto()}},vc=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Vb=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var ua=BigInt(4294967295),lV=BigInt(32);function zo(l,A=!1){return A?{h:Number(l&ua),l:Number(l>>lV&ua)}:{h:Number(l>>lV&ua)|0,l:Number(l&ua)|0}}function Ya(l,A=!1){let G=l.length,b=new Uint32Array(G),t=new Uint32Array(G);for(let c=0;c<G;c++){let{h:B,l:e}=zo(l[c],A);[b[c],t[c]]=[B,e]}return[b,t]}var jo=(l,A,G)=>l>>>G,Mo=(l,A,G)=>l<<32-G|A>>>G,Bc=(l,A,G)=>l>>>G|A<<32-G,ec=(l,A,G)=>l<<32-G|A>>>G,Ae=(l,A,G)=>l<<64-G|A>>>G-32,Ge=(l,A,G)=>l>>>G-32|A<<64-G,AV=(l,A)=>A,GV=(l,A)=>l,bV=(l,A,G)=>l<<G|A>>>32-G,tV=(l,A,G)=>A<<G|l>>>32-G,cV=(l,A,G)=>A<<G-32|l>>>64-G,BV=(l,A,G)=>l<<G-32|A>>>64-G;function dt(l,A,G,b){let t=(A>>>0)+(b>>>0);return{h:l+G+(t/2**32|0)|0,l:t|0}}var yd=(l,A,G)=>(l>>>0)+(A>>>0)+(G>>>0),Qd=(l,A,G,b)=>A+G+b+(l/2**32|0)|0,eV=(l,A,G,b)=>(l>>>0)+(A>>>0)+(G>>>0)+(b>>>0),ZV=(l,A,G,b,t)=>A+G+b+t+(l/2**32|0)|0,dV=(l,A,G,b,t)=>(l>>>0)+(A>>>0)+(G>>>0)+(b>>>0)+(t>>>0),nV=(l,A,G,b,t,c)=>A+G+b+t+c+(l/2**32|0)|0;var lb=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),zl=new Uint32Array(32);function oB(l,A,G,b,t,c){let B=t[c],e=t[c+1],d=zl[2*l],Z=zl[2*l+1],a=zl[2*A],n=zl[2*A+1],h=zl[2*G],W=zl[2*G+1],i=zl[2*b],Y=zl[2*b+1],R=yd(d,a,B);Z=Qd(R,Z,n,e),d=R|0,{Dh:Y,Dl:i}={Dh:Y^Z,Dl:i^d},{Dh:Y,Dl:i}={Dh:AV(Y,i),Dl:GV(Y,i)},{h:W,l:h}=dt(W,h,Y,i),{Bh:n,Bl:a}={Bh:n^W,Bl:a^h},{Bh:n,Bl:a}={Bh:Bc(n,a,24),Bl:ec(n,a,24)},zl[2*l]=d,zl[2*l+1]=Z,zl[2*A]=a,zl[2*A+1]=n,zl[2*G]=h,zl[2*G+1]=W,zl[2*b]=i,zl[2*b+1]=Y}function hB(l,A,G,b,t,c){let B=t[c],e=t[c+1],d=zl[2*l],Z=zl[2*l+1],a=zl[2*A],n=zl[2*A+1],h=zl[2*G],W=zl[2*G+1],i=zl[2*b],Y=zl[2*b+1],R=yd(d,a,B);Z=Qd(R,Z,n,e),d=R|0,{Dh:Y,Dl:i}={Dh:Y^Z,Dl:i^d},{Dh:Y,Dl:i}={Dh:Bc(Y,i,16),Dl:ec(Y,i,16)},{h:W,l:h}=dt(W,h,Y,i),{Bh:n,Bl:a}={Bh:n^W,Bl:a^h},{Bh:n,Bl:a}={Bh:Ae(n,a,63),Bl:Ge(n,a,63)},zl[2*l]=d,zl[2*l+1]=Z,zl[2*A]=a,zl[2*A+1]=n,zl[2*G]=h,zl[2*G+1]=W,zl[2*b]=i,zl[2*b+1]=Y}function CE(l,A={},G,b,t){if(mG(G),l<0||l>G)throw new Error("outputLen bigger than keyLen");let{key:c,salt:B,personalization:e}=A;if(c!==void 0&&(c.length<1||c.length>G))throw new Error("key length must be undefined or 1.."+G);if(B!==void 0&&B.length!==b)throw new Error("salt must be undefined or "+b);if(e!==void 0&&e.length!==t)throw new Error("personalization must be undefined or "+t)}var To=class extends tc{constructor(A,G){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,mG(A),mG(G),this.blockLen=A,this.outputLen=G,this.buffer=new Uint8Array(A),this.buffer32=ct(this.buffer)}update(A){pt(this),A=Zt(A),kG(A);let{blockLen:G,buffer:b,buffer32:t}=this,c=A.length,B=A.byteOffset,e=A.buffer;for(let d=0;d<c;){this.pos===G&&(Bt(t),this.compress(t,0,!1),Bt(t),this.pos=0);let Z=Math.min(G-this.pos,c-d),a=B+d;if(Z===G&&!(a%4)&&d+Z<c){let n=new Uint32Array(e,a,Math.floor((c-d)/4));Bt(n);for(let h=0;d+G<c;h+=t.length,d+=G)this.length+=G,this.compress(n,h,!1);Bt(n);continue}b.set(A.subarray(d,d+Z),this.pos),this.pos+=Z,this.length+=Z,d+=Z}return this}digestInto(A){pt(this),qe(A,this);let{pos:G,buffer32:b}=this;this.finished=!0,TG(this.buffer.subarray(G)),Bt(b),this.compress(b,0,!0),Bt(b);let t=ct(A);this.get().forEach((c,B)=>t[B]=cc(c))}digest(){let{buffer:A,outputLen:G}=this;this.digestInto(A);let b=A.slice(0,G);return this.destroy(),b}_cloneInto(A){let{buffer:G,length:b,finished:t,destroyed:c,outputLen:B,pos:e}=this;return A||(A=new this.constructor({dkLen:B})),A.set(...this.get()),A.buffer.set(G),A.destroyed=c,A.finished=t,A.length=b,A.pos=e,A.outputLen=B,A}clone(){return this._cloneInto()}},Ia=class extends To{constructor(A={}){let G=A.dkLen===void 0?64:A.dkLen;super(128,G),this.v0l=lb[0]|0,this.v0h=lb[1]|0,this.v1l=lb[2]|0,this.v1h=lb[3]|0,this.v2l=lb[4]|0,this.v2h=lb[5]|0,this.v3l=lb[6]|0,this.v3h=lb[7]|0,this.v4l=lb[8]|0,this.v4h=lb[9]|0,this.v5l=lb[10]|0,this.v5h=lb[11]|0,this.v6l=lb[12]|0,this.v6h=lb[13]|0,this.v7l=lb[14]|0,this.v7h=lb[15]|0,CE(G,A,64,16,16);let{key:b,personalization:t,salt:c}=A,B=0;if(b!==void 0&&(b=Zt(b),B=b.length),this.v0l^=this.outputLen|B<<8|65536|1<<24,c!==void 0){c=Zt(c);let e=ct(c);this.v4l^=cc(e[0]),this.v4h^=cc(e[1]),this.v5l^=cc(e[2]),this.v5h^=cc(e[3])}if(t!==void 0){t=Zt(t);let e=ct(t);this.v6l^=cc(e[0]),this.v6h^=cc(e[1]),this.v7l^=cc(e[2]),this.v7h^=cc(e[3])}if(b!==void 0){let e=new Uint8Array(this.blockLen);e.set(b),this.update(e)}}get(){let{v0l:A,v0h:G,v1l:b,v1h:t,v2l:c,v2h:B,v3l:e,v3h:d,v4l:Z,v4h:a,v5l:n,v5h:h,v6l:W,v6h:i,v7l:Y,v7h:R}=this;return[A,G,b,t,c,B,e,d,Z,a,n,h,W,i,Y,R]}set(A,G,b,t,c,B,e,d,Z,a,n,h,W,i,Y,R){this.v0l=A|0,this.v0h=G|0,this.v1l=b|0,this.v1h=t|0,this.v2l=c|0,this.v2h=B|0,this.v3l=e|0,this.v3h=d|0,this.v4l=Z|0,this.v4h=a|0,this.v5l=n|0,this.v5h=h|0,this.v6l=W|0,this.v6h=i|0,this.v7l=Y|0,this.v7h=R|0}compress(A,G,b){this.get().forEach((d,Z)=>zl[Z]=d),zl.set(lb,16);let{h:t,l:c}=zo(BigInt(this.length));zl[24]=lb[8]^c,zl[25]=lb[9]^t,b&&(zl[28]=~zl[28],zl[29]=~zl[29]);let B=0,e=q2;for(let d=0;d<12;d++)oB(0,4,8,12,A,G+2*e[B++]),hB(0,4,8,12,A,G+2*e[B++]),oB(1,5,9,13,A,G+2*e[B++]),hB(1,5,9,13,A,G+2*e[B++]),oB(2,6,10,14,A,G+2*e[B++]),hB(2,6,10,14,A,G+2*e[B++]),oB(3,7,11,15,A,G+2*e[B++]),hB(3,7,11,15,A,G+2*e[B++]),oB(0,5,10,15,A,G+2*e[B++]),hB(0,5,10,15,A,G+2*e[B++]),oB(1,6,11,12,A,G+2*e[B++]),hB(1,6,11,12,A,G+2*e[B++]),oB(2,7,8,13,A,G+2*e[B++]),hB(2,7,8,13,A,G+2*e[B++]),oB(3,4,9,14,A,G+2*e[B++]),hB(3,4,9,14,A,G+2*e[B++]);this.v0l^=zl[0]^zl[16],this.v0h^=zl[1]^zl[17],this.v1l^=zl[2]^zl[18],this.v1h^=zl[3]^zl[19],this.v2l^=zl[4]^zl[20],this.v2h^=zl[5]^zl[21],this.v3l^=zl[6]^zl[22],this.v3h^=zl[7]^zl[23],this.v4l^=zl[8]^zl[24],this.v4h^=zl[9]^zl[25],this.v5l^=zl[10]^zl[26],this.v5h^=zl[11]^zl[27],this.v6l^=zl[12]^zl[28],this.v6h^=zl[13]^zl[29],this.v7l^=zl[14]^zl[30],this.v7h^=zl[15]^zl[31],TG(zl)}destroy(){this.destroyed=!0,TG(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},gV=K2(l=>new Ia(l));var Do=gV;function SE(l){return l("return this")}var Zc=typeof globalThis<"u"?globalThis:typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:SE(Function);function $e(l,A){return typeof Zc[l]>"u"?A:Zc[l]}var Ra=class{constructor(A){el(this,"__encoding");this.__encoding=A}decode(A){let G="";for(let b=0,t=A.length;b<t;b++)G+=String.fromCharCode(A[b]);return G}};var WV=$e("TextDecoder",Ra);var Xa=class{encode(A){let G=A.length,b=new Uint8Array(G);for(let t=0;t<G;t++)b[t]=A.charCodeAt(t);return b}};var oV=$e("TextEncoder",Xa);function Nd(l){return typeof l=="function"}function zE(){return Number.NaN}var UA=$e("BigInt",zE);var lZ=UA(0),AZ=UA(1);var hV=UA(1e9),nk=hV*hV,ak=UA(Number.MAX_SAFE_INTEGER);var sV=UA(256),rV=UA(256*256),jE=UA("0x10000000000000000");function GZ(l,{isLe:A=!0,isNegative:G=!1}={}){A||(l=l.slice().reverse());let b=l.length;if(G&&b&&l[b-1]&128){switch(b){case 0:return UA(0);case 1:return UA((l[0]^255)*-1-1);case 2:return UA((l[0]+(l[1]<<8)^65535)*-1-1);case 4:return UA((l[0]+(l[1]<<8)+(l[2]<<16)+l[3]*16777216^4294967295)*-1-1)}let c=new DataView(l.buffer,l.byteOffset);if(b===8)return c.getBigInt64(0,!0);let B=UA(0),e=b%2;for(let d=b-2;d>=e;d-=2)B=B*rV+UA(c.getUint16(d,!0)^65535);return e&&(B=B*sV+UA(l[0]^255)),B*-AZ-AZ}switch(b){case 0:return UA(0);case 1:return UA(l[0]);case 2:return UA(l[0]+(l[1]<<8));case 4:return UA(l[0]+(l[1]<<8)+(l[2]<<16)+l[3]*16777216)}let t=new DataView(l.buffer,l.byteOffset);switch(b){case 8:return t.getBigUint64(0,!0);case 16:return t.getBigUint64(8,!0)*jE+t.getBigUint64(0,!0);default:{let c=UA(0),B=b%2;for(let e=b-2;e>=B;e-=2)c=c*rV+UA(t.getUint16(e,!0));return B&&(c=c*sV+UA(l[0])),c}}}var Lo="0123456789abcdef",pa=new Uint8Array(256),iV=new Uint8Array(256*256);for(let l=0,A=Lo.length;l<A;l++)pa[Lo[l].charCodeAt(0)|0]=l|0,l>9&&(pa[Lo[l].toUpperCase().charCodeAt(0)|0]=l|0);for(let l=0;l<256;l++){let A=l<<8;for(let G=0;G<256;G++)iV[A|G]=pa[l]<<4|pa[G]}function Hb(l,A=-1){if(!l)return new Uint8Array;let G=l.startsWith("0x")?2:0,b=Math.ceil((l.length-G)/2),t=Math.ceil(A===-1?b:A/8),c=new Uint8Array(t),B=t>b?t-b:0;for(let e=B;e<t;e++,G+=2)c[e]=iV[l.charCodeAt(G)<<8|l.charCodeAt(G+1)];return c}function mV(l,{isLe:A=!1,isNegative:G=!1}={}){return!l||l==="0x"?UA(0):GZ(Hb(l),{isLe:A,isNegative:G})}var FA=po(uV(),1);function Ed(l){return FA.default.isBN(l)}var Po=/^0x[\da-fA-F]+$/,YV=/^[\da-fA-F]+$/;function ub(l,A=-1,G){return typeof l=="string"&&(l==="0x"||Po.test(l))&&(A===-1?G||l.length%2===0:l.length===2+Math.ceil(A/4))}function IV(l){return!!l&&typeof l=="object"}function Fa(...l){return A=>(IV(A)||Nd(A))&&l.every(G=>Nd(A[G]))}var ya=Fa("toBigInt");var Qa=Fa("toBn");function RV(l){return typeof l=="bigint"?l:l?ub(l)?mV(l.toString()):Ed(l)?UA(l.toString()):ya(l)?l.toBigInt():Qa(l)?UA(l.toBn().toString()):UA(l):UA(0)}var PA=typeof UA=="function"&&typeof UA.asIntN=="function";var XV=typeof Zc.Buffer=="function"&&typeof Zc.Buffer.isBuffer=="function",zk=typeof Zc.process=="object";function pV(l){return XV&&!!l&&Nd(l.readDoubleLE)&&Zc.Buffer.isBuffer(l)}function Jb(l){return(l&&l.constructor)===Uint8Array||l instanceof Uint8Array}var ME=new oV;function uG(l){return l?ME.encode(l.toString()):new Uint8Array}function Tl(l,A=!1){if(A&&l==null)throw new Error("u8aToU8a: Expected non-null, non-undefined value");return Jb(l)?pV(l)?new Uint8Array(l):l:ub(l)?Hb(l):Array.isArray(l)?new Uint8Array(l):uG(l)}function nG(...l){let A=l.length,G=new Array(A),b=0;for(let t=0;t<A;t++)G[t]=Tl(l[t]),b+=G[t].length;return dc(G,b)}function dc(l,A=0){let G=l.length,b=0;if(!A)for(let c=0;c<G;c++)A+=l[c].length;let t=new Uint8Array(A);for(let c=0;c<G;c++)t.set(l[c],b),b+=l[c].length;return t}function vd(l){let A=l.length|0;for(let G=0;G<A;G++)if(l[G]|0)return!1;return!0}function Mb(l,A){let G=Tl(l),b=Tl(A);if(G.length===b.length){let t=new DataView(G.buffer,G.byteOffset),c=new DataView(b.buffer,b.byteOffset),B=G.length%4|0,e=G.length-B|0;for(let d=0;d<e;d+=4)if(t.getUint32(d)!==c.getUint32(d))return!1;for(let d=e,Z=G.length;d<Z;d++)if(G[d]!==b[d])return!1;return!0}return!1}function Ko(l,A=-1,G=!1){let b=Math.ceil(A/8);if(A===-1||l.length===b)return l;if(l.length>b)return l.subarray(0,b);let t=new Uint8Array(b);return t.set(l,G?0:b-l.length),t}function Hd(l,{isLe:A=!0,isNegative:G=!1}={}){A||(l=l.slice().reverse());let b=l.length;if(G&&b&&l[b-1]&128)switch(b){case 0:return new FA.default(0);case 1:return new FA.default((l[0]^255)*-1-1);case 2:return new FA.default((l[0]+(l[1]<<8)^65535)*-1-1);case 3:return new FA.default((l[0]+(l[1]<<8)+(l[2]<<16)^16777215)*-1-1);case 4:return new FA.default((l[0]+(l[1]<<8)+(l[2]<<16)+l[3]*16777216^4294967295)*-1-1);case 5:return new FA.default(((l[0]+(l[1]<<8)+(l[2]<<16)+l[3]*16777216^4294967295)+(l[4]^255)*4294967296)*-1-1);case 6:return new FA.default(((l[0]+(l[1]<<8)+(l[2]<<16)+l[3]*16777216^4294967295)+(l[4]+(l[5]<<8)^65535)*4294967296)*-1-1);default:return new FA.default(l,"le").fromTwos(b*8)}switch(b){case 0:return new FA.default(0);case 1:return new FA.default(l[0]);case 2:return new FA.default(l[0]+(l[1]<<8));case 3:return new FA.default(l[0]+(l[1]<<8)+(l[2]<<16));case 4:return new FA.default(l[0]+(l[1]<<8)+(l[2]<<16)+l[3]*16777216);case 5:return new FA.default(l[0]+(l[1]<<8)+(l[2]<<16)+(l[3]+(l[4]<<8))*16777216);case 6:return new FA.default(l[0]+(l[1]<<8)+(l[2]<<16)+(l[3]+(l[4]<<8)+(l[5]<<16))*16777216);default:return new FA.default(l,"le")}}var Na=new Array(256),FV=new Array(256*256);for(let l=0;l<256;l++)Na[l]=l.toString(16).padStart(2,"0");for(let l=0;l<256;l++){let A=l<<8;for(let G=0;G<256;G++)FV[A|G]=Na[l]+Na[G]}function qo(l,A){let G=l.length%2|0,b=l.length-G|0;for(let t=0;t<b;t+=2)A+=FV[l[t]<<8|l[t+1]];return G&&(A+=Na[l[b]|0]),A}function nt(l,A=-1,G=!0){let b=G?"0x":"";if(l?.length){if(A>0){let t=Math.ceil(A/8);if(l.length>t)return`${qo(l.subarray(0,t/2),b)}\u2026${qo(l.subarray(l.length-t/2),"")}`}}else return b;return qo(l,b)}var TE=new WV("utf-8");function Ea(l){return l?TE.decode(l):""}var va=Tl(`Ethereum Signed Message:
305
- `),bZ=Tl("<Bytes>"),tZ=Tl("</Bytes>"),DE=bZ.length+tZ.length;function cZ(l,A){return l.length>=DE&&Mb(l.subarray(0,bZ.length),bZ)&&Mb(l.slice(-tZ.length),tZ)||A&&l.length>=va.length&&Mb(l.subarray(0,va.length),va)}function _o(l){let A=Tl(l);return cZ(A,!1)?A.subarray(bZ.length,A.length-tZ.length):A}function $o(l){let A=Tl(l);return cZ(A,!0)?A:dc([bZ,A,tZ])}var yV=UA(256),LE=UA(255);function OE(l,A,G){let b=[],t=G&&l<lZ;for(t&&(l=(l+AZ)*-AZ);l!==lZ;){let c=l%yV,B=Number(t?c^LE:c);A?b.push(B):b.unshift(B),l=(l-c)/yV}return Uint8Array.from(b)}function lh(l,{bitLength:A=-1,isLe:G=!0,isNegative:b=!1}={}){let t=RV(l);if(t===lZ)return A===-1?new Uint8Array(1):new Uint8Array(Math.ceil((A||0)/8));let c=OE(t,G,b);if(A===-1)return c;let B=Math.ceil((A||0)/8),e=new Uint8Array(B);return b&&e.fill(255),e.set(c,G?0:B-c.length),e}function QV(l){if(!l||l==="0x")return"";if(Po.test(l))return l.substring(2);if(YV.test(l))return l;throw new Error(`Expected hex value to convert, found '${l}'`)}function NV(l,{isLe:A=!1,isNegative:G=!1}={}){if(!l||l==="0x")return new FA.default(0);let b=QV(l),t=new FA.default(b,16,A?"le":"be");return G?t.fromTwos(b.length*4):t}var Jd=new FA.default(1),fd=new FA.default(2);var EV=new FA.default(1e9),jw=EV.mul(EV),Mw=new FA.default(Number.MAX_SAFE_INTEGER);function xd(l){return typeof l=="bigint"}function kd(l){return l?FA.default.isBN(l)?l:ub(l)?NV(l.toString()):xd(l)?new FA.default(l.toString()):Qa(l)?l.toBn():ya(l)?new FA.default(l.toBigInt().toString()):new FA.default(l):new FA.default(0)}var PE={bitLength:-1,isLe:!0,isNegative:!1};function wG(l,{bitLength:A=-1,isLe:G=!0,isNegative:b=!1}=PE){let t=kd(l),c=Math.ceil(A===-1?t.bitLength()/8:(A||0)/8);if(!l)return A===-1?new Uint8Array(1):new Uint8Array(c);let B=new Uint8Array(c),e=b?t.toTwos(c*8):t;return B.set(e.toArray(G?"le":"be",c),0),B}var KE=fd.pow(new FA.default(6)).isub(Jd),qE=fd.pow(new FA.default(14)).isub(Jd),_E=fd.pow(new FA.default(30)).isub(Jd),$E={bitLength:16},lv={bitLength:32};function vV(l){let A=kd(l);if(A.lte(KE))return new Uint8Array([A.toNumber()<<2]);if(A.lte(qE))return wG(A.shln(2).iadd(Jd),$E);if(A.lte(_E))return wG(A.shln(2).iadd(fd),lv);let G=wG(A),b=G.length;for(;G[b-1]===0;)b--;if(b<4)throw new Error("Invalid length, previous checks match anything less than 2^30");return dc([new Uint8Array([(b-4<<2)+3]),G.subarray(0,b)])}function be(l){return dc([vV(l.length),l])}function Ah(l){return typeof l=="string"||l instanceof String}function Gh(l){return typeof l=="number"}function te(l,...A){let G=new Set(["__proto__","constructor","prototype"]);for(let b=0,t=A.length;b<t;b++){let c=A[b];if(c)if(typeof c.entries=="function")for(let[B,e]of c.entries())G.has(B)||(l[B]=e);else{let B=Object.create(null);for(let[e,d]of Object.entries(c))G.has(e)||(B[e]=d);Object.assign(l,B)}}return l}var Av=Zc.crypto;function Ha(l){return Av.getRandomValues(l)}var Ja={getRandomValues:Ha},Gv={crypto:Ja},Ft,fa=class{constructor(A){EG(this,Ft);el(this,"abort",()=>{throw new Error("abort")});el(this,"__wbindgen_is_undefined",A=>GA(this,Ft).getObject(A)===void 0);el(this,"__wbindgen_throw",(A,G)=>{throw new Error(GA(this,Ft).getString(A,G))});el(this,"__wbg_self_1b7a39e3a92c949c",()=>GA(this,Ft).addObject(Gv));el(this,"__wbg_require_604837428532a733",(A,G)=>{throw new Error(`Unable to require ${GA(this,Ft).getString(A,G)}`)});el(this,"__wbg_crypto_968f1772287e2df0",A=>GA(this,Ft).addObject(Ja));el(this,"__wbg_getRandomValues_a3d34b4fee3c2869",A=>GA(this,Ft).addObject(Ja.getRandomValues));el(this,"__wbg_getRandomValues_f5e14ab7ac8e995d",(A,G,b)=>{Ja.getRandomValues(GA(this,Ft).getU8a(G,b))});el(this,"__wbg_randomFillSync_d5bd2d655fdf256a",(A,G,b)=>{throw new Error("randomFillsync is not available")});el(this,"__wbindgen_object_drop_ref",A=>{GA(this,Ft).takeObject(A)});bG(this,Ft,A)}};Ft=new WeakMap;var wd,yt,Ud,sB,rB,Hc,at,BZ,ce,eZ,xa=class{constructor(A){EG(this,wd);EG(this,yt);EG(this,Ud);EG(this,sB);EG(this,rB);EG(this,Hc);EG(this,at);EG(this,BZ);EG(this,ce);EG(this,eZ);bG(this,wd,A),bG(this,sB,null),bG(this,rB,null),bG(this,yt,new Array(32).fill(void 0).concat(void 0,null,!0,!1)),bG(this,Hc,GA(this,yt).length),bG(this,eZ,"none"),bG(this,at,null),bG(this,BZ,null),bG(this,ce,null),bG(this,Ud,{...new fa(this)})}get error(){return GA(this,BZ)}get type(){return GA(this,eZ)}get wasm(){return GA(this,at)}async init(A){(!GA(this,ce)||A)&&bG(this,ce,(A||GA(this,wd))(GA(this,Ud)));let{error:G,type:b,wasm:t}=await GA(this,ce);return bG(this,eZ,b),bG(this,at,t),bG(this,BZ,G),GA(this,at)}getObject(A){return GA(this,yt)[A]}dropObject(A){A<36||(GA(this,yt)[A]=GA(this,Hc),bG(this,Hc,A))}takeObject(A){let G=this.getObject(A);return this.dropObject(A),G}addObject(A){GA(this,Hc)===GA(this,yt).length&&GA(this,yt).push(GA(this,yt).length+1);let G=GA(this,Hc);return bG(this,Hc,GA(this,yt)[G]),GA(this,yt)[G]=A,G}getInt32(){return(GA(this,sB)===null||GA(this,sB).buffer!==GA(this,at).memory.buffer)&&bG(this,sB,new Int32Array(GA(this,at).memory.buffer)),GA(this,sB)}getUint8(){return(GA(this,rB)===null||GA(this,rB).buffer!==GA(this,at).memory.buffer)&&bG(this,rB,new Uint8Array(GA(this,at).memory.buffer)),GA(this,rB)}getU8a(A,G){return this.getUint8().subarray(A/1,A/1+G)}getString(A,G){return Ea(this.getU8a(A,G))}allocU8a(A){let G=GA(this,at).__wbindgen_malloc(A.length*1);return this.getUint8().set(A,G/1),[G,A.length]}allocString(A){return this.allocU8a(uG(A))}resultU8a(){let A=this.getInt32()[2],G=this.getInt32()[8/4+1],b=this.getU8a(A,G).slice();return GA(this,at).__wbindgen_free(A,G*1),b}resultString(){return Ea(this.resultU8a())}};wd=new WeakMap,yt=new WeakMap,Ud=new WeakMap,sB=new WeakMap,rB=new WeakMap,Hc=new WeakMap,at=new WeakMap,BZ=new WeakMap,ce=new WeakMap,eZ=new WeakMap;function HV(l,A,G){return async b=>{let t={error:null,type:"none",wasm:null};try{if(A?.length){if(typeof WebAssembly!="object"||typeof WebAssembly.instantiate!="function")throw new Error("WebAssembly is not available in your environment")}else throw new Error("No WebAssembly provided for initialization");let c=await WebAssembly.instantiate(A,{wbg:b});t.wasm=c.instance.exports,t.type="wasm"}catch(c){typeof G=="function"?(t.wasm=G(b),t.type="asm"):(t.error=`FATAL: Unable to initialize @polkadot/wasm-${l}:: ${c.message}`,console.error(t.error))}return t}}var JV="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fV=new Array(256);for(let l=0,A=JV.length;l<A;l++)fV[JV.charCodeAt(l)]=l;function bh(l,A){let G=0,b=0,t=-1;for(let c=0,B=A.length-1;t!==B;c++)G=G<<6|fV[l.charCodeAt(c)],(b+=6)>=8&&(A[++t]=G>>>(b-=8)&255);return A}var nc=Uint8Array,iB=Uint16Array,Bh=Uint32Array,bv=new nc([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xV=new nc([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),kV=new nc([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),wV=(l,A)=>{let G=new iB(31);for(let t=0;t<31;++t)G[t]=A+=1<<l[t-1];let b=new Bh(G[30]);for(let t=1;t<30;++t)for(let c=G[t];c<G[t+1];++c)b[c]=c-G[t]<<5|t;return[G,b]},[UV,tv]=wV(xV,2);UV[28]=258,tv[258]=28;var[cv]=wV(kV,0),eh=new iB(32768);for(let l=0;l<32768;++l){let A=(l&43690)>>>1|(l&21845)<<1;A=(A&52428)>>>2|(A&13107)<<2,A=(A&61680)>>>4|(A&3855)<<4,eh[l]=((A&65280)>>>8|(A&255)<<8)>>>1}var Cd=(l,A,G)=>{let b=l.length,t=0,c=new iB(A);for(;t<b;++t)l[t]&&++c[l[t]-1];let B=new iB(A);for(t=1;t<A;++t)B[t]=B[t-1]+c[t-1]<<1;let e;if(G){e=new iB(1<<A);let d=15-A;for(t=0;t<b;++t)if(l[t]){let Z=t<<4|l[t],a=A-l[t],n=B[l[t]-1]++<<a;for(let h=n|(1<<a)-1;n<=h;++n)e[eh[n]>>d]=Z}}else for(e=new iB(b),t=0;t<b;++t)l[t]&&(e[t]=eh[B[l[t]-1]++]>>15-l[t]);return e},Sd=new nc(288);for(let l=0;l<144;++l)Sd[l]=8;for(let l=144;l<256;++l)Sd[l]=9;for(let l=256;l<280;++l)Sd[l]=7;for(let l=280;l<288;++l)Sd[l]=8;var CV=new nc(32);for(let l=0;l<32;++l)CV[l]=5;var Bv=Cd(Sd,9,1),ev=Cd(CV,5,1),Ut=(l,A,G)=>{let b=A>>>3;return(l[b]|l[b+1]<<8)>>>(A&7)&G},th=(l,A)=>{let G=A>>>3;return(l[G]|l[G+1]<<8|l[G+2]<<16)>>>(A&7)},Zv=l=>(l>>>3)+(l&7&&1),dv=(l,A,G)=>{(A==null||A<0)&&(A=0),(G==null||G>l.length)&&(G=l.length);let b=new(l instanceof iB?iB:l instanceof Bh?Bh:nc)(G-A);return b.set(l.subarray(A,G)),b},ch=l=>{let A=l[0];for(let G=1,b=l.length;G<b;++G)l[G]>A&&(A=l[G]);return A},nv=(l,A,G)=>{let b=!G||G.i;G||(G={});let t=l.length,c=!A||!b;A||(A=new nc(t*3));let B=Y=>{let R=A.length;if(Y>R){let V=new nc(Math.max(R<<1,Y));V.set(A),A=V}},e=G.f||0,d=G.p||0,Z=G.b||0,a=G.l,n=G.d,h=G.m,W=G.n;if(e&&!a)return A;let i=t<<3;do{if(!a){G.f=e=Ut(l,d,1);let m=Ut(l,d+1,3);if(d+=3,m)if(m==1)a=Bv,n=ev,h=9,W=5;else if(m==2){let I=Ut(l,d,31)+257,y=Ut(l,d+10,15)+4,x=I+Ut(l,d+5,31)+1;d+=14;let w=new nc(x),H=new nc(19);for(let Q=0;Q<y;++Q)H[bv[Q]]=Ut(l,d+Q*3,7);d+=y*3;let j=ch(H),C=(1<<j)-1;if(!b&&d+x*(j+7)>i)break;let D=Cd(H,j,1);for(let Q=0;Q<x;){let r=D[Ut(l,d,C)];d+=r&15;let F=r>>>4;if(F<16)w[Q++]=F;else{let E=0,f=0;for(F==16?(f=3+Ut(l,d,3),d+=2,E=w[Q-1]):F==17?(f=3+Ut(l,d,7),d+=3):F==18&&(f=11+Ut(l,d,127),d+=7);f--;)w[Q++]=E}}let $=w.subarray(0,I),K=w.subarray(I);h=ch($),W=ch(K),a=Cd($,h,1),n=Cd(K,W,1)}else throw"invalid block type";else{let I=Zv(d)+4,y=l[I-4]|l[I-3]<<8,x=I+y;if(x>t){if(b)throw"unexpected EOF";break}c&&B(Z+y),A.set(l.subarray(I,x),Z),G.b=Z+=y,G.p=d=x<<3;continue}if(d>i)throw"unexpected EOF"}c&&B(Z+131072);let Y=(1<<h)-1,R=(1<<W)-1,V=h+W+18;for(;b||d+V<i;){let m=a[th(l,d)&Y],I=m>>>4;if(d+=m&15,d>i)throw"unexpected EOF";if(!m)throw"invalid length/literal";if(I<256)A[Z++]=I;else if(I==256){a=void 0;break}else{let y=I-254;if(I>264){let C=I-257,D=xV[C];y=Ut(l,d,(1<<D)-1)+UV[C],d+=D}let x=n[th(l,d)&R],w=x>>>4;if(!x)throw"invalid distance";d+=x&15;let H=cv[w];if(w>3){let C=kV[w];H+=th(l,d)&(1<<C)-1,d+=C}if(d>i)throw"unexpected EOF";c&&B(Z+131072);let j=Z+y;for(;Z<j;Z+=4)A[Z]=A[Z-H],A[Z+1]=A[Z+1-H],A[Z+2]=A[Z+2-H],A[Z+3]=A[Z+3-H];Z=j}}G.l=a,G.p=d,G.b=Z,a&&(e=1,G.m=h,G.d=n,G.n=W)}while(!e);return Z==A.length?A:dv(A,0,Z)},av=l=>{if((l[0]&15)!=8||l[0]>>>4>7||(l[0]<<8|l[1])%31)throw"invalid zlib data";if(l[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Zh(l,A){return nv((av(l),l.subarray(2,-4)),A)}var ZZ=po(SV(),1);var zV=Zh(bh(ZZ.bytes,new Uint8Array(ZZ.lenIn)),new Uint8Array(ZZ.lenOut));var jV=HV("crypto",zV,null);var cA=new xa(jV);async function MV(l){return cA.init(l)}function UG(l){return(...A)=>{if(!cA.wasm)throw new Error("The WASM interface has not been initialized. Ensure that you wait for the initialization Promise with waitReady() from @polkadot/wasm-crypto (or cryptoWaitReady() from @polkadot/util-crypto) before attempting to use WASM-only interfaces.");return l(cA.wasm,...A)}}var TV=UG((l,A)=>(l.ext_bip39_to_entropy(8,...cA.allocString(A)),cA.resultU8a())),DV=UG((l,A,G)=>(l.ext_bip39_to_mini_secret(8,...cA.allocString(A),...cA.allocString(G)),cA.resultU8a())),LV=UG((l,A,G)=>(l.ext_bip39_to_seed(8,...cA.allocString(A),...cA.allocString(G)),cA.resultU8a())),OV=UG((l,A)=>l.ext_bip39_validate(...cA.allocString(A))!==0),PV=UG((l,A)=>(l.ext_ed_from_seed(8,...cA.allocU8a(A)),cA.resultU8a())),KV=UG((l,A,G,b)=>(l.ext_ed_sign(8,...cA.allocU8a(A),...cA.allocU8a(G),...cA.allocU8a(b)),cA.resultU8a())),qV=UG((l,A,G,b)=>l.ext_ed_verify(...cA.allocU8a(A),...cA.allocU8a(G),...cA.allocU8a(b))!==0),_V=UG((l,A)=>(l.ext_secp_from_seed(8,...cA.allocU8a(A)),cA.resultU8a())),$V=UG((l,A)=>(l.ext_secp_pub_compress(8,...cA.allocU8a(A)),cA.resultU8a())),lu=UG((l,A)=>(l.ext_secp_pub_expand(8,...cA.allocU8a(A)),cA.resultU8a())),Au=UG((l,A,G,b)=>(l.ext_secp_recover(8,...cA.allocU8a(A),...cA.allocU8a(G),b),cA.resultU8a())),Gu=UG((l,A,G)=>(l.ext_secp_sign(8,...cA.allocU8a(A),...cA.allocU8a(G)),cA.resultU8a()));var bu=UG((l,A,G,b)=>(l.ext_blake2b(8,...cA.allocU8a(A),...cA.allocU8a(G),b),cA.resultU8a())),tu=UG((l,A,G)=>(l.ext_hmac_sha256(8,...cA.allocU8a(A),...cA.allocU8a(G)),cA.resultU8a())),cu=UG((l,A,G)=>(l.ext_hmac_sha512(8,...cA.allocU8a(A),...cA.allocU8a(G)),cA.resultU8a())),Bu=UG((l,A)=>(l.ext_keccak256(8,...cA.allocU8a(A)),cA.resultU8a())),eu=UG((l,A)=>(l.ext_keccak512(8,...cA.allocU8a(A)),cA.resultU8a())),Zu=UG((l,A,G,b)=>(l.ext_pbkdf2(8,...cA.allocU8a(A),...cA.allocU8a(G),b),cA.resultU8a())),du=UG((l,A,G,b,t,c)=>(l.ext_scrypt(8,...cA.allocU8a(A),...cA.allocU8a(G),b,t,c),cA.resultU8a())),nu=UG((l,A)=>(l.ext_sha256(8,...cA.allocU8a(A)),cA.resultU8a())),au=UG((l,A)=>(l.ext_sha512(8,...cA.allocU8a(A)),cA.resultU8a()));function TA(){return!!cA.wasm}async function gu(){try{return!!await MV()}catch{return!1}}function dh(l){return(...A)=>nt(l(...A))}function nh(l,A){return(G,b)=>A(G,l,b)}function wa(l,A){return(G,b=256,t)=>{let c=Tl(G);return!PA||!t&&TA()?l[b](c):A[b](c)}}function Tb(l,A=256,G,b){let t=Math.ceil(A/8),c=Tl(l);return!PA||!b&&TA()?bu(c,Tl(G),t):G?Do(c,{dkLen:t,key:G}):Do(c,{dkLen:t})}var ah=dh(Tb);var uu=new TextEncoder,gv=new TextDecoder,Ca="cere.vault.grant.v1",mB="cere.vault.grant.v2",Be="",dZ=["public","internal","private","restricted"];function nZ(l){return dZ.includes(l)}function Yu(){let l=dZ.map(A=>`"${A}"`);return l.slice(0,-1).join(", ")+" or "+l[l.length-1]}var za="X-Grant-Signature",Wh="X-Grant-Issued-At";function Ab(l){let A=l.startsWith("0x")?l.slice(2):l;return A.startsWith("0X")&&(A=A.slice(2)),A=A.toLowerCase(),A===""||A.length%2!==0||!/^[0-9a-f]+$/.test(A)?l:`0x${A}`}function oh(l){let A=Ab(l);return`v-${ah(uu.encode(A),128).slice(2)}`}var zd="";var vG=class extends Error{constructor(G,b=""){super(G);el(this,"memberPubkey");this.memberPubkey=b,this.name="GrantVerificationError"}};function hh(l,A,G,b,t,c){return jd(l,A,G,b,t,c,Be)}function jd(l,A,G,b,t,c,B){if(l==="")throw new Error("canonical grant: vaultId is required");if(A==="")throw new Error("canonical grant: memberPubkey is required");if(G==="")throw new Error("canonical grant: role is required");if(t==="")throw new Error("canonical grant: issuedAt is required");let e=Ca;if(B!==Be){if(!nZ(B))throw new Error(`canonical grant: privacyCeiling ${JSON.stringify(B)} must be ${Yu()}`);e=mB}let Z=Object.keys(b).sort(Vv).map(n=>`{"name":${fc(n)},"level":${fc(b[n])}}`),a=`{"schema":${fc(e)},"vaultId":${fc(l)},"memberPubkey":${fc(A)},"role":${fc(G)},"scopes":[${Z.join(",")}],"issuedAt":${fc(t)},"expiresAt":${fc(c)}`+(B===Be?"":`,"privacyCeiling":${fc(B)}`)+"}";return uu.encode(a)}function sh(l){if(l.length===0)throw new Error("decode grant: empty document");let A;try{A=JSON.parse(gv.decode(l))}catch(W){throw new Error(`decode grant: ${W instanceof Error?W.message:String(W)}`)}if(typeof A!="object"||A===null||Array.isArray(A))throw new Error("decode grant: document is not a JSON object");let G=A,b=Jc(G,"schema"),t=Jc(G,"privacyCeiling",!0);if(b===Ca){if(t!=="")throw new Error(`decode grant: schema ${JSON.stringify(b)} carries a privacyCeiling; that is ${JSON.stringify(mB)}`)}else if(b===mB){if(!nZ(t))throw new Error(`decode grant: schema ${JSON.stringify(b)} requires a privacyCeiling of ${Yu()}, got ${JSON.stringify(t)}`)}else throw new Error(`decode grant: schema ${JSON.stringify(b)} is not ${JSON.stringify(Ca)} or ${JSON.stringify(mB)}`);let c=Jc(G,"vaultId"),B=Jc(G,"memberPubkey"),e=Jc(G,"role");if(c===""||B===""||e==="")throw new Error("decode grant: vaultId, memberPubkey and role are all required");let d=G.scopes;if(!Array.isArray(d))throw new Error("decode grant: scopes must be an array");let Z=Object.create(null);for(let W of d){if(typeof W!="object"||W===null||Array.isArray(W))throw new Error("decode grant: a scope entry is not an object");let i=Jc(W,"name");if(i==="")throw new Error("decode grant: a scope with no name");Z[i]=Jc(W,"level")}let a=Jc(G,"issuedAt");if(a==="")throw new Error("decode grant: issuedAt is required");let n=Jc(G,"expiresAt");return{schema:b,vaultId:c,memberPubkey:B,role:e,scopes:Z,issuedAt:a,expiresAt:n,privacyCeiling:b===mB?t:""}}async function Sa(l,A,G){if(A.length===0||G==="")return!1;let b,t;try{b=Te(It(l).toLowerCase()),t=Te(It(G).toLowerCase())}catch{return!1}return!Vu(l)||!Vu(G)||b.length!==32||t.length!==64?!1:ov(b,A,t)}var Wu=xo.n,Wv=(()=>{let l=new Uint8Array(32);return l[0]=1,l})();async function ov(l,A,G){let b=G.subarray(0,32),t=ou(G.subarray(32,64));if(t>=Wu)return!1;let c;try{c=bc.fromBytes(l,!0)}catch{return!1}let B=Co.mod(ou(await Co.sha512Async(b,l,A)),Wu),e=bc.BASE.multiply(t,!1).add(c.multiply(B,!1).negate()),d=e.is0()?Wv:e.toBytes();for(let Z=0;Z<32;Z++)if(d[Z]!==b[Z])return!1;return!0}function ou(l){let A=0n;for(let G=l.length-1;G>=0;G--)A=A<<8n|BigInt(l[G]);return A}async function rh(l,A,G={}){if(typeof A!="string"||A==="")throw new vG("expectedVaultId is required: verifying a roster against the vault id it carries only proves the response agrees with itself");if(typeof l!="object"||l===null)throw new vG(`signed roster is not an object (got ${hu(l)})`);if(typeof l.vaultId!="string"||l.vaultId==="")throw new vG("signed roster carries no vaultId");if(typeof l.orgWalletPubkey!="string"||l.orgWalletPubkey==="")throw new vG("signed roster carries no orgWalletPubkey");if(!Array.isArray(l.grants))throw new vG(`signed roster's grants is not an array (got ${hu(l.grants)})`);if(l.vaultId!==A)throw new vG(`signed roster names vault ${l.vaultId}, asked about ${A}`);if(oh(l.orgWalletPubkey)!==A)throw new vG(`orgWalletPubkey ${l.orgWalletPubkey} does not derive vault ${A}`);let b=[];for(let t of l.grants){if(typeof t!="object"||t===null){let c=new vG("signed roster holds a grant that is not an object");G.onUnverifiableGrant?.(c);continue}try{b.push(await Iu(A,l.orgWalletPubkey,t))}catch(c){if(!(c instanceof vG))throw c;G.onUnverifiableGrant?.(c)}}return b}function hu(l){return l===null?"null":Array.isArray(l)?"an array":typeof l}async function Iu(l,A,G){if(oh(A)!==l)throw new vG(`orgWalletPubkey ${A} does not derive vault ${l}`,G.memberPubkey);let b;try{b=No(G.doc)}catch(B){throw new vG(`grant document is not valid base64: ${B instanceof Error?B.message:String(B)}`,G.memberPubkey)}let t=G.signer??"";if(typeof t!="string")throw new vG("signer is not a string",G.memberPubkey);if(t!==""&&Ab(t)!==Ab(A))return hv(l,A,G,b,t);if((G.signerDoc??"")!==""||(G.signerSig??"")!=="")throw new vG("owner-signed entry carries signer evidence; signerDoc and signerSig belong only to an admin-signed entry",G.memberPubkey);if(!await Sa(A,b,G.sig))throw new vG(`grant document is not signed by the vault owner (${A})`,G.memberPubkey);let c;try{c=sh(b)}catch(B){throw new vG(B instanceof Error?B.message:String(B),G.memberPubkey)}if(c.vaultId!==l||c.memberPubkey!==G.memberPubkey)throw new vG(`grant document describes a different membership: it names ${c.memberPubkey} on ${c.vaultId}, and was served as ${G.memberPubkey} on ${l}`,G.memberPubkey);return c}var su="admin",ru="member";async function hv(l,A,G,b,t){let c=i=>new vG(i,G.memberPubkey),B=G.signerDoc??"",e=G.signerSig??"";if(B===""||e==="")throw c("admin-signed entry requires signer, signerDoc and signerSig together");let d=Ab(t);if(!/^0x[0-9a-f]{64}$/.test(d))throw c(`signer ${JSON.stringify(t)} is not a 32-byte hex ed25519 key`);let Z;try{Z=No(B)}catch(i){throw c(`signerDoc is not valid base64: ${i instanceof Error?i.message:String(i)}`)}if(!await Sa(A,Z,e))throw c("appointment is not signed by the vault wallet");let a=iu("appointment",Z,c);if(a.vaultId!==l)throw c(`appointment names vault ${JSON.stringify(a.vaultId)}`);if(Ab(a.memberPubkey)!==d)throw c(`appointment names member ${Ua(a.memberPubkey)}, signer is ${Ua(d)}`);if(a.role!==su)throw c(`appointment confers role ${JSON.stringify(a.role)}, not ${JSON.stringify(su)}`);if(!await Sa(d,b,G.sig))throw c("grant is not signed by the named admin");let n=iu("grant",b,c,i=>{if(i.vaultId!==l)throw c(`document names vault ${JSON.stringify(i.vaultId)}`);if(Ab(i.memberPubkey)!==Ab(G.memberPubkey))throw c(`document names member ${Ua(i.memberPubkey)}, entry names ${Ua(G.memberPubkey)}`)});if(n.role!==ru)throw c(`an admin-signed grant must confer role ${JSON.stringify(ru)}, got ${JSON.stringify(n.role)}`);if(Ab(n.memberPubkey)===d)throw c("admin-signed grant grants to its own signer");let h=gh("appointment issuedAt",a.issuedAt,c),W=gh("grant issuedAt",n.issuedAt,c);if(mu(W,h)<0)throw c(`grant issued ${n.issuedAt} predates the appointment issued ${a.issuedAt}`);if(a.expiresAt!==zd){let i=gh("appointment expiresAt",a.expiresAt,c);if(mu(W,i)>=0)throw c(`grant issued ${n.issuedAt} at or after the appointment expired ${a.expiresAt}`)}return{...n,grantedBy:d}}function iu(l,A,G,b){let t;try{t=sh(A)}catch(B){throw G(`${l} is not in canonical form: ${B instanceof Error?B.message:String(B)}`)}b?.(t);let c;try{c=jd(t.vaultId,t.memberPubkey,t.role,t.scopes,t.issuedAt,t.expiresAt,t.privacyCeiling)}catch{throw G(`${l} is not in canonical form`)}if(c.length!==A.length||c.some((B,e)=>B!==A[e]))throw G(`${l} is not in canonical form`);return t}var sv=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?Z$/;function gh(l,A,G){let b=sv.exec(A);if(b===null)throw G(`${l} ${JSON.stringify(A)} is not a UTC timestamp of the form YYYY-MM-DDTHH:MM:SS[.fraction]Z`);let[t,c,B,e,d,Z]=b.slice(1,7).map(Number);if(c<1||c>12||B<1||B>rv(t,c)||e>23||d>59||Z>59)throw G(`${l} ${JSON.stringify(A)} is not an RFC3339 time`);let a=Number((b[7]??"").padEnd(9,"0"));return[iv(t,c,B)*86400+e*3600+d*60+Z,a]}function mu(l,A){return l[0]!==A[0]?l[0]-A[0]:l[1]-A[1]}function rv(l,A){return A===2?l%4===0&&l%100!==0||l%400===0?29:28:[4,6,9,11].includes(A)?30:31}function iv(l,A,G){let b=A<=2?l-1:l,t=Math.floor(b/400),c=b-t*400,B=(A+9)%12,e=Math.floor((153*B+2)/5)+G-1,d=c*365+Math.floor(c/4)-Math.floor(c/100)+e;return t*146097+d-719468}function Ua(l){let A=l.startsWith("0x")?l.slice(2):l;return A.startsWith("0X")&&(A=A.slice(2)),A.slice(0,8)}function Vu(l){let A=l.startsWith("0x")?l.slice(2):l;return A.startsWith("0X")&&(A=A.slice(2)),A.length%2===0&&/^[0-9a-fA-F]*$/.test(A)}function Jc(l,A,G=!1){let b=l[A];if(b===void 0&&G)return"";if(typeof b!="string")throw new Error(`decode grant: ${A} must be a string, got ${b===void 0?"nothing":typeof b}`);return mv(b)}function mv(l){return l.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"\uFFFD")}function fc(l){return JSON.stringify(l).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Vv(l,A){let G=Array.from(l),b=Array.from(A),t=Math.min(G.length,b.length);for(let c=0;c<t;c++){let B=G[c].codePointAt(0),e=b[c].codePointAt(0);if(B!==e)return B-e}return G.length-b.length}var ja=class{constructor(A,G){el(this,"http");el(this,"signer");this.http=A,this.signer=G}mine(){return this.http.send("GET",fl.memberships())}list(A){return this.http.send("GET",fl.vaultMembers(A))}signedRoster(A){return this.http.send("GET",fl.vaultSignedRoster(A))}async put(A,G,b,t,c={}){let B=c.privacyCeiling===void 0?void 0:c.privacyCeiling;if(B!==void 0&&!nZ(B))throw new Error(`put: privacyCeiling ${JSON.stringify(B)} must be one of `+dZ.map(Z=>`"${Z}"`).join(", "));let e=c.scopes??await this.heldScopes(A,G),d=t===void 0?zd:t;return this.http.send("PUT",fl.vaultMember(A,G),{body:{role:b,expiresAt:t,...B===void 0?{}:{privacyCeiling:B},timestamp:new Date().toISOString()},headers:await this.grantHeader(A,G,b,e,d,B)})}remove(A,G){return this.http.send("DELETE",fl.vaultMember(A,G),{body:{timestamp:new Date().toISOString(),vaultId:A,memberPubkey:Ab(G)}})}scopes(A,G){return this.http.send("GET",fl.vaultMemberScopes(A,G))}async putScopes(A,G,b,t={}){this.grantSigner();let c=t.standing?.privacyCeiling;if(c!==void 0&&c!==Be&&!nZ(c))throw new Error(`putScopes: standing.privacyCeiling ${JSON.stringify(c)} must be one of `+dZ.map(Z=>`"${Z}"`).join(", ")+", or NO_PRIVACY_CEILING for a member who holds none");let B=t.standing??await this.heldStanding(A,G),e=c??await this.heldCeiling(A,G),d=B.expiresAt===void 0?zd:B.expiresAt;try{return await this.http.send("PUT",fl.vaultMemberScopes(A,G),{body:{scopes:b,expiresAt:B.expiresAt,timestamp:new Date().toISOString()},headers:await this.grantHeader(A,G,B.role,b,d,e===void 0||e===Be?void 0:e)})}catch(Z){if(e===void 0&&Z instanceof $G&&Z.status===400&&Z.message.includes(mB)){let a=Ab(G);throw new Rd(`putScopes: ${a} is not in ${A}'s signed roster (it serves live memberships only), so the grant was signed with no privacy ceiling, and vault-api refused it because this member holds one. Nothing was written. Pass \`{ standing: { role, expiresAt, privacyCeiling } }\` with the ceiling the member holds. Server said: ${Z.message}`,a,Z.status,Z.code)}throw Z}}async grantHeader(A,G,b,t,c,B){let e=this.grantSigner(),d=new Date().toISOString(),Z=B===void 0?hh(A,Ab(G),b,t,d,c):jd(A,Ab(G),b,t,d,c,B);return{[za]:qb(await e.sign(Z,"data")),[Wh]:d}}grantSigner(){let A=this.signer;if(A===void 0||typeof A.sign!="function")throw new Rt(`A membership write must carry the VAULT OWNER's signature over the grant's canonical document, in the ${za} header. Construct the SDK with \`signer\` set to the vault owner's key (\`new VaultSDK({ endpoint, signer })\`); a custom \`auth\` provider authenticates the request but cannot sign the grant, because the two cover different bytes.`);if(A.type!=="ed25519")throw new Rt(`A grant signature must be ed25519 \u2014 vault-api verifies it with SchemeEd25519 and nothing else \u2014 but this signer is "${A.type}". An sr25519 key can authenticate the request and still never authorise the grant.`);return A}async heldCeiling(A,G){let b=Ab(G),t=[],B=(await rh(await this.signedRoster(A),A,{onUnverifiableGrant:d=>t.push(d)})).find(d=>Ab(d.memberPubkey)===b);if(B!==void 0)return B.privacyCeiling;let e=t.find(d=>d.memberPubkey!==""&&Ab(d.memberPubkey)===b);if(e!==void 0)throw new vG(`putScopes: ${b}'s grant in the signed roster of ${A} failed verification (${e.message}), so the privacy ceiling it holds is unknown and no grant document can be signed for it.`,e.memberPubkey)}async heldScopes(A,G){try{return(await this.scopes(A,G)).scopes}catch(b){if(b instanceof $G&&b.status===404)return{};throw b}}async heldStanding(A,G){let b=Ab(G),t=(await this.list(A)).find(c=>c.isOwner!==!0&&Ab(c.memberPubkey)===b);if(t===void 0)throw new Error(`putScopes: ${b} has no membership row on ${A}, so there is no role or expiry to put in the grant document. Add the member first (\`memberships.put\`), or pass \`{ standing: { role, expiresAt } }\` if you already know them.`);return{role:t.role,expiresAt:t.expiresAt}}};var Ru=new tt,Ma=class{constructor(A){el(this,"http");this.http=A}getAgent(A,G){let b=G?fl.marketplaceAgentVersion(A,G):fl.marketplaceAgent(A);return this.http.send("GET",b,{auth:Ru})}async list(A={}){let G=await this.http.send("GET",fl.marketplaceAgents(),{auth:Ru,query:{limit:A.limit,cursor:A.cursor,q:A.query}}),t={items:G.agents??G.items??[]};return G.nextCursor!==void 0&&(t.nextCursor=G.nextCursor),t}};var Xu=new tt,Ta=class{constructor(A){el(this,"http");this.http=A}live(){return this.http.send("GET",fl.health(),{auth:Xu})}ready(){return this.http.send("GET",fl.ready(),{auth:Xu})}};var Da=class{constructor(A){el(this,"http");this.http=A}list(A){return this.http.send("GET",fl.scopes(A))}get(A,G){return this.http.send("GET",fl.scope(A,G))}create(A,G){return this.http.send("POST",fl.scopes(A),{body:pu(G)})}update(A,G,b){return this.http.send("PATCH",fl.scope(A,G),{body:pu(b)})}delete(A,G){return this.http.send("DELETE",fl.scope(A,G),{body:{}})}};function pu(l){let A={};return"name"in l&&l.name!==void 0&&(A.name=l.name),l.displayName!==void 0&&(A.displayName=l.displayName),l.streamLabel!==void 0&&(A.streamLabel=l.streamLabel),l.metadata!==void 0&&(A.metadata=l.metadata),A}function Fu(l,A){if(l.length>16)throw new Error(`[${A}] \`scopes\` has ${l.length} entries; the server refuses more than 16 \u2014 trim the set before calling`);for(let G of l)if(typeof G!="string"||G.trim().length===0)throw new Error(`[${A}] \`scopes\` contains an empty/blank entry (${JSON.stringify(G)}) \u2014 the server refuses an empty scope member`)}function aZ(l,A){let G=l.scope!==void 0,b=l.scopes!==void 0;if(G&&b)throw new Error(`[${A}] both \`scope\` (${JSON.stringify(l.scope)}) and \`scopes\` (${JSON.stringify(l.scopes)}) were supplied \u2014 these conflict and which one would apply is undefined; pass exactly one.`);if(b){if(!l.scopes||l.scopes.length===0)throw new Error(`[${A}] \`scopes\` must be a non-empty array`);return Fu(l.scopes,A),l.scopes}if(G)return Fu([l.scope],A),[l.scope];throw new Error(`[${A}] requires \`scope\` or a non-empty \`scopes\` array`)}var WZ=class{constructor(A){el(this,"http");this.http=A}async connect(A,G){let{ceiling:b,...t}=G,c=b===void 0?{...t}:{...t,ceiling:La(b)};return aZ(G,"Agents.connect"),this.http.send("POST",fl.agents(A),{body:c})}async list(A,G={}){return(await this.http.send("GET",fl.agents(A),{query:{status:G.status}})).items??[]}get(A,G){return this.http.send("GET",fl.agent(A,G))}update(A,G,b){return this.http.send("PATCH",fl.agent(A,G),{body:{settings:b}})}async setCeiling(A,G,b){let t=La(b);return this.http.send("PUT",fl.agentCeiling(A,G),{body:{...t}})}setHarvester(A,G,b){return this.http.send("PUT",fl.agentHarvester(A,G),{body:{harvester:b}})}disconnect(A,G){return this.http.send("DELETE",fl.agent(A,G),{body:{}})}};function gZ(l){return new $G(`invalid ceiling: ${l}`,0,"BAD_REQUEST")}function La(l){if(l===null||typeof l!="object"||Array.isArray(l))throw gZ("expected an object { gpuUnits?, a2aTokens? }");for(let t of Object.keys(l))if(t!=="gpuUnits"&&t!=="a2aTokens")throw gZ(`unknown field ${JSON.stringify(t)} (expected { gpuUnits?, a2aTokens? })`);let A=t=>{let c=l[t];if(c===void 0)return 0;if(typeof c!="number"||!Number.isFinite(c))throw gZ(`${t} must be a finite number (got ${String(c)})`);if(c<0)throw gZ(`${t} must be >= 0 (got ${c})`);return c},G=A("gpuUnits"),b=A("a2aTokens");if(!Number.isInteger(b))throw gZ(`a2aTokens must be an integer (got ${b})`);if(b>Number.MAX_SAFE_INTEGER)throw gZ(`a2aTokens must be <= Number.MAX_SAFE_INTEGER (got ${b})`);return{gpuUnits:G,a2aTokens:b}}var Qt=class{constructor(A){el(this,"http");this.http=A}listStreams(A,G,b={}){return this.http.send("GET",fl.scopeStreams(A,G),{query:{active:b.active,limit:b.limit,cursor:b.cursor}})}getStream(A,G,b){return this.http.send("GET",fl.stream(A,G,b))}listStreamEvents(A,G,b,t={}){return this.http.send("GET",fl.streamEvents(A,G,b),{query:{limit:t.limit,cursor:t.cursor}})}listJobs(A,G={}){return this.http.send("GET",fl.jobs(A),{query:{state:G.state,cursor:G.cursor,limit:G.limit,from:G.from,to:G.to,agentId:G.agentId}})}getJob(A,G){return this.http.send("GET",fl.job(A,G))}listAgentJobs(A,G,b={}){return this.http.send("GET",fl.agentJobs(A,G),{query:{state:b.state,cursor:b.cursor,limit:b.limit}})}listTasks(A,G,b={}){return this.http.send("GET",fl.jobTasks(A,G),{query:{cursor:b.cursor,limit:b.limit}})}getTask(A,G,b){return this.http.send("GET",fl.jobTask(A,G,b))}listTaskLogs(A,G,b,t={}){return this.http.send("GET",fl.jobTaskLogs(A,G,b),{query:{offset:t.offset,limit:t.limit}})}};var Oa=class{constructor(A,G){el(this,"http");el(this,"vaultId");this.http=A,this.vaultId=G}search(A,G={}){return this.http.send("POST",fl.memoryTool(this.vaultId,"record_search"),{body:{match:A,limit:G.limit,type:G.type,privacy:G.privacy,scope:G.scope,cursor:G.cursor,domain:G.domain}})}list(A,G={}){return this.http.send("POST",fl.memoryTool(this.vaultId,"record_list"),{body:{type:A,limit:G.limit,scope:G.scope,cursor:G.cursor,domain:G.domain}})}get(A){return this.http.send("POST",fl.memoryTool(this.vaultId,"record_get"),{body:{id:A}})}neighbours(A,G={}){return this.http.send("POST",fl.memoryTool(this.vaultId,"record_neighbours"),{body:{id:A,limit:G.limit,edge_type:G.edgeType,direction:G.direction}})}countByType(A={}){return this.http.send("POST",fl.memoryTool(this.vaultId,"record_count_by_type"),{body:{scope:A.scope,domain:A.domain}})}};var Pa=class{constructor(A,G){el(this,"http");el(this,"vaultId");this.http=A,this.vaultId=G}async list(A){let G=await this.http.send("GET",fl.agentWebhooks(this.vaultId,A)),b=G&&typeof G=="object"?G.webhooks:void 0;return Array.isArray(b)?b:[]}createKey(A,G,b){return this.http.send("POST",fl.agentWebhookKeys(this.vaultId,A,G),{body:{name:b.name,expiresAt:b.expiresAt}})}async revokeKey(A,G,b){await this.http.send("DELETE",fl.agentWebhookKey(this.vaultId,A,G,b),{body:{}})}};async function Qu(l){return _a(await l.send("GET",fl.connectors()),"connectors")}var Ka=class{constructor(A,G){el(this,"http");el(this,"vaultId");this.http=A,this.vaultId=G}async list(){return _a(await this.http.send("GET",fl.connections(this.vaultId)),"connections")}create(A){return this.http.send("POST",fl.connections(this.vaultId),{body:yu(A)})}update(A,G){return this.http.send("PATCH",fl.connection(this.vaultId,A),{body:yu(G)})}async revoke(A){await this.http.send("DELETE",fl.connection(this.vaultId,A),{body:{}})}async actions(A){return _a(await this.http.send("GET",fl.connectionActions(this.vaultId,A)),"actions")}},qa=class{constructor(A,G){el(this,"http");el(this,"vaultId");this.http=A,this.vaultId=G}async list(A){return _a(await this.http.send("GET",fl.agentConnections(this.vaultId,A)),"connections")}set(A,G,b){return this.http.send("PUT",fl.agentConnection(this.vaultId,A,G),{body:{actions:b.actions,events:b.events,filter:b.filter??{}}})}async remove(A,G){await this.http.send("DELETE",fl.agentConnection(this.vaultId,A,G),{body:{}})}};function yu(l){let A={};for(let[G,b]of Object.entries(l))b!==void 0&&(A[G]=b);return A}function _a(l,A){let G=l&&typeof l=="object"?l[A]:void 0;return Array.isArray(G)?G:[]}var $a=class{constructor(A){el(this,"http");this.http=A}publish(A,G,b){let c=(Array.isArray(b)?b:[b]).map(B=>({role:"user",...B,timestamp:B.timestamp??new Date().toISOString()}));return this.http.send("POST",fl.scopeEvents(A,G),{body:{events:c}})}};var lg=class{constructor(A){el(this,"http");this.http=A}async upload(A,G,b,t,c={}){return this.http.send("PUT",fl.scopeObject(A,G,b),{rawBody:t,headers:{"Content-Type":c.contentType??"application/octet-stream"}})}async get(A,G,b){return this.http.send("GET",fl.scopeObject(A,G,b),{responseType:"bytes"})}async head(A,G,b){let t=await this.http.send("HEAD",fl.scopeObject(A,G,b),{responseType:"headers"}),c=Number(t["content-length"]??"0");return{size:Number.isFinite(c)?c:0,contentType:t["content-type"]??"",etag:t.etag,updatedAt:t["last-modified"]}}async presignedUrl(A,G,b,t={}){return this.http.send("GET",fl.scopeObjectsPresignedUrl(A,G),{query:{path:b,ttlSeconds:t.ttlSeconds}})}async delete(A,G,b){await this.http.send("DELETE",fl.scopeObject(A,G,b),{body:{timestamp:new Date().toISOString()}})}async list(A,G,b={}){return this.http.send("GET",fl.scopeObjects(A,G),{query:{prefix:b.prefix}})}};function ih(l,A,G,b,t,c={}){let B=new Qt(l),e=c.intervalMs??1e3,d=c.pageSize??100,Z=c.onError??(V=>{console.warn("[vault-sdk] subscribe poll failed:",V)}),a=new Set,n=!1,h=0,W,i=new Promise(V=>W=V),Y=async()=>{let V;do{let m=await B.listStreamEvents(A,G,b.context,{cursor:V,limit:d});for(let I of m.items){if(n)return;a.has(I.eventId)||(a.add(I.eventId),!(b.types&&!b.types.includes(I.type))&&(b.from&&!b.from.includes(I.from??"")||await t(I)))}V=m.hasMore&&m.nextCursor?m.nextCursor:void 0}while(V&&!n)};return(async()=>{for(;!n;){try{await Y(),h=0}catch(m){h++,Z(m)}if(n)break;let V=c.maxBackoffMs&&h>0?Math.min(e*2**h,c.maxBackoffMs):e;await new Promise(m=>setTimeout(m,V))}W()})(),{unsubscribe(){n=!0},closed:i}}var Md=class{constructor(A,G,b){el(this,"http");el(this,"vaultId");el(this,"name");el(this,"events");el(this,"browse");el(this,"_objects");el(this,"streams",{list:(A={})=>this.browse.listStreams(this.vaultId,this.name,A),get:A=>this.browse.getStream(this.vaultId,this.name,A)});el(this,"objects",{upload:async(A,G,b={})=>{let t=await this._objects.upload(this.vaultId,this.name,A,G,b);return b.publishEvent&&await this.publish({type:b.publishEvent.type,context:b.publishEvent.context,payload:{...b.publishEvent.payload,vaultPath:t.vaultPath}}),t},get:A=>this._objects.get(this.vaultId,this.name,A),head:A=>this._objects.head(this.vaultId,this.name,A),presignedUrl:(A,G={})=>this._objects.presignedUrl(this.vaultId,this.name,A,G),delete:A=>this._objects.delete(this.vaultId,this.name,A),list:(A={})=>this._objects.list(this.vaultId,this.name,A)});this.http=A,this.vaultId=G,this.name=b,this.events=new $a(A),this.browse=new Qt(A),this._objects=new lg(A)}async publish(A){let G=await this.events.publish(this.vaultId,this.name,A),b=G.rejected??[],t=G.accepted??[];if(b.length>0){let c=b[0];throw new Error(`publish rejected: ${c.reason}${c.code?` (${c.code})`:""}`)}return{eventId:t[0]}}stream(A){return{events:{list:(G={})=>this.browse.listStreamEvents(this.vaultId,this.name,A,G)}}}subscribe(A,G,b={}){return ih(this.http,this.vaultId,this.name,A,G,b)}subscribeAll(A,G,b={}){return Iv(this.http,this.vaultId,this.name,this.browse,A,G,b)}};function Iv(l,A,G,b,t,c,B){let e=B.refreshIntervalMs??3e4,d=B.onError??(R=>{console.warn("[vault-sdk] subscribeAll refresh failed:",R)}),Z=new Map,a=!1,n,h,W=new Promise(R=>h=R),i=R=>{if(Z.has(R)||a)return;let V=ih(l,A,G,{context:R,...t.types?{types:t.types}:{}},c,B);Z.set(R,V)},Y=async()=>{try{let R=await b.listStreams(A,G);for(let V of R.items)i(V.context)}catch(R){d(R)}a||(n=setTimeout(Y,e))};return Y(),{unsubscribe(){if(a)return;a=!0,n&&clearTimeout(n);let R=[];for(let V of Z.values())V.unsubscribe(),R.push(V.closed);Z.clear(),Promise.all(R).then(()=>h())},closed:W}}var oZ=class{constructor(A){el(this,"http");this.http=A}query(A,G,b,t,c,B=[]){return this.http.send("POST",fl.cubbyQuery(A,G,b,t),{body:{sql:c,params:B}})}exec(A,G,b,t,c,B=[]){return this.http.send("POST",fl.cubbyExec(A,G,b,t),{body:{sql:c,params:B}})}serviceQuery(A,G,b,t,c=[]){return this.http.send("POST",fl.serviceCubbyQuery(A,G,b),{body:{sql:t,params:c}})}serviceExec(A,G,b,t,c=[]){return this.http.send("POST",fl.serviceCubbyExec(A,G,b),{body:{sql:t,params:c}})}async serviceList(A,G){return(await this.http.send("GET",fl.serviceCubbies(A,G)))?.data??[]}serviceProvision(A,G,b,t){return this.http.send("POST",fl.serviceCubbyProvision(A,G,b),{body:{migrations:t}})}serviceDelete(A,G,b){return this.http.send("DELETE",fl.serviceCubby(A,G,b))}};var Td=class{constructor(A,G,b){el(this,"vaultId");el(this,"asPubKey");el(this,"cubbies");this.vaultId=G,this.asPubKey=b,this.cubbies=new oZ(A)}list(){return this.cubbies.serviceList(this.vaultId,this.asPubKey)}cubby(A){let{vaultId:G,asPubKey:b,cubbies:t}=this;return{query:(c,B=[])=>t.serviceQuery(G,b,A,c,B),exec:(c,B=[])=>t.serviceExec(G,b,A,c,B),provision:c=>t.serviceProvision(G,b,A,c),delete:()=>t.serviceDelete(G,b,A)}}};var Dd=class{constructor(A,G,b,t,c){el(this,"vaultId");el(this,"scope");el(this,"agentId");el(this,"alias");el(this,"api");this.vaultId=G,this.scope=b,this.agentId=t,this.alias=c,this.api=new oZ(A)}query(A,G=[]){return this.api.query(this.vaultId,this.scope,this.agentId,this.alias,A,G)}exec(A,G=[]){return this.api.exec(this.vaultId,this.scope,this.agentId,this.alias,A,G)}};var ee=class l{constructor(A,G,b){el(this,"http");el(this,"vaultIdRoot");el(this,"vaultId");el(this,"agentId");el(this,"scope");el(this,"scopes");el(this,"version");el(this,"asPubKey");el(this,"cubbyAliases");el(this,"status");el(this,"manifest");el(this,"ceiling");el(this,"harvester");el(this,"bundle");el(this,"createdAt");el(this,"updatedAt");el(this,"api");el(this,"browse");el(this,"jobs",{list:(A={})=>this.browse.listAgentJobs(this.vaultIdRoot,this.agentId,A)});this.http=A,this.vaultIdRoot=G,this.vaultId=b.vaultId,this.agentId=b.agentId,this.scope=b.scope,this.scopes=b.scopes,this.version=b.version,this.asPubKey=b.asPubKey,this.cubbyAliases=b.cubbyAliases,this.status=b.status,this.manifest=b.manifest,this.ceiling=b.ceiling,this.harvester=b.harvester===!0,this.bundle=b.bundle,this.createdAt=b.createdAt,this.updatedAt=b.updatedAt,this.api=new WZ(A),this.browse=new Qt(A)}cubby(A){if(!this.cubbyAliases.includes(A))throw new Error(`agent ${this.agentId} has no cubby "${A}". Declared aliases: ${this.cubbyAliases.join(", ")||"(none)"}`);return new Dd(this.http,this.vaultIdRoot,this.scope,this.agentId,A)}async update(A){let G=await this.api.update(this.vaultIdRoot,this.agentId,A);return new l(this.http,this.vaultIdRoot,G)}async setCeiling(A){let G=await this.api.setCeiling(this.vaultIdRoot,this.agentId,A);return new l(this.http,this.vaultIdRoot,G)}async setHarvester(A){let G=await this.api.setHarvester(this.vaultIdRoot,this.agentId,A);return new l(this.http,this.vaultIdRoot,G)}disconnect(){return this.api.disconnect(this.vaultIdRoot,this.agentId)}};var Ld=class{constructor(A,G,b){el(this,"http");el(this,"vaultId");el(this,"jobId");el(this,"browse");el(this,"tasks",{list:(A={})=>this.browse.listTasks(this.vaultId,this.jobId,A),get:A=>this.browse.getTask(this.vaultId,this.jobId,A),logs:(A,G={})=>this.browse.listTaskLogs(this.vaultId,this.jobId,A,G),subscribe:(A,G,b={})=>Rv(this.browse,this.vaultId,this.jobId,A,G,b)});this.http=A,this.vaultId=G,this.jobId=b,this.browse=new Qt(A)}get(){return this.browse.getJob(this.vaultId,this.jobId)}tree(){throw new Error("JobHandle.tree() requires the orchestrator's tree route which is not yet implemented (returns 501).")}};function Rv(l,A,G,b,t,c){let B=c.intervalMs??1e3,e=c.pageSize??100,d=c.onError??(R=>{console.warn("[vault-sdk] tasks.subscribe poll failed:",R)}),Z=new Set,a,n=!1,h,W=new Promise(R=>h=R),i=b.since?Date.parse(b.since):void 0;return(async()=>{for(;!n;){try{let R=await l.listTasks(A,G,{cursor:a,limit:e});for(let V of R.items)if(!Z.has(V.taskId)){if(Z.add(V.taskId),i!==void 0){let m=V.startedAt??V.finishedAt;if(m&&Date.parse(m)<i)continue}await t(V)}R.nextCursor&&(a=R.nextCursor)}catch(R){d(R)}if(n)break;await new Promise(R=>setTimeout(R,B))}h()})(),{unsubscribe(){n=!0},closed:W}}var Xv=new TextEncoder;function mh(l){if(!l.scopes||l.scopes.length===0)throw new Error("buildVaultAgreementPayloadV2: `scopes` must be a non-empty array \u2014 an agreement must record at least one scope");let A=Array.from(new Set(l.scopes)),G=l.createdAt??ha,b={version:"v2",agent_service_pub_key:yo(l.asPubKey),agent_id:l.agentId,vault_id:l.vaultId,user_pub_key:yo(l.userPubKey),revoked:!1,expires_at:null,metadata:{scopes:A},created_at:G()};return{payload:b,bytes:Xv.encode(JSON.stringify(b))}}async function Ag(l){if(typeof l.signer?.sign!="function")throw new Rt;let{agentId:A,agentServicePubkey:G}=l.agent;if(!G)throw new Error("signAndSubmitAgreement: `agent.agentServicePubkey` is required");let b=aZ(l,"signAndSubmitAgreement"),{bytes:t}=mh({vaultId:l.vault.id,userPubKey:l.vault.userPubKey,asPubKey:G,agentId:A,scopes:b,createdAt:l.clock}),c=await l.signer.sign(t,"data"),B=qb(c),e={payload:De(t),signature:{algorithm:"ed25519",signer:gB(l.vault.userPubKey),value:gB(B)}};return await l.gar.postAgreement(e),{agreementSignature:It(B)}}var xc=class{constructor(A,G,b={}){el(this,"id");el(this,"bucketId");el(this,"walletPubkey");el(this,"gatewayEndpoint");el(this,"region");el(this,"status");el(this,"disconnectedAt");el(this,"displayName");el(this,"registryBucketId");el(this,"_http");el(this,"_scopes");el(this,"_agents");el(this,"_browse");el(this,"memory");el(this,"connections");el(this,"webhooks");el(this,"_access");el(this,"_gar");el(this,"_signer");el(this,"_userPubKey");el(this,"scopes",{list:()=>this._scopes.list(this.id),get:A=>this._scopes.get(this.id,A),create:A=>this._scopes.create(this.id,A),update:(A,G)=>this._scopes.update(this.id,A,G),delete:A=>this._scopes.delete(this.id,A)});el(this,"agents",{connect:async A=>{if(!this._gar)throw new Error("vault.agents.connect requires `garEndpoint` on VaultSDKConfig");if(!this._signer)throw new Error("vault.agents.connect requires a `signer` on VaultSDKConfig");let G=A.agentId.includes(":")?A.agentId.split(":")[0]:"",b=A.agentServicePubkey??G;if(!b)throw new Error(`[vault.agents.connect] cannot derive agentServicePubkey from agentId '${A.agentId}' (expected '<pubkey>:<alias>'); pass agentServicePubkey explicitly`);let t=aZ(A,"vault.agents.connect");A.ceiling!==void 0&&La(A.ceiling);let{agreementSignature:c}=await Ag({signer:this._signer,vault:{id:this.id,userPubKey:this._userPubKey},agent:{agentId:A.agentId,agentServicePubkey:b},scopes:t,gar:this._gar}),B=A.scope!==void 0?{scope:A.scope}:{scopes:A.scopes},e={agentId:A.agentId,...B,settings:A.settings??{},agreementSignature:c,...A.ceiling!==void 0?{ceiling:A.ceiling}:{},...A.bundleCid!==void 0?{bundleCid:A.bundleCid}:{}},d=await this._agents.connect(this.id,e);return new ee(this._http,this.id,d)},list:async()=>(await this._agents.list(this.id)).map(G=>new ee(this._http,this.id,G)),get:async A=>{let G=await this._agents.get(this.id,A);return new ee(this._http,this.id,G)},connections:A=>this._access.list(A),setConnection:(A,G,b)=>this._access.set(A,G,b),removeConnection:(A,G)=>this._access.remove(A,G)});el(this,"jobs",{list:(A={})=>this._browse.listJobs(this.id,A),get:A=>new Ld(this._http,this.id,A)});this.id=G.vaultId,this.bucketId=G.bucketId,this.walletPubkey=G.walletPubkey,this.gatewayEndpoint=G.gatewayEndpoint,this.region=G.region,this.status=G.status,this.disconnectedAt=G.disconnectedAt,this.displayName=G.displayName,this.registryBucketId=G.registryBucketId,this._http=A,this._scopes=new Da(A),this._agents=new WZ(A),this._browse=new Qt(A),this.memory=new Oa(this._http,this.id),this.connections=new Ka(this._http,this.id),this.webhooks=new Pa(this._http,this.id),this._access=new qa(this._http,this.id),this._gar=b.gar,this._signer=b.signer,this._userPubKey=b.signer?gB(qb(b.signer.publicKey)):G.walletPubkey}scope(A){return new Md(this._http,this.id,A)}service(A){return new Td(this._http,this.id,A)}connectors(){return Qu(this._http)}isDisconnected(){return this.status==="disconnected"}};var Vh=class extends Error{constructor(A){super(`Unsupported signature type "${A}": vault-api accepts only "ed25519" or "sr25519". Pass WalletAuthOptions.sigType to override.`),this.name="UnsupportedSignatureTypeError"}};function Gg(l){if(l==="ed25519"||l==="sr25519")return l;throw new Vh(l)}var Od=class{constructor(A,G={}){el(this,"signer");el(this,"opts");this.signer=A,this.opts=G}async authenticate(A){if(typeof this.signer?.sign!="function")throw new Rt;let G=this.opts.sigType??Gg(this.signer.type),b={"X-Public-Key":gB(qb(this.signer.publicKey)),"X-Signature-Type":G},t=A.method.toUpperCase();if(A.hash!==void 0){let{bytes:e}=Qo(t,A.path,A.query,this.opts.clock,A.hash),d=await this.signer.sign(e,"data");return b["X-Signed-Preamble"]=De(e),b["X-Signature"]=It(qb(d)),{headers:b}}if(t==="GET"||t==="HEAD"){let{bytes:e}=Qo(t,A.path,A.query,this.opts.clock),d=await this.signer.sign(e,"data");return b["X-Signed-Preamble"]=De(e),b["X-Signature"]=It(qb(d)),{headers:b}}let{bytes:c}=N2(A.body,this.opts.clock),B=await this.signer.sign(c,"data");return b["Content-Type"]="application/json",b["X-Signature"]=It(qb(B)),{headers:b,body:c}}};var pv=new tt,hZ=class{constructor(A){el(this,"http");this.http=A}async postAgreement(A){await this.http.send("POST","/api/v1/agreements",{body:A,auth:pv})}};var Pd=class extends Error{constructor(A){super(A),this.name="OnboardingRequiredError"}};function vu(l){return{publicKeyHex:`0x${Nu(l.publicKey)}`,keyType:Gg(l.type),async signRawHex(A){let G=await l.sign(A,"data");return Nu(G)}}}function Nu(l){let A="";for(let G=0;G<l.length;G++)A+=l[G].toString(16).padStart(2,"0");return A}async function Hu(l){let A=await l.signRawHex(new Uint8Array(0)),G=A.startsWith("0x")?A.slice(2):A;return{"X-Public-Key":l.publicKeyHex,"X-Signature":G,"X-Signature-Type":l.keyType}}async function Eu(l,A,G=fetch){let b=l.replace(/\/+$/,"")+"/auth/onboarding/status",t=await G(b,{method:"GET",headers:await Hu(A)});if(t.status===404)return null;if(!t.ok)throw new Error(`onboarding status ${t.status}`);return await t.json()}async function Fv(l,A,G=fetch){let b=l.replace(/\/+$/,"")+"/auth/onboarding/bootstrap",t=await G(b,{method:"POST",headers:await Hu(A)});if(t.status!==200&&t.status!==207)throw new Error(`onboarding bootstrap ${t.status}`);return await t.json()}async function Ju(l,A,G=fetch,b){let t=await Eu(l,A,G);if(t===null)return{kind:"skipped",status:null};if(t.gateway_is_proxy)return{kind:"ready",status:t};let c,B=t;if(t.faucet_eligible||t.ddc_seed_eligible){b?.(),c=await Fv(l,A,G);let e=await Eu(l,A,G);e&&(B=e)}return B.gateway_is_proxy?{kind:"ready",status:B}:{kind:"awaiting-proxy",status:B,bootstrap:c}}var yv=new tt,Kd=class{constructor(A){el(this,"http");this.http=A}async delegate(){let A=await this.http.send("GET",fl.delegateInfo(),{auth:yv}),G=A.delegate_pubkey??A.delegatePubkey;if(!G)throw new Error(`vault-api /delegate-info response is missing delegate_pubkey: ${JSON.stringify(A)}`);return{delegatePubkey:G}}};var Yh={PUT:1,GET:2,DELETE:3};function rZ(...l){let A=new Uint8Array(l.reduce((b,t)=>b+t.length,0)),G=0;for(let b of l)A.set(b,G),G+=b.length;return A}function bg(l){let A=BigInt(l);if(A<0n)throw new RangeError(`auth-token: negative varint ${l}`);let G=[];do{let b=Number(A&0x7fn);A>>=7n,A!==0n&&(b|=128),G.push(b)}while(A!==0n);return Uint8Array.from(G)}var fu=(l,A)=>bg(l<<3|A),sZ=(l,A)=>rZ(fu(l,2),bg(A.length),A),uh=(l,A)=>rZ(fu(l,0),bg(A));function Qv(l){let A=[sZ(2,l.subject),uh(3,l.canDelegate?1:0)];return l.bucketId!==void 0&&A.push(uh(4,l.bucketId)),l.operations.length>0&&A.push(sZ(5,rZ(...l.operations.map(G=>bg(G))))),A.push(uh(6,l.expiresAt)),rZ(...A)}var Nv="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Ev(l){let A=[0];for(let b of l){let t=b;for(let c=0;c<A.length;c++)t+=A[c]<<8,A[c]=t%58,t=Math.floor(t/58);for(;t>0;)A.push(t%58),t=Math.floor(t/58)}let G="";for(let b=0;b<l.length&&l[b]===0;b++)G+="1";for(let b=A.length-1;b>=0;b--)G+=Nv[A[b]];return G}async function Ih(l,A){if(l.type!=="ed25519")throw new Error(`auth-token: only ed25519 signers can mint a DDC AuthToken here (signer reports "${l.type}")`);let G=sZ(2,Qv(A)),b=await l.sign(G,"token"),t=rZ(sZ(2,l.publicKey),sZ(3,b));return Ev(rZ(sZ(1,t),G))}var vv=24*60*60*1e3,Rh=365*vv,ku=Rh-60*60*1e3,{GET:wu,PUT:Uu,DELETE:Hv}=Yh,Cu=[wu,Uu,Hv],Su=[wu,Uu],Jv=(1n<<64n)-1n,fv=(1n<<63n)-1n;function xu(l,A,G){let b;if(typeof A=="bigint")b=A;else if(/^[0-9]+$/.test(A))b=BigInt(A);else throw new Error(`${l} must be a decimal chain bucket id, got "${A}"`);if(b<=0n||b>G)throw new Error(`${l} ${b} is out of range: a chain bucket id is 1..${G}`);return b}function xv(l){let A=l.replace(/^0x/i,"");if(!/^[0-9a-fA-F]{64}$/.test(A))throw new Error(`delegatePubkey must be a 32-byte hex key, got "${l}"`);return Te(A)}async function Xh(l){let A=xu("vaultBucketId",l.vaultBucketId,Jv),G=xu("registryBucketId",l.registryBucketId,fv);if(A===G)throw new Error(`vaultBucketId and registryBucketId are the same bucket (${A}): the vault bucket is private because it holds memory and the registry bucket is public because agent code is read anonymously`);let b=xv(l.delegatePubkey),t=(l.now??Date.now)(),c=l.expiresAt===void 0?t+ku:l.expiresAt instanceof Date?l.expiresAt.getTime():l.expiresAt;if(!Number.isSafeInteger(c)||c<=t)throw new Error(`expiresAt must be in the future, got ${new Date(c).toISOString()}`);if(c>t+Rh)throw new Error(`expiresAt ${new Date(c).toISOString()} is more than one year away; vault-api refuses delegations beyond that`);if(l.signer.type!=="ed25519")throw new Error(`delegation tokens need an ed25519 owner wallet (signer reports "${l.signer.type}")`);let B=await Ih(l.signer,{subject:b,canDelegate:!0,bucketId:A,operations:Cu,expiresAt:c}),e=await Ih(l.signer,{subject:b,canDelegate:!0,bucketId:G,operations:Su,expiresAt:c});return{vaultDelegationToken:B,registryDelegationToken:e,expiresAt:new Date(c)}}var TH="https://ddc-s3-gateway.compute.dev.ddcdragon.com/auth/info",DH="https://agent-marketplace.compute.dev.ddcdragon.com",LH=3,OH=[2e3,5e3];function PH(l){return l.status===425||l.status===503&&l.retryable===!0}var qZ=class{constructor(A){el(this,"http");el(this,"marketplaceHttp");el(this,"endpoint");el(this,"chainUrl");el(this,"vaults");el(this,"gar");el(this,"signer");el(this,"s3GatewayAuthInfoUrl");el(this,"fetchFn");el(this,"marketplace");el(this,"health");el(this,"memberships");el(this,"vault",{ensure:async(A={})=>{let G=A.onProgress??(()=>{});if(A.onboard!==!1&&this.signer){let B=vu(this.signer),e=this.gatewayBaseUrl();G({kind:"inspecting-wallet"});let d=await Ju(e,B,this.fetchFn,()=>{G({kind:"funding-wallet"})});if(d.kind==="awaiting-proxy")throw G({kind:"gateway-authorization-required",status:d.status}),new Pd("Onboarding required: the gateway does not yet see this wallet's on-chain proxy authorization. Register it externally via `@cef-ai/account`'s `provisioning.ensure({ signer, chainUrl, gateway })`, wait for it to resolve, then retry `vault.ensure()`.")}let t=A.delegationToken;if(!t){if(!this.signer)throw new Error("vault.ensure() needs either a `delegationToken` or a `signer` configured on VaultSDKConfig (the signer drives the on-chain vault-delegate grant).");let B=A.chainUrl??this.chainUrl;if(!B)throw new Error("vault.ensure(): `chainUrl` is required on the wallet path \u2014 the SDK grants vault-api write delegation by submitting an on-chain NonTransfer proxy (`@cef-ai/account`'s `ensureVaultDelegate`) before claiming the vault. Set `chainUrl` on VaultSDKConfig (or pass it per call) with a Cere node WS URL, or pass `delegationToken` to use the legacy token-bearing claim instead.");G({kind:"authorizing-vault"});let{ensureVaultDelegate:e}=await Promise.resolve().then(()=>(OF(),LF));await e({signer:this.signer,chainUrl:B,vaultApiUrl:this.endpoint,fetchFn:this.fetchFn})}G({kind:"provisioning-vault"});let c=await this.claimVaultWithRetry({name:A.name,label:"vault",...t?{delegation_token:t}:{}},A.sleep);return new xc(this.http,c,{gar:this.gar,signer:this.signer})},current:async()=>{let A=await this.vaults.current();return new xc(this.http,A,{gar:this.gar,signer:this.signer})},byId:async A=>{let G=await this.vaults.byId(A);return new xc(this.http,G,{gar:this.gar,signer:this.signer})},rename:async(A,G)=>{let b=await this.vaults.patch(A,{displayName:G,timestamp:new Date().toISOString()});return new xc(this.http,b,{gar:this.gar,signer:this.signer})},delegations:{put:async(A,G)=>{let b=await this.vaults.putDelegations(A,{vaultDelegationToken:G.vaultDelegationToken,registryDelegationToken:G.registryDelegationToken,timestamp:new Date().toISOString()}),{vaultBucketId:t,registryBucketId:c,delegationsExpireAt:B,...e}=b;return{vault:new xc(this.http,{...e,registryBucketId:c},{gar:this.gar,signer:this.signer}),vaultBucketId:t,registryBucketId:c,delegationsExpireAt:B}},grant:async(A,G)=>{if(!this.signer)throw new Rt;let{delegatePubkey:b}=await new Kd(this.http).delegate(),t=await Xh({signer:this.signer,delegatePubkey:b,vaultBucketId:G.vaultBucketId,registryBucketId:G.registryBucketId,expiresAt:G.expiresAt});return this.vault.delegations.put(A,t)}}});let G=A.auth??(A.signer?new Od(A.signer):void 0);this.endpoint=A.endpoint,this.chainUrl=A.chainUrl,this.http=new Le({url:A.endpoint,auth:G,fetch:A.fetch,timeoutMs:A.timeoutMs}),this.marketplaceHttp=new Le({url:A.marketplaceEndpoint??DH,fetch:A.fetch,timeoutMs:A.timeoutMs}),A.garEndpoint&&(this.gar=new hZ(new Le({url:A.garEndpoint,fetch:A.fetch,timeoutMs:A.timeoutMs}))),this.signer=A.signer,this.s3GatewayAuthInfoUrl=A.s3GatewayAuthInfoUrl??TH,this.fetchFn=A.fetch??fetch.bind(globalThis),this.vaults=new sa(this.http),this.marketplace=new Ma(this.marketplaceHttp),this.health=new Ta(this.http),this.memberships=new ja(this.http,A.signer)}gatewayBaseUrl(){return this.s3GatewayAuthInfoUrl.replace(/\/+$/,"").replace(/\/auth\/info$/,"")}async claimVaultWithRetry(A,G){let b=G??(t=>new Promise(c=>setTimeout(c,t)));for(let t=1;;t++)try{return await this.vaults.claim(A)}catch(c){if(t>=LH||!(c instanceof $G)||!PH(c))throw c;await b(OH[t-1])}}};function PF(){return gu().then(()=>{if(!TA())throw new Error("Unable to initialize @polkadot/util-crypto");return!0}).catch(()=>!1)}function Fi(l){return l instanceof Uint8Array||ArrayBuffer.isView(l)&&l.constructor.name==="Uint8Array"}function KH(l,...A){if(!Fi(l))throw new Error("Uint8Array expected");if(A.length>0&&!A.includes(l.length))throw new Error("Uint8Array expected of length "+A+", got length="+l.length)}function _F(l,A){return Array.isArray(A)?A.length===0?!0:l?A.every(G=>typeof G=="string"):A.every(G=>Number.isSafeInteger(G)):!1}function xn(l,A){if(typeof A!="string")throw new Error(`${l}: string expected`);return!0}function kn(l){if(!Number.isSafeInteger(l))throw new Error(`invalid integer: ${l}`)}function fW(l){if(!Array.isArray(l))throw new Error("array expected")}function xW(l,A){if(!_F(!0,A))throw new Error(`${l}: array of strings expected`)}function $F(l,A){if(!_F(!1,A))throw new Error(`${l}: array of numbers expected`)}function ly(...l){let A=c=>c,G=(c,B)=>e=>c(B(e)),b=l.map(c=>c.encode).reduceRight(G,A),t=l.map(c=>c.decode).reduce(G,A);return{encode:b,decode:t}}function Ay(l){let A=typeof l=="string"?l.split(""):l,G=A.length;xW("alphabet",A);let b=new Map(A.map((t,c)=>[t,c]));return{encode:t=>(fW(t),t.map(c=>{if(!Number.isSafeInteger(c)||c<0||c>=G)throw new Error(`alphabet.encode: digit index outside alphabet "${c}". Allowed: ${l}`);return A[c]})),decode:t=>(fW(t),t.map(c=>{xn("alphabet.decode",c);let B=b.get(c);if(B===void 0)throw new Error(`Unknown letter: "${c}". Allowed: ${l}`);return B}))}}function Gy(l=""){return xn("join",l),{encode:A=>(xW("join.decode",A),A.join(l)),decode:A=>(xn("join.decode",A),A.split(l))}}function qH(l,A="="){return kn(l),xn("padding",A),{encode(G){for(xW("padding.encode",G);G.length*l%8;)G.push(A);return G},decode(G){xW("padding.decode",G);let b=G.length;if(b*l%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;b>0&&G[b-1]===A;b--)if((b-1)*l%8===0)throw new Error("padding: invalid, string has too much padding");return G.slice(0,b)}}}function KF(l,A,G){if(A<2)throw new Error(`convertRadix: invalid from=${A}, base cannot be less than 2`);if(G<2)throw new Error(`convertRadix: invalid to=${G}, base cannot be less than 2`);if(fW(l),!l.length)return[];let b=0,t=[],c=Array.from(l,e=>{if(kn(e),e<0||e>=A)throw new Error(`invalid integer: ${e}`);return e}),B=c.length;for(;;){let e=0,d=!0;for(let Z=b;Z<B;Z++){let a=c[Z],n=A*e,h=n+a;if(!Number.isSafeInteger(h)||n/A!==e||h-a!==n)throw new Error("convertRadix: carry overflow");let W=h/G;e=h%G;let i=Math.floor(W);if(c[Z]=i,!Number.isSafeInteger(i)||i*G+e!==h)throw new Error("convertRadix: carry overflow");if(d)i?d=!1:b=Z;else continue}if(t.push(e),d)break}for(let e=0;e<l.length-1&&l[e]===0;e++)t.push(0);return t.reverse()}var by=(l,A)=>A===0?l:by(A,l%A),kW=(l,A)=>l+(A-by(l,A)),pi=(()=>{let l=[];for(let A=0;A<40;A++)l.push(2**A);return l})();function qF(l,A,G,b){if(fW(l),A<=0||A>32)throw new Error(`convertRadix2: wrong from=${A}`);if(G<=0||G>32)throw new Error(`convertRadix2: wrong to=${G}`);if(kW(A,G)>32)throw new Error(`convertRadix2: carry overflow from=${A} to=${G} carryBits=${kW(A,G)}`);let t=0,c=0,B=pi[A],e=pi[G]-1,d=[];for(let Z of l){if(kn(Z),Z>=B)throw new Error(`convertRadix2: invalid data word=${Z} from=${A}`);if(t=t<<A|Z,c+A>32)throw new Error(`convertRadix2: carry overflow pos=${c} from=${A}`);for(c+=A;c>=G;c-=G)d.push((t>>c-G&e)>>>0);let a=pi[c];if(a===void 0)throw new Error("invalid carry");t&=a-1}if(t=t<<G-c&e,!b&&c>=A)throw new Error("Excess padding");if(!b&&t>0)throw new Error(`Non-zero padding: ${t}`);return b&&c>0&&d.push(t>>>0),d}function _H(l){kn(l);let A=2**8;return{encode:G=>{if(!Fi(G))throw new Error("radix.encode input should be Uint8Array");return KF(Array.from(G),A,l)},decode:G=>($F("radix.decode",G),Uint8Array.from(KF(G,l,A)))}}function $H(l,A=!1){if(kn(l),l<=0||l>32)throw new Error("radix2: bits should be in (0..32]");if(kW(8,l)>32||kW(l,8)>32)throw new Error("radix2: carry overflow");return{encode:G=>{if(!Fi(G))throw new Error("radix2.encode input should be Uint8Array");return qF(Array.from(G),8,l,!A)},decode:G=>($F("radix2.decode",G),Uint8Array.from(qF(G,l,8,A)))}}var l5=typeof Uint8Array.from([]).toBase64=="function"&&typeof Uint8Array.fromBase64=="function",A5=(l,A)=>{xn("base64",l);let G=A?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,b=A?"base64url":"base64";if(l.length>0&&!G.test(l))throw new Error("invalid base64");return Uint8Array.fromBase64(l,{alphabet:b,lastChunkHandling:"strict"})},ty=l5?{encode(l){return KH(l),l.toBase64()},decode(l){return A5(l,!1)}}:ly($H(6),Ay("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),qH(6),Gy(""));var G5=l=>ly(_H(58),Ay(l),Gy("")),cy=G5("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function wW({coder:l,ipfs:A},G){return(b,t)=>(G(b,t),l.decode(A&&t?b.substring(1):b))}function UW({coder:l,ipfs:A}){return(G,b)=>{let t=l.encode(Tl(G));return A&&b?`${A}${t}`:t}}function CW({chars:l,ipfs:A,type:G,withPadding:b}){return(t,c)=>{if(typeof t!="string")throw new Error(`Expected ${G} string input`);if(A&&c&&!t.startsWith(A))throw new Error(`Expected ipfs-compatible ${G} to start with '${A}'`);for(let B=c?1:0,e=t.length;B<e;B++)if(!l.includes(t[B]))if(b&&t[B]==="="){if(B!==e-1){if(t[B+1]!=="=")throw new Error(`Invalid ${G} padding sequence "${t[B]}${t[B+1]}" at index ${B}`)}}else throw new Error(`Invalid ${G} character "${t[B]}" (0x${t.charCodeAt(B).toString(16)}) at index ${B}`);return!0}}var yi={chars:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",coder:cy,ipfs:"z",type:"base58"},By=CW(yi),Qi=wW(yi,By),Ni=UW(yi);var t5=uG("SS58PRE");function SW(l){return Tb(nG(t5,l),512)}function ey(l){let A=l[0]&64?2:1,G=A===1?l[0]:(l[0]&63)<<2|l[1]>>6|(l[1]&63)<<8,b=[34+A,35+A].includes(l.length),t=l.length-(b?2:1),c=SW(l.subarray(0,t));return[(l[0]&128)===0&&![46,47].includes(l[0])&&(b?l[l.length-2]===c[0]&&l[l.length-1]===c[1]:l[l.length-1]===c[0]),t,A,G]}var Zy=[{prefix:0,network:"polkadot",displayName:"Polkadot Relay Chain",symbols:["DOT"],decimals:[10],standardAccount:"*25519",website:"https://polkadot.network"},{prefix:1,network:"BareSr25519",displayName:"Bare 32-bit Schnorr/Ristretto (S/R 25519) public key.",symbols:[],decimals:[],standardAccount:"Sr25519",website:null},{prefix:2,network:"kusama",displayName:"Kusama Relay Chain",symbols:["KSM"],decimals:[12],standardAccount:"*25519",website:"https://kusama.network"},{prefix:3,network:"BareEd25519",displayName:"Bare 32-bit Ed25519 public key.",symbols:[],decimals:[],standardAccount:"Ed25519",website:null},{prefix:4,network:"katalchain",displayName:"Katal Chain",symbols:[],decimals:[],standardAccount:"*25519",website:null},{prefix:5,network:"astar",displayName:"Astar Network",symbols:["ASTR"],decimals:[18],standardAccount:"*25519",website:"https://astar.network"},{prefix:6,network:"bifrost",displayName:"Bifrost",symbols:["BNC"],decimals:[12],standardAccount:"*25519",website:"https://bifrost.finance/"},{prefix:7,network:"edgeware",displayName:"Edgeware",symbols:["EDG"],decimals:[18],standardAccount:"*25519",website:"https://edgewa.re"},{prefix:8,network:"karura",displayName:"Karura",symbols:["KAR"],decimals:[12],standardAccount:"*25519",website:"https://karura.network/"},{prefix:9,network:"reynolds",displayName:"Laminar Reynolds Canary",symbols:["REY"],decimals:[18],standardAccount:"*25519",website:"http://laminar.network/"},{prefix:10,network:"acala",displayName:"Acala",symbols:["ACA"],decimals:[12],standardAccount:"*25519",website:"https://acala.network/"},{prefix:11,network:"laminar",displayName:"Laminar",symbols:["LAMI"],decimals:[18],standardAccount:"*25519",website:"http://laminar.network/"},{prefix:12,network:"polymesh",displayName:"Polymesh",symbols:["POLYX"],decimals:[6],standardAccount:"*25519",website:"https://polymath.network/"},{prefix:13,network:"integritee",displayName:"Integritee",symbols:["TEER"],decimals:[12],standardAccount:"*25519",website:"https://integritee.network"},{prefix:14,network:"totem",displayName:"Totem",symbols:["TOTEM"],decimals:[0],standardAccount:"*25519",website:"https://totemaccounting.com"},{prefix:15,network:"synesthesia",displayName:"Synesthesia",symbols:["SYN"],decimals:[12],standardAccount:"*25519",website:"https://synesthesia.network/"},{prefix:16,network:"kulupu",displayName:"Kulupu",symbols:["KLP"],decimals:[12],standardAccount:"*25519",website:"https://kulupu.network/"},{prefix:17,network:"dark",displayName:"Dark Mainnet",symbols:[],decimals:[],standardAccount:"*25519",website:null},{prefix:18,network:"darwinia",displayName:"Darwinia Network",symbols:["RING"],decimals:[18],standardAccount:"secp256k1",website:"https://darwinia.network"},{prefix:19,network:"watr",displayName:"Watr Protocol",symbols:["WATR"],decimals:[18],standardAccount:"*25519",website:"https://www.watr.org"},{prefix:20,network:"stafi",displayName:"Stafi",symbols:["FIS"],decimals:[12],standardAccount:"*25519",website:"https://stafi.io"},{prefix:21,network:"karmachain",displayName:"Karmacoin",symbols:["KCOIN"],decimals:[6],standardAccount:"*25519",website:"https://karmaco.in"},{prefix:22,network:"dock-pos-mainnet",displayName:"Dock Mainnet",symbols:["DCK"],decimals:[6],standardAccount:"*25519",website:"https://dock.io"},{prefix:23,network:"shift",displayName:"ShiftNrg",symbols:[],decimals:[],standardAccount:"*25519",website:null},{prefix:24,network:"zero",displayName:"ZERO",symbols:["ZERO"],decimals:[18],standardAccount:"*25519",website:"https://zero.io"},{prefix:25,network:"zero-alphaville",displayName:"ZERO Alphaville",symbols:["ZERO"],decimals:[18],standardAccount:"*25519",website:"https://zero.io"},{prefix:26,network:"jupiter",displayName:"Jupiter",symbols:["jDOT"],decimals:[10],standardAccount:"*25519",website:"https://jupiter.patract.io"},{prefix:27,network:"kabocha",displayName:"Kabocha",symbols:["KAB"],decimals:[12],standardAccount:"*25519",website:"https://kabocha.network"},{prefix:28,network:"subsocial",displayName:"Subsocial",symbols:[],decimals:[],standardAccount:"*25519",website:null},{prefix:29,network:"cord",displayName:"CORD Network",symbols:["DHI","WAY"],decimals:[12,12],standardAccount:"*25519",website:"https://cord.network/"},{prefix:30,network:"phala",displayName:"Phala Network",symbols:["PHA"],decimals:[12],standardAccount:"*25519",website:"https://phala.network"},{prefix:31,network:"litentry",displayName:"Litentry Network",symbols:["LIT"],decimals:[12],standardAccount:"*25519",website:"https://litentry.com/"},{prefix:32,network:"robonomics",displayName:"Robonomics",symbols:["XRT"],decimals:[9],standardAccount:"*25519",website:"https://robonomics.network"},{prefix:33,network:"datahighway",displayName:"DataHighway",symbols:[],decimals:[],standardAccount:"*25519",website:null},{prefix:34,network:"ares",displayName:"Ares Protocol",symbols:["ARES"],decimals:[12],standardAccount:"*25519",website:"https://www.aresprotocol.com/"},{prefix:35,network:"vln",displayName:"Valiu Liquidity Network",symbols:["USDv"],decimals:[15],standardAccount:"*25519",website:"https://valiu.com/"},{prefix:36,network:"centrifuge",displayName:"Centrifuge Chain",symbols:["CFG"],decimals:[18],standardAccount:"*25519",website:"https://centrifuge.io/"},{prefix:37,network:"nodle",displayName:"Nodle Chain",symbols:["NODL"],decimals:[11],standardAccount:"*25519",website:"https://nodle.io/"},{prefix:38,network:"kilt",displayName:"KILT Spiritnet",symbols:["KILT"],decimals:[15],standardAccount:"*25519",website:"https://kilt.io/"},{prefix:39,network:"mathchain",displayName:"MathChain mainnet",symbols:["MATH"],decimals:[18],standardAccount:"*25519",website:"https://mathwallet.org"},{prefix:40,network:"mathchain-testnet",displayName:"MathChain testnet",symbols:["MATH"],decimals:[18],standardAccount:"*25519",website:"https://mathwallet.org"},{prefix:41,network:"polimec",displayName:"Polimec Protocol",symbols:["PLMC"],decimals:[10],standardAccount:"*25519",website:"https://www.polimec.org/"},{prefix:42,network:"substrate",displayName:"Substrate",symbols:[],decimals:[],standardAccount:"*25519",website:"https://substrate.io/"},{prefix:43,network:"BareSecp256k1",displayName:"Bare 32-bit ECDSA SECP-256k1 public key.",symbols:[],decimals:[],standardAccount:"secp256k1",website:null},{prefix:44,network:"chainx",displayName:"ChainX",symbols:["PCX"],decimals:[8],standardAccount:"*25519",website:"https://chainx.org/"},{prefix:45,network:"uniarts",displayName:"UniArts Network",symbols:["UART","UINK"],decimals:[12,12],standardAccount:"*25519",website:"https://uniarts.me"},{prefix:46,network:"reserved46",displayName:"This prefix is reserved.",symbols:[],decimals:[],standardAccount:null,website:null},{prefix:47,network:"reserved47",displayName:"This prefix is reserved.",symbols:[],decimals:[],standardAccount:null,website:null},{prefix:48,network:"neatcoin",displayName:"Neatcoin Mainnet",symbols:["NEAT"],decimals:[12],standardAccount:"*25519",website:"https://neatcoin.org"},{prefix:49,network:"picasso",displayName:"Picasso",symbols:["PICA"],decimals:[12],standardAccount:"*25519",website:"https://picasso.composable.finance"},{prefix:50,network:"composable",displayName:"Composable Finance",symbols:["LAYR"],decimals:[12],standardAccount:"*25519",website:"https://composable.finance"},{prefix:51,network:"oak",displayName:"OAK Network",symbols:["OAK","TUR"],decimals:[10,10],standardAccount:"*25519",website:"https://oak.tech"},{prefix:52,network:"KICO",displayName:"KICO",symbols:["KICO"],decimals:[14],standardAccount:"*25519",website:"https://dico.io"},{prefix:53,network:"DICO",displayName:"DICO",symbols:["DICO"],decimals:[14],standardAccount:"*25519",website:"https://dico.io"},{prefix:54,network:"cere",displayName:"Cere Network",symbols:["CERE"],decimals:[10],standardAccount:"*25519",website:"https://cere.network"},{prefix:55,network:"xxnetwork",displayName:"xx network",symbols:["XX"],decimals:[9],standardAccount:"*25519",website:"https://xx.network"},{prefix:56,network:"pendulum",displayName:"Pendulum chain",symbols:["PEN"],decimals:[12],standardAccount:"*25519",website:"https://pendulumchain.org/"},{prefix:57,network:"amplitude",displayName:"Amplitude chain",symbols:["AMPE"],decimals:[12],standardAccount:"*25519",website:"https://pendulumchain.org/"},{prefix:58,network:"eternal-civilization",displayName:"Eternal Civilization",symbols:["ECC"],decimals:[12],standardAccount:"*25519",website:"http://www.ysknfr.cn/"},{prefix:63,network:"hydradx",displayName:"Hydration",symbols:["HDX"],decimals:[12],standardAccount:"*25519",website:"https://hydration.net"},{prefix:65,network:"aventus",displayName:"Aventus Mainnet",symbols:["AVT"],decimals:[18],standardAccount:"*25519",website:"https://aventus.io"},{prefix:66,network:"crust",displayName:"Crust Network",symbols:["CRU"],decimals:[12],standardAccount:"*25519",website:"https://crust.network"},{prefix:67,network:"genshiro",displayName:"Genshiro Network",symbols:["GENS","EQD","LPT0"],decimals:[9,9,9],standardAccount:"*25519",website:"https://genshiro.equilibrium.io"},{prefix:68,network:"equilibrium",displayName:"Equilibrium Network",symbols:["EQ"],decimals:[9],standardAccount:"*25519",website:"https://equilibrium.io"},{prefix:69,network:"sora",displayName:"SORA Network",symbols:["XOR"],decimals:[18],standardAccount:"*25519",website:"https://sora.org"},{prefix:71,network:"p3d",displayName:"3DP network",symbols:["P3D"],decimals:[12],standardAccount:"*25519",website:"https://3dpass.org"},{prefix:72,network:"p3dt",displayName:"3DP test network",symbols:["P3Dt"],decimals:[12],standardAccount:"*25519",website:"https://3dpass.org"},{prefix:73,network:"zeitgeist",displayName:"Zeitgeist",symbols:["ZTG"],decimals:[10],standardAccount:"*25519",website:"https://zeitgeist.pm"},{prefix:77,network:"manta",displayName:"Manta network",symbols:["MANTA"],decimals:[18],standardAccount:"*25519",website:"https://manta.network"},{prefix:78,network:"calamari",displayName:"Calamari: Manta Canary Network",symbols:["KMA"],decimals:[12],standardAccount:"*25519",website:"https://manta.network"},{prefix:81,network:"sora_dot_para",displayName:"SORA Polkadot Parachain",symbols:["XOR"],decimals:[18],standardAccount:"*25519",website:"https://sora.org"},{prefix:88,network:"polkadex",displayName:"Polkadex Mainnet",symbols:["PDEX"],decimals:[12],standardAccount:"*25519",website:"https://polkadex.trade"},{prefix:89,network:"polkadexparachain",displayName:"Polkadex Parachain",symbols:["PDEX"],decimals:[12],standardAccount:"*25519",website:"https://polkadex.trade"},{prefix:90,network:"frequency",displayName:"Frequency",symbols:["FRQCY"],decimals:[8],standardAccount:"*25519",website:"https://www.frequency.xyz"},{prefix:92,network:"anmol",displayName:"Anmol Network",symbols:["ANML"],decimals:[18],standardAccount:"*25519",website:"https://anmol.network/"},{prefix:93,network:"fragnova",displayName:"Fragnova Network",symbols:["NOVA"],decimals:[12],standardAccount:"*25519",website:"https://fragnova.com"},{prefix:98,network:"polkasmith",displayName:"PolkaSmith Canary Network",symbols:["PKS"],decimals:[18],standardAccount:"*25519",website:"https://polkafoundry.com"},{prefix:99,network:"polkafoundry",displayName:"PolkaFoundry Network",symbols:["PKF"],decimals:[18],standardAccount:"*25519",website:"https://polkafoundry.com"},{prefix:100,network:"ibtida",displayName:"Anmol Network Ibtida Canary network",symbols:["IANML"],decimals:[18],standardAccount:"*25519",website:"https://anmol.network/"},{prefix:101,network:"origintrail-parachain",displayName:"OriginTrail Parachain",symbols:["OTP"],decimals:[12],standardAccount:"*25519",website:"https://parachain.origintrail.io/"},{prefix:105,network:"pontem-network",displayName:"Pontem Network",symbols:["PONT"],decimals:[10],standardAccount:"*25519",website:"https://pontem.network"},{prefix:110,network:"heiko",displayName:"Heiko",symbols:["HKO"],decimals:[12],standardAccount:"*25519",website:"https://parallel.fi/"},{prefix:113,network:"integritee-incognito",displayName:"Integritee Incognito",symbols:[],decimals:[],standardAccount:"*25519",website:"https://integritee.network"},{prefix:117,network:"tinker",displayName:"Tinker",symbols:["TNKR"],decimals:[12],standardAccount:"*25519",website:"https://invarch.network"},{prefix:126,network:"joystream",displayName:"Joystream",symbols:["JOY"],decimals:[10],standardAccount:"*25519",website:"https://www.joystream.org"},{prefix:128,network:"clover",displayName:"Clover Finance",symbols:["CLV"],decimals:[18],standardAccount:"*25519",website:"https://clover.finance"},{prefix:129,network:"dorafactory-polkadot",displayName:"Dorafactory Polkadot Network",symbols:["DORA"],decimals:[12],standardAccount:"*25519",website:"https://dorafactory.org"},{prefix:131,network:"litmus",displayName:"Litmus Network",symbols:["LIT"],decimals:[12],standardAccount:"*25519",website:"https://litentry.com/"},{prefix:136,network:"altair",displayName:"Altair",symbols:["AIR"],decimals:[18],standardAccount:"*25519",website:"https://centrifuge.io/"},{prefix:137,network:"vara",displayName:"Vara Network",symbols:["VARA"],decimals:[12],standardAccount:"*25519",website:"https://vara.network/"},{prefix:172,network:"parallel",displayName:"Parallel",symbols:["PARA"],decimals:[12],standardAccount:"*25519",website:"https://parallel.fi/"},{prefix:252,network:"social-network",displayName:"Social Network",symbols:["NET"],decimals:[18],standardAccount:"*25519",website:"https://social.network"},{prefix:255,network:"quartz_mainnet",displayName:"QUARTZ by UNIQUE",symbols:["QTZ"],decimals:[18],standardAccount:"*25519",website:"https://unique.network"},{prefix:268,network:"pioneer_network",displayName:"Pioneer Network by Bit.Country",symbols:["NEER"],decimals:[18],standardAccount:"*25519",website:"https://bit.country"},{prefix:420,network:"sora_kusama_para",displayName:"SORA Kusama Parachain",symbols:["XOR"],decimals:[18],standardAccount:"*25519",website:"https://sora.org"},{prefix:440,network:"allfeat_network",displayName:"Allfeat Network",symbols:["AFT"],decimals:[12],standardAccount:"*25519",website:"https://allfeat.network"},{prefix:666,network:"metaquity_network",displayName:"Metaquity Network",symbols:["MQTY"],decimals:[18],standardAccount:"*25519",website:"https://metaquity.xyz/"},{prefix:777,network:"curio",displayName:"Curio",symbols:["CGT"],decimals:[18],standardAccount:"*25519",website:"https://parachain.capitaldex.exchange/"},{prefix:789,network:"geek",displayName:"GEEK Network",symbols:["GEEK"],decimals:[18],standardAccount:"*25519",website:"https://geek.gl"},{prefix:995,network:"ternoa",displayName:"Ternoa",symbols:["CAPS"],decimals:[18],standardAccount:"*25519",website:"https://www.ternoa.network"},{prefix:1110,network:"efinity",displayName:"Efinity",symbols:["EFI"],decimals:[18],standardAccount:"*25519",website:"https://efinity.io/"},{prefix:1221,network:"peaq",displayName:"Peaq Network",symbols:["PEAQ"],decimals:[18],standardAccount:"Sr25519",website:"https://www.peaq.network/"},{prefix:1222,network:"krest",displayName:"Krest Network",symbols:["KREST"],decimals:[18],standardAccount:"Sr25519",website:"https://www.peaq.network/"},{prefix:1284,network:"moonbeam",displayName:"Moonbeam",symbols:["GLMR"],decimals:[18],standardAccount:"secp256k1",website:"https://moonbeam.network"},{prefix:1285,network:"moonriver",displayName:"Moonriver",symbols:["MOVR"],decimals:[18],standardAccount:"secp256k1",website:"https://moonbeam.network"},{prefix:1328,network:"ajuna",displayName:"Ajuna Network",symbols:["AJUN"],decimals:[12],standardAccount:"*25519",website:"https://ajuna.io"},{prefix:1337,network:"bajun",displayName:"Bajun Network",symbols:["BAJU"],decimals:[12],standardAccount:"*25519",website:"https://ajuna.io"},{prefix:1516,network:"societal",displayName:"Societal",symbols:["SCTL"],decimals:[12],standardAccount:"*25519",website:"https://www.sctl.xyz"},{prefix:1985,network:"seals",displayName:"Seals Network",symbols:["SEAL"],decimals:[9],standardAccount:"*25519",website:"https://seals.app"},{prefix:2007,network:"kapex",displayName:"Kapex",symbols:["KAPEX"],decimals:[12],standardAccount:"*25519",website:"https://totemaccounting.com"},{prefix:2009,network:"cloudwalk_mainnet",displayName:"CloudWalk Network Mainnet",symbols:["CWN"],decimals:[18],standardAccount:"*25519",website:"https://explorer.mainnet.cloudwalk.io"},{prefix:2021,network:"logion",displayName:"logion network",symbols:["LGNT"],decimals:[18],standardAccount:"*25519",website:"https://logion.network"},{prefix:2024,network:"vow-chain",displayName:"Enigmatic Smile",symbols:["VOW"],decimals:[18],standardAccount:"*25519",website:"https://www.vow.foundation/"},{prefix:2032,network:"interlay",displayName:"Interlay",symbols:["INTR"],decimals:[10],standardAccount:"*25519",website:"https://interlay.io/"},{prefix:2092,network:"kintsugi",displayName:"Kintsugi",symbols:["KINT"],decimals:[12],standardAccount:"*25519",website:"https://interlay.io/"},{prefix:2106,network:"bitgreen",displayName:"Bitgreen",symbols:["BBB"],decimals:[18],standardAccount:"*25519",website:"https://bitgreen.org/"},{prefix:2112,network:"chainflip",displayName:"Chainflip",symbols:["FLIP"],decimals:[18],standardAccount:"*25519",website:"https://chainflip.io/"},{prefix:2199,network:"moonsama",displayName:"Moonsama",symbols:["SAMA"],decimals:[18],standardAccount:"secp256k1",website:"https://moonsama.com"},{prefix:2206,network:"ICE",displayName:"ICE Network",symbols:["ICY"],decimals:[18],standardAccount:"*25519",website:"https://icenetwork.io"},{prefix:2207,network:"SNOW",displayName:"SNOW: ICE Canary Network",symbols:["ICZ"],decimals:[18],standardAccount:"*25519",website:"https://icenetwork.io"},{prefix:2254,network:"subspace_testnet",displayName:"Subspace testnet",symbols:["tSSC"],decimals:[18],standardAccount:"*25519",website:"https://subspace.network"},{prefix:3333,network:"peerplays",displayName:"Peerplays",symbols:["PPY"],decimals:[18],standardAccount:"secp256k1",website:"https://www.peerplays.com/"},{prefix:4450,network:"g1",displayName:"\u011E1",symbols:["G1"],decimals:[2],standardAccount:"*25519",website:"https://duniter.org"},{prefix:5234,network:"humanode",displayName:"Humanode Network",symbols:["HMND"],decimals:[18],standardAccount:"*25519",website:"https://humanode.io"},{prefix:5845,network:"tangle",displayName:"Tangle Network",symbols:["TNT"],decimals:[18],standardAccount:"*25519",website:"https://www.tangle.tools/"},{prefix:6094,network:"autonomys",displayName:"Autonomys",symbols:["AI3"],decimals:[18],standardAccount:"*25519",website:"https://autonomys.xyz"},{prefix:7007,network:"tidefi",displayName:"Tidefi",symbols:["TDFY"],decimals:[12],standardAccount:"*25519",website:"https://tidefi.com"},{prefix:7013,network:"gm",displayName:"GM",symbols:["FREN","GM","GN"],decimals:[12,0,0],standardAccount:"*25519",website:"https://gmordie.com"},{prefix:7306,network:"krigan",displayName:"Krigan Network",symbols:["KRGN"],decimals:[9],standardAccount:"*25519",website:"https://krigan.network"},{prefix:7391,network:"unique_mainnet",displayName:"Unique Network",symbols:["UNQ"],decimals:[18],standardAccount:"*25519",website:"https://unique.network"},{prefix:8866,network:"golden_gate",displayName:"Golden Gate",symbols:["GGX"],decimals:[18],standardAccount:"*25519",website:"https://ggxchain.io/"},{prefix:8883,network:"sapphire_mainnet",displayName:"Sapphire by Unique",symbols:["QTZ"],decimals:[18],standardAccount:"*25519",website:"https://unique.network"},{prefix:8886,network:"golden_gate_sydney",displayName:"Golden Gate Sydney",symbols:["GGXT"],decimals:[18],standardAccount:"*25519",website:"https://ggxchain.io/"},{prefix:9072,network:"hashed",displayName:"Hashed Network",symbols:["HASH"],decimals:[18],standardAccount:"*25519",website:"https://hashed.network"},{prefix:9807,network:"dentnet",displayName:"DENTNet",symbols:["DENTX"],decimals:[18],standardAccount:"*25519",website:"https://www.dentnet.io"},{prefix:9935,network:"t3rn",displayName:"t3rn",symbols:["TRN"],decimals:[12],standardAccount:"*25519",website:"https://t3rn.io/"},{prefix:10041,network:"basilisk",displayName:"Basilisk",symbols:["BSX"],decimals:[12],standardAccount:"*25519",website:"https://bsx.fi"},{prefix:11330,network:"cess-testnet",displayName:"CESS Testnet",symbols:["TCESS"],decimals:[18],standardAccount:"*25519",website:"https://cess.cloud"},{prefix:11331,network:"cess",displayName:"CESS",symbols:["CESS"],decimals:[18],standardAccount:"*25519",website:"https://cess.cloud"},{prefix:11486,network:"luhn",displayName:"Luhn Network",symbols:["LUHN"],decimals:[18],standardAccount:"*25519",website:"https://luhn.network"},{prefix:11820,network:"contextfree",displayName:"Automata ContextFree",symbols:["CTX"],decimals:[18],standardAccount:"*25519",website:"https://ata.network"},{prefix:12155,network:"impact",displayName:"Impact Protocol Network",symbols:["BSTY"],decimals:[18],standardAccount:"*25519",website:"https://impactprotocol.network/"},{prefix:12191,network:"nftmart",displayName:"NFTMart",symbols:["NMT"],decimals:[12],standardAccount:"*25519",website:"https://nftmart.io"},{prefix:12850,network:"analog-timechain",displayName:"Analog Timechain",symbols:["ANLOG"],decimals:[12],standardAccount:"*25519",website:"https://analog.one"},{prefix:13116,network:"bittensor",displayName:"Bittensor",symbols:["TAO"],decimals:[9],standardAccount:"*25519",website:"https://bittensor.com"},{prefix:14697,network:"goro",displayName:"GORO Network",symbols:["GORO"],decimals:[9],standardAccount:"*25519",website:"https://goro.network"},{prefix:14998,network:"mosaic-chain",displayName:"Mosaic Chain",symbols:["MOS"],decimals:[18],standardAccount:"*25519",website:"https://mosaicchain.io"},{prefix:29972,network:"mythos",displayName:"Mythos",symbols:["MYTH"],decimals:[18],standardAccount:"secp256k1",website:"https://mythos.foundation"},{prefix:8888,network:"xcavate",displayName:"Xcavate Protocol",symbols:["XCAV"],decimals:[12],standardAccount:"*25519",website:"https://xcavate.io/"}];var Ei={acala:["0xfc41b9bd8ef8fe53d58c7ea67c794c7ec9a73daf05e6d54b14ff6342c99ba64c"],ajuna:["0xe358eb1d11b31255a286c12e44fe6780b7edb171d657905a97e39f71d9c6c3ee"],"aleph-node":["0x70255b4d28de0fc4e1a193d7e175ad1ccef431598211c55538f1018651a0344e"],astar:["0x9eb76c5184c4ab8679d2d5d819fdf90b9c001403e9e17da2e14b6d8aec4029c6"],basilisk:["0xa85cfb9b9fd4d622a5b28289a02347af987d8f73fa3108450e2b4a11c1ce5755"],bifrost:["0x262e1b2ad728475fd6fe88e62d34c200abe6fd693931ddad144059b1eb884e5b"],"bifrost-kusama":["0x9f28c6a68e0fc9646eff64935684f6eeeece527e37bbe1f213d22caa1d9d6bed"],bittensor:["0x2f0555cc76fc2840a25a6ea3b9637146806f1f44b090c175ffde2a7e5ab36c03"],centrifuge:["0xb3db41421702df9a7fcac62b53ffeac85f7853cc4e689e0b93aeb3db18c09d82","0x67dddf2673b69e5f875f6f25277495834398eafd67f492e09f3f3345e003d1b5"],cere:["0x81443836a9a24caaa23f1241897d1235717535711d1d3fe24eae4fdc942c092c"],composable:["0xdaab8df776eb52ec604a5df5d388bb62a050a0aaec4556a64265b9d42755552d"],creditcoin3:["0x4436a7d64e363df85e065a894721002a86643283f9707338bf195d360ba2ee71","0xfc4ec97a1c1f119c4353aecb4a17c7c0cf7b40d5d660143d8bad9117e9866572","0xfc9df99a665f964aed6649f275055e54df5e3420489538ed31d7788f53d11ef6"],darwinia:["0xe71578b37a7c799b0ab4ee87ffa6f059a6b98f71f06fb8c84a8d88013a548ad6"],dentnet:["0x0313f6a011d128d22f996703cbab05162e2fdc9e031493314fe6db79979c5ca7"],"dock-mainnet":["0x6bfe24dca2a3be10f22212678ac13a6446ec764103c0f3471c71609eac384aae","0xf73467c6544aa68df2ee546b135f955c46b90fa627e9b5d7935f41061bb8a5a9"],edgeware:["0x742a2ca70c2fda6cee4f8df98d64c4c670a052d9568058982dad9d5a7a135c5b"],encointer:["0x7dd99936c1e9e6d1ce7d90eb6f33bea8393b4bf87677d675aa63c9cb3e8c5b5b"],enjin:["0xd8761d3c88f26dc12875c00d3165f7d67243d56fc85b4cf19937601a7916e5a9"],equilibrium:["0x6f1a800de3daff7f5e037ddf66ab22ce03ab91874debeddb1086f5f7dbd48925"],frequency:["0x4a587bf17a404e3572747add7aab7bbe56e805a5479c6c436f07f36fcc8d3ae1"],genshiro:["0x9b8cefc0eb5c568b527998bdd76c184e2b76ae561be76e4667072230217ea243"],hydradx:["0xafdc188f45c71dacbaa0b62e16a91f726c7b8699a9748cdf715459de6b7f366d","0xd2a620c27ec5cbc5621ff9a522689895074f7cca0d08e7134a7804e1a3ba86fc","0x10af6e84234477d84dc572bac0789813b254aa490767ed06fb9591191d1073f9","0x3d75507dd46301767e601265791da1d9cb47b6ebc94e87347b635e5bf58bd047","0x0ed32bfcab4a83517fac88f2aa7cbc2f88d3ab93be9a12b6188a036bf8a943c2"],integritee:["0xcdedc8eadbfa209d3f207bba541e57c3c58a667b05a2e1d1e86353c9000758da","0xe13e7af377c64e83f95e0d70d5e5c3c01d697a84538776c5b9bbe0e7d7b6034c"],"interlay-parachain":["0xbf88efe70e9e0e916416e8bed61f2b45717f517d7f3523e33c7b001e5ffcbc72"],karura:["0xbaf5aabe40646d11f0ee8abbdc64f4a4b7674925cba08e4a05ff9ebed6e2126b"],khala:["0xd43540ba6d3eb4897c28a77d48cb5b729fea37603cbbfc7a86a73b72adb3be8d"],kulupu:["0xf7a99d3cb92853d00d5275c971c132c074636256583fee53b3bbe60d7b8769ba"],kusama:["0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe","0xe3777fa922cafbff200cadeaea1a76bd7898ad5b89f7848999058b50e715f636","0x3fd7b9eb6a00376e5be61f01abb429ffb0b104be05eaff4d458da48fcd425baf"],liberland:["0x6bd89e052d67a45bb60a9a23e8581053d5e0d619f15cb9865946937e690c42d6"],matrixchain:["0x3af4ff48ec76d2efc8476730f423ac07e25ad48f5f4c9dc39c778b164d808615"],mythos:["0xf6ee56e9c5277df5b4ce6ae9983ee88f3cbed27d31beeb98f9f84f997a1ab0b9"],nodle:["0x97da7ede98d7bad4e36b4d734b6055425a3be036da2a332ea5a7037656427a21"],origintrail:["0xe7e0962324a3b86c83404dbea483f25fb5dab4c224791c81b756cfc948006174"],p3d:["0x6c5894837ad89b6d92b114a2fb3eafa8fe3d26a54848e3447015442cd6ef4e66"],parallel:["0xe61a41c53f5dcd0beb09df93b34402aada44cb05117b71059cce40a2723a4e97"],peaq:["0xd2a5d385932d1f650dae03ef8e2748983779ee342c614f80854d32b8cd8fa48c"],pendulum:["0x5d3c298622d5634ed019bf61ea4b71655030015bde9beb0d6a24743714462c86"],phala:["0x1bb969d85965e4bb5a651abbedf21a54b6b31a21f66b5401cc3f1e286268d736"],picasso:["0x6811a339673c9daa897944dcdac99c6e2939cc88245ed21951a0a3c9a2be75bc","0xe8e7f0f4c4f5a00720b4821dbfddefea7490bcf0b19009961cc46957984e2c1c"],polimec:["0x7eb9354488318e7549c722669dcbdcdc526f1fef1420e7944667212f3601fdbd"],polkadex:["0x3920bcb4960a1eef5580cd5367ff3f430eef052774f78468852f7b9cb39f8a3c"],polkadot:["0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3"],polymesh:["0x6fbd74e5e1d0a61d52ccfe9d4adaed16dd3a7caa37c6bc4d0c2fa12e8b2f4063"],quartz:["0xcd4d732201ebe5d6b014edda071c4203e16867305332301dc8d092044b28e554"],rococo:["0x6408de7737c59c238890533af25896a2c20608d8b380bb01029acb392781063e","0xaaf2cd1b74b5f726895921259421b534124726263982522174147046b8827897","0x037f5f3c8e67b314062025fc886fcd6238ea25a4a9b45dce8d246815c9ebe770","0xc196f81260cf1686172b47a79cf002120735d7cb0eb1474e8adce56618456fff","0xf6e9983c37baf68846fedafe21e56718790e39fb1c582abc408b81bc7b208f9a","0x5fce687da39305dfe682b117f0820b319348e8bb37eb16cf34acbf6a202de9d9","0xe7c3d5edde7db964317cd9b51a3a059d7cd99f81bdbce14990047354334c9779","0x1611e1dbf0405379b861e2e27daa90f480b2e6d3682414a80835a52e8cb8a215","0x343442f12fa715489a8714e79a7b264ea88c0d5b8c66b684a7788a516032f6b9","0x78bcd530c6b3a068bc17473cf5d2aff9c287102bed9af3ae3c41c33b9d6c6147","0x47381ee0697153d64404fc578392c8fd5cba9073391908f46c888498415647bd","0x19c0e4fa8ab75f5ac7865e0b8f74ff91eb9a100d336f423cd013a8befba40299"],sora:["0x7e4e32d0feafd4f9c9414b0be86373f9a1efa904809b683453a9af6856d38ad5"],stafi:["0x290a4149f09ea0e402c74c1c7e96ae4239588577fe78932f94f5404c68243d80"],statemine:["0x48239ef607d7928874027a43a67689209727dfb3d3dc5e5b03a39bdc2eda771a"],statemint:["0x68d56f15f85d3136970ec16946040bc1752654e906147f7e43e9d539d7c3de2f"],subsocial:["0x0bd72c1c305172e1275278aaeb3f161e02eccb7a819e63f62d47bd53a28189f8"],ternoa:["0x6859c81ca95ef624c9dfe4dc6e3381c33e5d6509e35e147092bfbc780f777c4e"],unique:["0x84322d9cddbf35088f1e54e9a85c967a41a56a4f43445768125e61af166c7d31"],vara:["0xfe1b4c55fd4d668101126434206571a7838a8b6b93a6d1b95d607e78e6c53763"],vtb:["0x286bc8414c7000ce1d6ee6a834e29a54c1784814b76243eb77ed0b2c5573c60f","0x7483b89572fb2bd687c7b9a93b242d0b237f9aba463aba07ec24503931038aaa"],westend:["0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e"],xxnetwork:["0x50dd5d206917bf10502c68fb4d18a59fc8aa31586f4e8856b493e43544aa82aa"],zeitgeist:["0x1bf2a2ecb4a868de66ea8610f2ce7c8c43706561b6476031315f6640fe38e060"]};var vi={centrifuge:"polkadot",kusama:"polkadot",polkadot:"polkadot",sora:"polkadot",statemine:"polkadot",statemint:"polkadot",westmint:"polkadot"};var Hi={acala:787,ajuna:354,"aleph-node":643,astar:810,bifrost:788,"bifrost-kusama":788,bittensor:354,centrifuge:747,composable:354,creditcoin3:354,darwinia:354,dentnet:734,"dock-mainnet":594,edgeware:523,encointer:434,enjin:1155,equilibrium:99999997,frequency:2091,genshiro:99999996,hydradx:354,integritee:2015,"interlay-parachain":354,karura:686,khala:434,kusama:434,liberland:767,matrixchain:1155,mythos:60,nodle:1003,origintrail:354,parallel:354,peaq:3338,pendulum:354,phala:354,picasso:434,polimec:3344,polkadex:799,polkadot:354,polymesh:595,quartz:631,sora:617,stafi:907,statemine:434,statemint:354,ternoa:995,unique:661,vara:4976,vtb:694,xxnetwork:1955,zeitgeist:354};var Ji={"":!0,"cess-testnet":!0,"dock-testnet":!0,jupiter:!0,"mathchain-testnet":!0,p3dt:!0,subspace_testnet:!0,"zero-alphaville":!0};var dy=[0,2,42],c5=["testnet"];function B5(l){let A=l.network||"",G=A.replace(/_/g,"-").split("-"),b=l;return b.slip44=Hi[A],b.hasLedgerSupport=!!b.slip44,b.genesisHash=Ei[A]||[],b.icon=vi[A]||"substrate",b.isTestnet=!!Ji[A]||c5.includes(G[G.length-1]),b.isIgnored=b.isTestnet||!(l.standardAccount&&l.decimals?.length&&l.symbols?.length)&&l.prefix!==42,b}function e5({genesisHash:l,prefix:A}){return!!l.length||A===42}function Z5(l){return!l.isIgnored&&!!l.network}function d5(l,A){let G=dy.includes(l.prefix),b=dy.includes(A.prefix);return G===b?G?0:l.displayName.localeCompare(A.displayName):G?-1:1}var ny=Zy.map(B5),zW=ny.filter(Z5).sort(d5),n5=zW.filter(e5);var _Z={allowedDecodedLengths:[1,2,4,8,32,33],allowedEncodedLengths:[3,4,6,10,35,36,37,38],allowedPrefix:zW.map(({prefix:l})=>l),prefix:42};function Pt(l,A,G=-1){if(!l)throw new Error("Invalid empty address passed");if(Jb(l)||ub(l))return Tl(l);try{let b=Qi(l);if(!_Z.allowedEncodedLengths.includes(b.length))throw new Error("Invalid decoded address length");let[t,c,B,e]=ey(b);if(!t&&!A)throw new Error("Invalid decoded address checksum");if(G!==-1&&G!==e)throw new Error(`Expected ss58Format ${G}, received ${e}`);return b.slice(B,c)}catch(b){throw new Error(`Decoding ${l}: ${b.message}`)}}var fi={isLe:!1},jW={isLe:!0};var ay={bitLength:32,isLe:!1},MW={bitLength:32,isLe:!0},$c={bitLength:256,isLe:!1},gy={bitLength:256,isLe:!0};var a5=/^\d+$/,g5=32,$Z,Fe,xi=class xi{constructor(){EG(this,$Z,new Uint8Array(32));EG(this,Fe,!1)}static from(A){let G=new xi,[b,t]=A.startsWith("/")?[A.substring(1),!0]:[A,!1];return G.soft(a5.test(b)?new FA.default(b,10):b),t?G.harden():G}get chainCode(){return GA(this,$Z)}get isHard(){return GA(this,Fe)}get isSoft(){return!GA(this,Fe)}hard(A){return this.soft(A).harden()}harden(){return bG(this,Fe,!0),this}soft(A){return Gh(A)||Ed(A)||xd(A)?this.soft(wG(A,gy)):ub(A)?this.soft(Hb(A)):Ah(A)?this.soft(be(uG(A))):A.length>g5?this.soft(Tb(A)):(GA(this,$Z).fill(0),GA(this,$Z).set(A,0),this)}soften(){return bG(this,Fe,!1),this}};$Z=new WeakMap,Fe=new WeakMap;var TW=xi;var W5=/\/(\/?)([^/]+)/g;function wn(l){let A=l.match(W5),G=[],b="";if(A){b=A.join("");for(let t of A)G.push(TW.from(t.substring(1)))}if(b!==l)throw new Error(`Re-constructed path "${b}" does not match input`);return{parts:A,path:G}}var o5=/^((0x[a-fA-F0-9]+|[\p{L}\d]+(?: [\p{L}\d]+)*))((\/\/?[^/]+)*)(\/\/\/(.*))?$/u;function ki(l){let G=l.normalize("NFC").match(o5);if(G===null)throw new Error("Unable to match provided value to a secret URI");let[,b,,t,,,c]=G,{path:B}=wn(t);return{derivePath:t,password:c,path:B,phrase:b}}var h5=be(uG("Secp256k1HDKD"));function Wy(l,A){if(!Jb(A)||A.length!==32)throw new Error("Invalid chainCode passed to derive");return Tb(nG(h5,l,A),256)}var s5=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]),JB=new Uint32Array(64),DW=class extends Fd{constructor(A=32){super(64,A,8,!1),this.A=vc[0]|0,this.B=vc[1]|0,this.C=vc[2]|0,this.D=vc[3]|0,this.E=vc[4]|0,this.F=vc[5]|0,this.G=vc[6]|0,this.H=vc[7]|0}get(){let{A,B:G,C:b,D:t,E:c,F:B,G:e,H:d}=this;return[A,G,b,t,c,B,e,d]}set(A,G,b,t,c,B,e,d){this.A=A|0,this.B=G|0,this.C=b|0,this.D=t|0,this.E=c|0,this.F=B|0,this.G=e|0,this.H=d|0}process(A,G){for(let n=0;n<16;n++,G+=4)JB[n]=A.getUint32(G,!1);for(let n=16;n<64;n++){let h=JB[n-15],W=JB[n-2],i=wt(h,7)^wt(h,18)^h>>>3,Y=wt(W,17)^wt(W,19)^W>>>10;JB[n]=Y+JB[n-7]+i+JB[n-16]|0}let{A:b,B:t,C:c,D:B,E:e,F:d,G:Z,H:a}=this;for(let n=0;n<64;n++){let h=wt(e,6)^wt(e,11)^wt(e,25),W=a+h+_2(e,d,Z)+s5[n]+JB[n]|0,Y=(wt(b,2)^wt(b,13)^wt(b,22))+$2(b,t,c)|0;a=Z,Z=d,d=e,e=B+W|0,B=c,c=t,t=b,b=W+Y|0}b=b+this.A|0,t=t+this.B|0,c=c+this.C|0,B=B+this.D|0,e=e+this.E|0,d=d+this.F|0,Z=Z+this.G|0,a=a+this.H|0,this.set(b,t,c,B,e,d,Z,a)}roundClean(){TG(JB)}destroy(){this.set(0,0,0,0,0,0,0,0),TG(this.buffer)}};var oy=Ya(["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(l=>BigInt(l))),r5=oy[0],i5=oy[1],fB=new Uint32Array(80),xB=new Uint32Array(80),LW=class extends Fd{constructor(A=64){super(128,A,16,!1),this.Ah=Vb[0]|0,this.Al=Vb[1]|0,this.Bh=Vb[2]|0,this.Bl=Vb[3]|0,this.Ch=Vb[4]|0,this.Cl=Vb[5]|0,this.Dh=Vb[6]|0,this.Dl=Vb[7]|0,this.Eh=Vb[8]|0,this.El=Vb[9]|0,this.Fh=Vb[10]|0,this.Fl=Vb[11]|0,this.Gh=Vb[12]|0,this.Gl=Vb[13]|0,this.Hh=Vb[14]|0,this.Hl=Vb[15]|0}get(){let{Ah:A,Al:G,Bh:b,Bl:t,Ch:c,Cl:B,Dh:e,Dl:d,Eh:Z,El:a,Fh:n,Fl:h,Gh:W,Gl:i,Hh:Y,Hl:R}=this;return[A,G,b,t,c,B,e,d,Z,a,n,h,W,i,Y,R]}set(A,G,b,t,c,B,e,d,Z,a,n,h,W,i,Y,R){this.Ah=A|0,this.Al=G|0,this.Bh=b|0,this.Bl=t|0,this.Ch=c|0,this.Cl=B|0,this.Dh=e|0,this.Dl=d|0,this.Eh=Z|0,this.El=a|0,this.Fh=n|0,this.Fl=h|0,this.Gh=W|0,this.Gl=i|0,this.Hh=Y|0,this.Hl=R|0}process(A,G){for(let I=0;I<16;I++,G+=4)fB[I]=A.getUint32(G),xB[I]=A.getUint32(G+=4);for(let I=16;I<80;I++){let y=fB[I-15]|0,x=xB[I-15]|0,w=Bc(y,x,1)^Bc(y,x,8)^jo(y,x,7),H=ec(y,x,1)^ec(y,x,8)^Mo(y,x,7),j=fB[I-2]|0,C=xB[I-2]|0,D=Bc(j,C,19)^Ae(j,C,61)^jo(j,C,6),$=ec(j,C,19)^Ge(j,C,61)^Mo(j,C,6),K=eV(H,$,xB[I-7],xB[I-16]),Q=ZV(K,w,D,fB[I-7],fB[I-16]);fB[I]=Q|0,xB[I]=K|0}let{Ah:b,Al:t,Bh:c,Bl:B,Ch:e,Cl:d,Dh:Z,Dl:a,Eh:n,El:h,Fh:W,Fl:i,Gh:Y,Gl:R,Hh:V,Hl:m}=this;for(let I=0;I<80;I++){let y=Bc(n,h,14)^Bc(n,h,18)^Ae(n,h,41),x=ec(n,h,14)^ec(n,h,18)^Ge(n,h,41),w=n&W^~n&Y,H=h&i^~h&R,j=dV(m,x,H,i5[I],xB[I]),C=nV(j,V,y,w,r5[I],fB[I]),D=j|0,$=Bc(b,t,28)^Ae(b,t,34)^Ae(b,t,39),K=ec(b,t,28)^Ge(b,t,34)^Ge(b,t,39),Q=b&c^b&e^c&e,r=t&B^t&d^B&d;V=Y|0,m=R|0,Y=W|0,R=i|0,W=n|0,i=h|0,{h:n,l:h}=dt(Z|0,a|0,C|0,D|0),Z=e|0,a=d|0,e=c|0,d=B|0,c=b|0,B=t|0;let F=yd(D,K,r);b=Qd(F,C,$,Q),t=F|0}({h:b,l:t}=dt(this.Ah|0,this.Al|0,b|0,t|0)),{h:c,l:B}=dt(this.Bh|0,this.Bl|0,c|0,B|0),{h:e,l:d}=dt(this.Ch|0,this.Cl|0,e|0,d|0),{h:Z,l:a}=dt(this.Dh|0,this.Dl|0,Z|0,a|0),{h:n,l:h}=dt(this.Eh|0,this.El|0,n|0,h|0),{h:W,l:i}=dt(this.Fh|0,this.Fl|0,W|0,i|0),{h:Y,l:R}=dt(this.Gh|0,this.Gl|0,Y|0,R|0),{h:V,l:m}=dt(this.Hh|0,this.Hl|0,V|0,m|0),this.set(b,t,c,B,e,d,Z,a,n,h,W,i,Y,R,V,m)}roundClean(){TG(fB,xB)}destroy(){TG(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var ye=pd(()=>new DW);var OW=pd(()=>new LW);var PW=class extends tc{constructor(A,G){super(),this.finished=!1,this.destroyed=!1,Ke(A);let b=Zt(G);if(this.iHash=A.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;let t=this.blockLen,c=new Uint8Array(t);c.set(b.length>t?A.create().update(b).digest():b);for(let B=0;B<c.length;B++)c[B]^=54;this.iHash.update(c),this.oHash=A.create();for(let B=0;B<c.length;B++)c[B]^=106;this.oHash.update(c),TG(c)}update(A){return pt(this),this.iHash.update(A),this}digestInto(A){pt(this),kG(A,this.outputLen),this.finished=!0,this.iHash.digestInto(A),this.oHash.update(A),this.oHash.digestInto(A),this.destroy()}digest(){let A=new Uint8Array(this.oHash.outputLen);return this.digestInto(A),A}_cloneInto(A){A||(A=Object.create(Object.getPrototypeOf(this),{}));let{oHash:G,iHash:b,finished:t,destroyed:c,blockLen:B,outputLen:e}=this;return A=A,A.finished=t,A.destroyed=c,A.blockLen=B,A.outputLen=e,A.oHash=G._cloneInto(A.oHash),A.iHash=b._cloneInto(A.iHash),A}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Qe=(l,A,G)=>new PW(l,A).update(G).digest();Qe.create=(l,A)=>new PW(l,A);var Ci=BigInt(0),Ui=BigInt(1);function lB(l,A=""){if(typeof l!="boolean"){let G=A&&`"${A}"`;throw new Error(G+"expected boolean, got type="+typeof l)}return l}function Vt(l,A,G=""){let b=kt(l),t=l?.length,c=A!==void 0;if(!b||c&&t!==A){let B=G&&`"${G}" `,e=c?` of length ${A}`:"",d=b?`length=${t}`:`type=${typeof l}`;throw new Error(B+"expected Uint8Array"+e+", got "+d)}return l}function ld(l){let A=l.toString(16);return A.length&1?"0"+A:A}function Si(l){if(typeof l!="string")throw new Error("hex string expected, got "+typeof l);return l===""?Ci:BigInt("0x"+l)}function Ne(l){return Si(et(l))}function Kt(l){return kG(l),Si(et(Uint8Array.from(l).reverse()))}function Un(l,A){return WB(l.toString(16).padStart(A*2,"0"))}function Cn(l,A){return Un(l,A).reverse()}function ZG(l,A,G){let b;if(typeof A=="string")try{b=WB(A)}catch(c){throw new Error(l+" must be hex string or Uint8Array, cause: "+c)}else if(kt(A))b=Uint8Array.from(A);else throw new Error(l+" must be hex string or Uint8Array");let t=b.length;if(typeof G=="number"&&t!==G)throw new Error(l+" of length "+G+" expected, got "+t);return b}function zi(l,A){if(l.length!==A.length)return!1;let G=0;for(let b=0;b<l.length;b++)G|=l[b]^A[b];return G===0}function KW(l){return Uint8Array.from(l)}var wi=l=>typeof l=="bigint"&&Ci<=l;function ji(l,A,G){return wi(l)&&wi(A)&&wi(G)&&A<=l&&l<G}function Ee(l,A,G,b){if(!ji(A,G,b))throw new Error("expected valid "+l+": "+G+" <= n < "+b+", got "+A)}function Sn(l){let A;for(A=0;l>Ci;l>>=Ui,A+=1);return A}var Xc=l=>(Ui<<BigInt(l))-Ui;function Mi(l,A,G){if(typeof l!="number"||l<2)throw new Error("hashLen must be a number");if(typeof A!="number"||A<2)throw new Error("qByteLen must be a number");if(typeof G!="function")throw new Error("hmacFn must be a function");let b=W=>new Uint8Array(W),t=W=>Uint8Array.of(W),c=b(l),B=b(l),e=0,d=()=>{c.fill(1),B.fill(0),e=0},Z=(...W)=>G(B,c,...W),a=(W=b(0))=>{B=Z(t(0),W),c=Z(),W.length!==0&&(B=Z(t(1),W),c=Z())},n=()=>{if(e++>=1e3)throw new Error("drbg: tried 1000 values");let W=0,i=[];for(;W<A;){c=Z();let Y=c.slice();i.push(Y),W+=c.length}return VG(...i)};return(W,i)=>{d(),a(W);let Y;for(;!(Y=i(n()));)a();return d(),Y}}function kB(l,A,G={}){if(!l||typeof l!="object")throw new Error("expected valid options object");function b(t,c,B){let e=l[t];if(B&&e===void 0)return;let d=typeof e;if(d!==c||e===null)throw new Error(`param "${t}" is invalid: expected ${c}, got ${d}`)}Object.entries(A).forEach(([t,c])=>b(t,c,!1)),Object.entries(G).forEach(([t,c])=>b(t,c,!0))}var qW=()=>{throw new Error("not implemented")};function ve(l){let A=new WeakMap;return(G,...b)=>{let t=A.get(G);if(t!==void 0)return t;let c=l(G,...b);return A.set(G,c),c}}var Lb=BigInt(0),hb=BigInt(1),He=BigInt(2),ry=BigInt(3),iy=BigInt(4),my=BigInt(5),u5=BigInt(7),Vy=BigInt(8),Y5=BigInt(9),uy=BigInt(16);function IG(l,A){let G=l%A;return G>=Lb?G:A+G}function RG(l,A,G){let b=l;for(;A-- >Lb;)b*=b,b%=G;return b}function hy(l,A){if(l===Lb)throw new Error("invert: expected non-zero number");if(A<=Lb)throw new Error("invert: expected positive modulus, got "+A);let G=IG(l,A),b=A,t=Lb,c=hb,B=hb,e=Lb;for(;G!==Lb;){let Z=b/G,a=b%G,n=t-B*Z,h=c-e*Z;b=G,G=a,t=B,c=e,B=n,e=h}if(b!==hb)throw new Error("invert: does not exist");return IG(t,A)}function Ti(l,A,G){if(!l.eql(l.sqr(A),G))throw new Error("Cannot find square root")}function Yy(l,A){let G=(l.ORDER+hb)/iy,b=l.pow(A,G);return Ti(l,b,A),b}function I5(l,A){let G=(l.ORDER-my)/Vy,b=l.mul(A,He),t=l.pow(b,G),c=l.mul(A,t),B=l.mul(l.mul(c,He),t),e=l.mul(c,l.sub(B,l.ONE));return Ti(l,e,A),e}function R5(l){let A=ut(l),G=Iy(l),b=G(A,A.neg(A.ONE)),t=G(A,b),c=G(A,A.neg(b)),B=(l+u5)/uy;return(e,d)=>{let Z=e.pow(d,B),a=e.mul(Z,b),n=e.mul(Z,t),h=e.mul(Z,c),W=e.eql(e.sqr(a),d),i=e.eql(e.sqr(n),d);Z=e.cmov(Z,a,W),a=e.cmov(h,n,i);let Y=e.eql(e.sqr(a),d),R=e.cmov(Z,a,Y);return Ti(e,R,d),R}}function Iy(l){if(l<ry)throw new Error("sqrt is not defined for small field");let A=l-hb,G=0;for(;A%He===Lb;)A/=He,G++;let b=He,t=ut(l);for(;sy(t,b)===1;)if(b++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(G===1)return Yy;let c=t.pow(b,A),B=(A+hb)/He;return function(d,Z){if(d.is0(Z))return Z;if(sy(d,Z)!==1)throw new Error("Cannot find square root");let a=G,n=d.mul(d.ONE,c),h=d.pow(Z,A),W=d.pow(Z,B);for(;!d.eql(h,d.ONE);){if(d.is0(h))return d.ZERO;let i=1,Y=d.sqr(h);for(;!d.eql(Y,d.ONE);)if(i++,Y=d.sqr(Y),i===a)throw new Error("Cannot find square root");let R=hb<<BigInt(a-i-1),V=d.pow(n,R);a=i,n=d.sqr(V),h=d.mul(h,n),W=d.mul(W,V)}return W}}function X5(l){return l%iy===ry?Yy:l%Vy===my?I5:l%uy===Y5?R5(l):Iy(l)}var AB=(l,A)=>(IG(l,A)&hb)===hb,p5=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Di(l){let A={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},G=p5.reduce((b,t)=>(b[t]="function",b),A);return kB(l,G),l}function F5(l,A,G){if(G<Lb)throw new Error("invalid exponent, negatives unsupported");if(G===Lb)return l.ONE;if(G===hb)return A;let b=l.ONE,t=A;for(;G>Lb;)G&hb&&(b=l.mul(b,t)),t=l.sqr(t),G>>=hb;return b}function zn(l,A,G=!1){let b=new Array(A.length).fill(G?l.ZERO:void 0),t=A.reduce((B,e,d)=>l.is0(e)?B:(b[d]=B,l.mul(B,e)),l.ONE),c=l.inv(t);return A.reduceRight((B,e,d)=>l.is0(e)?B:(b[d]=l.mul(B,b[d]),l.mul(B,e)),c),b}function sy(l,A){let G=(l.ORDER-hb)/He,b=l.pow(A,G),t=l.eql(b,l.ONE),c=l.eql(b,l.ZERO),B=l.eql(b,l.neg(l.ONE));if(!t&&!c&&!B)throw new Error("invalid Legendre symbol result");return t?1:c?0:-1}function _W(l,A){A!==void 0&&mG(A);let G=A!==void 0?A:l.toString(2).length,b=Math.ceil(G/8);return{nBitLength:G,nByteLength:b}}function ut(l,A,G=!1,b={}){if(l<=Lb)throw new Error("invalid field: expected ORDER > 0, got "+l);let t,c,B=!1,e;if(typeof A=="object"&&A!=null){if(b.sqrt||G)throw new Error("cannot specify opts in two arguments");let h=A;h.BITS&&(t=h.BITS),h.sqrt&&(c=h.sqrt),typeof h.isLE=="boolean"&&(G=h.isLE),typeof h.modFromBytes=="boolean"&&(B=h.modFromBytes),e=h.allowedLengths}else typeof A=="number"&&(t=A),b.sqrt&&(c=b.sqrt);let{nBitLength:d,nByteLength:Z}=_W(l,t);if(Z>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let a,n=Object.freeze({ORDER:l,isLE:G,BITS:d,BYTES:Z,MASK:Xc(d),ZERO:Lb,ONE:hb,allowedLengths:e,create:h=>IG(h,l),isValid:h=>{if(typeof h!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof h);return Lb<=h&&h<l},is0:h=>h===Lb,isValidNot0:h=>!n.is0(h)&&n.isValid(h),isOdd:h=>(h&hb)===hb,neg:h=>IG(-h,l),eql:(h,W)=>h===W,sqr:h=>IG(h*h,l),add:(h,W)=>IG(h+W,l),sub:(h,W)=>IG(h-W,l),mul:(h,W)=>IG(h*W,l),pow:(h,W)=>F5(n,h,W),div:(h,W)=>IG(h*hy(W,l),l),sqrN:h=>h*h,addN:(h,W)=>h+W,subN:(h,W)=>h-W,mulN:(h,W)=>h*W,inv:h=>hy(h,l),sqrt:c||(h=>(a||(a=X5(l)),a(n,h))),toBytes:h=>G?Cn(h,Z):Un(h,Z),fromBytes:(h,W=!0)=>{if(e){if(!e.includes(h.length)||h.length>Z)throw new Error("Field.fromBytes: expected "+e+" bytes, got "+h.length);let Y=new Uint8Array(Z);Y.set(h,G?0:Y.length-h.length),h=Y}if(h.length!==Z)throw new Error("Field.fromBytes: expected "+Z+" bytes, got "+h.length);let i=G?Kt(h):Ne(h);if(B&&(i=IG(i,l)),!W&&!n.isValid(i))throw new Error("invalid field element: outside of range 0..ORDER");return i},invertBatch:h=>zn(n,h),cmov:(h,W,i)=>i?W:h});return Object.freeze(n)}function Ry(l){if(typeof l!="bigint")throw new Error("field order must be bigint");let A=l.toString(2).length;return Math.ceil(A/8)}function Li(l){let A=Ry(l);return A+Math.ceil(A/2)}function Oi(l,A,G=!1){let b=l.length,t=Ry(A),c=Li(A);if(b<16||b<c||b>1024)throw new Error("expected "+c+"-1024 bytes of input, got "+b);let B=G?Kt(l):Ne(l),e=IG(B,A-hb)+hb;return G?Cn(e,t):Un(e,t)}var Ad=BigInt(0),Je=BigInt(1);function jn(l,A){let G=A.negate();return l?G:A}function GB(l,A){let G=zn(l.Fp,A.map(b=>b.Z));return A.map((b,t)=>l.fromAffine(b.toAffine(G[t])))}function yy(l,A){if(!Number.isSafeInteger(l)||l<=0||l>A)throw new Error("invalid window size, expected [1.."+A+"], got W="+l)}function Pi(l,A){yy(l,A);let G=Math.ceil(A/l)+1,b=2**(l-1),t=2**l,c=Xc(l),B=BigInt(l);return{windows:G,windowSize:b,mask:c,maxNumber:t,shiftBy:B}}function Xy(l,A,G){let{windowSize:b,mask:t,maxNumber:c,shiftBy:B}=G,e=Number(l&t),d=l>>B;e>b&&(e-=c,d+=Je);let Z=A*b,a=Z+Math.abs(e)-1,n=e===0,h=e<0,W=A%2!==0;return{nextN:d,offset:a,isZero:n,isNeg:h,isNegF:W,offsetF:Z}}function Q5(l,A){if(!Array.isArray(l))throw new Error("array expected");l.forEach((G,b)=>{if(!(G instanceof A))throw new Error("invalid point at index "+b)})}function N5(l,A){if(!Array.isArray(l))throw new Error("array of scalars expected");l.forEach((G,b)=>{if(!A.isValid(G))throw new Error("invalid scalar at index "+b)})}var Ki=new WeakMap,Qy=new WeakMap;function qi(l){return Qy.get(l)||1}function py(l){if(l!==Ad)throw new Error("invalid wNAF")}var Gd=class{constructor(A,G){this.BASE=A.BASE,this.ZERO=A.ZERO,this.Fn=A.Fn,this.bits=G}_unsafeLadder(A,G,b=this.ZERO){let t=A;for(;G>Ad;)G&Je&&(b=b.add(t)),t=t.double(),G>>=Je;return b}precomputeWindow(A,G){let{windows:b,windowSize:t}=Pi(G,this.bits),c=[],B=A,e=B;for(let d=0;d<b;d++){e=B,c.push(e);for(let Z=1;Z<t;Z++)e=e.add(B),c.push(e);B=e.double()}return c}wNAF(A,G,b){if(!this.Fn.isValid(b))throw new Error("invalid scalar");let t=this.ZERO,c=this.BASE,B=Pi(A,this.bits);for(let e=0;e<B.windows;e++){let{nextN:d,offset:Z,isZero:a,isNeg:n,isNegF:h,offsetF:W}=Xy(b,e,B);b=d,a?c=c.add(jn(h,G[W])):t=t.add(jn(n,G[Z]))}return py(b),{p:t,f:c}}wNAFUnsafe(A,G,b,t=this.ZERO){let c=Pi(A,this.bits);for(let B=0;B<c.windows&&b!==Ad;B++){let{nextN:e,offset:d,isZero:Z,isNeg:a}=Xy(b,B,c);if(b=e,!Z){let n=G[d];t=t.add(a?n.negate():n)}}return py(b),t}getPrecomputes(A,G,b){let t=Ki.get(G);return t||(t=this.precomputeWindow(G,A),A!==1&&(typeof b=="function"&&(t=b(t)),Ki.set(G,t))),t}cached(A,G,b){let t=qi(A);return this.wNAF(t,this.getPrecomputes(t,A,b),G)}unsafe(A,G,b,t){let c=qi(A);return c===1?this._unsafeLadder(A,G,t):this.wNAFUnsafe(c,this.getPrecomputes(c,A,b),G,t)}createCache(A,G){yy(G,this.bits),Qy.set(A,G),Ki.delete(A)}hasCache(A){return qi(A)!==1}};function Ny(l,A,G,b){let t=A,c=l.ZERO,B=l.ZERO;for(;G>Ad||b>Ad;)G&Je&&(c=c.add(t)),b&Je&&(B=B.add(t)),t=t.double(),G>>=Je,b>>=Je;return{p1:c,p2:B}}function bd(l,A,G,b){Q5(G,l),N5(b,A);let t=G.length,c=b.length;if(t!==c)throw new Error("arrays of points and scalars must have equal length");let B=l.ZERO,e=Sn(BigInt(t)),d=1;e>12?d=e-3:e>4?d=e-2:e>0&&(d=2);let Z=Xc(d),a=new Array(Number(Z)+1).fill(B),n=Math.floor((A.BITS-1)/d)*d,h=B;for(let W=n;W>=0;W-=d){a.fill(B);for(let Y=0;Y<c;Y++){let R=b[Y],V=Number(R>>BigInt(W)&Z);a[V]=a[V].add(G[Y])}let i=B;for(let Y=a.length-1,R=B;Y>0;Y--)R=R.add(a[Y]),i=i.add(R);if(h=h.add(i),W!==0)for(let Y=0;Y<d;Y++)h=h.double()}return h}function Fy(l,A,G){if(A){if(A.ORDER!==l)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Di(A),A}else return ut(l,{isLE:G})}function $W(l,A,G={},b){if(b===void 0&&(b=l==="edwards"),!A||typeof A!="object")throw new Error(`expected valid ${l} CURVE object`);for(let d of["p","n","h"]){let Z=A[d];if(!(typeof Z=="bigint"&&Z>Ad))throw new Error(`CURVE.${d} must be positive bigint`)}let t=Fy(A.p,G.Fp,b),c=Fy(A.n,G.Fn,b),e=["Gx","Gy","a",l==="weierstrass"?"b":"d"];for(let d of e)if(!t.isValid(A[d]))throw new Error(`CURVE.${d} must be valid field element of CURVE.Fp`);return A=Object.freeze(Object.assign({},A)),{CURVE:A,Fp:t,Fn:c}}var Ey=(l,A)=>(l+(l>=0?A:-A)/vy)/A;function E5(l,A,G){let[[b,t],[c,B]]=A,e=Ey(B*l,G),d=Ey(-t*l,G),Z=l-e*b-d*c,a=-e*t-d*B,n=Z<tB,h=a<tB;n&&(Z=-Z),h&&(a=-a);let W=Xc(Math.ceil(Sn(G)/2))+cd;if(Z<tB||Z>=W||a<tB||a>=W)throw new Error("splitScalar (endomorphism): failed, k="+l);return{k1neg:n,k1:Z,k2neg:h,k2:a}}function $i(l){if(!["compact","recovered","der"].includes(l))throw new Error('Signature format must be "compact", "recovered", or "der"');return l}function _i(l,A){let G={};for(let b of Object.keys(A))G[b]=l[b]===void 0?A[b]:l[b];return lB(G.lowS,"lowS"),lB(G.prehash,"prehash"),G.format!==void 0&&$i(G.format),G}var lm=class extends Error{constructor(A=""){super(A)}},bB={Err:lm,_tlv:{encode:(l,A)=>{let{Err:G}=bB;if(l<0||l>256)throw new G("tlv.encode: wrong tag");if(A.length&1)throw new G("tlv.encode: unpadded data");let b=A.length/2,t=ld(b);if(t.length/2&128)throw new G("tlv.encode: long form length too big");let c=b>127?ld(t.length/2|128):"";return ld(l)+c+t+A},decode(l,A){let{Err:G}=bB,b=0;if(l<0||l>256)throw new G("tlv.encode: wrong tag");if(A.length<2||A[b++]!==l)throw new G("tlv.decode: wrong tlv");let t=A[b++],c=!!(t&128),B=0;if(!c)B=t;else{let d=t&127;if(!d)throw new G("tlv.decode(long): indefinite length not supported");if(d>4)throw new G("tlv.decode(long): byte length is too big");let Z=A.subarray(b,b+d);if(Z.length!==d)throw new G("tlv.decode: length bytes not complete");if(Z[0]===0)throw new G("tlv.decode(long): zero leftmost byte");for(let a of Z)B=B<<8|a;if(b+=d,B<128)throw new G("tlv.decode(long): not minimal encoding")}let e=A.subarray(b,b+B);if(e.length!==B)throw new G("tlv.decode: wrong value length");return{v:e,l:A.subarray(b+B)}}},_int:{encode(l){let{Err:A}=bB;if(l<tB)throw new A("integer: negative integers are not allowed");let G=ld(l);if(Number.parseInt(G[0],16)&8&&(G="00"+G),G.length&1)throw new A("unexpected DER parsing assertion: unpadded hex");return G},decode(l){let{Err:A}=bB;if(l[0]&128)throw new A("invalid signature integer: negative");if(l[0]===0&&!(l[1]&128))throw new A("invalid signature integer: unnecessary leading zero");return Ne(l)}},toSig(l){let{Err:A,_int:G,_tlv:b}=bB,t=ZG("signature",l),{v:c,l:B}=b.decode(48,t);if(B.length)throw new A("invalid signature: left bytes after parsing");let{v:e,l:d}=b.decode(2,c),{v:Z,l:a}=b.decode(2,d);if(a.length)throw new A("invalid signature: left bytes after parsing");return{r:G.decode(e),s:G.decode(Z)}},hexFromSig(l){let{_tlv:A,_int:G}=bB,b=A.encode(2,G.encode(l.r)),t=A.encode(2,G.encode(l.s)),c=b+t;return A.encode(48,c)}},tB=BigInt(0),cd=BigInt(1),vy=BigInt(2),lo=BigInt(3),v5=BigInt(4);function td(l,A){let{BYTES:G}=l,b;if(typeof A=="bigint")b=A;else{let t=ZG("private key",A);try{b=l.fromBytes(t)}catch{throw new Error(`invalid private key: expected ui8a of size ${G}, got ${typeof A}`)}}if(!l.isValidNot0(b))throw new Error("invalid private key: out of range [1..N-1]");return b}function H5(l,A={}){let G=$W("weierstrass",l,A),{Fp:b,Fn:t}=G,c=G.CURVE,{h:B,n:e}=c;kB(A,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:d}=A;if(d&&(!b.is0(c.a)||typeof d.beta!="bigint"||!Array.isArray(d.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let Z=Jy(b,t);function a(){if(!b.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function n(K,Q,r){let{x:F,y:E}=Q.toAffine(),f=b.toBytes(F);if(lB(r,"isCompressed"),r){a();let s=!b.isOdd(E);return VG(Hy(s),f)}else return VG(Uint8Array.of(4),f,b.toBytes(E))}function h(K){Vt(K,void 0,"Point");let{publicKey:Q,publicKeyUncompressed:r}=Z,F=K.length,E=K[0],f=K.subarray(1);if(F===Q&&(E===2||E===3)){let s=b.fromBytes(f);if(!b.isValid(s))throw new Error("bad point: is not on curve, wrong x");let p=Y(s),X;try{X=b.sqrt(p)}catch(u){let v=u instanceof Error?": "+u.message:"";throw new Error("bad point: is not on curve, sqrt error"+v)}a();let o=b.isOdd(X);return(E&1)===1!==o&&(X=b.neg(X)),{x:s,y:X}}else if(F===r&&E===4){let s=b.BYTES,p=b.fromBytes(f.subarray(0,s)),X=b.fromBytes(f.subarray(s,s*2));if(!R(p,X))throw new Error("bad point: is not on curve");return{x:p,y:X}}else throw new Error(`bad point: got length ${F}, expected compressed=${Q} or uncompressed=${r}`)}let W=A.toBytes||n,i=A.fromBytes||h;function Y(K){let Q=b.sqr(K),r=b.mul(Q,K);return b.add(b.add(r,b.mul(K,c.a)),c.b)}function R(K,Q){let r=b.sqr(Q),F=Y(K);return b.eql(r,F)}if(!R(c.Gx,c.Gy))throw new Error("bad curve params: generator point");let V=b.mul(b.pow(c.a,lo),v5),m=b.mul(b.sqr(c.b),BigInt(27));if(b.is0(b.add(V,m)))throw new Error("bad curve params: a or b");function I(K,Q,r=!1){if(!b.isValid(Q)||r&&b.is0(Q))throw new Error(`bad point coordinate ${K}`);return Q}function y(K){if(!(K instanceof C))throw new Error("ProjectivePoint expected")}function x(K){if(!d||!d.basises)throw new Error("no endo");return E5(K,d.basises,t.ORDER)}let w=ve((K,Q)=>{let{X:r,Y:F,Z:E}=K;if(b.eql(E,b.ONE))return{x:r,y:F};let f=K.is0();Q==null&&(Q=f?b.ONE:b.inv(E));let s=b.mul(r,Q),p=b.mul(F,Q),X=b.mul(E,Q);if(f)return{x:b.ZERO,y:b.ZERO};if(!b.eql(X,b.ONE))throw new Error("invZ was invalid");return{x:s,y:p}}),H=ve(K=>{if(K.is0()){if(A.allowInfinityPoint&&!b.is0(K.Y))return;throw new Error("bad point: ZERO")}let{x:Q,y:r}=K.toAffine();if(!b.isValid(Q)||!b.isValid(r))throw new Error("bad point: x or y not field elements");if(!R(Q,r))throw new Error("bad point: equation left != right");if(!K.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function j(K,Q,r,F,E){return r=new C(b.mul(r.X,K),r.Y,r.Z),Q=jn(F,Q),r=jn(E,r),Q.add(r)}class C{constructor(Q,r,F){this.X=I("x",Q),this.Y=I("y",r,!0),this.Z=I("z",F),Object.freeze(this)}static CURVE(){return c}static fromAffine(Q){let{x:r,y:F}=Q||{};if(!Q||!b.isValid(r)||!b.isValid(F))throw new Error("invalid affine point");if(Q instanceof C)throw new Error("projective point not allowed");return b.is0(r)&&b.is0(F)?C.ZERO:new C(r,F,b.ONE)}static fromBytes(Q){let r=C.fromAffine(i(Vt(Q,void 0,"point")));return r.assertValidity(),r}static fromHex(Q){return C.fromBytes(ZG("pointHex",Q))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(Q=8,r=!0){return $.createCache(this,Q),r||this.multiply(lo),this}assertValidity(){H(this)}hasEvenY(){let{y:Q}=this.toAffine();if(!b.isOdd)throw new Error("Field doesn't support isOdd");return!b.isOdd(Q)}equals(Q){y(Q);let{X:r,Y:F,Z:E}=this,{X:f,Y:s,Z:p}=Q,X=b.eql(b.mul(r,p),b.mul(f,E)),o=b.eql(b.mul(F,p),b.mul(s,E));return X&&o}negate(){return new C(this.X,b.neg(this.Y),this.Z)}double(){let{a:Q,b:r}=c,F=b.mul(r,lo),{X:E,Y:f,Z:s}=this,p=b.ZERO,X=b.ZERO,o=b.ZERO,g=b.mul(E,E),u=b.mul(f,f),v=b.mul(s,s),S=b.mul(E,f);return S=b.add(S,S),o=b.mul(E,s),o=b.add(o,o),p=b.mul(Q,o),X=b.mul(F,v),X=b.add(p,X),p=b.sub(u,X),X=b.add(u,X),X=b.mul(p,X),p=b.mul(S,p),o=b.mul(F,o),v=b.mul(Q,v),S=b.sub(g,v),S=b.mul(Q,S),S=b.add(S,o),o=b.add(g,g),g=b.add(o,g),g=b.add(g,v),g=b.mul(g,S),X=b.add(X,g),v=b.mul(f,s),v=b.add(v,v),g=b.mul(v,S),p=b.sub(p,g),o=b.mul(v,u),o=b.add(o,o),o=b.add(o,o),new C(p,X,o)}add(Q){y(Q);let{X:r,Y:F,Z:E}=this,{X:f,Y:s,Z:p}=Q,X=b.ZERO,o=b.ZERO,g=b.ZERO,u=c.a,v=b.mul(c.b,lo),S=b.mul(r,f),z=b.mul(F,s),q=b.mul(E,p),_=b.add(r,F),T=b.add(f,s);_=b.mul(_,T),T=b.add(S,z),_=b.sub(_,T),T=b.add(r,E);let J=b.add(f,p);return T=b.mul(T,J),J=b.add(S,q),T=b.sub(T,J),J=b.add(F,E),X=b.add(s,p),J=b.mul(J,X),X=b.add(z,q),J=b.sub(J,X),g=b.mul(u,T),X=b.mul(v,q),g=b.add(X,g),X=b.sub(z,g),g=b.add(z,g),o=b.mul(X,g),z=b.add(S,S),z=b.add(z,S),q=b.mul(u,q),T=b.mul(v,T),z=b.add(z,q),q=b.sub(S,q),q=b.mul(u,q),T=b.add(T,q),S=b.mul(z,T),o=b.add(o,S),S=b.mul(J,T),X=b.mul(_,X),X=b.sub(X,S),S=b.mul(_,z),g=b.mul(J,g),g=b.add(g,S),new C(X,o,g)}subtract(Q){return this.add(Q.negate())}is0(){return this.equals(C.ZERO)}multiply(Q){let{endo:r}=A;if(!t.isValidNot0(Q))throw new Error("invalid scalar: out of range");let F,E,f=s=>$.cached(this,s,p=>GB(C,p));if(r){let{k1neg:s,k1:p,k2neg:X,k2:o}=x(Q),{p:g,f:u}=f(p),{p:v,f:S}=f(o);E=u.add(S),F=j(r.beta,g,v,s,X)}else{let{p:s,f:p}=f(Q);F=s,E=p}return GB(C,[F,E])[0]}multiplyUnsafe(Q){let{endo:r}=A,F=this;if(!t.isValid(Q))throw new Error("invalid scalar: out of range");if(Q===tB||F.is0())return C.ZERO;if(Q===cd)return F;if($.hasCache(this))return this.multiply(Q);if(r){let{k1neg:E,k1:f,k2neg:s,k2:p}=x(Q),{p1:X,p2:o}=Ny(C,F,f,p);return j(r.beta,X,o,E,s)}else return $.unsafe(F,Q)}multiplyAndAddUnsafe(Q,r,F){let E=this.multiplyUnsafe(r).add(Q.multiplyUnsafe(F));return E.is0()?void 0:E}toAffine(Q){return w(this,Q)}isTorsionFree(){let{isTorsionFree:Q}=A;return B===cd?!0:Q?Q(C,this):$.unsafe(this,e).is0()}clearCofactor(){let{clearCofactor:Q}=A;return B===cd?this:Q?Q(C,this):this.multiplyUnsafe(B)}isSmallOrder(){return this.multiplyUnsafe(B).is0()}toBytes(Q=!0){return lB(Q,"isCompressed"),this.assertValidity(),W(C,this,Q)}toHex(Q=!0){return et(this.toBytes(Q))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(Q=!0){return this.toBytes(Q)}_setWindowSize(Q){this.precompute(Q)}static normalizeZ(Q){return GB(C,Q)}static msm(Q,r){return bd(C,t,Q,r)}static fromPrivateKey(Q){return C.BASE.multiply(td(t,Q))}}C.BASE=new C(c.Gx,c.Gy,b.ONE),C.ZERO=new C(b.ZERO,b.ONE,b.ZERO),C.Fp=b,C.Fn=t;let D=t.BITS,$=new Gd(C,A.endo?Math.ceil(D/2):D);return C.BASE.precompute(8),C}function Hy(l){return Uint8Array.of(l?2:3)}function Jy(l,A){return{secretKey:A.BYTES,publicKey:1+l.BYTES,publicKeyUncompressed:1+2*l.BYTES,publicKeyHasPrefix:!0,signature:2*A.BYTES}}function J5(l,A={}){let{Fn:G}=l,b=A.randomBytes||vb,t=Object.assign(Jy(l.Fp,G),{seed:Li(G.ORDER)});function c(W){try{return!!td(G,W)}catch{return!1}}function B(W,i){let{publicKey:Y,publicKeyUncompressed:R}=t;try{let V=W.length;return i===!0&&V!==Y||i===!1&&V!==R?!1:!!l.fromBytes(W)}catch{return!1}}function e(W=b(t.seed)){return Oi(Vt(W,t.seed,"seed"),G.ORDER)}function d(W,i=!0){return l.BASE.multiply(td(G,W)).toBytes(i)}function Z(W){let i=e(W);return{secretKey:i,publicKey:d(i)}}function a(W){if(typeof W=="bigint")return!1;if(W instanceof l)return!0;let{secretKey:i,publicKey:Y,publicKeyUncompressed:R}=t;if(G.allowedLengths||i===Y)return;let V=ZG("key",W).length;return V===Y||V===R}function n(W,i,Y=!0){if(a(W)===!0)throw new Error("first arg must be private key");if(a(i)===!1)throw new Error("second arg must be public key");let R=td(G,W);return l.fromHex(i).multiply(R).toBytes(Y)}return Object.freeze({getPublicKey:d,getSharedSecret:n,keygen:Z,Point:l,utils:{isValidSecretKey:c,isValidPublicKey:B,randomSecretKey:e,isValidPrivateKey:c,randomPrivateKey:e,normPrivateKeyToScalar:W=>td(G,W),precompute(W=8,i=l.BASE){return i.precompute(W,!1)}},lengths:t})}function f5(l,A,G={}){Ke(A),kB(G,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let b=G.randomBytes||vb,t=G.hmac||((r,...F)=>Qe(A,r,VG(...F))),{Fp:c,Fn:B}=l,{ORDER:e,BITS:d}=B,{keygen:Z,getPublicKey:a,getSharedSecret:n,utils:h,lengths:W}=J5(l,G),i={prehash:!1,lowS:typeof G.lowS=="boolean"?G.lowS:!1,format:void 0,extraEntropy:!1},Y="compact";function R(r){let F=e>>cd;return r>F}function V(r,F){if(!B.isValidNot0(F))throw new Error(`invalid signature ${r}: out of range 1..Point.Fn.ORDER`);return F}function m(r,F){$i(F);let E=W.signature,f=F==="compact"?E:F==="recovered"?E+1:void 0;return Vt(r,f,`${F} signature`)}class I{constructor(F,E,f){this.r=V("r",F),this.s=V("s",E),f!=null&&(this.recovery=f),Object.freeze(this)}static fromBytes(F,E=Y){m(F,E);let f;if(E==="der"){let{r:o,s:g}=bB.toSig(Vt(F));return new I(o,g)}E==="recovered"&&(f=F[0],E="compact",F=F.subarray(1));let s=B.BYTES,p=F.subarray(0,s),X=F.subarray(s,s*2);return new I(B.fromBytes(p),B.fromBytes(X),f)}static fromHex(F,E){return this.fromBytes(WB(F),E)}addRecoveryBit(F){return new I(this.r,this.s,F)}recoverPublicKey(F){let E=c.ORDER,{r:f,s,recovery:p}=this;if(p==null||![0,1,2,3].includes(p))throw new Error("recovery id invalid");if(e*vy<E&&p>1)throw new Error("recovery id is ambiguous for h>1 curve");let o=p===2||p===3?f+e:f;if(!c.isValid(o))throw new Error("recovery id 2 or 3 invalid");let g=c.toBytes(o),u=l.fromBytes(VG(Hy((p&1)===0),g)),v=B.inv(o),S=x(ZG("msgHash",F)),z=B.create(-S*v),q=B.create(s*v),_=l.BASE.multiplyUnsafe(z).add(u.multiplyUnsafe(q));if(_.is0())throw new Error("point at infinify");return _.assertValidity(),_}hasHighS(){return R(this.s)}toBytes(F=Y){if($i(F),F==="der")return WB(bB.hexFromSig(this));let E=B.toBytes(this.r),f=B.toBytes(this.s);if(F==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return VG(Uint8Array.of(this.recovery),E,f)}return VG(E,f)}toHex(F){return et(this.toBytes(F))}assertValidity(){}static fromCompact(F){return I.fromBytes(ZG("sig",F),"compact")}static fromDER(F){return I.fromBytes(ZG("sig",F),"der")}normalizeS(){return this.hasHighS()?new I(this.r,B.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return et(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return et(this.toBytes("compact"))}}let y=G.bits2int||function(F){if(F.length>8192)throw new Error("input is too large");let E=Ne(F),f=F.length*8-d;return f>0?E>>BigInt(f):E},x=G.bits2int_modN||function(F){return B.create(y(F))},w=Xc(d);function H(r){return Ee("num < 2^"+d,r,tB,w),B.toBytes(r)}function j(r,F){return Vt(r,void 0,"message"),F?Vt(A(r),void 0,"prehashed message"):r}function C(r,F,E){if(["recovered","canonical"].some(z=>z in E))throw new Error("sign() legacy options not supported");let{lowS:f,prehash:s,extraEntropy:p}=_i(E,i);r=j(r,s);let X=x(r),o=td(B,F),g=[H(o),H(X)];if(p!=null&&p!==!1){let z=p===!0?b(W.secretKey):p;g.push(ZG("extraEntropy",z))}let u=VG(...g),v=X;function S(z){let q=y(z);if(!B.isValidNot0(q))return;let _=B.inv(q),T=l.BASE.multiply(q).toAffine(),J=B.create(T.x);if(J===tB)return;let U=B.create(_*B.create(v+J*o));if(U===tB)return;let L=(T.x===J?0:2)|Number(T.y&cd),ll=U;return f&&R(U)&&(ll=B.neg(U),L^=1),new I(J,ll,L)}return{seed:u,k2sig:S}}function D(r,F,E={}){r=ZG("message",r);let{seed:f,k2sig:s}=C(r,F,E);return Mi(A.outputLen,B.BYTES,t)(f,s)}function $(r){let F,E=typeof r=="string"||kt(r),f=!E&&r!==null&&typeof r=="object"&&typeof r.r=="bigint"&&typeof r.s=="bigint";if(!E&&!f)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(f)F=new I(r.r,r.s);else if(E){try{F=I.fromBytes(ZG("sig",r),"der")}catch(s){if(!(s instanceof bB.Err))throw s}if(!F)try{F=I.fromBytes(ZG("sig",r),"compact")}catch{return!1}}return F||!1}function K(r,F,E,f={}){let{lowS:s,prehash:p,format:X}=_i(f,i);if(E=ZG("publicKey",E),F=j(ZG("message",F),p),"strict"in f)throw new Error("options.strict was renamed to lowS");let o=X===void 0?$(r):I.fromBytes(ZG("sig",r),X);if(o===!1)return!1;try{let g=l.fromBytes(E);if(s&&o.hasHighS())return!1;let{r:u,s:v}=o,S=x(F),z=B.inv(v),q=B.create(S*z),_=B.create(u*z),T=l.BASE.multiplyUnsafe(q).add(g.multiplyUnsafe(_));return T.is0()?!1:B.create(T.x)===u}catch{return!1}}function Q(r,F,E={}){let{prehash:f}=_i(E,i);return F=j(F,f),I.fromBytes(r,"recovered").recoverPublicKey(F).toBytes()}return Object.freeze({keygen:Z,getPublicKey:a,getSharedSecret:n,utils:h,lengths:W,Point:l,sign:D,verify:K,recoverPublicKey:Q,Signature:I,hash:A})}function x5(l){let A={a:l.a,b:l.b,p:l.Fp.ORDER,n:l.n,h:l.h,Gx:l.Gx,Gy:l.Gy},G=l.Fp,b=l.allowedPrivateKeyLengths?Array.from(new Set(l.allowedPrivateKeyLengths.map(B=>Math.ceil(B/2)))):void 0,t=ut(A.n,{BITS:l.nBitLength,allowedLengths:b,modFromBytes:l.wrapPrivateKey}),c={Fp:G,Fn:t,allowInfinityPoint:l.allowInfinityPoint,endo:l.endo,isTorsionFree:l.isTorsionFree,clearCofactor:l.clearCofactor,fromBytes:l.fromBytes,toBytes:l.toBytes};return{CURVE:A,curveOpts:c}}function k5(l){let{CURVE:A,curveOpts:G}=x5(l),b={hmac:l.hmac,randomBytes:l.randomBytes,lowS:l.lowS,bits2int:l.bits2int,bits2int_modN:l.bits2int_modN};return{CURVE:A,curveOpts:G,hash:l.hash,ecdsaOpts:b}}function w5(l,A){let G=A.Point;return Object.assign({},A,{ProjectivePoint:G,CURVE:Object.assign({},l,_W(G.Fn.ORDER,G.Fn.BITS))})}function fy(l){let{CURVE:A,curveOpts:G,hash:b,ecdsaOpts:t}=k5(l),c=H5(A,G),B=f5(c,b,t);return w5(l,B)}function xy(l,A){let G=b=>fy({...l,hash:b});return{...G(A),create:G}}var Gm={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},U5={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var ky=BigInt(2);function C5(l){let A=Gm.p,G=BigInt(3),b=BigInt(6),t=BigInt(11),c=BigInt(22),B=BigInt(23),e=BigInt(44),d=BigInt(88),Z=l*l*l%A,a=Z*Z*l%A,n=RG(a,G,A)*a%A,h=RG(n,G,A)*a%A,W=RG(h,ky,A)*Z%A,i=RG(W,t,A)*W%A,Y=RG(i,c,A)*i%A,R=RG(Y,e,A)*Y%A,V=RG(R,d,A)*R%A,m=RG(V,e,A)*Y%A,I=RG(m,G,A)*a%A,y=RG(I,B,A)*i%A,x=RG(y,b,A)*Z%A,w=RG(x,ky,A);if(!Am.eql(Am.sqr(w),l))throw new Error("Cannot find square root");return w}var Am=ut(Gm.p,{sqrt:C5}),pc=xy({...Gm,Fp:Am,lowS:!0,endo:U5},ye);function qt(l,A){if(l.length!==32)throw new Error("Expected valid 32-byte private key as a seed");if(!PA||!A&&TA()){let G=_V(l),b=G.slice(32);if(vd(b))throw new Error("Invalid publicKey generated from WASM interface");return{publicKey:b,secretKey:G.slice(0,32)}}return{publicKey:pc.getPublicKey(l,!0),secretKey:l}}function Ao(l,A){return(G,{chainCode:b,isHard:t})=>{if(!t)throw new Error("A soft key was found in the path and is not supported");return l(A(G.secretKey.subarray(0,32),b))}}var bm=Ao(qt,Wy);var S5=be(uG("Ed25519HDKD"));function tm(l,A){if(!Jb(A)||A.length!==32)throw new Error("Invalid chainCode passed to derive");return Tb(nG(S5,l,A))}function Bd(l=32){return Ha(new Uint8Array(l))}var wB=BigInt(0),sb=BigInt(1),cm=BigInt(2),z5=BigInt(8);function j5(l,A,G,b){let t=l.sqr(G),c=l.sqr(b),B=l.add(l.mul(A.a,t),c),e=l.add(l.ONE,l.mul(A.d,l.mul(t,c)));return l.eql(B,e)}function M5(l,A={}){let G=$W("edwards",l,A,A.FpFnLE),{Fp:b,Fn:t}=G,c=G.CURVE,{h:B}=c;kB(A,{},{uvRatio:"function"});let e=cm<<BigInt(t.BYTES*8)-sb,d=R=>b.create(R),Z=A.uvRatio||((R,V)=>{try{return{isValid:!0,value:b.sqrt(b.div(R,V))}}catch{return{isValid:!1,value:wB}}});if(!j5(b,c,c.Gx,c.Gy))throw new Error("bad curve params: generator point");function a(R,V,m=!1){let I=m?sb:wB;return Ee("coordinate "+R,V,I,e),V}function n(R){if(!(R instanceof i))throw new Error("ExtendedPoint expected")}let h=ve((R,V)=>{let{X:m,Y:I,Z:y}=R,x=R.is0();V==null&&(V=x?z5:b.inv(y));let w=d(m*V),H=d(I*V),j=b.mul(y,V);if(x)return{x:wB,y:sb};if(j!==sb)throw new Error("invZ was invalid");return{x:w,y:H}}),W=ve(R=>{let{a:V,d:m}=c;if(R.is0())throw new Error("bad point: ZERO");let{X:I,Y:y,Z:x,T:w}=R,H=d(I*I),j=d(y*y),C=d(x*x),D=d(C*C),$=d(H*V),K=d(C*d($+j)),Q=d(D+d(m*d(H*j)));if(K!==Q)throw new Error("bad point: equation left != right (1)");let r=d(I*y),F=d(x*w);if(r!==F)throw new Error("bad point: equation left != right (2)");return!0});class i{constructor(V,m,I,y){this.X=a("x",V),this.Y=a("y",m),this.Z=a("z",I,!0),this.T=a("t",y),Object.freeze(this)}static CURVE(){return c}static fromAffine(V){if(V instanceof i)throw new Error("extended point not allowed");let{x:m,y:I}=V||{};return a("x",m),a("y",I),new i(m,I,sb,d(m*I))}static fromBytes(V,m=!1){let I=b.BYTES,{a:y,d:x}=c;V=KW(Vt(V,I,"point")),lB(m,"zip215");let w=KW(V),H=V[I-1];w[I-1]=H&-129;let j=Kt(w),C=m?e:b.ORDER;Ee("point.y",j,wB,C);let D=d(j*j),$=d(D-sb),K=d(x*D-y),{isValid:Q,value:r}=Z($,K);if(!Q)throw new Error("bad point: invalid y coordinate");let F=(r&sb)===sb,E=(H&128)!==0;if(!m&&r===wB&&E)throw new Error("bad point: x=0 and x_0=1");return E!==F&&(r=d(-r)),i.fromAffine({x:r,y:j})}static fromHex(V,m=!1){return i.fromBytes(ZG("point",V),m)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(V=8,m=!0){return Y.createCache(this,V),m||this.multiply(cm),this}assertValidity(){W(this)}equals(V){n(V);let{X:m,Y:I,Z:y}=this,{X:x,Y:w,Z:H}=V,j=d(m*H),C=d(x*y),D=d(I*H),$=d(w*y);return j===C&&D===$}is0(){return this.equals(i.ZERO)}negate(){return new i(d(-this.X),this.Y,this.Z,d(-this.T))}double(){let{a:V}=c,{X:m,Y:I,Z:y}=this,x=d(m*m),w=d(I*I),H=d(cm*d(y*y)),j=d(V*x),C=m+I,D=d(d(C*C)-x-w),$=j+w,K=$-H,Q=j-w,r=d(D*K),F=d($*Q),E=d(D*Q),f=d(K*$);return new i(r,F,f,E)}add(V){n(V);let{a:m,d:I}=c,{X:y,Y:x,Z:w,T:H}=this,{X:j,Y:C,Z:D,T:$}=V,K=d(y*j),Q=d(x*C),r=d(H*I*$),F=d(w*D),E=d((y+x)*(j+C)-K-Q),f=F-r,s=F+r,p=d(Q-m*K),X=d(E*f),o=d(s*p),g=d(E*p),u=d(f*s);return new i(X,o,u,g)}subtract(V){return this.add(V.negate())}multiply(V){if(!t.isValidNot0(V))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:m,f:I}=Y.cached(this,V,y=>GB(i,y));return GB(i,[m,I])[0]}multiplyUnsafe(V,m=i.ZERO){if(!t.isValid(V))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return V===wB?i.ZERO:this.is0()||V===sb?this:Y.unsafe(this,V,I=>GB(i,I),m)}isSmallOrder(){return this.multiplyUnsafe(B).is0()}isTorsionFree(){return Y.unsafe(this,c.n).is0()}toAffine(V){return h(this,V)}clearCofactor(){return B===sb?this:this.multiplyUnsafe(B)}toBytes(){let{x:V,y:m}=this.toAffine(),I=b.toBytes(m);return I[I.length-1]|=V&sb?128:0,I}toHex(){return et(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(V){return GB(i,V)}static msm(V,m){return bd(i,t,V,m)}_setWindowSize(V){this.precompute(V)}toRawBytes(){return this.toBytes()}}i.BASE=new i(c.Gx,c.Gy,sb,d(c.Gx*c.Gy)),i.ZERO=new i(wB,sb,sb,wB),i.Fp=b,i.Fn=t;let Y=new Gd(i,t.BITS);return i.BASE.precompute(8),i}var Go=class{constructor(A){this.ep=A}static fromBytes(A){qW()}static fromHex(A){qW()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(A){return this.ep.toAffine(A)}toHex(){return et(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(A){return this.assertSame(A),this.init(this.ep.add(A.ep))}subtract(A){return this.assertSame(A),this.init(this.ep.subtract(A.ep))}multiply(A){return this.init(this.ep.multiply(A))}multiplyUnsafe(A){return this.init(this.ep.multiplyUnsafe(A))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(A,G){return this.init(this.ep.precompute(A,G))}toRawBytes(){return this.toBytes()}};function T5(l,A,G={}){if(typeof A!="function")throw new Error('"hash" function param is required');kB(G,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:b}=G,{BASE:t,Fp:c,Fn:B}=l,e=G.randomBytes||vb,d=G.adjustScalarBytes||(C=>C),Z=G.domain||((C,D,$)=>{if(lB($,"phflag"),D.length||$)throw new Error("Contexts/pre-hash are not supported");return C});function a(C){return B.create(Kt(C))}function n(C){let D=I.secretKey;C=ZG("private key",C,D);let $=ZG("hashed private key",A(C),2*D),K=d($.slice(0,D)),Q=$.slice(D,2*D),r=a(K);return{head:K,prefix:Q,scalar:r}}function h(C){let{head:D,prefix:$,scalar:K}=n(C),Q=t.multiply(K),r=Q.toBytes();return{head:D,prefix:$,scalar:K,point:Q,pointBytes:r}}function W(C){return h(C).pointBytes}function i(C=Uint8Array.of(),...D){let $=VG(...D);return a(A(Z($,ZG("context",C),!!b)))}function Y(C,D,$={}){C=ZG("message",C),b&&(C=b(C));let{prefix:K,scalar:Q,pointBytes:r}=h(D),F=i($.context,K,C),E=t.multiply(F).toBytes(),f=i($.context,E,r,C),s=B.create(F+f*Q);if(!B.isValid(s))throw new Error("sign failed: invalid s");let p=VG(E,B.toBytes(s));return Vt(p,I.signature,"result")}let R={zip215:!0};function V(C,D,$,K=R){let{context:Q,zip215:r}=K,F=I.signature;C=ZG("signature",C,F),D=ZG("message",D),$=ZG("publicKey",$,I.publicKey),r!==void 0&&lB(r,"zip215"),b&&(D=b(D));let E=F/2,f=C.subarray(0,E),s=Kt(C.subarray(E,F)),p,X,o;try{p=l.fromBytes($,r),X=l.fromBytes(f,r),o=t.multiplyUnsafe(s)}catch{return!1}if(!r&&p.isSmallOrder())return!1;let g=i(Q,X.toBytes(),p.toBytes(),D);return X.add(p.multiplyUnsafe(g)).subtract(o).clearCofactor().is0()}let m=c.BYTES,I={secretKey:m,publicKey:m,signature:2*m,seed:m};function y(C=e(I.seed)){return Vt(C,I.seed,"seed")}function x(C){let D=j.randomSecretKey(C);return{secretKey:D,publicKey:W(D)}}function w(C){return kt(C)&&C.length===B.BYTES}function H(C,D){try{return!!l.fromBytes(C,D)}catch{return!1}}let j={getExtendedPublicKey:h,randomSecretKey:y,isValidSecretKey:w,isValidPublicKey:H,toMontgomery(C){let{y:D}=l.fromBytes(C),$=I.publicKey,K=$===32;if(!K&&$!==57)throw new Error("only defined for 25519 and 448");let Q=K?c.div(sb+D,sb-D):c.div(D-sb,D+sb);return c.toBytes(Q)},toMontgomerySecret(C){let D=I.secretKey;Vt(C,D);let $=A(C.subarray(0,D));return d($).subarray(0,D)},randomPrivateKey:y,precompute(C=8,D=l.BASE){return D.precompute(C,!1)}};return Object.freeze({keygen:x,getPublicKey:W,sign:Y,verify:V,utils:j,Point:l,lengths:I})}function D5(l){let A={a:l.a,d:l.d,p:l.Fp.ORDER,n:l.n,h:l.h,Gx:l.Gx,Gy:l.Gy},G=l.Fp,b=ut(A.n,l.nBitLength,!0),t={Fp:G,Fn:b,uvRatio:l.uvRatio},c={randomBytes:l.randomBytes,adjustScalarBytes:l.adjustScalarBytes,domain:l.domain,prehash:l.prehash,mapToCurve:l.mapToCurve};return{CURVE:A,curveOpts:t,hash:l.hash,eddsaOpts:c}}function L5(l,A){let G=A.Point;return Object.assign({},A,{ExtendedPoint:G,CURVE:l,nBitLength:G.Fn.BITS,nByteLength:G.Fn.BYTES})}function wy(l){let{CURVE:A,curveOpts:G,hash:b,eddsaOpts:t}=D5(l),c=M5(A,G),B=T5(c,b,t);return L5(l,B)}var O5=BigInt(0),cB=BigInt(1),Uy=BigInt(2),tcl=BigInt(3),P5=BigInt(5),K5=BigInt(8),ed=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Mn={p:ed,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:K5,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function q5(l){let A=BigInt(10),G=BigInt(20),b=BigInt(40),t=BigInt(80),c=ed,e=l*l%c*l%c,d=RG(e,Uy,c)*e%c,Z=RG(d,cB,c)*l%c,a=RG(Z,P5,c)*Z%c,n=RG(a,A,c)*a%c,h=RG(n,G,c)*n%c,W=RG(h,b,c)*h%c,i=RG(W,t,c)*W%c,Y=RG(i,t,c)*W%c,R=RG(Y,A,c)*a%c;return{pow_p_5_8:RG(R,Uy,c)*l%c,b2:e}}function _5(l){return l[0]&=248,l[31]&=127,l[31]|=64,l}var Bm=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function dm(l,A){let G=ed,b=IG(A*A*A,G),t=IG(b*b*A,G),c=q5(l*t).pow_p_5_8,B=IG(l*b*c,G),e=IG(A*B*B,G),d=B,Z=IG(B*Bm,G),a=e===l,n=e===IG(-l,G),h=e===IG(-l*Bm,G);return a&&(B=d),(n||h)&&(B=Z),AB(B,G)&&(B=IG(-B,G)),{isValid:a||n,value:B}}var UB=ut(Mn.p,{isLE:!0}),$5=ut(Mn.n,{isLE:!0}),lJ={...Mn,Fp:UB,hash:OW,adjustScalarBytes:_5,uvRatio:dm},Ob=wy(lJ);var em=Bm,AJ=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),GJ=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),bJ=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),tJ=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Cy=l=>dm(cB,l),cJ=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Zm=l=>Ob.Point.Fp.create(Kt(l)&cJ);function Sy(l){let{d:A}=Mn,G=ed,b=V=>UB.create(V),t=b(em*l*l),c=b((t+cB)*bJ),B=BigInt(-1),e=b((B-A*t)*b(t+A)),{isValid:d,value:Z}=dm(c,e),a=b(Z*l);AB(a,G)||(a=b(-a)),d||(Z=a),d||(B=t);let n=b(B*(t-cB)*tJ-e),h=Z*Z,W=b((Z+Z)*e),i=b(n*AJ),Y=b(cB-h),R=b(cB+h);return new Ob.Point(b(W*R),b(Y*i),b(i*R),b(W*Y))}function BJ(l){kG(l,64);let A=Zm(l.subarray(0,32)),G=Sy(A),b=Zm(l.subarray(32,64)),t=Sy(b);return new Fc(G.add(t))}var Fc=class l extends Go{constructor(A){super(A)}static fromAffine(A){return new l(Ob.Point.fromAffine(A))}assertSame(A){if(!(A instanceof l))throw new Error("RistrettoPoint expected")}init(A){return new l(A)}static hashToCurve(A){return BJ(ZG("ristrettoHash",A,64))}static fromBytes(A){kG(A,32);let{a:G,d:b}=Mn,t=ed,c=y=>UB.create(y),B=Zm(A);if(!zi(UB.toBytes(B),A)||AB(B,t))throw new Error("invalid ristretto255 encoding 1");let e=c(B*B),d=c(cB+G*e),Z=c(cB-G*e),a=c(d*d),n=c(Z*Z),h=c(G*b*a-n),{isValid:W,value:i}=Cy(c(h*n)),Y=c(i*Z),R=c(i*Y*h),V=c((B+B)*Y);AB(V,t)&&(V=c(-V));let m=c(d*R),I=c(V*m);if(!W||AB(I,t)||m===O5)throw new Error("invalid ristretto255 encoding 2");return new l(new Ob.Point(V,m,cB,I))}static fromHex(A){return l.fromBytes(ZG("ristrettoHex",A,32))}static msm(A,G){return bd(l,Ob.Point.Fn,A,G)}toBytes(){let{X:A,Y:G,Z:b,T:t}=this.ep,c=ed,B=R=>UB.create(R),e=B(B(b+G)*B(b-G)),d=B(A*G),Z=B(d*d),{value:a}=Cy(B(e*Z)),n=B(a*e),h=B(a*d),W=B(n*h*t),i;if(AB(t*W,c)){let R=B(G*em),V=B(A*em);A=R,G=V,i=B(n*GJ)}else i=h;AB(A*W,c)&&(G=B(-G));let Y=B((b-G)*i);return AB(Y,c)&&(Y=B(-Y)),UB.toBytes(Y)}equals(A){this.assertSame(A);let{X:G,Y:b}=this.ep,{X:t,Y:c}=A.ep,B=Z=>UB.create(Z),e=B(G*c)===B(b*t),d=B(b*c)===B(G*t);return e||d}is0(){return this.equals(l.ZERO)}};Fc.BASE=new Fc(Ob.Point.BASE);Fc.ZERO=new Fc(Ob.Point.ZERO);Fc.Fp=UB;Fc.Fn=$5;var KG=Fc;function fe(l,A){if(!PA||!A&&TA()){let b=PV(l);return{publicKey:b.slice(32),secretKey:b.slice(0,64)}}let G=Ob.getPublicKey(l);return{publicKey:G,secretKey:dc([l,G])}}function nm(l,{publicKey:A,secretKey:G},b){if(G){if(!A)throw new Error("Expected a valid publicKey")}else throw new Error("Expected a valid secretKey");let t=Tl(l),c=G.subarray(0,32);return!PA||!b&&TA()?KV(A,c,t):Ob.sign(t,c)}function zy(l,A,G,b){let t=Tl(l),c=Tl(G),B=Tl(A);if(c.length!==32)throw new Error(`Invalid publicKey, received ${c.length}, expected 32`);if(B.length!==64)throw new Error(`Invalid signature, received ${B.length} bytes, expected 64`);try{return!PA||!b&&TA()?qV(B,t,c):Ob.verify(B,t,c)}catch{return!1}}var jy=Ao(fe,tm);var am=kt;var Zd=Kt;var _t=Cn;var gm=Ee;var My=Xc;var eJ=BigInt(0),Tn=BigInt(1),ZJ=BigInt(2),dJ=BigInt(7),nJ=BigInt(256),aJ=BigInt(113),Ly=[],Oy=[],Py=[];for(let l=0,A=Tn,G=1,b=0;l<24;l++){[G,b]=[b,(2*G+3*b)%5],Ly.push(2*(5*b+G)),Oy.push((l+1)*(l+2)/2%64);let t=eJ;for(let c=0;c<7;c++)A=(A<<Tn^(A>>dJ)*aJ)%nJ,A&ZJ&&(t^=Tn<<(Tn<<BigInt(c))-Tn);Py.push(t)}var Ky=Ya(Py,!0),gJ=Ky[0],WJ=Ky[1],Ty=(l,A,G)=>G>32?cV(l,A,G):bV(l,A,G),Dy=(l,A,G)=>G>32?BV(l,A,G):tV(l,A,G);function om(l,A=24){let G=new Uint32Array(10);for(let b=24-A;b<24;b++){for(let B=0;B<10;B++)G[B]=l[B]^l[B+10]^l[B+20]^l[B+30]^l[B+40];for(let B=0;B<10;B+=2){let e=(B+8)%10,d=(B+2)%10,Z=G[d],a=G[d+1],n=Ty(Z,a,1)^G[e],h=Dy(Z,a,1)^G[e+1];for(let W=0;W<50;W+=10)l[B+W]^=n,l[B+W+1]^=h}let t=l[2],c=l[3];for(let B=0;B<24;B++){let e=Oy[B],d=Ty(t,c,e),Z=Dy(t,c,e),a=Ly[B];t=l[a],c=l[a+1],l[a]=d,l[a+1]=Z}for(let B=0;B<50;B+=10){for(let e=0;e<10;e++)G[e]=l[B+e];for(let e=0;e<10;e++)l[B+e]^=~G[(e+2)%10]&G[(e+4)%10]}l[0]^=gJ[b],l[1]^=WJ[b]}TG(G)}var Wm=class l extends tc{constructor(A,G,b,t=!1,c=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=A,this.suffix=G,this.outputLen=b,this.enableXOF=t,this.rounds=c,mG(b),!(0<A&&A<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=ct(this.state)}clone(){return this._cloneInto()}keccak(){Bt(this.state32),om(this.state32,this.rounds),Bt(this.state32),this.posOut=0,this.pos=0}update(A){pt(this),A=Zt(A),kG(A);let{blockLen:G,state:b}=this,t=A.length;for(let c=0;c<t;){let B=Math.min(G-this.pos,t-c);for(let e=0;e<B;e++)b[this.pos++]^=A[c++];this.pos===G&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:A,suffix:G,pos:b,blockLen:t}=this;A[b]^=G,G&128&&b===t-1&&this.keccak(),A[t-1]^=128,this.keccak()}writeInto(A){pt(this,!1),kG(A),this.finish();let G=this.state,{blockLen:b}=this;for(let t=0,c=A.length;t<c;){this.posOut>=b&&this.keccak();let B=Math.min(b-this.posOut,c-t);A.set(G.subarray(this.posOut,this.posOut+B),t),this.posOut+=B,t+=B}return A}xofInto(A){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(A)}xof(A){return mG(A),this.xofInto(new Uint8Array(A))}digestInto(A){if(qe(A,this),this.finished)throw new Error("digest() was already called");return this.writeInto(A),this.destroy(),A}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,TG(this.state)}_cloneInto(A){let{blockLen:G,suffix:b,outputLen:t,rounds:c,enableXOF:B}=this;return A||(A=new l(G,b,t,B,c)),A.state32.set(this.state32),A.pos=this.pos,A.posOut=this.posOut,A.finished=this.finished,A.rounds=c,A.suffix=b,A.outputLen=t,A.enableXOF=B,A.destroyed=this.destroyed,A}},qy=(l,A,G)=>pd(()=>new Wm(A,l,G));var bo=qy(1,136,256/8);var _y=qy(1,72,512/8);var CB=OW;var GQ=BigInt(0),bQ=BigInt(3);function hm(l){if(typeof l=="string")return Ec(l);if(am(l))return l;throw new Error("Wrong data")}function NG(l,A,...G){if(!am(A))throw new Error(`${l}: Uint8Array expected`);if(G.length&&!G.includes(A.length))throw new Error(`${l}: Uint8Array expected of length ${G}, not of length=${A.length}`)}function to(l,A){if(!Number.isSafeInteger(A)||A<0||A>4294967295)throw new Error(`${l}: wrong u32 integer: ${A}`);return A}function dd(...l){for(let A of l)A.fill(0)}var xe=Uint8Array.of(),im=Ob.CURVE.n;function $y(l,A){NG(l,A,32);let G=Zd(A);return gm(l,G,GQ,im),G}var Ln=l=>IG(l,im),Dn=166,$t={I:1,A:2,C:4,T:8,M:16,K:32},sm=class l{constructor(A){this.state=new Uint8Array(200),this.pos=0,this.posBegin=0,this.curFlags=0,this.state.set([1,Dn+2,1,0,1,96],0),this.state.set(Ec("STROBEv1.0.2"),6),this.state32=ct(this.state),this.keccakF1600(),this.metaAD(A,!1)}keccakF1600(){om(this.state32)}runF(){this.state[this.pos]^=this.posBegin,this.state[this.pos+1]^=4,this.state[Dn+1]^=128,this.keccakF1600(),this.pos=0,this.posBegin=0}absorb(A){for(let G=0;G<A.length;G++)this.state[this.pos++]^=A[G],this.pos===Dn&&this.runF()}squeeze(A){let G=new Uint8Array(A);for(let b=0;b<G.length;b++)G[b]=this.state[this.pos],this.state[this.pos++]=0,this.pos===Dn&&this.runF();return G}overwrite(A){for(let G=0;G<A.length;G++)this.state[this.pos++]=A[G],this.pos===Dn&&this.runF()}beginOp(A,G){if(G){if(this.curFlags!==A)throw new Error(`Continued op with changed flags from ${this.curFlags.toString(2)} to ${A.toString(2)}`);return}if(A&$t.T)throw new Error("T flag is not supported");let b=this.posBegin;this.posBegin=this.pos+1,this.curFlags=A,this.absorb(new Uint8Array([b,A])),(A&($t.C|$t.K))!==0&&this.pos!==0&&this.runF()}metaAD(A,G){this.beginOp($t.M|$t.A,G),this.absorb(hm(A))}AD(A,G){this.beginOp($t.A,G),this.absorb(hm(A))}PRF(A,G){return this.beginOp($t.I|$t.A|$t.C,G),this.squeeze(A)}KEY(A,G){this.beginOp($t.A|$t.C,G),this.overwrite(hm(A))}clone(){let A=new l("0");return A.pos=this.pos,A.posBegin=this.posBegin,A.state.set(this.state),A.curFlags=this.curFlags,A}clean(){this.state.fill(0),this.pos=0,this.curFlags=0,this.posBegin=0}},rm=class{constructor(A){this.strobe=new sm("Merlin v1.0"),this.appendMessage("dom-sep",A)}appendMessage(A,G){this.strobe.metaAD(A,!1),to("Merlin.appendMessage",G.length),this.strobe.metaAD(_t(G.length,4),!0),this.strobe.AD(G,!1)}challengeBytes(A,G){return this.strobe.metaAD(A,!1),to("Merlin.challengeBytes",G),this.strobe.metaAD(_t(G,4),!0),this.strobe.PRF(G,!1)}clean(){this.strobe.clean()}},BB=class extends rm{constructor(A,G=vb){super(A),this.rng=G}label(A){this.appendMessage("",A)}bytes(A){return this.appendMessage("sign-bytes",A),this}protoName(A){this.appendMessage("proto-name",A)}commitPoint(A,G){this.appendMessage(A,G.toRawBytes())}challengeScalar(A){return Ln(Zd(this.challengeBytes(A,64)))}witnessScalar(A,G=[]){return Ln(Zd(this.witnessBytes(A,64,G)))}witnessBytes(A,G,b=[]){to("SigningContext.witnessBytes",G);let t=this.strobe.clone();for(let B of b)t.metaAD(A,!1),to("SigningContext.witnessBytes nonce length",B.length),t.metaAD(_t(B.length,4),!0),t.KEY(B,!1);let c=this.rng(32);return t.metaAD("rng",!1),t.KEY(c,!1),t.metaAD(_t(G,4),!1),t.PRF(G,!1)}},oJ=My(256),tQ=l=>_t(l<<bQ&oJ,32),nd=l=>Zd(l)>>bQ;function ke(l){NG("secretKey",l,64);let A=nd(l.subarray(0,32));return KG.BASE.multiply(A).toRawBytes()}function mm(l){NG("seed",l,32);let A=CB(l);A[0]&=248,A[31]&=63,A[31]|=64;let G=tQ(nd(A.subarray(0,32))),b=A.subarray(32,64),t=VG(G,b);return dd(G,b,A),t}var cQ=Ec("substrate");function BQ(l,A,G=vb){NG("message",A),NG("secretKey",l,64);let b=new BB("SigningContext",G);b.label(cQ),b.bytes(A);let t=nd(l.subarray(0,32)),c=l.subarray(32,64),B=KG.fromHex(ke(l));b.protoName("Schnorr-sig"),b.commitPoint("sign:pk",B);let e=b.witnessScalar("signing",[c]),d=KG.BASE.multiply(e);b.commitPoint("sign:R",d);let Z=b.challengeScalar("sign:c"),a=Ln(Z*t+e),n=VG(d.toRawBytes(),_t(a,32));return n[63]|=128,b.clean(),n}function eQ(l,A,G){if(NG("message",l),NG("signature",A,64),NG("publicKey",G,32),!(A[63]&128))throw new Error("Schnorrkel marker missing");let b=Uint8Array.from(A.subarray(32,64));b[31]&=127;let t=KG.fromHex(A.subarray(0,32)),c=Zd(b);gm("s",c,GQ,im);let B=new BB("SigningContext");B.label(cQ),B.bytes(l);let e=KG.fromHex(G);if(e.equals(KG.ZERO))return!1;B.protoName("Schnorr-sig"),B.commitPoint("sign:pk",e),B.commitPoint("sign:R",t);let d=B.challengeScalar("sign:c"),Z=KG.BASE.multiply(c),a=e.negate().multiply(d).add(Z);return B.clean(),dd(b),a.equals(t)}var co={secretSoft(l,A,G=vb){NG("secretKey",l,64),NG("chainCode",A,32);let b=nd(l.subarray(0,32)),t=l.subarray(32,64),c=KG.fromHex(ke(l)),B=new BB("SchnorrRistrettoHDKD",G);B.bytes(xe),B.appendMessage("chain-code",A),B.commitPoint("public-key",c);let e=B.challengeScalar("HDKD-scalar"),d=B.challengeBytes("HDKD-chaincode",32),Z=VG(_t(b,32),t),a=B.witnessBytes("HDKD-nonce",32,[t,Z]),n=tQ(Ln(b+e)),h=VG(n,a);return dd(n,a,Z,d),B.clean(),h},publicSoft(l,A){NG("publicKey",l,32),NG("chainCode",A,32);let G=KG.fromHex(l),b=new BB("SchnorrRistrettoHDKD");b.bytes(xe),b.appendMessage("chain-code",A),b.commitPoint("public-key",G);let t=b.challengeScalar("HDKD-scalar");return b.challengeBytes("HDKD-chaincode",32),b.clean(),G.add(KG.BASE.multiply(t)).toRawBytes()},secretHard(l,A){NG("secretKey",l,64),NG("chainCode",A,32);let G=_t(nd(l.subarray(0,32)),32),b=new BB("SchnorrRistrettoHDKD");b.bytes(xe),b.appendMessage("chain-code",A),b.appendMessage("secret-key",G);let t=b.challengeBytes("HDKD-hard",32),c=b.challengeBytes("HDKD-chaincode",32);b.clean();let B=mm(t);return dd(G,t,c),b.clean(),B}},lQ={proove(l,A,G,b,t,c){b.protoName("DLEQProof"),b.commitPoint("vrf:h",t);let B=b.witnessScalar("proving\x000",[A]),e=KG.BASE.multiply(B);b.commitPoint("vrf:R=g^r",e);let d=t.multiply(B);b.commitPoint("vrf:h^r",d),b.commitPoint("vrf:pk",G),b.commitPoint("vrf:h^sk",c);let Z=b.challengeScalar("prove"),a=Ln(B-Z*l);return{proof:{c:Z,s:a},proofBatchable:{R:e,Hr:d,s:a}}},verify(l,A,G,b,t){if(l.equals(KG.ZERO))return!1;A.protoName("DLEQProof"),A.commitPoint("vrf:h",G);let c=l.multiply(t.c).add(KG.BASE.multiply(t.s));A.commitPoint("vrf:R=g^r",c);let B=b.multiply(t.c).add(G.multiply(t.s));A.commitPoint("vrf:h^r",B),A.commitPoint("vrf:pk",l),A.commitPoint("vrf:h^sk",b);let e=A.challengeScalar("prove");return t.c===e?{R:c,Hr:B,s:t.s}:!1}};function AQ(l,A,G,b,t=vb){let c=new BB("SigningContext",t);c.label(l),c.bytes(A),c.commitPoint("vrf-nm-pk",b);let B=c.challengeBytes("VRFHash",64),e=KG.hashToCurve(B),d=new BB("VRF",t);return G.length&&d.label(G),c.clean(),dd(B),{input:e,t:d}}var Bo={sign(l,A,G=xe,b=xe,t=vb){NG("msg",l),NG("secretKey",A,64),NG("ctx",G),NG("extra",b);let c=nd(A.subarray(0,32)),B=A.subarray(32,64),e=KG.fromHex(ke(A)),{input:d,t:Z}=AQ(G,l,b,e,t),a=d.multiply(c),n={input:d,output:a},{proof:h}=lQ.proove(c,B,e,Z,d,a),W=_t(h.c,32),i=_t(h.s,32),Y=VG(n.output.toRawBytes(),W,i);return dd(B,W,i),Y},verify(l,A,G,b=xe,t=xe,c=vb){NG("msg",l),NG("signature",A,96),NG("pubkey",G,32),NG("ctx",b),NG("extra",t);let B=KG.fromHex(G);if(B.equals(KG.ZERO))return!1;let e={c:$y("signature.c",A.subarray(32,64)),s:$y("signature.s",A.subarray(64,96))},{input:d,t:Z}=AQ(b,l,t,B,c),a=KG.fromHex(A.subarray(0,32));if(a.equals(KG.ZERO))throw new Error("vrf.verify: wrong output point (identity)");return lQ.verify(B,Z,d,a,e)!==!1}};function eo(l){return(A,G)=>{if(!Jb(G)||G.length!==32)throw new Error("Invalid chainCode passed to derive");let b=l(A.secretKey,G);return{publicKey:ke(b),secretKey:b}}}var ZQ=eo(co.secretHard);var dQ=eo(co.secretSoft);function nQ(l,{chainCode:A,isSoft:G}){return G?dQ(l,A):ZQ(l,A)}var hJ={ecdsa:bm,ed25519:jy,ethereum:bm,sr25519:nQ};function On(l,A,G){let b=hJ[G],t=l;for(let c of A)t=b(t,c);return t}function Pn(l){let A=Tl(l);if(A.length!==32)throw new Error(`Expected a seed matching 32 bytes, found ${A.length}`);let G=mm(A);return{publicKey:ke(G),secretKey:G}}function Vm(l,{publicKey:A,secretKey:G}){if(A?.length!==32)throw new Error("Expected a valid publicKey, 32-bytes");if(G?.length!==64)throw new Error("Expected a valid secretKey, 64-bytes");return BQ(G,Tl(l))}function aQ(l,A,G){let b=Tl(G),t=Tl(A);if(b.length!==32)throw new Error(`Invalid publicKey, received ${b.length} bytes, expected 32`);if(t.length!==64)throw new Error(`Invalid signature, received ${t.length} bytes, expected 64`);return eQ(Tl(l),t,b)}var gQ=new Uint8Array;function um(l,{secretKey:A},G=gQ,b=gQ){if(A?.length!==64)throw new Error("Invalid secretKey, expected 64-bytes");return Bo.sign(Tl(l),A,Tl(G),Tl(b),vb)}var WQ=new Uint8Array;function Ym(l,A,G,b=WQ,t=WQ){let c=Tl(G),B=Tl(A);if(c.length!==32)throw new Error("Invalid publicKey, expected 32-bytes");if(B.length!==96)throw new Error("Invalid vrfSign output, expected 96 bytes");return Bo.verify(Tl(l),B,c,Tl(b),Tl(t))}function Kn(l,A=_Z.prefix){let G=Pt(l);if(A<0||A>16383&&!sJ.includes(A)||[46,47].includes(A))throw new Error("Out of range ss58Format specified");if(!_Z.allowedDecodedLengths.includes(G.length))throw new Error(`Expected a valid key to convert, with length ${_Z.allowedDecodedLengths.join(", ")}`);let b=nG(A<64?[A]:[(A&252)>>2|64,A>>8|(A&3)<<6],G);return Ni(nG(b,SW(b).subarray(0,[32,33].includes(G.length)?2:1)))}var sJ=[29972];var zB=wa({256:Bu,512:eu},{256:bo,512:_y});function qn(l,A,G){return l==="keccak"?zB(A,void 0,G):Tb(A,void 0,void 0,G)}var Im={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",coder:ty,type:"base64",withPadding:!0},oQ=CW(Im);var Rm=wW(Im,oQ),Xm=UW(Im);function _n(l,A){if(![33,65].includes(l.length))throw new Error(`Invalid publicKey provided, received ${l.length} bytes input`);return l.length===33?l:!PA||!A&&TA()?$V(l):pc.ProjectivePoint.fromHex(l).toRawBytes(!0)}function we(l,A){if(![33,65].includes(l.length))throw new Error(`Invalid publicKey provided, received ${l.length} bytes input`);if(l.length===65)return l.subarray(1);if(!PA||!A&&TA())return lu(l).subarray(1);let{x:G,y:b}=pc.ProjectivePoint.fromHex(l);return nG(wG(G,$c),wG(b,$c))}function hQ(l,A,G,b="blake2",t){let c=Tl(A).subarray(0,64),B=Tl(l),e=!PA||!t&&TA()?Au(B,c,G):pc.Signature.fromCompact(c).addRecoveryBit(G).recoverPublicKey(B).toRawBytes();if(!e)throw new Error("Unable to recover publicKey from signature");return b==="keccak"?we(e,t):_n(e,t)}function Zo(l,{secretKey:A},G="blake2",b){if(A?.length!==32)throw new Error("Expected valid secp256k1 secretKey, 32-bytes");let t=qn(G,l,b);if(!PA||!b&&TA())return Gu(t,A);let c=pc.sign(t,A,{lowS:!0});return nG(wG(c.r,$c),wG(c.s,$c),new Uint8Array([c.recovery||0]))}var sQ="ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141".replace(/ /g,""),pm=UA(`0x${sQ}`),Fm=new FA.default(sQ,"hex");function rJ(l,A){let G=GZ(A,fi);if(G>=pm)throw new Error("Tweak parameter is out of range");if(G+=GZ(l,fi),G>=pm&&(G-=pm),G===lZ)throw new Error("Invalid resulting private key");return lh(G,$c)}function iJ(l,A){let G=new FA.default(A);if(G.cmp(Fm)>=0)throw new Error("Tweak parameter is out of range");if(G.iadd(new FA.default(l)),G.cmp(Fm)>=0&&G.isub(Fm),G.isZero())throw new Error("Invalid resulting private key");return wG(G,$c)}function ym(l,A,G){if(!Jb(l)||l.length!==32)throw new Error("Expected seckey to be an Uint8Array with length 32");if(!Jb(A)||A.length!==32)throw new Error("Expected tweak to be an Uint8Array with length 32");return!PA||G?iJ(l,A):rJ(l,A)}function rQ(l,A,G,b="blake2",t){let c=Tl(A);if(c.length!==65)throw new Error(`Expected signature with 65 bytes, ${c.length} found instead`);let B=hQ(qn(b,l),c,c[64],b,t),e=qn(b,B,t),d=Tl(G);return Mb(B,d)||(b==="keccak"?Mb(e.slice(-20),d.slice(-20)):Mb(e,d))}function mJ(l){return[33,65].includes(l.length)&&(l=zB(we(l))),l.slice(-20)}function $n(l){if(!l)return"0x";let A=Tl(l);if(![20,32,33,65].includes(A.length))throw new Error(`Invalid address or publicKey provided, received ${A.length} bytes input`);let G=nt(mJ(A),-1,!1),b=nt(zB(G),-1,!1),t="";for(let c=0;c<40;c++)t=`${t}${parseInt(b[c],16)>7?G[c].toUpperCase():G[c]}`;return`0x${t}`}var no=ye;var VJ={256:no,512:CB},uJ={256:tu,512:cu};function ao(l,A,G=256,b){let t=Tl(l);return!PA||!b&&TA()?uJ[G](t,A):Qe(VJ[G],t,A)}function iQ(l){if(!l.startsWith("m/"))return!1;let A=l.split("/").slice(1);for(let G of A){let b=/^\d+'?$/.test(G)?parseInt(G.replace(/'$/,""),10):Number.NaN;if(isNaN(b)||b>=2147483648||b<0)return!1}return!0}var YJ=uG("Bitcoin seed");function VQ(l,A){return{chainCode:A,publicKey:qt(l).publicKey,secretKey:l}}function uQ(l,A){let G=wG(A,ay),b=A>=2147483648?nG(new Uint8Array(1),l.secretKey,G):nG(l.publicKey,G);try{let t=ao(l.chainCode,b,512);return VQ(ym(l.secretKey,t.slice(0,32)),t.slice(32))}catch{return uQ(l,A+1)}}function Qm(l,A=""){let G=ao(YJ,l,512),b=VQ(G.slice(0,32),G.slice(32));if(!A||A==="m"||A==="M"||A==="m'"||A==="M'")return b;if(!iQ(A))throw new Error("Invalid derivation path");let t=A.split("/").slice(1);for(let c of t)b=uQ(b,parseInt(c,10)+(c.length>1&&c.endsWith("'")?2147483648:0));return b}function RJ(l,A,G,b){Ke(l);let t=Va({dkLen:32,asyncTick:10},b),{c,dkLen:B,asyncTick:e}=t;if(mG(c),mG(B),mG(e),c<1)throw new Error("iterations (c) should be >= 1");let d=So(A),Z=So(G),a=new Uint8Array(B),n=Qe.create(l,d),h=n._cloneInto().update(Z);return{c,dkLen:B,asyncTick:e,DK:a,PRF:n,PRFSalt:h}}function XJ(l,A,G,b,t){return l.destroy(),A.destroy(),b&&b.destroy(),TG(t),G}function la(l,A,G,b){let{c:t,dkLen:c,DK:B,PRF:e,PRFSalt:d}=RJ(l,A,G,b),Z,a=new Uint8Array(4),n=_e(a),h=new Uint8Array(e.outputLen);for(let W=1,i=0;i<c;W++,i+=e.outputLen){let Y=B.subarray(i,i+e.outputLen);n.setInt32(0,W,!1),(Z=d._cloneInto(Z)).update(a).digestInto(h),Y.set(h.subarray(0,Y.length));for(let R=1;R<t;R++){e._cloneInto(Z).update(h).digestInto(h);for(let V=0;V<Y.length;V++)Y[V]^=h[V]}}return XJ(e,d,B,Z,h)}function Aa(l,A=Bd(),G=2048,b){let t=Tl(l),c=Tl(A);return{password:!PA||!b&&TA()?Zu(t,c,G):la(CB,t,c,{c:G,dkLen:64}),rounds:G,salt:A}}var YQ=wa({256:nu,512:au},{256:no,512:CB}),Nm=nh(256,YQ);var IQ="abandon|ability|able|about|above|absent|absorb|abstract|absurd|abuse|access|accident|account|accuse|achieve|acid|acoustic|acquire|across|act|action|actor|actress|actual|adapt|add|addict|address|adjust|admit|adult|advance|advice|aerobic|affair|afford|afraid|again|age|agent|agree|ahead|aim|air|airport|aisle|alarm|album|alcohol|alert|alien|all|alley|allow|almost|alone|alpha|already|also|alter|always|amateur|amazing|among|amount|amused|analyst|anchor|ancient|anger|angle|angry|animal|ankle|announce|annual|another|answer|antenna|antique|anxiety|any|apart|apology|appear|apple|approve|april|arch|arctic|area|arena|argue|arm|armed|armor|army|around|arrange|arrest|arrive|arrow|art|artefact|artist|artwork|ask|aspect|assault|asset|assist|assume|asthma|athlete|atom|attack|attend|attitude|attract|auction|audit|august|aunt|author|auto|autumn|average|avocado|avoid|awake|aware|away|awesome|awful|awkward|axis|baby|bachelor|bacon|badge|bag|balance|balcony|ball|bamboo|banana|banner|bar|barely|bargain|barrel|base|basic|basket|battle|beach|bean|beauty|because|become|beef|before|begin|behave|behind|believe|below|belt|bench|benefit|best|betray|better|between|beyond|bicycle|bid|bike|bind|biology|bird|birth|bitter|black|blade|blame|blanket|blast|bleak|bless|blind|blood|blossom|blouse|blue|blur|blush|board|boat|body|boil|bomb|bone|bonus|book|boost|border|boring|borrow|boss|bottom|bounce|box|boy|bracket|brain|brand|brass|brave|bread|breeze|brick|bridge|brief|bright|bring|brisk|broccoli|broken|bronze|broom|brother|brown|brush|bubble|buddy|budget|buffalo|build|bulb|bulk|bullet|bundle|bunker|burden|burger|burst|bus|business|busy|butter|buyer|buzz|cabbage|cabin|cable|cactus|cage|cake|call|calm|camera|camp|can|canal|cancel|candy|cannon|canoe|canvas|canyon|capable|capital|captain|car|carbon|card|cargo|carpet|carry|cart|case|cash|casino|castle|casual|cat|catalog|catch|category|cattle|caught|cause|caution|cave|ceiling|celery|cement|census|century|cereal|certain|chair|chalk|champion|change|chaos|chapter|charge|chase|chat|cheap|check|cheese|chef|cherry|chest|chicken|chief|child|chimney|choice|choose|chronic|chuckle|chunk|churn|cigar|cinnamon|circle|citizen|city|civil|claim|clap|clarify|claw|clay|clean|clerk|clever|click|client|cliff|climb|clinic|clip|clock|clog|close|cloth|cloud|clown|club|clump|cluster|clutch|coach|coast|coconut|code|coffee|coil|coin|collect|color|column|combine|come|comfort|comic|common|company|concert|conduct|confirm|congress|connect|consider|control|convince|cook|cool|copper|copy|coral|core|corn|correct|cost|cotton|couch|country|couple|course|cousin|cover|coyote|crack|cradle|craft|cram|crane|crash|crater|crawl|crazy|cream|credit|creek|crew|cricket|crime|crisp|critic|crop|cross|crouch|crowd|crucial|cruel|cruise|crumble|crunch|crush|cry|crystal|cube|culture|cup|cupboard|curious|current|curtain|curve|cushion|custom|cute|cycle|dad|damage|damp|dance|danger|daring|dash|daughter|dawn|day|deal|debate|debris|decade|december|decide|decline|decorate|decrease|deer|defense|define|defy|degree|delay|deliver|demand|demise|denial|dentist|deny|depart|depend|deposit|depth|deputy|derive|describe|desert|design|desk|despair|destroy|detail|detect|develop|device|devote|diagram|dial|diamond|diary|dice|diesel|diet|differ|digital|dignity|dilemma|dinner|dinosaur|direct|dirt|disagree|discover|disease|dish|dismiss|disorder|display|distance|divert|divide|divorce|dizzy|doctor|document|dog|doll|dolphin|domain|donate|donkey|donor|door|dose|double|dove|draft|dragon|drama|drastic|draw|dream|dress|drift|drill|drink|drip|drive|drop|drum|dry|duck|dumb|dune|during|dust|dutch|duty|dwarf|dynamic|eager|eagle|early|earn|earth|easily|east|easy|echo|ecology|economy|edge|edit|educate|effort|egg|eight|either|elbow|elder|electric|elegant|element|elephant|elevator|elite|else|embark|embody|embrace|emerge|emotion|employ|empower|empty|enable|enact|end|endless|endorse|enemy|energy|enforce|engage|engine|enhance|enjoy|enlist|enough|enrich|enroll|ensure|enter|entire|entry|envelope|episode|equal|equip|era|erase|erode|erosion|error|erupt|escape|essay|essence|estate|eternal|ethics|evidence|evil|evoke|evolve|exact|example|excess|exchange|excite|exclude|excuse|execute|exercise|exhaust|exhibit|exile|exist|exit|exotic|expand|expect|expire|explain|expose|express|extend|extra|eye|eyebrow|fabric|face|faculty|fade|faint|faith|fall|false|fame|family|famous|fan|fancy|fantasy|farm|fashion|fat|fatal|father|fatigue|fault|favorite|feature|february|federal|fee|feed|feel|female|fence|festival|fetch|fever|few|fiber|fiction|field|figure|file|film|filter|final|find|fine|finger|finish|fire|firm|first|fiscal|fish|fit|fitness|fix|flag|flame|flash|flat|flavor|flee|flight|flip|float|flock|floor|flower|fluid|flush|fly|foam|focus|fog|foil|fold|follow|food|foot|force|forest|forget|fork|fortune|forum|forward|fossil|foster|found|fox|fragile|frame|frequent|fresh|friend|fringe|frog|front|frost|frown|frozen|fruit|fuel|fun|funny|furnace|fury|future|gadget|gain|galaxy|gallery|game|gap|garage|garbage|garden|garlic|garment|gas|gasp|gate|gather|gauge|gaze|general|genius|genre|gentle|genuine|gesture|ghost|giant|gift|giggle|ginger|giraffe|girl|give|glad|glance|glare|glass|glide|glimpse|globe|gloom|glory|glove|glow|glue|goat|goddess|gold|good|goose|gorilla|gospel|gossip|govern|gown|grab|grace|grain|grant|grape|grass|gravity|great|green|grid|grief|grit|grocery|group|grow|grunt|guard|guess|guide|guilt|guitar|gun|gym|habit|hair|half|hammer|hamster|hand|happy|harbor|hard|harsh|harvest|hat|have|hawk|hazard|head|health|heart|heavy|hedgehog|height|hello|helmet|help|hen|hero|hidden|high|hill|hint|hip|hire|history|hobby|hockey|hold|hole|holiday|hollow|home|honey|hood|hope|horn|horror|horse|hospital|host|hotel|hour|hover|hub|huge|human|humble|humor|hundred|hungry|hunt|hurdle|hurry|hurt|husband|hybrid|ice|icon|idea|identify|idle|ignore|ill|illegal|illness|image|imitate|immense|immune|impact|impose|improve|impulse|inch|include|income|increase|index|indicate|indoor|industry|infant|inflict|inform|inhale|inherit|initial|inject|injury|inmate|inner|innocent|input|inquiry|insane|insect|inside|inspire|install|intact|interest|into|invest|invite|involve|iron|island|isolate|issue|item|ivory|jacket|jaguar|jar|jazz|jealous|jeans|jelly|jewel|job|join|joke|journey|joy|judge|juice|jump|jungle|junior|junk|just|kangaroo|keen|keep|ketchup|key|kick|kid|kidney|kind|kingdom|kiss|kit|kitchen|kite|kitten|kiwi|knee|knife|knock|know|lab|label|labor|ladder|lady|lake|lamp|language|laptop|large|later|latin|laugh|laundry|lava|law|lawn|lawsuit|layer|lazy|leader|leaf|learn|leave|lecture|left|leg|legal|legend|leisure|lemon|lend|length|lens|leopard|lesson|letter|level|liar|liberty|library|license|life|lift|light|like|limb|limit|link|lion|liquid|list|little|live|lizard|load|loan|lobster|local|lock|logic|lonely|long|loop|lottery|loud|lounge|love|loyal|lucky|luggage|lumber|lunar|lunch|luxury|lyrics|machine|mad|magic|magnet|maid|mail|main|major|make|mammal|man|manage|mandate|mango|mansion|manual|maple|marble|march|margin|marine|market|marriage|mask|mass|master|match|material|math|matrix|matter|maximum|maze|meadow|mean|measure|meat|mechanic|medal|media|melody|melt|member|memory|mention|menu|mercy|merge|merit|merry|mesh|message|metal|method|middle|midnight|milk|million|mimic|mind|minimum|minor|minute|miracle|mirror|misery|miss|mistake|mix|mixed|mixture|mobile|model|modify|mom|moment|monitor|monkey|monster|month|moon|moral|more|morning|mosquito|mother|motion|motor|mountain|mouse|move|movie|much|muffin|mule|multiply|muscle|museum|mushroom|music|must|mutual|myself|mystery|myth|naive|name|napkin|narrow|nasty|nation|nature|near|neck|need|negative|neglect|neither|nephew|nerve|nest|net|network|neutral|never|news|next|nice|night|noble|noise|nominee|noodle|normal|north|nose|notable|note|nothing|notice|novel|now|nuclear|number|nurse|nut|oak|obey|object|oblige|obscure|observe|obtain|obvious|occur|ocean|october|odor|off|offer|office|often|oil|okay|old|olive|olympic|omit|once|one|onion|online|only|open|opera|opinion|oppose|option|orange|orbit|orchard|order|ordinary|organ|orient|original|orphan|ostrich|other|outdoor|outer|output|outside|oval|oven|over|own|owner|oxygen|oyster|ozone|pact|paddle|page|pair|palace|palm|panda|panel|panic|panther|paper|parade|parent|park|parrot|party|pass|patch|path|patient|patrol|pattern|pause|pave|payment|peace|peanut|pear|peasant|pelican|pen|penalty|pencil|people|pepper|perfect|permit|person|pet|phone|photo|phrase|physical|piano|picnic|picture|piece|pig|pigeon|pill|pilot|pink|pioneer|pipe|pistol|pitch|pizza|place|planet|plastic|plate|play|please|pledge|pluck|plug|plunge|poem|poet|point|polar|pole|police|pond|pony|pool|popular|portion|position|possible|post|potato|pottery|poverty|powder|power|practice|praise|predict|prefer|prepare|present|pretty|prevent|price|pride|primary|print|priority|prison|private|prize|problem|process|produce|profit|program|project|promote|proof|property|prosper|protect|proud|provide|public|pudding|pull|pulp|pulse|pumpkin|punch|pupil|puppy|purchase|purity|purpose|purse|push|put|puzzle|pyramid|quality|quantum|quarter|question|quick|quit|quiz|quote|rabbit|raccoon|race|rack|radar|radio|rail|rain|raise|rally|ramp|ranch|random|range|rapid|rare|rate|rather|raven|raw|razor|ready|real|reason|rebel|rebuild|recall|receive|recipe|record|recycle|reduce|reflect|reform|refuse|region|regret|regular|reject|relax|release|relief|rely|remain|remember|remind|remove|render|renew|rent|reopen|repair|repeat|replace|report|require|rescue|resemble|resist|resource|response|result|retire|retreat|return|reunion|reveal|review|reward|rhythm|rib|ribbon|rice|rich|ride|ridge|rifle|right|rigid|ring|riot|ripple|risk|ritual|rival|river|road|roast|robot|robust|rocket|romance|roof|rookie|room|rose|rotate|rough|round|route|royal|rubber|rude|rug|rule|run|runway|rural|sad|saddle|sadness|safe|sail|salad|salmon|salon|salt|salute|same|sample|sand|satisfy|satoshi|sauce|sausage|save|say|scale|scan|scare|scatter|scene|scheme|school|science|scissors|scorpion|scout|scrap|screen|script|scrub|sea|search|season|seat|second|secret|section|security|seed|seek|segment|select|sell|seminar|senior|sense|sentence|series|service|session|settle|setup|seven|shadow|shaft|shallow|share|shed|shell|sheriff|shield|shift|shine|ship|shiver|shock|shoe|shoot|shop|short|shoulder|shove|shrimp|shrug|shuffle|shy|sibling|sick|side|siege|sight|sign|silent|silk|silly|silver|similar|simple|since|sing|siren|sister|situate|six|size|skate|sketch|ski|skill|skin|skirt|skull|slab|slam|sleep|slender|slice|slide|slight|slim|slogan|slot|slow|slush|small|smart|smile|smoke|smooth|snack|snake|snap|sniff|snow|soap|soccer|social|sock|soda|soft|solar|soldier|solid|solution|solve|someone|song|soon|sorry|sort|soul|sound|soup|source|south|space|spare|spatial|spawn|speak|special|speed|spell|spend|sphere|spice|spider|spike|spin|spirit|split|spoil|sponsor|spoon|sport|spot|spray|spread|spring|spy|square|squeeze|squirrel|stable|stadium|staff|stage|stairs|stamp|stand|start|state|stay|steak|steel|stem|step|stereo|stick|still|sting|stock|stomach|stone|stool|story|stove|strategy|street|strike|strong|struggle|student|stuff|stumble|style|subject|submit|subway|success|such|sudden|suffer|sugar|suggest|suit|summer|sun|sunny|sunset|super|supply|supreme|sure|surface|surge|surprise|surround|survey|suspect|sustain|swallow|swamp|swap|swarm|swear|sweet|swift|swim|swing|switch|sword|symbol|symptom|syrup|system|table|tackle|tag|tail|talent|talk|tank|tape|target|task|taste|tattoo|taxi|teach|team|tell|ten|tenant|tennis|tent|term|test|text|thank|that|theme|then|theory|there|they|thing|this|thought|three|thrive|throw|thumb|thunder|ticket|tide|tiger|tilt|timber|time|tiny|tip|tired|tissue|title|toast|tobacco|today|toddler|toe|together|toilet|token|tomato|tomorrow|tone|tongue|tonight|tool|tooth|top|topic|topple|torch|tornado|tortoise|toss|total|tourist|toward|tower|town|toy|track|trade|traffic|tragic|train|transfer|trap|trash|travel|tray|treat|tree|trend|trial|tribe|trick|trigger|trim|trip|trophy|trouble|truck|true|truly|trumpet|trust|truth|try|tube|tuition|tumble|tuna|tunnel|turkey|turn|turtle|twelve|twenty|twice|twin|twist|two|type|typical|ugly|umbrella|unable|unaware|uncle|uncover|under|undo|unfair|unfold|unhappy|uniform|unique|unit|universe|unknown|unlock|until|unusual|unveil|update|upgrade|uphold|upon|upper|upset|urban|urge|usage|use|used|useful|useless|usual|utility|vacant|vacuum|vague|valid|valley|valve|van|vanish|vapor|various|vast|vault|vehicle|velvet|vendor|venture|venue|verb|verify|version|very|vessel|veteran|viable|vibrant|vicious|victory|video|view|village|vintage|violin|virtual|virus|visa|visit|visual|vital|vivid|vocal|voice|void|volcano|volume|vote|voyage|wage|wagon|wait|walk|wall|walnut|want|warfare|warm|warrior|wash|wasp|waste|water|wave|way|wealth|weapon|wear|weasel|weather|web|wedding|weekend|weird|welcome|west|wet|whale|what|wheat|wheel|when|where|whip|whisper|wide|width|wife|wild|will|win|window|wine|wing|wink|winner|winter|wire|wisdom|wise|wish|witness|wolf|woman|wonder|wood|wool|word|work|world|worry|worth|wrap|wreck|wrestle|wrist|write|wrong|yard|year|yellow|you|young|youth|zebra|zero|zone|zoo".split("|");var RQ="Invalid mnemonic",pJ="Invalid entropy",FJ="Invalid mnemonic checksum";function Em(l){return(l||"").normalize("NFKD")}function yJ(l){return parseInt(l,2)}function QJ(l){return l.map(A=>A.toString(2).padStart(8,"0")).join("")}function NJ(l){return QJ(Array.from(Nm(l))).slice(0,l.length*8/32)}function vm(l,A){return Aa(uG(Em(l)),uG(`mnemonic${Em(A)}`)).password}function Hm(l,A=IQ){let G=Em(l).split(" ");if(G.length%3!==0)throw new Error(RQ);let b=G.map(a=>{let n=A.indexOf(a);if(n===-1)throw new Error(RQ);return n.toString(2).padStart(11,"0")}).join(""),t=Math.floor(b.length/33)*32,c=b.slice(0,t),B=b.slice(t),d=c.match(/(.{1,8})/g)?.map(yJ);if(!d||d.length%4!==0||d.length<16||d.length>32)throw new Error(pJ);let Z=Tl(d);if(NJ(Z)!==B)throw new Error(FJ);return Z}function XQ(l,A){try{Hm(l,A)}catch{return!1}return!0}function pQ(l,A,G){return!PA||!A&&!G&&TA()?TV(l):Hm(l,A)}function go(l,A,G){return!PA||!A&&!G&&TA()?OV(l):XQ(l,A)}function Jm(l,A="",G,b=32){if(go(l)){if(![32,64].includes(b))throw new Error(`Invalid seed length ${b}, expected 32 or 64`)}else throw new Error("Invalid bip39 mnemonic specified");return b===32?!PA||!G&&TA()?LV(l,A):vm(l,A).subarray(0,32):vm(l,A)}function fm(l,A="",G,b){if(go(l,G,b)){if(!G&&!b&&TA())return DV(l,A)}else throw new Error("Invalid bip39 mnemonic specified");let t=pQ(l,G),c=uG(`mnemonic${A}`);return Aa(t,c).password.slice(0,32)}function Wo(l,A){return l<<A|l>>>32-A}function ad(l,A){let G=l[A+3]&255;return G=G<<8|l[A+2]&255,G=G<<8|l[A+1]&255,G<<8|l[A+0]&255}function xm(l,A,G){for(let b=0;b<4;b++)l[A+b]=G&255,G>>>=8}function EJ(l,A,G,b,t){let c=0;for(let B=0;B<t;B++)c|=l[A+B]^G[b+B];return(1&c-1>>>8)-1}function wm(l,A,G,b,t){let c=new Uint32Array(16),B=new Uint32Array(16),e=new Uint32Array(16),d=new Uint32Array(4),Z,a,n;for(Z=0;Z<4;Z++)B[5*Z]=ad(b,4*Z),B[1+Z]=ad(G,4*Z),B[6+Z]=ad(A,4*Z),B[11+Z]=ad(G,16+4*Z);for(Z=0;Z<16;Z++)e[Z]=B[Z];for(Z=0;Z<20;Z++){for(a=0;a<4;a++){for(n=0;n<4;n++)d[n]=B[(5*a+4*n)%16];for(d[1]^=Wo(d[0]+d[3]|0,7),d[2]^=Wo(d[1]+d[0]|0,9),d[3]^=Wo(d[2]+d[1]|0,13),d[0]^=Wo(d[3]+d[2]|0,18),n=0;n<4;n++)c[4*a+(a+n)%4]=d[n]}for(n=0;n<16;n++)B[n]=c[n]}if(t){for(Z=0;Z<16;Z++)B[Z]=B[Z]+e[Z]|0;for(Z=0;Z<4;Z++)B[5*Z]=B[5*Z]-ad(b,4*Z)|0,B[6+Z]=B[6+Z]-ad(A,4*Z)|0;for(Z=0;Z<4;Z++)xm(l,4*Z,B[5*Z]),xm(l,16+4*Z,B[6+Z])}else for(Z=0;Z<16;Z++)xm(l,4*Z,B[Z]+e[Z]|0)}var Um=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function vJ(l,A,G,b,t,c,B){let e=new Uint8Array(16),d=new Uint8Array(64),Z,a;if(!t)return 0;for(a=0;a<16;a++)e[a]=0;for(a=0;a<8;a++)e[a]=c[a];for(;t>=64;){for(wm(d,e,B,Um,!1),a=0;a<64;a++)l[A+a]=(G?G[b+a]:0)^d[a];for(Z=1,a=8;a<16;a++)Z=Z+(e[a]&255)|0,e[a]=Z&255,Z>>>=8;t-=64,A+=64,G&&(b+=64)}if(t>0)for(wm(d,e,B,Um,!1),a=0;a<t;a++)l[A+a]=(G?G[b+a]:0)^d[a];return 0}function Cm(l,A,G,b,t,c,B){let e=new Uint8Array(32);return wm(e,c,B,Um,!0),vJ(l,A,G,b,t,c.subarray(16),e)}function km(l,A){let G=0;for(let b=0;b<17;b++)G=G+(l[b]+A[b]|0)|0,l[b]=G&255,G>>>=8}var HJ=new Uint32Array([5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252]);function FQ(l,A,G,b,t,c){let B,e,d,Z=new Uint32Array(17),a=new Uint32Array(17),n=new Uint32Array(17),h=new Uint32Array(17),W=new Uint32Array(17);for(e=0;e<17;e++)a[e]=n[e]=0;for(e=0;e<16;e++)a[e]=c[e];for(a[3]&=15,a[4]&=252,a[7]&=15,a[8]&=252,a[11]&=15,a[12]&=252,a[15]&=15;t>0;){for(e=0;e<17;e++)h[e]=0;for(e=0;e<16&&e<t;++e)h[e]=G[b+e];for(h[e]=1,b+=e,t-=e,km(n,h),B=0;B<17;B++)for(Z[B]=0,e=0;e<17;e++)Z[B]=Z[B]+n[e]*(e<=B?a[B-e]:320*a[B+17-e]|0)|0|0;for(B=0;B<17;B++)n[B]=Z[B];for(d=0,e=0;e<16;e++)d=d+n[e]|0,n[e]=d&255,d>>>=8;for(d=d+n[16]|0,n[16]=d&3,d=5*(d>>>2)|0,e=0;e<16;e++)d=d+n[e]|0,n[e]=d&255,d>>>=8;d=d+n[16]|0,n[16]=d}for(e=0;e<17;e++)W[e]=n[e];km(n,HJ);let i=-(n[16]>>>7)|0;for(e=0;e<17;e++)n[e]^=i&(W[e]^n[e]);for(e=0;e<16;e++)h[e]=c[e+16];for(h[16]=0,km(n,h),e=0;e<16;e++)l[A+e]=n[e];return 0}function JJ(l,A,G,b,t,c){let B=new Uint8Array(16);return FQ(B,0,G,b,t,c),EJ(l,A,B,0,16)}function fJ(l,A,G,b,t){if(G<32)return-1;Cm(l,0,A,0,G,b,t),FQ(l,16,l,32,G-32,l);for(let c=0;c<16;c++)l[c]=0;return 0}function xJ(l,A,G,b,t){let c=new Uint8Array(32);if(G<32||(Cm(c,0,null,0,32,b,t),JJ(A,16,A,32,G-32,c)!==0))return-1;Cm(l,0,A,0,G,b,t);for(let B=0;B<32;B++)l[B]=0;return 0}var kJ=32,wJ=24,Sm=32,zm=16;function yQ(l,A){if(l.length!==kJ)throw new Error("bad key size");if(A.length!==wJ)throw new Error("bad nonce size")}function QQ(...l){for(let A=0,G=l.length;A<G;A++)if(!(l[A]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function NQ(l,A,G){QQ(l,A,G),yQ(G,A);let b=new Uint8Array(Sm+l.length),t=new Uint8Array(b.length);for(let c=0;c<l.length;c++)b[c+Sm]=l[c];return fJ(t,b,b.length,A,G),t.subarray(zm)}function EQ(l,A,G){QQ(l,A,G),yQ(G,A);let b=new Uint8Array(zm+l.length),t=new Uint8Array(b.length);for(let c=0;c<l.length;c++)b[c+zm]=l[c];return b.length<32||xJ(t,b,b.length,A,G)!==0?null:t.subarray(Sm)}function jm(l,A,G){return EQ(l,A,G)}function Mm(l,A,G=Bd(24)){return{encrypted:NQ(l,G,A),nonce:G}}function vQ(l,A,G,b,t,c){let B=l[A++]^G[b++],e=l[A++]^G[b++],d=l[A++]^G[b++],Z=l[A++]^G[b++],a=l[A++]^G[b++],n=l[A++]^G[b++],h=l[A++]^G[b++],W=l[A++]^G[b++],i=l[A++]^G[b++],Y=l[A++]^G[b++],R=l[A++]^G[b++],V=l[A++]^G[b++],m=l[A++]^G[b++],I=l[A++]^G[b++],y=l[A++]^G[b++],x=l[A++]^G[b++],w=B,H=e,j=d,C=Z,D=a,$=n,K=h,Q=W,r=i,F=Y,E=R,f=V,s=m,p=I,X=y,o=x;for(let g=0;g<8;g+=2)D^=qA(w+s|0,7),r^=qA(D+w|0,9),s^=qA(r+D|0,13),w^=qA(s+r|0,18),F^=qA($+H|0,7),p^=qA(F+$|0,9),H^=qA(p+F|0,13),$^=qA(H+p|0,18),X^=qA(E+K|0,7),j^=qA(X+E|0,9),K^=qA(j+X|0,13),E^=qA(K+j|0,18),C^=qA(o+f|0,7),Q^=qA(C+o|0,9),f^=qA(Q+C|0,13),o^=qA(f+Q|0,18),H^=qA(w+C|0,7),j^=qA(H+w|0,9),C^=qA(j+H|0,13),w^=qA(C+j|0,18),K^=qA($+D|0,7),Q^=qA(K+$|0,9),D^=qA(Q+K|0,13),$^=qA(D+Q|0,18),f^=qA(E+F|0,7),r^=qA(f+E|0,9),F^=qA(r+f|0,13),E^=qA(F+r|0,18),s^=qA(o+X|0,7),p^=qA(s+o|0,9),X^=qA(p+s|0,13),o^=qA(X+p|0,18);t[c++]=B+w|0,t[c++]=e+H|0,t[c++]=d+j|0,t[c++]=Z+C|0,t[c++]=a+D|0,t[c++]=n+$|0,t[c++]=h+K|0,t[c++]=W+Q|0,t[c++]=i+r|0,t[c++]=Y+F|0,t[c++]=R+E|0,t[c++]=V+f|0,t[c++]=m+s|0,t[c++]=I+p|0,t[c++]=y+X|0,t[c++]=x+o|0}function Tm(l,A,G,b,t){let c=b+0,B=b+16*t;for(let e=0;e<16;e++)G[B+e]=l[A+(2*t-1)*16+e];for(let e=0;e<t;e++,c+=16,A+=16)vQ(G,B,l,A,G,c),e>0&&(B+=16),vQ(G,c,l,A+=16,G,B)}function UJ(l,A,G){let b=Va({dkLen:32,asyncTick:10,maxmem:1073742848},G),{N:t,r:c,p:B,dkLen:e,asyncTick:d,maxmem:Z,onProgress:a}=b;if(mG(t),mG(c),mG(B),mG(e),mG(d),mG(Z),a!==void 0&&typeof a!="function")throw new Error("progressCb should be function");let n=128*c,h=n/4,W=Math.pow(2,32);if(t<=1||t&t-1||t>W)throw new Error("Scrypt: N must be larger than 1, a power of 2, and less than 2^32");if(B<0||B>(W-1)*32/n)throw new Error("Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)");if(e<0||e>(W-1)*32)throw new Error("Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32");if(n*(t+B)>Z)throw new Error("Scrypt: memused is bigger than maxMem. Expected 128 * r * (N + p) > maxmem of "+Z);let Y=la(ye,l,A,{c:1,dkLen:n*B}),R=ct(Y),V=ct(new Uint8Array(n*t)),m=ct(new Uint8Array(n)),I=()=>{};if(a){let y=2*t*B,x=Math.max(Math.floor(y/1e4),1),w=0;I=()=>{w++,a&&(!(w%x)||w===y)&&a(w/y)}}return{N:t,r:c,p:B,dkLen:e,blockSize32:h,V,B32:R,B:Y,tmp:m,blockMixCb:I,asyncTick:d}}function CJ(l,A,G,b,t){let c=la(ye,l,G,{c:1,dkLen:A});return TG(G,b,t),c}function HQ(l,A,G){let{N:b,r:t,p:c,dkLen:B,blockSize32:e,V:d,B32:Z,B:a,tmp:n,blockMixCb:h}=UJ(l,A,G);Bt(Z);for(let W=0;W<c;W++){let i=e*W;for(let Y=0;Y<e;Y++)d[Y]=Z[i+Y];for(let Y=0,R=0;Y<b-1;Y++)Tm(d,R,d,R+=e,t),h();Tm(d,(b-1)*e,Z,i,t),h();for(let Y=0;Y<b;Y++){let R=Z[i+e-16]%b;for(let V=0;V<e;V++)n[V]=Z[i+V]^d[R*e+V];Tm(n,0,Z,i,t),h()}}return Bt(Z),CJ(l,B,a,d,n)}var JQ=[{N:8192,p:10,r:8},{N:16384,p:5,r:8},{N:32768,p:3,r:8},{N:32768,p:1,r:8},{N:65536,p:2,r:8},{N:131072,p:1,r:8}],fQ={N:1<<17,p:1,r:8};function Ga(l,A=Bd(),G=fQ,b){let t=Tl(l);return{params:G,password:!PA||!b&&TA()?du(t,A,Math.log2(G.N),G.r,G.p):HQ(t,A,te({dkLen:64},G)),salt:A}}function Dm(l){if(!(l instanceof Uint8Array))throw new Error("Expected input to be a Uint8Array");if(l.length<44)throw new Error(`Invalid input length: expected 44 bytes, found ${l.length}`);let A=l.subarray(0,32),G=Hd(l.subarray(32,36),jW).toNumber(),b=Hd(l.subarray(36,40),jW).toNumber(),t=Hd(l.subarray(40,44),jW).toNumber();if(G>1<<20||b>4||t>16)throw new Error("Scrypt parameters exceed safe limits");if(!JQ.some(B=>B.N===G&&B.p===b&&B.r===t))throw new Error("Invalid injected scrypt params found");return{params:{N:G,p:b,r:t},salt:A}}function Lm(l,{N:A,p:G,r:b}){return nG(l,wG(A,MW),wG(G,MW),wG(b,MW))}var oo=["scrypt","xsalsa20-poly1305"],xQ=["none"],kQ="3";function Om(l,A,G=oo){if(l){if(G.includes("xsalsa20-poly1305")&&!A)throw new Error("Password required to decode encrypted data")}else throw new Error("No encrypted data available to decode");let b=l;if(A){let t;if(G.includes("scrypt")){let{params:c,salt:B}=Dm(l);t=Ga(A,B,c).password,l=l.subarray(44)}else t=uG(A);b=jm(l.subarray(24),l.subarray(0,24),Ko(t,256,!0))}if(!b)throw new Error("Unable to decode using the supplied passphrase");return b}function Pm(l,A,G){return{encoded:Xm(l),encoding:{content:A,type:G?oo:xQ,version:kQ}}}var UQ=l=>(A,G,b)=>rQ(A,G,b,l,!0),Km=[["ecdsa",UQ("blake2")],["ethereum",UQ("keccak")]],CQ=[["ed25519",zy],["sr25519",aQ]];function ho(l,{message:A,publicKey:G,signature:b},t=[...CQ,...Km]){return l.isValid=t.some(([c,B])=>{try{if(B(A,b,G))return l.crypto=c,!0}catch{}return!1}),l}function zJ(l,{message:A,publicKey:G,signature:b}){if(![0,1,2].includes(b[0])||![65,66].includes(b.length))throw new Error(`Unknown crypto type, expected signature prefix [0..2], found ${b[0]}`);return b.length===66?l=ho(l,{message:A,publicKey:G,signature:b.subarray(1)},Km):(l=ho(l,{message:A,publicKey:G,signature:b.subarray(1)},CQ),l.isValid||(l=ho(l,{message:A,publicKey:G,signature:b},Km)),l.isValid||(l.crypto="none")),l}function jJ(l){return[0,1,2].includes(l[0])&&[65,66].includes(l.length)?zJ:ho}function so(l,A,G){let b=Tl(A);if(![64,65,66].includes(b.length))throw new Error(`Invalid signature length, expected [64..66] bytes, found ${b.length}`);let t=Pt(G),c={message:Tl(l),publicKey:t,signature:b},B={crypto:"none",isValid:!1,isWrapped:cZ(c.message,!0),publicKey:t},e=cZ(c.message,!1),d=jJ(b);return d(B,c),B.crypto!=="none"||B.isWrapped&&!e?B:(c.message=e?_o(c.message):$o(c.message),d(B,c))}var jB=new Uint8Array([161,35,3,33,0]),gd=new Uint8Array([48,83,2,1,1,48,5,6,3,43,101,112,4,34,4,32]),SQ=32;var qm=64,zQ=32;var ba=gd.length;function jQ(l,A,G){let b=Array.isArray(G)||G===void 0?G:[G],t=Om(A,l,b),c=t.subarray(0,gd.length);if(!Mb(c,gd))throw new Error("Invalid encoding header found in body");let B=t.subarray(ba,ba+qm),e=ba+qm,d=t.subarray(e,e+jB.length);if(!Mb(d,jB)&&(e=ba+zQ,B=t.subarray(ba,e),d=t.subarray(e,e+jB.length),!Mb(d,jB)))throw new Error("Invalid encoding divider found in body");let Z=e+jB.length;return{publicKey:t.subarray(Z,Z+SQ),secretKey:B}}function MQ({publicKey:l,secretKey:A},G){if(!A)throw new Error("Expected a valid secretKey to be passed to encode");let b=nG(gd,A,jB,l);if(!G)return b;let{params:t,password:c,salt:B}=Ga(G),{encrypted:e,nonce:d}=Mm(b,c.subarray(0,32));return nG(Lm(B,t),d,e)}function TQ(l,{address:A,meta:G},b,t){return te(Pm(b,["pkcs8",l],t),{address:A,meta:G})}var MJ=new Uint8Array,TJ={ecdsa:qt,ed25519:fe,ethereum:qt,sr25519:Pn},DQ={ecdsa:new Uint8Array([2]),ed25519:new Uint8Array([0]),ethereum:new Uint8Array([2]),sr25519:new Uint8Array([1])},LQ={ecdsa:(l,A)=>Zo(l,A,"blake2"),ed25519:nm,ethereum:(l,A)=>Zo(l,A,"keccak"),sr25519:Vm},ro={ecdsa:l=>l.length>32?Tb(l):l,ed25519:l=>l,ethereum:l=>l.length===20?l:zB(we(l)),sr25519:l=>l};function ta(l){return!l||vd(l)}function OQ(l,A,G){return Tb(nG(A||"",G||"",l))}function Ue({toSS58:l,type:A},{publicKey:G,secretKey:b},t={},c=null,B){let e=(a,n)=>{let h=jQ(a,n||c,B);if(h.secretKey.length===64)G=h.publicKey,b=h.secretKey;else{let W=TJ[A](h.secretKey);G=W.publicKey,b=W.secretKey}},d=a=>(ta(b)&&c&&e(a,c),c=MQ({publicKey:G,secretKey:b},a),B=void 0,c),Z=()=>{let a=ro[A](G);return A==="ethereum"?$n(a):l(a)};return{get address(){return Z()},get addressRaw(){let a=ro[A](G);return A==="ethereum"?a.slice(-20):a},get isLocked(){return ta(b)},get meta(){return t},get publicKey(){return G},get type(){return A},decodePkcs8:e,derive:(a,n)=>{if(A==="ethereum")throw new Error("Unable to derive on this keypair");if(ta(b))throw new Error("Cannot derive on a locked keypair");let{path:h}=wn(a),W=On({publicKey:G,secretKey:b},h,A);return Ue({toSS58:l,type:A},W,n,null)},encodePkcs8:a=>d(a),lock:()=>{b=new Uint8Array},setMeta:a=>{t=te({},t,a)},sign:(a,n={})=>{if(ta(b))throw new Error("Cannot sign with a locked key pair");return nG(n.withType?DQ[A]:MJ,LQ[A](Tl(a),{publicKey:G,secretKey:b}))},toJson:a=>{let n=["ecdsa","ethereum"].includes(A)?G.length===20?nt(G):nt(_n(G)):Z();return TQ(A,{address:n,meta:t},d(a),!!a)},unlock:a=>e(a),verify:(a,n,h)=>so(a,n,ro[A](Tl(h))).isValid,vrfSign:(a,n,h)=>{if(ta(b))throw new Error("Cannot sign with a locked key pair");if(A==="sr25519")return um(a,{secretKey:b},n,h);let W=LQ[A](Tl(a),{publicKey:G,secretKey:b});return nG(OQ(W,n,h),W)},vrfVerify:(a,n,h,W,i)=>A==="sr25519"?Ym(a,n,G,W,i):so(a,nG(DQ[A],n.subarray(32)),ro[A](Tl(h))).isValid&&Mb(n.subarray(0,32),OQ(n.subarray(32),W,i))}}var PQ="bottom drive obey lake curtain smoke basket hold race lonely fit walk";var Ce,io=class{constructor(){EG(this,Ce,{})}add(A){return GA(this,Ce)[Pt(A.address).toString()]=A,A}all(){return Object.values(GA(this,Ce))}get(A){let G=GA(this,Ce)[Pt(A).toString()];if(!G)throw new Error(`Unable to retrieve keypair '${Jb(A)||ub(A)?nt(Tl(A)):A}'`);return G}remove(A){delete GA(this,Ce)[Pt(A).toString()]}};Ce=new WeakMap;var _m={ecdsa:l=>qt(l),ed25519:l=>fe(l),ethereum:l=>qt(l),sr25519:l=>Pn(l)};function DJ({publicKey:l}){return l}var yc,Ba,Wd,ca=class{constructor(A={}){EG(this,yc);EG(this,Ba);EG(this,Wd);el(this,"decodeAddress",Pt);el(this,"encodeAddress",(A,G)=>this.type==="ethereum"?$n(A):Kn(A,G??GA(this,Wd)));if(A.type=A.type||"ed25519",!["ecdsa","ethereum","ed25519","sr25519"].includes(A.type||"undefined"))throw new Error(`Expected a keyring type of either 'ed25519', 'sr25519', 'ethereum' or 'ecdsa', found '${A.type||"unknown"}`);bG(this,yc,new io),bG(this,Wd,A.ss58Format),bG(this,Ba,A.type)}get pairs(){return this.getPairs()}get publicKeys(){return this.getPublicKeys()}get type(){return GA(this,Ba)}addPair(A){return GA(this,yc).add(A)}addFromAddress(A,G={},b=null,t=this.type,c,B){let e=this.decodeAddress(A,c);return this.addPair(Ue({toSS58:this.encodeAddress,type:t},{publicKey:e,secretKey:new Uint8Array},G,b,B))}addFromJson(A,G){return this.addPair(this.createFromJson(A,G))}addFromMnemonic(A,G={},b=this.type,t){return this.addFromUri(A,G,b,t)}addFromPair(A,G={},b=this.type){return this.addPair(this.createFromPair(A,G,b))}addFromSeed(A,G={},b=this.type){return this.addPair(Ue({toSS58:this.encodeAddress,type:b},_m[b](A),G,null))}addFromUri(A,G={},b=this.type,t){return this.addPair(this.createFromUri(A,G,b,t))}createFromJson({address:A,encoded:G,encoding:{content:b,type:t,version:c},meta:B},e){if(c==="3"&&b[0]!=="pkcs8")throw new Error(`Unable to decode non-pkcs8 type, [${b.join(",")}] found}`);let d=c==="0"||!Array.isArray(b)?this.type:b[1],Z=Array.isArray(t)?t:[t];if(!["ed25519","sr25519","ecdsa","ethereum"].includes(d))throw new Error(`Unknown crypto type ${d}`);let a=ub(A)?Hb(A):this.decodeAddress(A,e),n=ub(G)?Hb(G):Rm(G);return Ue({toSS58:this.encodeAddress,type:d},{publicKey:a,secretKey:new Uint8Array},B,n,Z)}createFromPair(A,G={},b=this.type){return Ue({toSS58:this.encodeAddress,type:b},A,G,null)}createFromUri(A,G={},b=this.type,t){let c=A.startsWith("//")?`${PQ}${A}`:A,{derivePath:B,password:e,path:d,phrase:Z}=ki(c),a,n=ub(Z,256);if(n)a=Hb(Z);else{let W=Z.split(" ");if([12,15,18,21,24].includes(W.length))a=b==="ethereum"?Jm(Z,"",!1,64):fm(Z,e,t);else{if(Z.length>32)throw new Error("specified phrase is not a valid mnemonic and is invalid as a raw seed at > 32 bytes");a=uG(Z.padEnd(32))}}let h=b==="ethereum"?n?_m[b](a):Qm(a,B.substring(1)):On(_m[b](a),d,b);return Ue({toSS58:this.encodeAddress,type:b},h,G,null)}getPair(A){return GA(this,yc).get(A)}getPairs(){return GA(this,yc).all()}getPublicKeys(){return GA(this,yc).all().map(DJ)}removePair(A){GA(this,yc).remove(A)}setSS58Format(A){bG(this,Wd,A)}toJson(A,G){return GA(this,yc).get(A).toJson(G)}};yc=new WeakMap,Ba=new WeakMap,Wd=new WeakMap;var od=class{constructor(A){el(this,"token");if(this.token=A,!A)throw new Error("DelegationAuthProvider requires a non-empty delegation token")}async authenticate(A){let G={Authorization:`Bearer ${this.token}`};return A.body===void 0?{headers:G}:(G["Content-Type"]="application/json",{headers:G,body:new TextEncoder().encode(JSON.stringify(A.body))})}};var KJ="cef-widget:identity-request",qJ="cef-widget:identity-response",_J="cef-widget:sign-request",$J="cef-widget:sign-response";var $Q="unsupported-version";var hd=class extends Error{constructor(A){super(`WidgetProtocolVersionError: ${A}`),this.name="WidgetProtocolVersionError"}},mo=class extends Error{constructor(A){super(`WidgetMalformedMessageError: ${A}`),this.name="WidgetMalformedMessageError"}};function lN(l){return l!==void 0&&l!==1}function lf(l){if(!Array.isArray(l)||l.length>65536)return!1;for(let A=0;A<l.length;A++){if(!(A in l))return!1;let G=l[A];if(typeof G!="number"||!Number.isInteger(G)||G<0||G>255)return!1}return!0}var _Q=!1,sd=new Map;function AN(){_Q||(_Q=!0,window.addEventListener("message",l=>{if(l.source!==window.parent)return;let A=l.data;if(!A||typeof A!="object")return;let{type:G,requestId:b}=A;if(typeof b!="string"||G!==qJ&&G!==$J)return;let t=sd.get(b);t&&(sd.delete(b),t.resolve(A))}))}function GN(){return`${Date.now()}-${Math.random().toString(36).slice(2)}`}var $m;async function Af(){if(window.parent===window)return null;if($m!==void 0)return $m;AN();let l=400,A=8e3,G=Date.now()+A;return new Promise((b,t)=>{let c=!1,B,e,d=new Set;function Z(){c=!0,B!==void 0&&(clearTimeout(B),B=void 0),e!==void 0&&(clearTimeout(e),e=void 0);for(let h of d)sd.delete(h);d.clear()}function a(){if(c)return;let h=GN();d.add(h),sd.set(h,{resolve:W=>{if(c)return;let i=W;if(lN(i.v)){Z(),t(new hd(`the host replied in protocol v${String(i.v)}; this build speaks v1`));return}if(i.errorCode===$Q){Z(),t(new hd(`the host rejected protocol v1 (${i.error??"no detail"})`));return}if(i.error||!i.pubkey){n();return}let Y={pubkey:i.pubkey,sigType:i.sigType??"ed25519",...i.token?{token:i.token}:{},...i.context?{context:i.context}:{}};Z(),$m=Y,b(Y)},reject:()=>{c||n()}}),window.parent.postMessage({type:KJ,requestId:h,v:1},"*"),n()}function n(){if(c)return;B!==void 0&&(clearTimeout(B),B=void 0);let h=G-Date.now();if(h<=0){Z(),b(null);return}B=setTimeout(()=>{c||a()},Math.min(l,h))}a(),e=setTimeout(()=>{c||(Z(),b(null))},A+l)})}async function Gf(l){if(window.parent===window)throw new Error("sign called outside of an iframe");if(l.length>65536)throw new mo(`sign-request.bytes is ${l.length} bytes; the contract caps it at 65536`);AN();let A=6e4,G=GN();return new Promise((b,t)=>{let c=setTimeout(()=>{sd.delete(G),t(new Error("widget signing timed out \u2014 the host page may have closed the widget"))},A);sd.set(G,{resolve:B=>{clearTimeout(c);let e=B;lN(e.v)?t(new hd(`the host replied in protocol v${String(e.v)}; this build speaks v1`)):e.errorCode===$Q?t(new hd(`the host rejected protocol v1 (${e.error??"no detail"})`)):e.error?t(new Error(e.error)):e.signature===null?t(new Error("widget signing was declined")):lf(e.signature)?b(Uint8Array.from(e.signature)):t(new mo("sign-response.signature must be null or an array of integers 0-255"))},reject:B=>{clearTimeout(c),t(B)}}),window.parent.postMessage({type:_J,requestId:G,v:1,bytes:Array.from(l)},"*")})}function bN(){return{requestIdentity:Af,sign:Gf}}var bf=54;function l2(l,A,G){return{type:A,address:Kn(Hb(l),bf),publicKey:Hb(l),isReady:async()=>!0,sign:b=>G(b)}}var ZN=po(BN(),1);var eN=["private_key","ed25519_private_key","eth_private_key"];function tf(l){let A=l.trim().replace(/^0x/i,"");return/^[0-9a-fA-F]{64,}$/.test(A)?"0x"+A.slice(0,64).toLowerCase():null}async function cf(l){for(let A of eN)try{let G=await l.request({method:A});if(typeof G!="string")continue;let b=tf(G);if(b)return b}catch{}throw new Error("standalone wallet: could not extract embed-wallet seed. Tried: "+eN.join(", "))}function Bf(l){return l.startsWith("0x")?l:`0x${l}`}async function dN(l){await PF();let A=new ZN.EmbedWallet({appId:l.appId,env:l.env});await A.init({appId:l.appId,env:l.env,popupMode:"modal"}),await A.connect();let b=await A.getSigner({type:"ed25519"}).getAccount(),t=Bf(b.publicKey).toLowerCase(),c=await cf(A.provider),e=new ca({type:"ed25519"}).addFromSeed(Hb(c)),d=nt(e.publicKey);if(d!==t)throw new Error(`[widget-runtime] standalone wallet: derived pubkey (${d}) does not match the wallet's pubkey (${t}) \u2014 refusing to sign.`);return{pubkey:()=>t,sigType:"ed25519",signRawBytes:async Z=>e.sign(Z)}}var iG=class extends Error{constructor(l,A,G,b){super(A?`${l}: ${A}`:l),this.code=l,this.detail=A,this.traceId=G,this.status=b,this.name="WalletError"}toJSON(){return{name:this.name,code:this.code,detail:this.detail,traceId:this.traceId,message:this.message}}};function ef(l){if(l.length>=255)throw new TypeError("Alphabet too long");let A=new Uint8Array(256);for(let Z=0;Z<A.length;Z++)A[Z]=255;for(let Z=0;Z<l.length;Z++){let a=l.charAt(Z),n=a.charCodeAt(0);if(A[n]!==255)throw new TypeError(a+" is ambiguous");A[n]=Z}let G=l.length,b=l.charAt(0),t=Math.log(G)/Math.log(256),c=Math.log(256)/Math.log(G);function B(Z){if(Z instanceof Uint8Array||(ArrayBuffer.isView(Z)?Z=new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength):Array.isArray(Z)&&(Z=Uint8Array.from(Z))),!(Z instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(Z.length===0)return"";let a=0,n=0,h=0,W=Z.length;for(;h!==W&&Z[h]===0;)h++,a++;let i=(W-h)*c+1>>>0,Y=new Uint8Array(i);for(;h!==W;){let m=Z[h],I=0;for(let y=i-1;(m!==0||I<n)&&y!==-1;y--,I++)m+=256*Y[y]>>>0,Y[y]=m%G>>>0,m=m/G>>>0;if(m!==0)throw new Error("Non-zero carry");n=I,h++}let R=i-n;for(;R!==i&&Y[R]===0;)R++;let V=b.repeat(a);for(;R<i;++R)V+=l.charAt(Y[R]);return V}function e(Z){if(typeof Z!="string")throw new TypeError("Expected String");if(Z.length===0)return new Uint8Array;let a=0,n=0,h=0;for(;Z[a]===b;)n++,a++;let W=(Z.length-a)*t+1>>>0,i=new Uint8Array(W);for(;a<Z.length;){let m=Z.charCodeAt(a);if(m>255)return;let I=A[m];if(I===255)return;let y=0;for(let x=W-1;(I!==0||y<h)&&x!==-1;x--,y++)I+=G*i[x]>>>0,i[x]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");h=y,a++}let Y=W-h;for(;Y!==W&&i[Y]===0;)Y++;let R=new Uint8Array(n+(W-Y)),V=n;for(;Y!==W;)R[V++]=i[Y++];return R}function d(Z){let a=e(Z);if(a)return a;throw new Error("Non-base"+G+" character")}return{encode:B,decodeUnsafe:e,decode:d}}var nN=ef;var Zf="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",aN=nN(Zf);var Lal=new Uint8Array([241,55,252,128,200,121,231,173,149,167,104,105,124,215,6,125,113,218,113,114,238,51,232,185,156,209,26,46,78,6,58,137]);var Oal=new TextEncoder().encode("SS58PRE");function gN(l){let A=aN.decode(l);if(A.length!==32)throw new Error(`expected a 32-byte Ed25519 pubkey from the Solana address, got ${A.length}`);return A}var df="cere-wallet-root-wrap-v1",nf="v1",Pal={[nf]:df};var rd=(l,A,G)=>new Promise((b,t)=>{var c=d=>{try{e(G.next(d))}catch(Z){t(Z)}},B=d=>{try{e(G.throw(d))}catch(Z){t(Z)}},e=d=>d.done?b(d.value):Promise.resolve(d.value).then(c,B);e((G=G.apply(l,A)).next())}),hN=class{constructor(l){this.chain="evm",this.address=l.address,this.sign=l.sign}getAddress(){return rd(this,null,function*(){return this.address})}signMessage(l){return rd(this,null,function*(){let A=WN(l),G=yield this.sign("evm",A),b=G.slice(0,32),t=G.slice(32,64),c=G[64]+27;return"0x"+oN(b)+oN(t)+c.toString(16).padStart(2,"0")})}signMessageRaw(l){return rd(this,null,function*(){let A=WN(l);return this.sign("evm",A)})}};function WN(l){let A=typeof l=="string"?new TextEncoder().encode(l):l,G=new TextEncoder().encode(`Ethereum Signed Message:
305
+ `),bZ=Tl("<Bytes>"),tZ=Tl("</Bytes>"),DE=bZ.length+tZ.length;function cZ(l,A){return l.length>=DE&&Mb(l.subarray(0,bZ.length),bZ)&&Mb(l.slice(-tZ.length),tZ)||A&&l.length>=va.length&&Mb(l.subarray(0,va.length),va)}function _o(l){let A=Tl(l);return cZ(A,!1)?A.subarray(bZ.length,A.length-tZ.length):A}function $o(l){let A=Tl(l);return cZ(A,!0)?A:dc([bZ,A,tZ])}var yV=UA(256),LE=UA(255);function OE(l,A,G){let b=[],t=G&&l<lZ;for(t&&(l=(l+AZ)*-AZ);l!==lZ;){let c=l%yV,B=Number(t?c^LE:c);A?b.push(B):b.unshift(B),l=(l-c)/yV}return Uint8Array.from(b)}function lh(l,{bitLength:A=-1,isLe:G=!0,isNegative:b=!1}={}){let t=RV(l);if(t===lZ)return A===-1?new Uint8Array(1):new Uint8Array(Math.ceil((A||0)/8));let c=OE(t,G,b);if(A===-1)return c;let B=Math.ceil((A||0)/8),e=new Uint8Array(B);return b&&e.fill(255),e.set(c,G?0:B-c.length),e}function QV(l){if(!l||l==="0x")return"";if(Po.test(l))return l.substring(2);if(YV.test(l))return l;throw new Error(`Expected hex value to convert, found '${l}'`)}function NV(l,{isLe:A=!1,isNegative:G=!1}={}){if(!l||l==="0x")return new FA.default(0);let b=QV(l),t=new FA.default(b,16,A?"le":"be");return G?t.fromTwos(b.length*4):t}var Jd=new FA.default(1),fd=new FA.default(2);var EV=new FA.default(1e9),jw=EV.mul(EV),Mw=new FA.default(Number.MAX_SAFE_INTEGER);function xd(l){return typeof l=="bigint"}function kd(l){return l?FA.default.isBN(l)?l:ub(l)?NV(l.toString()):xd(l)?new FA.default(l.toString()):Qa(l)?l.toBn():ya(l)?new FA.default(l.toBigInt().toString()):new FA.default(l):new FA.default(0)}var PE={bitLength:-1,isLe:!0,isNegative:!1};function wG(l,{bitLength:A=-1,isLe:G=!0,isNegative:b=!1}=PE){let t=kd(l),c=Math.ceil(A===-1?t.bitLength()/8:(A||0)/8);if(!l)return A===-1?new Uint8Array(1):new Uint8Array(c);let B=new Uint8Array(c),e=b?t.toTwos(c*8):t;return B.set(e.toArray(G?"le":"be",c),0),B}var KE=fd.pow(new FA.default(6)).isub(Jd),qE=fd.pow(new FA.default(14)).isub(Jd),_E=fd.pow(new FA.default(30)).isub(Jd),$E={bitLength:16},lv={bitLength:32};function vV(l){let A=kd(l);if(A.lte(KE))return new Uint8Array([A.toNumber()<<2]);if(A.lte(qE))return wG(A.shln(2).iadd(Jd),$E);if(A.lte(_E))return wG(A.shln(2).iadd(fd),lv);let G=wG(A),b=G.length;for(;G[b-1]===0;)b--;if(b<4)throw new Error("Invalid length, previous checks match anything less than 2^30");return dc([new Uint8Array([(b-4<<2)+3]),G.subarray(0,b)])}function be(l){return dc([vV(l.length),l])}function Ah(l){return typeof l=="string"||l instanceof String}function Gh(l){return typeof l=="number"}function te(l,...A){let G=new Set(["__proto__","constructor","prototype"]);for(let b=0,t=A.length;b<t;b++){let c=A[b];if(c)if(typeof c.entries=="function")for(let[B,e]of c.entries())G.has(B)||(l[B]=e);else{let B=Object.create(null);for(let[e,d]of Object.entries(c))G.has(e)||(B[e]=d);Object.assign(l,B)}}return l}var Av=Zc.crypto;function Ha(l){return Av.getRandomValues(l)}var Ja={getRandomValues:Ha},Gv={crypto:Ja},Ft,fa=class{constructor(A){EG(this,Ft);el(this,"abort",()=>{throw new Error("abort")});el(this,"__wbindgen_is_undefined",A=>GA(this,Ft).getObject(A)===void 0);el(this,"__wbindgen_throw",(A,G)=>{throw new Error(GA(this,Ft).getString(A,G))});el(this,"__wbg_self_1b7a39e3a92c949c",()=>GA(this,Ft).addObject(Gv));el(this,"__wbg_require_604837428532a733",(A,G)=>{throw new Error(`Unable to require ${GA(this,Ft).getString(A,G)}`)});el(this,"__wbg_crypto_968f1772287e2df0",A=>GA(this,Ft).addObject(Ja));el(this,"__wbg_getRandomValues_a3d34b4fee3c2869",A=>GA(this,Ft).addObject(Ja.getRandomValues));el(this,"__wbg_getRandomValues_f5e14ab7ac8e995d",(A,G,b)=>{Ja.getRandomValues(GA(this,Ft).getU8a(G,b))});el(this,"__wbg_randomFillSync_d5bd2d655fdf256a",(A,G,b)=>{throw new Error("randomFillsync is not available")});el(this,"__wbindgen_object_drop_ref",A=>{GA(this,Ft).takeObject(A)});bG(this,Ft,A)}};Ft=new WeakMap;var wd,yt,Ud,sB,rB,Hc,at,BZ,ce,eZ,xa=class{constructor(A){EG(this,wd);EG(this,yt);EG(this,Ud);EG(this,sB);EG(this,rB);EG(this,Hc);EG(this,at);EG(this,BZ);EG(this,ce);EG(this,eZ);bG(this,wd,A),bG(this,sB,null),bG(this,rB,null),bG(this,yt,new Array(32).fill(void 0).concat(void 0,null,!0,!1)),bG(this,Hc,GA(this,yt).length),bG(this,eZ,"none"),bG(this,at,null),bG(this,BZ,null),bG(this,ce,null),bG(this,Ud,{...new fa(this)})}get error(){return GA(this,BZ)}get type(){return GA(this,eZ)}get wasm(){return GA(this,at)}async init(A){(!GA(this,ce)||A)&&bG(this,ce,(A||GA(this,wd))(GA(this,Ud)));let{error:G,type:b,wasm:t}=await GA(this,ce);return bG(this,eZ,b),bG(this,at,t),bG(this,BZ,G),GA(this,at)}getObject(A){return GA(this,yt)[A]}dropObject(A){A<36||(GA(this,yt)[A]=GA(this,Hc),bG(this,Hc,A))}takeObject(A){let G=this.getObject(A);return this.dropObject(A),G}addObject(A){GA(this,Hc)===GA(this,yt).length&&GA(this,yt).push(GA(this,yt).length+1);let G=GA(this,Hc);return bG(this,Hc,GA(this,yt)[G]),GA(this,yt)[G]=A,G}getInt32(){return(GA(this,sB)===null||GA(this,sB).buffer!==GA(this,at).memory.buffer)&&bG(this,sB,new Int32Array(GA(this,at).memory.buffer)),GA(this,sB)}getUint8(){return(GA(this,rB)===null||GA(this,rB).buffer!==GA(this,at).memory.buffer)&&bG(this,rB,new Uint8Array(GA(this,at).memory.buffer)),GA(this,rB)}getU8a(A,G){return this.getUint8().subarray(A/1,A/1+G)}getString(A,G){return Ea(this.getU8a(A,G))}allocU8a(A){let G=GA(this,at).__wbindgen_malloc(A.length*1);return this.getUint8().set(A,G/1),[G,A.length]}allocString(A){return this.allocU8a(uG(A))}resultU8a(){let A=this.getInt32()[2],G=this.getInt32()[8/4+1],b=this.getU8a(A,G).slice();return GA(this,at).__wbindgen_free(A,G*1),b}resultString(){return Ea(this.resultU8a())}};wd=new WeakMap,yt=new WeakMap,Ud=new WeakMap,sB=new WeakMap,rB=new WeakMap,Hc=new WeakMap,at=new WeakMap,BZ=new WeakMap,ce=new WeakMap,eZ=new WeakMap;function HV(l,A,G){return async b=>{let t={error:null,type:"none",wasm:null};try{if(A?.length){if(typeof WebAssembly!="object"||typeof WebAssembly.instantiate!="function")throw new Error("WebAssembly is not available in your environment")}else throw new Error("No WebAssembly provided for initialization");let c=await WebAssembly.instantiate(A,{wbg:b});t.wasm=c.instance.exports,t.type="wasm"}catch(c){typeof G=="function"?(t.wasm=G(b),t.type="asm"):(t.error=`FATAL: Unable to initialize @polkadot/wasm-${l}:: ${c.message}`,console.error(t.error))}return t}}var JV="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fV=new Array(256);for(let l=0,A=JV.length;l<A;l++)fV[JV.charCodeAt(l)]=l;function bh(l,A){let G=0,b=0,t=-1;for(let c=0,B=A.length-1;t!==B;c++)G=G<<6|fV[l.charCodeAt(c)],(b+=6)>=8&&(A[++t]=G>>>(b-=8)&255);return A}var nc=Uint8Array,iB=Uint16Array,Bh=Uint32Array,bv=new nc([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xV=new nc([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),kV=new nc([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),wV=(l,A)=>{let G=new iB(31);for(let t=0;t<31;++t)G[t]=A+=1<<l[t-1];let b=new Bh(G[30]);for(let t=1;t<30;++t)for(let c=G[t];c<G[t+1];++c)b[c]=c-G[t]<<5|t;return[G,b]},[UV,tv]=wV(xV,2);UV[28]=258,tv[258]=28;var[cv]=wV(kV,0),eh=new iB(32768);for(let l=0;l<32768;++l){let A=(l&43690)>>>1|(l&21845)<<1;A=(A&52428)>>>2|(A&13107)<<2,A=(A&61680)>>>4|(A&3855)<<4,eh[l]=((A&65280)>>>8|(A&255)<<8)>>>1}var Cd=(l,A,G)=>{let b=l.length,t=0,c=new iB(A);for(;t<b;++t)l[t]&&++c[l[t]-1];let B=new iB(A);for(t=1;t<A;++t)B[t]=B[t-1]+c[t-1]<<1;let e;if(G){e=new iB(1<<A);let d=15-A;for(t=0;t<b;++t)if(l[t]){let Z=t<<4|l[t],a=A-l[t],n=B[l[t]-1]++<<a;for(let h=n|(1<<a)-1;n<=h;++n)e[eh[n]>>d]=Z}}else for(e=new iB(b),t=0;t<b;++t)l[t]&&(e[t]=eh[B[l[t]-1]++]>>15-l[t]);return e},Sd=new nc(288);for(let l=0;l<144;++l)Sd[l]=8;for(let l=144;l<256;++l)Sd[l]=9;for(let l=256;l<280;++l)Sd[l]=7;for(let l=280;l<288;++l)Sd[l]=8;var CV=new nc(32);for(let l=0;l<32;++l)CV[l]=5;var Bv=Cd(Sd,9,1),ev=Cd(CV,5,1),Ut=(l,A,G)=>{let b=A>>>3;return(l[b]|l[b+1]<<8)>>>(A&7)&G},th=(l,A)=>{let G=A>>>3;return(l[G]|l[G+1]<<8|l[G+2]<<16)>>>(A&7)},Zv=l=>(l>>>3)+(l&7&&1),dv=(l,A,G)=>{(A==null||A<0)&&(A=0),(G==null||G>l.length)&&(G=l.length);let b=new(l instanceof iB?iB:l instanceof Bh?Bh:nc)(G-A);return b.set(l.subarray(A,G)),b},ch=l=>{let A=l[0];for(let G=1,b=l.length;G<b;++G)l[G]>A&&(A=l[G]);return A},nv=(l,A,G)=>{let b=!G||G.i;G||(G={});let t=l.length,c=!A||!b;A||(A=new nc(t*3));let B=Y=>{let R=A.length;if(Y>R){let V=new nc(Math.max(R<<1,Y));V.set(A),A=V}},e=G.f||0,d=G.p||0,Z=G.b||0,a=G.l,n=G.d,h=G.m,W=G.n;if(e&&!a)return A;let i=t<<3;do{if(!a){G.f=e=Ut(l,d,1);let m=Ut(l,d+1,3);if(d+=3,m)if(m==1)a=Bv,n=ev,h=9,W=5;else if(m==2){let I=Ut(l,d,31)+257,y=Ut(l,d+10,15)+4,x=I+Ut(l,d+5,31)+1;d+=14;let w=new nc(x),H=new nc(19);for(let Q=0;Q<y;++Q)H[bv[Q]]=Ut(l,d+Q*3,7);d+=y*3;let j=ch(H),C=(1<<j)-1;if(!b&&d+x*(j+7)>i)break;let D=Cd(H,j,1);for(let Q=0;Q<x;){let r=D[Ut(l,d,C)];d+=r&15;let F=r>>>4;if(F<16)w[Q++]=F;else{let E=0,f=0;for(F==16?(f=3+Ut(l,d,3),d+=2,E=w[Q-1]):F==17?(f=3+Ut(l,d,7),d+=3):F==18&&(f=11+Ut(l,d,127),d+=7);f--;)w[Q++]=E}}let $=w.subarray(0,I),K=w.subarray(I);h=ch($),W=ch(K),a=Cd($,h,1),n=Cd(K,W,1)}else throw"invalid block type";else{let I=Zv(d)+4,y=l[I-4]|l[I-3]<<8,x=I+y;if(x>t){if(b)throw"unexpected EOF";break}c&&B(Z+y),A.set(l.subarray(I,x),Z),G.b=Z+=y,G.p=d=x<<3;continue}if(d>i)throw"unexpected EOF"}c&&B(Z+131072);let Y=(1<<h)-1,R=(1<<W)-1,V=h+W+18;for(;b||d+V<i;){let m=a[th(l,d)&Y],I=m>>>4;if(d+=m&15,d>i)throw"unexpected EOF";if(!m)throw"invalid length/literal";if(I<256)A[Z++]=I;else if(I==256){a=void 0;break}else{let y=I-254;if(I>264){let C=I-257,D=xV[C];y=Ut(l,d,(1<<D)-1)+UV[C],d+=D}let x=n[th(l,d)&R],w=x>>>4;if(!x)throw"invalid distance";d+=x&15;let H=cv[w];if(w>3){let C=kV[w];H+=th(l,d)&(1<<C)-1,d+=C}if(d>i)throw"unexpected EOF";c&&B(Z+131072);let j=Z+y;for(;Z<j;Z+=4)A[Z]=A[Z-H],A[Z+1]=A[Z+1-H],A[Z+2]=A[Z+2-H],A[Z+3]=A[Z+3-H];Z=j}}G.l=a,G.p=d,G.b=Z,a&&(e=1,G.m=h,G.d=n,G.n=W)}while(!e);return Z==A.length?A:dv(A,0,Z)},av=l=>{if((l[0]&15)!=8||l[0]>>>4>7||(l[0]<<8|l[1])%31)throw"invalid zlib data";if(l[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Zh(l,A){return nv((av(l),l.subarray(2,-4)),A)}var ZZ=po(SV(),1);var zV=Zh(bh(ZZ.bytes,new Uint8Array(ZZ.lenIn)),new Uint8Array(ZZ.lenOut));var jV=HV("crypto",zV,null);var cA=new xa(jV);async function MV(l){return cA.init(l)}function UG(l){return(...A)=>{if(!cA.wasm)throw new Error("The WASM interface has not been initialized. Ensure that you wait for the initialization Promise with waitReady() from @polkadot/wasm-crypto (or cryptoWaitReady() from @polkadot/util-crypto) before attempting to use WASM-only interfaces.");return l(cA.wasm,...A)}}var TV=UG((l,A)=>(l.ext_bip39_to_entropy(8,...cA.allocString(A)),cA.resultU8a())),DV=UG((l,A,G)=>(l.ext_bip39_to_mini_secret(8,...cA.allocString(A),...cA.allocString(G)),cA.resultU8a())),LV=UG((l,A,G)=>(l.ext_bip39_to_seed(8,...cA.allocString(A),...cA.allocString(G)),cA.resultU8a())),OV=UG((l,A)=>l.ext_bip39_validate(...cA.allocString(A))!==0),PV=UG((l,A)=>(l.ext_ed_from_seed(8,...cA.allocU8a(A)),cA.resultU8a())),KV=UG((l,A,G,b)=>(l.ext_ed_sign(8,...cA.allocU8a(A),...cA.allocU8a(G),...cA.allocU8a(b)),cA.resultU8a())),qV=UG((l,A,G,b)=>l.ext_ed_verify(...cA.allocU8a(A),...cA.allocU8a(G),...cA.allocU8a(b))!==0),_V=UG((l,A)=>(l.ext_secp_from_seed(8,...cA.allocU8a(A)),cA.resultU8a())),$V=UG((l,A)=>(l.ext_secp_pub_compress(8,...cA.allocU8a(A)),cA.resultU8a())),lu=UG((l,A)=>(l.ext_secp_pub_expand(8,...cA.allocU8a(A)),cA.resultU8a())),Au=UG((l,A,G,b)=>(l.ext_secp_recover(8,...cA.allocU8a(A),...cA.allocU8a(G),b),cA.resultU8a())),Gu=UG((l,A,G)=>(l.ext_secp_sign(8,...cA.allocU8a(A),...cA.allocU8a(G)),cA.resultU8a()));var bu=UG((l,A,G,b)=>(l.ext_blake2b(8,...cA.allocU8a(A),...cA.allocU8a(G),b),cA.resultU8a())),tu=UG((l,A,G)=>(l.ext_hmac_sha256(8,...cA.allocU8a(A),...cA.allocU8a(G)),cA.resultU8a())),cu=UG((l,A,G)=>(l.ext_hmac_sha512(8,...cA.allocU8a(A),...cA.allocU8a(G)),cA.resultU8a())),Bu=UG((l,A)=>(l.ext_keccak256(8,...cA.allocU8a(A)),cA.resultU8a())),eu=UG((l,A)=>(l.ext_keccak512(8,...cA.allocU8a(A)),cA.resultU8a())),Zu=UG((l,A,G,b)=>(l.ext_pbkdf2(8,...cA.allocU8a(A),...cA.allocU8a(G),b),cA.resultU8a())),du=UG((l,A,G,b,t,c)=>(l.ext_scrypt(8,...cA.allocU8a(A),...cA.allocU8a(G),b,t,c),cA.resultU8a())),nu=UG((l,A)=>(l.ext_sha256(8,...cA.allocU8a(A)),cA.resultU8a())),au=UG((l,A)=>(l.ext_sha512(8,...cA.allocU8a(A)),cA.resultU8a()));function TA(){return!!cA.wasm}async function gu(){try{return!!await MV()}catch{return!1}}function dh(l){return(...A)=>nt(l(...A))}function nh(l,A){return(G,b)=>A(G,l,b)}function wa(l,A){return(G,b=256,t)=>{let c=Tl(G);return!PA||!t&&TA()?l[b](c):A[b](c)}}function Tb(l,A=256,G,b){let t=Math.ceil(A/8),c=Tl(l);return!PA||!b&&TA()?bu(c,Tl(G),t):G?Do(c,{dkLen:t,key:G}):Do(c,{dkLen:t})}var ah=dh(Tb);var uu=new TextEncoder,gv=new TextDecoder,Ca="cere.vault.grant.v1",mB="cere.vault.grant.v2",Be="",dZ=["public","internal","private","restricted"];function nZ(l){return dZ.includes(l)}function Yu(){let l=dZ.map(A=>`"${A}"`);return l.slice(0,-1).join(", ")+" or "+l[l.length-1]}var za="X-Grant-Signature",Wh="X-Grant-Issued-At";function Ab(l){let A=l.startsWith("0x")?l.slice(2):l;return A.startsWith("0X")&&(A=A.slice(2)),A=A.toLowerCase(),A===""||A.length%2!==0||!/^[0-9a-f]+$/.test(A)?l:`0x${A}`}function oh(l){let A=Ab(l);return`v-${ah(uu.encode(A),128).slice(2)}`}var zd="";var vG=class extends Error{constructor(G,b=""){super(G);el(this,"memberPubkey");this.memberPubkey=b,this.name="GrantVerificationError"}};function hh(l,A,G,b,t,c){return jd(l,A,G,b,t,c,Be)}function jd(l,A,G,b,t,c,B){if(l==="")throw new Error("canonical grant: vaultId is required");if(A==="")throw new Error("canonical grant: memberPubkey is required");if(G==="")throw new Error("canonical grant: role is required");if(t==="")throw new Error("canonical grant: issuedAt is required");let e=Ca;if(B!==Be){if(!nZ(B))throw new Error(`canonical grant: privacyCeiling ${JSON.stringify(B)} must be ${Yu()}`);e=mB}let Z=Object.keys(b).sort(Vv).map(n=>`{"name":${fc(n)},"level":${fc(b[n])}}`),a=`{"schema":${fc(e)},"vaultId":${fc(l)},"memberPubkey":${fc(A)},"role":${fc(G)},"scopes":[${Z.join(",")}],"issuedAt":${fc(t)},"expiresAt":${fc(c)}`+(B===Be?"":`,"privacyCeiling":${fc(B)}`)+"}";return uu.encode(a)}function sh(l){if(l.length===0)throw new Error("decode grant: empty document");let A;try{A=JSON.parse(gv.decode(l))}catch(W){throw new Error(`decode grant: ${W instanceof Error?W.message:String(W)}`)}if(typeof A!="object"||A===null||Array.isArray(A))throw new Error("decode grant: document is not a JSON object");let G=A,b=Jc(G,"schema"),t=Jc(G,"privacyCeiling",!0);if(b===Ca){if(t!=="")throw new Error(`decode grant: schema ${JSON.stringify(b)} carries a privacyCeiling; that is ${JSON.stringify(mB)}`)}else if(b===mB){if(!nZ(t))throw new Error(`decode grant: schema ${JSON.stringify(b)} requires a privacyCeiling of ${Yu()}, got ${JSON.stringify(t)}`)}else throw new Error(`decode grant: schema ${JSON.stringify(b)} is not ${JSON.stringify(Ca)} or ${JSON.stringify(mB)}`);let c=Jc(G,"vaultId"),B=Jc(G,"memberPubkey"),e=Jc(G,"role");if(c===""||B===""||e==="")throw new Error("decode grant: vaultId, memberPubkey and role are all required");let d=G.scopes;if(!Array.isArray(d))throw new Error("decode grant: scopes must be an array");let Z=Object.create(null);for(let W of d){if(typeof W!="object"||W===null||Array.isArray(W))throw new Error("decode grant: a scope entry is not an object");let i=Jc(W,"name");if(i==="")throw new Error("decode grant: a scope with no name");Z[i]=Jc(W,"level")}let a=Jc(G,"issuedAt");if(a==="")throw new Error("decode grant: issuedAt is required");let n=Jc(G,"expiresAt");return{schema:b,vaultId:c,memberPubkey:B,role:e,scopes:Z,issuedAt:a,expiresAt:n,privacyCeiling:b===mB?t:""}}async function Sa(l,A,G){if(A.length===0||G==="")return!1;let b,t;try{b=Te(It(l).toLowerCase()),t=Te(It(G).toLowerCase())}catch{return!1}return!Vu(l)||!Vu(G)||b.length!==32||t.length!==64?!1:ov(b,A,t)}var Wu=xo.n,Wv=(()=>{let l=new Uint8Array(32);return l[0]=1,l})();async function ov(l,A,G){let b=G.subarray(0,32),t=ou(G.subarray(32,64));if(t>=Wu)return!1;let c;try{c=bc.fromBytes(l,!0)}catch{return!1}let B=Co.mod(ou(await Co.sha512Async(b,l,A)),Wu),e=bc.BASE.multiply(t,!1).add(c.multiply(B,!1).negate()),d=e.is0()?Wv:e.toBytes();for(let Z=0;Z<32;Z++)if(d[Z]!==b[Z])return!1;return!0}function ou(l){let A=0n;for(let G=l.length-1;G>=0;G--)A=A<<8n|BigInt(l[G]);return A}async function rh(l,A,G={}){if(typeof A!="string"||A==="")throw new vG("expectedVaultId is required: verifying a roster against the vault id it carries only proves the response agrees with itself");if(typeof l!="object"||l===null)throw new vG(`signed roster is not an object (got ${hu(l)})`);if(typeof l.vaultId!="string"||l.vaultId==="")throw new vG("signed roster carries no vaultId");if(typeof l.orgWalletPubkey!="string"||l.orgWalletPubkey==="")throw new vG("signed roster carries no orgWalletPubkey");if(!Array.isArray(l.grants))throw new vG(`signed roster's grants is not an array (got ${hu(l.grants)})`);if(l.vaultId!==A)throw new vG(`signed roster names vault ${l.vaultId}, asked about ${A}`);if(oh(l.orgWalletPubkey)!==A)throw new vG(`orgWalletPubkey ${l.orgWalletPubkey} does not derive vault ${A}`);let b=[];for(let t of l.grants){if(typeof t!="object"||t===null){let c=new vG("signed roster holds a grant that is not an object");G.onUnverifiableGrant?.(c);continue}try{b.push(await Iu(A,l.orgWalletPubkey,t))}catch(c){if(!(c instanceof vG))throw c;G.onUnverifiableGrant?.(c)}}return b}function hu(l){return l===null?"null":Array.isArray(l)?"an array":typeof l}async function Iu(l,A,G){if(oh(A)!==l)throw new vG(`orgWalletPubkey ${A} does not derive vault ${l}`,G.memberPubkey);let b;try{b=No(G.doc)}catch(B){throw new vG(`grant document is not valid base64: ${B instanceof Error?B.message:String(B)}`,G.memberPubkey)}let t=G.signer??"";if(typeof t!="string")throw new vG("signer is not a string",G.memberPubkey);if(t!==""&&Ab(t)!==Ab(A))return hv(l,A,G,b,t);if((G.signerDoc??"")!==""||(G.signerSig??"")!=="")throw new vG("owner-signed entry carries signer evidence; signerDoc and signerSig belong only to an admin-signed entry",G.memberPubkey);if(!await Sa(A,b,G.sig))throw new vG(`grant document is not signed by the vault owner (${A})`,G.memberPubkey);let c;try{c=sh(b)}catch(B){throw new vG(B instanceof Error?B.message:String(B),G.memberPubkey)}if(c.vaultId!==l||c.memberPubkey!==G.memberPubkey)throw new vG(`grant document describes a different membership: it names ${c.memberPubkey} on ${c.vaultId}, and was served as ${G.memberPubkey} on ${l}`,G.memberPubkey);return c}var su="admin",ru="member";async function hv(l,A,G,b,t){let c=i=>new vG(i,G.memberPubkey),B=G.signerDoc??"",e=G.signerSig??"";if(B===""||e==="")throw c("admin-signed entry requires signer, signerDoc and signerSig together");let d=Ab(t);if(!/^0x[0-9a-f]{64}$/.test(d))throw c(`signer ${JSON.stringify(t)} is not a 32-byte hex ed25519 key`);let Z;try{Z=No(B)}catch(i){throw c(`signerDoc is not valid base64: ${i instanceof Error?i.message:String(i)}`)}if(!await Sa(A,Z,e))throw c("appointment is not signed by the vault wallet");let a=iu("appointment",Z,c);if(a.vaultId!==l)throw c(`appointment names vault ${JSON.stringify(a.vaultId)}`);if(Ab(a.memberPubkey)!==d)throw c(`appointment names member ${Ua(a.memberPubkey)}, signer is ${Ua(d)}`);if(a.role!==su)throw c(`appointment confers role ${JSON.stringify(a.role)}, not ${JSON.stringify(su)}`);if(!await Sa(d,b,G.sig))throw c("grant is not signed by the named admin");let n=iu("grant",b,c,i=>{if(i.vaultId!==l)throw c(`document names vault ${JSON.stringify(i.vaultId)}`);if(Ab(i.memberPubkey)!==Ab(G.memberPubkey))throw c(`document names member ${Ua(i.memberPubkey)}, entry names ${Ua(G.memberPubkey)}`)});if(n.role!==ru)throw c(`an admin-signed grant must confer role ${JSON.stringify(ru)}, got ${JSON.stringify(n.role)}`);if(Ab(n.memberPubkey)===d)throw c("admin-signed grant grants to its own signer");let h=gh("appointment issuedAt",a.issuedAt,c),W=gh("grant issuedAt",n.issuedAt,c);if(mu(W,h)<0)throw c(`grant issued ${n.issuedAt} predates the appointment issued ${a.issuedAt}`);if(a.expiresAt!==zd){let i=gh("appointment expiresAt",a.expiresAt,c);if(mu(W,i)>=0)throw c(`grant issued ${n.issuedAt} at or after the appointment expired ${a.expiresAt}`)}return{...n,grantedBy:d}}function iu(l,A,G,b){let t;try{t=sh(A)}catch(B){throw G(`${l} is not in canonical form: ${B instanceof Error?B.message:String(B)}`)}b?.(t);let c;try{c=jd(t.vaultId,t.memberPubkey,t.role,t.scopes,t.issuedAt,t.expiresAt,t.privacyCeiling)}catch{throw G(`${l} is not in canonical form`)}if(c.length!==A.length||c.some((B,e)=>B!==A[e]))throw G(`${l} is not in canonical form`);return t}var sv=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?Z$/;function gh(l,A,G){let b=sv.exec(A);if(b===null)throw G(`${l} ${JSON.stringify(A)} is not a UTC timestamp of the form YYYY-MM-DDTHH:MM:SS[.fraction]Z`);let[t,c,B,e,d,Z]=b.slice(1,7).map(Number);if(c<1||c>12||B<1||B>rv(t,c)||e>23||d>59||Z>59)throw G(`${l} ${JSON.stringify(A)} is not an RFC3339 time`);let a=Number((b[7]??"").padEnd(9,"0"));return[iv(t,c,B)*86400+e*3600+d*60+Z,a]}function mu(l,A){return l[0]!==A[0]?l[0]-A[0]:l[1]-A[1]}function rv(l,A){return A===2?l%4===0&&l%100!==0||l%400===0?29:28:[4,6,9,11].includes(A)?30:31}function iv(l,A,G){let b=A<=2?l-1:l,t=Math.floor(b/400),c=b-t*400,B=(A+9)%12,e=Math.floor((153*B+2)/5)+G-1,d=c*365+Math.floor(c/4)-Math.floor(c/100)+e;return t*146097+d-719468}function Ua(l){let A=l.startsWith("0x")?l.slice(2):l;return A.startsWith("0X")&&(A=A.slice(2)),A.slice(0,8)}function Vu(l){let A=l.startsWith("0x")?l.slice(2):l;return A.startsWith("0X")&&(A=A.slice(2)),A.length%2===0&&/^[0-9a-fA-F]*$/.test(A)}function Jc(l,A,G=!1){let b=l[A];if(b===void 0&&G)return"";if(typeof b!="string")throw new Error(`decode grant: ${A} must be a string, got ${b===void 0?"nothing":typeof b}`);return mv(b)}function mv(l){return l.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"\uFFFD")}function fc(l){return JSON.stringify(l).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Vv(l,A){let G=Array.from(l),b=Array.from(A),t=Math.min(G.length,b.length);for(let c=0;c<t;c++){let B=G[c].codePointAt(0),e=b[c].codePointAt(0);if(B!==e)return B-e}return G.length-b.length}var ja=class{constructor(A,G){el(this,"http");el(this,"signer");this.http=A,this.signer=G}mine(){return this.http.send("GET",fl.memberships())}list(A){return this.http.send("GET",fl.vaultMembers(A))}signedRoster(A){return this.http.send("GET",fl.vaultSignedRoster(A))}async put(A,G,b,t,c={}){let B=c.privacyCeiling===void 0?void 0:c.privacyCeiling;if(B!==void 0&&!nZ(B))throw new Error(`put: privacyCeiling ${JSON.stringify(B)} must be one of `+dZ.map(Z=>`"${Z}"`).join(", "));let e=c.scopes??await this.heldScopes(A,G),d=t===void 0?zd:t;return this.http.send("PUT",fl.vaultMember(A,G),{body:{role:b,expiresAt:t,...B===void 0?{}:{privacyCeiling:B},timestamp:new Date().toISOString()},headers:await this.grantHeader(A,G,b,e,d,B)})}remove(A,G){return this.http.send("DELETE",fl.vaultMember(A,G),{body:{timestamp:new Date().toISOString(),vaultId:A,memberPubkey:Ab(G)}})}scopes(A,G){return this.http.send("GET",fl.vaultMemberScopes(A,G))}async putScopes(A,G,b,t={}){this.grantSigner();let c=t.standing?.privacyCeiling;if(c!==void 0&&c!==Be&&!nZ(c))throw new Error(`putScopes: standing.privacyCeiling ${JSON.stringify(c)} must be one of `+dZ.map(Z=>`"${Z}"`).join(", ")+", or NO_PRIVACY_CEILING for a member who holds none");let B=t.standing??await this.heldStanding(A,G),e=c??await this.heldCeiling(A,G),d=B.expiresAt===void 0?zd:B.expiresAt;try{return await this.http.send("PUT",fl.vaultMemberScopes(A,G),{body:{scopes:b,expiresAt:B.expiresAt,timestamp:new Date().toISOString()},headers:await this.grantHeader(A,G,B.role,b,d,e===void 0||e===Be?void 0:e)})}catch(Z){if(e===void 0&&Z instanceof $G&&Z.status===400&&Z.message.includes(mB)){let a=Ab(G);throw new Rd(`putScopes: ${a} is not in ${A}'s signed roster (it serves live memberships only), so the grant was signed with no privacy ceiling, and vault-api refused it because this member holds one. Nothing was written. Pass \`{ standing: { role, expiresAt, privacyCeiling } }\` with the ceiling the member holds. Server said: ${Z.message}`,a,Z.status,Z.code)}throw Z}}async grantHeader(A,G,b,t,c,B){let e=this.grantSigner(),d=new Date().toISOString(),Z=B===void 0?hh(A,Ab(G),b,t,d,c):jd(A,Ab(G),b,t,d,c,B);return{[za]:qb(await e.sign(Z,"data")),[Wh]:d}}grantSigner(){let A=this.signer;if(A===void 0||typeof A.sign!="function")throw new Rt(`A membership write must carry the VAULT OWNER's signature over the grant's canonical document, in the ${za} header. Construct the SDK with \`signer\` set to the vault owner's key (\`new VaultSDK({ endpoint, signer })\`); a custom \`auth\` provider authenticates the request but cannot sign the grant, because the two cover different bytes.`);if(A.type!=="ed25519")throw new Rt(`A grant signature must be ed25519 \u2014 vault-api verifies it with SchemeEd25519 and nothing else \u2014 but this signer is "${A.type}". An sr25519 key can authenticate the request and still never authorise the grant.`);return A}async heldCeiling(A,G){let b=Ab(G),t=[],B=(await rh(await this.signedRoster(A),A,{onUnverifiableGrant:d=>t.push(d)})).find(d=>Ab(d.memberPubkey)===b);if(B!==void 0)return B.privacyCeiling;let e=t.find(d=>d.memberPubkey!==""&&Ab(d.memberPubkey)===b);if(e!==void 0)throw new vG(`putScopes: ${b}'s grant in the signed roster of ${A} failed verification (${e.message}), so the privacy ceiling it holds is unknown and no grant document can be signed for it.`,e.memberPubkey)}async heldScopes(A,G){try{return(await this.scopes(A,G)).scopes}catch(b){if(b instanceof $G&&b.status===404)return{};throw b}}async heldStanding(A,G){let b=Ab(G),t=(await this.list(A)).find(c=>c.isOwner!==!0&&Ab(c.memberPubkey)===b);if(t===void 0)throw new Error(`putScopes: ${b} has no membership row on ${A}, so there is no role or expiry to put in the grant document. Add the member first (\`memberships.put\`), or pass \`{ standing: { role, expiresAt } }\` if you already know them.`);return{role:t.role,expiresAt:t.expiresAt}}};var Ru=new tt,Ma=class{constructor(A){el(this,"http");this.http=A}getAgent(A,G){let b=G?fl.marketplaceAgentVersion(A,G):fl.marketplaceAgent(A);return this.http.send("GET",b,{auth:Ru})}async list(A={}){let G=await this.http.send("GET",fl.marketplaceAgents(),{auth:Ru,query:{limit:A.limit,cursor:A.cursor,q:A.query}}),t={items:G.agents??G.items??[]};return G.nextCursor!==void 0&&(t.nextCursor=G.nextCursor),t}};var Xu=new tt,Ta=class{constructor(A){el(this,"http");this.http=A}live(){return this.http.send("GET",fl.health(),{auth:Xu})}ready(){return this.http.send("GET",fl.ready(),{auth:Xu})}};var Da=class{constructor(A){el(this,"http");this.http=A}list(A){return this.http.send("GET",fl.scopes(A))}get(A,G){return this.http.send("GET",fl.scope(A,G))}create(A,G){return this.http.send("POST",fl.scopes(A),{body:pu(G)})}update(A,G,b){return this.http.send("PATCH",fl.scope(A,G),{body:pu(b)})}delete(A,G){return this.http.send("DELETE",fl.scope(A,G),{body:{}})}};function pu(l){let A={};return"name"in l&&l.name!==void 0&&(A.name=l.name),l.displayName!==void 0&&(A.displayName=l.displayName),l.streamLabel!==void 0&&(A.streamLabel=l.streamLabel),l.metadata!==void 0&&(A.metadata=l.metadata),A}function Fu(l,A){if(l.length>16)throw new Error(`[${A}] \`scopes\` has ${l.length} entries; the server refuses more than 16 \u2014 trim the set before calling`);for(let G of l)if(typeof G!="string"||G.trim().length===0)throw new Error(`[${A}] \`scopes\` contains an empty/blank entry (${JSON.stringify(G)}) \u2014 the server refuses an empty scope member`)}function aZ(l,A){let G=l.scope!==void 0,b=l.scopes!==void 0;if(G&&b)throw new Error(`[${A}] both \`scope\` (${JSON.stringify(l.scope)}) and \`scopes\` (${JSON.stringify(l.scopes)}) were supplied \u2014 these conflict and which one would apply is undefined; pass exactly one.`);if(b){if(!l.scopes||l.scopes.length===0)throw new Error(`[${A}] \`scopes\` must be a non-empty array`);return Fu(l.scopes,A),l.scopes}if(G)return Fu([l.scope],A),[l.scope];throw new Error(`[${A}] requires \`scope\` or a non-empty \`scopes\` array`)}var WZ=class{constructor(A){el(this,"http");this.http=A}async connect(A,G){let{ceiling:b,...t}=G,c=b===void 0?{...t}:{...t,ceiling:La(b)};return aZ(G,"Agents.connect"),this.http.send("POST",fl.agents(A),{body:c})}async list(A,G={}){return(await this.http.send("GET",fl.agents(A),{query:{status:G.status}})).items??[]}get(A,G){return this.http.send("GET",fl.agent(A,G))}update(A,G,b){return this.http.send("PATCH",fl.agent(A,G),{body:{settings:b}})}async setCeiling(A,G,b){let t=La(b);return this.http.send("PUT",fl.agentCeiling(A,G),{body:{...t}})}setHarvester(A,G,b){return this.http.send("PUT",fl.agentHarvester(A,G),{body:{harvester:b}})}disconnect(A,G){return this.http.send("DELETE",fl.agent(A,G),{body:{}})}};function gZ(l){return new $G(`invalid ceiling: ${l}`,0,"BAD_REQUEST")}function La(l){if(l===null||typeof l!="object"||Array.isArray(l))throw gZ("expected an object { gpuUnits?, a2aTokens? }");for(let t of Object.keys(l))if(t!=="gpuUnits"&&t!=="a2aTokens")throw gZ(`unknown field ${JSON.stringify(t)} (expected { gpuUnits?, a2aTokens? })`);let A=t=>{let c=l[t];if(c===void 0)return 0;if(typeof c!="number"||!Number.isFinite(c))throw gZ(`${t} must be a finite number (got ${String(c)})`);if(c<0)throw gZ(`${t} must be >= 0 (got ${c})`);return c},G=A("gpuUnits"),b=A("a2aTokens");if(!Number.isInteger(b))throw gZ(`a2aTokens must be an integer (got ${b})`);if(b>Number.MAX_SAFE_INTEGER)throw gZ(`a2aTokens must be <= Number.MAX_SAFE_INTEGER (got ${b})`);return{gpuUnits:G,a2aTokens:b}}var Qt=class{constructor(A){el(this,"http");this.http=A}listStreams(A,G,b={}){return this.http.send("GET",fl.scopeStreams(A,G),{query:{active:b.active,limit:b.limit,cursor:b.cursor}})}getStream(A,G,b){return this.http.send("GET",fl.stream(A,G,b))}listStreamEvents(A,G,b,t={}){return this.http.send("GET",fl.streamEvents(A,G,b),{query:{limit:t.limit,cursor:t.cursor}})}listJobs(A,G={}){return this.http.send("GET",fl.jobs(A),{query:{state:G.state,cursor:G.cursor,limit:G.limit,from:G.from,to:G.to,agentId:G.agentId}})}getJob(A,G){return this.http.send("GET",fl.job(A,G))}listAgentJobs(A,G,b={}){return this.http.send("GET",fl.agentJobs(A,G),{query:{state:b.state,cursor:b.cursor,limit:b.limit}})}listTasks(A,G,b={}){return this.http.send("GET",fl.jobTasks(A,G),{query:{cursor:b.cursor,limit:b.limit}})}getTask(A,G,b){return this.http.send("GET",fl.jobTask(A,G,b))}listTaskLogs(A,G,b,t={}){return this.http.send("GET",fl.jobTaskLogs(A,G,b),{query:{offset:t.offset,limit:t.limit}})}};var Oa=class{constructor(A,G){el(this,"http");el(this,"vaultId");this.http=A,this.vaultId=G}search(A,G={}){return this.http.send("POST",fl.memoryTool(this.vaultId,"record_search"),{body:{match:A,limit:G.limit,type:G.type,privacy:G.privacy,scope:G.scope,cursor:G.cursor,domain:G.domain}})}list(A,G={}){return this.http.send("POST",fl.memoryTool(this.vaultId,"record_list"),{body:{type:A,limit:G.limit,scope:G.scope,cursor:G.cursor,domain:G.domain}})}get(A){return this.http.send("POST",fl.memoryTool(this.vaultId,"record_get"),{body:{id:A}})}neighbours(A,G={}){return this.http.send("POST",fl.memoryTool(this.vaultId,"record_neighbours"),{body:{id:A,limit:G.limit,edge_type:G.edgeType,direction:G.direction}})}countByType(A={}){return this.http.send("POST",fl.memoryTool(this.vaultId,"record_count_by_type"),{body:{scope:A.scope,domain:A.domain}})}};var Pa=class{constructor(A,G){el(this,"http");el(this,"vaultId");this.http=A,this.vaultId=G}async list(A){let G=await this.http.send("GET",fl.agentWebhooks(this.vaultId,A)),b=G&&typeof G=="object"?G.webhooks:void 0;return Array.isArray(b)?b:[]}createKey(A,G,b){return this.http.send("POST",fl.agentWebhookKeys(this.vaultId,A,G),{body:{name:b.name,expiresAt:b.expiresAt}})}async revokeKey(A,G,b){await this.http.send("DELETE",fl.agentWebhookKey(this.vaultId,A,G,b),{body:{}})}};async function Qu(l){return _a(await l.send("GET",fl.connectors()),"connectors")}var Ka=class{constructor(A,G){el(this,"http");el(this,"vaultId");this.http=A,this.vaultId=G}async list(){return _a(await this.http.send("GET",fl.connections(this.vaultId)),"connections")}create(A){return this.http.send("POST",fl.connections(this.vaultId),{body:yu(A)})}update(A,G){return this.http.send("PATCH",fl.connection(this.vaultId,A),{body:yu(G)})}async revoke(A){await this.http.send("DELETE",fl.connection(this.vaultId,A),{body:{}})}async actions(A){return _a(await this.http.send("GET",fl.connectionActions(this.vaultId,A)),"actions")}},qa=class{constructor(A,G){el(this,"http");el(this,"vaultId");this.http=A,this.vaultId=G}async list(A){return _a(await this.http.send("GET",fl.agentConnections(this.vaultId,A)),"connections")}set(A,G,b){return this.http.send("PUT",fl.agentConnection(this.vaultId,A,G),{body:{actions:b.actions,events:b.events,filter:b.filter??{}}})}async remove(A,G){await this.http.send("DELETE",fl.agentConnection(this.vaultId,A,G),{body:{}})}};function yu(l){let A={};for(let[G,b]of Object.entries(l))b!==void 0&&(A[G]=b);return A}function _a(l,A){let G=l&&typeof l=="object"?l[A]:void 0;return Array.isArray(G)?G:[]}var $a=class{constructor(A){el(this,"http");this.http=A}publish(A,G,b){let c=(Array.isArray(b)?b:[b]).map(B=>({role:"user",...B,timestamp:B.timestamp??new Date().toISOString()}));return this.http.send("POST",fl.scopeEvents(A,G),{body:{events:c}})}};var lg=class{constructor(A){el(this,"http");this.http=A}async upload(A,G,b,t,c={}){return this.http.send("PUT",fl.scopeObject(A,G,b),{rawBody:t,headers:{"Content-Type":c.contentType??"application/octet-stream",...c.ifNoneMatch?{"If-None-Match":c.ifNoneMatch}:{}}})}async get(A,G,b){return this.http.send("GET",fl.scopeObject(A,G,b),{responseType:"bytes"})}async head(A,G,b){let t=await this.http.send("HEAD",fl.scopeObject(A,G,b),{responseType:"headers"}),c=Number(t["content-length"]??"0");return{size:Number.isFinite(c)?c:0,contentType:t["content-type"]??"",etag:t.etag,updatedAt:t["last-modified"]}}async presignedUrl(A,G,b,t={}){return this.http.send("GET",fl.scopeObjectsPresignedUrl(A,G),{query:{path:b,ttlSeconds:t.ttlSeconds}})}async delete(A,G,b){await this.http.send("DELETE",fl.scopeObject(A,G,b),{body:{timestamp:new Date().toISOString()}})}async list(A,G,b={}){return this.http.send("GET",fl.scopeObjects(A,G),{query:{prefix:b.prefix}})}};function ih(l,A,G,b,t,c={}){let B=new Qt(l),e=c.intervalMs??1e3,d=c.pageSize??100,Z=c.onError??(V=>{console.warn("[vault-sdk] subscribe poll failed:",V)}),a=new Set,n=!1,h=0,W,i=new Promise(V=>W=V),Y=async()=>{let V;do{let m=await B.listStreamEvents(A,G,b.context,{cursor:V,limit:d});for(let I of m.items){if(n)return;a.has(I.eventId)||(a.add(I.eventId),!(b.types&&!b.types.includes(I.type))&&(b.from&&!b.from.includes(I.from??"")||await t(I)))}V=m.hasMore&&m.nextCursor?m.nextCursor:void 0}while(V&&!n)};return(async()=>{for(;!n;){try{await Y(),h=0}catch(m){h++,Z(m)}if(n)break;let V=c.maxBackoffMs&&h>0?Math.min(e*2**h,c.maxBackoffMs):e;await new Promise(m=>setTimeout(m,V))}W()})(),{unsubscribe(){n=!0},closed:i}}var Md=class{constructor(A,G,b){el(this,"http");el(this,"vaultId");el(this,"name");el(this,"events");el(this,"browse");el(this,"_objects");el(this,"streams",{list:(A={})=>this.browse.listStreams(this.vaultId,this.name,A),get:A=>this.browse.getStream(this.vaultId,this.name,A)});el(this,"objects",{upload:async(A,G,b={})=>{let t=await this._objects.upload(this.vaultId,this.name,A,G,b);return b.publishEvent&&await this.publish({type:b.publishEvent.type,context:b.publishEvent.context,payload:{...b.publishEvent.payload,vaultPath:t.vaultPath}}),t},get:A=>this._objects.get(this.vaultId,this.name,A),head:A=>this._objects.head(this.vaultId,this.name,A),presignedUrl:(A,G={})=>this._objects.presignedUrl(this.vaultId,this.name,A,G),delete:A=>this._objects.delete(this.vaultId,this.name,A),list:(A={})=>this._objects.list(this.vaultId,this.name,A)});this.http=A,this.vaultId=G,this.name=b,this.events=new $a(A),this.browse=new Qt(A),this._objects=new lg(A)}async publish(A){let G=await this.events.publish(this.vaultId,this.name,A),b=G.rejected??[],t=G.accepted??[];if(b.length>0){let c=b[0];throw new Error(`publish rejected: ${c.reason}${c.code?` (${c.code})`:""}`)}return{eventId:t[0]}}stream(A){return{events:{list:(G={})=>this.browse.listStreamEvents(this.vaultId,this.name,A,G)}}}subscribe(A,G,b={}){return ih(this.http,this.vaultId,this.name,A,G,b)}subscribeAll(A,G,b={}){return Iv(this.http,this.vaultId,this.name,this.browse,A,G,b)}};function Iv(l,A,G,b,t,c,B){let e=B.refreshIntervalMs??3e4,d=B.onError??(R=>{console.warn("[vault-sdk] subscribeAll refresh failed:",R)}),Z=new Map,a=!1,n,h,W=new Promise(R=>h=R),i=R=>{if(Z.has(R)||a)return;let V=ih(l,A,G,{context:R,...t.types?{types:t.types}:{}},c,B);Z.set(R,V)},Y=async()=>{try{let R=await b.listStreams(A,G);for(let V of R.items)i(V.context)}catch(R){d(R)}a||(n=setTimeout(Y,e))};return Y(),{unsubscribe(){if(a)return;a=!0,n&&clearTimeout(n);let R=[];for(let V of Z.values())V.unsubscribe(),R.push(V.closed);Z.clear(),Promise.all(R).then(()=>h())},closed:W}}var oZ=class{constructor(A){el(this,"http");this.http=A}query(A,G,b,t,c,B=[]){return this.http.send("POST",fl.cubbyQuery(A,G,b,t),{body:{sql:c,params:B}})}exec(A,G,b,t,c,B=[]){return this.http.send("POST",fl.cubbyExec(A,G,b,t),{body:{sql:c,params:B}})}serviceQuery(A,G,b,t,c=[]){return this.http.send("POST",fl.serviceCubbyQuery(A,G,b),{body:{sql:t,params:c}})}serviceExec(A,G,b,t,c=[]){return this.http.send("POST",fl.serviceCubbyExec(A,G,b),{body:{sql:t,params:c}})}async serviceList(A,G){return(await this.http.send("GET",fl.serviceCubbies(A,G)))?.data??[]}serviceProvision(A,G,b,t){return this.http.send("POST",fl.serviceCubbyProvision(A,G,b),{body:{migrations:t}})}serviceDelete(A,G,b){return this.http.send("DELETE",fl.serviceCubby(A,G,b))}};var Td=class{constructor(A,G,b){el(this,"vaultId");el(this,"asPubKey");el(this,"cubbies");this.vaultId=G,this.asPubKey=b,this.cubbies=new oZ(A)}list(){return this.cubbies.serviceList(this.vaultId,this.asPubKey)}cubby(A){let{vaultId:G,asPubKey:b,cubbies:t}=this;return{query:(c,B=[])=>t.serviceQuery(G,b,A,c,B),exec:(c,B=[])=>t.serviceExec(G,b,A,c,B),provision:c=>t.serviceProvision(G,b,A,c),delete:()=>t.serviceDelete(G,b,A)}}};var Dd=class{constructor(A,G,b,t,c){el(this,"vaultId");el(this,"scope");el(this,"agentId");el(this,"alias");el(this,"api");this.vaultId=G,this.scope=b,this.agentId=t,this.alias=c,this.api=new oZ(A)}query(A,G=[]){return this.api.query(this.vaultId,this.scope,this.agentId,this.alias,A,G)}exec(A,G=[]){return this.api.exec(this.vaultId,this.scope,this.agentId,this.alias,A,G)}};var ee=class l{constructor(A,G,b){el(this,"http");el(this,"vaultIdRoot");el(this,"vaultId");el(this,"agentId");el(this,"scope");el(this,"scopes");el(this,"version");el(this,"asPubKey");el(this,"cubbyAliases");el(this,"status");el(this,"manifest");el(this,"ceiling");el(this,"harvester");el(this,"bundle");el(this,"createdAt");el(this,"updatedAt");el(this,"api");el(this,"browse");el(this,"jobs",{list:(A={})=>this.browse.listAgentJobs(this.vaultIdRoot,this.agentId,A)});this.http=A,this.vaultIdRoot=G,this.vaultId=b.vaultId,this.agentId=b.agentId,this.scope=b.scope,this.scopes=b.scopes,this.version=b.version,this.asPubKey=b.asPubKey,this.cubbyAliases=b.cubbyAliases,this.status=b.status,this.manifest=b.manifest,this.ceiling=b.ceiling,this.harvester=b.harvester===!0,this.bundle=b.bundle,this.createdAt=b.createdAt,this.updatedAt=b.updatedAt,this.api=new WZ(A),this.browse=new Qt(A)}cubby(A){if(!this.cubbyAliases.includes(A))throw new Error(`agent ${this.agentId} has no cubby "${A}". Declared aliases: ${this.cubbyAliases.join(", ")||"(none)"}`);return new Dd(this.http,this.vaultIdRoot,this.scope,this.agentId,A)}async update(A){let G=await this.api.update(this.vaultIdRoot,this.agentId,A);return new l(this.http,this.vaultIdRoot,G)}async setCeiling(A){let G=await this.api.setCeiling(this.vaultIdRoot,this.agentId,A);return new l(this.http,this.vaultIdRoot,G)}async setHarvester(A){let G=await this.api.setHarvester(this.vaultIdRoot,this.agentId,A);return new l(this.http,this.vaultIdRoot,G)}disconnect(){return this.api.disconnect(this.vaultIdRoot,this.agentId)}};var Ld=class{constructor(A,G,b){el(this,"http");el(this,"vaultId");el(this,"jobId");el(this,"browse");el(this,"tasks",{list:(A={})=>this.browse.listTasks(this.vaultId,this.jobId,A),get:A=>this.browse.getTask(this.vaultId,this.jobId,A),logs:(A,G={})=>this.browse.listTaskLogs(this.vaultId,this.jobId,A,G),subscribe:(A,G,b={})=>Rv(this.browse,this.vaultId,this.jobId,A,G,b)});this.http=A,this.vaultId=G,this.jobId=b,this.browse=new Qt(A)}get(){return this.browse.getJob(this.vaultId,this.jobId)}tree(){throw new Error("JobHandle.tree() requires the orchestrator's tree route which is not yet implemented (returns 501).")}};function Rv(l,A,G,b,t,c){let B=c.intervalMs??1e3,e=c.pageSize??100,d=c.onError??(R=>{console.warn("[vault-sdk] tasks.subscribe poll failed:",R)}),Z=new Set,a,n=!1,h,W=new Promise(R=>h=R),i=b.since?Date.parse(b.since):void 0;return(async()=>{for(;!n;){try{let R=await l.listTasks(A,G,{cursor:a,limit:e});for(let V of R.items)if(!Z.has(V.taskId)){if(Z.add(V.taskId),i!==void 0){let m=V.startedAt??V.finishedAt;if(m&&Date.parse(m)<i)continue}await t(V)}R.nextCursor&&(a=R.nextCursor)}catch(R){d(R)}if(n)break;await new Promise(R=>setTimeout(R,B))}h()})(),{unsubscribe(){n=!0},closed:W}}var Xv=new TextEncoder;function mh(l){if(!l.scopes||l.scopes.length===0)throw new Error("buildVaultAgreementPayloadV2: `scopes` must be a non-empty array \u2014 an agreement must record at least one scope");let A=Array.from(new Set(l.scopes)),G=l.createdAt??ha,b={version:"v2",agent_service_pub_key:yo(l.asPubKey),agent_id:l.agentId,vault_id:l.vaultId,user_pub_key:yo(l.userPubKey),revoked:!1,expires_at:null,metadata:{scopes:A},created_at:G()};return{payload:b,bytes:Xv.encode(JSON.stringify(b))}}async function Ag(l){if(typeof l.signer?.sign!="function")throw new Rt;let{agentId:A,agentServicePubkey:G}=l.agent;if(!G)throw new Error("signAndSubmitAgreement: `agent.agentServicePubkey` is required");let b=aZ(l,"signAndSubmitAgreement"),{bytes:t}=mh({vaultId:l.vault.id,userPubKey:l.vault.userPubKey,asPubKey:G,agentId:A,scopes:b,createdAt:l.clock}),c=await l.signer.sign(t,"data"),B=qb(c),e={payload:De(t),signature:{algorithm:"ed25519",signer:gB(l.vault.userPubKey),value:gB(B)}};return await l.gar.postAgreement(e),{agreementSignature:It(B)}}var xc=class{constructor(A,G,b={}){el(this,"id");el(this,"bucketId");el(this,"walletPubkey");el(this,"gatewayEndpoint");el(this,"region");el(this,"status");el(this,"disconnectedAt");el(this,"displayName");el(this,"registryBucketId");el(this,"_http");el(this,"_scopes");el(this,"_agents");el(this,"_browse");el(this,"memory");el(this,"connections");el(this,"webhooks");el(this,"_access");el(this,"_gar");el(this,"_signer");el(this,"_userPubKey");el(this,"scopes",{list:()=>this._scopes.list(this.id),get:A=>this._scopes.get(this.id,A),create:A=>this._scopes.create(this.id,A),update:(A,G)=>this._scopes.update(this.id,A,G),delete:A=>this._scopes.delete(this.id,A)});el(this,"agents",{connect:async A=>{if(!this._gar)throw new Error("vault.agents.connect requires `garEndpoint` on VaultSDKConfig");if(!this._signer)throw new Error("vault.agents.connect requires a `signer` on VaultSDKConfig");let G=A.agentId.includes(":")?A.agentId.split(":")[0]:"",b=A.agentServicePubkey??G;if(!b)throw new Error(`[vault.agents.connect] cannot derive agentServicePubkey from agentId '${A.agentId}' (expected '<pubkey>:<alias>'); pass agentServicePubkey explicitly`);let t=aZ(A,"vault.agents.connect");A.ceiling!==void 0&&La(A.ceiling);let{agreementSignature:c}=await Ag({signer:this._signer,vault:{id:this.id,userPubKey:this._userPubKey},agent:{agentId:A.agentId,agentServicePubkey:b},scopes:t,gar:this._gar}),B=A.scope!==void 0?{scope:A.scope}:{scopes:A.scopes},e={agentId:A.agentId,...B,settings:A.settings??{},agreementSignature:c,...A.ceiling!==void 0?{ceiling:A.ceiling}:{},...A.bundleCid!==void 0?{bundleCid:A.bundleCid}:{}},d=await this._agents.connect(this.id,e);return new ee(this._http,this.id,d)},list:async()=>(await this._agents.list(this.id)).map(G=>new ee(this._http,this.id,G)),get:async A=>{let G=await this._agents.get(this.id,A);return new ee(this._http,this.id,G)},connections:A=>this._access.list(A),setConnection:(A,G,b)=>this._access.set(A,G,b),removeConnection:(A,G)=>this._access.remove(A,G)});el(this,"jobs",{list:(A={})=>this._browse.listJobs(this.id,A),get:A=>new Ld(this._http,this.id,A)});this.id=G.vaultId,this.bucketId=G.bucketId,this.walletPubkey=G.walletPubkey,this.gatewayEndpoint=G.gatewayEndpoint,this.region=G.region,this.status=G.status,this.disconnectedAt=G.disconnectedAt,this.displayName=G.displayName,this.registryBucketId=G.registryBucketId,this._http=A,this._scopes=new Da(A),this._agents=new WZ(A),this._browse=new Qt(A),this.memory=new Oa(this._http,this.id),this.connections=new Ka(this._http,this.id),this.webhooks=new Pa(this._http,this.id),this._access=new qa(this._http,this.id),this._gar=b.gar,this._signer=b.signer,this._userPubKey=b.signer?gB(qb(b.signer.publicKey)):G.walletPubkey}scope(A){return new Md(this._http,this.id,A)}service(A){return new Td(this._http,this.id,A)}connectors(){return Qu(this._http)}isDisconnected(){return this.status==="disconnected"}};var Vh=class extends Error{constructor(A){super(`Unsupported signature type "${A}": vault-api accepts only "ed25519" or "sr25519". Pass WalletAuthOptions.sigType to override.`),this.name="UnsupportedSignatureTypeError"}};function Gg(l){if(l==="ed25519"||l==="sr25519")return l;throw new Vh(l)}var Od=class{constructor(A,G={}){el(this,"signer");el(this,"opts");this.signer=A,this.opts=G}async authenticate(A){if(typeof this.signer?.sign!="function")throw new Rt;let G=this.opts.sigType??Gg(this.signer.type),b={"X-Public-Key":gB(qb(this.signer.publicKey)),"X-Signature-Type":G},t=A.method.toUpperCase();if(A.hash!==void 0){let{bytes:e}=Qo(t,A.path,A.query,this.opts.clock,A.hash),d=await this.signer.sign(e,"data");return b["X-Signed-Preamble"]=De(e),b["X-Signature"]=It(qb(d)),{headers:b}}if(t==="GET"||t==="HEAD"){let{bytes:e}=Qo(t,A.path,A.query,this.opts.clock),d=await this.signer.sign(e,"data");return b["X-Signed-Preamble"]=De(e),b["X-Signature"]=It(qb(d)),{headers:b}}let{bytes:c}=N2(A.body,this.opts.clock),B=await this.signer.sign(c,"data");return b["Content-Type"]="application/json",b["X-Signature"]=It(qb(B)),{headers:b,body:c}}};var pv=new tt,hZ=class{constructor(A){el(this,"http");this.http=A}async postAgreement(A){await this.http.send("POST","/api/v1/agreements",{body:A,auth:pv})}};var Pd=class extends Error{constructor(A){super(A),this.name="OnboardingRequiredError"}};function vu(l){return{publicKeyHex:`0x${Nu(l.publicKey)}`,keyType:Gg(l.type),async signRawHex(A){let G=await l.sign(A,"data");return Nu(G)}}}function Nu(l){let A="";for(let G=0;G<l.length;G++)A+=l[G].toString(16).padStart(2,"0");return A}async function Hu(l){let A=await l.signRawHex(new Uint8Array(0)),G=A.startsWith("0x")?A.slice(2):A;return{"X-Public-Key":l.publicKeyHex,"X-Signature":G,"X-Signature-Type":l.keyType}}async function Eu(l,A,G=fetch){let b=l.replace(/\/+$/,"")+"/auth/onboarding/status",t=await G(b,{method:"GET",headers:await Hu(A)});if(t.status===404)return null;if(!t.ok)throw new Error(`onboarding status ${t.status}`);return await t.json()}async function Fv(l,A,G=fetch){let b=l.replace(/\/+$/,"")+"/auth/onboarding/bootstrap",t=await G(b,{method:"POST",headers:await Hu(A)});if(t.status!==200&&t.status!==207)throw new Error(`onboarding bootstrap ${t.status}`);return await t.json()}async function Ju(l,A,G=fetch,b){let t=await Eu(l,A,G);if(t===null)return{kind:"skipped",status:null};if(t.gateway_is_proxy)return{kind:"ready",status:t};let c,B=t;if(t.faucet_eligible||t.ddc_seed_eligible){b?.(),c=await Fv(l,A,G);let e=await Eu(l,A,G);e&&(B=e)}return B.gateway_is_proxy?{kind:"ready",status:B}:{kind:"awaiting-proxy",status:B,bootstrap:c}}var yv=new tt,Kd=class{constructor(A){el(this,"http");this.http=A}async delegate(){let A=await this.http.send("GET",fl.delegateInfo(),{auth:yv}),G=A.delegate_pubkey??A.delegatePubkey;if(!G)throw new Error(`vault-api /delegate-info response is missing delegate_pubkey: ${JSON.stringify(A)}`);return{delegatePubkey:G}}};var Yh={PUT:1,GET:2,DELETE:3};function rZ(...l){let A=new Uint8Array(l.reduce((b,t)=>b+t.length,0)),G=0;for(let b of l)A.set(b,G),G+=b.length;return A}function bg(l){let A=BigInt(l);if(A<0n)throw new RangeError(`auth-token: negative varint ${l}`);let G=[];do{let b=Number(A&0x7fn);A>>=7n,A!==0n&&(b|=128),G.push(b)}while(A!==0n);return Uint8Array.from(G)}var fu=(l,A)=>bg(l<<3|A),sZ=(l,A)=>rZ(fu(l,2),bg(A.length),A),uh=(l,A)=>rZ(fu(l,0),bg(A));function Qv(l){let A=[sZ(2,l.subject),uh(3,l.canDelegate?1:0)];return l.bucketId!==void 0&&A.push(uh(4,l.bucketId)),l.operations.length>0&&A.push(sZ(5,rZ(...l.operations.map(G=>bg(G))))),A.push(uh(6,l.expiresAt)),rZ(...A)}var Nv="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Ev(l){let A=[0];for(let b of l){let t=b;for(let c=0;c<A.length;c++)t+=A[c]<<8,A[c]=t%58,t=Math.floor(t/58);for(;t>0;)A.push(t%58),t=Math.floor(t/58)}let G="";for(let b=0;b<l.length&&l[b]===0;b++)G+="1";for(let b=A.length-1;b>=0;b--)G+=Nv[A[b]];return G}async function Ih(l,A){if(l.type!=="ed25519")throw new Error(`auth-token: only ed25519 signers can mint a DDC AuthToken here (signer reports "${l.type}")`);let G=sZ(2,Qv(A)),b=await l.sign(G,"token"),t=rZ(sZ(2,l.publicKey),sZ(3,b));return Ev(rZ(sZ(1,t),G))}var vv=24*60*60*1e3,Rh=365*vv,ku=Rh-60*60*1e3,{GET:wu,PUT:Uu,DELETE:Hv}=Yh,Cu=[wu,Uu,Hv],Su=[wu,Uu],Jv=(1n<<64n)-1n,fv=(1n<<63n)-1n;function xu(l,A,G){let b;if(typeof A=="bigint")b=A;else if(/^[0-9]+$/.test(A))b=BigInt(A);else throw new Error(`${l} must be a decimal chain bucket id, got "${A}"`);if(b<=0n||b>G)throw new Error(`${l} ${b} is out of range: a chain bucket id is 1..${G}`);return b}function xv(l){let A=l.replace(/^0x/i,"");if(!/^[0-9a-fA-F]{64}$/.test(A))throw new Error(`delegatePubkey must be a 32-byte hex key, got "${l}"`);return Te(A)}async function Xh(l){let A=xu("vaultBucketId",l.vaultBucketId,Jv),G=xu("registryBucketId",l.registryBucketId,fv);if(A===G)throw new Error(`vaultBucketId and registryBucketId are the same bucket (${A}): the vault bucket is private because it holds memory and the registry bucket is public because agent code is read anonymously`);let b=xv(l.delegatePubkey),t=(l.now??Date.now)(),c=l.expiresAt===void 0?t+ku:l.expiresAt instanceof Date?l.expiresAt.getTime():l.expiresAt;if(!Number.isSafeInteger(c)||c<=t)throw new Error(`expiresAt must be in the future, got ${new Date(c).toISOString()}`);if(c>t+Rh)throw new Error(`expiresAt ${new Date(c).toISOString()} is more than one year away; vault-api refuses delegations beyond that`);if(l.signer.type!=="ed25519")throw new Error(`delegation tokens need an ed25519 owner wallet (signer reports "${l.signer.type}")`);let B=await Ih(l.signer,{subject:b,canDelegate:!0,bucketId:A,operations:Cu,expiresAt:c}),e=await Ih(l.signer,{subject:b,canDelegate:!0,bucketId:G,operations:Su,expiresAt:c});return{vaultDelegationToken:B,registryDelegationToken:e,expiresAt:new Date(c)}}var TH="https://ddc-s3-gateway.compute.dev.ddcdragon.com/auth/info",DH="https://agent-marketplace.compute.dev.ddcdragon.com",LH=3,OH=[2e3,5e3];function PH(l){return l.status===425||l.status===503&&l.retryable===!0}var qZ=class{constructor(A){el(this,"http");el(this,"marketplaceHttp");el(this,"endpoint");el(this,"chainUrl");el(this,"vaults");el(this,"gar");el(this,"signer");el(this,"s3GatewayAuthInfoUrl");el(this,"fetchFn");el(this,"marketplace");el(this,"health");el(this,"memberships");el(this,"vault",{ensure:async(A={})=>{let G=A.onProgress??(()=>{});if(A.onboard!==!1&&this.signer){let B=vu(this.signer),e=this.gatewayBaseUrl();G({kind:"inspecting-wallet"});let d=await Ju(e,B,this.fetchFn,()=>{G({kind:"funding-wallet"})});if(d.kind==="awaiting-proxy")throw G({kind:"gateway-authorization-required",status:d.status}),new Pd("Onboarding required: the gateway does not yet see this wallet's on-chain proxy authorization. Register it externally via `@cef-ai/account`'s `provisioning.ensure({ signer, chainUrl, gateway })`, wait for it to resolve, then retry `vault.ensure()`.")}let t=A.delegationToken;if(!t){if(!this.signer)throw new Error("vault.ensure() needs either a `delegationToken` or a `signer` configured on VaultSDKConfig (the signer drives the on-chain vault-delegate grant).");let B=A.chainUrl??this.chainUrl;if(!B)throw new Error("vault.ensure(): `chainUrl` is required on the wallet path \u2014 the SDK grants vault-api write delegation by submitting an on-chain NonTransfer proxy (`@cef-ai/account`'s `ensureVaultDelegate`) before claiming the vault. Set `chainUrl` on VaultSDKConfig (or pass it per call) with a Cere node WS URL, or pass `delegationToken` to use the legacy token-bearing claim instead.");G({kind:"authorizing-vault"});let{ensureVaultDelegate:e}=await Promise.resolve().then(()=>(OF(),LF));await e({signer:this.signer,chainUrl:B,vaultApiUrl:this.endpoint,fetchFn:this.fetchFn})}G({kind:"provisioning-vault"});let c=await this.claimVaultWithRetry({name:A.name,label:"vault",...t?{delegation_token:t}:{}},A.sleep);return new xc(this.http,c,{gar:this.gar,signer:this.signer})},current:async()=>{let A=await this.vaults.current();return new xc(this.http,A,{gar:this.gar,signer:this.signer})},byId:async A=>{let G=await this.vaults.byId(A);return new xc(this.http,G,{gar:this.gar,signer:this.signer})},rename:async(A,G)=>{let b=await this.vaults.patch(A,{displayName:G,timestamp:new Date().toISOString()});return new xc(this.http,b,{gar:this.gar,signer:this.signer})},delegations:{put:async(A,G)=>{let b=await this.vaults.putDelegations(A,{vaultDelegationToken:G.vaultDelegationToken,registryDelegationToken:G.registryDelegationToken,timestamp:new Date().toISOString()}),{vaultBucketId:t,registryBucketId:c,delegationsExpireAt:B,...e}=b;return{vault:new xc(this.http,{...e,registryBucketId:c},{gar:this.gar,signer:this.signer}),vaultBucketId:t,registryBucketId:c,delegationsExpireAt:B}},grant:async(A,G)=>{if(!this.signer)throw new Rt;let{delegatePubkey:b}=await new Kd(this.http).delegate(),t=await Xh({signer:this.signer,delegatePubkey:b,vaultBucketId:G.vaultBucketId,registryBucketId:G.registryBucketId,expiresAt:G.expiresAt});return this.vault.delegations.put(A,t)}}});let G=A.auth??(A.signer?new Od(A.signer):void 0);this.endpoint=A.endpoint,this.chainUrl=A.chainUrl,this.http=new Le({url:A.endpoint,auth:G,fetch:A.fetch,timeoutMs:A.timeoutMs}),this.marketplaceHttp=new Le({url:A.marketplaceEndpoint??DH,fetch:A.fetch,timeoutMs:A.timeoutMs}),A.garEndpoint&&(this.gar=new hZ(new Le({url:A.garEndpoint,fetch:A.fetch,timeoutMs:A.timeoutMs}))),this.signer=A.signer,this.s3GatewayAuthInfoUrl=A.s3GatewayAuthInfoUrl??TH,this.fetchFn=A.fetch??fetch.bind(globalThis),this.vaults=new sa(this.http),this.marketplace=new Ma(this.marketplaceHttp),this.health=new Ta(this.http),this.memberships=new ja(this.http,A.signer)}gatewayBaseUrl(){return this.s3GatewayAuthInfoUrl.replace(/\/+$/,"").replace(/\/auth\/info$/,"")}async claimVaultWithRetry(A,G){let b=G??(t=>new Promise(c=>setTimeout(c,t)));for(let t=1;;t++)try{return await this.vaults.claim(A)}catch(c){if(t>=LH||!(c instanceof $G)||!PH(c))throw c;await b(OH[t-1])}}};function PF(){return gu().then(()=>{if(!TA())throw new Error("Unable to initialize @polkadot/util-crypto");return!0}).catch(()=>!1)}function Fi(l){return l instanceof Uint8Array||ArrayBuffer.isView(l)&&l.constructor.name==="Uint8Array"}function KH(l,...A){if(!Fi(l))throw new Error("Uint8Array expected");if(A.length>0&&!A.includes(l.length))throw new Error("Uint8Array expected of length "+A+", got length="+l.length)}function _F(l,A){return Array.isArray(A)?A.length===0?!0:l?A.every(G=>typeof G=="string"):A.every(G=>Number.isSafeInteger(G)):!1}function xn(l,A){if(typeof A!="string")throw new Error(`${l}: string expected`);return!0}function kn(l){if(!Number.isSafeInteger(l))throw new Error(`invalid integer: ${l}`)}function fW(l){if(!Array.isArray(l))throw new Error("array expected")}function xW(l,A){if(!_F(!0,A))throw new Error(`${l}: array of strings expected`)}function $F(l,A){if(!_F(!1,A))throw new Error(`${l}: array of numbers expected`)}function ly(...l){let A=c=>c,G=(c,B)=>e=>c(B(e)),b=l.map(c=>c.encode).reduceRight(G,A),t=l.map(c=>c.decode).reduce(G,A);return{encode:b,decode:t}}function Ay(l){let A=typeof l=="string"?l.split(""):l,G=A.length;xW("alphabet",A);let b=new Map(A.map((t,c)=>[t,c]));return{encode:t=>(fW(t),t.map(c=>{if(!Number.isSafeInteger(c)||c<0||c>=G)throw new Error(`alphabet.encode: digit index outside alphabet "${c}". Allowed: ${l}`);return A[c]})),decode:t=>(fW(t),t.map(c=>{xn("alphabet.decode",c);let B=b.get(c);if(B===void 0)throw new Error(`Unknown letter: "${c}". Allowed: ${l}`);return B}))}}function Gy(l=""){return xn("join",l),{encode:A=>(xW("join.decode",A),A.join(l)),decode:A=>(xn("join.decode",A),A.split(l))}}function qH(l,A="="){return kn(l),xn("padding",A),{encode(G){for(xW("padding.encode",G);G.length*l%8;)G.push(A);return G},decode(G){xW("padding.decode",G);let b=G.length;if(b*l%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;b>0&&G[b-1]===A;b--)if((b-1)*l%8===0)throw new Error("padding: invalid, string has too much padding");return G.slice(0,b)}}}function KF(l,A,G){if(A<2)throw new Error(`convertRadix: invalid from=${A}, base cannot be less than 2`);if(G<2)throw new Error(`convertRadix: invalid to=${G}, base cannot be less than 2`);if(fW(l),!l.length)return[];let b=0,t=[],c=Array.from(l,e=>{if(kn(e),e<0||e>=A)throw new Error(`invalid integer: ${e}`);return e}),B=c.length;for(;;){let e=0,d=!0;for(let Z=b;Z<B;Z++){let a=c[Z],n=A*e,h=n+a;if(!Number.isSafeInteger(h)||n/A!==e||h-a!==n)throw new Error("convertRadix: carry overflow");let W=h/G;e=h%G;let i=Math.floor(W);if(c[Z]=i,!Number.isSafeInteger(i)||i*G+e!==h)throw new Error("convertRadix: carry overflow");if(d)i?d=!1:b=Z;else continue}if(t.push(e),d)break}for(let e=0;e<l.length-1&&l[e]===0;e++)t.push(0);return t.reverse()}var by=(l,A)=>A===0?l:by(A,l%A),kW=(l,A)=>l+(A-by(l,A)),pi=(()=>{let l=[];for(let A=0;A<40;A++)l.push(2**A);return l})();function qF(l,A,G,b){if(fW(l),A<=0||A>32)throw new Error(`convertRadix2: wrong from=${A}`);if(G<=0||G>32)throw new Error(`convertRadix2: wrong to=${G}`);if(kW(A,G)>32)throw new Error(`convertRadix2: carry overflow from=${A} to=${G} carryBits=${kW(A,G)}`);let t=0,c=0,B=pi[A],e=pi[G]-1,d=[];for(let Z of l){if(kn(Z),Z>=B)throw new Error(`convertRadix2: invalid data word=${Z} from=${A}`);if(t=t<<A|Z,c+A>32)throw new Error(`convertRadix2: carry overflow pos=${c} from=${A}`);for(c+=A;c>=G;c-=G)d.push((t>>c-G&e)>>>0);let a=pi[c];if(a===void 0)throw new Error("invalid carry");t&=a-1}if(t=t<<G-c&e,!b&&c>=A)throw new Error("Excess padding");if(!b&&t>0)throw new Error(`Non-zero padding: ${t}`);return b&&c>0&&d.push(t>>>0),d}function _H(l){kn(l);let A=2**8;return{encode:G=>{if(!Fi(G))throw new Error("radix.encode input should be Uint8Array");return KF(Array.from(G),A,l)},decode:G=>($F("radix.decode",G),Uint8Array.from(KF(G,l,A)))}}function $H(l,A=!1){if(kn(l),l<=0||l>32)throw new Error("radix2: bits should be in (0..32]");if(kW(8,l)>32||kW(l,8)>32)throw new Error("radix2: carry overflow");return{encode:G=>{if(!Fi(G))throw new Error("radix2.encode input should be Uint8Array");return qF(Array.from(G),8,l,!A)},decode:G=>($F("radix2.decode",G),Uint8Array.from(qF(G,l,8,A)))}}var l5=typeof Uint8Array.from([]).toBase64=="function"&&typeof Uint8Array.fromBase64=="function",A5=(l,A)=>{xn("base64",l);let G=A?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,b=A?"base64url":"base64";if(l.length>0&&!G.test(l))throw new Error("invalid base64");return Uint8Array.fromBase64(l,{alphabet:b,lastChunkHandling:"strict"})},ty=l5?{encode(l){return KH(l),l.toBase64()},decode(l){return A5(l,!1)}}:ly($H(6),Ay("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),qH(6),Gy(""));var G5=l=>ly(_H(58),Ay(l),Gy("")),cy=G5("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function wW({coder:l,ipfs:A},G){return(b,t)=>(G(b,t),l.decode(A&&t?b.substring(1):b))}function UW({coder:l,ipfs:A}){return(G,b)=>{let t=l.encode(Tl(G));return A&&b?`${A}${t}`:t}}function CW({chars:l,ipfs:A,type:G,withPadding:b}){return(t,c)=>{if(typeof t!="string")throw new Error(`Expected ${G} string input`);if(A&&c&&!t.startsWith(A))throw new Error(`Expected ipfs-compatible ${G} to start with '${A}'`);for(let B=c?1:0,e=t.length;B<e;B++)if(!l.includes(t[B]))if(b&&t[B]==="="){if(B!==e-1){if(t[B+1]!=="=")throw new Error(`Invalid ${G} padding sequence "${t[B]}${t[B+1]}" at index ${B}`)}}else throw new Error(`Invalid ${G} character "${t[B]}" (0x${t.charCodeAt(B).toString(16)}) at index ${B}`);return!0}}var yi={chars:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",coder:cy,ipfs:"z",type:"base58"},By=CW(yi),Qi=wW(yi,By),Ni=UW(yi);var t5=uG("SS58PRE");function SW(l){return Tb(nG(t5,l),512)}function ey(l){let A=l[0]&64?2:1,G=A===1?l[0]:(l[0]&63)<<2|l[1]>>6|(l[1]&63)<<8,b=[34+A,35+A].includes(l.length),t=l.length-(b?2:1),c=SW(l.subarray(0,t));return[(l[0]&128)===0&&![46,47].includes(l[0])&&(b?l[l.length-2]===c[0]&&l[l.length-1]===c[1]:l[l.length-1]===c[0]),t,A,G]}var Zy=[{prefix:0,network:"polkadot",displayName:"Polkadot Relay Chain",symbols:["DOT"],decimals:[10],standardAccount:"*25519",website:"https://polkadot.network"},{prefix:1,network:"BareSr25519",displayName:"Bare 32-bit Schnorr/Ristretto (S/R 25519) public key.",symbols:[],decimals:[],standardAccount:"Sr25519",website:null},{prefix:2,network:"kusama",displayName:"Kusama Relay Chain",symbols:["KSM"],decimals:[12],standardAccount:"*25519",website:"https://kusama.network"},{prefix:3,network:"BareEd25519",displayName:"Bare 32-bit Ed25519 public key.",symbols:[],decimals:[],standardAccount:"Ed25519",website:null},{prefix:4,network:"katalchain",displayName:"Katal Chain",symbols:[],decimals:[],standardAccount:"*25519",website:null},{prefix:5,network:"astar",displayName:"Astar Network",symbols:["ASTR"],decimals:[18],standardAccount:"*25519",website:"https://astar.network"},{prefix:6,network:"bifrost",displayName:"Bifrost",symbols:["BNC"],decimals:[12],standardAccount:"*25519",website:"https://bifrost.finance/"},{prefix:7,network:"edgeware",displayName:"Edgeware",symbols:["EDG"],decimals:[18],standardAccount:"*25519",website:"https://edgewa.re"},{prefix:8,network:"karura",displayName:"Karura",symbols:["KAR"],decimals:[12],standardAccount:"*25519",website:"https://karura.network/"},{prefix:9,network:"reynolds",displayName:"Laminar Reynolds Canary",symbols:["REY"],decimals:[18],standardAccount:"*25519",website:"http://laminar.network/"},{prefix:10,network:"acala",displayName:"Acala",symbols:["ACA"],decimals:[12],standardAccount:"*25519",website:"https://acala.network/"},{prefix:11,network:"laminar",displayName:"Laminar",symbols:["LAMI"],decimals:[18],standardAccount:"*25519",website:"http://laminar.network/"},{prefix:12,network:"polymesh",displayName:"Polymesh",symbols:["POLYX"],decimals:[6],standardAccount:"*25519",website:"https://polymath.network/"},{prefix:13,network:"integritee",displayName:"Integritee",symbols:["TEER"],decimals:[12],standardAccount:"*25519",website:"https://integritee.network"},{prefix:14,network:"totem",displayName:"Totem",symbols:["TOTEM"],decimals:[0],standardAccount:"*25519",website:"https://totemaccounting.com"},{prefix:15,network:"synesthesia",displayName:"Synesthesia",symbols:["SYN"],decimals:[12],standardAccount:"*25519",website:"https://synesthesia.network/"},{prefix:16,network:"kulupu",displayName:"Kulupu",symbols:["KLP"],decimals:[12],standardAccount:"*25519",website:"https://kulupu.network/"},{prefix:17,network:"dark",displayName:"Dark Mainnet",symbols:[],decimals:[],standardAccount:"*25519",website:null},{prefix:18,network:"darwinia",displayName:"Darwinia Network",symbols:["RING"],decimals:[18],standardAccount:"secp256k1",website:"https://darwinia.network"},{prefix:19,network:"watr",displayName:"Watr Protocol",symbols:["WATR"],decimals:[18],standardAccount:"*25519",website:"https://www.watr.org"},{prefix:20,network:"stafi",displayName:"Stafi",symbols:["FIS"],decimals:[12],standardAccount:"*25519",website:"https://stafi.io"},{prefix:21,network:"karmachain",displayName:"Karmacoin",symbols:["KCOIN"],decimals:[6],standardAccount:"*25519",website:"https://karmaco.in"},{prefix:22,network:"dock-pos-mainnet",displayName:"Dock Mainnet",symbols:["DCK"],decimals:[6],standardAccount:"*25519",website:"https://dock.io"},{prefix:23,network:"shift",displayName:"ShiftNrg",symbols:[],decimals:[],standardAccount:"*25519",website:null},{prefix:24,network:"zero",displayName:"ZERO",symbols:["ZERO"],decimals:[18],standardAccount:"*25519",website:"https://zero.io"},{prefix:25,network:"zero-alphaville",displayName:"ZERO Alphaville",symbols:["ZERO"],decimals:[18],standardAccount:"*25519",website:"https://zero.io"},{prefix:26,network:"jupiter",displayName:"Jupiter",symbols:["jDOT"],decimals:[10],standardAccount:"*25519",website:"https://jupiter.patract.io"},{prefix:27,network:"kabocha",displayName:"Kabocha",symbols:["KAB"],decimals:[12],standardAccount:"*25519",website:"https://kabocha.network"},{prefix:28,network:"subsocial",displayName:"Subsocial",symbols:[],decimals:[],standardAccount:"*25519",website:null},{prefix:29,network:"cord",displayName:"CORD Network",symbols:["DHI","WAY"],decimals:[12,12],standardAccount:"*25519",website:"https://cord.network/"},{prefix:30,network:"phala",displayName:"Phala Network",symbols:["PHA"],decimals:[12],standardAccount:"*25519",website:"https://phala.network"},{prefix:31,network:"litentry",displayName:"Litentry Network",symbols:["LIT"],decimals:[12],standardAccount:"*25519",website:"https://litentry.com/"},{prefix:32,network:"robonomics",displayName:"Robonomics",symbols:["XRT"],decimals:[9],standardAccount:"*25519",website:"https://robonomics.network"},{prefix:33,network:"datahighway",displayName:"DataHighway",symbols:[],decimals:[],standardAccount:"*25519",website:null},{prefix:34,network:"ares",displayName:"Ares Protocol",symbols:["ARES"],decimals:[12],standardAccount:"*25519",website:"https://www.aresprotocol.com/"},{prefix:35,network:"vln",displayName:"Valiu Liquidity Network",symbols:["USDv"],decimals:[15],standardAccount:"*25519",website:"https://valiu.com/"},{prefix:36,network:"centrifuge",displayName:"Centrifuge Chain",symbols:["CFG"],decimals:[18],standardAccount:"*25519",website:"https://centrifuge.io/"},{prefix:37,network:"nodle",displayName:"Nodle Chain",symbols:["NODL"],decimals:[11],standardAccount:"*25519",website:"https://nodle.io/"},{prefix:38,network:"kilt",displayName:"KILT Spiritnet",symbols:["KILT"],decimals:[15],standardAccount:"*25519",website:"https://kilt.io/"},{prefix:39,network:"mathchain",displayName:"MathChain mainnet",symbols:["MATH"],decimals:[18],standardAccount:"*25519",website:"https://mathwallet.org"},{prefix:40,network:"mathchain-testnet",displayName:"MathChain testnet",symbols:["MATH"],decimals:[18],standardAccount:"*25519",website:"https://mathwallet.org"},{prefix:41,network:"polimec",displayName:"Polimec Protocol",symbols:["PLMC"],decimals:[10],standardAccount:"*25519",website:"https://www.polimec.org/"},{prefix:42,network:"substrate",displayName:"Substrate",symbols:[],decimals:[],standardAccount:"*25519",website:"https://substrate.io/"},{prefix:43,network:"BareSecp256k1",displayName:"Bare 32-bit ECDSA SECP-256k1 public key.",symbols:[],decimals:[],standardAccount:"secp256k1",website:null},{prefix:44,network:"chainx",displayName:"ChainX",symbols:["PCX"],decimals:[8],standardAccount:"*25519",website:"https://chainx.org/"},{prefix:45,network:"uniarts",displayName:"UniArts Network",symbols:["UART","UINK"],decimals:[12,12],standardAccount:"*25519",website:"https://uniarts.me"},{prefix:46,network:"reserved46",displayName:"This prefix is reserved.",symbols:[],decimals:[],standardAccount:null,website:null},{prefix:47,network:"reserved47",displayName:"This prefix is reserved.",symbols:[],decimals:[],standardAccount:null,website:null},{prefix:48,network:"neatcoin",displayName:"Neatcoin Mainnet",symbols:["NEAT"],decimals:[12],standardAccount:"*25519",website:"https://neatcoin.org"},{prefix:49,network:"picasso",displayName:"Picasso",symbols:["PICA"],decimals:[12],standardAccount:"*25519",website:"https://picasso.composable.finance"},{prefix:50,network:"composable",displayName:"Composable Finance",symbols:["LAYR"],decimals:[12],standardAccount:"*25519",website:"https://composable.finance"},{prefix:51,network:"oak",displayName:"OAK Network",symbols:["OAK","TUR"],decimals:[10,10],standardAccount:"*25519",website:"https://oak.tech"},{prefix:52,network:"KICO",displayName:"KICO",symbols:["KICO"],decimals:[14],standardAccount:"*25519",website:"https://dico.io"},{prefix:53,network:"DICO",displayName:"DICO",symbols:["DICO"],decimals:[14],standardAccount:"*25519",website:"https://dico.io"},{prefix:54,network:"cere",displayName:"Cere Network",symbols:["CERE"],decimals:[10],standardAccount:"*25519",website:"https://cere.network"},{prefix:55,network:"xxnetwork",displayName:"xx network",symbols:["XX"],decimals:[9],standardAccount:"*25519",website:"https://xx.network"},{prefix:56,network:"pendulum",displayName:"Pendulum chain",symbols:["PEN"],decimals:[12],standardAccount:"*25519",website:"https://pendulumchain.org/"},{prefix:57,network:"amplitude",displayName:"Amplitude chain",symbols:["AMPE"],decimals:[12],standardAccount:"*25519",website:"https://pendulumchain.org/"},{prefix:58,network:"eternal-civilization",displayName:"Eternal Civilization",symbols:["ECC"],decimals:[12],standardAccount:"*25519",website:"http://www.ysknfr.cn/"},{prefix:63,network:"hydradx",displayName:"Hydration",symbols:["HDX"],decimals:[12],standardAccount:"*25519",website:"https://hydration.net"},{prefix:65,network:"aventus",displayName:"Aventus Mainnet",symbols:["AVT"],decimals:[18],standardAccount:"*25519",website:"https://aventus.io"},{prefix:66,network:"crust",displayName:"Crust Network",symbols:["CRU"],decimals:[12],standardAccount:"*25519",website:"https://crust.network"},{prefix:67,network:"genshiro",displayName:"Genshiro Network",symbols:["GENS","EQD","LPT0"],decimals:[9,9,9],standardAccount:"*25519",website:"https://genshiro.equilibrium.io"},{prefix:68,network:"equilibrium",displayName:"Equilibrium Network",symbols:["EQ"],decimals:[9],standardAccount:"*25519",website:"https://equilibrium.io"},{prefix:69,network:"sora",displayName:"SORA Network",symbols:["XOR"],decimals:[18],standardAccount:"*25519",website:"https://sora.org"},{prefix:71,network:"p3d",displayName:"3DP network",symbols:["P3D"],decimals:[12],standardAccount:"*25519",website:"https://3dpass.org"},{prefix:72,network:"p3dt",displayName:"3DP test network",symbols:["P3Dt"],decimals:[12],standardAccount:"*25519",website:"https://3dpass.org"},{prefix:73,network:"zeitgeist",displayName:"Zeitgeist",symbols:["ZTG"],decimals:[10],standardAccount:"*25519",website:"https://zeitgeist.pm"},{prefix:77,network:"manta",displayName:"Manta network",symbols:["MANTA"],decimals:[18],standardAccount:"*25519",website:"https://manta.network"},{prefix:78,network:"calamari",displayName:"Calamari: Manta Canary Network",symbols:["KMA"],decimals:[12],standardAccount:"*25519",website:"https://manta.network"},{prefix:81,network:"sora_dot_para",displayName:"SORA Polkadot Parachain",symbols:["XOR"],decimals:[18],standardAccount:"*25519",website:"https://sora.org"},{prefix:88,network:"polkadex",displayName:"Polkadex Mainnet",symbols:["PDEX"],decimals:[12],standardAccount:"*25519",website:"https://polkadex.trade"},{prefix:89,network:"polkadexparachain",displayName:"Polkadex Parachain",symbols:["PDEX"],decimals:[12],standardAccount:"*25519",website:"https://polkadex.trade"},{prefix:90,network:"frequency",displayName:"Frequency",symbols:["FRQCY"],decimals:[8],standardAccount:"*25519",website:"https://www.frequency.xyz"},{prefix:92,network:"anmol",displayName:"Anmol Network",symbols:["ANML"],decimals:[18],standardAccount:"*25519",website:"https://anmol.network/"},{prefix:93,network:"fragnova",displayName:"Fragnova Network",symbols:["NOVA"],decimals:[12],standardAccount:"*25519",website:"https://fragnova.com"},{prefix:98,network:"polkasmith",displayName:"PolkaSmith Canary Network",symbols:["PKS"],decimals:[18],standardAccount:"*25519",website:"https://polkafoundry.com"},{prefix:99,network:"polkafoundry",displayName:"PolkaFoundry Network",symbols:["PKF"],decimals:[18],standardAccount:"*25519",website:"https://polkafoundry.com"},{prefix:100,network:"ibtida",displayName:"Anmol Network Ibtida Canary network",symbols:["IANML"],decimals:[18],standardAccount:"*25519",website:"https://anmol.network/"},{prefix:101,network:"origintrail-parachain",displayName:"OriginTrail Parachain",symbols:["OTP"],decimals:[12],standardAccount:"*25519",website:"https://parachain.origintrail.io/"},{prefix:105,network:"pontem-network",displayName:"Pontem Network",symbols:["PONT"],decimals:[10],standardAccount:"*25519",website:"https://pontem.network"},{prefix:110,network:"heiko",displayName:"Heiko",symbols:["HKO"],decimals:[12],standardAccount:"*25519",website:"https://parallel.fi/"},{prefix:113,network:"integritee-incognito",displayName:"Integritee Incognito",symbols:[],decimals:[],standardAccount:"*25519",website:"https://integritee.network"},{prefix:117,network:"tinker",displayName:"Tinker",symbols:["TNKR"],decimals:[12],standardAccount:"*25519",website:"https://invarch.network"},{prefix:126,network:"joystream",displayName:"Joystream",symbols:["JOY"],decimals:[10],standardAccount:"*25519",website:"https://www.joystream.org"},{prefix:128,network:"clover",displayName:"Clover Finance",symbols:["CLV"],decimals:[18],standardAccount:"*25519",website:"https://clover.finance"},{prefix:129,network:"dorafactory-polkadot",displayName:"Dorafactory Polkadot Network",symbols:["DORA"],decimals:[12],standardAccount:"*25519",website:"https://dorafactory.org"},{prefix:131,network:"litmus",displayName:"Litmus Network",symbols:["LIT"],decimals:[12],standardAccount:"*25519",website:"https://litentry.com/"},{prefix:136,network:"altair",displayName:"Altair",symbols:["AIR"],decimals:[18],standardAccount:"*25519",website:"https://centrifuge.io/"},{prefix:137,network:"vara",displayName:"Vara Network",symbols:["VARA"],decimals:[12],standardAccount:"*25519",website:"https://vara.network/"},{prefix:172,network:"parallel",displayName:"Parallel",symbols:["PARA"],decimals:[12],standardAccount:"*25519",website:"https://parallel.fi/"},{prefix:252,network:"social-network",displayName:"Social Network",symbols:["NET"],decimals:[18],standardAccount:"*25519",website:"https://social.network"},{prefix:255,network:"quartz_mainnet",displayName:"QUARTZ by UNIQUE",symbols:["QTZ"],decimals:[18],standardAccount:"*25519",website:"https://unique.network"},{prefix:268,network:"pioneer_network",displayName:"Pioneer Network by Bit.Country",symbols:["NEER"],decimals:[18],standardAccount:"*25519",website:"https://bit.country"},{prefix:420,network:"sora_kusama_para",displayName:"SORA Kusama Parachain",symbols:["XOR"],decimals:[18],standardAccount:"*25519",website:"https://sora.org"},{prefix:440,network:"allfeat_network",displayName:"Allfeat Network",symbols:["AFT"],decimals:[12],standardAccount:"*25519",website:"https://allfeat.network"},{prefix:666,network:"metaquity_network",displayName:"Metaquity Network",symbols:["MQTY"],decimals:[18],standardAccount:"*25519",website:"https://metaquity.xyz/"},{prefix:777,network:"curio",displayName:"Curio",symbols:["CGT"],decimals:[18],standardAccount:"*25519",website:"https://parachain.capitaldex.exchange/"},{prefix:789,network:"geek",displayName:"GEEK Network",symbols:["GEEK"],decimals:[18],standardAccount:"*25519",website:"https://geek.gl"},{prefix:995,network:"ternoa",displayName:"Ternoa",symbols:["CAPS"],decimals:[18],standardAccount:"*25519",website:"https://www.ternoa.network"},{prefix:1110,network:"efinity",displayName:"Efinity",symbols:["EFI"],decimals:[18],standardAccount:"*25519",website:"https://efinity.io/"},{prefix:1221,network:"peaq",displayName:"Peaq Network",symbols:["PEAQ"],decimals:[18],standardAccount:"Sr25519",website:"https://www.peaq.network/"},{prefix:1222,network:"krest",displayName:"Krest Network",symbols:["KREST"],decimals:[18],standardAccount:"Sr25519",website:"https://www.peaq.network/"},{prefix:1284,network:"moonbeam",displayName:"Moonbeam",symbols:["GLMR"],decimals:[18],standardAccount:"secp256k1",website:"https://moonbeam.network"},{prefix:1285,network:"moonriver",displayName:"Moonriver",symbols:["MOVR"],decimals:[18],standardAccount:"secp256k1",website:"https://moonbeam.network"},{prefix:1328,network:"ajuna",displayName:"Ajuna Network",symbols:["AJUN"],decimals:[12],standardAccount:"*25519",website:"https://ajuna.io"},{prefix:1337,network:"bajun",displayName:"Bajun Network",symbols:["BAJU"],decimals:[12],standardAccount:"*25519",website:"https://ajuna.io"},{prefix:1516,network:"societal",displayName:"Societal",symbols:["SCTL"],decimals:[12],standardAccount:"*25519",website:"https://www.sctl.xyz"},{prefix:1985,network:"seals",displayName:"Seals Network",symbols:["SEAL"],decimals:[9],standardAccount:"*25519",website:"https://seals.app"},{prefix:2007,network:"kapex",displayName:"Kapex",symbols:["KAPEX"],decimals:[12],standardAccount:"*25519",website:"https://totemaccounting.com"},{prefix:2009,network:"cloudwalk_mainnet",displayName:"CloudWalk Network Mainnet",symbols:["CWN"],decimals:[18],standardAccount:"*25519",website:"https://explorer.mainnet.cloudwalk.io"},{prefix:2021,network:"logion",displayName:"logion network",symbols:["LGNT"],decimals:[18],standardAccount:"*25519",website:"https://logion.network"},{prefix:2024,network:"vow-chain",displayName:"Enigmatic Smile",symbols:["VOW"],decimals:[18],standardAccount:"*25519",website:"https://www.vow.foundation/"},{prefix:2032,network:"interlay",displayName:"Interlay",symbols:["INTR"],decimals:[10],standardAccount:"*25519",website:"https://interlay.io/"},{prefix:2092,network:"kintsugi",displayName:"Kintsugi",symbols:["KINT"],decimals:[12],standardAccount:"*25519",website:"https://interlay.io/"},{prefix:2106,network:"bitgreen",displayName:"Bitgreen",symbols:["BBB"],decimals:[18],standardAccount:"*25519",website:"https://bitgreen.org/"},{prefix:2112,network:"chainflip",displayName:"Chainflip",symbols:["FLIP"],decimals:[18],standardAccount:"*25519",website:"https://chainflip.io/"},{prefix:2199,network:"moonsama",displayName:"Moonsama",symbols:["SAMA"],decimals:[18],standardAccount:"secp256k1",website:"https://moonsama.com"},{prefix:2206,network:"ICE",displayName:"ICE Network",symbols:["ICY"],decimals:[18],standardAccount:"*25519",website:"https://icenetwork.io"},{prefix:2207,network:"SNOW",displayName:"SNOW: ICE Canary Network",symbols:["ICZ"],decimals:[18],standardAccount:"*25519",website:"https://icenetwork.io"},{prefix:2254,network:"subspace_testnet",displayName:"Subspace testnet",symbols:["tSSC"],decimals:[18],standardAccount:"*25519",website:"https://subspace.network"},{prefix:3333,network:"peerplays",displayName:"Peerplays",symbols:["PPY"],decimals:[18],standardAccount:"secp256k1",website:"https://www.peerplays.com/"},{prefix:4450,network:"g1",displayName:"\u011E1",symbols:["G1"],decimals:[2],standardAccount:"*25519",website:"https://duniter.org"},{prefix:5234,network:"humanode",displayName:"Humanode Network",symbols:["HMND"],decimals:[18],standardAccount:"*25519",website:"https://humanode.io"},{prefix:5845,network:"tangle",displayName:"Tangle Network",symbols:["TNT"],decimals:[18],standardAccount:"*25519",website:"https://www.tangle.tools/"},{prefix:6094,network:"autonomys",displayName:"Autonomys",symbols:["AI3"],decimals:[18],standardAccount:"*25519",website:"https://autonomys.xyz"},{prefix:7007,network:"tidefi",displayName:"Tidefi",symbols:["TDFY"],decimals:[12],standardAccount:"*25519",website:"https://tidefi.com"},{prefix:7013,network:"gm",displayName:"GM",symbols:["FREN","GM","GN"],decimals:[12,0,0],standardAccount:"*25519",website:"https://gmordie.com"},{prefix:7306,network:"krigan",displayName:"Krigan Network",symbols:["KRGN"],decimals:[9],standardAccount:"*25519",website:"https://krigan.network"},{prefix:7391,network:"unique_mainnet",displayName:"Unique Network",symbols:["UNQ"],decimals:[18],standardAccount:"*25519",website:"https://unique.network"},{prefix:8866,network:"golden_gate",displayName:"Golden Gate",symbols:["GGX"],decimals:[18],standardAccount:"*25519",website:"https://ggxchain.io/"},{prefix:8883,network:"sapphire_mainnet",displayName:"Sapphire by Unique",symbols:["QTZ"],decimals:[18],standardAccount:"*25519",website:"https://unique.network"},{prefix:8886,network:"golden_gate_sydney",displayName:"Golden Gate Sydney",symbols:["GGXT"],decimals:[18],standardAccount:"*25519",website:"https://ggxchain.io/"},{prefix:9072,network:"hashed",displayName:"Hashed Network",symbols:["HASH"],decimals:[18],standardAccount:"*25519",website:"https://hashed.network"},{prefix:9807,network:"dentnet",displayName:"DENTNet",symbols:["DENTX"],decimals:[18],standardAccount:"*25519",website:"https://www.dentnet.io"},{prefix:9935,network:"t3rn",displayName:"t3rn",symbols:["TRN"],decimals:[12],standardAccount:"*25519",website:"https://t3rn.io/"},{prefix:10041,network:"basilisk",displayName:"Basilisk",symbols:["BSX"],decimals:[12],standardAccount:"*25519",website:"https://bsx.fi"},{prefix:11330,network:"cess-testnet",displayName:"CESS Testnet",symbols:["TCESS"],decimals:[18],standardAccount:"*25519",website:"https://cess.cloud"},{prefix:11331,network:"cess",displayName:"CESS",symbols:["CESS"],decimals:[18],standardAccount:"*25519",website:"https://cess.cloud"},{prefix:11486,network:"luhn",displayName:"Luhn Network",symbols:["LUHN"],decimals:[18],standardAccount:"*25519",website:"https://luhn.network"},{prefix:11820,network:"contextfree",displayName:"Automata ContextFree",symbols:["CTX"],decimals:[18],standardAccount:"*25519",website:"https://ata.network"},{prefix:12155,network:"impact",displayName:"Impact Protocol Network",symbols:["BSTY"],decimals:[18],standardAccount:"*25519",website:"https://impactprotocol.network/"},{prefix:12191,network:"nftmart",displayName:"NFTMart",symbols:["NMT"],decimals:[12],standardAccount:"*25519",website:"https://nftmart.io"},{prefix:12850,network:"analog-timechain",displayName:"Analog Timechain",symbols:["ANLOG"],decimals:[12],standardAccount:"*25519",website:"https://analog.one"},{prefix:13116,network:"bittensor",displayName:"Bittensor",symbols:["TAO"],decimals:[9],standardAccount:"*25519",website:"https://bittensor.com"},{prefix:14697,network:"goro",displayName:"GORO Network",symbols:["GORO"],decimals:[9],standardAccount:"*25519",website:"https://goro.network"},{prefix:14998,network:"mosaic-chain",displayName:"Mosaic Chain",symbols:["MOS"],decimals:[18],standardAccount:"*25519",website:"https://mosaicchain.io"},{prefix:29972,network:"mythos",displayName:"Mythos",symbols:["MYTH"],decimals:[18],standardAccount:"secp256k1",website:"https://mythos.foundation"},{prefix:8888,network:"xcavate",displayName:"Xcavate Protocol",symbols:["XCAV"],decimals:[12],standardAccount:"*25519",website:"https://xcavate.io/"}];var Ei={acala:["0xfc41b9bd8ef8fe53d58c7ea67c794c7ec9a73daf05e6d54b14ff6342c99ba64c"],ajuna:["0xe358eb1d11b31255a286c12e44fe6780b7edb171d657905a97e39f71d9c6c3ee"],"aleph-node":["0x70255b4d28de0fc4e1a193d7e175ad1ccef431598211c55538f1018651a0344e"],astar:["0x9eb76c5184c4ab8679d2d5d819fdf90b9c001403e9e17da2e14b6d8aec4029c6"],basilisk:["0xa85cfb9b9fd4d622a5b28289a02347af987d8f73fa3108450e2b4a11c1ce5755"],bifrost:["0x262e1b2ad728475fd6fe88e62d34c200abe6fd693931ddad144059b1eb884e5b"],"bifrost-kusama":["0x9f28c6a68e0fc9646eff64935684f6eeeece527e37bbe1f213d22caa1d9d6bed"],bittensor:["0x2f0555cc76fc2840a25a6ea3b9637146806f1f44b090c175ffde2a7e5ab36c03"],centrifuge:["0xb3db41421702df9a7fcac62b53ffeac85f7853cc4e689e0b93aeb3db18c09d82","0x67dddf2673b69e5f875f6f25277495834398eafd67f492e09f3f3345e003d1b5"],cere:["0x81443836a9a24caaa23f1241897d1235717535711d1d3fe24eae4fdc942c092c"],composable:["0xdaab8df776eb52ec604a5df5d388bb62a050a0aaec4556a64265b9d42755552d"],creditcoin3:["0x4436a7d64e363df85e065a894721002a86643283f9707338bf195d360ba2ee71","0xfc4ec97a1c1f119c4353aecb4a17c7c0cf7b40d5d660143d8bad9117e9866572","0xfc9df99a665f964aed6649f275055e54df5e3420489538ed31d7788f53d11ef6"],darwinia:["0xe71578b37a7c799b0ab4ee87ffa6f059a6b98f71f06fb8c84a8d88013a548ad6"],dentnet:["0x0313f6a011d128d22f996703cbab05162e2fdc9e031493314fe6db79979c5ca7"],"dock-mainnet":["0x6bfe24dca2a3be10f22212678ac13a6446ec764103c0f3471c71609eac384aae","0xf73467c6544aa68df2ee546b135f955c46b90fa627e9b5d7935f41061bb8a5a9"],edgeware:["0x742a2ca70c2fda6cee4f8df98d64c4c670a052d9568058982dad9d5a7a135c5b"],encointer:["0x7dd99936c1e9e6d1ce7d90eb6f33bea8393b4bf87677d675aa63c9cb3e8c5b5b"],enjin:["0xd8761d3c88f26dc12875c00d3165f7d67243d56fc85b4cf19937601a7916e5a9"],equilibrium:["0x6f1a800de3daff7f5e037ddf66ab22ce03ab91874debeddb1086f5f7dbd48925"],frequency:["0x4a587bf17a404e3572747add7aab7bbe56e805a5479c6c436f07f36fcc8d3ae1"],genshiro:["0x9b8cefc0eb5c568b527998bdd76c184e2b76ae561be76e4667072230217ea243"],hydradx:["0xafdc188f45c71dacbaa0b62e16a91f726c7b8699a9748cdf715459de6b7f366d","0xd2a620c27ec5cbc5621ff9a522689895074f7cca0d08e7134a7804e1a3ba86fc","0x10af6e84234477d84dc572bac0789813b254aa490767ed06fb9591191d1073f9","0x3d75507dd46301767e601265791da1d9cb47b6ebc94e87347b635e5bf58bd047","0x0ed32bfcab4a83517fac88f2aa7cbc2f88d3ab93be9a12b6188a036bf8a943c2"],integritee:["0xcdedc8eadbfa209d3f207bba541e57c3c58a667b05a2e1d1e86353c9000758da","0xe13e7af377c64e83f95e0d70d5e5c3c01d697a84538776c5b9bbe0e7d7b6034c"],"interlay-parachain":["0xbf88efe70e9e0e916416e8bed61f2b45717f517d7f3523e33c7b001e5ffcbc72"],karura:["0xbaf5aabe40646d11f0ee8abbdc64f4a4b7674925cba08e4a05ff9ebed6e2126b"],khala:["0xd43540ba6d3eb4897c28a77d48cb5b729fea37603cbbfc7a86a73b72adb3be8d"],kulupu:["0xf7a99d3cb92853d00d5275c971c132c074636256583fee53b3bbe60d7b8769ba"],kusama:["0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe","0xe3777fa922cafbff200cadeaea1a76bd7898ad5b89f7848999058b50e715f636","0x3fd7b9eb6a00376e5be61f01abb429ffb0b104be05eaff4d458da48fcd425baf"],liberland:["0x6bd89e052d67a45bb60a9a23e8581053d5e0d619f15cb9865946937e690c42d6"],matrixchain:["0x3af4ff48ec76d2efc8476730f423ac07e25ad48f5f4c9dc39c778b164d808615"],mythos:["0xf6ee56e9c5277df5b4ce6ae9983ee88f3cbed27d31beeb98f9f84f997a1ab0b9"],nodle:["0x97da7ede98d7bad4e36b4d734b6055425a3be036da2a332ea5a7037656427a21"],origintrail:["0xe7e0962324a3b86c83404dbea483f25fb5dab4c224791c81b756cfc948006174"],p3d:["0x6c5894837ad89b6d92b114a2fb3eafa8fe3d26a54848e3447015442cd6ef4e66"],parallel:["0xe61a41c53f5dcd0beb09df93b34402aada44cb05117b71059cce40a2723a4e97"],peaq:["0xd2a5d385932d1f650dae03ef8e2748983779ee342c614f80854d32b8cd8fa48c"],pendulum:["0x5d3c298622d5634ed019bf61ea4b71655030015bde9beb0d6a24743714462c86"],phala:["0x1bb969d85965e4bb5a651abbedf21a54b6b31a21f66b5401cc3f1e286268d736"],picasso:["0x6811a339673c9daa897944dcdac99c6e2939cc88245ed21951a0a3c9a2be75bc","0xe8e7f0f4c4f5a00720b4821dbfddefea7490bcf0b19009961cc46957984e2c1c"],polimec:["0x7eb9354488318e7549c722669dcbdcdc526f1fef1420e7944667212f3601fdbd"],polkadex:["0x3920bcb4960a1eef5580cd5367ff3f430eef052774f78468852f7b9cb39f8a3c"],polkadot:["0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3"],polymesh:["0x6fbd74e5e1d0a61d52ccfe9d4adaed16dd3a7caa37c6bc4d0c2fa12e8b2f4063"],quartz:["0xcd4d732201ebe5d6b014edda071c4203e16867305332301dc8d092044b28e554"],rococo:["0x6408de7737c59c238890533af25896a2c20608d8b380bb01029acb392781063e","0xaaf2cd1b74b5f726895921259421b534124726263982522174147046b8827897","0x037f5f3c8e67b314062025fc886fcd6238ea25a4a9b45dce8d246815c9ebe770","0xc196f81260cf1686172b47a79cf002120735d7cb0eb1474e8adce56618456fff","0xf6e9983c37baf68846fedafe21e56718790e39fb1c582abc408b81bc7b208f9a","0x5fce687da39305dfe682b117f0820b319348e8bb37eb16cf34acbf6a202de9d9","0xe7c3d5edde7db964317cd9b51a3a059d7cd99f81bdbce14990047354334c9779","0x1611e1dbf0405379b861e2e27daa90f480b2e6d3682414a80835a52e8cb8a215","0x343442f12fa715489a8714e79a7b264ea88c0d5b8c66b684a7788a516032f6b9","0x78bcd530c6b3a068bc17473cf5d2aff9c287102bed9af3ae3c41c33b9d6c6147","0x47381ee0697153d64404fc578392c8fd5cba9073391908f46c888498415647bd","0x19c0e4fa8ab75f5ac7865e0b8f74ff91eb9a100d336f423cd013a8befba40299"],sora:["0x7e4e32d0feafd4f9c9414b0be86373f9a1efa904809b683453a9af6856d38ad5"],stafi:["0x290a4149f09ea0e402c74c1c7e96ae4239588577fe78932f94f5404c68243d80"],statemine:["0x48239ef607d7928874027a43a67689209727dfb3d3dc5e5b03a39bdc2eda771a"],statemint:["0x68d56f15f85d3136970ec16946040bc1752654e906147f7e43e9d539d7c3de2f"],subsocial:["0x0bd72c1c305172e1275278aaeb3f161e02eccb7a819e63f62d47bd53a28189f8"],ternoa:["0x6859c81ca95ef624c9dfe4dc6e3381c33e5d6509e35e147092bfbc780f777c4e"],unique:["0x84322d9cddbf35088f1e54e9a85c967a41a56a4f43445768125e61af166c7d31"],vara:["0xfe1b4c55fd4d668101126434206571a7838a8b6b93a6d1b95d607e78e6c53763"],vtb:["0x286bc8414c7000ce1d6ee6a834e29a54c1784814b76243eb77ed0b2c5573c60f","0x7483b89572fb2bd687c7b9a93b242d0b237f9aba463aba07ec24503931038aaa"],westend:["0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e"],xxnetwork:["0x50dd5d206917bf10502c68fb4d18a59fc8aa31586f4e8856b493e43544aa82aa"],zeitgeist:["0x1bf2a2ecb4a868de66ea8610f2ce7c8c43706561b6476031315f6640fe38e060"]};var vi={centrifuge:"polkadot",kusama:"polkadot",polkadot:"polkadot",sora:"polkadot",statemine:"polkadot",statemint:"polkadot",westmint:"polkadot"};var Hi={acala:787,ajuna:354,"aleph-node":643,astar:810,bifrost:788,"bifrost-kusama":788,bittensor:354,centrifuge:747,composable:354,creditcoin3:354,darwinia:354,dentnet:734,"dock-mainnet":594,edgeware:523,encointer:434,enjin:1155,equilibrium:99999997,frequency:2091,genshiro:99999996,hydradx:354,integritee:2015,"interlay-parachain":354,karura:686,khala:434,kusama:434,liberland:767,matrixchain:1155,mythos:60,nodle:1003,origintrail:354,parallel:354,peaq:3338,pendulum:354,phala:354,picasso:434,polimec:3344,polkadex:799,polkadot:354,polymesh:595,quartz:631,sora:617,stafi:907,statemine:434,statemint:354,ternoa:995,unique:661,vara:4976,vtb:694,xxnetwork:1955,zeitgeist:354};var Ji={"":!0,"cess-testnet":!0,"dock-testnet":!0,jupiter:!0,"mathchain-testnet":!0,p3dt:!0,subspace_testnet:!0,"zero-alphaville":!0};var dy=[0,2,42],c5=["testnet"];function B5(l){let A=l.network||"",G=A.replace(/_/g,"-").split("-"),b=l;return b.slip44=Hi[A],b.hasLedgerSupport=!!b.slip44,b.genesisHash=Ei[A]||[],b.icon=vi[A]||"substrate",b.isTestnet=!!Ji[A]||c5.includes(G[G.length-1]),b.isIgnored=b.isTestnet||!(l.standardAccount&&l.decimals?.length&&l.symbols?.length)&&l.prefix!==42,b}function e5({genesisHash:l,prefix:A}){return!!l.length||A===42}function Z5(l){return!l.isIgnored&&!!l.network}function d5(l,A){let G=dy.includes(l.prefix),b=dy.includes(A.prefix);return G===b?G?0:l.displayName.localeCompare(A.displayName):G?-1:1}var ny=Zy.map(B5),zW=ny.filter(Z5).sort(d5),n5=zW.filter(e5);var _Z={allowedDecodedLengths:[1,2,4,8,32,33],allowedEncodedLengths:[3,4,6,10,35,36,37,38],allowedPrefix:zW.map(({prefix:l})=>l),prefix:42};function Pt(l,A,G=-1){if(!l)throw new Error("Invalid empty address passed");if(Jb(l)||ub(l))return Tl(l);try{let b=Qi(l);if(!_Z.allowedEncodedLengths.includes(b.length))throw new Error("Invalid decoded address length");let[t,c,B,e]=ey(b);if(!t&&!A)throw new Error("Invalid decoded address checksum");if(G!==-1&&G!==e)throw new Error(`Expected ss58Format ${G}, received ${e}`);return b.slice(B,c)}catch(b){throw new Error(`Decoding ${l}: ${b.message}`)}}var fi={isLe:!1},jW={isLe:!0};var ay={bitLength:32,isLe:!1},MW={bitLength:32,isLe:!0},$c={bitLength:256,isLe:!1},gy={bitLength:256,isLe:!0};var a5=/^\d+$/,g5=32,$Z,Fe,xi=class xi{constructor(){EG(this,$Z,new Uint8Array(32));EG(this,Fe,!1)}static from(A){let G=new xi,[b,t]=A.startsWith("/")?[A.substring(1),!0]:[A,!1];return G.soft(a5.test(b)?new FA.default(b,10):b),t?G.harden():G}get chainCode(){return GA(this,$Z)}get isHard(){return GA(this,Fe)}get isSoft(){return!GA(this,Fe)}hard(A){return this.soft(A).harden()}harden(){return bG(this,Fe,!0),this}soft(A){return Gh(A)||Ed(A)||xd(A)?this.soft(wG(A,gy)):ub(A)?this.soft(Hb(A)):Ah(A)?this.soft(be(uG(A))):A.length>g5?this.soft(Tb(A)):(GA(this,$Z).fill(0),GA(this,$Z).set(A,0),this)}soften(){return bG(this,Fe,!1),this}};$Z=new WeakMap,Fe=new WeakMap;var TW=xi;var W5=/\/(\/?)([^/]+)/g;function wn(l){let A=l.match(W5),G=[],b="";if(A){b=A.join("");for(let t of A)G.push(TW.from(t.substring(1)))}if(b!==l)throw new Error(`Re-constructed path "${b}" does not match input`);return{parts:A,path:G}}var o5=/^((0x[a-fA-F0-9]+|[\p{L}\d]+(?: [\p{L}\d]+)*))((\/\/?[^/]+)*)(\/\/\/(.*))?$/u;function ki(l){let G=l.normalize("NFC").match(o5);if(G===null)throw new Error("Unable to match provided value to a secret URI");let[,b,,t,,,c]=G,{path:B}=wn(t);return{derivePath:t,password:c,path:B,phrase:b}}var h5=be(uG("Secp256k1HDKD"));function Wy(l,A){if(!Jb(A)||A.length!==32)throw new Error("Invalid chainCode passed to derive");return Tb(nG(h5,l,A),256)}var s5=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]),JB=new Uint32Array(64),DW=class extends Fd{constructor(A=32){super(64,A,8,!1),this.A=vc[0]|0,this.B=vc[1]|0,this.C=vc[2]|0,this.D=vc[3]|0,this.E=vc[4]|0,this.F=vc[5]|0,this.G=vc[6]|0,this.H=vc[7]|0}get(){let{A,B:G,C:b,D:t,E:c,F:B,G:e,H:d}=this;return[A,G,b,t,c,B,e,d]}set(A,G,b,t,c,B,e,d){this.A=A|0,this.B=G|0,this.C=b|0,this.D=t|0,this.E=c|0,this.F=B|0,this.G=e|0,this.H=d|0}process(A,G){for(let n=0;n<16;n++,G+=4)JB[n]=A.getUint32(G,!1);for(let n=16;n<64;n++){let h=JB[n-15],W=JB[n-2],i=wt(h,7)^wt(h,18)^h>>>3,Y=wt(W,17)^wt(W,19)^W>>>10;JB[n]=Y+JB[n-7]+i+JB[n-16]|0}let{A:b,B:t,C:c,D:B,E:e,F:d,G:Z,H:a}=this;for(let n=0;n<64;n++){let h=wt(e,6)^wt(e,11)^wt(e,25),W=a+h+_2(e,d,Z)+s5[n]+JB[n]|0,Y=(wt(b,2)^wt(b,13)^wt(b,22))+$2(b,t,c)|0;a=Z,Z=d,d=e,e=B+W|0,B=c,c=t,t=b,b=W+Y|0}b=b+this.A|0,t=t+this.B|0,c=c+this.C|0,B=B+this.D|0,e=e+this.E|0,d=d+this.F|0,Z=Z+this.G|0,a=a+this.H|0,this.set(b,t,c,B,e,d,Z,a)}roundClean(){TG(JB)}destroy(){this.set(0,0,0,0,0,0,0,0),TG(this.buffer)}};var oy=Ya(["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(l=>BigInt(l))),r5=oy[0],i5=oy[1],fB=new Uint32Array(80),xB=new Uint32Array(80),LW=class extends Fd{constructor(A=64){super(128,A,16,!1),this.Ah=Vb[0]|0,this.Al=Vb[1]|0,this.Bh=Vb[2]|0,this.Bl=Vb[3]|0,this.Ch=Vb[4]|0,this.Cl=Vb[5]|0,this.Dh=Vb[6]|0,this.Dl=Vb[7]|0,this.Eh=Vb[8]|0,this.El=Vb[9]|0,this.Fh=Vb[10]|0,this.Fl=Vb[11]|0,this.Gh=Vb[12]|0,this.Gl=Vb[13]|0,this.Hh=Vb[14]|0,this.Hl=Vb[15]|0}get(){let{Ah:A,Al:G,Bh:b,Bl:t,Ch:c,Cl:B,Dh:e,Dl:d,Eh:Z,El:a,Fh:n,Fl:h,Gh:W,Gl:i,Hh:Y,Hl:R}=this;return[A,G,b,t,c,B,e,d,Z,a,n,h,W,i,Y,R]}set(A,G,b,t,c,B,e,d,Z,a,n,h,W,i,Y,R){this.Ah=A|0,this.Al=G|0,this.Bh=b|0,this.Bl=t|0,this.Ch=c|0,this.Cl=B|0,this.Dh=e|0,this.Dl=d|0,this.Eh=Z|0,this.El=a|0,this.Fh=n|0,this.Fl=h|0,this.Gh=W|0,this.Gl=i|0,this.Hh=Y|0,this.Hl=R|0}process(A,G){for(let I=0;I<16;I++,G+=4)fB[I]=A.getUint32(G),xB[I]=A.getUint32(G+=4);for(let I=16;I<80;I++){let y=fB[I-15]|0,x=xB[I-15]|0,w=Bc(y,x,1)^Bc(y,x,8)^jo(y,x,7),H=ec(y,x,1)^ec(y,x,8)^Mo(y,x,7),j=fB[I-2]|0,C=xB[I-2]|0,D=Bc(j,C,19)^Ae(j,C,61)^jo(j,C,6),$=ec(j,C,19)^Ge(j,C,61)^Mo(j,C,6),K=eV(H,$,xB[I-7],xB[I-16]),Q=ZV(K,w,D,fB[I-7],fB[I-16]);fB[I]=Q|0,xB[I]=K|0}let{Ah:b,Al:t,Bh:c,Bl:B,Ch:e,Cl:d,Dh:Z,Dl:a,Eh:n,El:h,Fh:W,Fl:i,Gh:Y,Gl:R,Hh:V,Hl:m}=this;for(let I=0;I<80;I++){let y=Bc(n,h,14)^Bc(n,h,18)^Ae(n,h,41),x=ec(n,h,14)^ec(n,h,18)^Ge(n,h,41),w=n&W^~n&Y,H=h&i^~h&R,j=dV(m,x,H,i5[I],xB[I]),C=nV(j,V,y,w,r5[I],fB[I]),D=j|0,$=Bc(b,t,28)^Ae(b,t,34)^Ae(b,t,39),K=ec(b,t,28)^Ge(b,t,34)^Ge(b,t,39),Q=b&c^b&e^c&e,r=t&B^t&d^B&d;V=Y|0,m=R|0,Y=W|0,R=i|0,W=n|0,i=h|0,{h:n,l:h}=dt(Z|0,a|0,C|0,D|0),Z=e|0,a=d|0,e=c|0,d=B|0,c=b|0,B=t|0;let F=yd(D,K,r);b=Qd(F,C,$,Q),t=F|0}({h:b,l:t}=dt(this.Ah|0,this.Al|0,b|0,t|0)),{h:c,l:B}=dt(this.Bh|0,this.Bl|0,c|0,B|0),{h:e,l:d}=dt(this.Ch|0,this.Cl|0,e|0,d|0),{h:Z,l:a}=dt(this.Dh|0,this.Dl|0,Z|0,a|0),{h:n,l:h}=dt(this.Eh|0,this.El|0,n|0,h|0),{h:W,l:i}=dt(this.Fh|0,this.Fl|0,W|0,i|0),{h:Y,l:R}=dt(this.Gh|0,this.Gl|0,Y|0,R|0),{h:V,l:m}=dt(this.Hh|0,this.Hl|0,V|0,m|0),this.set(b,t,c,B,e,d,Z,a,n,h,W,i,Y,R,V,m)}roundClean(){TG(fB,xB)}destroy(){TG(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var ye=pd(()=>new DW);var OW=pd(()=>new LW);var PW=class extends tc{constructor(A,G){super(),this.finished=!1,this.destroyed=!1,Ke(A);let b=Zt(G);if(this.iHash=A.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;let t=this.blockLen,c=new Uint8Array(t);c.set(b.length>t?A.create().update(b).digest():b);for(let B=0;B<c.length;B++)c[B]^=54;this.iHash.update(c),this.oHash=A.create();for(let B=0;B<c.length;B++)c[B]^=106;this.oHash.update(c),TG(c)}update(A){return pt(this),this.iHash.update(A),this}digestInto(A){pt(this),kG(A,this.outputLen),this.finished=!0,this.iHash.digestInto(A),this.oHash.update(A),this.oHash.digestInto(A),this.destroy()}digest(){let A=new Uint8Array(this.oHash.outputLen);return this.digestInto(A),A}_cloneInto(A){A||(A=Object.create(Object.getPrototypeOf(this),{}));let{oHash:G,iHash:b,finished:t,destroyed:c,blockLen:B,outputLen:e}=this;return A=A,A.finished=t,A.destroyed=c,A.blockLen=B,A.outputLen=e,A.oHash=G._cloneInto(A.oHash),A.iHash=b._cloneInto(A.iHash),A}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Qe=(l,A,G)=>new PW(l,A).update(G).digest();Qe.create=(l,A)=>new PW(l,A);var Ci=BigInt(0),Ui=BigInt(1);function lB(l,A=""){if(typeof l!="boolean"){let G=A&&`"${A}"`;throw new Error(G+"expected boolean, got type="+typeof l)}return l}function Vt(l,A,G=""){let b=kt(l),t=l?.length,c=A!==void 0;if(!b||c&&t!==A){let B=G&&`"${G}" `,e=c?` of length ${A}`:"",d=b?`length=${t}`:`type=${typeof l}`;throw new Error(B+"expected Uint8Array"+e+", got "+d)}return l}function ld(l){let A=l.toString(16);return A.length&1?"0"+A:A}function Si(l){if(typeof l!="string")throw new Error("hex string expected, got "+typeof l);return l===""?Ci:BigInt("0x"+l)}function Ne(l){return Si(et(l))}function Kt(l){return kG(l),Si(et(Uint8Array.from(l).reverse()))}function Un(l,A){return WB(l.toString(16).padStart(A*2,"0"))}function Cn(l,A){return Un(l,A).reverse()}function ZG(l,A,G){let b;if(typeof A=="string")try{b=WB(A)}catch(c){throw new Error(l+" must be hex string or Uint8Array, cause: "+c)}else if(kt(A))b=Uint8Array.from(A);else throw new Error(l+" must be hex string or Uint8Array");let t=b.length;if(typeof G=="number"&&t!==G)throw new Error(l+" of length "+G+" expected, got "+t);return b}function zi(l,A){if(l.length!==A.length)return!1;let G=0;for(let b=0;b<l.length;b++)G|=l[b]^A[b];return G===0}function KW(l){return Uint8Array.from(l)}var wi=l=>typeof l=="bigint"&&Ci<=l;function ji(l,A,G){return wi(l)&&wi(A)&&wi(G)&&A<=l&&l<G}function Ee(l,A,G,b){if(!ji(A,G,b))throw new Error("expected valid "+l+": "+G+" <= n < "+b+", got "+A)}function Sn(l){let A;for(A=0;l>Ci;l>>=Ui,A+=1);return A}var Xc=l=>(Ui<<BigInt(l))-Ui;function Mi(l,A,G){if(typeof l!="number"||l<2)throw new Error("hashLen must be a number");if(typeof A!="number"||A<2)throw new Error("qByteLen must be a number");if(typeof G!="function")throw new Error("hmacFn must be a function");let b=W=>new Uint8Array(W),t=W=>Uint8Array.of(W),c=b(l),B=b(l),e=0,d=()=>{c.fill(1),B.fill(0),e=0},Z=(...W)=>G(B,c,...W),a=(W=b(0))=>{B=Z(t(0),W),c=Z(),W.length!==0&&(B=Z(t(1),W),c=Z())},n=()=>{if(e++>=1e3)throw new Error("drbg: tried 1000 values");let W=0,i=[];for(;W<A;){c=Z();let Y=c.slice();i.push(Y),W+=c.length}return VG(...i)};return(W,i)=>{d(),a(W);let Y;for(;!(Y=i(n()));)a();return d(),Y}}function kB(l,A,G={}){if(!l||typeof l!="object")throw new Error("expected valid options object");function b(t,c,B){let e=l[t];if(B&&e===void 0)return;let d=typeof e;if(d!==c||e===null)throw new Error(`param "${t}" is invalid: expected ${c}, got ${d}`)}Object.entries(A).forEach(([t,c])=>b(t,c,!1)),Object.entries(G).forEach(([t,c])=>b(t,c,!0))}var qW=()=>{throw new Error("not implemented")};function ve(l){let A=new WeakMap;return(G,...b)=>{let t=A.get(G);if(t!==void 0)return t;let c=l(G,...b);return A.set(G,c),c}}var Lb=BigInt(0),hb=BigInt(1),He=BigInt(2),ry=BigInt(3),iy=BigInt(4),my=BigInt(5),u5=BigInt(7),Vy=BigInt(8),Y5=BigInt(9),uy=BigInt(16);function IG(l,A){let G=l%A;return G>=Lb?G:A+G}function RG(l,A,G){let b=l;for(;A-- >Lb;)b*=b,b%=G;return b}function hy(l,A){if(l===Lb)throw new Error("invert: expected non-zero number");if(A<=Lb)throw new Error("invert: expected positive modulus, got "+A);let G=IG(l,A),b=A,t=Lb,c=hb,B=hb,e=Lb;for(;G!==Lb;){let Z=b/G,a=b%G,n=t-B*Z,h=c-e*Z;b=G,G=a,t=B,c=e,B=n,e=h}if(b!==hb)throw new Error("invert: does not exist");return IG(t,A)}function Ti(l,A,G){if(!l.eql(l.sqr(A),G))throw new Error("Cannot find square root")}function Yy(l,A){let G=(l.ORDER+hb)/iy,b=l.pow(A,G);return Ti(l,b,A),b}function I5(l,A){let G=(l.ORDER-my)/Vy,b=l.mul(A,He),t=l.pow(b,G),c=l.mul(A,t),B=l.mul(l.mul(c,He),t),e=l.mul(c,l.sub(B,l.ONE));return Ti(l,e,A),e}function R5(l){let A=ut(l),G=Iy(l),b=G(A,A.neg(A.ONE)),t=G(A,b),c=G(A,A.neg(b)),B=(l+u5)/uy;return(e,d)=>{let Z=e.pow(d,B),a=e.mul(Z,b),n=e.mul(Z,t),h=e.mul(Z,c),W=e.eql(e.sqr(a),d),i=e.eql(e.sqr(n),d);Z=e.cmov(Z,a,W),a=e.cmov(h,n,i);let Y=e.eql(e.sqr(a),d),R=e.cmov(Z,a,Y);return Ti(e,R,d),R}}function Iy(l){if(l<ry)throw new Error("sqrt is not defined for small field");let A=l-hb,G=0;for(;A%He===Lb;)A/=He,G++;let b=He,t=ut(l);for(;sy(t,b)===1;)if(b++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(G===1)return Yy;let c=t.pow(b,A),B=(A+hb)/He;return function(d,Z){if(d.is0(Z))return Z;if(sy(d,Z)!==1)throw new Error("Cannot find square root");let a=G,n=d.mul(d.ONE,c),h=d.pow(Z,A),W=d.pow(Z,B);for(;!d.eql(h,d.ONE);){if(d.is0(h))return d.ZERO;let i=1,Y=d.sqr(h);for(;!d.eql(Y,d.ONE);)if(i++,Y=d.sqr(Y),i===a)throw new Error("Cannot find square root");let R=hb<<BigInt(a-i-1),V=d.pow(n,R);a=i,n=d.sqr(V),h=d.mul(h,n),W=d.mul(W,V)}return W}}function X5(l){return l%iy===ry?Yy:l%Vy===my?I5:l%uy===Y5?R5(l):Iy(l)}var AB=(l,A)=>(IG(l,A)&hb)===hb,p5=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Di(l){let A={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},G=p5.reduce((b,t)=>(b[t]="function",b),A);return kB(l,G),l}function F5(l,A,G){if(G<Lb)throw new Error("invalid exponent, negatives unsupported");if(G===Lb)return l.ONE;if(G===hb)return A;let b=l.ONE,t=A;for(;G>Lb;)G&hb&&(b=l.mul(b,t)),t=l.sqr(t),G>>=hb;return b}function zn(l,A,G=!1){let b=new Array(A.length).fill(G?l.ZERO:void 0),t=A.reduce((B,e,d)=>l.is0(e)?B:(b[d]=B,l.mul(B,e)),l.ONE),c=l.inv(t);return A.reduceRight((B,e,d)=>l.is0(e)?B:(b[d]=l.mul(B,b[d]),l.mul(B,e)),c),b}function sy(l,A){let G=(l.ORDER-hb)/He,b=l.pow(A,G),t=l.eql(b,l.ONE),c=l.eql(b,l.ZERO),B=l.eql(b,l.neg(l.ONE));if(!t&&!c&&!B)throw new Error("invalid Legendre symbol result");return t?1:c?0:-1}function _W(l,A){A!==void 0&&mG(A);let G=A!==void 0?A:l.toString(2).length,b=Math.ceil(G/8);return{nBitLength:G,nByteLength:b}}function ut(l,A,G=!1,b={}){if(l<=Lb)throw new Error("invalid field: expected ORDER > 0, got "+l);let t,c,B=!1,e;if(typeof A=="object"&&A!=null){if(b.sqrt||G)throw new Error("cannot specify opts in two arguments");let h=A;h.BITS&&(t=h.BITS),h.sqrt&&(c=h.sqrt),typeof h.isLE=="boolean"&&(G=h.isLE),typeof h.modFromBytes=="boolean"&&(B=h.modFromBytes),e=h.allowedLengths}else typeof A=="number"&&(t=A),b.sqrt&&(c=b.sqrt);let{nBitLength:d,nByteLength:Z}=_W(l,t);if(Z>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let a,n=Object.freeze({ORDER:l,isLE:G,BITS:d,BYTES:Z,MASK:Xc(d),ZERO:Lb,ONE:hb,allowedLengths:e,create:h=>IG(h,l),isValid:h=>{if(typeof h!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof h);return Lb<=h&&h<l},is0:h=>h===Lb,isValidNot0:h=>!n.is0(h)&&n.isValid(h),isOdd:h=>(h&hb)===hb,neg:h=>IG(-h,l),eql:(h,W)=>h===W,sqr:h=>IG(h*h,l),add:(h,W)=>IG(h+W,l),sub:(h,W)=>IG(h-W,l),mul:(h,W)=>IG(h*W,l),pow:(h,W)=>F5(n,h,W),div:(h,W)=>IG(h*hy(W,l),l),sqrN:h=>h*h,addN:(h,W)=>h+W,subN:(h,W)=>h-W,mulN:(h,W)=>h*W,inv:h=>hy(h,l),sqrt:c||(h=>(a||(a=X5(l)),a(n,h))),toBytes:h=>G?Cn(h,Z):Un(h,Z),fromBytes:(h,W=!0)=>{if(e){if(!e.includes(h.length)||h.length>Z)throw new Error("Field.fromBytes: expected "+e+" bytes, got "+h.length);let Y=new Uint8Array(Z);Y.set(h,G?0:Y.length-h.length),h=Y}if(h.length!==Z)throw new Error("Field.fromBytes: expected "+Z+" bytes, got "+h.length);let i=G?Kt(h):Ne(h);if(B&&(i=IG(i,l)),!W&&!n.isValid(i))throw new Error("invalid field element: outside of range 0..ORDER");return i},invertBatch:h=>zn(n,h),cmov:(h,W,i)=>i?W:h});return Object.freeze(n)}function Ry(l){if(typeof l!="bigint")throw new Error("field order must be bigint");let A=l.toString(2).length;return Math.ceil(A/8)}function Li(l){let A=Ry(l);return A+Math.ceil(A/2)}function Oi(l,A,G=!1){let b=l.length,t=Ry(A),c=Li(A);if(b<16||b<c||b>1024)throw new Error("expected "+c+"-1024 bytes of input, got "+b);let B=G?Kt(l):Ne(l),e=IG(B,A-hb)+hb;return G?Cn(e,t):Un(e,t)}var Ad=BigInt(0),Je=BigInt(1);function jn(l,A){let G=A.negate();return l?G:A}function GB(l,A){let G=zn(l.Fp,A.map(b=>b.Z));return A.map((b,t)=>l.fromAffine(b.toAffine(G[t])))}function yy(l,A){if(!Number.isSafeInteger(l)||l<=0||l>A)throw new Error("invalid window size, expected [1.."+A+"], got W="+l)}function Pi(l,A){yy(l,A);let G=Math.ceil(A/l)+1,b=2**(l-1),t=2**l,c=Xc(l),B=BigInt(l);return{windows:G,windowSize:b,mask:c,maxNumber:t,shiftBy:B}}function Xy(l,A,G){let{windowSize:b,mask:t,maxNumber:c,shiftBy:B}=G,e=Number(l&t),d=l>>B;e>b&&(e-=c,d+=Je);let Z=A*b,a=Z+Math.abs(e)-1,n=e===0,h=e<0,W=A%2!==0;return{nextN:d,offset:a,isZero:n,isNeg:h,isNegF:W,offsetF:Z}}function Q5(l,A){if(!Array.isArray(l))throw new Error("array expected");l.forEach((G,b)=>{if(!(G instanceof A))throw new Error("invalid point at index "+b)})}function N5(l,A){if(!Array.isArray(l))throw new Error("array of scalars expected");l.forEach((G,b)=>{if(!A.isValid(G))throw new Error("invalid scalar at index "+b)})}var Ki=new WeakMap,Qy=new WeakMap;function qi(l){return Qy.get(l)||1}function py(l){if(l!==Ad)throw new Error("invalid wNAF")}var Gd=class{constructor(A,G){this.BASE=A.BASE,this.ZERO=A.ZERO,this.Fn=A.Fn,this.bits=G}_unsafeLadder(A,G,b=this.ZERO){let t=A;for(;G>Ad;)G&Je&&(b=b.add(t)),t=t.double(),G>>=Je;return b}precomputeWindow(A,G){let{windows:b,windowSize:t}=Pi(G,this.bits),c=[],B=A,e=B;for(let d=0;d<b;d++){e=B,c.push(e);for(let Z=1;Z<t;Z++)e=e.add(B),c.push(e);B=e.double()}return c}wNAF(A,G,b){if(!this.Fn.isValid(b))throw new Error("invalid scalar");let t=this.ZERO,c=this.BASE,B=Pi(A,this.bits);for(let e=0;e<B.windows;e++){let{nextN:d,offset:Z,isZero:a,isNeg:n,isNegF:h,offsetF:W}=Xy(b,e,B);b=d,a?c=c.add(jn(h,G[W])):t=t.add(jn(n,G[Z]))}return py(b),{p:t,f:c}}wNAFUnsafe(A,G,b,t=this.ZERO){let c=Pi(A,this.bits);for(let B=0;B<c.windows&&b!==Ad;B++){let{nextN:e,offset:d,isZero:Z,isNeg:a}=Xy(b,B,c);if(b=e,!Z){let n=G[d];t=t.add(a?n.negate():n)}}return py(b),t}getPrecomputes(A,G,b){let t=Ki.get(G);return t||(t=this.precomputeWindow(G,A),A!==1&&(typeof b=="function"&&(t=b(t)),Ki.set(G,t))),t}cached(A,G,b){let t=qi(A);return this.wNAF(t,this.getPrecomputes(t,A,b),G)}unsafe(A,G,b,t){let c=qi(A);return c===1?this._unsafeLadder(A,G,t):this.wNAFUnsafe(c,this.getPrecomputes(c,A,b),G,t)}createCache(A,G){yy(G,this.bits),Qy.set(A,G),Ki.delete(A)}hasCache(A){return qi(A)!==1}};function Ny(l,A,G,b){let t=A,c=l.ZERO,B=l.ZERO;for(;G>Ad||b>Ad;)G&Je&&(c=c.add(t)),b&Je&&(B=B.add(t)),t=t.double(),G>>=Je,b>>=Je;return{p1:c,p2:B}}function bd(l,A,G,b){Q5(G,l),N5(b,A);let t=G.length,c=b.length;if(t!==c)throw new Error("arrays of points and scalars must have equal length");let B=l.ZERO,e=Sn(BigInt(t)),d=1;e>12?d=e-3:e>4?d=e-2:e>0&&(d=2);let Z=Xc(d),a=new Array(Number(Z)+1).fill(B),n=Math.floor((A.BITS-1)/d)*d,h=B;for(let W=n;W>=0;W-=d){a.fill(B);for(let Y=0;Y<c;Y++){let R=b[Y],V=Number(R>>BigInt(W)&Z);a[V]=a[V].add(G[Y])}let i=B;for(let Y=a.length-1,R=B;Y>0;Y--)R=R.add(a[Y]),i=i.add(R);if(h=h.add(i),W!==0)for(let Y=0;Y<d;Y++)h=h.double()}return h}function Fy(l,A,G){if(A){if(A.ORDER!==l)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Di(A),A}else return ut(l,{isLE:G})}function $W(l,A,G={},b){if(b===void 0&&(b=l==="edwards"),!A||typeof A!="object")throw new Error(`expected valid ${l} CURVE object`);for(let d of["p","n","h"]){let Z=A[d];if(!(typeof Z=="bigint"&&Z>Ad))throw new Error(`CURVE.${d} must be positive bigint`)}let t=Fy(A.p,G.Fp,b),c=Fy(A.n,G.Fn,b),e=["Gx","Gy","a",l==="weierstrass"?"b":"d"];for(let d of e)if(!t.isValid(A[d]))throw new Error(`CURVE.${d} must be valid field element of CURVE.Fp`);return A=Object.freeze(Object.assign({},A)),{CURVE:A,Fp:t,Fn:c}}var Ey=(l,A)=>(l+(l>=0?A:-A)/vy)/A;function E5(l,A,G){let[[b,t],[c,B]]=A,e=Ey(B*l,G),d=Ey(-t*l,G),Z=l-e*b-d*c,a=-e*t-d*B,n=Z<tB,h=a<tB;n&&(Z=-Z),h&&(a=-a);let W=Xc(Math.ceil(Sn(G)/2))+cd;if(Z<tB||Z>=W||a<tB||a>=W)throw new Error("splitScalar (endomorphism): failed, k="+l);return{k1neg:n,k1:Z,k2neg:h,k2:a}}function $i(l){if(!["compact","recovered","der"].includes(l))throw new Error('Signature format must be "compact", "recovered", or "der"');return l}function _i(l,A){let G={};for(let b of Object.keys(A))G[b]=l[b]===void 0?A[b]:l[b];return lB(G.lowS,"lowS"),lB(G.prehash,"prehash"),G.format!==void 0&&$i(G.format),G}var lm=class extends Error{constructor(A=""){super(A)}},bB={Err:lm,_tlv:{encode:(l,A)=>{let{Err:G}=bB;if(l<0||l>256)throw new G("tlv.encode: wrong tag");if(A.length&1)throw new G("tlv.encode: unpadded data");let b=A.length/2,t=ld(b);if(t.length/2&128)throw new G("tlv.encode: long form length too big");let c=b>127?ld(t.length/2|128):"";return ld(l)+c+t+A},decode(l,A){let{Err:G}=bB,b=0;if(l<0||l>256)throw new G("tlv.encode: wrong tag");if(A.length<2||A[b++]!==l)throw new G("tlv.decode: wrong tlv");let t=A[b++],c=!!(t&128),B=0;if(!c)B=t;else{let d=t&127;if(!d)throw new G("tlv.decode(long): indefinite length not supported");if(d>4)throw new G("tlv.decode(long): byte length is too big");let Z=A.subarray(b,b+d);if(Z.length!==d)throw new G("tlv.decode: length bytes not complete");if(Z[0]===0)throw new G("tlv.decode(long): zero leftmost byte");for(let a of Z)B=B<<8|a;if(b+=d,B<128)throw new G("tlv.decode(long): not minimal encoding")}let e=A.subarray(b,b+B);if(e.length!==B)throw new G("tlv.decode: wrong value length");return{v:e,l:A.subarray(b+B)}}},_int:{encode(l){let{Err:A}=bB;if(l<tB)throw new A("integer: negative integers are not allowed");let G=ld(l);if(Number.parseInt(G[0],16)&8&&(G="00"+G),G.length&1)throw new A("unexpected DER parsing assertion: unpadded hex");return G},decode(l){let{Err:A}=bB;if(l[0]&128)throw new A("invalid signature integer: negative");if(l[0]===0&&!(l[1]&128))throw new A("invalid signature integer: unnecessary leading zero");return Ne(l)}},toSig(l){let{Err:A,_int:G,_tlv:b}=bB,t=ZG("signature",l),{v:c,l:B}=b.decode(48,t);if(B.length)throw new A("invalid signature: left bytes after parsing");let{v:e,l:d}=b.decode(2,c),{v:Z,l:a}=b.decode(2,d);if(a.length)throw new A("invalid signature: left bytes after parsing");return{r:G.decode(e),s:G.decode(Z)}},hexFromSig(l){let{_tlv:A,_int:G}=bB,b=A.encode(2,G.encode(l.r)),t=A.encode(2,G.encode(l.s)),c=b+t;return A.encode(48,c)}},tB=BigInt(0),cd=BigInt(1),vy=BigInt(2),lo=BigInt(3),v5=BigInt(4);function td(l,A){let{BYTES:G}=l,b;if(typeof A=="bigint")b=A;else{let t=ZG("private key",A);try{b=l.fromBytes(t)}catch{throw new Error(`invalid private key: expected ui8a of size ${G}, got ${typeof A}`)}}if(!l.isValidNot0(b))throw new Error("invalid private key: out of range [1..N-1]");return b}function H5(l,A={}){let G=$W("weierstrass",l,A),{Fp:b,Fn:t}=G,c=G.CURVE,{h:B,n:e}=c;kB(A,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:d}=A;if(d&&(!b.is0(c.a)||typeof d.beta!="bigint"||!Array.isArray(d.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let Z=Jy(b,t);function a(){if(!b.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function n(K,Q,r){let{x:F,y:E}=Q.toAffine(),f=b.toBytes(F);if(lB(r,"isCompressed"),r){a();let s=!b.isOdd(E);return VG(Hy(s),f)}else return VG(Uint8Array.of(4),f,b.toBytes(E))}function h(K){Vt(K,void 0,"Point");let{publicKey:Q,publicKeyUncompressed:r}=Z,F=K.length,E=K[0],f=K.subarray(1);if(F===Q&&(E===2||E===3)){let s=b.fromBytes(f);if(!b.isValid(s))throw new Error("bad point: is not on curve, wrong x");let p=Y(s),X;try{X=b.sqrt(p)}catch(u){let v=u instanceof Error?": "+u.message:"";throw new Error("bad point: is not on curve, sqrt error"+v)}a();let o=b.isOdd(X);return(E&1)===1!==o&&(X=b.neg(X)),{x:s,y:X}}else if(F===r&&E===4){let s=b.BYTES,p=b.fromBytes(f.subarray(0,s)),X=b.fromBytes(f.subarray(s,s*2));if(!R(p,X))throw new Error("bad point: is not on curve");return{x:p,y:X}}else throw new Error(`bad point: got length ${F}, expected compressed=${Q} or uncompressed=${r}`)}let W=A.toBytes||n,i=A.fromBytes||h;function Y(K){let Q=b.sqr(K),r=b.mul(Q,K);return b.add(b.add(r,b.mul(K,c.a)),c.b)}function R(K,Q){let r=b.sqr(Q),F=Y(K);return b.eql(r,F)}if(!R(c.Gx,c.Gy))throw new Error("bad curve params: generator point");let V=b.mul(b.pow(c.a,lo),v5),m=b.mul(b.sqr(c.b),BigInt(27));if(b.is0(b.add(V,m)))throw new Error("bad curve params: a or b");function I(K,Q,r=!1){if(!b.isValid(Q)||r&&b.is0(Q))throw new Error(`bad point coordinate ${K}`);return Q}function y(K){if(!(K instanceof C))throw new Error("ProjectivePoint expected")}function x(K){if(!d||!d.basises)throw new Error("no endo");return E5(K,d.basises,t.ORDER)}let w=ve((K,Q)=>{let{X:r,Y:F,Z:E}=K;if(b.eql(E,b.ONE))return{x:r,y:F};let f=K.is0();Q==null&&(Q=f?b.ONE:b.inv(E));let s=b.mul(r,Q),p=b.mul(F,Q),X=b.mul(E,Q);if(f)return{x:b.ZERO,y:b.ZERO};if(!b.eql(X,b.ONE))throw new Error("invZ was invalid");return{x:s,y:p}}),H=ve(K=>{if(K.is0()){if(A.allowInfinityPoint&&!b.is0(K.Y))return;throw new Error("bad point: ZERO")}let{x:Q,y:r}=K.toAffine();if(!b.isValid(Q)||!b.isValid(r))throw new Error("bad point: x or y not field elements");if(!R(Q,r))throw new Error("bad point: equation left != right");if(!K.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function j(K,Q,r,F,E){return r=new C(b.mul(r.X,K),r.Y,r.Z),Q=jn(F,Q),r=jn(E,r),Q.add(r)}class C{constructor(Q,r,F){this.X=I("x",Q),this.Y=I("y",r,!0),this.Z=I("z",F),Object.freeze(this)}static CURVE(){return c}static fromAffine(Q){let{x:r,y:F}=Q||{};if(!Q||!b.isValid(r)||!b.isValid(F))throw new Error("invalid affine point");if(Q instanceof C)throw new Error("projective point not allowed");return b.is0(r)&&b.is0(F)?C.ZERO:new C(r,F,b.ONE)}static fromBytes(Q){let r=C.fromAffine(i(Vt(Q,void 0,"point")));return r.assertValidity(),r}static fromHex(Q){return C.fromBytes(ZG("pointHex",Q))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(Q=8,r=!0){return $.createCache(this,Q),r||this.multiply(lo),this}assertValidity(){H(this)}hasEvenY(){let{y:Q}=this.toAffine();if(!b.isOdd)throw new Error("Field doesn't support isOdd");return!b.isOdd(Q)}equals(Q){y(Q);let{X:r,Y:F,Z:E}=this,{X:f,Y:s,Z:p}=Q,X=b.eql(b.mul(r,p),b.mul(f,E)),o=b.eql(b.mul(F,p),b.mul(s,E));return X&&o}negate(){return new C(this.X,b.neg(this.Y),this.Z)}double(){let{a:Q,b:r}=c,F=b.mul(r,lo),{X:E,Y:f,Z:s}=this,p=b.ZERO,X=b.ZERO,o=b.ZERO,g=b.mul(E,E),u=b.mul(f,f),v=b.mul(s,s),S=b.mul(E,f);return S=b.add(S,S),o=b.mul(E,s),o=b.add(o,o),p=b.mul(Q,o),X=b.mul(F,v),X=b.add(p,X),p=b.sub(u,X),X=b.add(u,X),X=b.mul(p,X),p=b.mul(S,p),o=b.mul(F,o),v=b.mul(Q,v),S=b.sub(g,v),S=b.mul(Q,S),S=b.add(S,o),o=b.add(g,g),g=b.add(o,g),g=b.add(g,v),g=b.mul(g,S),X=b.add(X,g),v=b.mul(f,s),v=b.add(v,v),g=b.mul(v,S),p=b.sub(p,g),o=b.mul(v,u),o=b.add(o,o),o=b.add(o,o),new C(p,X,o)}add(Q){y(Q);let{X:r,Y:F,Z:E}=this,{X:f,Y:s,Z:p}=Q,X=b.ZERO,o=b.ZERO,g=b.ZERO,u=c.a,v=b.mul(c.b,lo),S=b.mul(r,f),z=b.mul(F,s),q=b.mul(E,p),_=b.add(r,F),T=b.add(f,s);_=b.mul(_,T),T=b.add(S,z),_=b.sub(_,T),T=b.add(r,E);let J=b.add(f,p);return T=b.mul(T,J),J=b.add(S,q),T=b.sub(T,J),J=b.add(F,E),X=b.add(s,p),J=b.mul(J,X),X=b.add(z,q),J=b.sub(J,X),g=b.mul(u,T),X=b.mul(v,q),g=b.add(X,g),X=b.sub(z,g),g=b.add(z,g),o=b.mul(X,g),z=b.add(S,S),z=b.add(z,S),q=b.mul(u,q),T=b.mul(v,T),z=b.add(z,q),q=b.sub(S,q),q=b.mul(u,q),T=b.add(T,q),S=b.mul(z,T),o=b.add(o,S),S=b.mul(J,T),X=b.mul(_,X),X=b.sub(X,S),S=b.mul(_,z),g=b.mul(J,g),g=b.add(g,S),new C(X,o,g)}subtract(Q){return this.add(Q.negate())}is0(){return this.equals(C.ZERO)}multiply(Q){let{endo:r}=A;if(!t.isValidNot0(Q))throw new Error("invalid scalar: out of range");let F,E,f=s=>$.cached(this,s,p=>GB(C,p));if(r){let{k1neg:s,k1:p,k2neg:X,k2:o}=x(Q),{p:g,f:u}=f(p),{p:v,f:S}=f(o);E=u.add(S),F=j(r.beta,g,v,s,X)}else{let{p:s,f:p}=f(Q);F=s,E=p}return GB(C,[F,E])[0]}multiplyUnsafe(Q){let{endo:r}=A,F=this;if(!t.isValid(Q))throw new Error("invalid scalar: out of range");if(Q===tB||F.is0())return C.ZERO;if(Q===cd)return F;if($.hasCache(this))return this.multiply(Q);if(r){let{k1neg:E,k1:f,k2neg:s,k2:p}=x(Q),{p1:X,p2:o}=Ny(C,F,f,p);return j(r.beta,X,o,E,s)}else return $.unsafe(F,Q)}multiplyAndAddUnsafe(Q,r,F){let E=this.multiplyUnsafe(r).add(Q.multiplyUnsafe(F));return E.is0()?void 0:E}toAffine(Q){return w(this,Q)}isTorsionFree(){let{isTorsionFree:Q}=A;return B===cd?!0:Q?Q(C,this):$.unsafe(this,e).is0()}clearCofactor(){let{clearCofactor:Q}=A;return B===cd?this:Q?Q(C,this):this.multiplyUnsafe(B)}isSmallOrder(){return this.multiplyUnsafe(B).is0()}toBytes(Q=!0){return lB(Q,"isCompressed"),this.assertValidity(),W(C,this,Q)}toHex(Q=!0){return et(this.toBytes(Q))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(Q=!0){return this.toBytes(Q)}_setWindowSize(Q){this.precompute(Q)}static normalizeZ(Q){return GB(C,Q)}static msm(Q,r){return bd(C,t,Q,r)}static fromPrivateKey(Q){return C.BASE.multiply(td(t,Q))}}C.BASE=new C(c.Gx,c.Gy,b.ONE),C.ZERO=new C(b.ZERO,b.ONE,b.ZERO),C.Fp=b,C.Fn=t;let D=t.BITS,$=new Gd(C,A.endo?Math.ceil(D/2):D);return C.BASE.precompute(8),C}function Hy(l){return Uint8Array.of(l?2:3)}function Jy(l,A){return{secretKey:A.BYTES,publicKey:1+l.BYTES,publicKeyUncompressed:1+2*l.BYTES,publicKeyHasPrefix:!0,signature:2*A.BYTES}}function J5(l,A={}){let{Fn:G}=l,b=A.randomBytes||vb,t=Object.assign(Jy(l.Fp,G),{seed:Li(G.ORDER)});function c(W){try{return!!td(G,W)}catch{return!1}}function B(W,i){let{publicKey:Y,publicKeyUncompressed:R}=t;try{let V=W.length;return i===!0&&V!==Y||i===!1&&V!==R?!1:!!l.fromBytes(W)}catch{return!1}}function e(W=b(t.seed)){return Oi(Vt(W,t.seed,"seed"),G.ORDER)}function d(W,i=!0){return l.BASE.multiply(td(G,W)).toBytes(i)}function Z(W){let i=e(W);return{secretKey:i,publicKey:d(i)}}function a(W){if(typeof W=="bigint")return!1;if(W instanceof l)return!0;let{secretKey:i,publicKey:Y,publicKeyUncompressed:R}=t;if(G.allowedLengths||i===Y)return;let V=ZG("key",W).length;return V===Y||V===R}function n(W,i,Y=!0){if(a(W)===!0)throw new Error("first arg must be private key");if(a(i)===!1)throw new Error("second arg must be public key");let R=td(G,W);return l.fromHex(i).multiply(R).toBytes(Y)}return Object.freeze({getPublicKey:d,getSharedSecret:n,keygen:Z,Point:l,utils:{isValidSecretKey:c,isValidPublicKey:B,randomSecretKey:e,isValidPrivateKey:c,randomPrivateKey:e,normPrivateKeyToScalar:W=>td(G,W),precompute(W=8,i=l.BASE){return i.precompute(W,!1)}},lengths:t})}function f5(l,A,G={}){Ke(A),kB(G,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let b=G.randomBytes||vb,t=G.hmac||((r,...F)=>Qe(A,r,VG(...F))),{Fp:c,Fn:B}=l,{ORDER:e,BITS:d}=B,{keygen:Z,getPublicKey:a,getSharedSecret:n,utils:h,lengths:W}=J5(l,G),i={prehash:!1,lowS:typeof G.lowS=="boolean"?G.lowS:!1,format:void 0,extraEntropy:!1},Y="compact";function R(r){let F=e>>cd;return r>F}function V(r,F){if(!B.isValidNot0(F))throw new Error(`invalid signature ${r}: out of range 1..Point.Fn.ORDER`);return F}function m(r,F){$i(F);let E=W.signature,f=F==="compact"?E:F==="recovered"?E+1:void 0;return Vt(r,f,`${F} signature`)}class I{constructor(F,E,f){this.r=V("r",F),this.s=V("s",E),f!=null&&(this.recovery=f),Object.freeze(this)}static fromBytes(F,E=Y){m(F,E);let f;if(E==="der"){let{r:o,s:g}=bB.toSig(Vt(F));return new I(o,g)}E==="recovered"&&(f=F[0],E="compact",F=F.subarray(1));let s=B.BYTES,p=F.subarray(0,s),X=F.subarray(s,s*2);return new I(B.fromBytes(p),B.fromBytes(X),f)}static fromHex(F,E){return this.fromBytes(WB(F),E)}addRecoveryBit(F){return new I(this.r,this.s,F)}recoverPublicKey(F){let E=c.ORDER,{r:f,s,recovery:p}=this;if(p==null||![0,1,2,3].includes(p))throw new Error("recovery id invalid");if(e*vy<E&&p>1)throw new Error("recovery id is ambiguous for h>1 curve");let o=p===2||p===3?f+e:f;if(!c.isValid(o))throw new Error("recovery id 2 or 3 invalid");let g=c.toBytes(o),u=l.fromBytes(VG(Hy((p&1)===0),g)),v=B.inv(o),S=x(ZG("msgHash",F)),z=B.create(-S*v),q=B.create(s*v),_=l.BASE.multiplyUnsafe(z).add(u.multiplyUnsafe(q));if(_.is0())throw new Error("point at infinify");return _.assertValidity(),_}hasHighS(){return R(this.s)}toBytes(F=Y){if($i(F),F==="der")return WB(bB.hexFromSig(this));let E=B.toBytes(this.r),f=B.toBytes(this.s);if(F==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return VG(Uint8Array.of(this.recovery),E,f)}return VG(E,f)}toHex(F){return et(this.toBytes(F))}assertValidity(){}static fromCompact(F){return I.fromBytes(ZG("sig",F),"compact")}static fromDER(F){return I.fromBytes(ZG("sig",F),"der")}normalizeS(){return this.hasHighS()?new I(this.r,B.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return et(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return et(this.toBytes("compact"))}}let y=G.bits2int||function(F){if(F.length>8192)throw new Error("input is too large");let E=Ne(F),f=F.length*8-d;return f>0?E>>BigInt(f):E},x=G.bits2int_modN||function(F){return B.create(y(F))},w=Xc(d);function H(r){return Ee("num < 2^"+d,r,tB,w),B.toBytes(r)}function j(r,F){return Vt(r,void 0,"message"),F?Vt(A(r),void 0,"prehashed message"):r}function C(r,F,E){if(["recovered","canonical"].some(z=>z in E))throw new Error("sign() legacy options not supported");let{lowS:f,prehash:s,extraEntropy:p}=_i(E,i);r=j(r,s);let X=x(r),o=td(B,F),g=[H(o),H(X)];if(p!=null&&p!==!1){let z=p===!0?b(W.secretKey):p;g.push(ZG("extraEntropy",z))}let u=VG(...g),v=X;function S(z){let q=y(z);if(!B.isValidNot0(q))return;let _=B.inv(q),T=l.BASE.multiply(q).toAffine(),J=B.create(T.x);if(J===tB)return;let U=B.create(_*B.create(v+J*o));if(U===tB)return;let L=(T.x===J?0:2)|Number(T.y&cd),ll=U;return f&&R(U)&&(ll=B.neg(U),L^=1),new I(J,ll,L)}return{seed:u,k2sig:S}}function D(r,F,E={}){r=ZG("message",r);let{seed:f,k2sig:s}=C(r,F,E);return Mi(A.outputLen,B.BYTES,t)(f,s)}function $(r){let F,E=typeof r=="string"||kt(r),f=!E&&r!==null&&typeof r=="object"&&typeof r.r=="bigint"&&typeof r.s=="bigint";if(!E&&!f)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(f)F=new I(r.r,r.s);else if(E){try{F=I.fromBytes(ZG("sig",r),"der")}catch(s){if(!(s instanceof bB.Err))throw s}if(!F)try{F=I.fromBytes(ZG("sig",r),"compact")}catch{return!1}}return F||!1}function K(r,F,E,f={}){let{lowS:s,prehash:p,format:X}=_i(f,i);if(E=ZG("publicKey",E),F=j(ZG("message",F),p),"strict"in f)throw new Error("options.strict was renamed to lowS");let o=X===void 0?$(r):I.fromBytes(ZG("sig",r),X);if(o===!1)return!1;try{let g=l.fromBytes(E);if(s&&o.hasHighS())return!1;let{r:u,s:v}=o,S=x(F),z=B.inv(v),q=B.create(S*z),_=B.create(u*z),T=l.BASE.multiplyUnsafe(q).add(g.multiplyUnsafe(_));return T.is0()?!1:B.create(T.x)===u}catch{return!1}}function Q(r,F,E={}){let{prehash:f}=_i(E,i);return F=j(F,f),I.fromBytes(r,"recovered").recoverPublicKey(F).toBytes()}return Object.freeze({keygen:Z,getPublicKey:a,getSharedSecret:n,utils:h,lengths:W,Point:l,sign:D,verify:K,recoverPublicKey:Q,Signature:I,hash:A})}function x5(l){let A={a:l.a,b:l.b,p:l.Fp.ORDER,n:l.n,h:l.h,Gx:l.Gx,Gy:l.Gy},G=l.Fp,b=l.allowedPrivateKeyLengths?Array.from(new Set(l.allowedPrivateKeyLengths.map(B=>Math.ceil(B/2)))):void 0,t=ut(A.n,{BITS:l.nBitLength,allowedLengths:b,modFromBytes:l.wrapPrivateKey}),c={Fp:G,Fn:t,allowInfinityPoint:l.allowInfinityPoint,endo:l.endo,isTorsionFree:l.isTorsionFree,clearCofactor:l.clearCofactor,fromBytes:l.fromBytes,toBytes:l.toBytes};return{CURVE:A,curveOpts:c}}function k5(l){let{CURVE:A,curveOpts:G}=x5(l),b={hmac:l.hmac,randomBytes:l.randomBytes,lowS:l.lowS,bits2int:l.bits2int,bits2int_modN:l.bits2int_modN};return{CURVE:A,curveOpts:G,hash:l.hash,ecdsaOpts:b}}function w5(l,A){let G=A.Point;return Object.assign({},A,{ProjectivePoint:G,CURVE:Object.assign({},l,_W(G.Fn.ORDER,G.Fn.BITS))})}function fy(l){let{CURVE:A,curveOpts:G,hash:b,ecdsaOpts:t}=k5(l),c=H5(A,G),B=f5(c,b,t);return w5(l,B)}function xy(l,A){let G=b=>fy({...l,hash:b});return{...G(A),create:G}}var Gm={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},U5={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var ky=BigInt(2);function C5(l){let A=Gm.p,G=BigInt(3),b=BigInt(6),t=BigInt(11),c=BigInt(22),B=BigInt(23),e=BigInt(44),d=BigInt(88),Z=l*l*l%A,a=Z*Z*l%A,n=RG(a,G,A)*a%A,h=RG(n,G,A)*a%A,W=RG(h,ky,A)*Z%A,i=RG(W,t,A)*W%A,Y=RG(i,c,A)*i%A,R=RG(Y,e,A)*Y%A,V=RG(R,d,A)*R%A,m=RG(V,e,A)*Y%A,I=RG(m,G,A)*a%A,y=RG(I,B,A)*i%A,x=RG(y,b,A)*Z%A,w=RG(x,ky,A);if(!Am.eql(Am.sqr(w),l))throw new Error("Cannot find square root");return w}var Am=ut(Gm.p,{sqrt:C5}),pc=xy({...Gm,Fp:Am,lowS:!0,endo:U5},ye);function qt(l,A){if(l.length!==32)throw new Error("Expected valid 32-byte private key as a seed");if(!PA||!A&&TA()){let G=_V(l),b=G.slice(32);if(vd(b))throw new Error("Invalid publicKey generated from WASM interface");return{publicKey:b,secretKey:G.slice(0,32)}}return{publicKey:pc.getPublicKey(l,!0),secretKey:l}}function Ao(l,A){return(G,{chainCode:b,isHard:t})=>{if(!t)throw new Error("A soft key was found in the path and is not supported");return l(A(G.secretKey.subarray(0,32),b))}}var bm=Ao(qt,Wy);var S5=be(uG("Ed25519HDKD"));function tm(l,A){if(!Jb(A)||A.length!==32)throw new Error("Invalid chainCode passed to derive");return Tb(nG(S5,l,A))}function Bd(l=32){return Ha(new Uint8Array(l))}var wB=BigInt(0),sb=BigInt(1),cm=BigInt(2),z5=BigInt(8);function j5(l,A,G,b){let t=l.sqr(G),c=l.sqr(b),B=l.add(l.mul(A.a,t),c),e=l.add(l.ONE,l.mul(A.d,l.mul(t,c)));return l.eql(B,e)}function M5(l,A={}){let G=$W("edwards",l,A,A.FpFnLE),{Fp:b,Fn:t}=G,c=G.CURVE,{h:B}=c;kB(A,{},{uvRatio:"function"});let e=cm<<BigInt(t.BYTES*8)-sb,d=R=>b.create(R),Z=A.uvRatio||((R,V)=>{try{return{isValid:!0,value:b.sqrt(b.div(R,V))}}catch{return{isValid:!1,value:wB}}});if(!j5(b,c,c.Gx,c.Gy))throw new Error("bad curve params: generator point");function a(R,V,m=!1){let I=m?sb:wB;return Ee("coordinate "+R,V,I,e),V}function n(R){if(!(R instanceof i))throw new Error("ExtendedPoint expected")}let h=ve((R,V)=>{let{X:m,Y:I,Z:y}=R,x=R.is0();V==null&&(V=x?z5:b.inv(y));let w=d(m*V),H=d(I*V),j=b.mul(y,V);if(x)return{x:wB,y:sb};if(j!==sb)throw new Error("invZ was invalid");return{x:w,y:H}}),W=ve(R=>{let{a:V,d:m}=c;if(R.is0())throw new Error("bad point: ZERO");let{X:I,Y:y,Z:x,T:w}=R,H=d(I*I),j=d(y*y),C=d(x*x),D=d(C*C),$=d(H*V),K=d(C*d($+j)),Q=d(D+d(m*d(H*j)));if(K!==Q)throw new Error("bad point: equation left != right (1)");let r=d(I*y),F=d(x*w);if(r!==F)throw new Error("bad point: equation left != right (2)");return!0});class i{constructor(V,m,I,y){this.X=a("x",V),this.Y=a("y",m),this.Z=a("z",I,!0),this.T=a("t",y),Object.freeze(this)}static CURVE(){return c}static fromAffine(V){if(V instanceof i)throw new Error("extended point not allowed");let{x:m,y:I}=V||{};return a("x",m),a("y",I),new i(m,I,sb,d(m*I))}static fromBytes(V,m=!1){let I=b.BYTES,{a:y,d:x}=c;V=KW(Vt(V,I,"point")),lB(m,"zip215");let w=KW(V),H=V[I-1];w[I-1]=H&-129;let j=Kt(w),C=m?e:b.ORDER;Ee("point.y",j,wB,C);let D=d(j*j),$=d(D-sb),K=d(x*D-y),{isValid:Q,value:r}=Z($,K);if(!Q)throw new Error("bad point: invalid y coordinate");let F=(r&sb)===sb,E=(H&128)!==0;if(!m&&r===wB&&E)throw new Error("bad point: x=0 and x_0=1");return E!==F&&(r=d(-r)),i.fromAffine({x:r,y:j})}static fromHex(V,m=!1){return i.fromBytes(ZG("point",V),m)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(V=8,m=!0){return Y.createCache(this,V),m||this.multiply(cm),this}assertValidity(){W(this)}equals(V){n(V);let{X:m,Y:I,Z:y}=this,{X:x,Y:w,Z:H}=V,j=d(m*H),C=d(x*y),D=d(I*H),$=d(w*y);return j===C&&D===$}is0(){return this.equals(i.ZERO)}negate(){return new i(d(-this.X),this.Y,this.Z,d(-this.T))}double(){let{a:V}=c,{X:m,Y:I,Z:y}=this,x=d(m*m),w=d(I*I),H=d(cm*d(y*y)),j=d(V*x),C=m+I,D=d(d(C*C)-x-w),$=j+w,K=$-H,Q=j-w,r=d(D*K),F=d($*Q),E=d(D*Q),f=d(K*$);return new i(r,F,f,E)}add(V){n(V);let{a:m,d:I}=c,{X:y,Y:x,Z:w,T:H}=this,{X:j,Y:C,Z:D,T:$}=V,K=d(y*j),Q=d(x*C),r=d(H*I*$),F=d(w*D),E=d((y+x)*(j+C)-K-Q),f=F-r,s=F+r,p=d(Q-m*K),X=d(E*f),o=d(s*p),g=d(E*p),u=d(f*s);return new i(X,o,u,g)}subtract(V){return this.add(V.negate())}multiply(V){if(!t.isValidNot0(V))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:m,f:I}=Y.cached(this,V,y=>GB(i,y));return GB(i,[m,I])[0]}multiplyUnsafe(V,m=i.ZERO){if(!t.isValid(V))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return V===wB?i.ZERO:this.is0()||V===sb?this:Y.unsafe(this,V,I=>GB(i,I),m)}isSmallOrder(){return this.multiplyUnsafe(B).is0()}isTorsionFree(){return Y.unsafe(this,c.n).is0()}toAffine(V){return h(this,V)}clearCofactor(){return B===sb?this:this.multiplyUnsafe(B)}toBytes(){let{x:V,y:m}=this.toAffine(),I=b.toBytes(m);return I[I.length-1]|=V&sb?128:0,I}toHex(){return et(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(V){return GB(i,V)}static msm(V,m){return bd(i,t,V,m)}_setWindowSize(V){this.precompute(V)}toRawBytes(){return this.toBytes()}}i.BASE=new i(c.Gx,c.Gy,sb,d(c.Gx*c.Gy)),i.ZERO=new i(wB,sb,sb,wB),i.Fp=b,i.Fn=t;let Y=new Gd(i,t.BITS);return i.BASE.precompute(8),i}var Go=class{constructor(A){this.ep=A}static fromBytes(A){qW()}static fromHex(A){qW()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(A){return this.ep.toAffine(A)}toHex(){return et(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(A){return this.assertSame(A),this.init(this.ep.add(A.ep))}subtract(A){return this.assertSame(A),this.init(this.ep.subtract(A.ep))}multiply(A){return this.init(this.ep.multiply(A))}multiplyUnsafe(A){return this.init(this.ep.multiplyUnsafe(A))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(A,G){return this.init(this.ep.precompute(A,G))}toRawBytes(){return this.toBytes()}};function T5(l,A,G={}){if(typeof A!="function")throw new Error('"hash" function param is required');kB(G,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:b}=G,{BASE:t,Fp:c,Fn:B}=l,e=G.randomBytes||vb,d=G.adjustScalarBytes||(C=>C),Z=G.domain||((C,D,$)=>{if(lB($,"phflag"),D.length||$)throw new Error("Contexts/pre-hash are not supported");return C});function a(C){return B.create(Kt(C))}function n(C){let D=I.secretKey;C=ZG("private key",C,D);let $=ZG("hashed private key",A(C),2*D),K=d($.slice(0,D)),Q=$.slice(D,2*D),r=a(K);return{head:K,prefix:Q,scalar:r}}function h(C){let{head:D,prefix:$,scalar:K}=n(C),Q=t.multiply(K),r=Q.toBytes();return{head:D,prefix:$,scalar:K,point:Q,pointBytes:r}}function W(C){return h(C).pointBytes}function i(C=Uint8Array.of(),...D){let $=VG(...D);return a(A(Z($,ZG("context",C),!!b)))}function Y(C,D,$={}){C=ZG("message",C),b&&(C=b(C));let{prefix:K,scalar:Q,pointBytes:r}=h(D),F=i($.context,K,C),E=t.multiply(F).toBytes(),f=i($.context,E,r,C),s=B.create(F+f*Q);if(!B.isValid(s))throw new Error("sign failed: invalid s");let p=VG(E,B.toBytes(s));return Vt(p,I.signature,"result")}let R={zip215:!0};function V(C,D,$,K=R){let{context:Q,zip215:r}=K,F=I.signature;C=ZG("signature",C,F),D=ZG("message",D),$=ZG("publicKey",$,I.publicKey),r!==void 0&&lB(r,"zip215"),b&&(D=b(D));let E=F/2,f=C.subarray(0,E),s=Kt(C.subarray(E,F)),p,X,o;try{p=l.fromBytes($,r),X=l.fromBytes(f,r),o=t.multiplyUnsafe(s)}catch{return!1}if(!r&&p.isSmallOrder())return!1;let g=i(Q,X.toBytes(),p.toBytes(),D);return X.add(p.multiplyUnsafe(g)).subtract(o).clearCofactor().is0()}let m=c.BYTES,I={secretKey:m,publicKey:m,signature:2*m,seed:m};function y(C=e(I.seed)){return Vt(C,I.seed,"seed")}function x(C){let D=j.randomSecretKey(C);return{secretKey:D,publicKey:W(D)}}function w(C){return kt(C)&&C.length===B.BYTES}function H(C,D){try{return!!l.fromBytes(C,D)}catch{return!1}}let j={getExtendedPublicKey:h,randomSecretKey:y,isValidSecretKey:w,isValidPublicKey:H,toMontgomery(C){let{y:D}=l.fromBytes(C),$=I.publicKey,K=$===32;if(!K&&$!==57)throw new Error("only defined for 25519 and 448");let Q=K?c.div(sb+D,sb-D):c.div(D-sb,D+sb);return c.toBytes(Q)},toMontgomerySecret(C){let D=I.secretKey;Vt(C,D);let $=A(C.subarray(0,D));return d($).subarray(0,D)},randomPrivateKey:y,precompute(C=8,D=l.BASE){return D.precompute(C,!1)}};return Object.freeze({keygen:x,getPublicKey:W,sign:Y,verify:V,utils:j,Point:l,lengths:I})}function D5(l){let A={a:l.a,d:l.d,p:l.Fp.ORDER,n:l.n,h:l.h,Gx:l.Gx,Gy:l.Gy},G=l.Fp,b=ut(A.n,l.nBitLength,!0),t={Fp:G,Fn:b,uvRatio:l.uvRatio},c={randomBytes:l.randomBytes,adjustScalarBytes:l.adjustScalarBytes,domain:l.domain,prehash:l.prehash,mapToCurve:l.mapToCurve};return{CURVE:A,curveOpts:t,hash:l.hash,eddsaOpts:c}}function L5(l,A){let G=A.Point;return Object.assign({},A,{ExtendedPoint:G,CURVE:l,nBitLength:G.Fn.BITS,nByteLength:G.Fn.BYTES})}function wy(l){let{CURVE:A,curveOpts:G,hash:b,eddsaOpts:t}=D5(l),c=M5(A,G),B=T5(c,b,t);return L5(l,B)}var O5=BigInt(0),cB=BigInt(1),Uy=BigInt(2),tcl=BigInt(3),P5=BigInt(5),K5=BigInt(8),ed=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Mn={p:ed,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:K5,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function q5(l){let A=BigInt(10),G=BigInt(20),b=BigInt(40),t=BigInt(80),c=ed,e=l*l%c*l%c,d=RG(e,Uy,c)*e%c,Z=RG(d,cB,c)*l%c,a=RG(Z,P5,c)*Z%c,n=RG(a,A,c)*a%c,h=RG(n,G,c)*n%c,W=RG(h,b,c)*h%c,i=RG(W,t,c)*W%c,Y=RG(i,t,c)*W%c,R=RG(Y,A,c)*a%c;return{pow_p_5_8:RG(R,Uy,c)*l%c,b2:e}}function _5(l){return l[0]&=248,l[31]&=127,l[31]|=64,l}var Bm=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function dm(l,A){let G=ed,b=IG(A*A*A,G),t=IG(b*b*A,G),c=q5(l*t).pow_p_5_8,B=IG(l*b*c,G),e=IG(A*B*B,G),d=B,Z=IG(B*Bm,G),a=e===l,n=e===IG(-l,G),h=e===IG(-l*Bm,G);return a&&(B=d),(n||h)&&(B=Z),AB(B,G)&&(B=IG(-B,G)),{isValid:a||n,value:B}}var UB=ut(Mn.p,{isLE:!0}),$5=ut(Mn.n,{isLE:!0}),lJ={...Mn,Fp:UB,hash:OW,adjustScalarBytes:_5,uvRatio:dm},Ob=wy(lJ);var em=Bm,AJ=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),GJ=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),bJ=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),tJ=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Cy=l=>dm(cB,l),cJ=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Zm=l=>Ob.Point.Fp.create(Kt(l)&cJ);function Sy(l){let{d:A}=Mn,G=ed,b=V=>UB.create(V),t=b(em*l*l),c=b((t+cB)*bJ),B=BigInt(-1),e=b((B-A*t)*b(t+A)),{isValid:d,value:Z}=dm(c,e),a=b(Z*l);AB(a,G)||(a=b(-a)),d||(Z=a),d||(B=t);let n=b(B*(t-cB)*tJ-e),h=Z*Z,W=b((Z+Z)*e),i=b(n*AJ),Y=b(cB-h),R=b(cB+h);return new Ob.Point(b(W*R),b(Y*i),b(i*R),b(W*Y))}function BJ(l){kG(l,64);let A=Zm(l.subarray(0,32)),G=Sy(A),b=Zm(l.subarray(32,64)),t=Sy(b);return new Fc(G.add(t))}var Fc=class l extends Go{constructor(A){super(A)}static fromAffine(A){return new l(Ob.Point.fromAffine(A))}assertSame(A){if(!(A instanceof l))throw new Error("RistrettoPoint expected")}init(A){return new l(A)}static hashToCurve(A){return BJ(ZG("ristrettoHash",A,64))}static fromBytes(A){kG(A,32);let{a:G,d:b}=Mn,t=ed,c=y=>UB.create(y),B=Zm(A);if(!zi(UB.toBytes(B),A)||AB(B,t))throw new Error("invalid ristretto255 encoding 1");let e=c(B*B),d=c(cB+G*e),Z=c(cB-G*e),a=c(d*d),n=c(Z*Z),h=c(G*b*a-n),{isValid:W,value:i}=Cy(c(h*n)),Y=c(i*Z),R=c(i*Y*h),V=c((B+B)*Y);AB(V,t)&&(V=c(-V));let m=c(d*R),I=c(V*m);if(!W||AB(I,t)||m===O5)throw new Error("invalid ristretto255 encoding 2");return new l(new Ob.Point(V,m,cB,I))}static fromHex(A){return l.fromBytes(ZG("ristrettoHex",A,32))}static msm(A,G){return bd(l,Ob.Point.Fn,A,G)}toBytes(){let{X:A,Y:G,Z:b,T:t}=this.ep,c=ed,B=R=>UB.create(R),e=B(B(b+G)*B(b-G)),d=B(A*G),Z=B(d*d),{value:a}=Cy(B(e*Z)),n=B(a*e),h=B(a*d),W=B(n*h*t),i;if(AB(t*W,c)){let R=B(G*em),V=B(A*em);A=R,G=V,i=B(n*GJ)}else i=h;AB(A*W,c)&&(G=B(-G));let Y=B((b-G)*i);return AB(Y,c)&&(Y=B(-Y)),UB.toBytes(Y)}equals(A){this.assertSame(A);let{X:G,Y:b}=this.ep,{X:t,Y:c}=A.ep,B=Z=>UB.create(Z),e=B(G*c)===B(b*t),d=B(b*c)===B(G*t);return e||d}is0(){return this.equals(l.ZERO)}};Fc.BASE=new Fc(Ob.Point.BASE);Fc.ZERO=new Fc(Ob.Point.ZERO);Fc.Fp=UB;Fc.Fn=$5;var KG=Fc;function fe(l,A){if(!PA||!A&&TA()){let b=PV(l);return{publicKey:b.slice(32),secretKey:b.slice(0,64)}}let G=Ob.getPublicKey(l);return{publicKey:G,secretKey:dc([l,G])}}function nm(l,{publicKey:A,secretKey:G},b){if(G){if(!A)throw new Error("Expected a valid publicKey")}else throw new Error("Expected a valid secretKey");let t=Tl(l),c=G.subarray(0,32);return!PA||!b&&TA()?KV(A,c,t):Ob.sign(t,c)}function zy(l,A,G,b){let t=Tl(l),c=Tl(G),B=Tl(A);if(c.length!==32)throw new Error(`Invalid publicKey, received ${c.length}, expected 32`);if(B.length!==64)throw new Error(`Invalid signature, received ${B.length} bytes, expected 64`);try{return!PA||!b&&TA()?qV(B,t,c):Ob.verify(B,t,c)}catch{return!1}}var jy=Ao(fe,tm);var am=kt;var Zd=Kt;var _t=Cn;var gm=Ee;var My=Xc;var eJ=BigInt(0),Tn=BigInt(1),ZJ=BigInt(2),dJ=BigInt(7),nJ=BigInt(256),aJ=BigInt(113),Ly=[],Oy=[],Py=[];for(let l=0,A=Tn,G=1,b=0;l<24;l++){[G,b]=[b,(2*G+3*b)%5],Ly.push(2*(5*b+G)),Oy.push((l+1)*(l+2)/2%64);let t=eJ;for(let c=0;c<7;c++)A=(A<<Tn^(A>>dJ)*aJ)%nJ,A&ZJ&&(t^=Tn<<(Tn<<BigInt(c))-Tn);Py.push(t)}var Ky=Ya(Py,!0),gJ=Ky[0],WJ=Ky[1],Ty=(l,A,G)=>G>32?cV(l,A,G):bV(l,A,G),Dy=(l,A,G)=>G>32?BV(l,A,G):tV(l,A,G);function om(l,A=24){let G=new Uint32Array(10);for(let b=24-A;b<24;b++){for(let B=0;B<10;B++)G[B]=l[B]^l[B+10]^l[B+20]^l[B+30]^l[B+40];for(let B=0;B<10;B+=2){let e=(B+8)%10,d=(B+2)%10,Z=G[d],a=G[d+1],n=Ty(Z,a,1)^G[e],h=Dy(Z,a,1)^G[e+1];for(let W=0;W<50;W+=10)l[B+W]^=n,l[B+W+1]^=h}let t=l[2],c=l[3];for(let B=0;B<24;B++){let e=Oy[B],d=Ty(t,c,e),Z=Dy(t,c,e),a=Ly[B];t=l[a],c=l[a+1],l[a]=d,l[a+1]=Z}for(let B=0;B<50;B+=10){for(let e=0;e<10;e++)G[e]=l[B+e];for(let e=0;e<10;e++)l[B+e]^=~G[(e+2)%10]&G[(e+4)%10]}l[0]^=gJ[b],l[1]^=WJ[b]}TG(G)}var Wm=class l extends tc{constructor(A,G,b,t=!1,c=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=A,this.suffix=G,this.outputLen=b,this.enableXOF=t,this.rounds=c,mG(b),!(0<A&&A<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=ct(this.state)}clone(){return this._cloneInto()}keccak(){Bt(this.state32),om(this.state32,this.rounds),Bt(this.state32),this.posOut=0,this.pos=0}update(A){pt(this),A=Zt(A),kG(A);let{blockLen:G,state:b}=this,t=A.length;for(let c=0;c<t;){let B=Math.min(G-this.pos,t-c);for(let e=0;e<B;e++)b[this.pos++]^=A[c++];this.pos===G&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:A,suffix:G,pos:b,blockLen:t}=this;A[b]^=G,G&128&&b===t-1&&this.keccak(),A[t-1]^=128,this.keccak()}writeInto(A){pt(this,!1),kG(A),this.finish();let G=this.state,{blockLen:b}=this;for(let t=0,c=A.length;t<c;){this.posOut>=b&&this.keccak();let B=Math.min(b-this.posOut,c-t);A.set(G.subarray(this.posOut,this.posOut+B),t),this.posOut+=B,t+=B}return A}xofInto(A){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(A)}xof(A){return mG(A),this.xofInto(new Uint8Array(A))}digestInto(A){if(qe(A,this),this.finished)throw new Error("digest() was already called");return this.writeInto(A),this.destroy(),A}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,TG(this.state)}_cloneInto(A){let{blockLen:G,suffix:b,outputLen:t,rounds:c,enableXOF:B}=this;return A||(A=new l(G,b,t,B,c)),A.state32.set(this.state32),A.pos=this.pos,A.posOut=this.posOut,A.finished=this.finished,A.rounds=c,A.suffix=b,A.outputLen=t,A.enableXOF=B,A.destroyed=this.destroyed,A}},qy=(l,A,G)=>pd(()=>new Wm(A,l,G));var bo=qy(1,136,256/8);var _y=qy(1,72,512/8);var CB=OW;var GQ=BigInt(0),bQ=BigInt(3);function hm(l){if(typeof l=="string")return Ec(l);if(am(l))return l;throw new Error("Wrong data")}function NG(l,A,...G){if(!am(A))throw new Error(`${l}: Uint8Array expected`);if(G.length&&!G.includes(A.length))throw new Error(`${l}: Uint8Array expected of length ${G}, not of length=${A.length}`)}function to(l,A){if(!Number.isSafeInteger(A)||A<0||A>4294967295)throw new Error(`${l}: wrong u32 integer: ${A}`);return A}function dd(...l){for(let A of l)A.fill(0)}var xe=Uint8Array.of(),im=Ob.CURVE.n;function $y(l,A){NG(l,A,32);let G=Zd(A);return gm(l,G,GQ,im),G}var Ln=l=>IG(l,im),Dn=166,$t={I:1,A:2,C:4,T:8,M:16,K:32},sm=class l{constructor(A){this.state=new Uint8Array(200),this.pos=0,this.posBegin=0,this.curFlags=0,this.state.set([1,Dn+2,1,0,1,96],0),this.state.set(Ec("STROBEv1.0.2"),6),this.state32=ct(this.state),this.keccakF1600(),this.metaAD(A,!1)}keccakF1600(){om(this.state32)}runF(){this.state[this.pos]^=this.posBegin,this.state[this.pos+1]^=4,this.state[Dn+1]^=128,this.keccakF1600(),this.pos=0,this.posBegin=0}absorb(A){for(let G=0;G<A.length;G++)this.state[this.pos++]^=A[G],this.pos===Dn&&this.runF()}squeeze(A){let G=new Uint8Array(A);for(let b=0;b<G.length;b++)G[b]=this.state[this.pos],this.state[this.pos++]=0,this.pos===Dn&&this.runF();return G}overwrite(A){for(let G=0;G<A.length;G++)this.state[this.pos++]=A[G],this.pos===Dn&&this.runF()}beginOp(A,G){if(G){if(this.curFlags!==A)throw new Error(`Continued op with changed flags from ${this.curFlags.toString(2)} to ${A.toString(2)}`);return}if(A&$t.T)throw new Error("T flag is not supported");let b=this.posBegin;this.posBegin=this.pos+1,this.curFlags=A,this.absorb(new Uint8Array([b,A])),(A&($t.C|$t.K))!==0&&this.pos!==0&&this.runF()}metaAD(A,G){this.beginOp($t.M|$t.A,G),this.absorb(hm(A))}AD(A,G){this.beginOp($t.A,G),this.absorb(hm(A))}PRF(A,G){return this.beginOp($t.I|$t.A|$t.C,G),this.squeeze(A)}KEY(A,G){this.beginOp($t.A|$t.C,G),this.overwrite(hm(A))}clone(){let A=new l("0");return A.pos=this.pos,A.posBegin=this.posBegin,A.state.set(this.state),A.curFlags=this.curFlags,A}clean(){this.state.fill(0),this.pos=0,this.curFlags=0,this.posBegin=0}},rm=class{constructor(A){this.strobe=new sm("Merlin v1.0"),this.appendMessage("dom-sep",A)}appendMessage(A,G){this.strobe.metaAD(A,!1),to("Merlin.appendMessage",G.length),this.strobe.metaAD(_t(G.length,4),!0),this.strobe.AD(G,!1)}challengeBytes(A,G){return this.strobe.metaAD(A,!1),to("Merlin.challengeBytes",G),this.strobe.metaAD(_t(G,4),!0),this.strobe.PRF(G,!1)}clean(){this.strobe.clean()}},BB=class extends rm{constructor(A,G=vb){super(A),this.rng=G}label(A){this.appendMessage("",A)}bytes(A){return this.appendMessage("sign-bytes",A),this}protoName(A){this.appendMessage("proto-name",A)}commitPoint(A,G){this.appendMessage(A,G.toRawBytes())}challengeScalar(A){return Ln(Zd(this.challengeBytes(A,64)))}witnessScalar(A,G=[]){return Ln(Zd(this.witnessBytes(A,64,G)))}witnessBytes(A,G,b=[]){to("SigningContext.witnessBytes",G);let t=this.strobe.clone();for(let B of b)t.metaAD(A,!1),to("SigningContext.witnessBytes nonce length",B.length),t.metaAD(_t(B.length,4),!0),t.KEY(B,!1);let c=this.rng(32);return t.metaAD("rng",!1),t.KEY(c,!1),t.metaAD(_t(G,4),!1),t.PRF(G,!1)}},oJ=My(256),tQ=l=>_t(l<<bQ&oJ,32),nd=l=>Zd(l)>>bQ;function ke(l){NG("secretKey",l,64);let A=nd(l.subarray(0,32));return KG.BASE.multiply(A).toRawBytes()}function mm(l){NG("seed",l,32);let A=CB(l);A[0]&=248,A[31]&=63,A[31]|=64;let G=tQ(nd(A.subarray(0,32))),b=A.subarray(32,64),t=VG(G,b);return dd(G,b,A),t}var cQ=Ec("substrate");function BQ(l,A,G=vb){NG("message",A),NG("secretKey",l,64);let b=new BB("SigningContext",G);b.label(cQ),b.bytes(A);let t=nd(l.subarray(0,32)),c=l.subarray(32,64),B=KG.fromHex(ke(l));b.protoName("Schnorr-sig"),b.commitPoint("sign:pk",B);let e=b.witnessScalar("signing",[c]),d=KG.BASE.multiply(e);b.commitPoint("sign:R",d);let Z=b.challengeScalar("sign:c"),a=Ln(Z*t+e),n=VG(d.toRawBytes(),_t(a,32));return n[63]|=128,b.clean(),n}function eQ(l,A,G){if(NG("message",l),NG("signature",A,64),NG("publicKey",G,32),!(A[63]&128))throw new Error("Schnorrkel marker missing");let b=Uint8Array.from(A.subarray(32,64));b[31]&=127;let t=KG.fromHex(A.subarray(0,32)),c=Zd(b);gm("s",c,GQ,im);let B=new BB("SigningContext");B.label(cQ),B.bytes(l);let e=KG.fromHex(G);if(e.equals(KG.ZERO))return!1;B.protoName("Schnorr-sig"),B.commitPoint("sign:pk",e),B.commitPoint("sign:R",t);let d=B.challengeScalar("sign:c"),Z=KG.BASE.multiply(c),a=e.negate().multiply(d).add(Z);return B.clean(),dd(b),a.equals(t)}var co={secretSoft(l,A,G=vb){NG("secretKey",l,64),NG("chainCode",A,32);let b=nd(l.subarray(0,32)),t=l.subarray(32,64),c=KG.fromHex(ke(l)),B=new BB("SchnorrRistrettoHDKD",G);B.bytes(xe),B.appendMessage("chain-code",A),B.commitPoint("public-key",c);let e=B.challengeScalar("HDKD-scalar"),d=B.challengeBytes("HDKD-chaincode",32),Z=VG(_t(b,32),t),a=B.witnessBytes("HDKD-nonce",32,[t,Z]),n=tQ(Ln(b+e)),h=VG(n,a);return dd(n,a,Z,d),B.clean(),h},publicSoft(l,A){NG("publicKey",l,32),NG("chainCode",A,32);let G=KG.fromHex(l),b=new BB("SchnorrRistrettoHDKD");b.bytes(xe),b.appendMessage("chain-code",A),b.commitPoint("public-key",G);let t=b.challengeScalar("HDKD-scalar");return b.challengeBytes("HDKD-chaincode",32),b.clean(),G.add(KG.BASE.multiply(t)).toRawBytes()},secretHard(l,A){NG("secretKey",l,64),NG("chainCode",A,32);let G=_t(nd(l.subarray(0,32)),32),b=new BB("SchnorrRistrettoHDKD");b.bytes(xe),b.appendMessage("chain-code",A),b.appendMessage("secret-key",G);let t=b.challengeBytes("HDKD-hard",32),c=b.challengeBytes("HDKD-chaincode",32);b.clean();let B=mm(t);return dd(G,t,c),b.clean(),B}},lQ={proove(l,A,G,b,t,c){b.protoName("DLEQProof"),b.commitPoint("vrf:h",t);let B=b.witnessScalar("proving\x000",[A]),e=KG.BASE.multiply(B);b.commitPoint("vrf:R=g^r",e);let d=t.multiply(B);b.commitPoint("vrf:h^r",d),b.commitPoint("vrf:pk",G),b.commitPoint("vrf:h^sk",c);let Z=b.challengeScalar("prove"),a=Ln(B-Z*l);return{proof:{c:Z,s:a},proofBatchable:{R:e,Hr:d,s:a}}},verify(l,A,G,b,t){if(l.equals(KG.ZERO))return!1;A.protoName("DLEQProof"),A.commitPoint("vrf:h",G);let c=l.multiply(t.c).add(KG.BASE.multiply(t.s));A.commitPoint("vrf:R=g^r",c);let B=b.multiply(t.c).add(G.multiply(t.s));A.commitPoint("vrf:h^r",B),A.commitPoint("vrf:pk",l),A.commitPoint("vrf:h^sk",b);let e=A.challengeScalar("prove");return t.c===e?{R:c,Hr:B,s:t.s}:!1}};function AQ(l,A,G,b,t=vb){let c=new BB("SigningContext",t);c.label(l),c.bytes(A),c.commitPoint("vrf-nm-pk",b);let B=c.challengeBytes("VRFHash",64),e=KG.hashToCurve(B),d=new BB("VRF",t);return G.length&&d.label(G),c.clean(),dd(B),{input:e,t:d}}var Bo={sign(l,A,G=xe,b=xe,t=vb){NG("msg",l),NG("secretKey",A,64),NG("ctx",G),NG("extra",b);let c=nd(A.subarray(0,32)),B=A.subarray(32,64),e=KG.fromHex(ke(A)),{input:d,t:Z}=AQ(G,l,b,e,t),a=d.multiply(c),n={input:d,output:a},{proof:h}=lQ.proove(c,B,e,Z,d,a),W=_t(h.c,32),i=_t(h.s,32),Y=VG(n.output.toRawBytes(),W,i);return dd(B,W,i),Y},verify(l,A,G,b=xe,t=xe,c=vb){NG("msg",l),NG("signature",A,96),NG("pubkey",G,32),NG("ctx",b),NG("extra",t);let B=KG.fromHex(G);if(B.equals(KG.ZERO))return!1;let e={c:$y("signature.c",A.subarray(32,64)),s:$y("signature.s",A.subarray(64,96))},{input:d,t:Z}=AQ(b,l,t,B,c),a=KG.fromHex(A.subarray(0,32));if(a.equals(KG.ZERO))throw new Error("vrf.verify: wrong output point (identity)");return lQ.verify(B,Z,d,a,e)!==!1}};function eo(l){return(A,G)=>{if(!Jb(G)||G.length!==32)throw new Error("Invalid chainCode passed to derive");let b=l(A.secretKey,G);return{publicKey:ke(b),secretKey:b}}}var ZQ=eo(co.secretHard);var dQ=eo(co.secretSoft);function nQ(l,{chainCode:A,isSoft:G}){return G?dQ(l,A):ZQ(l,A)}var hJ={ecdsa:bm,ed25519:jy,ethereum:bm,sr25519:nQ};function On(l,A,G){let b=hJ[G],t=l;for(let c of A)t=b(t,c);return t}function Pn(l){let A=Tl(l);if(A.length!==32)throw new Error(`Expected a seed matching 32 bytes, found ${A.length}`);let G=mm(A);return{publicKey:ke(G),secretKey:G}}function Vm(l,{publicKey:A,secretKey:G}){if(A?.length!==32)throw new Error("Expected a valid publicKey, 32-bytes");if(G?.length!==64)throw new Error("Expected a valid secretKey, 64-bytes");return BQ(G,Tl(l))}function aQ(l,A,G){let b=Tl(G),t=Tl(A);if(b.length!==32)throw new Error(`Invalid publicKey, received ${b.length} bytes, expected 32`);if(t.length!==64)throw new Error(`Invalid signature, received ${t.length} bytes, expected 64`);return eQ(Tl(l),t,b)}var gQ=new Uint8Array;function um(l,{secretKey:A},G=gQ,b=gQ){if(A?.length!==64)throw new Error("Invalid secretKey, expected 64-bytes");return Bo.sign(Tl(l),A,Tl(G),Tl(b),vb)}var WQ=new Uint8Array;function Ym(l,A,G,b=WQ,t=WQ){let c=Tl(G),B=Tl(A);if(c.length!==32)throw new Error("Invalid publicKey, expected 32-bytes");if(B.length!==96)throw new Error("Invalid vrfSign output, expected 96 bytes");return Bo.verify(Tl(l),B,c,Tl(b),Tl(t))}function Kn(l,A=_Z.prefix){let G=Pt(l);if(A<0||A>16383&&!sJ.includes(A)||[46,47].includes(A))throw new Error("Out of range ss58Format specified");if(!_Z.allowedDecodedLengths.includes(G.length))throw new Error(`Expected a valid key to convert, with length ${_Z.allowedDecodedLengths.join(", ")}`);let b=nG(A<64?[A]:[(A&252)>>2|64,A>>8|(A&3)<<6],G);return Ni(nG(b,SW(b).subarray(0,[32,33].includes(G.length)?2:1)))}var sJ=[29972];var zB=wa({256:Bu,512:eu},{256:bo,512:_y});function qn(l,A,G){return l==="keccak"?zB(A,void 0,G):Tb(A,void 0,void 0,G)}var Im={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",coder:ty,type:"base64",withPadding:!0},oQ=CW(Im);var Rm=wW(Im,oQ),Xm=UW(Im);function _n(l,A){if(![33,65].includes(l.length))throw new Error(`Invalid publicKey provided, received ${l.length} bytes input`);return l.length===33?l:!PA||!A&&TA()?$V(l):pc.ProjectivePoint.fromHex(l).toRawBytes(!0)}function we(l,A){if(![33,65].includes(l.length))throw new Error(`Invalid publicKey provided, received ${l.length} bytes input`);if(l.length===65)return l.subarray(1);if(!PA||!A&&TA())return lu(l).subarray(1);let{x:G,y:b}=pc.ProjectivePoint.fromHex(l);return nG(wG(G,$c),wG(b,$c))}function hQ(l,A,G,b="blake2",t){let c=Tl(A).subarray(0,64),B=Tl(l),e=!PA||!t&&TA()?Au(B,c,G):pc.Signature.fromCompact(c).addRecoveryBit(G).recoverPublicKey(B).toRawBytes();if(!e)throw new Error("Unable to recover publicKey from signature");return b==="keccak"?we(e,t):_n(e,t)}function Zo(l,{secretKey:A},G="blake2",b){if(A?.length!==32)throw new Error("Expected valid secp256k1 secretKey, 32-bytes");let t=qn(G,l,b);if(!PA||!b&&TA())return Gu(t,A);let c=pc.sign(t,A,{lowS:!0});return nG(wG(c.r,$c),wG(c.s,$c),new Uint8Array([c.recovery||0]))}var sQ="ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141".replace(/ /g,""),pm=UA(`0x${sQ}`),Fm=new FA.default(sQ,"hex");function rJ(l,A){let G=GZ(A,fi);if(G>=pm)throw new Error("Tweak parameter is out of range");if(G+=GZ(l,fi),G>=pm&&(G-=pm),G===lZ)throw new Error("Invalid resulting private key");return lh(G,$c)}function iJ(l,A){let G=new FA.default(A);if(G.cmp(Fm)>=0)throw new Error("Tweak parameter is out of range");if(G.iadd(new FA.default(l)),G.cmp(Fm)>=0&&G.isub(Fm),G.isZero())throw new Error("Invalid resulting private key");return wG(G,$c)}function ym(l,A,G){if(!Jb(l)||l.length!==32)throw new Error("Expected seckey to be an Uint8Array with length 32");if(!Jb(A)||A.length!==32)throw new Error("Expected tweak to be an Uint8Array with length 32");return!PA||G?iJ(l,A):rJ(l,A)}function rQ(l,A,G,b="blake2",t){let c=Tl(A);if(c.length!==65)throw new Error(`Expected signature with 65 bytes, ${c.length} found instead`);let B=hQ(qn(b,l),c,c[64],b,t),e=qn(b,B,t),d=Tl(G);return Mb(B,d)||(b==="keccak"?Mb(e.slice(-20),d.slice(-20)):Mb(e,d))}function mJ(l){return[33,65].includes(l.length)&&(l=zB(we(l))),l.slice(-20)}function $n(l){if(!l)return"0x";let A=Tl(l);if(![20,32,33,65].includes(A.length))throw new Error(`Invalid address or publicKey provided, received ${A.length} bytes input`);let G=nt(mJ(A),-1,!1),b=nt(zB(G),-1,!1),t="";for(let c=0;c<40;c++)t=`${t}${parseInt(b[c],16)>7?G[c].toUpperCase():G[c]}`;return`0x${t}`}var no=ye;var VJ={256:no,512:CB},uJ={256:tu,512:cu};function ao(l,A,G=256,b){let t=Tl(l);return!PA||!b&&TA()?uJ[G](t,A):Qe(VJ[G],t,A)}function iQ(l){if(!l.startsWith("m/"))return!1;let A=l.split("/").slice(1);for(let G of A){let b=/^\d+'?$/.test(G)?parseInt(G.replace(/'$/,""),10):Number.NaN;if(isNaN(b)||b>=2147483648||b<0)return!1}return!0}var YJ=uG("Bitcoin seed");function VQ(l,A){return{chainCode:A,publicKey:qt(l).publicKey,secretKey:l}}function uQ(l,A){let G=wG(A,ay),b=A>=2147483648?nG(new Uint8Array(1),l.secretKey,G):nG(l.publicKey,G);try{let t=ao(l.chainCode,b,512);return VQ(ym(l.secretKey,t.slice(0,32)),t.slice(32))}catch{return uQ(l,A+1)}}function Qm(l,A=""){let G=ao(YJ,l,512),b=VQ(G.slice(0,32),G.slice(32));if(!A||A==="m"||A==="M"||A==="m'"||A==="M'")return b;if(!iQ(A))throw new Error("Invalid derivation path");let t=A.split("/").slice(1);for(let c of t)b=uQ(b,parseInt(c,10)+(c.length>1&&c.endsWith("'")?2147483648:0));return b}function RJ(l,A,G,b){Ke(l);let t=Va({dkLen:32,asyncTick:10},b),{c,dkLen:B,asyncTick:e}=t;if(mG(c),mG(B),mG(e),c<1)throw new Error("iterations (c) should be >= 1");let d=So(A),Z=So(G),a=new Uint8Array(B),n=Qe.create(l,d),h=n._cloneInto().update(Z);return{c,dkLen:B,asyncTick:e,DK:a,PRF:n,PRFSalt:h}}function XJ(l,A,G,b,t){return l.destroy(),A.destroy(),b&&b.destroy(),TG(t),G}function la(l,A,G,b){let{c:t,dkLen:c,DK:B,PRF:e,PRFSalt:d}=RJ(l,A,G,b),Z,a=new Uint8Array(4),n=_e(a),h=new Uint8Array(e.outputLen);for(let W=1,i=0;i<c;W++,i+=e.outputLen){let Y=B.subarray(i,i+e.outputLen);n.setInt32(0,W,!1),(Z=d._cloneInto(Z)).update(a).digestInto(h),Y.set(h.subarray(0,Y.length));for(let R=1;R<t;R++){e._cloneInto(Z).update(h).digestInto(h);for(let V=0;V<Y.length;V++)Y[V]^=h[V]}}return XJ(e,d,B,Z,h)}function Aa(l,A=Bd(),G=2048,b){let t=Tl(l),c=Tl(A);return{password:!PA||!b&&TA()?Zu(t,c,G):la(CB,t,c,{c:G,dkLen:64}),rounds:G,salt:A}}var YQ=wa({256:nu,512:au},{256:no,512:CB}),Nm=nh(256,YQ);var IQ="abandon|ability|able|about|above|absent|absorb|abstract|absurd|abuse|access|accident|account|accuse|achieve|acid|acoustic|acquire|across|act|action|actor|actress|actual|adapt|add|addict|address|adjust|admit|adult|advance|advice|aerobic|affair|afford|afraid|again|age|agent|agree|ahead|aim|air|airport|aisle|alarm|album|alcohol|alert|alien|all|alley|allow|almost|alone|alpha|already|also|alter|always|amateur|amazing|among|amount|amused|analyst|anchor|ancient|anger|angle|angry|animal|ankle|announce|annual|another|answer|antenna|antique|anxiety|any|apart|apology|appear|apple|approve|april|arch|arctic|area|arena|argue|arm|armed|armor|army|around|arrange|arrest|arrive|arrow|art|artefact|artist|artwork|ask|aspect|assault|asset|assist|assume|asthma|athlete|atom|attack|attend|attitude|attract|auction|audit|august|aunt|author|auto|autumn|average|avocado|avoid|awake|aware|away|awesome|awful|awkward|axis|baby|bachelor|bacon|badge|bag|balance|balcony|ball|bamboo|banana|banner|bar|barely|bargain|barrel|base|basic|basket|battle|beach|bean|beauty|because|become|beef|before|begin|behave|behind|believe|below|belt|bench|benefit|best|betray|better|between|beyond|bicycle|bid|bike|bind|biology|bird|birth|bitter|black|blade|blame|blanket|blast|bleak|bless|blind|blood|blossom|blouse|blue|blur|blush|board|boat|body|boil|bomb|bone|bonus|book|boost|border|boring|borrow|boss|bottom|bounce|box|boy|bracket|brain|brand|brass|brave|bread|breeze|brick|bridge|brief|bright|bring|brisk|broccoli|broken|bronze|broom|brother|brown|brush|bubble|buddy|budget|buffalo|build|bulb|bulk|bullet|bundle|bunker|burden|burger|burst|bus|business|busy|butter|buyer|buzz|cabbage|cabin|cable|cactus|cage|cake|call|calm|camera|camp|can|canal|cancel|candy|cannon|canoe|canvas|canyon|capable|capital|captain|car|carbon|card|cargo|carpet|carry|cart|case|cash|casino|castle|casual|cat|catalog|catch|category|cattle|caught|cause|caution|cave|ceiling|celery|cement|census|century|cereal|certain|chair|chalk|champion|change|chaos|chapter|charge|chase|chat|cheap|check|cheese|chef|cherry|chest|chicken|chief|child|chimney|choice|choose|chronic|chuckle|chunk|churn|cigar|cinnamon|circle|citizen|city|civil|claim|clap|clarify|claw|clay|clean|clerk|clever|click|client|cliff|climb|clinic|clip|clock|clog|close|cloth|cloud|clown|club|clump|cluster|clutch|coach|coast|coconut|code|coffee|coil|coin|collect|color|column|combine|come|comfort|comic|common|company|concert|conduct|confirm|congress|connect|consider|control|convince|cook|cool|copper|copy|coral|core|corn|correct|cost|cotton|couch|country|couple|course|cousin|cover|coyote|crack|cradle|craft|cram|crane|crash|crater|crawl|crazy|cream|credit|creek|crew|cricket|crime|crisp|critic|crop|cross|crouch|crowd|crucial|cruel|cruise|crumble|crunch|crush|cry|crystal|cube|culture|cup|cupboard|curious|current|curtain|curve|cushion|custom|cute|cycle|dad|damage|damp|dance|danger|daring|dash|daughter|dawn|day|deal|debate|debris|decade|december|decide|decline|decorate|decrease|deer|defense|define|defy|degree|delay|deliver|demand|demise|denial|dentist|deny|depart|depend|deposit|depth|deputy|derive|describe|desert|design|desk|despair|destroy|detail|detect|develop|device|devote|diagram|dial|diamond|diary|dice|diesel|diet|differ|digital|dignity|dilemma|dinner|dinosaur|direct|dirt|disagree|discover|disease|dish|dismiss|disorder|display|distance|divert|divide|divorce|dizzy|doctor|document|dog|doll|dolphin|domain|donate|donkey|donor|door|dose|double|dove|draft|dragon|drama|drastic|draw|dream|dress|drift|drill|drink|drip|drive|drop|drum|dry|duck|dumb|dune|during|dust|dutch|duty|dwarf|dynamic|eager|eagle|early|earn|earth|easily|east|easy|echo|ecology|economy|edge|edit|educate|effort|egg|eight|either|elbow|elder|electric|elegant|element|elephant|elevator|elite|else|embark|embody|embrace|emerge|emotion|employ|empower|empty|enable|enact|end|endless|endorse|enemy|energy|enforce|engage|engine|enhance|enjoy|enlist|enough|enrich|enroll|ensure|enter|entire|entry|envelope|episode|equal|equip|era|erase|erode|erosion|error|erupt|escape|essay|essence|estate|eternal|ethics|evidence|evil|evoke|evolve|exact|example|excess|exchange|excite|exclude|excuse|execute|exercise|exhaust|exhibit|exile|exist|exit|exotic|expand|expect|expire|explain|expose|express|extend|extra|eye|eyebrow|fabric|face|faculty|fade|faint|faith|fall|false|fame|family|famous|fan|fancy|fantasy|farm|fashion|fat|fatal|father|fatigue|fault|favorite|feature|february|federal|fee|feed|feel|female|fence|festival|fetch|fever|few|fiber|fiction|field|figure|file|film|filter|final|find|fine|finger|finish|fire|firm|first|fiscal|fish|fit|fitness|fix|flag|flame|flash|flat|flavor|flee|flight|flip|float|flock|floor|flower|fluid|flush|fly|foam|focus|fog|foil|fold|follow|food|foot|force|forest|forget|fork|fortune|forum|forward|fossil|foster|found|fox|fragile|frame|frequent|fresh|friend|fringe|frog|front|frost|frown|frozen|fruit|fuel|fun|funny|furnace|fury|future|gadget|gain|galaxy|gallery|game|gap|garage|garbage|garden|garlic|garment|gas|gasp|gate|gather|gauge|gaze|general|genius|genre|gentle|genuine|gesture|ghost|giant|gift|giggle|ginger|giraffe|girl|give|glad|glance|glare|glass|glide|glimpse|globe|gloom|glory|glove|glow|glue|goat|goddess|gold|good|goose|gorilla|gospel|gossip|govern|gown|grab|grace|grain|grant|grape|grass|gravity|great|green|grid|grief|grit|grocery|group|grow|grunt|guard|guess|guide|guilt|guitar|gun|gym|habit|hair|half|hammer|hamster|hand|happy|harbor|hard|harsh|harvest|hat|have|hawk|hazard|head|health|heart|heavy|hedgehog|height|hello|helmet|help|hen|hero|hidden|high|hill|hint|hip|hire|history|hobby|hockey|hold|hole|holiday|hollow|home|honey|hood|hope|horn|horror|horse|hospital|host|hotel|hour|hover|hub|huge|human|humble|humor|hundred|hungry|hunt|hurdle|hurry|hurt|husband|hybrid|ice|icon|idea|identify|idle|ignore|ill|illegal|illness|image|imitate|immense|immune|impact|impose|improve|impulse|inch|include|income|increase|index|indicate|indoor|industry|infant|inflict|inform|inhale|inherit|initial|inject|injury|inmate|inner|innocent|input|inquiry|insane|insect|inside|inspire|install|intact|interest|into|invest|invite|involve|iron|island|isolate|issue|item|ivory|jacket|jaguar|jar|jazz|jealous|jeans|jelly|jewel|job|join|joke|journey|joy|judge|juice|jump|jungle|junior|junk|just|kangaroo|keen|keep|ketchup|key|kick|kid|kidney|kind|kingdom|kiss|kit|kitchen|kite|kitten|kiwi|knee|knife|knock|know|lab|label|labor|ladder|lady|lake|lamp|language|laptop|large|later|latin|laugh|laundry|lava|law|lawn|lawsuit|layer|lazy|leader|leaf|learn|leave|lecture|left|leg|legal|legend|leisure|lemon|lend|length|lens|leopard|lesson|letter|level|liar|liberty|library|license|life|lift|light|like|limb|limit|link|lion|liquid|list|little|live|lizard|load|loan|lobster|local|lock|logic|lonely|long|loop|lottery|loud|lounge|love|loyal|lucky|luggage|lumber|lunar|lunch|luxury|lyrics|machine|mad|magic|magnet|maid|mail|main|major|make|mammal|man|manage|mandate|mango|mansion|manual|maple|marble|march|margin|marine|market|marriage|mask|mass|master|match|material|math|matrix|matter|maximum|maze|meadow|mean|measure|meat|mechanic|medal|media|melody|melt|member|memory|mention|menu|mercy|merge|merit|merry|mesh|message|metal|method|middle|midnight|milk|million|mimic|mind|minimum|minor|minute|miracle|mirror|misery|miss|mistake|mix|mixed|mixture|mobile|model|modify|mom|moment|monitor|monkey|monster|month|moon|moral|more|morning|mosquito|mother|motion|motor|mountain|mouse|move|movie|much|muffin|mule|multiply|muscle|museum|mushroom|music|must|mutual|myself|mystery|myth|naive|name|napkin|narrow|nasty|nation|nature|near|neck|need|negative|neglect|neither|nephew|nerve|nest|net|network|neutral|never|news|next|nice|night|noble|noise|nominee|noodle|normal|north|nose|notable|note|nothing|notice|novel|now|nuclear|number|nurse|nut|oak|obey|object|oblige|obscure|observe|obtain|obvious|occur|ocean|october|odor|off|offer|office|often|oil|okay|old|olive|olympic|omit|once|one|onion|online|only|open|opera|opinion|oppose|option|orange|orbit|orchard|order|ordinary|organ|orient|original|orphan|ostrich|other|outdoor|outer|output|outside|oval|oven|over|own|owner|oxygen|oyster|ozone|pact|paddle|page|pair|palace|palm|panda|panel|panic|panther|paper|parade|parent|park|parrot|party|pass|patch|path|patient|patrol|pattern|pause|pave|payment|peace|peanut|pear|peasant|pelican|pen|penalty|pencil|people|pepper|perfect|permit|person|pet|phone|photo|phrase|physical|piano|picnic|picture|piece|pig|pigeon|pill|pilot|pink|pioneer|pipe|pistol|pitch|pizza|place|planet|plastic|plate|play|please|pledge|pluck|plug|plunge|poem|poet|point|polar|pole|police|pond|pony|pool|popular|portion|position|possible|post|potato|pottery|poverty|powder|power|practice|praise|predict|prefer|prepare|present|pretty|prevent|price|pride|primary|print|priority|prison|private|prize|problem|process|produce|profit|program|project|promote|proof|property|prosper|protect|proud|provide|public|pudding|pull|pulp|pulse|pumpkin|punch|pupil|puppy|purchase|purity|purpose|purse|push|put|puzzle|pyramid|quality|quantum|quarter|question|quick|quit|quiz|quote|rabbit|raccoon|race|rack|radar|radio|rail|rain|raise|rally|ramp|ranch|random|range|rapid|rare|rate|rather|raven|raw|razor|ready|real|reason|rebel|rebuild|recall|receive|recipe|record|recycle|reduce|reflect|reform|refuse|region|regret|regular|reject|relax|release|relief|rely|remain|remember|remind|remove|render|renew|rent|reopen|repair|repeat|replace|report|require|rescue|resemble|resist|resource|response|result|retire|retreat|return|reunion|reveal|review|reward|rhythm|rib|ribbon|rice|rich|ride|ridge|rifle|right|rigid|ring|riot|ripple|risk|ritual|rival|river|road|roast|robot|robust|rocket|romance|roof|rookie|room|rose|rotate|rough|round|route|royal|rubber|rude|rug|rule|run|runway|rural|sad|saddle|sadness|safe|sail|salad|salmon|salon|salt|salute|same|sample|sand|satisfy|satoshi|sauce|sausage|save|say|scale|scan|scare|scatter|scene|scheme|school|science|scissors|scorpion|scout|scrap|screen|script|scrub|sea|search|season|seat|second|secret|section|security|seed|seek|segment|select|sell|seminar|senior|sense|sentence|series|service|session|settle|setup|seven|shadow|shaft|shallow|share|shed|shell|sheriff|shield|shift|shine|ship|shiver|shock|shoe|shoot|shop|short|shoulder|shove|shrimp|shrug|shuffle|shy|sibling|sick|side|siege|sight|sign|silent|silk|silly|silver|similar|simple|since|sing|siren|sister|situate|six|size|skate|sketch|ski|skill|skin|skirt|skull|slab|slam|sleep|slender|slice|slide|slight|slim|slogan|slot|slow|slush|small|smart|smile|smoke|smooth|snack|snake|snap|sniff|snow|soap|soccer|social|sock|soda|soft|solar|soldier|solid|solution|solve|someone|song|soon|sorry|sort|soul|sound|soup|source|south|space|spare|spatial|spawn|speak|special|speed|spell|spend|sphere|spice|spider|spike|spin|spirit|split|spoil|sponsor|spoon|sport|spot|spray|spread|spring|spy|square|squeeze|squirrel|stable|stadium|staff|stage|stairs|stamp|stand|start|state|stay|steak|steel|stem|step|stereo|stick|still|sting|stock|stomach|stone|stool|story|stove|strategy|street|strike|strong|struggle|student|stuff|stumble|style|subject|submit|subway|success|such|sudden|suffer|sugar|suggest|suit|summer|sun|sunny|sunset|super|supply|supreme|sure|surface|surge|surprise|surround|survey|suspect|sustain|swallow|swamp|swap|swarm|swear|sweet|swift|swim|swing|switch|sword|symbol|symptom|syrup|system|table|tackle|tag|tail|talent|talk|tank|tape|target|task|taste|tattoo|taxi|teach|team|tell|ten|tenant|tennis|tent|term|test|text|thank|that|theme|then|theory|there|they|thing|this|thought|three|thrive|throw|thumb|thunder|ticket|tide|tiger|tilt|timber|time|tiny|tip|tired|tissue|title|toast|tobacco|today|toddler|toe|together|toilet|token|tomato|tomorrow|tone|tongue|tonight|tool|tooth|top|topic|topple|torch|tornado|tortoise|toss|total|tourist|toward|tower|town|toy|track|trade|traffic|tragic|train|transfer|trap|trash|travel|tray|treat|tree|trend|trial|tribe|trick|trigger|trim|trip|trophy|trouble|truck|true|truly|trumpet|trust|truth|try|tube|tuition|tumble|tuna|tunnel|turkey|turn|turtle|twelve|twenty|twice|twin|twist|two|type|typical|ugly|umbrella|unable|unaware|uncle|uncover|under|undo|unfair|unfold|unhappy|uniform|unique|unit|universe|unknown|unlock|until|unusual|unveil|update|upgrade|uphold|upon|upper|upset|urban|urge|usage|use|used|useful|useless|usual|utility|vacant|vacuum|vague|valid|valley|valve|van|vanish|vapor|various|vast|vault|vehicle|velvet|vendor|venture|venue|verb|verify|version|very|vessel|veteran|viable|vibrant|vicious|victory|video|view|village|vintage|violin|virtual|virus|visa|visit|visual|vital|vivid|vocal|voice|void|volcano|volume|vote|voyage|wage|wagon|wait|walk|wall|walnut|want|warfare|warm|warrior|wash|wasp|waste|water|wave|way|wealth|weapon|wear|weasel|weather|web|wedding|weekend|weird|welcome|west|wet|whale|what|wheat|wheel|when|where|whip|whisper|wide|width|wife|wild|will|win|window|wine|wing|wink|winner|winter|wire|wisdom|wise|wish|witness|wolf|woman|wonder|wood|wool|word|work|world|worry|worth|wrap|wreck|wrestle|wrist|write|wrong|yard|year|yellow|you|young|youth|zebra|zero|zone|zoo".split("|");var RQ="Invalid mnemonic",pJ="Invalid entropy",FJ="Invalid mnemonic checksum";function Em(l){return(l||"").normalize("NFKD")}function yJ(l){return parseInt(l,2)}function QJ(l){return l.map(A=>A.toString(2).padStart(8,"0")).join("")}function NJ(l){return QJ(Array.from(Nm(l))).slice(0,l.length*8/32)}function vm(l,A){return Aa(uG(Em(l)),uG(`mnemonic${Em(A)}`)).password}function Hm(l,A=IQ){let G=Em(l).split(" ");if(G.length%3!==0)throw new Error(RQ);let b=G.map(a=>{let n=A.indexOf(a);if(n===-1)throw new Error(RQ);return n.toString(2).padStart(11,"0")}).join(""),t=Math.floor(b.length/33)*32,c=b.slice(0,t),B=b.slice(t),d=c.match(/(.{1,8})/g)?.map(yJ);if(!d||d.length%4!==0||d.length<16||d.length>32)throw new Error(pJ);let Z=Tl(d);if(NJ(Z)!==B)throw new Error(FJ);return Z}function XQ(l,A){try{Hm(l,A)}catch{return!1}return!0}function pQ(l,A,G){return!PA||!A&&!G&&TA()?TV(l):Hm(l,A)}function go(l,A,G){return!PA||!A&&!G&&TA()?OV(l):XQ(l,A)}function Jm(l,A="",G,b=32){if(go(l)){if(![32,64].includes(b))throw new Error(`Invalid seed length ${b}, expected 32 or 64`)}else throw new Error("Invalid bip39 mnemonic specified");return b===32?!PA||!G&&TA()?LV(l,A):vm(l,A).subarray(0,32):vm(l,A)}function fm(l,A="",G,b){if(go(l,G,b)){if(!G&&!b&&TA())return DV(l,A)}else throw new Error("Invalid bip39 mnemonic specified");let t=pQ(l,G),c=uG(`mnemonic${A}`);return Aa(t,c).password.slice(0,32)}function Wo(l,A){return l<<A|l>>>32-A}function ad(l,A){let G=l[A+3]&255;return G=G<<8|l[A+2]&255,G=G<<8|l[A+1]&255,G<<8|l[A+0]&255}function xm(l,A,G){for(let b=0;b<4;b++)l[A+b]=G&255,G>>>=8}function EJ(l,A,G,b,t){let c=0;for(let B=0;B<t;B++)c|=l[A+B]^G[b+B];return(1&c-1>>>8)-1}function wm(l,A,G,b,t){let c=new Uint32Array(16),B=new Uint32Array(16),e=new Uint32Array(16),d=new Uint32Array(4),Z,a,n;for(Z=0;Z<4;Z++)B[5*Z]=ad(b,4*Z),B[1+Z]=ad(G,4*Z),B[6+Z]=ad(A,4*Z),B[11+Z]=ad(G,16+4*Z);for(Z=0;Z<16;Z++)e[Z]=B[Z];for(Z=0;Z<20;Z++){for(a=0;a<4;a++){for(n=0;n<4;n++)d[n]=B[(5*a+4*n)%16];for(d[1]^=Wo(d[0]+d[3]|0,7),d[2]^=Wo(d[1]+d[0]|0,9),d[3]^=Wo(d[2]+d[1]|0,13),d[0]^=Wo(d[3]+d[2]|0,18),n=0;n<4;n++)c[4*a+(a+n)%4]=d[n]}for(n=0;n<16;n++)B[n]=c[n]}if(t){for(Z=0;Z<16;Z++)B[Z]=B[Z]+e[Z]|0;for(Z=0;Z<4;Z++)B[5*Z]=B[5*Z]-ad(b,4*Z)|0,B[6+Z]=B[6+Z]-ad(A,4*Z)|0;for(Z=0;Z<4;Z++)xm(l,4*Z,B[5*Z]),xm(l,16+4*Z,B[6+Z])}else for(Z=0;Z<16;Z++)xm(l,4*Z,B[Z]+e[Z]|0)}var Um=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function vJ(l,A,G,b,t,c,B){let e=new Uint8Array(16),d=new Uint8Array(64),Z,a;if(!t)return 0;for(a=0;a<16;a++)e[a]=0;for(a=0;a<8;a++)e[a]=c[a];for(;t>=64;){for(wm(d,e,B,Um,!1),a=0;a<64;a++)l[A+a]=(G?G[b+a]:0)^d[a];for(Z=1,a=8;a<16;a++)Z=Z+(e[a]&255)|0,e[a]=Z&255,Z>>>=8;t-=64,A+=64,G&&(b+=64)}if(t>0)for(wm(d,e,B,Um,!1),a=0;a<t;a++)l[A+a]=(G?G[b+a]:0)^d[a];return 0}function Cm(l,A,G,b,t,c,B){let e=new Uint8Array(32);return wm(e,c,B,Um,!0),vJ(l,A,G,b,t,c.subarray(16),e)}function km(l,A){let G=0;for(let b=0;b<17;b++)G=G+(l[b]+A[b]|0)|0,l[b]=G&255,G>>>=8}var HJ=new Uint32Array([5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252]);function FQ(l,A,G,b,t,c){let B,e,d,Z=new Uint32Array(17),a=new Uint32Array(17),n=new Uint32Array(17),h=new Uint32Array(17),W=new Uint32Array(17);for(e=0;e<17;e++)a[e]=n[e]=0;for(e=0;e<16;e++)a[e]=c[e];for(a[3]&=15,a[4]&=252,a[7]&=15,a[8]&=252,a[11]&=15,a[12]&=252,a[15]&=15;t>0;){for(e=0;e<17;e++)h[e]=0;for(e=0;e<16&&e<t;++e)h[e]=G[b+e];for(h[e]=1,b+=e,t-=e,km(n,h),B=0;B<17;B++)for(Z[B]=0,e=0;e<17;e++)Z[B]=Z[B]+n[e]*(e<=B?a[B-e]:320*a[B+17-e]|0)|0|0;for(B=0;B<17;B++)n[B]=Z[B];for(d=0,e=0;e<16;e++)d=d+n[e]|0,n[e]=d&255,d>>>=8;for(d=d+n[16]|0,n[16]=d&3,d=5*(d>>>2)|0,e=0;e<16;e++)d=d+n[e]|0,n[e]=d&255,d>>>=8;d=d+n[16]|0,n[16]=d}for(e=0;e<17;e++)W[e]=n[e];km(n,HJ);let i=-(n[16]>>>7)|0;for(e=0;e<17;e++)n[e]^=i&(W[e]^n[e]);for(e=0;e<16;e++)h[e]=c[e+16];for(h[16]=0,km(n,h),e=0;e<16;e++)l[A+e]=n[e];return 0}function JJ(l,A,G,b,t,c){let B=new Uint8Array(16);return FQ(B,0,G,b,t,c),EJ(l,A,B,0,16)}function fJ(l,A,G,b,t){if(G<32)return-1;Cm(l,0,A,0,G,b,t),FQ(l,16,l,32,G-32,l);for(let c=0;c<16;c++)l[c]=0;return 0}function xJ(l,A,G,b,t){let c=new Uint8Array(32);if(G<32||(Cm(c,0,null,0,32,b,t),JJ(A,16,A,32,G-32,c)!==0))return-1;Cm(l,0,A,0,G,b,t);for(let B=0;B<32;B++)l[B]=0;return 0}var kJ=32,wJ=24,Sm=32,zm=16;function yQ(l,A){if(l.length!==kJ)throw new Error("bad key size");if(A.length!==wJ)throw new Error("bad nonce size")}function QQ(...l){for(let A=0,G=l.length;A<G;A++)if(!(l[A]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function NQ(l,A,G){QQ(l,A,G),yQ(G,A);let b=new Uint8Array(Sm+l.length),t=new Uint8Array(b.length);for(let c=0;c<l.length;c++)b[c+Sm]=l[c];return fJ(t,b,b.length,A,G),t.subarray(zm)}function EQ(l,A,G){QQ(l,A,G),yQ(G,A);let b=new Uint8Array(zm+l.length),t=new Uint8Array(b.length);for(let c=0;c<l.length;c++)b[c+zm]=l[c];return b.length<32||xJ(t,b,b.length,A,G)!==0?null:t.subarray(Sm)}function jm(l,A,G){return EQ(l,A,G)}function Mm(l,A,G=Bd(24)){return{encrypted:NQ(l,G,A),nonce:G}}function vQ(l,A,G,b,t,c){let B=l[A++]^G[b++],e=l[A++]^G[b++],d=l[A++]^G[b++],Z=l[A++]^G[b++],a=l[A++]^G[b++],n=l[A++]^G[b++],h=l[A++]^G[b++],W=l[A++]^G[b++],i=l[A++]^G[b++],Y=l[A++]^G[b++],R=l[A++]^G[b++],V=l[A++]^G[b++],m=l[A++]^G[b++],I=l[A++]^G[b++],y=l[A++]^G[b++],x=l[A++]^G[b++],w=B,H=e,j=d,C=Z,D=a,$=n,K=h,Q=W,r=i,F=Y,E=R,f=V,s=m,p=I,X=y,o=x;for(let g=0;g<8;g+=2)D^=qA(w+s|0,7),r^=qA(D+w|0,9),s^=qA(r+D|0,13),w^=qA(s+r|0,18),F^=qA($+H|0,7),p^=qA(F+$|0,9),H^=qA(p+F|0,13),$^=qA(H+p|0,18),X^=qA(E+K|0,7),j^=qA(X+E|0,9),K^=qA(j+X|0,13),E^=qA(K+j|0,18),C^=qA(o+f|0,7),Q^=qA(C+o|0,9),f^=qA(Q+C|0,13),o^=qA(f+Q|0,18),H^=qA(w+C|0,7),j^=qA(H+w|0,9),C^=qA(j+H|0,13),w^=qA(C+j|0,18),K^=qA($+D|0,7),Q^=qA(K+$|0,9),D^=qA(Q+K|0,13),$^=qA(D+Q|0,18),f^=qA(E+F|0,7),r^=qA(f+E|0,9),F^=qA(r+f|0,13),E^=qA(F+r|0,18),s^=qA(o+X|0,7),p^=qA(s+o|0,9),X^=qA(p+s|0,13),o^=qA(X+p|0,18);t[c++]=B+w|0,t[c++]=e+H|0,t[c++]=d+j|0,t[c++]=Z+C|0,t[c++]=a+D|0,t[c++]=n+$|0,t[c++]=h+K|0,t[c++]=W+Q|0,t[c++]=i+r|0,t[c++]=Y+F|0,t[c++]=R+E|0,t[c++]=V+f|0,t[c++]=m+s|0,t[c++]=I+p|0,t[c++]=y+X|0,t[c++]=x+o|0}function Tm(l,A,G,b,t){let c=b+0,B=b+16*t;for(let e=0;e<16;e++)G[B+e]=l[A+(2*t-1)*16+e];for(let e=0;e<t;e++,c+=16,A+=16)vQ(G,B,l,A,G,c),e>0&&(B+=16),vQ(G,c,l,A+=16,G,B)}function UJ(l,A,G){let b=Va({dkLen:32,asyncTick:10,maxmem:1073742848},G),{N:t,r:c,p:B,dkLen:e,asyncTick:d,maxmem:Z,onProgress:a}=b;if(mG(t),mG(c),mG(B),mG(e),mG(d),mG(Z),a!==void 0&&typeof a!="function")throw new Error("progressCb should be function");let n=128*c,h=n/4,W=Math.pow(2,32);if(t<=1||t&t-1||t>W)throw new Error("Scrypt: N must be larger than 1, a power of 2, and less than 2^32");if(B<0||B>(W-1)*32/n)throw new Error("Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)");if(e<0||e>(W-1)*32)throw new Error("Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32");if(n*(t+B)>Z)throw new Error("Scrypt: memused is bigger than maxMem. Expected 128 * r * (N + p) > maxmem of "+Z);let Y=la(ye,l,A,{c:1,dkLen:n*B}),R=ct(Y),V=ct(new Uint8Array(n*t)),m=ct(new Uint8Array(n)),I=()=>{};if(a){let y=2*t*B,x=Math.max(Math.floor(y/1e4),1),w=0;I=()=>{w++,a&&(!(w%x)||w===y)&&a(w/y)}}return{N:t,r:c,p:B,dkLen:e,blockSize32:h,V,B32:R,B:Y,tmp:m,blockMixCb:I,asyncTick:d}}function CJ(l,A,G,b,t){let c=la(ye,l,G,{c:1,dkLen:A});return TG(G,b,t),c}function HQ(l,A,G){let{N:b,r:t,p:c,dkLen:B,blockSize32:e,V:d,B32:Z,B:a,tmp:n,blockMixCb:h}=UJ(l,A,G);Bt(Z);for(let W=0;W<c;W++){let i=e*W;for(let Y=0;Y<e;Y++)d[Y]=Z[i+Y];for(let Y=0,R=0;Y<b-1;Y++)Tm(d,R,d,R+=e,t),h();Tm(d,(b-1)*e,Z,i,t),h();for(let Y=0;Y<b;Y++){let R=Z[i+e-16]%b;for(let V=0;V<e;V++)n[V]=Z[i+V]^d[R*e+V];Tm(n,0,Z,i,t),h()}}return Bt(Z),CJ(l,B,a,d,n)}var JQ=[{N:8192,p:10,r:8},{N:16384,p:5,r:8},{N:32768,p:3,r:8},{N:32768,p:1,r:8},{N:65536,p:2,r:8},{N:131072,p:1,r:8}],fQ={N:1<<17,p:1,r:8};function Ga(l,A=Bd(),G=fQ,b){let t=Tl(l);return{params:G,password:!PA||!b&&TA()?du(t,A,Math.log2(G.N),G.r,G.p):HQ(t,A,te({dkLen:64},G)),salt:A}}function Dm(l){if(!(l instanceof Uint8Array))throw new Error("Expected input to be a Uint8Array");if(l.length<44)throw new Error(`Invalid input length: expected 44 bytes, found ${l.length}`);let A=l.subarray(0,32),G=Hd(l.subarray(32,36),jW).toNumber(),b=Hd(l.subarray(36,40),jW).toNumber(),t=Hd(l.subarray(40,44),jW).toNumber();if(G>1<<20||b>4||t>16)throw new Error("Scrypt parameters exceed safe limits");if(!JQ.some(B=>B.N===G&&B.p===b&&B.r===t))throw new Error("Invalid injected scrypt params found");return{params:{N:G,p:b,r:t},salt:A}}function Lm(l,{N:A,p:G,r:b}){return nG(l,wG(A,MW),wG(G,MW),wG(b,MW))}var oo=["scrypt","xsalsa20-poly1305"],xQ=["none"],kQ="3";function Om(l,A,G=oo){if(l){if(G.includes("xsalsa20-poly1305")&&!A)throw new Error("Password required to decode encrypted data")}else throw new Error("No encrypted data available to decode");let b=l;if(A){let t;if(G.includes("scrypt")){let{params:c,salt:B}=Dm(l);t=Ga(A,B,c).password,l=l.subarray(44)}else t=uG(A);b=jm(l.subarray(24),l.subarray(0,24),Ko(t,256,!0))}if(!b)throw new Error("Unable to decode using the supplied passphrase");return b}function Pm(l,A,G){return{encoded:Xm(l),encoding:{content:A,type:G?oo:xQ,version:kQ}}}var UQ=l=>(A,G,b)=>rQ(A,G,b,l,!0),Km=[["ecdsa",UQ("blake2")],["ethereum",UQ("keccak")]],CQ=[["ed25519",zy],["sr25519",aQ]];function ho(l,{message:A,publicKey:G,signature:b},t=[...CQ,...Km]){return l.isValid=t.some(([c,B])=>{try{if(B(A,b,G))return l.crypto=c,!0}catch{}return!1}),l}function zJ(l,{message:A,publicKey:G,signature:b}){if(![0,1,2].includes(b[0])||![65,66].includes(b.length))throw new Error(`Unknown crypto type, expected signature prefix [0..2], found ${b[0]}`);return b.length===66?l=ho(l,{message:A,publicKey:G,signature:b.subarray(1)},Km):(l=ho(l,{message:A,publicKey:G,signature:b.subarray(1)},CQ),l.isValid||(l=ho(l,{message:A,publicKey:G,signature:b},Km)),l.isValid||(l.crypto="none")),l}function jJ(l){return[0,1,2].includes(l[0])&&[65,66].includes(l.length)?zJ:ho}function so(l,A,G){let b=Tl(A);if(![64,65,66].includes(b.length))throw new Error(`Invalid signature length, expected [64..66] bytes, found ${b.length}`);let t=Pt(G),c={message:Tl(l),publicKey:t,signature:b},B={crypto:"none",isValid:!1,isWrapped:cZ(c.message,!0),publicKey:t},e=cZ(c.message,!1),d=jJ(b);return d(B,c),B.crypto!=="none"||B.isWrapped&&!e?B:(c.message=e?_o(c.message):$o(c.message),d(B,c))}var jB=new Uint8Array([161,35,3,33,0]),gd=new Uint8Array([48,83,2,1,1,48,5,6,3,43,101,112,4,34,4,32]),SQ=32;var qm=64,zQ=32;var ba=gd.length;function jQ(l,A,G){let b=Array.isArray(G)||G===void 0?G:[G],t=Om(A,l,b),c=t.subarray(0,gd.length);if(!Mb(c,gd))throw new Error("Invalid encoding header found in body");let B=t.subarray(ba,ba+qm),e=ba+qm,d=t.subarray(e,e+jB.length);if(!Mb(d,jB)&&(e=ba+zQ,B=t.subarray(ba,e),d=t.subarray(e,e+jB.length),!Mb(d,jB)))throw new Error("Invalid encoding divider found in body");let Z=e+jB.length;return{publicKey:t.subarray(Z,Z+SQ),secretKey:B}}function MQ({publicKey:l,secretKey:A},G){if(!A)throw new Error("Expected a valid secretKey to be passed to encode");let b=nG(gd,A,jB,l);if(!G)return b;let{params:t,password:c,salt:B}=Ga(G),{encrypted:e,nonce:d}=Mm(b,c.subarray(0,32));return nG(Lm(B,t),d,e)}function TQ(l,{address:A,meta:G},b,t){return te(Pm(b,["pkcs8",l],t),{address:A,meta:G})}var MJ=new Uint8Array,TJ={ecdsa:qt,ed25519:fe,ethereum:qt,sr25519:Pn},DQ={ecdsa:new Uint8Array([2]),ed25519:new Uint8Array([0]),ethereum:new Uint8Array([2]),sr25519:new Uint8Array([1])},LQ={ecdsa:(l,A)=>Zo(l,A,"blake2"),ed25519:nm,ethereum:(l,A)=>Zo(l,A,"keccak"),sr25519:Vm},ro={ecdsa:l=>l.length>32?Tb(l):l,ed25519:l=>l,ethereum:l=>l.length===20?l:zB(we(l)),sr25519:l=>l};function ta(l){return!l||vd(l)}function OQ(l,A,G){return Tb(nG(A||"",G||"",l))}function Ue({toSS58:l,type:A},{publicKey:G,secretKey:b},t={},c=null,B){let e=(a,n)=>{let h=jQ(a,n||c,B);if(h.secretKey.length===64)G=h.publicKey,b=h.secretKey;else{let W=TJ[A](h.secretKey);G=W.publicKey,b=W.secretKey}},d=a=>(ta(b)&&c&&e(a,c),c=MQ({publicKey:G,secretKey:b},a),B=void 0,c),Z=()=>{let a=ro[A](G);return A==="ethereum"?$n(a):l(a)};return{get address(){return Z()},get addressRaw(){let a=ro[A](G);return A==="ethereum"?a.slice(-20):a},get isLocked(){return ta(b)},get meta(){return t},get publicKey(){return G},get type(){return A},decodePkcs8:e,derive:(a,n)=>{if(A==="ethereum")throw new Error("Unable to derive on this keypair");if(ta(b))throw new Error("Cannot derive on a locked keypair");let{path:h}=wn(a),W=On({publicKey:G,secretKey:b},h,A);return Ue({toSS58:l,type:A},W,n,null)},encodePkcs8:a=>d(a),lock:()=>{b=new Uint8Array},setMeta:a=>{t=te({},t,a)},sign:(a,n={})=>{if(ta(b))throw new Error("Cannot sign with a locked key pair");return nG(n.withType?DQ[A]:MJ,LQ[A](Tl(a),{publicKey:G,secretKey:b}))},toJson:a=>{let n=["ecdsa","ethereum"].includes(A)?G.length===20?nt(G):nt(_n(G)):Z();return TQ(A,{address:n,meta:t},d(a),!!a)},unlock:a=>e(a),verify:(a,n,h)=>so(a,n,ro[A](Tl(h))).isValid,vrfSign:(a,n,h)=>{if(ta(b))throw new Error("Cannot sign with a locked key pair");if(A==="sr25519")return um(a,{secretKey:b},n,h);let W=LQ[A](Tl(a),{publicKey:G,secretKey:b});return nG(OQ(W,n,h),W)},vrfVerify:(a,n,h,W,i)=>A==="sr25519"?Ym(a,n,G,W,i):so(a,nG(DQ[A],n.subarray(32)),ro[A](Tl(h))).isValid&&Mb(n.subarray(0,32),OQ(n.subarray(32),W,i))}}var PQ="bottom drive obey lake curtain smoke basket hold race lonely fit walk";var Ce,io=class{constructor(){EG(this,Ce,{})}add(A){return GA(this,Ce)[Pt(A.address).toString()]=A,A}all(){return Object.values(GA(this,Ce))}get(A){let G=GA(this,Ce)[Pt(A).toString()];if(!G)throw new Error(`Unable to retrieve keypair '${Jb(A)||ub(A)?nt(Tl(A)):A}'`);return G}remove(A){delete GA(this,Ce)[Pt(A).toString()]}};Ce=new WeakMap;var _m={ecdsa:l=>qt(l),ed25519:l=>fe(l),ethereum:l=>qt(l),sr25519:l=>Pn(l)};function DJ({publicKey:l}){return l}var yc,Ba,Wd,ca=class{constructor(A={}){EG(this,yc);EG(this,Ba);EG(this,Wd);el(this,"decodeAddress",Pt);el(this,"encodeAddress",(A,G)=>this.type==="ethereum"?$n(A):Kn(A,G??GA(this,Wd)));if(A.type=A.type||"ed25519",!["ecdsa","ethereum","ed25519","sr25519"].includes(A.type||"undefined"))throw new Error(`Expected a keyring type of either 'ed25519', 'sr25519', 'ethereum' or 'ecdsa', found '${A.type||"unknown"}`);bG(this,yc,new io),bG(this,Wd,A.ss58Format),bG(this,Ba,A.type)}get pairs(){return this.getPairs()}get publicKeys(){return this.getPublicKeys()}get type(){return GA(this,Ba)}addPair(A){return GA(this,yc).add(A)}addFromAddress(A,G={},b=null,t=this.type,c,B){let e=this.decodeAddress(A,c);return this.addPair(Ue({toSS58:this.encodeAddress,type:t},{publicKey:e,secretKey:new Uint8Array},G,b,B))}addFromJson(A,G){return this.addPair(this.createFromJson(A,G))}addFromMnemonic(A,G={},b=this.type,t){return this.addFromUri(A,G,b,t)}addFromPair(A,G={},b=this.type){return this.addPair(this.createFromPair(A,G,b))}addFromSeed(A,G={},b=this.type){return this.addPair(Ue({toSS58:this.encodeAddress,type:b},_m[b](A),G,null))}addFromUri(A,G={},b=this.type,t){return this.addPair(this.createFromUri(A,G,b,t))}createFromJson({address:A,encoded:G,encoding:{content:b,type:t,version:c},meta:B},e){if(c==="3"&&b[0]!=="pkcs8")throw new Error(`Unable to decode non-pkcs8 type, [${b.join(",")}] found}`);let d=c==="0"||!Array.isArray(b)?this.type:b[1],Z=Array.isArray(t)?t:[t];if(!["ed25519","sr25519","ecdsa","ethereum"].includes(d))throw new Error(`Unknown crypto type ${d}`);let a=ub(A)?Hb(A):this.decodeAddress(A,e),n=ub(G)?Hb(G):Rm(G);return Ue({toSS58:this.encodeAddress,type:d},{publicKey:a,secretKey:new Uint8Array},B,n,Z)}createFromPair(A,G={},b=this.type){return Ue({toSS58:this.encodeAddress,type:b},A,G,null)}createFromUri(A,G={},b=this.type,t){let c=A.startsWith("//")?`${PQ}${A}`:A,{derivePath:B,password:e,path:d,phrase:Z}=ki(c),a,n=ub(Z,256);if(n)a=Hb(Z);else{let W=Z.split(" ");if([12,15,18,21,24].includes(W.length))a=b==="ethereum"?Jm(Z,"",!1,64):fm(Z,e,t);else{if(Z.length>32)throw new Error("specified phrase is not a valid mnemonic and is invalid as a raw seed at > 32 bytes");a=uG(Z.padEnd(32))}}let h=b==="ethereum"?n?_m[b](a):Qm(a,B.substring(1)):On(_m[b](a),d,b);return Ue({toSS58:this.encodeAddress,type:b},h,G,null)}getPair(A){return GA(this,yc).get(A)}getPairs(){return GA(this,yc).all()}getPublicKeys(){return GA(this,yc).all().map(DJ)}removePair(A){GA(this,yc).remove(A)}setSS58Format(A){bG(this,Wd,A)}toJson(A,G){return GA(this,yc).get(A).toJson(G)}};yc=new WeakMap,Ba=new WeakMap,Wd=new WeakMap;var od=class{constructor(A){el(this,"token");if(this.token=A,!A)throw new Error("DelegationAuthProvider requires a non-empty delegation token")}async authenticate(A){let G={Authorization:`Bearer ${this.token}`};return A.body===void 0?{headers:G}:(G["Content-Type"]="application/json",{headers:G,body:new TextEncoder().encode(JSON.stringify(A.body))})}};var KJ="cef-widget:identity-request",qJ="cef-widget:identity-response",_J="cef-widget:sign-request",$J="cef-widget:sign-response";var $Q="unsupported-version";var hd=class extends Error{constructor(A){super(`WidgetProtocolVersionError: ${A}`),this.name="WidgetProtocolVersionError"}},mo=class extends Error{constructor(A){super(`WidgetMalformedMessageError: ${A}`),this.name="WidgetMalformedMessageError"}};function lN(l){return l!==void 0&&l!==1}function lf(l){if(!Array.isArray(l)||l.length>65536)return!1;for(let A=0;A<l.length;A++){if(!(A in l))return!1;let G=l[A];if(typeof G!="number"||!Number.isInteger(G)||G<0||G>255)return!1}return!0}var _Q=!1,sd=new Map;function AN(){_Q||(_Q=!0,window.addEventListener("message",l=>{if(l.source!==window.parent)return;let A=l.data;if(!A||typeof A!="object")return;let{type:G,requestId:b}=A;if(typeof b!="string"||G!==qJ&&G!==$J)return;let t=sd.get(b);t&&(sd.delete(b),t.resolve(A))}))}function GN(){return`${Date.now()}-${Math.random().toString(36).slice(2)}`}var $m;async function Af(){if(window.parent===window)return null;if($m!==void 0)return $m;AN();let l=400,A=8e3,G=Date.now()+A;return new Promise((b,t)=>{let c=!1,B,e,d=new Set;function Z(){c=!0,B!==void 0&&(clearTimeout(B),B=void 0),e!==void 0&&(clearTimeout(e),e=void 0);for(let h of d)sd.delete(h);d.clear()}function a(){if(c)return;let h=GN();d.add(h),sd.set(h,{resolve:W=>{if(c)return;let i=W;if(lN(i.v)){Z(),t(new hd(`the host replied in protocol v${String(i.v)}; this build speaks v1`));return}if(i.errorCode===$Q){Z(),t(new hd(`the host rejected protocol v1 (${i.error??"no detail"})`));return}if(i.error||!i.pubkey){n();return}let Y={pubkey:i.pubkey,sigType:i.sigType??"ed25519",...i.token?{token:i.token}:{},...i.context?{context:i.context}:{}};Z(),$m=Y,b(Y)},reject:()=>{c||n()}}),window.parent.postMessage({type:KJ,requestId:h,v:1},"*"),n()}function n(){if(c)return;B!==void 0&&(clearTimeout(B),B=void 0);let h=G-Date.now();if(h<=0){Z(),b(null);return}B=setTimeout(()=>{c||a()},Math.min(l,h))}a(),e=setTimeout(()=>{c||(Z(),b(null))},A+l)})}async function Gf(l){if(window.parent===window)throw new Error("sign called outside of an iframe");if(l.length>65536)throw new mo(`sign-request.bytes is ${l.length} bytes; the contract caps it at 65536`);AN();let A=6e4,G=GN();return new Promise((b,t)=>{let c=setTimeout(()=>{sd.delete(G),t(new Error("widget signing timed out \u2014 the host page may have closed the widget"))},A);sd.set(G,{resolve:B=>{clearTimeout(c);let e=B;lN(e.v)?t(new hd(`the host replied in protocol v${String(e.v)}; this build speaks v1`)):e.errorCode===$Q?t(new hd(`the host rejected protocol v1 (${e.error??"no detail"})`)):e.error?t(new Error(e.error)):e.signature===null?t(new Error("widget signing was declined")):lf(e.signature)?b(Uint8Array.from(e.signature)):t(new mo("sign-response.signature must be null or an array of integers 0-255"))},reject:B=>{clearTimeout(c),t(B)}}),window.parent.postMessage({type:_J,requestId:G,v:1,bytes:Array.from(l)},"*")})}function bN(){return{requestIdentity:Af,sign:Gf}}var bf=54;function l2(l,A,G){return{type:A,address:Kn(Hb(l),bf),publicKey:Hb(l),isReady:async()=>!0,sign:b=>G(b)}}var ZN=po(BN(),1);var eN=["private_key","ed25519_private_key","eth_private_key"];function tf(l){let A=l.trim().replace(/^0x/i,"");return/^[0-9a-fA-F]{64,}$/.test(A)?"0x"+A.slice(0,64).toLowerCase():null}async function cf(l){for(let A of eN)try{let G=await l.request({method:A});if(typeof G!="string")continue;let b=tf(G);if(b)return b}catch{}throw new Error("standalone wallet: could not extract embed-wallet seed. Tried: "+eN.join(", "))}function Bf(l){return l.startsWith("0x")?l:`0x${l}`}async function dN(l){await PF();let A=new ZN.EmbedWallet({appId:l.appId,env:l.env});await A.init({appId:l.appId,env:l.env,popupMode:"modal"}),await A.connect();let b=await A.getSigner({type:"ed25519"}).getAccount(),t=Bf(b.publicKey).toLowerCase(),c=await cf(A.provider),e=new ca({type:"ed25519"}).addFromSeed(Hb(c)),d=nt(e.publicKey);if(d!==t)throw new Error(`[widget-runtime] standalone wallet: derived pubkey (${d}) does not match the wallet's pubkey (${t}) \u2014 refusing to sign.`);return{pubkey:()=>t,sigType:"ed25519",signRawBytes:async Z=>e.sign(Z)}}var iG=class extends Error{constructor(l,A,G,b){super(A?`${l}: ${A}`:l),this.code=l,this.detail=A,this.traceId=G,this.status=b,this.name="WalletError"}toJSON(){return{name:this.name,code:this.code,detail:this.detail,traceId:this.traceId,message:this.message}}};function ef(l){if(l.length>=255)throw new TypeError("Alphabet too long");let A=new Uint8Array(256);for(let Z=0;Z<A.length;Z++)A[Z]=255;for(let Z=0;Z<l.length;Z++){let a=l.charAt(Z),n=a.charCodeAt(0);if(A[n]!==255)throw new TypeError(a+" is ambiguous");A[n]=Z}let G=l.length,b=l.charAt(0),t=Math.log(G)/Math.log(256),c=Math.log(256)/Math.log(G);function B(Z){if(Z instanceof Uint8Array||(ArrayBuffer.isView(Z)?Z=new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength):Array.isArray(Z)&&(Z=Uint8Array.from(Z))),!(Z instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(Z.length===0)return"";let a=0,n=0,h=0,W=Z.length;for(;h!==W&&Z[h]===0;)h++,a++;let i=(W-h)*c+1>>>0,Y=new Uint8Array(i);for(;h!==W;){let m=Z[h],I=0;for(let y=i-1;(m!==0||I<n)&&y!==-1;y--,I++)m+=256*Y[y]>>>0,Y[y]=m%G>>>0,m=m/G>>>0;if(m!==0)throw new Error("Non-zero carry");n=I,h++}let R=i-n;for(;R!==i&&Y[R]===0;)R++;let V=b.repeat(a);for(;R<i;++R)V+=l.charAt(Y[R]);return V}function e(Z){if(typeof Z!="string")throw new TypeError("Expected String");if(Z.length===0)return new Uint8Array;let a=0,n=0,h=0;for(;Z[a]===b;)n++,a++;let W=(Z.length-a)*t+1>>>0,i=new Uint8Array(W);for(;a<Z.length;){let m=Z.charCodeAt(a);if(m>255)return;let I=A[m];if(I===255)return;let y=0;for(let x=W-1;(I!==0||y<h)&&x!==-1;x--,y++)I+=G*i[x]>>>0,i[x]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");h=y,a++}let Y=W-h;for(;Y!==W&&i[Y]===0;)Y++;let R=new Uint8Array(n+(W-Y)),V=n;for(;Y!==W;)R[V++]=i[Y++];return R}function d(Z){let a=e(Z);if(a)return a;throw new Error("Non-base"+G+" character")}return{encode:B,decodeUnsafe:e,decode:d}}var nN=ef;var Zf="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",aN=nN(Zf);var Lal=new Uint8Array([241,55,252,128,200,121,231,173,149,167,104,105,124,215,6,125,113,218,113,114,238,51,232,185,156,209,26,46,78,6,58,137]);var Oal=new TextEncoder().encode("SS58PRE");function gN(l){let A=aN.decode(l);if(A.length!==32)throw new Error(`expected a 32-byte Ed25519 pubkey from the Solana address, got ${A.length}`);return A}var df="cere-wallet-root-wrap-v1",nf="v1",Pal={[nf]:df};var rd=(l,A,G)=>new Promise((b,t)=>{var c=d=>{try{e(G.next(d))}catch(Z){t(Z)}},B=d=>{try{e(G.throw(d))}catch(Z){t(Z)}},e=d=>d.done?b(d.value):Promise.resolve(d.value).then(c,B);e((G=G.apply(l,A)).next())}),hN=class{constructor(l){this.chain="evm",this.address=l.address,this.sign=l.sign}getAddress(){return rd(this,null,function*(){return this.address})}signMessage(l){return rd(this,null,function*(){let A=WN(l),G=yield this.sign("evm",A),b=G.slice(0,32),t=G.slice(32,64),c=G[64]+27;return"0x"+oN(b)+oN(t)+c.toString(16).padStart(2,"0")})}signMessageRaw(l){return rd(this,null,function*(){let A=WN(l);return this.sign("evm",A)})}};function WN(l){let A=typeof l=="string"?new TextEncoder().encode(l):l,G=new TextEncoder().encode(`Ethereum Signed Message:
306
306
  ${A.length}`);return bo(VG(G,A))}function oN(l){let A="";for(let G of l)A+=G.toString(16).padStart(2,"0");return A}var sN=class{constructor(l){this.chain="cere",this.nextId=1,this.address=l.address,this.sign=l.sign}signRaw(l){return rd(this,null,function*(){if(l.type!=="ed25519")throw new Error(`PolkadotSigner: unsupported sig type "${l.type}" (only ed25519)`);let A=typeof l.data=="string"?af(l.data):l.data,G=yield this.sign("cere",A);return{id:this.nextId++,signature:"0x"+gf(G)}})}signMessage(l){return rd(this,null,function*(){return this.sign("cere",l)})}};function af(l){let A=l.startsWith("0x")?l.slice(2):l;if(A.length%2!==0)throw new Error(`PolkadotSigner: odd-length hex "${l}"`);let G=new Uint8Array(A.length/2);for(let b=0;b<G.length;b++)G[b]=parseInt(A.slice(b*2,b*2+2),16);return G}function gf(l){let A="";for(let G of l)A+=G.toString(16).padStart(2,"0");return A}var rN=class{constructor(l){this.chain="solana",this.address=l.address,this.sign=l.sign}get publicKey(){return this.address}signMessage(l){return rd(this,null,function*(){let A=typeof l=="string"?new TextEncoder().encode(l):l;return this.sign("solana",A)})}};var Wf=Object.defineProperty,iN=Object.getOwnPropertySymbols,of=Object.prototype.hasOwnProperty,hf=Object.prototype.propertyIsEnumerable,mN=(l,A,G)=>A in l?Wf(l,A,{enumerable:!0,configurable:!0,writable:!0,value:G}):l[A]=G,TB=(l,A)=>{for(var G in A||(A={}))of.call(A,G)&&mN(l,G,A[G]);if(iN)for(var G of iN(A))hf.call(A,G)&&mN(l,G,A[G]);return l},fG=(l,A,G)=>new Promise((b,t)=>{var c=d=>{try{e(G.next(d))}catch(Z){t(Z)}},B=d=>{try{e(G.throw(d))}catch(Z){t(Z)}},e=d=>d.done?b(d.value):Promise.resolve(d.value).then(c,B);e((G=G.apply(l,A)).next())}),sf=6e4;function rf(l){let A=null,G=null,b=!1,t=()=>(G||(G=l().then(c=>(A={token:c.token,expMs:new Date(c.expiresAt).getTime()},c.token)).finally(()=>{G=null})),G);return{getToken(){return fG(this,null,function*(){if(b)throw new Error("delegation-closed");return A&&Date.now()<A.expMs-sf?A.token:t()})},refresh(){return fG(this,null,function*(){if(b)throw new Error("delegation-closed");return A=null,t()})},close(){b=!0,A=null}}}var VN="publickey-credentials-get";function uN(l){let A=l;for(let G of[A?.featurePolicy,A?.permissionsPolicy]){let b=G;if(typeof b?.allowsFeature=="function")return b}return null}function mf(l,A){try{return new URL(l).origin===new URL(A).origin}catch{return!1}}function Vf(l,A){var G;if(!A)return null;let b=l?.querySelectorAll;if(typeof b!="function")return null;let t;try{t=b.call(l,"iframe")}catch{return null}for(let c=0;c<t.length;c+=1){let B=t[c],e=B?.src||((G=B?.getAttribute)==null?void 0:G.call(B,"src"))||"";if(e&&mf(e,A))return B}return null}function uf(l,A){let G=uN(l);if(!G)return null;let b=uN(Vf(l,A));if(b)try{return b.allowsFeature(VN,A)===!0}catch{return null}try{return G.allowsFeature(VN)===!1?!1:null}catch{return null}}function Yf(l){if(typeof l!="object"||l===null)return!1;let{code:A,message:G}=l;return typeof A=="string"&&A.length>0&&typeof G=="string"}function YN(l,A){if(!l||!A)return!1;try{let G=new URL(l),b=new URL(A);return G.origin===b.origin}catch{return!1}}function IN(l,A){return!l||!A?!0:l===A}var If="width=420,height=640,resizable=yes,scrollbars=yes",Rf=400,MB=class{constructor(l){this.popup=null,this.pending=new Map,this.listener=null,this.popupReady=!1,this.outbox=[],this.closeWatch=null,this.opts=TB({openPopup:Xf,hostWindow:globalThis.window,defaultTimeoutMs:6e4,handshakeTimeoutMs:1e4,onDiag:()=>{}},l)}request(l,A){return fG(this,arguments,function*(G,b,t={}){var c,B,e;if(!this.popup||this.popup.closed){this.rejectClosedPending();let n=(B=(c=globalThis.location)==null?void 0:c.origin)!=null?B:"",h=`${this.opts.walletOrigin}/embed/wallet?origin=${encodeURIComponent(n)}`;if(this.popup=this.opts.openPopup(h,If),!this.popup)throw new iG("popup-blocked","popup window failed to open");this.popupReady=!1,this.outbox=[],this.ensureListening()}let d=this.popup,Z=G.id,a=(e=t.timeoutMs)!=null?e:this.opts.defaultTimeoutMs;return new Promise((n,h)=>{let W=setTimeout(()=>{this.pending.has(Z)&&(this.pending.delete(Z),this.outbox=this.outbox.filter(i=>i.id!==Z),h(new iG("internal",`request "${G.type}" (id=${Z}) timed out after ${a}ms`)))},a);this.pending.set(Z,{expectedTypes:b,resolve:i=>n(i),reject:h,timer:W,popup:d}),this.popupReady?this.popup.postMessage(G,this.opts.walletOrigin):(this.outbox.push(G),this.armHandshakeTimeout(Z,G,W)),this.watchForClose()})})}watchForClose(){this.closeWatch||(this.closeWatch=setInterval(()=>{this.rejectClosedPending(),this.pending.size===0&&this.clearCloseWatch()},Rf))}rejectClosedPending(){for(let[l,A]of[...this.pending])A.popup.closed&&(clearTimeout(A.timer),this.pending.delete(l),this.outbox=this.outbox.filter(G=>G.id!==l),A.reject(new iG("popup-closed","the wallet popup was closed before it answered; nothing was created or signed")))}clearCloseWatch(){this.closeWatch&&(clearInterval(this.closeWatch),this.closeWatch=null)}armHandshakeTimeout(l,A,G){let b=this.opts.handshakeTimeoutMs;b>0&&setTimeout(()=>{if(this.popupReady)return;let t=this.pending.get(l);t&&(this.pending.delete(l),this.outbox=this.outbox.filter(c=>c.id!==l),clearTimeout(G),this.opts.onDiag("surface-not-ready",Date.now(),{transport:"popup",request:A.type}),t.reject(new iG("internal",`wallet popup at ${this.opts.walletOrigin} never signalled ready within ${b}ms, so "${A.type}" (id=${l}) was never delivered. The popup may have been blocked, navigated away, or opened by a previous page that has since reloaded (its opener link no longer reaches this document).`)))},b)}close(){this.clearCloseWatch(),this.rejectAllPending("transport closed"),this.popup&&!this.popup.closed&&this.popup.close(),this.popup=null,this.popupReady=!1,this.outbox=[]}destroy(){this.close(),this.listener&&(this.opts.hostWindow.removeEventListener("message",this.listener),this.listener=null)}rejectAllPending(l){for(let[A,G]of this.pending)clearTimeout(G.timer),this.pending.delete(A),G.reject(new iG("internal",l))}ensureListening(){this.listener||(this.listener=l=>this.onMessage(l),this.opts.hostWindow.addEventListener("message",this.listener))}onMessage(l){var A,G;if(!YN(l.origin,this.opts.walletOrigin)){let c=l.data;if(c&&typeof c.id=="string"&&this.pending.has(c.id)){let B=this.pending.get(c.id);this.pending.delete(c.id),clearTimeout(B.timer),B.reject(new iG("origin-mismatch",`message from "${l.origin}" rejected (expected "${this.opts.walletOrigin}")`))}return}let b=l.data;if(!b||typeof b.type!="string"||typeof b.id!="string"||!IN(l.source,this.popup))return;if(b.type==="wallet:ready"){if(this.popupReady)return;this.popupReady=!0;let c=this.outbox;if(this.outbox=[],this.popup&&!this.popup.closed)for(let B of c)this.popup.postMessage(B,this.opts.walletOrigin);return}if(b.type==="wallet:diag"){(G=(A=this.opts).onDiag)==null||G.call(A,b.name,b.at,b.detail);return}let t=this.pending.get(b.id);if(t){if(clearTimeout(t.timer),this.pending.delete(b.id),this.pending.size===0&&this.clearCloseWatch(),b.type==="wallet:error"){t.reject(new iG(b.code,b.message,b.traceId));return}if(!t.expectedTypes.includes(b.type)){t.reject(new iG("internal",`received unexpected response type "${b.type}" for id "${b.id}"`));return}t.resolve(b)}}};function Xf(l,A){let G=globalThis.window;return G?.open(l,"_blank",A)}var pf=class{constructor(l){this.iframe=null,this.pending=new Map,this.listener=null,this.ready=!1,this.outbox=[],this.backdrop=null,this.hiddenCssText="",this.overlayVisible=!1,this.opts=TB({hostWindow:globalThis.window,document:globalThis.document,defaultTimeoutMs:6e4,handshakeTimeoutMs:1e4,mountIframe:l.mountIframe,onOverlay:l.onOverlay,onDiag:l.onDiag},l)}ensureIframe(){var l,A,G;if(this.iframe)return;let b=(A=(l=globalThis.location)==null?void 0:l.origin)!=null?A:"",t=`${this.opts.walletOrigin}/embed/wallet?origin=${encodeURIComponent(b)}`,c=`publickey-credentials-get ${this.opts.walletOrigin}`;if(this.opts.mountIframe)this.iframe=this.opts.mountIframe(t,c);else{let B=this.opts.document.createElement("iframe");B.src=t,B.setAttribute("allow",c),B.style.cssText="position:fixed;border:0;width:0;height:0;left:-9999px;",this.opts.document.body.appendChild(B),this.iframe=B}this.hiddenCssText=(G=this.iframe.style.cssText)!=null?G:"",this.ready=!1,this.outbox=[],this.overlayVisible=!1,this.ensureListening()}showOverlay(){var l,A;if(!this.overlayVisible){if(this.overlayVisible=!0,this.iframe){let G=this.opts.document.createElement("div");G.setAttribute("data-wallet-overlay-backdrop",""),G.style.cssText="position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:2147483646;",this.opts.document.body.appendChild(G),this.backdrop=G,this.iframe.style.cssText="position:fixed;border:0;z-index:2147483647;width:min(420px,100vw);height:min(640px,100vh);left:50%;top:50%;transform:translate(-50%,-50%);"}(A=(l=this.opts).onOverlay)==null||A.call(l,!0)}}hideOverlay(){var l,A,G;this.overlayVisible&&(this.overlayVisible=!1,(l=this.backdrop)==null||l.remove(),this.backdrop=null,this.iframe&&(this.iframe.style.cssText=this.hiddenCssText),(G=(A=this.opts).onOverlay)==null||G.call(A,!1))}ensureListening(){this.listener||(this.listener=l=>this.onMessage(l),this.opts.hostWindow.addEventListener("message",this.listener))}request(l,A){return fG(this,arguments,function*(G,b,t={}){var c;this.ensureIframe();let B=G.id,e=(c=t.timeoutMs)!=null?c:this.opts.defaultTimeoutMs;return new Promise((d,Z)=>{let a=setTimeout(()=>{this.pending.has(B)&&(this.pending.delete(B),this.outbox=this.outbox.filter(n=>n.id!==B),Z(new iG("internal",`request "${G.type}" (id=${B}) timed out after ${e}ms`)))},e);this.pending.set(B,{expectedTypes:b,resolve:n=>d(n),reject:Z,timer:a}),this.ready?this.postToIframe(G):(this.outbox.push(G),this.armHandshakeTimeout(B,G,a))})})}armHandshakeTimeout(l,A,G){let b=this.opts.handshakeTimeoutMs;b>0&&setTimeout(()=>{var t,c;if(this.ready)return;let B=this.pending.get(l);B&&(this.pending.delete(l),this.outbox=this.outbox.filter(e=>e.id!==l),clearTimeout(G),(c=(t=this.opts).onDiag)==null||c.call(t,"surface-not-ready",Date.now(),{transport:"iframe",request:A.type}),B.reject(new iG("internal",`wallet iframe at ${this.opts.walletOrigin} never signalled ready within ${b}ms, so "${A.type}" (id=${l}) was never delivered. Check that the wallet origin is reachable and that the host page's Permissions-Policy / CSP does not block the embedded document.`)))},b)}postToIframe(l){var A,G;(G=(A=this.iframe)==null?void 0:A.contentWindow)==null||G.postMessage(l,this.opts.walletOrigin)}close(){var l,A;this.rejectAllPending("transport closed"),(l=this.backdrop)==null||l.remove(),this.backdrop=null,this.overlayVisible=!1,(A=this.iframe)==null||A.remove(),this.iframe=null,this.ready=!1,this.outbox=[]}destroy(){this.close(),this.listener&&(this.opts.hostWindow.removeEventListener("message",this.listener),this.listener=null)}rejectAllPending(l){for(let[A,G]of this.pending)clearTimeout(G.timer),this.pending.delete(A),G.reject(new iG("internal",l))}onMessage(l){var A,G,b;let t=l.data;if(!YN(l.origin,this.opts.walletOrigin)){if(t&&typeof t.id=="string"&&this.pending.has(t.id)){let B=this.pending.get(t.id);this.pending.delete(t.id),clearTimeout(B.timer),B.reject(new iG("origin-mismatch",`message from "${l.origin}" rejected (expected "${this.opts.walletOrigin}")`))}return}if(!t||typeof t.type!="string"||typeof t.id!="string"||!IN(l.source,(A=this.iframe)==null?void 0:A.contentWindow))return;if(t.type==="wallet:ready"){if(this.ready)return;this.ready=!0;let B=this.outbox;this.outbox=[];for(let e of B)this.postToIframe(e);return}if(t.type==="wallet:ui:show"){this.showOverlay();return}if(t.type==="wallet:ui:hide"){this.hideOverlay();return}if(t.type==="wallet:diag"){(b=(G=this.opts).onDiag)==null||b.call(G,t.name,t.at,t.detail);return}let c=this.pending.get(t.id);if(c){if(clearTimeout(c.timer),this.pending.delete(t.id),t.type==="wallet:error"){c.reject(new iG(t.code,t.message,t.traceId));return}if(!c.expectedTypes.includes(t.type)){c.reject(new iG("internal",`received unexpected response type "${t.type}" for id "${t.id}"`));return}c.resolve(t)}}},Ff=15*6e4;function yf(l,A){let G=new Set([...Object.keys(l),...Object.keys(A)]);for(let b of G)if(l[b]!==A[b])return!1;return!0}var RN=class{constructor(l){this._addresses=null,this._credentialId=null,this._accountId=null,this._email=null,this._displayName=null,this._hasKeys=!1,this.policyRefused=!1,this._listeners={},this.registerInFlight=null,this.loginInFlight=null,this.relayDiag=(Z,a,n)=>{this.emit("diag",TB({type:"diag",name:Z,at:a},n?{detail:n}:{}))};var A,G,b,t,c,B,e;let d=(A=l.__internal__)==null?void 0:A.transport;if(!d&&!l.walletOrigin)throw new Error("EmbedWallet: `walletOrigin` is required (e.g. https://wallet.example.com).");this.appId=l.appId,this.walletOrigin=(G=l.walletOrigin)!=null?G:"",this.popup={width:(t=(b=l.popup)==null?void 0:b.width)!=null?t:420,height:(B=(c=l.popup)==null?void 0:c.height)!=null?B:640},this.appName=(e=l.appName)!=null?e:"",this.popupOpener=l.popupOpener,this.transport=d??(l.transport==="popup"?new MB({walletOrigin:this.walletOrigin,onDiag:this.relayDiag}):new pf({walletOrigin:this.walletOrigin,onDiag:this.relayDiag}))}get isLoggedIn(){return this._addresses!==null}get addresses(){return this._addresses}get credentialId(){return this._credentialId}get accountId(){return this._accountId}get email(){return this._email}get displayName(){return this._displayName}get hasKeys(){return this._hasKeys}get ceremonySurface(){return this.transport instanceof MB||this.policyRefused||uf(globalThis.document,this.walletOrigin)===!1?"popup":"iframe"}register(){return fG(this,arguments,function*(l={}){return this.registerInFlight||(this.registerInFlight=this.registerImpl(l).finally(()=>{this.registerInFlight=null})),this.registerInFlight})}registerImpl(l){return fG(this,null,function*(){if(this.transport instanceof MB)return this.helloAndAwaitLogin("register",l);let A=new MB(TB({walletOrigin:this.walletOrigin,onDiag:this.relayDiag},this.popupOpener?{openPopup:this.popupOpener}:{}));this.diagPopup("popup-open","register");let G;try{G=yield this.helloAndAwaitLogin("register",l,A)}finally{A.close(),this.diagPopup("popup-close","register")}try{let b=yield this.helloAndAwaitLogin("login",{credentialId:G.credentialId},this.transport,G.credentialId,!1);if(!yf(b.addresses,G.addresses))throw this.clearSessionState(),this.emit("logout",{type:"logout"}),new iG("derivation-mismatch","in-frame re-derivation after registration produced different addresses than the registration ceremony");this._hasKeys=!0,this.diag("session-state",{state:"keyed",hasKeys:!0})}catch(b){if(b instanceof iG&&b.code==="derivation-mismatch")throw b;this._hasKeys=!1,this.diag("session-state",{state:"bearer-active",hasKeys:!1})}return G})}resume(){return fG(this,null,function*(){var l,A,G;let b=yield this.checkSessionStatus();return b?.authenticated&&b.addresses&&b.credentialId?(this._addresses=b.addresses,this._credentialId=b.credentialId,this._hasKeys=b.hasKeys,this._accountId=(l=b.accountId)!=null?l:null,this._email=b.accountId&&(A=b.email)!=null?A:null,this._displayName=b.accountId&&(G=b.displayName)!=null?G:null,this.diag("adopt-session",{hasKeys:b.hasKeys}),this.diag("session-state",{state:b.hasKeys?"keyed":"bearer-active",hasKeys:b.hasKeys}),this.emit("login",{type:"login",addresses:b.addresses}),{addresses:b.addresses,credentialId:b.credentialId,accountCreated:!1}):null})}login(){return fG(this,null,function*(){return this.loginInFlight||(this.loginInFlight=this.loginImpl().finally(()=>{this.loginInFlight=null})),this.loginInFlight})}loginImpl(){return fG(this,null,function*(){let l=yield this.resume();if(l)return l;try{let A=yield this.helloAndAwaitLogin("login");return this._hasKeys=!0,this.diag("session-state",{state:"keyed",hasKeys:!0}),A}catch(A){return this.assertPopupFallbackAllowed(A),this.loginViaPopup()}})}loginViaPopup(){return fG(this,null,function*(){let l=new MB(TB({walletOrigin:this.walletOrigin,onDiag:this.relayDiag},this.popupOpener?{openPopup:this.popupOpener}:{}));this.diagPopup("popup-open","login");try{let A=yield this.helloAndAwaitLogin("login",{},l);return this._hasKeys=!1,this.diag("session-state",{state:"bearer-active",hasKeys:!1}),A}finally{l.close(),this.diagPopup("popup-close","login")}})}assertPopupFallbackAllowed(l){if(!Yf(l)||l.code!=="ceremony-policy-denied"||this.transport instanceof MB)throw l;this.policyRefused=!0,this.diag("iframe-ceremony-unavailable",{fallback:"popup"});let A=globalThis.navigator;if(A?.userActivation&&A.userActivation.isActive===!1)throw new iG("gesture-required","a popup ceremony needs a user gesture; retry from a click")}logout(){return fG(this,null,function*(){let l=crypto.randomUUID();try{yield this.transport.request({type:"wallet:logout",id:l},["wallet:result"])}catch{}this.clearSessionState(),this.transport.close(),this.diag("session-state",{state:"logged-out",hasKeys:!1}),this.emit("logout",{type:"logout"})})}clearSessionState(){this._addresses=null,this._credentialId=null,this._hasKeys=!1,this._accountId=null,this._email=null,this._displayName=null}getSigner(l){this.assertLoggedIn("getSigner");let A=(b,t)=>fG(this,null,function*(){return this.signWithStepUp({chain:b,payload:t,requestKind:"sdk"})}),G=this._addresses;switch(l.chain){case"evm":return this.withLiveAddress(new hN({address:G.evm,sign:A}),()=>this.requireAddresses("getSigner").evm);case"cere":return this.withLiveAddress(new sN({address:G.cere,sign:A}),()=>this.requireAddresses("getSigner").cere);case"solana":return this.withLiveAddress(new rN({address:G.solana,sign:A}),()=>this.requireAddresses("getSigner").solana);default:throw new iG("validation",`getSigner: unknown chain "${String(l.chain)}"`)}}asSigner(){this.assertLoggedIn("asSigner");let l=(G,b,t)=>fG(this,null,function*(){if(!this.isLoggedIn)throw new iG("unauthorized","asSigner: wallet is no longer logged in");return this.signWithStepUp({chain:"cere",payload:G,requestKind:b??"sdk",humanReadable:t})}),A=this;return{type:"ed25519",get address(){return A.requireAddresses("asSigner").cere},get publicKey(){return gN(A.requireAddresses("asSigner").solana)},isReady:()=>fG(this,null,function*(){return this.isLoggedIn}),sign:(G,b,t)=>l(G,b,t?.humanReadable)}}requestDelegation(l){return fG(this,null,function*(){this.assertLoggedIn("requestDelegation");let A=crypto.randomUUID(),G={capabilities:l.capabilities,appId:l.appId,agentPubkey:l.agentPubkey,constraints:l.constraints};return(yield this.transport.request({type:"wallet:requestDelegation",id:A,scope:G,ttl:l.ttl},["wallet:result"])).result})}createDelegation(l){return rf(()=>this.requestDelegation(l))}findApplications(){return fG(this,arguments,function*(l={}){this.assertLoggedIn("findApplications");let A=crypto.randomUUID();return(yield this.transport.request({type:"wallet:findApplications",id:A,appId:l.appId},["wallet:result"])).result})}saveApplication(l){return fG(this,null,function*(){this.assertLoggedIn("saveApplication");let A=crypto.randomUUID();return(yield this.transport.request({type:"wallet:saveApplication",id:A,permissions:l.permissions,email:l.email},["wallet:result"])).result})}on(l,A){var G;let b=this._listeners;return((G=b[l])!=null?G:b[l]=new Set).add(A),this}off(l,A){var G;return(G=this._listeners[l])==null||G.delete(A),this}dispose(){this._addresses=null,this._credentialId=null,this._hasKeys=!1,this._accountId=null,this._email=null,this._displayName=null,this._listeners={},this.transport.destroy()}appContext(){let l=typeof window<"u"?window.location.origin:"";return{appId:this.appId,name:this.appName,origin:l}}helloAndAwaitLogin(l){return fG(this,arguments,function*(A,G={},b=this.transport,t,c=!0){var B,e,d,Z,a,n;let W={type:"wallet:hello",id:crypto.randomUUID(),appContext:this.appContext(),intent:A,label:G.label,credentialId:G.credentialId},i=yield b.request(W,["wallet:login:ok"],A==="register"?{timeoutMs:Ff}:{});if(t!==void 0&&i.credentialId!==t)throw new iG("unauthorized","helloAndAwaitLogin: step-up ceremony returned a different credential than the active session; refusing to sign");this._addresses=i.addresses,this._credentialId=i.credentialId,this._hasKeys=!0,this._accountId=(e=(B=i.account)==null?void 0:B.accountId)!=null?e:null,this._email=(Z=(d=i.account)==null?void 0:d.email)!=null?Z:null,this._displayName=(n=(a=i.account)==null?void 0:a.displayName)!=null?n:null,c&&this.emit("login",{type:"login",addresses:i.addresses});let Y=A==="register"?i.accountCreated:!1;return TB({addresses:i.addresses,credentialId:i.credentialId},Y===void 0?{}:{accountCreated:Y})})}signWithStepUp(l){return fG(this,null,function*(){if(this._hasKeys)try{return yield this.sendSign(this.transport,l)}catch(G){throw G instanceof iG&&G.code==="needs-step-up"&&(this._hasKeys=!1),G}let A=this._credentialId;if(this.transport instanceof MB)return yield this.helloAndAwaitLogin("login",{credentialId:A??void 0},this.transport,A??void 0),this.sendSign(this.transport,l);try{yield this.helloAndAwaitLogin("login",{credentialId:A??void 0},this.transport,A??void 0)}catch(G){return this.assertPopupFallbackAllowed(G),this.stepUpViaPopup(l,A)}return this._hasKeys=!0,this.diag("session-state",{state:"keyed",hasKeys:!0}),this.sendSign(this.transport,l)})}stepUpViaPopup(l,A){return fG(this,null,function*(){let G=new MB(TB({walletOrigin:this.walletOrigin,onDiag:this.relayDiag},this.popupOpener?{openPopup:this.popupOpener}:{}));this.diagPopup("popup-open","step-up");try{yield this.helloAndAwaitLogin("login",{credentialId:A??void 0},G,A??void 0);let b=yield this.sendSign(G,l);return this._hasKeys=!1,this.diag("session-state",{state:"bearer-active",hasKeys:!1}),b}finally{G.close(),this.diagPopup("popup-close","step-up")}})}sendSign(l,A){return fG(this,null,function*(){let G=crypto.randomUUID(),t=(yield l.request({type:"wallet:sign",id:G,chain:A.chain,payload:A.payload,requestKind:A.requestKind,humanReadable:A.humanReadable},["wallet:result"])).result;if(!(t instanceof Uint8Array))throw new iG("internal",`popup returned non-Uint8Array sign result (got ${typeof t})`);return t})}checkSessionStatus(){return fG(this,null,function*(){let l=crypto.randomUUID();try{return(yield this.transport.request({type:"wallet:session:status",id:l},["wallet:result"])).result}catch{return null}})}emit(l,A){let G=this._listeners[l];if(G)for(let b of G)try{b(A)}catch{}}diagPopup(l,A){this.diag(l,{intent:A})}diag(l,A){this.emit("diag",TB({type:"diag",name:l,at:Date.now()},A?{detail:A}:{}))}assertLoggedIn(l){if(!this._addresses)throw new iG("unauthorized",`${l}: not logged in`)}requireAddresses(l){if(!this._addresses)throw new iG("unauthorized",`${l}: not logged in`);return this._addresses}withLiveAddress(l,A){return Object.defineProperty(l,"address",{get:A,enumerable:!0,configurable:!0}),l}};var Qf=["ddc-read","ddc-write"],XN="cef-widget",Nf="1h",Ef=60*60*1e3,vf=10*60*1e3,G2=class extends Error{constructor(){super("PopupBlockedError: the browser did not open the wallet window"),this.name="PopupBlockedError"}},Hf=(l,A)=>{let G=window.open(l,"_blank",A);if(!G)throw new G2;return G},b2=class extends Error{constructor(){super("WidgetWalletUnconfiguredError: this widget was published without a `wallet.origin`, so there is no wallet to sign in to. Rebuild and republish it with a CLI new enough to stamp one (`cef push --kind widget`)."),this.name="WidgetWalletUnconfiguredError"}};function Jf(l){let A=l.publicKey,G="0x";for(let b of A)G+=b.toString(16).padStart(2,"0");return G}function pN(l){if(!l.walletOrigin)throw new b2;let A=new RN({appId:XN,appName:l.appName??"CEF widget",walletOrigin:l.walletOrigin,...l.transport?{transport:l.transport}:{},...l.transport==="popup"?{popupOpener:Hf}:{}}),G=null,b=()=>{let c=G;if(c&&Date.now()-c.mintedAt<Ef-vf)return c.token;let B=A.requestDelegation({capabilities:[...Qf],appId:XN,ttl:Nf}).then(e=>e.token).catch(e=>{throw G=null,e});return G={token:B,mintedAt:Date.now()},B},t=()=>{let c=A.asSigner(),B=Jf(c);return{pubkey:()=>B,sigType:"ed25519",signRawBytes:e=>c.sign(e),delegation:b}};return{async resume(){return await A.resume()?(G=null,t()):null},async signIn(){return await A.login(),G=null,t()},async register(){return await A.register(),G=null,t()},ceremonySurface(){return A.ceremonySurface}}}var FN="cef-widget-signin",ff={title:"Sign in to view this",body:"This page reads data you need permission for. Sign in with your CEF account \u2014 the same one you use for the console.",signIn:"Sign in",register:"Create an account"};function DB(l,A,G){let b=document.createElement(l);return b.setAttribute("style",A),G!==void 0&&(b.textContent=G),b}var xf=["position:fixed","inset:0","z-index:2147483000","display:flex","align-items:center","justify-content:center","padding:24px","background:rgba(15,18,25,.55)",'font:14px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif'].join(";"),kf=["max-width:420px","width:100%","box-sizing:border-box","background:#fff","color:#11151c","border-radius:14px","padding:28px","box-shadow:0 18px 48px rgba(15,18,25,.28)"].join(";"),wf=["appearance:none","border:0","border-radius:9px","padding:11px 18px","font:inherit","font-weight:600","cursor:pointer","background:#6b3df5","color:#fff"].join(";"),Uf=["appearance:none","border:1px solid #d7dae2","border-radius:9px","padding:11px 18px","font:inherit","font-weight:600","cursor:pointer","background:#fff","color:#11151c"].join(";");function Cf(l,A={},G){let b={...ff,...A};return new Promise(t=>{let c=document.getElementById(FN);c&&c.remove();let B=DB("div",xf);B.id=FN;let e=DB("div",kf);e.appendChild(DB("h2","margin:0 0 8px;font-size:18px;font-weight:700",b.title)),e.appendChild(DB("p","margin:0 0 20px;color:#4a5160",b.body));let d=DB("div","display:flex;gap:10px;flex-wrap:wrap"),Z=DB("button",wf,b.signIn),a=DB("button",Uf,b.register);Z.type="button",a.type="button",d.appendChild(Z),d.appendChild(a),e.appendChild(d);let n=DB("p","margin:16px 0 0;color:#b00020;display:none");e.appendChild(n),B.appendChild(e),document.body.appendChild(B);let h=!1,W=l,i=!1,Y=R=>()=>{h||(h=!0,n.style.display="none",Z.disabled=!0,a.disabled=!0,B.style.display="none",R(W).catch(V=>{if(!G||i)throw V;return i=!0,W=G(),console.info("[widget-runtime] framed ceremony refused; retrying in a popup",V),R(W)}).then(V=>{B.remove(),t(V)}).catch(V=>{h=!1,B.style.display="flex",Z.disabled=!1,a.disabled=!1,n.textContent=V instanceof Error?V.message:String(V),n.style.display="block"}))};Z.addEventListener("click",Y(R=>R.signIn())),a.addEventListener("click",Y(R=>R.register()))})}async function yN(l,A,G={}){let b=!0;try{let c=await l.resume();if(c)return c}catch(c){b=!1,console.info("[widget-runtime] wallet surface did not come up; skipping the framed ceremony",c)}if(b)try{return await l.signIn()}catch(c){console.info("[widget-runtime] framed ceremony refused; trying a popup",c)}let t=A();try{return await t.signIn()}catch(c){console.info("[widget-runtime] popup did not open on its own; asking for a click",c)}return Cf(t,G)}var t2={vaultId:["vaultId","vault"],runId:["runId","run"],recordId:["recordId","record"]};function QN(l,A){for(let G of A){let b=l.get(G);if(b&&b.trim())return b.trim()}}function Sf(l){let A=l.hash??"",G=A.indexOf("?"),b=G>=0?A.slice(G+1):A.replace(/^#/,""),t=new URLSearchParams(b),c=new URLSearchParams((l.search??"").replace(/^\?/,"")),B=n=>QN(t,n)??QN(c,n),e={},d=B(t2.vaultId),Z=B(t2.runId),a=B(t2.recordId);return d&&(e.vaultId=d),Z&&(e.runId=Z),a&&(e.recordId=a),Object.keys(e).length>0?e:void 0}function NN(){if(!(typeof window>"u"||!window.location))return Sf(window.location)}var c2=class extends Error{constructor(A="WidgetSignedOutError: the embedding host did not supply an identity (no cef-widget:identity-response within 8s, or a malformed one). Mount createWidgetHost() on the host page."){super(A),this.name="WidgetSignedOutError"}};function EN(l){let A=null;return function(){return A||(A=(async()=>{let b=await l.bridge.requestIdentity();if(b)return{source:"host",publicKey:b.pubkey,sigType:b.sigType,sign:d=>l.bridge.sign(d),...b.token?{token:b.token}:{},...b.context?{context:b.context}:{}};if(window.parent!==window)throw new c2;let t=await l.connectWallet(),c,B=t.delegation?.bind(t);if(B)try{c=await B()}catch(d){console.warn("[widget-runtime] no delegation minted; falling back to signing",d)}let e=l.linkContext?.();return{source:"wallet",publicKey:t.pubkey(),sigType:t.sigType,sign:d=>t.signRawBytes(d),...c&&B?{token:c,renewToken:B}:{},...e?{context:e}:{}}})().catch(b=>{throw A=null,b}),A)}}var zf=2500,jf=3e4,uo=class extends Error{constructor(A,G){let b=G===void 0?"this build of the runtime has no vault.byId to open it with":G instanceof Error?G.message:String(G);super(`WidgetVaultUnreachableError: the host opened this widget on vault ${A}, and it cannot be read from here (${b}). Falling back to your own vault would answer from a different database \u2014 which looks exactly like a run that produced nothing.`),this.name="WidgetVaultUnreachableError",this.vaultId=A,this.reason=b}};async function B2(l,A,G){if(!A)return l.ensure({onboard:!1,...G?{delegationToken:G}:{}});if(typeof l.byId!="function")throw new uo(A);try{return await l.byId(A)}catch(b){throw new uo(A,b)}}function vN(l){if(l&&typeof l=="object"&&"columns"in l&&"rows"in l){let A=l.columns,G=l.rows;if(Array.isArray(A)&&Array.isArray(G))return{columns:A.map(String),rows:G,meta:{rowCount:G.length}}}if(Array.isArray(l)){let A=l.length>0?Object.keys(l[0]):[],G=l.map(b=>A.map(t=>b[t]));return{columns:A,rows:G,meta:{rowCount:l.length}}}return console.warn("[widget-runtime] unrecognized cubby query result shape; treating as empty",l),{columns:[],rows:[],meta:{rowCount:0}}}function HN(l,A,G,b){let t,c,B=()=>t??(t=A()),e=async()=>B2(B().vault,b,G),d=()=>(c??(c=e().catch(W=>{throw c=void 0,W})),c),Z=W=>l.queries.find(i=>i.id===W),a=()=>{let W=l.agentId.indexOf(":");return W>0?l.agentId.slice(0,W):""},n=async(W,i)=>{let Y=await d();if(!Y.service)throw new Error(`[widget-runtime] this host's vault-sdk has no agent-service cubby surface, so the query "${W.id}" cannot be answered here`);let R=a();if(!R)throw new Error(`[widget-runtime] "${W.id}" reads the agent service's cubby, but "${l.agentId}" carries no service key to read it from`);let V=W.cubby??l.cubbyAlias;if(!V)throw new Error(`[widget-runtime] "${W.id}" reads the agent service's cubby but names none, and this widget has no cubbyAlias to fall back on \u2014 set \`cubby\` on the query`);return Y.service(R).cubby(V).query(W.sql??"",i)},h=async(W,i)=>{let Y=await d();if(!Y.memory)throw new Error(`[widget-runtime] this host's vault-sdk has no memory surface, so the query "${W.id}" cannot be answered here`);let R=i[0],V=W.limit;switch(W.tool??"search"){case"search":return Y.memory.search(String(R??""),V?{limit:V}:void 0);case"get":return Y.memory.get(String(R??""));case"neighbours":return Y.memory.neighbours(String(R??""),V?{limit:V}:void 0);case"countByType":return Y.memory.countByType();default:throw new Error(`[widget-runtime] "${W.id}" names no memory tool this runtime knows`)}};return{async query(W,i){let Y=Z(W);return Y?.tool?vN(await h(Y,i??[])):vN(await n(Y??{id:W,label:W,sql:W},i??[]))},async publish(W,i,Y,R){return(await d()).scope(l.scope).publish({type:W,context:Y??"",payload:i,...R?.target?{target:R.target}:{}})},subscribe(W,i,Y){let R=i.onError??(w=>{console.warn("[widget-runtime] subscribe poll failed:",w)}),V=!1,m,I=[],y,x=()=>{y=void 0;let w=I;if(I=[],w.length!==0)try{Y(w)}catch(H){R(H)}};return d().then(w=>{if(V)return;let H=w.scope(l.scope);if(typeof H.subscribe!="function")throw new Error("[widget-runtime] this host's vault-sdk cannot follow a stream (no scope.subscribe)");m=H.subscribe({context:W,...i.types?{types:i.types}:{}},j=>{V||(I.push({eventId:j.eventId,type:j.type,context:j.context,payload:j.payload,...j.from?{from:j.from}:{},timestamp:j.timestamp}),y??(y=setTimeout(x,0)))},{intervalMs:i.intervalMs??zf,maxBackoffMs:i.maxBackoffMs??jf,onError:R})}).catch(w=>{V||R(w)}),()=>{V||(V=!0,y!==void 0&&clearTimeout(y),I=[],m?.unsubscribe())}},async connectAgent(){await(await d()).agents.connect({agentId:l.agentId,scope:l.scope})},async agentStatus(){try{return(await(await d()).agents.get(l.agentId)).status==="active"?"connected":"disconnected"}catch{return"disconnected"}}}}function e2(l,A,G,b){let t={endpoint:l.vault,garEndpoint:l.gar,marketplaceEndpoint:l.marketplace,s3GatewayAuthInfoUrl:l.s3GatewayAuthInfo,chainUrl:l.rpc};return b?{...t,auth:Mf(b)}:G?{...t,auth:new od(G)}:{...t,signer:A}}function Mf(l){return{authenticate:async A=>new od(await l()).authenticate(A)}}function JN(l,A){let G="anon",b="",t,c,B=new Set,e=Z=>{G=Z;let a={publicKey:b,status:G,...t?{context:t}:{}};for(let n of B)n(a)};function d(){return c??(c=(async()=>{e("connecting");let Z=await A.resolveIdentity(l);b=Z.publicKey,t=Z.context;let a=A.buildVaultClient(l,Z);return e("ready"),a})().catch(Z=>{throw c=void 0,e("anon"),Z})),c}return{async query(Z,a){return(await d()).query(Z,a)},async publish(Z,a,n,h){return(await d()).publish(Z,a,n,h)},async identity(){return await d(),{publicKey:b,status:G,...t?{context:t}:{}}},async connect(){return await d(),{publicKey:b,status:G,...t?{context:t}:{}}},async connectAgent(){await(await d()).connectAgent()},async agentStatus(){return(await d()).agentStatus()},onIdentityChange(Z){return B.add(Z),()=>B.delete(Z)},subscribe(Z,a,n){let h=!1,W;return d().then(i=>{h||(W=i.subscribe(Z,a,n))},i=>{h||(a.onError??(Y=>{console.warn("[widget-runtime] subscribe failed:",Y)}))(i)}),()=>{h||(h=!0,W?.())}}}}var ugl=new TextEncoder;function fN(l,A){let G=new ArrayBuffer(44+l.length*2),b=new DataView(G),t=(B,e)=>{for(let d=0;d<e.length;d++)b.setUint8(B+d,e.charCodeAt(d))};t(0,"RIFF"),b.setUint32(4,36+l.length*2,!0),t(8,"WAVE"),t(12,"fmt "),b.setUint32(16,16,!0),b.setUint16(20,1,!0),b.setUint16(22,1,!0),b.setUint32(24,A,!0),b.setUint32(28,A*2,!0),b.setUint16(32,2,!0),b.setUint16(34,16,!0),t(36,"data"),b.setUint32(40,l.length*2,!0);let c=44;for(let B=0;B<l.length;B++,c+=2){let e=Math.max(-1,Math.min(1,l[B]));b.setInt16(c,e<0?e*32768:e*32767,!0)}return G}function xN(l,A,G){let b=A*G,t=[];for(let c=0;c<l.length;c+=b)t.push(l.subarray(c,Math.min(c+b,l.length)));return t.length?t:[l]}async function kN(l){let A=await l.arrayBuffer(),G=window.OfflineAudioContext||window.webkitOfflineAudioContext,b=new(window.AudioContext||window.webkitAudioContext),t=await b.decodeAudioData(A.slice(0));b.close();let c=Math.ceil(t.duration*16e3),B=new G(1,c,16e3),e=B.createBufferSource();return e.buffer=t,e.connect(B.destination),e.start(),(await B.startRendering()).getChannelData(0).slice()}var Xgl=Object.freeze({PUT:1,GET:2,DELETE:3}),pgl=Object.freeze({ED_25519:0,SR_25519:1});async function wN(l,A){let G=l.segmentSeconds??25,b=await A.decode(l.blob),t=b.length/A.sampleRate;l.softCapSeconds&&t>l.softCapSeconds&&l.onWarn?.(`Recording is ${Math.round(t/60)} min; long uploads may be slow.`);let c=xN(b,A.sampleRate,G),B=[];for(let e=0;e<c.length;e++)B.push(await A.upload(fN(c[e],A.sampleRate),e)),l.onProgress?.(e+1,c.length);return A.upload.finalizeUrls?await A.upload.finalizeUrls(B):B}function UN(l){let A=l.keyPrefix??`widget-audio/${crypto.randomUUID()}`,G=l.readTtlSeconds?{ttlSeconds:l.readTtlSeconds}:{},b=async function(c,B){let e=`${A}/${B}.wav`;return await l.objects.upload(e,new Uint8Array(c),{contentType:"audio/wav"}),(await l.objects.presignedUrl(e,G)).url};return b.finalizeUrls=async t=>Promise.all(t.map(async(c,B)=>(await l.objects.presignedUrl(`${A}/${B}.wav`,G)).url)),b}g2();function _f(l){typeof document<"u"&&document.readyState==="loading"?document.addEventListener("DOMContentLoaded",l,{once:!0}):l()}async function $f(l){let A=l.wallet?.origin;if(!A)return dN(l.wallet);let G=b=>pN({walletOrigin:A,appName:l.name,...b?{transport:b}:{}});return yN(G(),()=>G("popup"))}function lx(){let l=window.WidgetSandbox?.manifest;if(!l)return;let A=bN(),G=EN({bridge:A,connectWallet:()=>$f(l),linkContext:NN}),b,t,c={resolveIdentity:async()=>{let e=await G();return b=e.token,t=e.renewToken,{source:e.source,publicKey:e.publicKey,sigType:e.sigType,...e.context?{context:e.context}:{}}},buildVaultClient:(e,d)=>{let Z=d.sigType??"ed25519",a=b,n=t,h=Y=>G().then(R=>R.sign(Y)),W=l2(d.publicKey,Z,h);return HN(e,()=>new qZ(e2(e.endpoints,W,a,n)),a,d.context?.vaultId)}},B;if(l.kind==="submit"||l.kind==="conversation"||l.kind==="composite"){let e=null,d=()=>e||(e=(async()=>{let a=await G(),n=l2(a.publicKey,a.sigType,a.sign),h=new qZ(e2(l.endpoints,n,a.token,a.renewToken)),W=await B2(h.vault,a.context?.vaultId,a.token);return UN({objects:W.scope(l.scope).objects})})().catch(a=>{throw e=null,a}),e);B={uploadAudio:(a,n)=>d().then(h=>wN({blob:a,segmentSeconds:n?.segmentSeconds,softCapSeconds:n?.softCapSeconds,onProgress:n?.onProgress,onWarn:n?.onWarn},{decode:kN,upload:h,sampleRate:16e3}))}}window.WidgetRuntime=JN(l,c),window.registerCompositePanel=AE,l.kind&&l.kind!=="custom"&&l.config&&_f(()=>{let e=document.getElementById("app");if(!e){console.error(`[widget-runtime] widget "${l.widgetId}" declares kind "${l.kind}" but its entry HTML has no <div id="app"></div>, so there is nowhere to render. Add the element, or declare kind "custom" and mount it yourself.`);return}Promise.resolve().then(()=>(a2(),qN)).then(({mountKind:d})=>d(e,l.config,window.WidgetRuntime,B))})}lx();})();
307
307
  /*! Bundled license information:
308
308