@konemono/nostr-login 1.7.48 → 1.7.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,47 +1,18 @@
1
- var BUILD={allRenderFn:!1,element:!0,event:!0,hasRenderFn:!0,hostListener:!0,hostListenerTargetWindow:!0,hostListenerTargetDocument:!0,hostListenerTargetBody:!0,hostListenerTargetParent:!1,hostListenerTarget:!0,member:!0,method:!0,mode:!0,observeAttribute:!0,prop:!0,propMutable:!0,reflect:!0,scoped:!0,shadowDom:!0,slot:!0,cssAnnotations:!0,state:!0,style:!0,formAssociated:!1,svg:!0,updatable:!0,vdomAttribute:!0,vdomXlink:!0,vdomClass:!0,vdomFunctional:!0,vdomKey:!0,vdomListener:!0,vdomRef:!0,vdomPropOrAttr:!0,vdomRender:!0,vdomStyle:!0,vdomText:!0,propChangeCallback:!0,taskQueue:!0,hotModuleReplacement:!1,isDebug:!1,isDev:!1,isTesting:!1,hydrateServerSide:!1,hydrateClientSide:!1,lifecycleDOMEvents:!1,lazyLoad:!1,profile:!1,slotRelocation:!0,appendChildSlotFix:!1,cloneNodeFix:!1,hydratedAttribute:!1,hydratedClass:!0,scriptDataOpts:!1,scopedSlotTextContentFix:!1,shadowDomShim:!1,slotChildNodesFix:!1,invisiblePrehydration:!0,propBoolean:!0,propNumber:!0,propString:!0,constructableCSS:!0,devTools:!1,shadowDelegatesFocus:!0,initializeNextTick:!1,asyncLoading:!0,asyncQueue:!1,transformTagName:!1,attachStyles:!0,experimentalSlotFixes:!1},NAMESPACE="app",__defProp$3=Object.defineProperty,__export$2=(e,t)=>{for(var n in t)__defProp$3(e,n,{get:t[n],enumerable:!0})},SVG_NS="http://www.w3.org/2000/svg",HTML_NS="http://www.w3.org/1999/xhtml",reWireGetterSetter=(e,t)=>{var n;const r=t.$cmpMeta$;Object.entries(null!=(n=r.$members$)?n:{}).map(([n,[r]])=>{if(31&r||32&r){const r=e[n],i=getPropertyDescriptor(Object.getPrototypeOf(e),n)||Object.getOwnPropertyDescriptor(e,n);i&&Object.defineProperty(e,n,{get(){return i.get.call(this)},set(e){i.set.call(this,e)},configurable:!0,enumerable:!0}),e[n]=t.$instanceValues$.has(n)?t.$instanceValues$.get(n):r}})};function getPropertyDescriptor(e,t){for(;e;){const n=Object.getOwnPropertyDescriptor(e,t);if(null==n?void 0:n.get)return n;e=Object.getPrototypeOf(e)}}var getHostRef=e=>{if(e.__stencil__getHostRef)return e.__stencil__getHostRef()},registerHost=(e,t)=>{const n={$flags$:0,$hostElement$:e,$cmpMeta$:t,$instanceValues$:new Map,$serializerValues$:new Map};n.$onReadyPromise$=new Promise(e=>n.$onReadyResolve$=e),e["s-p"]=[],e["s-rc"]=[];const r=n;return e.__stencil__getHostRef=()=>r,512&t.$flags$&&BUILD.state&&reWireGetterSetter(e,n),r},isMemberInElement=(e,t)=>t in e,consoleError=(e,t)=>(0,console.error)(e,t),styles=new Map,modeResolutionChain=[],SLOT_FB_CSS="slot-fb{display:contents}slot-fb[hidden]{display:none}",XLINK_NS="http://www.w3.org/1999/xlink",win="undefined"!=typeof window?window:{},H=win.HTMLElement||class{},plt={$flags$:0,$resourcesUrl$:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,n,r)=>e.addEventListener(t,n,r),rel:(e,t,n,r)=>e.removeEventListener(t,n,r),ce:(e,t)=>new CustomEvent(e,t)},supportsListenerOptions=(()=>{var e;let t=!1;try{null==(e=win.document)||e.addEventListener("e",null,Object.defineProperty({},"passive",{get(){t=!0}}))}catch(e){}return t})(),promiseResolve=e=>Promise.resolve(e),supportsConstructableStylesheets=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync}catch(e){}return!1})(),supportsMutableAdoptedStyleSheets=!!supportsConstructableStylesheets&&(()=>!!win.document&&Object.getOwnPropertyDescriptor(win.document.adoptedStyleSheets,"length").writable)(),queuePending=!1,queueDomReads=[],queueDomWrites=[],queueTask=(e,t)=>n=>{e.push(n),queuePending||(queuePending=!0,t&&4&plt.$flags$?nextTick(flush):plt.raf(flush))},consume=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){consoleError(e)}e.length=0},flush=()=>{consume(queueDomReads),consume(queueDomWrites),(queuePending=queueDomReads.length>0)&&plt.raf(flush)},nextTick=e=>promiseResolve().then(e),writeTask=queueTask(queueDomWrites,!0),isDef=e=>null!=e&&void 0!==e,isComplexType=e=>"object"===(e=typeof e)||"function"===e;function queryNonceMetaTagContent(e){var t,n,r;return null!=(r=null==(n=null==(t=e.head)?void 0:t.querySelector('meta[name="csp-nonce"]'))?void 0:n.getAttribute("content"))?r:void 0}var escapeRegExpSpecialCharacters=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),result_exports={};__export$2(result_exports,{err:()=>err,map:()=>map,ok:()=>ok,unwrap:()=>unwrap$1,unwrapErr:()=>unwrapErr});var ok=e=>({isOk:!0,isErr:!1,value:e}),err=e=>({isOk:!1,isErr:!0,value:e});function map(e,t){if(e.isOk){const n=t(e.value);return n instanceof Promise?n.then(e=>ok(e)):ok(n)}if(e.isErr){const t=e.value;return err(t)}throw"should never get here"}var unwrap$1=e=>{if(e.isOk)return e.value;throw e.value},unwrapErr=e=>{if(e.isErr)return e.value;throw e.value},globalStyleSheet;function createStyleSheetIfNeededAndSupported(e){}function createShadowRoot(e){var t;const n=this.attachShadow({mode:"open",delegatesFocus:!!(16&e.$flags$)});void 0===globalStyleSheet&&(globalStyleSheet=null!=(t=createStyleSheetIfNeededAndSupported())?t:null),globalStyleSheet&&(supportsMutableAdoptedStyleSheets?n.adoptedStyleSheets.push(globalStyleSheet):n.adoptedStyleSheets=[...n.adoptedStyleSheets,globalStyleSheet])}var updateFallbackSlotVisibility=e=>{const t=internalCall(e,"childNodes");e.tagName&&e.tagName.includes("-")&&e["s-cr"]&&"SLOT-FB"!==e.tagName&&getHostSlotNodes(t,e.tagName).forEach(e=>{1===e.nodeType&&"SLOT-FB"===e.tagName&&(getSlotChildSiblings(e,getSlotName(e),!1).length?e.hidden=!0:e.hidden=!1)});let n=0;for(n=0;n<t.length;n++){const e=t[n];1===e.nodeType&&internalCall(e,"childNodes").length&&updateFallbackSlotVisibility(e)}},getSlottedChildNodes=e=>{const t=[];for(let n=0;n<e.length;n++){const r=e[n]["s-nr"]||void 0;r&&r.isConnected&&t.push(r)}return t};function getHostSlotNodes(e,t,n){let r,i=0,s=[];for(;i<e.length;i++)r=e[i],!r["s-sr"]||t&&r["s-hn"]!==t||void 0!==n||s.push(r),s=[...s,...getHostSlotNodes(r.childNodes,t,n)];return s}var getSlotChildSiblings=(e,t,n=!0)=>{const r=[];(n&&e["s-sr"]||!e["s-sr"])&&r.push(e);let i=e;for(;i=i.nextSibling;)getSlotName(i)!==t||!n&&i["s-sr"]||r.push(i);return r},isNodeLocatedInSlot=(e,t)=>1===e.nodeType?null===e.getAttribute("slot")&&""===t||e.getAttribute("slot")===t:e["s-sn"]===t||""===t,getSlotName=e=>"string"==typeof e["s-sn"]?e["s-sn"]:1===e.nodeType&&e.getAttribute("slot")||void 0;function patchSlotNode(e){if(e.assignedElements||e.assignedNodes||!e["s-sr"])return;const t=t=>function(e){const n=[],r=this["s-sn"];(null==e?void 0:e.flatten)&&console.error("\n Flattening is not supported for Stencil non-shadow slots.\n You can use `.childNodes` to nested slot fallback content.\n If you have a particular use case, please open an issue on the Stencil repo.\n ");const i=this["s-cr"].parentElement;return(i.__childNodes?i.childNodes:getSlottedChildNodes(i.childNodes)).forEach(e=>{r===getSlotName(e)&&n.push(e)}),t?n.filter(e=>1===e.nodeType):n}.bind(e);e.assignedElements=t(!0),e.assignedNodes=t(!1)}function internalCall(e,t){if("__"+t in e){const n=e["__"+t];return"function"!=typeof n?n:n.bind(e)}return"function"!=typeof e[t]?e[t]:e[t].bind(e)}var createTime=(e,t="")=>()=>{},rootAppliedStyles=new WeakMap,registerStyle=(e,t,n)=>{let r=styles.get(e);supportsConstructableStylesheets&&n?(r=r||new CSSStyleSheet,"string"==typeof r?r=t:r.replaceSync(t)):r=t,styles.set(e,r)},addStyle=(e,t,n)=>{var r;const i=getScopeId(t,n),s=styles.get(i);if(!win.document)return i;if(e=11===e.nodeType?e:win.document,s)if("string"==typeof s){e=e.head||e;let n,o=rootAppliedStyles.get(e);if(o||rootAppliedStyles.set(e,o=new Set),!o.has(i)){{n=win.document.createElement("style"),n.innerHTML=s;const i=null!=(r=plt.$nonce$)?r:queryNonceMetaTagContent(win.document);if(null!=i&&n.setAttribute("nonce",i),!(1&t.$flags$))if("HEAD"===e.nodeName){const t=e.querySelectorAll("link[rel=preconnect]"),r=t.length>0?t[t.length-1].nextSibling:e.querySelector("style");e.insertBefore(n,(null==r?void 0:r.parentNode)===e?r:null)}else if("host"in e)if(supportsConstructableStylesheets){const t=new CSSStyleSheet;t.replaceSync(s),supportsMutableAdoptedStyleSheets?e.adoptedStyleSheets.unshift(t):e.adoptedStyleSheets=[t,...e.adoptedStyleSheets]}else{const t=e.querySelector("style");t?t.innerHTML=s+t.innerHTML:e.prepend(n)}else e.append(n);1&t.$flags$&&e.insertBefore(n,null)}4&t.$flags$&&(n.innerHTML+=SLOT_FB_CSS),o&&o.add(i)}}else e.adoptedStyleSheets.includes(s)||(supportsMutableAdoptedStyleSheets?e.adoptedStyleSheets.push(s):e.adoptedStyleSheets=[...e.adoptedStyleSheets,s]);return i},attachStyles=e=>{const t=e.$cmpMeta$,n=e.$hostElement$,r=t.$flags$,i=createTime("attachStyles",t.$tagName$),s=addStyle(n.shadowRoot?n.shadowRoot:n.getRootNode(),t,e.$modeName$);10&r&&(n["s-sc"]=s,n.classList.add(s+"-h")),i()},getScopeId=(e,t)=>"sc-"+(t&&32&e.$flags$?e.$tagName$+"-"+t:e.$tagName$),h=(e,t,...n)=>{"string"==typeof e&&(e=transformTag(e));let r=null,i=null,s=null,o=!1,a=!1;const c=[],l=t=>{for(let n=0;n<t.length;n++)r=t[n],Array.isArray(r)?l(r):null!=r&&"boolean"!=typeof r&&((o="function"!=typeof e&&!isComplexType(r))&&(r=String(r)),o&&a?c[c.length-1].$text$+=r:c.push(o?newVNode(null,r):r),a=o)};if(l(n),t){t.key&&(i=t.key),t.name&&(s=t.name);{const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter(t=>e[t]).join(" "))}}if("function"==typeof e)return e(null===t?{}:t,c,vdomFnUtils);const h=newVNode(e,null);return h.$attrs$=t,c.length>0&&(h.$children$=c),h.$key$=i,h.$name$=s,h},newVNode=(e,t)=>{const n={$flags$:0,$tag$:e,$text$:t,$elm$:null,$children$:null,$attrs$:null,$key$:null,$name$:null};return n},Host={},isHost=e=>e&&e.$tag$===Host,vdomFnUtils={forEach:(e,t)=>e.map(convertToPublic).forEach(t),map:(e,t)=>e.map(convertToPublic).map(t).map(convertToPrivate)},convertToPublic=e=>({vattrs:e.$attrs$,vchildren:e.$children$,vkey:e.$key$,vname:e.$name$,vtag:e.$tag$,vtext:e.$text$}),convertToPrivate=e=>{if("function"==typeof e.vtag){const t={...e.vattrs};return e.vkey&&(t.key=e.vkey),e.vname&&(t.name=e.vname),h(e.vtag,t,...e.vchildren||[])}const t=newVNode(e.vtag,e.vtext);return t.$attrs$=e.vattrs,t.$children$=e.vchildren,t.$key$=e.vkey,t.$name$=e.vname,t},createSupportsRuleRe=e=>{const t=escapeRegExpSpecialCharacters(e);return new RegExp(`(^|[^@]|@(?!supports\\s+selector\\s*\\([^{]*?${t}))(${t}\\b)`,"g")};createSupportsRuleRe("::slotted"),createSupportsRuleRe(":host"),createSupportsRuleRe(":host-context");var computeMode=e=>modeResolutionChain.map(t=>t(e)).find(e=>!!e),parsePropertyValue=(e,t,n)=>null==e||isComplexType(e)?e:4&t?"false"!==e&&(""===e||!!e):2&t?"string"==typeof e?parseFloat(e):"number"==typeof e?e:NaN:1&t?String(e):e,getElement=e=>e,createEvent$1=(e,t,n)=>{const r=getElement(e);return{emit:e=>emitEvent(r,t,{bubbles:!0,composed:!0,cancelable:!0,detail:e})}},emitEvent=(e,t,n)=>{const r=plt.ce(t,n);return e.dispatchEvent(r),r},setAccessor=(e,t,n,r,i,s,o)=>{if(n===r)return;let a=isMemberInElement(e,t),c=t.toLowerCase();if("class"===t){const t=e.classList,i=parseClassList(n);let s=parseClassList(r);t.remove(...i.filter(e=>e&&!s.includes(e))),t.add(...s.filter(e=>e&&!i.includes(e)))}else if("style"===t){for(const t in n)r&&null!=r[t]||(t.includes("-")?e.style.removeProperty(t):e.style[t]="");for(const t in r)n&&r[t]===n[t]||(t.includes("-")?e.style.setProperty(t,r[t]):e.style[t]=r[t])}else if("key"===t);else if("ref"===t)r&&r(e);else if(e.__lookupSetter__(t)||"o"!==t[0]||"n"!==t[1]){const o=isComplexType(r);if((a||o&&null!==r)&&!i)try{if(e.tagName.includes("-"))e[t]!==r&&(e[t]=r);else{const i=null==r?"":r;"list"===t?a=!1:null!=n&&e[t]==i||("function"==typeof e.__lookupSetter__(t)?e[t]=i:e.setAttribute(t,i))}}catch(e){}let l=!1;c!==(c=c.replace(/^xlink\:?/,""))&&(t=c,l=!0),null==r||!1===r?!1===r&&""!==e.getAttribute(t)||(l?e.removeAttributeNS(XLINK_NS,t):e.removeAttribute(t)):(!a||4&s||i)&&!o&&1===e.nodeType&&(r=!0===r?"":r,l?e.setAttributeNS(XLINK_NS,t,r):e.setAttribute(t,r))}else if(t="-"===t[2]?t.slice(3):isMemberInElement(win,c)?c.slice(2):c[2]+t.slice(3),n||r){const i=t.endsWith(CAPTURE_EVENT_SUFFIX);t=t.replace(CAPTURE_EVENT_REGEX,""),n&&plt.rel(e,t,n,i),r&&plt.ael(e,t,r,i)}},parseClassListRegex=/\s/,parseClassList=e=>("object"==typeof e&&e&&"baseVal"in e&&(e=e.baseVal),e&&"string"==typeof e?e.split(parseClassListRegex):[]),CAPTURE_EVENT_SUFFIX="Capture",CAPTURE_EVENT_REGEX=new RegExp(CAPTURE_EVENT_SUFFIX+"$"),updateElement=(e,t,n,r)=>{const i=11===t.$elm$.nodeType&&t.$elm$.host?t.$elm$.host:t.$elm$,s=e&&e.$attrs$||{},o=t.$attrs$||{};for(const e of sortedAttrNames(Object.keys(s)))e in o||setAccessor(i,e,s[e],void 0,n,t.$flags$);for(const e of sortedAttrNames(Object.keys(o)))setAccessor(i,e,s[e],o[e],n,t.$flags$)},scopeId,contentRef,hostTagName;function sortedAttrNames(e){return e.includes("ref")?[...e.filter(e=>"ref"!==e),"ref"]:e}var useNativeShadowDom=!1,checkSlotFallbackVisibility=!1,checkSlotRelocate=!1,isSvgMode=!1,createElm=(e,t,n)=>{var r;const i=t.$children$[n];let s,o,a,c=0;if(useNativeShadowDom||(checkSlotRelocate=!0,"slot"===i.$tag$&&(i.$flags$|=i.$children$?2:1)),null!==i.$text$)s=i.$elm$=win.document.createTextNode(i.$text$);else if(1&i.$flags$)s=i.$elm$=win.document.createTextNode(""),updateElement(null,i,isSvgMode);else{if(isSvgMode||(isSvgMode="svg"===i.$tag$),!win.document)throw new Error("You are trying to render a Stencil component in an environment that doesn't support the DOM. Make sure to populate the [`window`](https://developer.mozilla.org/en-US/docs/Web/API/Window/window) object before rendering a component.");if(s=i.$elm$=win.document.createElementNS(isSvgMode?SVG_NS:HTML_NS,!useNativeShadowDom&&BUILD.slotRelocation&&2&i.$flags$?"slot-fb":i.$tag$),isSvgMode&&"foreignObject"===i.$tag$&&(isSvgMode=!1),updateElement(null,i,isSvgMode),isDef(scopeId)&&s["s-si"]!==scopeId&&s.classList.add(s["s-si"]=scopeId),i.$children$)for(c=0;c<i.$children$.length;++c)o=createElm(e,i,c),o&&s.appendChild(o);"svg"===i.$tag$?isSvgMode=!1:"foreignObject"===s.tagName&&(isSvgMode=!0)}return s["s-hn"]=hostTagName,3&i.$flags$&&(s["s-sr"]=!0,s["s-cr"]=contentRef,s["s-sn"]=i.$name$||"",s["s-rf"]=null==(r=i.$attrs$)?void 0:r.ref,patchSlotNode(s),a=e&&e.$children$&&e.$children$[n],a&&a.$tag$===i.$tag$&&e.$elm$&&putBackInOriginalLocation(e.$elm$,!1),addRemoveSlotScopedClass(contentRef,s,t.$elm$,null==e?void 0:e.$elm$)),s},putBackInOriginalLocation=(e,t)=>{plt.$flags$|=1;const n=Array.from(e.__childNodes||e.childNodes);e["s-sr"]&&BUILD.experimentalSlotFixes;for(let e=n.length-1;e>=0;e--){const r=n[e];r["s-hn"]!==hostTagName&&r["s-ol"]&&(insertBefore(referenceNode(r).parentNode,r,referenceNode(r)),r["s-ol"].remove(),r["s-ol"]=void 0,r["s-sh"]=void 0,checkSlotRelocate=!0),t&&putBackInOriginalLocation(r,t)}plt.$flags$&=-2},addVnodes=(e,t,n,r,i,s)=>{let o,a=e["s-cr"]&&e["s-cr"].parentNode||e;for(a.shadowRoot&&a.tagName===hostTagName&&(a=a.shadowRoot);i<=s;++i)r[i]&&(o=createElm(null,n,i),o&&(r[i].$elm$=o,insertBefore(a,o,referenceNode(t))))},removeVnodes=(e,t,n)=>{for(let r=t;r<=n;++r){const t=e[r];if(t){const e=t.$elm$;nullifyVNodeRefs(t),e&&(checkSlotFallbackVisibility=!0,e["s-ol"]?e["s-ol"].remove():putBackInOriginalLocation(e,!0),e.remove())}}},updateChildren=(e,t,n,r,i=!1)=>{let s,o,a=0,c=0,l=0,h=0,d=t.length-1,u=t[0],f=t[d],p=r.length-1,g=r[0],y=r[p];for(;a<=d&&c<=p;)if(null==u)u=t[++a];else if(null==f)f=t[--d];else if(null==g)g=r[++c];else if(null==y)y=r[--p];else if(isSameVnode(u,g,i))patch(u,g,i),u=t[++a],g=r[++c];else if(isSameVnode(f,y,i))patch(f,y,i),f=t[--d],y=r[--p];else if(isSameVnode(u,y,i))"slot"!==u.$tag$&&"slot"!==y.$tag$||putBackInOriginalLocation(u.$elm$.parentNode,!1),patch(u,y,i),insertBefore(e,u.$elm$,f.$elm$.nextSibling),u=t[++a],y=r[--p];else if(isSameVnode(f,g,i))"slot"!==u.$tag$&&"slot"!==y.$tag$||putBackInOriginalLocation(f.$elm$.parentNode,!1),patch(f,g,i),insertBefore(e,f.$elm$,u.$elm$),f=t[--d],g=r[++c];else{for(l=-1,h=a;h<=d;++h)if(t[h]&&null!==t[h].$key$&&t[h].$key$===g.$key$){l=h;break}l>=0?(o=t[l],o.$tag$!==g.$tag$?s=createElm(t&&t[c],n,l):(patch(o,g,i),t[l]=void 0,s=o.$elm$),g=r[++c]):(s=createElm(t&&t[c],n,c),g=r[++c]),s&&insertBefore(referenceNode(u.$elm$).parentNode,s,referenceNode(u.$elm$))}a>d?addVnodes(e,null==r[p+1]?null:r[p+1].$elm$,n,r,c,p):c>p&&removeVnodes(t,a,d)},isSameVnode=(e,t,n=!1)=>e.$tag$===t.$tag$&&("slot"===e.$tag$?e.$name$===t.$name$:n?(n&&!e.$key$&&t.$key$&&(e.$key$=t.$key$),!0):e.$key$===t.$key$),referenceNode=e=>e&&e["s-ol"]||e,patch=(e,t,n=!1)=>{const r=t.$elm$=e.$elm$,i=e.$children$,s=t.$children$,o=t.$tag$,a=t.$text$;let c;null===a?(updateElement(e,t,isSvgMode="svg"===o||"foreignObject"!==o&&isSvgMode),null!==i&&null!==s?updateChildren(r,i,t,s,n):null!==s?(null!==e.$text$&&(r.textContent=""),addVnodes(r,null,t,s,0,s.length-1)):!n&&BUILD.updatable&&null!==i&&removeVnodes(i,0,i.length-1),isSvgMode&&"svg"===o&&(isSvgMode=!1)):(c=r["s-cr"])?c.parentNode.textContent=a:e.$text$!==a&&(r.data=a)},relocateNodes=[],markSlotContentForRelocation=e=>{let t,n,r;const i=e.__childNodes||e.childNodes;for(const e of i){if(e["s-sr"]&&(t=e["s-cr"])&&t.parentNode){n=t.parentNode.__childNodes||t.parentNode.childNodes;const i=e["s-sn"];for(r=n.length-1;r>=0;r--)if(t=n[r],!t["s-cn"]&&!t["s-nr"]&&t["s-hn"]!==e["s-hn"])if(isNodeLocatedInSlot(t,i)){let n=relocateNodes.find(e=>e.$nodeToRelocate$===t);checkSlotFallbackVisibility=!0,t["s-sn"]=t["s-sn"]||i,n?(n.$nodeToRelocate$["s-sh"]=e["s-hn"],n.$slotRefNode$=e):(t["s-sh"]=e["s-hn"],relocateNodes.push({$slotRefNode$:e,$nodeToRelocate$:t})),t["s-sr"]&&relocateNodes.map(e=>{isNodeLocatedInSlot(e.$nodeToRelocate$,t["s-sn"])&&(n=relocateNodes.find(e=>e.$nodeToRelocate$===t),n&&!e.$slotRefNode$&&(e.$slotRefNode$=n.$slotRefNode$))})}else relocateNodes.some(e=>e.$nodeToRelocate$===t)||relocateNodes.push({$nodeToRelocate$:t})}1===e.nodeType&&markSlotContentForRelocation(e)}},nullifyVNodeRefs=e=>{e.$attrs$&&e.$attrs$.ref&&e.$attrs$.ref(null),e.$children$&&e.$children$.map(nullifyVNodeRefs)},insertBefore=(e,t,n)=>("string"==typeof t["s-sn"]&&t["s-sr"]&&t["s-cr"]&&addRemoveSlotScopedClass(t["s-cr"],t,e,t.parentElement),null==e?void 0:e.insertBefore(t,n));function addRemoveSlotScopedClass(e,t,n,r){var i,s;let o;if(e&&"string"==typeof t["s-sn"]&&t["s-sr"]&&e.parentNode&&e.parentNode["s-sc"]&&(o=t["s-si"]||e.parentNode["s-sc"])){const e=t["s-sn"],a=t["s-hn"];if(null==(i=n.classList)||i.add(o+"-s"),r&&(null==(s=r.classList)?void 0:s.contains(o+"-s"))){let t=(r.__childNodes||r.childNodes)[0],n=!1;for(;t;){if(t["s-sn"]!==e&&t["s-hn"]===a&&t["s-sr"]){n=!0;break}t=t.nextSibling}n||r.classList.remove(o+"-s")}}}var renderVdom=(e,t,n=!1)=>{var r,i,s,o,a;const c=e.$hostElement$,l=e.$cmpMeta$,d=e.$vnode$||newVNode(null,null),u=isHost(t)?t:h(null,null,t);if(hostTagName=c.tagName,l.$attrsToReflect$&&(u.$attrs$=u.$attrs$||{},l.$attrsToReflect$.forEach(([t,n])=>{BUILD.serializer&&e.$serializerValues$.has(t)?u.$attrs$[n]=e.$serializerValues$.get(t):u.$attrs$[n]=c[t]})),n&&u.$attrs$)for(const e of Object.keys(u.$attrs$))c.hasAttribute(e)&&!["key","ref","style","class"].includes(e)&&(u.$attrs$[e]=c[e]);if(u.$tag$=null,u.$flags$|=4,e.$vnode$=u,u.$elm$=d.$elm$=c.shadowRoot||c,scopeId=c["s-sc"],useNativeShadowDom=!(!(1&l.$flags$)||128&l.$flags$),contentRef=c["s-cr"],checkSlotFallbackVisibility=!1,patch(d,u,n),plt.$flags$|=1,checkSlotRelocate){markSlotContentForRelocation(u.$elm$);for(const e of relocateNodes){const t=e.$nodeToRelocate$;if(!t["s-ol"]&&win.document){const e=win.document.createTextNode("");e["s-nr"]=t,insertBefore(t.parentNode,t["s-ol"]=e,t)}}for(const e of relocateNodes){const t=e.$nodeToRelocate$,a=e.$slotRefNode$;if(a){const e=a.parentNode;let n=a.nextSibling;{let s=null==(r=t["s-ol"])?void 0:r.previousSibling;for(;s;){let r=null!=(i=s["s-nr"])?i:null;if(r&&r["s-sn"]===t["s-sn"]&&e===(r.__parentNode||r.parentNode)){for(r=r.nextSibling;r===t||(null==r?void 0:r["s-sr"]);)r=null==r?void 0:r.nextSibling;if(!r||!r["s-nr"]){n=r;break}}s=s.previousSibling}}const o=t.__parentNode||t.parentNode,c=t.__nextSibling||t.nextSibling;(!n&&e!==o||c!==n)&&t!==n&&(!t["s-hn"]&&t["s-ol"]&&(t["s-hn"]=t["s-ol"].parentNode.nodeName),insertBefore(e,t,n),1===t.nodeType&&"SLOT-FB"!==t.tagName&&(t.hidden=null!=(s=t["s-ih"])&&s)),t&&"function"==typeof a["s-rf"]&&a["s-rf"](a)}else 1===t.nodeType&&(n&&(t["s-ih"]=null!=(o=t.hidden)&&o),t.hidden=!0)}}if(checkSlotFallbackVisibility&&updateFallbackSlotVisibility(u.$elm$),plt.$flags$&=-2,relocateNodes.length=0,BUILD.experimentalScopedSlotChanges&&2&l.$flags$){const e=u.$elm$.__childNodes||u.$elm$.childNodes;for(const t of e)t["s-hn"]===hostTagName||t["s-sh"]||1!==t.nodeType||(n&&null==t["s-ih"]&&(t["s-ih"]=null!=(a=t.hidden)&&a),t.hidden=!0)}contentRef=void 0},attachToAncestor=(e,t)=>{if(t&&!e.$onRenderResolve$&&t["s-p"]){const n=t["s-p"].push(new Promise(r=>e.$onRenderResolve$=()=>{t["s-p"].splice(n-1,1),r()}))}},scheduleUpdate=(e,t)=>{if(e.$flags$|=16,4&e.$flags$)return void(e.$flags$|=512);attachToAncestor(e,e.$ancestorComponent$);const n=()=>dispatchHooks(e,t);if(!t)return writeTask(n);queueMicrotask(()=>{n()})},dispatchHooks=(e,t)=>{const n=e.$hostElement$,r=createTime("scheduleUpdate",e.$cmpMeta$.$tagName$),i=n;if(!i)throw new Error(`Can't render component <${n.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);let s;return s=safeCall(i,t?"componentWillLoad":"componentWillUpdate",void 0,n),s=enqueue(s,()=>safeCall(i,"componentWillRender",void 0,n)),r(),enqueue(s,()=>updateComponent(e,i,t))},enqueue=(e,t)=>isPromisey(e)?e.then(t).catch(e=>{console.error(e),t()}):t(),isPromisey=e=>e instanceof Promise||e&&e.then&&"function"==typeof e.then,updateComponent=async(e,t,n)=>{var r;const i=e.$hostElement$,s=createTime("update",e.$cmpMeta$.$tagName$),o=i["s-rc"];n&&attachStyles(e);const a=createTime("render",e.$cmpMeta$.$tagName$);callRender(e,t,i,n),o&&(o.map(e=>e()),i["s-rc"]=void 0),a(),s();{const t=null!=(r=i["s-p"])?r:[],n=()=>postUpdateComponent(e);0===t.length?n():(Promise.all(t).then(n),e.$flags$|=4,t.length=0)}},renderingRef=null,callRender=(e,t,n,r)=>{try{renderingRef=t,t=t.render&&t.render(),e.$flags$&=-17,e.$flags$|=2,(BUILD.hasRenderFn||BUILD.reflect)&&(BUILD.vdomRender||BUILD.reflect)&&(BUILD.hydrateServerSide||renderVdom(e,t,r))}catch(t){consoleError(t,e.$hostElement$)}return renderingRef=null,null},getRenderingRef=()=>renderingRef,postUpdateComponent=e=>{const t=e.$cmpMeta$.$tagName$,n=e.$hostElement$,r=createTime("postUpdate",t),i=n,s=e.$ancestorComponent$;safeCall(i,"componentDidRender",void 0,n),64&e.$flags$?(safeCall(i,"componentDidUpdate",void 0,n),r()):(e.$flags$|=64,addHydratedFlag(n),safeCall(i,"componentDidLoad",void 0,n),r(),e.$onReadyResolve$(n),s||appDidLoad()),e.$onRenderResolve$&&(e.$onRenderResolve$(),e.$onRenderResolve$=void 0),512&e.$flags$&&nextTick(()=>scheduleUpdate(e,!1)),e.$flags$&=-517},forceUpdate=e=>{var t;{const n=getHostRef(e),r=null==(t=null==n?void 0:n.$hostElement$)?void 0:t.isConnected;return r&&2==(18&n.$flags$)&&scheduleUpdate(n,!1),r}},appDidLoad=e=>{nextTick(()=>emitEvent(win,"appload",{detail:{namespace:NAMESPACE}}))},safeCall=(e,t,n,r)=>{if(e&&e[t])try{return e[t](n)}catch(e){consoleError(e,r)}},addHydratedFlag=e=>{var t;return e.classList.add(null!=(t=BUILD.hydratedSelectorName)?t:"hydrated")},getValue=(e,t)=>getHostRef(e).$instanceValues$.get(t),setValue=(e,t,n,r)=>{const i=getHostRef(e);if(!i)return;if(BUILD.serializer&&i.$serializerValues$.has(t)&&i.$serializerValues$.get(t)===n)return;const s=e,o=i.$instanceValues$.get(t),a=i.$flags$,c=s;n=parsePropertyValue(n,r.$members$[t][0]);const l=Number.isNaN(o)&&Number.isNaN(n);if(n!==o&&!l){if(i.$instanceValues$.set(t,n),BUILD.serializer&&BUILD.reflect&&r.$attrsToReflect$&&c&&r.$serializers$&&r.$serializers$[t]){let e=n;for(const n of r.$serializers$[t])e=c[n](e,t);i.$serializerValues$.set(t,e)}if(r.$watchers$&&128&a){const e=r.$watchers$[t];e&&e.map(e=>{try{c[e](n,o,t)}catch(e){consoleError(e,s)}})}if(2==(18&a)){if(c.componentShouldUpdate&&!1===c.componentShouldUpdate(n,o,t))return;scheduleUpdate(i,!1)}}},proxyComponent=(e,t,n)=>{var r,i;const s=e.prototype;if(t.$members$||BUILD.propChangeCallback){e.watchers&&!t.$watchers$&&(t.$watchers$=e.watchers),e.deserializers&&!t.$deserializers$&&(t.$deserializers$=e.deserializers),e.serializers&&!t.$serializers$&&(t.$serializers$=e.serializers);const n=Object.entries(null!=(r=t.$members$)?r:{});n.map(([e,[n]])=>{if(31&n||32&n){const{get:r,set:i}=Object.getOwnPropertyDescriptor(s,e)||{};r&&(t.$members$[e][0]|=2048),i&&(t.$members$[e][0]|=4096),Object.defineProperty(s,e,{get(){return r?r.apply(this):getValue(this,e)},configurable:!0,enumerable:!0}),Object.defineProperty(s,e,{set(r){const s=getHostRef(this);if(s){if(i){return void 0===(32&n?this[e]:s.$hostElement$[e])&&s.$instanceValues$.get(e)&&(r=s.$instanceValues$.get(e)),i.apply(this,[parsePropertyValue(r,n)]),r=32&n?this[e]:s.$hostElement$[e],void setValue(this,e,r,t)}setValue(this,e,r,t)}}})}});{const r=new Map;s.attributeChangedCallback=function(e,i,o){plt.jmp(()=>{var a;const c=r.get(e),l=getHostRef(this);if(BUILD.serializer&&l.$serializerValues$.has(c)&&l.$serializerValues$.get(c)===o)return;if(this.hasOwnProperty(c)&&BUILD.lazyLoad,BUILD.deserializer&&t.$deserializers$&&t.$deserializers$[c]){const e=(e,t)=>{const n=null==t?void 0:t[e](o,c);n!==this[c]&&(this[c]=n)};for(const n of t.$deserializers$[c])e(n,this);return}if(s.hasOwnProperty(c)&&"number"==typeof this[c]&&this[c]==o)return;if(null==c){const n=null==l?void 0:l.$flags$;if(l&&n&&!(8&n)&&128&n&&o!==i){const n=this,r=null==(a=t.$watchers$)?void 0:a[e];null==r||r.forEach(t=>{null!=n[t]&&n[t].call(n,o,i,e)})}return}const h=n.find(([e])=>e===c);h&&4&h[1][0]&&(o=null!==o&&"false"!==o);const d=Object.getOwnPropertyDescriptor(s,c);o==this[c]||d.get&&!d.set||(this[c]=o)})},e.observedAttributes=Array.from(new Set([...Object.keys(null!=(i=t.$watchers$)?i:{}),...n.filter(([e,t])=>31&t[0]).map(([e,n])=>{var i;const s=n[1]||e;return r.set(s,e),512&n[0]&&(null==(i=t.$attrsToReflect$)||i.push([e,s])),s})]))}}return e},initializeComponent=async(e,t,n,r)=>{let i;if(!(32&t.$flags$)){t.$flags$|=32,n.$lazyBundleId$;{i=e.constructor;const n=e.localName;customElements.whenDefined(n).then(()=>t.$flags$|=128)}if(i&&i.style){let r;"string"==typeof i.style?r=i.style:"string"!=typeof i.style&&(t.$modeName$=computeMode(e),t.$modeName$&&(r=i.style[t.$modeName$]));const s=getScopeId(n,t.$modeName$);if(!styles.has(s)){const e=createTime("registerStyles",n.$tagName$);registerStyle(s,r,!!(1&n.$flags$)),e()}}}const s=t.$ancestorComponent$,o=()=>scheduleUpdate(t,!0);s&&s["s-rc"]?s["s-rc"].push(o):o()},fireConnectedCallback=(e,t)=>{},connectedCallback=e=>{if(!(1&plt.$flags$)){const t=getHostRef(e);if(!t)return;const n=t.$cmpMeta$,r=createTime("connectedCallback",n.$tagName$);if(1&t.$flags$)addHostEventListeners(e,t,n.$listeners$),(null==t?void 0:t.$lazyInstance$)?fireConnectedCallback(t.$lazyInstance$):(null==t?void 0:t.$onReadyPromise$)&&t.$onReadyPromise$.then(()=>fireConnectedCallback(t.$lazyInstance$));else{t.$flags$|=1,12&n.$flags$&&setContentReference(e);{let n=e;for(;n=n.parentNode||n.host;)if(n["s-p"]){attachToAncestor(t,t.$ancestorComponent$=n);break}}n.$members$&&Object.entries(n.$members$).map(([t,[n]])=>{if(31&n&&t in e&&e[t]!==Object.prototype[t]){const n=e[t];delete e[t],e[t]=n}}),initializeComponent(e,t,n)}r()}},setContentReference=e=>{if(!win.document)return;const t=e["s-cr"]=win.document.createComment("");t["s-cn"]=!0,insertBefore(e,t,e.firstChild)},disconnectedCallback=async e=>{if(!(1&plt.$flags$)){const t=getHostRef(e);(null==t?void 0:t.$rmListeners$)&&(t.$rmListeners$.map(e=>e()),t.$rmListeners$=void 0)}rootAppliedStyles.has(e)&&rootAppliedStyles.delete(e),e.shadowRoot&&rootAppliedStyles.has(e.shadowRoot)&&rootAppliedStyles.delete(e.shadowRoot)},proxyCustomElement=(e,t)=>{const n={$flags$:t[0],$tagName$:t[1]};n.$members$=t[2],n.$listeners$=t[3],n.$watchers$=e.$watchers$,n.$deserializers$=e.$deserializers$,n.$serializers$=e.$serializers$,n.$attrsToReflect$=[],!(1&n.$flags$)&&n.$flags$;const r=e.prototype.connectedCallback,i=e.prototype.disconnectedCallback;return Object.assign(e.prototype,{__hasHostListenerAttached:!1,__registerHost(){registerHost(this,n)},connectedCallback(){if(!this.__hasHostListenerAttached){const e=getHostRef(this);if(!e)return;addHostEventListeners(this,e,n.$listeners$),this.__hasHostListenerAttached=!0}connectedCallback(this),r&&r.call(this)},disconnectedCallback(){disconnectedCallback(this),i&&i.call(this)},__attachShadow(){if(this.shadowRoot){if("open"!==this.shadowRoot.mode)throw new Error(`Unable to re-use existing shadow root for ${n.$tagName$}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else createShadowRoot.call(this,n)}}),e.is=n.$tagName$,proxyComponent(e,n)},Fragment=(e,t)=>t,addHostEventListeners=(e,t,n,r)=>{n&&win.document&&n.map(([n,r,i])=>{const s=getHostListenerTarget(win.document,e,n),o=hostListenerProxy(t,i),a=hostListenerOpts(n);plt.ael(s,r,o,a),(t.$rmListeners$=t.$rmListeners$||[]).push(()=>plt.rel(s,r,o,a))})},hostListenerProxy=(e,t)=>n=>{try{BUILD.lazyLoad||e.$hostElement$[t](n)}catch(t){consoleError(t,e.$hostElement$)}},getHostListenerTarget=(e,t,n)=>4&n?e:8&n?win:16&n?e.body:t,hostListenerOpts=e=>supportsListenerOptions?{passive:!!(1&e),capture:!!(2&e)}:!!(2&e),CURRENT_MODULE,METHOD_MODULE;function transformTag(e){return e}!function(e){e.WELCOME="welcome",e.WELCOME_LOGIN="welcome-login",e.WELCOME_SIGNUP="welcome-signup",e.INFO="info",e.LOGIN_BUNKER_URL="login-bunker-url",e.LOGIN_READ_ONLY="login-read-only",e.CONFIRM_LOGOUT="confirm-logout",e.IMPORT_FLOW="import",e.IMPORT_OTP="import-otp",e.LOGIN="login",e.SIGNUP="signup",e.LOCAL_SIGNUP="local-signup",e.EXTENSION="extension",e.LOADING="loading",e.PREVIOUSLY_LOGGED="switch-account",e.LOGIN_OTP="otp",e.CONNECT="connect",e.CONNECTION_STRING="connection-string",e.IFRAME="iframe"}(CURRENT_MODULE||(CURRENT_MODULE={})),function(e){e.LOGIN="login",e.SIGNUP="signup",e.LOGOUT="logout",e.CONFIRM="confirm"}(METHOD_MODULE||(METHOD_MODULE={}));const appendToMap=(e,t,n)=>{const r=e.get(t);r?r.includes(n)||r.push(n):e.set(t,[n])},debounce=(e,t)=>{let n;return(...r)=>{n&&clearTimeout(n),n=setTimeout(()=>{n=0,e(...r)},t)}},isConnected=e=>!("isConnected"in e)||e.isConnected,cleanupElements=debounce(e=>{for(let t of e.keys())e.set(t,e.get(t).filter(isConnected))},2e3),stencilSubscription=()=>{if("function"!=typeof getRenderingRef)return{};const e=new Map;return{dispose:()=>e.clear(),get:t=>{const n=getRenderingRef();n&&appendToMap(e,t,n)},set:t=>{const n=e.get(t);n&&e.set(t,n.filter(forceUpdate)),cleanupElements(e)},reset:()=>{e.forEach(e=>e.forEach(forceUpdate)),cleanupElements(e)}}},unwrap=e=>"function"==typeof e?e():e,createObservableMap=(e,t=(e,t)=>e!==t)=>{const n=unwrap(e);let r=new Map(Object.entries(null!=n?n:{}));const i={dispose:[],get:[],set:[],reset:[]},s=()=>{var t;r=new Map(Object.entries(null!==(t=unwrap(e))&&void 0!==t?t:{})),i.reset.forEach(e=>e())},o=e=>(i.get.forEach(t=>t(e)),r.get(e)),a=(e,n)=>{const s=r.get(e);t(n,s,e)&&(r.set(e,n),i.set.forEach(t=>t(e,n,s)))},c="undefined"==typeof Proxy?{}:new Proxy(n,{get:(e,t)=>o(t),ownKeys:e=>Array.from(r.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(e,t)=>r.has(t),set:(e,t,n)=>(a(t,n),!0)}),l=(e,t)=>(i[e].push(t),()=>{removeFromArray(i[e],t)});return{state:c,get:o,set:a,on:l,onChange:(t,n)=>{const r=l("set",(e,r)=>{e===t&&n(r)}),i=l("reset",()=>n(unwrap(e)[t]));return()=>{r(),i()}},use:(...e)=>{const t=e.reduce((e,t)=>(t.set&&e.push(l("set",t.set)),t.get&&e.push(l("get",t.get)),t.reset&&e.push(l("reset",t.reset)),t.dispose&&e.push(l("dispose",t.dispose)),e),[]);return()=>t.forEach(e=>e())},dispose:()=>{i.dispose.forEach(e=>e()),s()},reset:s,forceUpdate:e=>{const t=r.get(e);i.set.forEach(n=>n(e,t,t))}}},removeFromArray=(e,t)=>{const n=e.indexOf(t);n>=0&&(e[n]=e[e.length-1],e.length--)},createStore=(e,t)=>{const n=createObservableMap(e,t);return n.use(stencilSubscription()),n},{state:state,onChange:onChange,reset:reset}=createStore({screen:CURRENT_MODULE.WELCOME,prevScreen:CURRENT_MODULE.WELCOME,path:[CURRENT_MODULE.WELCOME],error:"",isLoading:!1,isLoadingExtension:!1,isOTP:!1,authUrl:"",iframeUrl:"",njumpIframe:"",nlSignin:{loginName:""},nlSignup:{signupName:"",domain:"",servers:[{name:"@nsec.app",value:"nsec.app"},{name:"@highlighter.com",value:"highlighter.com"}]},nlSigninBunkerUrl:{loginName:""},nlSigninReadOnly:{loginName:""},nlSigninOTP:{loginName:"",code:""},nlImport:null});onChange("screen",()=>{state.error="",state.nlSignin.loginName="",state.nlSignup.signupName="",state.nlSignup.domain=""});const baseCss="/*! tailwindcss v3.4.10 | MIT License | https://tailwindcss.com*/*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:\"\"}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:normal;-webkit-tap-highlight-color:transparent;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:normal;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,fieldset,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{color:#9ca3af;color:#6b7280;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}[multiple],[type=date],[type=datetime-local],[type=email],[type=month],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=time],[type=url],[type=week],input:where(:not([type])),select,textarea{--tw-shadow:0 0 #0000;appearance:none;background-color:#fff;border-color:#6b7280;border-radius:0;border-width:1px;font-size:1rem;line-height:1.5rem;padding:.5rem .75rem}[multiple]:focus,[type=date]:focus,[type=datetime-local]:focus,[type=email]:focus,[type=month]:focus,[type=number]:focus,[type=password]:focus,[type=search]:focus,[type=tel]:focus,[type=text]:focus,[type=time]:focus,[type=url]:focus,[type=week]:focus,input:where(:not([type])):focus,select:focus,textarea:focus{--tw-ring-inset:var(--tw-empty, );--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#2563eb;--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);border-color:#2563eb;box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-date-and-time-value{min-height:1.5em;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-year-field{padding-bottom:0;padding-top:0}select{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E\");background-position:right .5rem center;background-repeat:no-repeat;background-size:1.5em 1.5em;padding-right:2.5rem;print-color-adjust:exact}[multiple],[size]:where(select:not([size=\"1\"])){background-image:none;background-position:0 0;background-repeat:unset;background-size:initial;padding-right:.75rem;print-color-adjust:unset}[type=checkbox],[type=radio]{--tw-shadow:0 0 #0000;appearance:none;background-color:#fff;background-origin:border-box;border-color:#6b7280;border-width:1px;color:#2563eb;display:inline-block;flex-shrink:0;height:1rem;padding:0;print-color-adjust:exact;user-select:none;vertical-align:middle;width:1rem}[type=checkbox]{border-radius:0}[type=radio]{border-radius:100%}[type=checkbox]:focus,[type=radio]:focus{--tw-ring-inset:var(--tw-empty, );--tw-ring-offset-width:2px;--tw-ring-offset-color:#fff;--tw-ring-color:#2563eb;--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}[type=checkbox]:checked,[type=radio]:checked{background-color:currentColor;background-position:50%;background-repeat:no-repeat;background-size:100% 100%;border-color:transparent}[type=checkbox]:checked{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 16 16' fill='%23fff' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 0 1 0 1.414l-5 5a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L6.5 9.086l4.293-4.293a1 1 0 0 1 1.414 0z'/%3E%3C/svg%3E\")}@media (forced-colors:active){[type=checkbox]:checked{appearance:auto}}[type=radio]:checked{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 16 16' fill='%23fff' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='8' cy='8' r='3'/%3E%3C/svg%3E\")}@media (forced-colors:active){[type=radio]:checked{appearance:auto}}[type=checkbox]:checked:focus,[type=checkbox]:checked:hover,[type=radio]:checked:focus,[type=radio]:checked:hover{background-color:currentColor;border-color:transparent}[type=checkbox]:indeterminate{background-color:currentColor;background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3E%3Cpath stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3E%3C/svg%3E\");background-position:50%;background-repeat:no-repeat;background-size:100% 100%;border-color:transparent}@media (forced-colors:active){[type=checkbox]:indeterminate{appearance:auto}}[type=checkbox]:indeterminate:focus,[type=checkbox]:indeterminate:hover{background-color:currentColor;border-color:transparent}[type=file]{background:unset;border-color:inherit;border-radius:0;border-width:0;font-size:unset;line-height:inherit;padding:0}[type=file]:focus{outline:1px solid ButtonText;outline:1px auto -webkit-focus-ring-color}::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;}.block{display:block}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.theme-default .nl-bg{--tw-bg-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(255 255 255/var(--tw-bg-opacity));box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.theme-default .dark .nl-bg{--tw-bg-opacity:1;--tw-shadow-color:rgba(51,65,85,.7);--tw-shadow:var(--tw-shadow-colored);background-color:rgb(31 41 55/var(--tw-bg-opacity))}.theme-default .nl-description,.theme-default .nl-logo,.theme-default .nl-title{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.theme-default .dark .nl-description,.theme-default .dark .nl-logo,.theme-default .dark .nl-title{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.theme-default .nl-description a{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity));text-decoration-line:underline}.theme-default .dark .nl-description a{--tw-text-opacity:1;color:rgb(191 219 254/var(--tw-text-opacity));text-decoration-line:underline}.theme-default .nl-action-button{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity));outline:2px solid transparent;outline-offset:2px}.theme-default .nl-action-button:hover{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.theme-default .dark .nl-action-button{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity));outline:2px solid transparent;outline-offset:2px}.theme-default .dark .nl-action-button:hover{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity))}.theme-default .nl-title{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.theme-default .dark .nl-title{--tw-text-opacity:1;color:rgb(229 231 235/var(--tw-text-opacity))}.theme-default .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(255 255 255/var(--tw-bg-opacity));border-color:rgb(229 231 235/var(--tw-border-opacity));border-width:1px;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);color:rgb(31 41 55/var(--tw-text-opacity))}.theme-default .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity))}.theme-default .dark .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(15 23 42/var(--tw-bg-opacity));border-color:rgb(55 65 81/var(--tw-border-opacity));color:rgb(209 213 219/var(--tw-text-opacity))}.theme-default .dark .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity))}.theme-default .nl-divider{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.theme-default .nl-divider:before{border-top-width:1px}.theme-default .nl-divider:after,.theme-default .nl-divider:before{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity));content:var(--tw-content)}.theme-default .dark .nl-divider{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity))}.theme-default .dark .nl-divider:after,.theme-default .dark .nl-divider:before{--tw-border-opacity:1;border-color:rgb(75 85 99/var(--tw-border-opacity));content:var(--tw-content)}.theme-default .nl-footer{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.theme-default .dark .nl-footer{--tw-text-opacity:1;color:rgb(229 231 235/var(--tw-text-opacity))}.theme-default .nl-error{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity))}.theme-default .dark .nl-error{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity))}.theme-default .nl-input{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.theme-default .nl-input:focus{--tw-border-opacity:1;--tw-ring-opacity:1;--tw-ring-color:rgb(168 85 247/var(--tw-ring-opacity));border-color:rgb(168 85 247/var(--tw-border-opacity))}.theme-default .dark .nl-input{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity));color:rgb(156 163 175/var(--tw-text-opacity))}.theme-default .dark .nl-input:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(75 85 99/var(--tw-ring-opacity))}.theme-default .nl-select{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.theme-default .nl-select:focus{--tw-border-opacity:1;--tw-ring-opacity:1;--tw-ring-color:rgb(168 85 247/var(--tw-ring-opacity));border-color:rgb(168 85 247/var(--tw-border-opacity))}.theme-default .dark .nl-select{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity));color:rgb(156 163 175/var(--tw-text-opacity))}.theme-default .dark .nl-select:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(75 85 99/var(--tw-ring-opacity))}.theme-default .nl-select-list{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.theme-default .dark .nl-select-list{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity))}.theme-default .nl-select-option{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.theme-default .nl-select-option:hover{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.theme-default .nl-select-option.active-option{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity));color:rgb(30 58 138/var(--tw-text-opacity))}.theme-default .dark .nl-select-option{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.theme-default .dark .nl-select-option:hover{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity));color:rgb(209 213 219/var(--tw-text-opacity))}.theme-default .nl-text-error{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity))}.theme-default .nl-text-success{--tw-text-opacity:1;color:rgb(45 212 191/var(--tw-text-opacity))}.theme-default .nl-banner{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(255 255 255/var(--tw-bg-opacity));border-color:rgb(229 231 235/var(--tw-border-opacity));border-width:1px;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);color:rgb(31 41 55/var(--tw-text-opacity))}.theme-default .dark .nl-banner{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(15 23 42/var(--tw-bg-opacity));border-color:rgb(55 65 81/var(--tw-border-opacity));color:rgb(209 213 219/var(--tw-text-opacity))}.theme-ocean .nl-bg{--tw-bg-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(191 219 254/var(--tw-bg-opacity));box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.theme-ocean .dark .nl-bg{--tw-bg-opacity:1;--tw-shadow-color:rgba(51,65,85,.7);--tw-shadow:var(--tw-shadow-colored);background-color:rgb(8 47 73/var(--tw-bg-opacity))}.theme-ocean .nl-description,.theme-ocean .nl-logo,.theme-ocean .nl-title{--tw-text-opacity:1;color:rgb(8 47 73/var(--tw-text-opacity))}.theme-ocean .dark .nl-description,.theme-ocean .dark .nl-logo,.theme-ocean .dark .nl-title{--tw-text-opacity:1;color:rgb(186 230 253/var(--tw-text-opacity))}.theme-ocean .nl-action-button{--tw-text-opacity:1;color:rgb(8 47 73/var(--tw-text-opacity));outline:2px solid transparent;outline-offset:2px}.theme-ocean .nl-action-button:hover{--tw-bg-opacity:1;background-color:rgb(224 242 254/var(--tw-bg-opacity))}.theme-ocean .dark .nl-action-button{--tw-text-opacity:1;color:rgb(186 230 253/var(--tw-text-opacity));outline:2px solid transparent;outline-offset:2px}.theme-ocean .dark .nl-action-button:hover{--tw-bg-opacity:1;background-color:rgb(12 74 110/var(--tw-bg-opacity))}.theme-ocean .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(224 242 254/var(--tw-bg-opacity));border-color:rgb(186 230 253/var(--tw-border-opacity));border-width:1px;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);color:rgb(8 47 73/var(--tw-text-opacity))}.theme-ocean .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(240 249 255/var(--tw-bg-opacity))}.theme-ocean .dark .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(7 89 133/var(--tw-bg-opacity));border-color:rgb(8 47 73/var(--tw-border-opacity));color:rgb(186 230 253/var(--tw-text-opacity))}.theme-ocean .dark .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(12 74 110/var(--tw-bg-opacity))}.theme-ocean .nl-divider{--tw-text-opacity:1;color:rgb(8 47 73/var(--tw-text-opacity))}.theme-ocean .nl-divider:after,.theme-ocean .nl-divider:before{--tw-border-opacity:1;border-color:rgb(8 47 73/var(--tw-border-opacity));content:var(--tw-content)}.theme-ocean .dark .nl-divider{--tw-text-opacity:1;color:rgb(186 230 253/var(--tw-text-opacity))}.theme-ocean .dark .nl-divider:after,.theme-ocean .dark .nl-divider:before{--tw-border-opacity:1;border-color:rgb(186 230 253/var(--tw-border-opacity));content:var(--tw-content)}.theme-ocean .nl-footer{--tw-text-opacity:1;color:rgb(8 47 73/var(--tw-text-opacity))}.theme-ocean .dark .nl-footer{--tw-text-opacity:1;color:rgb(186 230 253/var(--tw-text-opacity))}.theme-ocean .nl-error{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity))}.theme-ocean .dark .nl-error{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity))}.theme-ocean .nl-input{--tw-bg-opacity:1;background-color:rgb(224 242 254/var(--tw-bg-opacity))}.theme-ocean .nl-input:focus{--tw-border-opacity:1;--tw-ring-opacity:1;--tw-ring-color:rgb(14 165 233/var(--tw-ring-opacity));border-color:rgb(14 165 233/var(--tw-border-opacity))}.theme-ocean .dark .nl-input{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(12 74 110/var(--tw-bg-opacity));color:rgb(56 189 248/var(--tw-text-opacity))}.theme-ocean .dark .nl-input:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(2 132 199/var(--tw-ring-opacity))}.theme-ocean .nl-select{--tw-bg-opacity:1;background-color:rgb(224 242 254/var(--tw-bg-opacity))}.theme-ocean .nl-select:focus{--tw-border-opacity:1;--tw-ring-opacity:1;--tw-ring-color:rgb(14 165 233/var(--tw-ring-opacity));border-color:rgb(14 165 233/var(--tw-border-opacity))}.theme-ocean .dark .nl-select{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(12 74 110/var(--tw-bg-opacity));color:rgb(56 189 248/var(--tw-text-opacity))}.theme-ocean .dark .nl-select:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(2 132 199/var(--tw-ring-opacity))}.theme-ocean .nl-select-list{--tw-bg-opacity:1;background-color:rgb(224 242 254/var(--tw-bg-opacity))}.theme-ocean .dark .nl-select-list{--tw-bg-opacity:1;background-color:rgb(3 105 161/var(--tw-bg-opacity))}.theme-ocean .nl-select-option{--tw-text-opacity:1;color:rgb(7 89 133/var(--tw-text-opacity))}.theme-ocean .nl-select-option:hover{--tw-bg-opacity:1;background-color:rgb(186 230 253/var(--tw-bg-opacity))}.theme-ocean .dark .nl-select-option{--tw-text-opacity:1;color:rgb(56 189 248/var(--tw-text-opacity))}.theme-ocean .dark .nl-select-option:hover{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(7 89 133/var(--tw-bg-opacity));color:rgb(125 211 252/var(--tw-text-opacity))}.theme-ocean .nl-text-error{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity))}.theme-ocean .dark .nl-text-error{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity))}.theme-ocean .nl-text-success{--tw-text-opacity:1;color:rgb(13 148 136/var(--tw-text-opacity))}.theme-ocean .dark .nl-text-success{--tw-text-opacity:1;color:rgb(45 212 191/var(--tw-text-opacity))}.theme-lemonade .nl-bg{--tw-bg-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(187 247 208/var(--tw-bg-opacity));box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.theme-lemonade .dark .nl-bg{--tw-bg-opacity:1;--tw-shadow-color:rgba(51,65,85,.7);--tw-shadow:var(--tw-shadow-colored);background-color:rgb(5 46 22/var(--tw-bg-opacity))}.theme-lemonade .nl-description,.theme-lemonade .nl-logo,.theme-lemonade .nl-title{--tw-text-opacity:1;color:rgb(5 46 22/var(--tw-text-opacity))}.theme-lemonade .dark .nl-description,.theme-lemonade .dark .nl-logo,.theme-lemonade .dark .nl-title{--tw-text-opacity:1;color:rgb(187 247 208/var(--tw-text-opacity))}.theme-lemonade .nl-action-button{--tw-text-opacity:1;color:rgb(5 46 22/var(--tw-text-opacity));outline:2px solid transparent;outline-offset:2px}.theme-lemonade .nl-action-button:hover{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity))}.theme-lemonade .dark .nl-action-button{--tw-text-opacity:1;color:rgb(187 247 208/var(--tw-text-opacity));outline:2px solid transparent;outline-offset:2px}.theme-lemonade .dark .nl-action-button:hover{--tw-bg-opacity:1;background-color:rgb(20 83 45/var(--tw-bg-opacity))}.theme-lemonade .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(220 252 231/var(--tw-bg-opacity));border-color:rgb(187 247 208/var(--tw-border-opacity));border-width:1px;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);color:rgb(5 46 22/var(--tw-text-opacity))}.theme-lemonade .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity))}.theme-lemonade .dark .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(22 101 52/var(--tw-bg-opacity));border-color:rgb(5 46 22/var(--tw-border-opacity));color:rgb(187 247 208/var(--tw-text-opacity))}.theme-lemonade .dark .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(20 83 45/var(--tw-bg-opacity))}.theme-lemonade .nl-divider{--tw-text-opacity:1;color:rgb(5 46 22/var(--tw-text-opacity))}.theme-lemonade .nl-divider:after,.theme-lemonade .nl-divider:before{--tw-border-opacity:1;border-color:rgb(5 46 22/var(--tw-border-opacity));content:var(--tw-content)}.theme-lemonade .dark .nl-divider{--tw-text-opacity:1;color:rgb(187 247 208/var(--tw-text-opacity))}.theme-lemonade .dark .nl-divider:after,.theme-lemonade .dark .nl-divider:before{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity));content:var(--tw-content)}.theme-lemonade .nl-footer{--tw-text-opacity:1;color:rgb(5 46 22/var(--tw-text-opacity))}.theme-lemonade .dark .nl-footer{--tw-text-opacity:1;color:rgb(187 247 208/var(--tw-text-opacity))}.theme-lemonade .nl-error{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity))}.theme-lemonade .dark .nl-error{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity))}.theme-lemonade .nl-input{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity))}.theme-lemonade .nl-input:focus{--tw-border-opacity:1;--tw-ring-opacity:1;--tw-ring-color:rgb(34 197 94/var(--tw-ring-opacity));border-color:rgb(34 197 94/var(--tw-border-opacity))}.theme-lemonade .dark .nl-input{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(20 83 45/var(--tw-bg-opacity));color:rgb(74 222 128/var(--tw-text-opacity))}.theme-lemonade .dark .nl-input:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(22 163 74/var(--tw-ring-opacity))}.theme-lemonade .nl-select{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity))}.theme-lemonade .nl-select:focus{--tw-border-opacity:1;--tw-ring-opacity:1;--tw-ring-color:rgb(34 197 94/var(--tw-ring-opacity));border-color:rgb(34 197 94/var(--tw-border-opacity))}.theme-lemonade .dark .nl-select{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(20 83 45/var(--tw-bg-opacity));color:rgb(74 222 128/var(--tw-text-opacity))}.theme-lemonade .dark .nl-select:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(22 163 74/var(--tw-ring-opacity))}.theme-lemonade .nl-select-list{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity))}.theme-lemonade .dark .nl-select-list{--tw-bg-opacity:1;background-color:rgb(21 128 61/var(--tw-bg-opacity))}.theme-lemonade .nl-select-option{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity))}.theme-lemonade .nl-select-option:hover{--tw-bg-opacity:1;background-color:rgb(187 247 208/var(--tw-bg-opacity))}.theme-lemonade .dark .nl-select-option{--tw-text-opacity:1;color:rgb(74 222 128/var(--tw-text-opacity))}.theme-lemonade .dark .nl-select-option:hover{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(22 101 52/var(--tw-bg-opacity));color:rgb(134 239 172/var(--tw-text-opacity))}.theme-lemonade .nl-text-error{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity))}.theme-lemonade .dark .nl-text-error{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity))}.theme-lemonade .nl-text-success{--tw-text-opacity:1;color:rgb(13 148 136/var(--tw-text-opacity))}.theme-lemonade .dark .nl-text-success{--tw-text-opacity:1;color:rgb(45 212 191/var(--tw-text-opacity))}.theme-purple .nl-bg{--tw-bg-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(233 213 255/var(--tw-bg-opacity));box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.theme-purple .dark .nl-bg{--tw-bg-opacity:1;--tw-shadow-color:rgba(51,65,85,.7);--tw-shadow:var(--tw-shadow-colored);background-color:rgb(59 7 100/var(--tw-bg-opacity))}.theme-purple .nl-description,.theme-purple .nl-logo,.theme-purple .nl-title{--tw-text-opacity:1;color:rgb(59 7 100/var(--tw-text-opacity))}.theme-purple .dark .nl-description,.theme-purple .dark .nl-logo,.theme-purple .dark .nl-title{--tw-text-opacity:1;color:rgb(233 213 255/var(--tw-text-opacity))}.theme-purple .nl-action-button{--tw-text-opacity:1;color:rgb(59 7 100/var(--tw-text-opacity));outline:2px solid transparent;outline-offset:2px}.theme-purple .nl-action-button:hover{--tw-bg-opacity:1;background-color:rgb(243 232 255/var(--tw-bg-opacity))}.theme-purple .dark .nl-action-button{--tw-text-opacity:1;color:rgb(233 213 255/var(--tw-text-opacity));outline:2px solid transparent;outline-offset:2px}.theme-purple .dark .nl-action-button:hover{--tw-bg-opacity:1;background-color:rgb(88 28 135/var(--tw-bg-opacity))}.theme-purple .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(243 232 255/var(--tw-bg-opacity));border-color:rgb(233 213 255/var(--tw-border-opacity));border-width:1px;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);color:rgb(59 7 100/var(--tw-text-opacity))}.theme-purple .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(250 245 255/var(--tw-bg-opacity))}.theme-purple .dark .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(107 33 168/var(--tw-bg-opacity));border-color:rgb(59 7 100/var(--tw-border-opacity));color:rgb(233 213 255/var(--tw-text-opacity))}.theme-purple .dark .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(88 28 135/var(--tw-bg-opacity))}.theme-purple .nl-divider{--tw-text-opacity:1;color:rgb(59 7 100/var(--tw-text-opacity))}.theme-purple .nl-divider:after,.theme-purple .nl-divider:before{--tw-border-opacity:1;border-color:rgb(59 7 100/var(--tw-border-opacity));content:var(--tw-content)}.theme-purple .dark .nl-divider{--tw-text-opacity:1;color:rgb(233 213 255/var(--tw-text-opacity))}.theme-purple .dark .nl-divider:after,.theme-purple .dark .nl-divider:before{--tw-border-opacity:1;border-color:rgb(233 213 255/var(--tw-border-opacity));content:var(--tw-content)}.theme-purple .nl-footer{--tw-text-opacity:1;color:rgb(59 7 100/var(--tw-text-opacity))}.theme-purple .dark .nl-footer{--tw-text-opacity:1;color:rgb(233 213 255/var(--tw-text-opacity))}.theme-purple .nl-error{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity))}.theme-purple .dark .nl-error{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity))}.theme-purple .nl-input{--tw-bg-opacity:1;background-color:rgb(243 232 255/var(--tw-bg-opacity))}.theme-purple .nl-input:focus{--tw-border-opacity:1;--tw-ring-opacity:1;--tw-ring-color:rgb(168 85 247/var(--tw-ring-opacity));border-color:rgb(168 85 247/var(--tw-border-opacity))}.theme-purple .dark .nl-input{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(88 28 135/var(--tw-bg-opacity));color:rgb(192 132 252/var(--tw-text-opacity))}.theme-purple .dark .nl-input:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(147 51 234/var(--tw-ring-opacity))}.theme-purple .nl-select{--tw-bg-opacity:1;background-color:rgb(243 232 255/var(--tw-bg-opacity))}.theme-purple .nl-select:focus{--tw-border-opacity:1;--tw-ring-opacity:1;--tw-ring-color:rgb(168 85 247/var(--tw-ring-opacity));border-color:rgb(168 85 247/var(--tw-border-opacity))}.theme-purple .dark .nl-select{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(88 28 135/var(--tw-bg-opacity));color:rgb(192 132 252/var(--tw-text-opacity))}.theme-purple .dark .nl-select:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(147 51 234/var(--tw-ring-opacity))}.theme-purple .nl-select-list{--tw-bg-opacity:1;background-color:rgb(243 232 255/var(--tw-bg-opacity))}.theme-purple .dark .nl-select-list{--tw-bg-opacity:1;background-color:rgb(126 34 206/var(--tw-bg-opacity))}.theme-purple .nl-select-option{--tw-text-opacity:1;color:rgb(107 33 168/var(--tw-text-opacity))}.theme-purple .nl-select-option:hover{--tw-bg-opacity:1;background-color:rgb(233 213 255/var(--tw-bg-opacity))}.theme-purple .dark .nl-select-option{--tw-text-opacity:1;color:rgb(192 132 252/var(--tw-text-opacity))}.theme-purple .dark .nl-select-option:hover{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(107 33 168/var(--tw-bg-opacity));color:rgb(216 180 254/var(--tw-text-opacity))}.theme-purple .nl-text-error{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity))}.theme-purple .dark .nl-text-error{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity))}.theme-purple .nl-text-success{--tw-text-opacity:1;color:rgb(13 148 136/var(--tw-text-opacity))}.theme-purple .dark .nl-text-success{--tw-text-opacity:1;color:rgb(45 212 191/var(--tw-text-opacity))}.theme-crab .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(254 226 226/var(--tw-bg-opacity));border-color:rgb(254 202 202/var(--tw-border-opacity));border-width:1px;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);color:rgb(69 10 10/var(--tw-text-opacity))}.theme-crab .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity))}.theme-crab .dark .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(153 27 27/var(--tw-bg-opacity));border-color:rgb(69 10 10/var(--tw-border-opacity));color:rgb(254 202 202/var(--tw-text-opacity))}.theme-crab .dark .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity))}.show-slow{display:none;opacity:0;transition:.1s}.isOpen .show-slow{display:block;opacity:1;transition:.2s;transition-delay:.2s}:host{display:block}.animate-spin-loading{animation:spin2 1s linear infinite;background:var(--qa-dark-color)}@keyframes spin2{to{transform:rotate(1turn)}}.active{animation:blink .7s infinite alternate}@keyframes blink{0%{opacity:1}to{opacity:0}}.sr-only{clip:rect(0,0,0,0);border-width:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.right-0{right:0}.right-2{right:8px}.top-2{top:8px}.top-52{top:208px}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-50{z-index:50}.m-auto{margin:auto}.mx-auto{margin-left:auto;margin-right:auto}.mb-2{margin-bottom:8px}.ml-0{margin-left:0}.ml-\\[2px\\]{margin-left:2px}.mr-0{margin-right:0}.mr-2{margin-right:8px}.mr-3\\.5{margin-right:14px}.mt-2{margin-top:8px}.inline-block{display:inline-block}.flex{display:flex}.inline-flex{display:inline-flex}.grid{display:grid}.hidden{display:none}.h-0{height:0}.h-12{height:48px}.h-4{height:16px}.h-5{height:20px}.h-6{height:24px}.h-7{height:28px}.h-8{height:32px}.h-\\[46px\\]{height:46px}.h-auto{height:auto}.w-0{width:0}.w-12{width:48px}.w-16{width:64px}.w-4{width:16px}.w-5{width:20px}.w-52{width:208px}.w-6{width:24px}.w-7{width:28px}.w-8{width:32px}.w-\\[48px\\]{width:48px}.w-full{width:100%}.min-w-40{min-width:160px}.max-w-40{max-width:160px}.flex-shrink-0{flex-shrink:0}@keyframes spin{to{transform:rotate(1turn)}}.animate-spin{animation:spin 1s linear infinite}.cursor-pointer{cursor:pointer}.place-items-center{place-items:center}.items-center{align-items:center}.justify-center{justify-content:center}.gap-x-2{column-gap:8px}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.text-nowrap{text-wrap:nowrap}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-r-lg{border-bottom-right-radius:.5rem;border-top-right-radius:.5rem}.rounded-r-none{border-bottom-right-radius:0;border-top-right-radius:0}.border{border-width:1px}.border-\\[0px\\]{border-width:0}.border-\\[2px\\]{border-width:2px}.border-current{border-color:currentColor}.border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}.border-transparent{border-color:transparent}.border-t-transparent{border-top-color:transparent}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.p-3{padding:12px}.px-2{padding-left:8px;padding-right:8px}.px-3{padding-left:12px;padding-right:12px}.py-2\\.5{padding-bottom:10px;padding-top:10px}.pl-\\[11px\\]{padding-left:11px}.text-center{text-align:center}.text-sm{font-size:14px;line-height:20px}.text-xs{font-size:12px;line-height:16px}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity))}.text-slate-900{--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity))}.opacity-0{opacity:0}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.duration-300{transition-duration:.3s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.hover\\:right-2:hover{right:8px}.hover\\:rounded-r-lg:hover{border-bottom-right-radius:.5rem;border-top-right-radius:.5rem}.disabled\\:pointer-events-none:disabled{pointer-events:none}.disabled\\:opacity-50:disabled{opacity:.5}.dark\\:text-gray-300:is(.dark *){--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity))}.dark\\:focus\\:outline-none:focus:is(.dark *){outline:2px solid transparent;outline-offset:2px}.dark\\:focus\\:ring-1:focus:is(.dark *){--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.dark\\:focus\\:ring-gray-600:focus:is(.dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(75 85 99/var(--tw-ring-opacity))}.w-auto{width:auto}.rounded-xl{border-radius:.75rem}.border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity))}.border-orange-300{--tw-border-opacity:1;border-color:rgb(253 186 116/var(--tw-border-opacity))}.border-red-300{--tw-border-opacity:1;border-color:rgb(252 165 165/var(--tw-border-opacity))}.border-teal-300{--tw-border-opacity:1;border-color:rgb(94 234 212/var(--tw-border-opacity))}.border-yellow-300{--tw-border-opacity:1;border-color:rgb(253 224 71/var(--tw-border-opacity))}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.bg-orange-100{--tw-bg-opacity:1;background-color:rgb(255 237 213/var(--tw-bg-opacity))}.bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity))}.bg-teal-100{--tw-bg-opacity:1;background-color:rgb(204 251 241/var(--tw-bg-opacity))}.bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity))}.px-1{padding-left:4px;padding-right:4px}.text-\\[10px\\]{font-size:10px}.text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity))}.text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity))}.text-teal-600{--tw-text-opacity:1;color:rgb(13 148 136/var(--tw-text-opacity))}.text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity))}.mt-0{margin-top:0}.mt-3{margin-top:12px}.h-full{height:100%}.max-h-0{max-height:0}.max-h-\\[500px\\]{max-height:500px}.max-w-52{max-width:208px}.max-w-7{max-width:28px}.max-w-96{max-width:384px}.rotate-0{--tw-rotate:0deg}.rotate-0,.rotate-180{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate:180deg}.flex-col{flex-direction:column}.justify-between{justify-content:space-between}.gap-0\\.5{gap:2px}.gap-2{gap:8px}.gap-3{gap:12px}.gap-x-3\\.5{column-gap:14px}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.border-b-\\[1px\\]{border-bottom-width:1px}.border-dashed{border-style:dashed}.border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity))}.border-gray-400{--tw-border-opacity:1;border-color:rgb(156 163 175/var(--tw-border-opacity))}.p-2{padding:8px}.p-4{padding:16px}.py-2{padding-bottom:8px;padding-top:8px}.pb-1{padding-bottom:4px}.pb-1\\.5{padding-bottom:6px}.pb-5{padding-bottom:20px}.pe-4{padding-inline-end:16px}.ps-4{padding-inline-start:16px}.pt-5{padding-top:20px}.text-3xl{font-size:30px;line-height:36px}.font-light{font-weight:300}.text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity))}.decoration-dashed{text-decoration-style:dashed}.duration-\\[0\\.25s\\]{transition-duration:.25s}.ease-in{transition-timing-function:cubic-bezier(.4,0,1,1)}.hover\\:bg-gray-300:hover{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity))}.left-0{left:0}.start-0{inset-inline-start:0}.top-0{top:0}.z-\\[80\\]{z-index:80}.z-\\[81\\]{z-index:81}.gap-1{gap:4px}.overflow-x-hidden{overflow-x:hidden}.bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity))}.bg-opacity-75{--tw-bg-opacity:0.75}.px-4{padding-left:16px;padding-right:16px}.py-3{padding-bottom:12px}.pt-3,.py-3{padding-top:12px}.text-base{font-size:16px;line-height:24px}.text-blue-400{--tw-text-opacity:1;color:rgb(96 165 250/var(--tw-text-opacity))}@media (min-width:640px){.sm\\:mx-auto{margin-left:auto;margin-right:auto}.sm\\:w-full{width:100%}.sm\\:max-w-lg{max-width:512px}}.ml-auto,.mx-auto{margin-left:auto}.mr-auto{margin-right:auto}.w-60{width:240px}.pt-2{padding-top:8px}.text-4xl{font-size:36px;line-height:40px}.text-lg{font-size:18px;line-height:28px}.mb-0\\.5{margin-bottom:2px}.mb-5{margin-bottom:20px}.ml-auto{margin-left:auto}.w-72{width:288px}.max-w-72{max-width:288px}.border-\\[3px\\]{border-width:3px}.pb-2{padding-bottom:8px}.text-2xl{font-size:24px;line-height:32px}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.mb-10{margin-bottom:40px}.mt-10{margin-top:40px}.h-20{height:80px}.w-20{width:80px}.border-\\[4px\\]{border-width:4px}.text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity))}.dark\\:text-green-200:is(.dark *){--tw-text-opacity:1;color:rgb(187 247 208/var(--tw-text-opacity))}.pointer-events-none{pointer-events:none}.inset-y-0{bottom:0;top:0}.ps-11{padding-inline-start:44px}.text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity))}.peer:disabled~.peer-disabled\\:pointer-events-none{pointer-events:none}.peer:disabled~.peer-disabled\\:opacity-50{opacity:.5}.dark\\:border-transparent:is(.dark *){border-color:transparent}.mt-1{margin-top:4px}.min-w-\\[15rem\\]{min-width:15rem}.overflow-hidden,.truncate{overflow:hidden}.shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.before\\:absolute:before{content:var(--tw-content);position:absolute}.before\\:-top-4:before{content:var(--tw-content);top:-16px}.before\\:start-0:before{content:var(--tw-content);inset-inline-start:0}.before\\:h-4:before{content:var(--tw-content);height:16px}.before\\:w-full:before{content:var(--tw-content);width:100%}.after\\:absolute:after{content:var(--tw-content);position:absolute}.after\\:-bottom-4:after{bottom:-16px;content:var(--tw-content)}.after\\:start-0:after{content:var(--tw-content);inset-inline-start:0}.after\\:h-4:after{content:var(--tw-content);height:16px}.after\\:w-full:after{content:var(--tw-content);width:100%}.right-\\[-2px\\]{right:-2px}.right-\\[-3px\\]{right:-3px}.top-\\[-2px\\]{top:-2px}.top-\\[-3px\\]{top:-3px}.h-1\\.5{height:6px}.h-3{height:12px}.w-1\\.5{width:6px}.w-3{width:12px}.max-w-6{max-width:24px}.border-2{border-width:2px}.border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity))}.border-white{--tw-border-opacity:1;border-color:rgb(255 255 255/var(--tw-border-opacity))}.bg-green-500{--tw-bg-opacity:1;background-color:rgb(34 197 94/var(--tw-bg-opacity))}.pb-3{padding-bottom:12px}.pt-0{padding-top:0}.text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity))}.hover\\:bg-gray-400:hover{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity))}.hover\\:text-red-600:hover{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity))}.group:hover .group-hover\\:border-blue-400{--tw-border-opacity:1;border-color:rgb(96 165 250/var(--tw-border-opacity))}.end-0{inset-inline-end:0}.h-\\[20px\\]{height:20px}.w-\\[20px\\]{width:20px}.pe-11{padding-inline-end:44px}",buttonBaseCss=baseCss,ButtonBaseStyle0=buttonBaseCss,ButtonBase=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.theme="default",this.darkMode=!1,this.titleBtn="Open modal",this.disabled=!1}componentDidRender(){const e=this.element.querySelector("svg");e&&(e.classList.add("flex-shrink-0","w-4","h-4","block"),e.removeAttribute("style"))}render(){return h("div",{key:"1048576f0a9839c56cac030b1de7899b25b5f39e",class:`theme-${this.theme}`},h("div",{key:"ea29f74a1f7e4268802c6e4aaca5867dfd2e4c9b",class:"animate-spin-loading active"}),h("button",{key:"71f84d47b11aa3971818b686f8dddb74e0d36eb0",disabled:this.disabled,type:"button",class:"nl-button py-2.5 px-3 w-full inline-flex justify-center items-center gap-x-2 text-sm font-medium rounded-lg disabled:opacity-50 disabled:pointer-events-none dark:focus:outline-none dark:focus:ring-1 dark:focus:ring-gray-600"},h("slot",{key:"91a91994e20dc10e3bbb2576e4214fa98533be8e",name:"icon-start"}),this.titleBtn))}get element(){return this}static get style(){return ButtonBaseStyle0}},[4,"button-base",{theme:[1025],darkMode:[1028,"dark-mode"],titleBtn:[1,"title-btn"],disabled:[4]}]);function defineCustomElement$q(){if("undefined"==typeof customElements)return;["button-base"].forEach(e=>{if("button-base"===e)customElements.get(e)||customElements.define(e,ButtonBase)})}defineCustomElement$q();const nlConfirmLogoutCss=baseCss,NlConfirmLogoutStyle0=nlConfirmLogoutCss,NlConfirmLogout$1=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.handleLogoutBanner=createEvent$1(this,"handleLogoutBanner"),this.handleBackUpModal=createEvent$1(this,"handleBackUpModal"),this.nlCloseModal=createEvent$1(this,"nlCloseModal"),this.titleModal="Delete keys?",this.description="Your profile keys are stored in this browser tab and will be deleted if you log out, and your profile will be inaccessible."}handleLogout(){this.handleLogoutBanner.emit(METHOD_MODULE.LOGOUT),this.nlCloseModal.emit()}handleCancel(){this.nlCloseModal.emit()}handleBackUp(){state.path=[CURRENT_MODULE.IMPORT_FLOW]}render(){return h("div",{key:"fe605f38f9d0a440fe53e21f19288c41e4762c22",class:"p-4 overflow-y-auto"},h("h1",{key:"84d14a59035515b2fd612d262400a038887a10d7",class:"nl-title font-bold text-center text-4xl"},this.titleModal),h("p",{key:"83ef73271c76309561be95e0207f8130d75a161c",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},this.description),h("div",{key:"fce0f132846beb95dd9e41357f5ab87be7229a56",class:"mt-3 ml-auto mr-auto w-60 flex flex-col gap-2"},h("button-base",{key:"c4fc722a7c98d84e797963ed7fe928164411b701",onClick:()=>this.handleBackUp(),titleBtn:"Backup keys",theme:"lemonade"}),h("button-base",{key:"39df385a9a8dc3fcd74f4196d4191bc4a308a16d",onClick:()=>this.handleLogout(),theme:"crab",titleBtn:"Logout and delete keys"})))}static get style(){return NlConfirmLogoutStyle0}},[0,"nl-confirm-logout",{titleModal:[1,"title-modal"],description:[1]}]);function defineCustomElement$p(){if("undefined"==typeof customElements)return;["nl-confirm-logout","button-base"].forEach(e=>{switch(e){case"nl-confirm-logout":customElements.get(e)||customElements.define(e,NlConfirmLogout$1);break;case"button-base":customElements.get(e)||defineCustomElement$q()}})}defineCustomElement$p();const nlConnectCss=baseCss,NlConnectStyle0=nlConnectCss,NlConnect=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlNostrConnect=createEvent$1(this,"nlNostrConnect"),this.titleWelcome="Connect to key store",this.authMethods=[],this.hasOTP=!1,this.connectionStringServices=[],this.isOpenAdvancedLogin=!1}handleChangeScreen(e){state.path=[...state.path,e]}handleOpenAdvanced(){this.isOpenAdvancedLogin=!this.isOpenAdvancedLogin}allowAuthMethod(e){return!this.authMethods.length||this.authMethods.includes(e)}componentWillLoad(){}handleOpenLink(e,t){e.preventDefault(),this.nlNostrConnect.emit(t)}handleConnectionString(){this.handleChangeScreen(CURRENT_MODULE.CONNECTION_STRING)}render(){const e=(this.isOpenAdvancedLogin?"rotate-180":"rotate-0")+" duration-300 flex-shrink-0 w-4 h-4 text-blue-500";return h(Fragment,{key:"1927cf668a1188fe3d7646e4a7854046b5476f31"},h("div",{key:"0428eec0130c32c6ac0386f5bbc7ebf5d693a459",class:"p-4 overflow-y-auto"},h("h1",{key:"e7bb4180be357e4208c319f3cf508ed93b409d87",class:"nl-title font-bold text-center text-3xl"},this.titleWelcome)),h("div",{key:"9860c1c264fe6da144590f17067139006f4e1c96",class:"p-4"},Boolean(this.connectionStringServices.length)&&h("div",{key:"dacc446ecd659a60f90f336c513aea08d464c53f",class:"max-w-96 mx-auto pt-5"},h("p",{key:"58eee01671daa814da10883363384feb3fc0026e",class:"nl-description font-medium text-sm pb-1.5"},"Select key store:"),h("ul",{key:"cbb8cd144d9b84dc6d6555f31e6d1838002301ea",class:"p-2 rounded-lg border border-gray-200 flex flex-col w-full gap-0.5"},this.connectionStringServices.map(e=>h("li",null,h("a",{href:e.link,target:"_blank",onClick:t=>this.handleOpenLink(t,e),class:"flex items-center gap-x-3.5 w-full hover:bg-gray-300 flex cursor-pointer items-center gap-x-3.5 py-2 px-3 rounded-lg text-sm justify-between"},h("div",{class:"w-full max-w-7 h-7 flex relative"},h("div",{class:"uppercase font-bold w-full h-full rounded-full border border-gray-400 flex justify-center items-center"},Boolean(e.img)?h("img",{class:"w-full rounded-full",src:e.img,alt:e.name}):h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"#9ca3af",class:"w-4 h-4 block"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z"})))),h("div",{class:"overflow-hidden flex flex-col w-full"},h("div",{class:"nl-title truncate overflow-hidden"},e.name)))))))),h("div",{key:"654367c0e9106d1e840fedf349dc25f0452d4d4f",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"42a2ede70e15abbe98ac04cc0ff6a50d4afd5aad",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("div",{key:"a923dcb9b50dd9377711a15fc1900570db8becbe",class:"max-w-52 mx-auto pb-5"},(this.allowAuthMethod("connect")||this.allowAuthMethod("readOnly"))&&h("div",{key:"ad3520c80d4052b6579893e09d3683ec002027ba",class:"flex justify-center"},h("div",{key:"7232d7a387c3cb437ef2c7cb5c8622fea4b14416",onClick:()=>this.handleOpenAdvanced(),class:"text-blue-500 mt-3 decoration-dashed cursor-pointer inline-flex gap-2 items-center pb-1 border-dashed border-b-[1px] border-blue-500 text-sm font-light"},"Advanced",h("svg",{key:"e687b41e6e2cf3605edec3a51376228db029dcc4",class:e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},h("path",{key:"39aa6f5a53580a306f0667efb5a4cd3280cdced1",d:"m6 9 6 6 6-6"})))),h("div",{key:"dce6ddf9e7079e169f9a1e85d847f53b2897e238",class:(this.isOpenAdvancedLogin?"max-h-[500px] mt-3 duration-300":"max-h-0 mt-0 duration-[0.25s]")+" transition-max-height ease-in flex gap-3 flex-col overflow-hidden"},this.allowAuthMethod("connect")&&h("button-base",{key:"e2f193770cd51db143fed6bc398bb9131f6a61e8",titleBtn:"User name",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN)},h("svg",{key:"99d92ddfd0c142f556b77ad3cf7e9a3f2b7a74f7",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},h("path",{key:"60c43b645f481548a1e6cc01ba8b28d645e132d7","stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z"}))),this.allowAuthMethod("connect")&&h("button-base",{key:"e36f778cfbb4a55ba6d2a020365c70471728e2f1",titleBtn:"Connection string",onClick:()=>this.handleConnectionString()},h("svg",{key:"d7e13e1643d7ce8f339813a36d9d6633398120ca",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"67e838e2045708e9ca5f13c705c59097747dec0f","stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 4.875c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5A1.125 1.125 0 0 1 3.75 9.375v-4.5ZM3.75 14.625c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5a1.125 1.125 0 0 1-1.125-1.125v-4.5ZM13.5 4.875c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5A1.125 1.125 0 0 1 13.5 9.375v-4.5Z"}),h("path",{key:"3d7c3636ce9148b8e668aebb43260cf69991004c","stroke-linecap":"round","stroke-linejoin":"round",d:"M6.75 6.75h.75v.75h-.75v-.75ZM6.75 16.5h.75v.75h-.75v-.75ZM16.5 6.75h.75v.75h-.75v-.75ZM13.5 13.5h.75v.75h-.75v-.75ZM13.5 19.5h.75v.75h-.75v-.75ZM19.5 13.5h.75v.75h-.75v-.75ZM19.5 19.5h.75v.75h-.75v-.75ZM16.5 16.5h.75v.75h-.75v-.75Z"}))),this.allowAuthMethod("connect")&&h("button-base",{key:"54157a016b76d351aa93f0f98b1cdfb6c3548561",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN_BUNKER_URL),titleBtn:"Bunker URL"},h("svg",{key:"6c637c9fc47729887720b2c76a40d0287f68bb5f",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"45eccf5015bb2afaf15a4159a213505fe5e18de1","stroke-linecap":"round","stroke-linejoin":"round",d:"M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"}))))))}static get style(){return NlConnectStyle0}},[0,"nl-connect",{titleWelcome:[1,"title-welcome"],authMethods:[16],hasOTP:[4,"has-o-t-p"],connectionStringServices:[16],isOpenAdvancedLogin:[32]}]);function defineCustomElement$o(){if("undefined"==typeof customElements)return;["nl-connect","button-base"].forEach(e=>{switch(e){case"nl-connect":customElements.get(e)||customElements.define(e,NlConnect);break;case"button-base":customElements.get(e)||defineCustomElement$q()}})}defineCustomElement$o();const nlIframeCss=baseCss,NlIframeStyle0=nlIframeCss,NlConfirmLogout=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlCloseModal=createEvent$1(this,"nlCloseModal"),this.titleModal="Confirm",this.description="Your profile keys are stored in this browser tab and will be deleted if you log out, and your profile will be inaccessible.",this.iframeUrl=""}handleCancel(){this.nlCloseModal.emit()}render(){return h("div",{key:"36ee9fd43bbb16768b7634783781ecffb1c9432a",class:"p-4 overflow-y-auto"},h("div",{key:"1634e1fd37bc44030f22bfdab9f7deec2806731b",class:"mt-3 flex flex-col gap-2"},this.iframeUrl&&h("iframe",{key:"2b1ab3032b152fb109f3531bb7600bb76aa1a562",src:this.iframeUrl,style:{width:"100%",height:"600px",border:"1px solid #ccc",borderRadius:"8px"}})))}static get style(){return NlIframeStyle0}},[0,"nl-iframe",{titleModal:[1,"title-modal"],description:[1],iframeUrl:[1,"iframe-url"]}]);function defineCustomElement$n(){if("undefined"==typeof customElements)return;["nl-iframe"].forEach(e=>{if("nl-iframe"===e)customElements.get(e)||customElements.define(e,NlConfirmLogout)})}defineCustomElement$n();const nlSelectCss=baseCss,NlSelectStyle0=nlSelectCss,NlSelect=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.selectDomain=createEvent$1(this,"selectDomain"),this.isOpen=!1,this.value=null,this.options=void 0,this.selected=void 0,this.mode=!1,this.darkMode=!1,this.themeState="default",this.theme="default"}handleWindowClick(){this.wrapperRef.querySelector(".listClass")&&(this.isOpen=!1)}toggleDropdown(){this.isOpen=!this.isOpen,this.calculateDropdownPosition()}watchPropHandler(e){this.themeState=e}watchModeHandler(e){this.mode=e}connectedCallback(){this.themeState=this.theme,this.mode=this.darkMode,this.value=this.options[this.selected],this.selectDomain.emit(this.value.value)}calculateDropdownPosition(){if(this.isOpen&&this.buttonRef){const e=this.buttonRef.getBoundingClientRect();this.ulRef.style.top=`${e.height}px`}}handleChange(e){this.value=e,this.isOpen=!1,this.selectDomain.emit(this.value.value)}render(){const e=(this.isOpen?"listClass":"hidden")+" min-w-[15rem] nl-select-list absolute left-0 shadow-md rounded-lg p-2 mt-1 after:h-4 after:absolute after:-bottom-4 after:start-0 after:w-full before:h-4 before:absolute before:-top-4 before:start-0 before:w-full",t=(this.isOpen?"rotate-180":"rotate-0")+" duration-300 flex-shrink-0 w-4 h-4 text-gray-500";return h("div",{key:"c86084c50712455e04682a4392e490bc0e20eb1d",class:`theme-${this.themeState}`},h("div",{key:"a90d9b4af52845a9971c39cec69c13493d511381",class:"relative",ref:e=>this.wrapperRef=e},h("button",{key:"1391137997bf8fcd0a5466cd9fa20c79b4ce27ba",ref:e=>this.buttonRef=e,onClick:()=>this.toggleDropdown(),type:"button",class:"nl-select peer py-3 px-4 flex items-center w-full justify-between border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent"},h("span",{key:"224425ab92ba3599595924972e98a0fc9cb1a189",class:"truncate overflow-hidden"},this.value.name),h("svg",{key:"8eb2a2b552cb9ea36fb1abc61d804efb423afda6",class:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},h("path",{key:"feea1a7f54f4a111b7bf01e3945445311b97ab82",d:"m6 9 6 6 6-6"}))),h("ul",{key:"fca4982f04f4133d5c2a2f613a7e7d977dd5c241",ref:e=>this.ulRef=e,class:e},this.options.map(e=>h("li",{onClick:()=>this.handleChange(e),class:"nl-select-option flex cursor-pointer items-center gap-x-3.5 py-2 px-3 rounded-lg text-sm"},e.name)))))}get element(){return this}static get watchers(){return{theme:["watchPropHandler"],darkMode:["watchModeHandler"]}}static get style(){return NlSelectStyle0}},[0,"nl-select",{options:[16],selected:[2],darkMode:[4,"dark-mode"],theme:[1],isOpen:[32],value:[32],mode:[32],themeState:[32]},[[8,"click","handleWindowClick"]],{theme:["watchPropHandler"],darkMode:["watchModeHandler"]}]);function defineCustomElement$m(){if("undefined"==typeof customElements)return;["nl-select"].forEach(e=>{if("nl-select"===e)customElements.get(e)||customElements.define(e,NlSelect)})}defineCustomElement$m();const nlImportFlowCss=baseCss,NlImportFlowStyle0=nlImportFlowCss,NlImportFlow$1=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlImportAccount=createEvent$1(this,"nlImportAccount"),this.nlExportKeys=createEvent$1(this,"nlExportKeys"),this.titleInfo="Back up your keys",this.titleImport="Choose a service",this.services=[],this.isContinued=!1,this.isKeyBackup=!1,this.isCopy=!1}handleDomainSelect(e){const t=this.services.find(t=>t.domain===e.detail);state.nlImport=t}handleCreateAccount(e){e.preventDefault(),this.nlImportAccount.emit(state.nlImport)}handleContinue(){this.isContinued=!0}handleContinueKeyBackup(){this.isKeyBackup=!0}async copyToClipboard(){this.nlExportKeys.emit(),this.isCopy=!0,setTimeout(()=>{this.isCopy=!1},1500)}render(){if(!this.isContinued&&!this.isKeyBackup)return h("div",{class:"p-4 overflow-y-auto"},h("h1",{class:"nl-title font-bold text-center text-2xl"},this.titleInfo),h("p",{class:"nl-description font-light text-sm pt-2 pb-2 max-w-96 mx-auto"},"Nostr profiles are controlled by cryptographic keys.",h("br",null),h("br",null),"Your keys are currently only stored in this browser tab, and may be lost if you close it.",h("br",null),h("br",null),"You should backup your keys.",h("br",null),h("br",null),"We recommend to import your keys into a key store service, to protect them and to use with other apps."),h("div",{class:"ml-auto mr-auto mb-2 w-72"},h("button-base",{onClick:()=>this.handleContinue(),titleBtn:"Import to key store"})),h("div",{class:"ml-auto mr-auto w-72"},h("button-base",{onClick:()=>this.handleContinueKeyBackup(),titleBtn:"Export keys"})));if(this.isKeyBackup)return h("div",{class:"p-4 overflow-y-auto"},h("h1",{class:"nl-title font-bold text-center text-2xl"},"Key export"),h("p",{class:"nl-description font-light text-sm pt-2 pb-2 max-w-96 mx-auto"},"Copy your keys and store them in a safe place, like a password manager.",h("br",null),h("br",null),"You can sign into other Nostr apps by pasting your keys into them.",h("br",null),h("br",null),"Your keys must be kept secret, never share them with anyone."),h("div",{class:"max-w-72 mx-auto"},h("div",{class:"ml-auto mr-auto mb-2 w-72"},h("button-base",{onClick:()=>this.copyToClipboard(),titleBtn:this.isCopy?"Copied!":"Copy to clipboard"}))));const e=this.services.filter(e=>e.canImport).map(e=>({name:e.domain,value:e.domain}));return h(Fragment,null,h("div",{class:"p-4 overflow-y-auto"},h("h1",{class:"nl-title font-bold text-center text-2xl"},this.titleImport),h("p",{class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},"Your Nostr keys will be imported into the service you choose. You will manage your keys on their website.")),h("div",{class:"max-w-72 mx-auto mb-5"},h("div",{class:"mb-0.5"},h("nl-select",{onSelectDomain:e=>this.handleDomainSelect(e),selected:0,options:e})),h("p",{class:"nl-title font-light text-sm mb-2"},"Default provider is a fine choice to start with."),h("div",{class:"ps-4 pe-4 overflow-y-auto"},h("p",{class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{disabled:state.isLoading,onClick:e=>this.handleCreateAccount(e),titleBtn:"Start importing"},state.isLoading?h("span",{slot:"icon-start",class:"animate-spin-loading inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}):h("svg",{slot:"icon-start",style:{display:"none"},xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M18 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0ZM3 19.235v-.11a6.375 6.375 0 0 1 12.75 0v.109A12.318 12.318 0 0 1 9.374 21c-2.331 0-4.512-.645-6.374-1.766Z"})))))}static get style(){return NlImportFlowStyle0}},[0,"nl-import-flow",{titleInfo:[1025,"title-info"],titleImport:[1,"title-import"],services:[16],isContinued:[32],isKeyBackup:[32],isCopy:[32]}]);function defineCustomElement$l(){if("undefined"==typeof customElements)return;["nl-import-flow","button-base","nl-select"].forEach(e=>{switch(e){case"nl-import-flow":customElements.get(e)||customElements.define(e,NlImportFlow$1);break;case"button-base":customElements.get(e)||defineCustomElement$q();break;case"nl-select":customElements.get(e)||defineCustomElement$m()}})}defineCustomElement$l();const nlInfoCss=baseCss,NlInfoStyle0=nlInfoCss,NlInfo=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost()}render(){return h("div",{key:"7463f42c27643903a9d6fb0160fbabe833679fcb",class:"p-4 overflow-y-auto"},h("svg",{key:"86c5f04f87b21553f3512d289425996b46eb6c57",class:"w-12 h-12 mx-auto mb-2",width:"225",height:"224",viewBox:"0 0 225 224",fill:"none",xmlns:"http://www.w3.org/2000/svg"},h("rect",{key:"6be61e0b2ff3d3f13e617e9b1df073fbe3b5678b",width:"224.047",height:"224",rx:"64",fill:"#6951FA"}),h("path",{key:"0c0aff7d5143022fe857de141cdae31397c3c2f4",d:"M162.441 135.941V88.0593C170.359 85.1674 176 77.5348 176 68.6696C176 57.2919 166.708 48 155.33 48C143.953 48 134.661 57.2444 134.661 68.6696C134.661 77.5822 140.302 85.1674 148.219 88.0593V135.941C147.698 136.13 147.176 136.367 146.655 136.604L87.3956 77.3452C88.6282 74.6904 89.2919 71.7511 89.2919 68.6696C89.2919 57.2444 80.0474 48 68.6696 48C57.2919 48 48 57.2444 48 68.6696C48 77.5822 53.6415 85.1674 61.5585 88.0593V135.941C53.6415 138.833 48 146.465 48 155.33C48 166.708 57.2444 176 68.6696 176C80.0948 176 89.3393 166.708 89.3393 155.33C89.3393 146.418 83.6978 138.833 75.7807 135.941V88.0593C76.3022 87.8696 76.8237 87.6326 77.3452 87.3956L136.604 146.655C135.372 149.31 134.708 152.249 134.708 155.33C134.708 166.708 143.953 176 155.378 176C166.803 176 176.047 166.708 176.047 155.33C176.047 146.418 170.406 138.833 162.489 135.941H162.441Z",fill:"white"})),h("h1",{key:"3a89ee5051e2d74945347dec6055749cec126f27",class:"nl-title font-bold text-center text-4xl"},"Nostr ",h("span",{key:"96a49c22dffa4a30639f387a949d7695604c6a1f",class:"font-light"},"Login")),h("p",{key:"a6dded720da9db673173a1ff02bc5544e6a66d38",class:"text-green-800 dark:text-green-200 font-light text-center text-lg pt-2 max-w-96 mx-auto"},"Version: 1.7.11"),h("p",{key:"9d9dbd36ade753d30db448139dc057921f29697d",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},"Learn more about Nostr"," ",h("a",{key:"1811ad4f1acda7f5235566ea6f2ce8e70c62c91c",target:"_blank",href:"https://nostr.how"},"here"),".",h("br",{key:"127a6127e71f43caa1c262c6ec8108a5a6f40774"}),"This is an"," ",h("a",{key:"0e18839f8577229533eb2d2ef00f8657e6396aa1",target:"_blank",href:"https://github.com/nostrband/nostr-login"},"open-source")," ","tool by"," ",h("a",{key:"9affd14ad9dedae3e5d269a1477343eae63cd46b",target:"_blank",href:"https://nostr.band"},"Nostr.Band"),"."))}static get style(){return NlInfoStyle0}},[0,"nl-info"]);function defineCustomElement$k(){if("undefined"==typeof customElements)return;["nl-info"].forEach(e=>{if("nl-info"===e)customElements.get(e)||customElements.define(e,NlInfo)})}defineCustomElement$k();const nlInfoExtensionCss=baseCss,NlInfoExtensionStyle0=nlInfoExtensionCss,NlInfoExtension=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost()}render(){return h("div",{key:"9335feb745c6d09a213a2e771c40262036341b54",class:"p-4 overflow-y-auto"},state.isLoadingExtension?h("div",null,h("h1",{class:"nl-title font-bold text-center text-4xl"},"Signing in..."),h("div",{class:"mt-10 mb-10 ml-auto mr-auto w-20"},h("span",{slot:"icon-start",class:"animate-spin-loading ml-auto mr-auto inline-block w-20 h-20 border-[4px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"})),h("div",{class:"ps-4 pe-4 overflow-y-auto"},h("p",{class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error))):h("div",null,h("h1",{class:"nl-title font-bold text-center text-4xl"},"Install browser extension!"),h("p",{class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},"Try"," ",h("a",{href:"https://getalby.com",target:"_blank"},"Alby"),","," ",h("a",{href:"https://chromewebstore.google.com/detail/nos2x/kpgefcfmnafjgpblomihpgmejjdanjjp",target:"_blank"},"nos2x")," ","or"," ",h("a",{href:"https://apps.apple.com/us/app/nostore/id1666553677",target:"_blank"},"Nostore"))))}static get style(){return NlInfoExtensionStyle0}},[0,"nl-info-extension"]);function defineCustomElement$j(){if("undefined"==typeof customElements)return;["nl-info-extension"].forEach(e=>{if("nl-info-extension"===e)customElements.get(e)||customElements.define(e,NlInfoExtension)})}defineCustomElement$j();const nlLoadingCss=baseCss,NlLoadingStyle0=nlLoadingCss,NlLoading=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.stopFetchHandler=createEvent$1(this,"stopFetchHandler"),this.handleContinue=createEvent$1(this,"handleContinue"),this.path=void 0}handleStop(e){e.preventDefault(),this.stopFetchHandler.emit()}handleContinueClick(e){e.preventDefault(),this.handleContinue.emit()}render(){let e="Connecting...",t="Establishing connection to your key storage.";state.njumpIframe?(e="",t=""):this.path===CURRENT_MODULE.LOCAL_SIGNUP?(e="Creating...",t="Publishing your profile on Nostr."):state.authUrl&&(state.isLoading?(e="Confirming...",t="Please confirm the connection in your key storage app."):(e="Almost ready!",t="Continue to confirm the connection to your key storage."));const n=this.path!==CURRENT_MODULE.LOCAL_SIGNUP,r=!state.isLoading&&state.iframeUrl&&state.authUrl,i=state.iframeUrl?`${state.iframeUrl}?connect=${encodeURIComponent(state.authUrl)}`:"";return h("div",{key:"ff7ae663f31e7c0e10a0f10d45314519f08d5199",class:"p-4 overflow-y-auto"},e&&h("h1",{key:"86c13915dd489fd9182263edd47835cbe6c0c24a",class:"nl-title font-bold text-center text-4xl"},e),t&&h("p",{key:"23b2cc3700b833e0c4575c4b5833dce77b51af78",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},t),!state.njumpIframe&&!state.authUrl&&state.isLoading&&h("div",{key:"8f7da53775a410de55c26a706d70a5954ff3231c",class:"mt-10 mb-10 ml-auto mr-auto w-20"},h("span",{key:"15e94a6bf7a0a4471e2d4e6bd0bce5eb5cd3dc0a",slot:"icon-start",class:"animate-spin-loading ml-auto mr-auto inline-block w-20 h-20 border-[4px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"})),h("div",{key:"c32c535e64608e4d7bc11df9d0ee5360604ec9ea",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"73e123470d5d0466a2690cd9ba947663e550afda",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),i&&h("div",{key:"e6778c319037c8621aff5d34d1d2b3f0cbfc1c1e",class:"mt-3 ml-auto mr-auto w-72 flex justify-center"},h("iframe",{key:"d202f154ef014e96eae19e3f97432113a71127d4",src:i,width:"180px",height:"80px",style:{display:r?"block":"none",border:"0"}})),state.njumpIframe&&h("div",{key:"8fdc700c3983574930b14ea04448fb8123dfb83a",class:"mt-3 ml-auto mr-auto flex justify-center"},h("iframe",{key:"eafaf5df4a3ecbfba3d191c3e1b1c63181bdb41b",srcdoc:state.njumpIframe,width:"600px",style:{border:"0",height:"80vh",borderRadius:"8px"}})),!r&&n&&h("div",{key:"1557f1de773239d199e10249c45bc3684dee1773",class:"mt-3 ml-auto mr-auto w-72"},h("button-base",{key:"1f33346f69d5b2a670f0e507e48855376b82e679",onClick:e=>{state.authUrl&&!state.isLoading?this.handleContinueClick(e):this.handleStop(e)},titleBtn:state.isLoading?"Cancel":"Continue"})))}static get style(){return NlLoadingStyle0}},[0,"nl-loading",{path:[1]}]);function defineCustomElement$i(){if("undefined"==typeof customElements)return;["nl-loading","button-base"].forEach(e=>{switch(e){case"nl-loading":customElements.get(e)||customElements.define(e,NlLoading);break;case"button-base":customElements.get(e)||defineCustomElement$q()}})}defineCustomElement$i();const nlLocalSignupCss=baseCss,NlLocalSignupStyle0=nlLocalSignupCss,NlLocalSignup=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlLocalSignup=createEvent$1(this,"nlLocalSignup"),this.nlSignupNjump=createEvent$1(this,"nlSignupNjump"),this.fetchHandler=createEvent$1(this,"fetchHandler"),this.titleSignup="Create Nostr profile",this.description="Choose any username, you can always change it later.",this.descriptionNjump="Proceed to creating your Nostr profile in a new tab.",this.signupNjump=!1,this.isAvailable=!1}handleInputChange(e){state.nlSignup.signupName=e.target.value}handleCreateAccount(e){e.preventDefault(),this.signupNjump?this.nlSignupNjump.emit():this.nlLocalSignup.emit(`${state.nlSignup.signupName}`)}render(){return h(Fragment,{key:"6ea0144cad11803864f8d6b5bc7896d8d9b413cf"},h("div",{key:"be257a544937601e20521adac8ec98b46a6c8af5",class:"p-4 overflow-y-auto"},h("h1",{key:"c8e91ccc003d0a6e344010a41bb47eeec1abdbf0",class:"nl-title font-bold text-center text-2xl"},this.titleSignup),h("p",{key:"e71ee5aa6ac01059b63ee2245800c3659301ec06",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.signupNjump?this.descriptionNjump:this.description)),h("div",{key:"516c8c44b6936554b96151a4fe4a9b6af614b554",class:"max-w-72 mx-auto"},!this.signupNjump&&h("div",{key:"a74e48d36f120fe249abfd57131c2bfde7f3dce4",class:"relative mb-2"},h("input",{key:"b77730184df9033291010d4e8ead166be726e8d9",onInput:e=>this.handleInputChange(e),type:"text",class:"nl-input peer py-3 px-4 ps-11 block w-full border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent",placeholder:"Enter username",value:state.nlSignup.signupName}),h("div",{key:"cc061801a575391e879759c5873e8256fc68f547",class:"absolute inset-y-0 start-0 flex items-center pointer-events-none ps-4 peer-disabled:opacity-50 peer-disabled:pointer-events-none"},h("svg",{key:"909c6728e8f26012647a3c9b3de8f4b16ae31e80",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:this.isAvailable?"#00cc00":"currentColor",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{key:"0306f3c147c376bbd7b01b3e2eca178f339ac167","stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z"})))),h("div",{key:"77368eeb60108aeec228e83aa206ef2b2d3fa27a",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"e87a1ae66cfaf9a75cb723a29e57c5e0ff54aabd",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"99ce9506bf5db9c26d916314e1e5700bf515f1b7",disabled:state.isLoading,onClick:e=>this.handleCreateAccount(e),titleBtn:this.signupNjump?"Get started":"Create profile"},state.isLoading?h("span",{slot:"icon-start",class:"animate-spin-loading inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}):h("svg",{slot:"icon-start",style:{display:"none"},xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M18 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0ZM3 19.235v-.11a6.375 6.375 0 0 1 12.75 0v.109A12.318 12.318 0 0 1 9.374 21c-2.331 0-4.512-.645-6.374-1.766Z"})))))}static get style(){return NlLocalSignupStyle0}},[0,"nl-local-signup",{titleSignup:[1,"title-signup"],description:[1],descriptionNjump:[1,"description-njump"],signupNjump:[4,"signup-njump"],isAvailable:[32]}]);function defineCustomElement$h(){if("undefined"==typeof customElements)return;["nl-local-signup","button-base"].forEach(e=>{switch(e){case"nl-local-signup":customElements.get(e)||customElements.define(e,NlLocalSignup);break;case"button-base":customElements.get(e)||defineCustomElement$q()}})}defineCustomElement$h();const NlLoginStatus=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.info=void 0}render(){let e="",t="";if("extension"===this.info.authMethod)e="Extension",t="border-yellow-300 text-yellow-500 bg-yellow-100";else if("readOnly"===this.info.authMethod)e="Read only",t="border-gray-300 text-gray-400 bg-gray-100";else if("connect"===this.info.authMethod)e="Connect",t="border-teal-300 text-teal-600 bg-teal-100";else if("local"===this.info.authMethod)e="Temporary",t="border-red-300 text-red-600 bg-red-100";else{if("otp"!==this.info.authMethod)throw console.log("unknown auth method",this.info),new Error("Unknown auth method");e="Delegated",t="border-orange-300 text-orange-600 bg-orange-100"}return h("div",{key:"f0e9b20820467a4c427fa60bd1879e3ac7cc7f62"},h("span",{key:"4c96936eac7dbe558e398f9cff963873659f4aec",class:`${t} rounded-xl border w-auto text-[10px] px-1 `},e))}},[0,"nl-login-status",{info:[16]}]);function defineCustomElement$g(){if("undefined"==typeof customElements)return;["nl-login-status"].forEach(e=>{if("nl-login-status"===e)customElements.get(e)||customElements.define(e,NlLoginStatus)})}defineCustomElement$g();const nlOtpMigrateCss=baseCss,NlOtpMigrateStyle0=nlOtpMigrateCss,NlImportFlow=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlImportAccount=createEvent$1(this,"nlImportAccount"),this.titleInfo="Import keys to storage service",this.titleImport="Choose a service",this.textImport="You will be prompted to import keys to the chosen service, and this website will connect to your keys.",this.services=[]}handleDomainSelect(e){const t=this.services.find(t=>t.domain===e.detail);state.nlImport=t}handleCreateAccount(e){e.preventDefault(),this.nlImportAccount.emit(state.nlImport)}render(){const e=this.services.filter(e=>e.canImport).map(e=>({name:e.domain,value:e.domain}));return h(Fragment,{key:"8295d7fd819696a264100c3c1834a7e943f3f60e"},h("div",{key:"4d0e48726fccfe24be45db8ef328b25b4778763c",class:"p-4 overflow-y-auto"},h("h1",{key:"8a035ea913fa770188e62557971649a223fe7ed8",class:"nl-title font-bold text-center text-2xl"},this.titleImport),h("p",{key:"ad9c8565205acafeea8ab3991cc405ae84a6c95a",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.textImport)),h("div",{key:"7ee07d8ac0fc0278f342e794686126465b643278",class:"max-w-72 mx-auto mb-5"},h("div",{key:"677ca636b72bcefc6092e2e09b8c0ad445a956f6",class:"mb-0.5"},h("nl-select",{key:"8ec042faaa8319c0d683818cfa5321c20b2e6a57",onSelectDomain:e=>this.handleDomainSelect(e),selected:0,options:e})),h("p",{key:"d6348d95a65a003047e0961a9b8b86835bcebf1f",class:"nl-title font-light text-sm mb-2"},"Default provider is a fine choice to start with."),h("div",{key:"df09b9b23fd192407f797d8b191a30ca3a649142",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"77901d809985d421f9be1e7ff6e5263db52aa37f",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"87eb6648d8d5e4e4990f745c507bcaacddc6676a",disabled:state.isLoading,onClick:e=>this.handleCreateAccount(e),titleBtn:"Start importing"},state.isLoading?h("span",{slot:"icon-start",class:"animate-spin-loading inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}):h("svg",{slot:"icon-start",style:{display:"none"},xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M18 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0ZM3 19.235v-.11a6.375 6.375 0 0 1 12.75 0v.109A12.318 12.318 0 0 1 9.374 21c-2.331 0-4.512-.645-6.374-1.766Z"})))))}static get style(){return NlOtpMigrateStyle0}},[0,"nl-otp-migrate",{titleInfo:[1025,"title-info"],titleImport:[1,"title-import"],textImport:[1,"text-import"],services:[16]}]);function defineCustomElement$f(){if("undefined"==typeof customElements)return;["nl-otp-migrate","button-base","nl-select"].forEach(e=>{switch(e){case"nl-otp-migrate":customElements.get(e)||customElements.define(e,NlImportFlow);break;case"button-base":customElements.get(e)||defineCustomElement$q();break;case"nl-select":customElements.get(e)||defineCustomElement$m()}})}defineCustomElement$f();const nlPreviouslyLoggedCss=baseCss,NlPreviouslyLoggedStyle0=nlPreviouslyLoggedCss,NlPreviouslyLogged=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlSwitchAccount=createEvent$1(this,"nlSwitchAccount"),this.nlLoginRecentAccount=createEvent$1(this,"nlLoginRecentAccount"),this.nlRemoveRecent=createEvent$1(this,"nlRemoveRecent"),this.titlePage="Your profiles",this.description="Switch between active profiles or choose a recent one for fast login.",this.accounts=[],this.recents=[]}handleGoToWelcome(){state.path=[CURRENT_MODULE.WELCOME]}switchToWelcomeIfEmpty(){this.recents.length||this.accounts.length||(state.path=[CURRENT_MODULE.WELCOME])}watchAccounts(){this.switchToWelcomeIfEmpty()}watchRecents(){this.switchToWelcomeIfEmpty()}handleRemoveRecent(e){this.nlRemoveRecent.emit(e)}handleSwitch(e){this.nlSwitchAccount.emit(e)}handleLoginRecentAccount(e){this.nlLoginRecentAccount.emit(e)}render(){return h(Fragment,{key:"cd2b0c3c8949cf948e41ded42e7f75ef079fccc4"},h("div",{key:"32115943896e66bc20490610e26bd01f9e14457a",class:"p-4 pt-0 overflow-y-auto"},h("h1",{key:"a889d10b7704cdc080f48cde372f505896b456b6",class:"nl-title font-bold text-center text-4xl"},this.titlePage),h("p",{key:"030784a7a9b4366bd4dcf1755b470f2bfbdf4c14",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"a8c2afeeebc96527e1ca5b36cb3a2a544f6d50b4",class:"p-4"},Boolean(this.accounts.length)&&h("div",{key:"1f504e1448c1c60c9cf97eb5e18328d8935af54d",class:"max-w-96 mx-auto"},h("p",{key:"fed353027e7847653d869bef971229b6e862b6f3",class:"nl-description font-medium text-sm pb-1.5"},"Active profiles"),h("ul",{key:"d8aa546725b5248e180d88bb384521076eeb3a30",class:"p-2 rounded-lg border border-blue-200 flex flex-col w-full gap-0.5"},this.accounts.map(e=>{const t=Boolean(null==e?void 0:e.picture),n=e.name||e.nip05||e.pubkey,r=Boolean(n);return h("li",{onClick:()=>this.handleSwitch(e),class:"group hover:bg-gray-400 flex cursor-pointer gap-x-3.5 py-2 px-3 rounded-lg text-sm items-center justify-between"},h("div",{class:"flex items-center gap-x-3.5 w-full"},h("div",{class:"w-full max-w-7 h-7 flex relative"},h("div",{class:"absolute top-[-2px] right-[-2px] bg-white border-2 border-white rounded-xl"},h("div",{class:"active h-1.5 w-1.5 bg-green-500 rounded-xl"})),h("div",{class:"group-hover:border-blue-400 uppercase font-bold w-full h-full rounded-full border border-gray-400 flex justify-center items-center"},t?h("img",{class:"w-full rounded-full",src:e.picture,alt:"Logo"}):r?n[0]:h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-full"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})))),h("div",{class:"overflow-hidden flex flex-col w-full"},h("div",{class:"nl-title truncate overflow-hidden"},n),h("nl-login-status",{info:e}))))}))),Boolean(this.recents.length)&&h("div",{key:"15a0033a26712020d4cdc0665335047215dcb6fc",class:"max-w-96 mx-auto pt-5"},h("p",{key:"95d4c1270ebe75291b4ccb0b98ad8002a6e6d6b3",class:"nl-description font-medium text-sm pb-1.5"},"Recent profiles"),h("ul",{key:"9e126af579e621e51c9b3cc66585b0285c941e52",class:"p-2 rounded-lg border border-gray-200 flex flex-col w-full gap-0.5"},this.recents.map(e=>{const t=Boolean(null==e?void 0:e.picture),n=e.name||e.nip05||e.pubkey,r=Boolean(n);return h("li",{onClick:()=>this.handleLoginRecentAccount(e),class:"flex items-center gap-x-3.5 w-full hover:bg-gray-400 flex cursor-pointer items-center gap-x-3.5 py-2 px-3 rounded-lg text-sm justify-between"},h("div",{class:"w-full max-w-7 h-7 flex relative"},h("div",{class:"absolute top-[-3px] right-[-3px] bg-white border border-white rounded-xl"},h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-3 h-3"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}))),h("div",{class:"uppercase font-bold w-full h-full rounded-full border border-gray-400 flex justify-center items-center"},t?h("img",{class:"w-full rounded-full",src:e.picture,alt:"Logo"}):r?n[0]:h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-full"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})))),h("div",{class:"overflow-hidden flex flex-col w-full"},h("div",{class:"nl-title truncate overflow-hidden"},n),h("nl-login-status",{info:e})),h("svg",{onClick:t=>{t.stopPropagation(),this.handleRemoveRecent(e)},xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-full max-w-6 h-6 text-red-500 hover:text-red-600 ml-auto"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})))})))),h("div",{key:"4c1788fd1722ec954333fc024b502b56c397c5b8",class:"p-4 overflow-y-auto"},h("p",{key:"6f7ab030e88c3cb08b45533c465ab4dc4ca1cacb",class:"nl-footer font-light text-center text-sm max-w-96 mx-auto"},"You can also"," ",h("span",{key:"bf4e2b5222afab40c8098ebd22025596df85bf7f",onClick:()=>this.handleGoToWelcome(),class:"cursor-pointer pb-3 text-blue-500"},"add another profile"))))}static get watchers(){return{accounts:["watchAccounts"],recents:["watchRecents"]}}static get style(){return NlPreviouslyLoggedStyle0}},[0,"nl-previously-logged",{titlePage:[1,"title-page"],description:[1],accounts:[16],recents:[16]},void 0,{accounts:["watchAccounts"],recents:["watchRecents"]}]);function defineCustomElement$e(){if("undefined"==typeof customElements)return;["nl-previously-logged","nl-login-status"].forEach(e=>{switch(e){case"nl-previously-logged":customElements.get(e)||customElements.define(e,NlPreviouslyLogged);break;case"nl-login-status":customElements.get(e)||defineCustomElement$g()}})}defineCustomElement$e();const nlSigninCss=baseCss,NlSigninStyle0=nlSigninCss,NlSignin=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlLogin=createEvent$1(this,"nlLogin"),this.nlCheckLogin=createEvent$1(this,"nlCheckLogin"),this.titleLogin="Connect to key store",this.description="Please enter your user name.",this.isGood=!1}handleInputChange(e){state.nlSignin.loginName=e.target.value,this.nlCheckLogin.emit(e.target.value)}handleLogin(e){e.preventDefault(),this.nlLogin.emit(state.nlSignin.loginName)}render(){return h(Fragment,{key:"9375186e2638a4ec14c0fd6bd4954c68a6695d0a"},h("div",{key:"915342c0300b6ac7f6c5c84060117cf4b54c1bb2",class:"p-4 overflow-y-auto"},h("h1",{key:"c43f028b47c5ac566afda65cca1728fdade271a8",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h("p",{key:"d55111de6c8da0e06b957eb97fc66c3f25dd19a0",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"4105fbbe19bf83b1eb23d2b75bf936abc121db52",class:"max-w-72 mx-auto"},h("div",{key:"319964a6a9cdce3e2857a3722212f9f2c14a9657",class:"relative mb-2"},h("input",{key:"5016006907ecde3717f9ef32a04a5a93e5e8dd1c",onInput:e=>this.handleInputChange(e),type:"text",class:"nl-input peer py-3 px-4 ps-11 block w-full border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent",placeholder:"name@domain.com",value:state.nlSignin.loginName}),h("div",{key:"1a02c7e5b6ece79557e05c67f10fae224b3eab13",class:"absolute inset-y-0 start-0 flex items-center pointer-events-none ps-4 peer-disabled:opacity-50 peer-disabled:pointer-events-none"},h("svg",{key:"4ed7bc02af0383f5d378132df916a40eab90594d",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:this.isGood?"#00cc00":"currentColor",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{key:"f6d18366b44aaa84f72a7f4c8c6bc4de9d914254","stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z"})))),h("div",{key:"9325a0734cee2e749f8d0bd24177f0ae98031769",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"692b415ff9e06d6c79cd893bb01eadb6cc0dcaf6",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"b53079a6c2d6551ab18f9abe46d28bcfa3ee1e63",titleBtn:"Connect",disabled:state.isLoading,onClick:e=>this.handleLogin(e)},state.isLoading?h("span",{slot:"icon-start",class:"animate-spin-loading inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}):h("svg",{style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 9V5.25A2.25 2.25 0 0 1 10.5 3h6a2.25 2.25 0 0 1 2.25 2.25v13.5A2.25 2.25 0 0 1 16.5 21h-6a2.25 2.25 0 0 1-2.25-2.25V15M12 9l3 3m0 0-3 3m3-3H2.25"})))))}static get style(){return NlSigninStyle0}},[0,"nl-signin",{titleLogin:[1,"title-login"],description:[1],isGood:[32]}]);function defineCustomElement$d(){if("undefined"==typeof customElements)return;["nl-signin","button-base"].forEach(e=>{switch(e){case"nl-signin":customElements.get(e)||customElements.define(e,NlSignin);break;case"button-base":customElements.get(e)||defineCustomElement$q()}})}defineCustomElement$d();const nlSigninBunkerUrlCss=baseCss,NlSigninBunkerUrlStyle0=nlSigninBunkerUrlCss,NlSigninBunkerUrl=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlLogin=createEvent$1(this,"nlLogin"),this.nlCheckLogin=createEvent$1(this,"nlCheckLogin"),this.titleLogin="Connect with bunker url",this.description="Please enter a bunker url provided by key store.",this.isGood=!1}handleInputChange(e){state.nlSigninBunkerUrl.loginName=e.target.value,this.nlCheckLogin.emit(e.target.value)}handleLogin(e){e.preventDefault(),this.nlLogin.emit(state.nlSigninBunkerUrl.loginName)}render(){return h(Fragment,{key:"3a422253215916369f1c65894fd90e17732a735e"},h("div",{key:"ace79364c3c4c858b43746a5c5e05f925c78402b",class:"p-4 overflow-y-auto"},h("h1",{key:"1c7cdc50eff87cac91f4387b96f89109ca84f7cd",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h("p",{key:"dd25754386d05d8cc4035e29b9aa555de08756e1",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"1684b906cd07ec17d55db1f1f1aad37ba9b72121",class:"max-w-72 mx-auto"},h("div",{key:"ec6a77d2793a0e4ea383991ddcc593c8235e3443",class:"relative mb-2"},h("input",{key:"2f8440550f9db57b131556c5d4e88228cc2db277",onInput:e=>this.handleInputChange(e),type:"text",class:"nl-input peer py-3 px-4 ps-11 block w-full border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent",placeholder:"bunker://...",value:state.nlSigninBunkerUrl.loginName}),h("div",{key:"7718e520a18b35bdd89b6c4f835e01c304b9dcbb",class:"absolute inset-y-0 start-0 flex items-center pointer-events-none ps-4 peer-disabled:opacity-50 peer-disabled:pointer-events-none"},h("svg",{key:"f0c09de6a0cc3040cd7a52815e83318e270706b4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:this.isGood?"#00cc00":"currentColor",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{key:"93069f3407609c925ee8d14bea26245cf12afe9b","stroke-linecap":"round","stroke-linejoin":"round",d:"M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"})))),h("div",{key:"94a2a34d9275dbf6fa9819f71eb819f1fcffcdf0",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"9bfbaadcac84780014802805aa82ff8b079dd698",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"30534a179e1fbdfd3849de2b7d2dcc9b15351444",titleBtn:"Connect",disabled:state.isLoading,onClick:e=>this.handleLogin(e)},state.isLoading?h("span",{slot:"icon-start",class:"animate-spin-loading inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}):h("svg",{style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 9V5.25A2.25 2.25 0 0 1 10.5 3h6a2.25 2.25 0 0 1 2.25 2.25v13.5A2.25 2.25 0 0 1 16.5 21h-6a2.25 2.25 0 0 1-2.25-2.25V15M12 9l3 3m0 0-3 3m3-3H2.25"})))))}static get style(){return NlSigninBunkerUrlStyle0}},[0,"nl-signin-bunker-url",{titleLogin:[1,"title-login"],description:[1],isGood:[32]}]);function defineCustomElement$c(){if("undefined"==typeof customElements)return;["nl-signin-bunker-url","button-base"].forEach(e=>{switch(e){case"nl-signin-bunker-url":customElements.get(e)||customElements.define(e,NlSigninBunkerUrl);break;case"button-base":customElements.get(e)||defineCustomElement$q()}})}defineCustomElement$c();var browser$1={},canPromise$1=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then},qrcode={},utils$1$1={};let toSJISFunction;const CODEWORDS_COUNT=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];utils$1$1.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return 4*e+17},utils$1$1.getSymbolTotalCodewords=function(e){return CODEWORDS_COUNT[e]},utils$1$1.getBCHDigit=function(e){let t=0;for(;0!==e;)t++,e>>>=1;return t},utils$1$1.setToSJISFunction=function(e){if("function"!=typeof e)throw new Error('"toSJISFunc" is not a valid function.');toSJISFunction=e},utils$1$1.isKanjiModeEnabled=function(){return void 0!==toSJISFunction},utils$1$1.toSJIS=function(e){return toSJISFunction(e)};var errorCorrectionLevel={},exports$1;function BitBuffer$1(){this.buffer=[],this.length=0}exports$1=errorCorrectionLevel,exports$1.L={bit:1},exports$1.M={bit:0},exports$1.Q={bit:3},exports$1.H={bit:2},exports$1.isValid=function(e){return e&&void 0!==e.bit&&e.bit>=0&&e.bit<4},exports$1.from=function(e,t){if(exports$1.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return exports$1.L;case"m":case"medium":return exports$1.M;case"q":case"quartile":return exports$1.Q;case"h":case"high":return exports$1.H;default:throw new Error("Unknown EC Level: "+e)}}(e)}catch(e){return t}},BitBuffer$1.prototype={get:function(e){const t=Math.floor(e/8);return 1==(this.buffer[t]>>>7-e%8&1)},put:function(e,t){for(let n=0;n<t;n++)this.putBit(1==(e>>>t-n-1&1))},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var bitBuffer=BitBuffer$1;function BitMatrix$1(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}BitMatrix$1.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},BitMatrix$1.prototype.get=function(e,t){return this.data[e*this.size+t]},BitMatrix$1.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},BitMatrix$1.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var bitMatrix=BitMatrix$1,alignmentPattern={};!function(e){const t=utils$1$1.getSymbolSize;e.getRowColCoords=function(e){if(1===e)return[];const n=Math.floor(e/7)+2,r=t(e),i=145===r?26:2*Math.ceil((r-13)/(2*n-2)),s=[r-7];for(let e=1;e<n-1;e++)s[e]=s[e-1]-i;return s.push(6),s.reverse()},e.getPositions=function(t){const n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)0===e&&0===t||0===e&&t===i-1||e===i-1&&0===t||n.push([r[e],r[t]]);return n}}(alignmentPattern);var finderPattern={};const getSymbolSize=utils$1$1.getSymbolSize,FINDER_PATTERN_SIZE=7;finderPattern.getPositions=function(e){const t=getSymbolSize(e);return[[0,0],[t-FINDER_PATTERN_SIZE,0],[0,t-FINDER_PATTERN_SIZE]]};var maskPattern={};!function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t=3,n=3,r=40,i=10;function s(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}}e.isValid=function(e){return null!=e&&""!==e&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){const n=e.size;let r=0,i=0,s=0,o=null,a=null;for(let c=0;c<n;c++){i=s=0,o=a=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t+(i-5)),o=n,i=1),n=e.get(l,c),n===a?s++:(s>=5&&(r+=t+(s-5)),a=n,s=1)}i>=5&&(r+=t+(i-5)),s>=5&&(r+=t+(s-5))}return r},e.getPenaltyN2=function(e){const t=e.size;let r=0;for(let n=0;n<t-1;n++)for(let i=0;i<t-1;i++){const t=e.get(n,i)+e.get(n,i+1)+e.get(n+1,i)+e.get(n+1,i+1);4!==t&&0!==t||r++}return r*n},e.getPenaltyN3=function(e){const t=e.size;let n=0,i=0,s=0;for(let r=0;r<t;r++){i=s=0;for(let o=0;o<t;o++)i=i<<1&2047|e.get(r,o),o>=10&&(1488===i||93===i)&&n++,s=s<<1&2047|e.get(o,r),o>=10&&(1488===s||93===s)&&n++}return n*r},e.getPenaltyN4=function(e){let t=0;const n=e.data.length;for(let r=0;r<n;r++)t+=e.data[r];return Math.abs(Math.ceil(100*t/n/5)-10)*i},e.applyMask=function(e,t){const n=t.size;for(let r=0;r<n;r++)for(let i=0;i<n;i++)t.isReserved(i,r)||t.xor(i,r,s(e,i,r))},e.getBestMask=function(t,n){const r=Object.keys(e.Patterns).length;let i=0,s=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);const r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<s&&(s=r,i=o)}return i}}(maskPattern);var errorCorrectionCode={};const ECLevel$1=errorCorrectionLevel,EC_BLOCKS_TABLE=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],EC_CODEWORDS_TABLE=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];errorCorrectionCode.getBlocksCount=function(e,t){switch(t){case ECLevel$1.L:return EC_BLOCKS_TABLE[4*(e-1)+0];case ECLevel$1.M:return EC_BLOCKS_TABLE[4*(e-1)+1];case ECLevel$1.Q:return EC_BLOCKS_TABLE[4*(e-1)+2];case ECLevel$1.H:return EC_BLOCKS_TABLE[4*(e-1)+3];default:return}},errorCorrectionCode.getTotalCodewordsCount=function(e,t){switch(t){case ECLevel$1.L:return EC_CODEWORDS_TABLE[4*(e-1)+0];case ECLevel$1.M:return EC_CODEWORDS_TABLE[4*(e-1)+1];case ECLevel$1.Q:return EC_CODEWORDS_TABLE[4*(e-1)+2];case ECLevel$1.H:return EC_CODEWORDS_TABLE[4*(e-1)+3];default:return}};var polynomial={},galoisField={};const EXP_TABLE=new Uint8Array(512),LOG_TABLE=new Uint8Array(256);!function(){let e=1;for(let t=0;t<255;t++)EXP_TABLE[t]=e,LOG_TABLE[e]=t,e<<=1,256&e&&(e^=285);for(let e=255;e<512;e++)EXP_TABLE[e]=EXP_TABLE[e-255]}(),galoisField.log=function(e){if(e<1)throw new Error("log("+e+")");return LOG_TABLE[e]},galoisField.exp=function(e){return EXP_TABLE[e]},galoisField.mul=function(e,t){return 0===e||0===t?0:EXP_TABLE[LOG_TABLE[e]+LOG_TABLE[t]]},function(e){const t=galoisField;e.mul=function(e,n){const r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let s=0;s<n.length;s++)r[i+s]^=t.mul(e[i],n[s]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){const e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&0===r[i];)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}}(polynomial);const Polynomial=polynomial;function ReedSolomonEncoder$1(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}ReedSolomonEncoder$1.prototype.initialize=function(e){this.degree=e,this.genPoly=Polynomial.generateECPolynomial(this.degree)},ReedSolomonEncoder$1.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");const t=new Uint8Array(e.length+this.degree);t.set(e);const n=Polynomial.mod(t,this.genPoly),r=this.degree-n.length;if(r>0){const e=new Uint8Array(this.degree);return e.set(n,r),e}return n};var reedSolomonEncoder=ReedSolomonEncoder$1,version={},mode={},versionCheck={isValid:function(e){return!isNaN(e)&&e>=1&&e<=40}},regex$2={};const numeric="[0-9]+",alphanumeric="[A-Z $%*+\\-./:]+";let kanji="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";kanji=kanji.replace(/u/g,"\\u");const byte="(?:(?![A-Z0-9 $%*+\\-./:]|"+kanji+")(?:.|[\r\n]))+";regex$2.KANJI=new RegExp(kanji,"g"),regex$2.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),regex$2.BYTE=new RegExp(byte,"g"),regex$2.NUMERIC=new RegExp(numeric,"g"),regex$2.ALPHANUMERIC=new RegExp(alphanumeric,"g");const TEST_KANJI=new RegExp("^"+kanji+"$"),TEST_NUMERIC=new RegExp("^"+numeric+"$"),TEST_ALPHANUMERIC=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");regex$2.testKanji=function(e){return TEST_KANJI.test(e)},regex$2.testNumeric=function(e){return TEST_NUMERIC.test(e)},regex$2.testAlphanumeric=function(e){return TEST_ALPHANUMERIC.test(e)},function(e){const t=versionCheck,n=regex$2;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!t.isValid(n))throw new Error("Invalid version: "+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")},e.isValid=function(e){return e&&e.bit&&e.ccBits},e.from=function(t,n){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+t)}}(t)}catch(e){return n}}}(mode),function(e){const t=utils$1$1,n=errorCorrectionCode,r=errorCorrectionLevel,i=mode,s=versionCheck,o=t.getBCHDigit(7973);function a(e,t){return i.getCharCountIndicator(e,t)+4}function c(e,t){let n=0;return e.forEach(function(e){const r=a(e.mode,t);n+=r+e.getBitsLength()}),n}e.from=function(e,t){return s.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!s.isValid(e))throw new Error("Invalid QR Code version");void 0===o&&(o=i.BYTE);const c=8*(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r));if(o===i.MIXED)return c;const l=c-a(o,e);switch(o){case i.NUMERIC:return Math.floor(l/10*3);case i.ALPHANUMERIC:return Math.floor(l/11*2);case i.KANJI:return Math.floor(l/13);case i.BYTE:default:return Math.floor(l/8)}},e.getBestVersionForData=function(t,n){let s;const o=r.from(n,r.M);if(Array.isArray(t)){if(t.length>1)return function(t,n){for(let r=1;r<=40;r++)if(c(t,r)<=e.getCapacity(r,n,i.MIXED))return r}(t,o);if(0===t.length)return 1;s=t[0]}else s=t;return function(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}(s.mode,s.getLength(),o)},e.getEncodedBits=function(e){if(!s.isValid(e)||e<7)throw new Error("Invalid QR Code version");let n=e<<12;for(;t.getBCHDigit(n)-o>=0;)n^=7973<<t.getBCHDigit(n)-o;return e<<12|n}}(version);var formatInfo={};const Utils$3=utils$1$1,G15=1335,G15_MASK=21522,G15_BCH=Utils$3.getBCHDigit(G15);formatInfo.getEncodedBits=function(e,t){const n=e.bit<<3|t;let r=n<<10;for(;Utils$3.getBCHDigit(r)-G15_BCH>=0;)r^=G15<<Utils$3.getBCHDigit(r)-G15_BCH;return(n<<10|r)^G15_MASK};var segments={};const Mode$4=mode;function NumericData(e){this.mode=Mode$4.NUMERIC,this.data=e.toString()}NumericData.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},NumericData.prototype.getLength=function(){return this.data.length},NumericData.prototype.getBitsLength=function(){return NumericData.getBitsLength(this.data.length)},NumericData.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);const i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,3*i+1))};var numericData=NumericData;const Mode$3=mode,ALPHA_NUM_CHARS=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function AlphanumericData(e){this.mode=Mode$3.ALPHANUMERIC,this.data=e}AlphanumericData.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},AlphanumericData.prototype.getLength=function(){return this.data.length},AlphanumericData.prototype.getBitsLength=function(){return AlphanumericData.getBitsLength(this.data.length)},AlphanumericData.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=45*ALPHA_NUM_CHARS.indexOf(this.data[t]);n+=ALPHA_NUM_CHARS.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(ALPHA_NUM_CHARS.indexOf(this.data[t]),6)};var alphanumericData=AlphanumericData;const Mode$2=mode;function ByteData(e){this.mode=Mode$2.BYTE,this.data="string"==typeof e?(new TextEncoder).encode(e):new Uint8Array(e)}ByteData.getBitsLength=function(e){return 8*e},ByteData.prototype.getLength=function(){return this.data.length},ByteData.prototype.getBitsLength=function(){return ByteData.getBitsLength(this.data.length)},ByteData.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var byteData=ByteData;const Mode$1=mode,Utils$2=utils$1$1;function KanjiData(e){this.mode=Mode$1.KANJI,this.data=e}KanjiData.getBitsLength=function(e){return 13*e},KanjiData.prototype.getLength=function(){return this.data.length},KanjiData.prototype.getBitsLength=function(){return KanjiData.getBitsLength(this.data.length)},KanjiData.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=Utils$2.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[t]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),e.put(n,13)}};var kanjiData=KanjiData,dijkstra={exports:{}};!function(e){var t={single_source_shortest_paths:function(e,n,r){var i={},s={};s[n]=0;var o,a,c,l,h,d,u,f=t.PriorityQueue.make();for(f.push(n,0);!f.empty();)for(c in a=(o=f.pop()).value,l=o.cost,h=e[a]||{})h.hasOwnProperty(c)&&(d=l+h[c],u=s[c],(void 0===s[c]||u>d)&&(s[c]=d,f.push(c,d),i[c]=a));if(void 0!==r&&void 0===s[r]){var p=["Could not find a path from ",n," to ",r,"."].join("");throw new Error(p)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),r=e[r];return n.reverse(),n},find_path:function(e,n,r){var i=t.single_source_shortest_paths(e,n,r);return t.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var n,r=t.PriorityQueue,i={};for(n in e=e||{},r)r.hasOwnProperty(n)&&(i[n]=r[n]);return i.queue=[],i.sorter=e.sorter||r.default_sorter,i},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};e.exports=t}(dijkstra),function(e){const t=mode,n=numericData,r=alphanumericData,i=byteData,s=kanjiData,o=regex$2,a=utils$1$1,c=dijkstra.exports;function l(e){return unescape(encodeURIComponent(e)).length}function h(e,t,n){const r=[];let i;for(;null!==(i=e.exec(n));)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){const n=h(o.NUMERIC,t.NUMERIC,e),r=h(o.ALPHANUMERIC,t.ALPHANUMERIC,e);let i,s;a.isKanjiModeEnabled()?(i=h(o.BYTE,t.BYTE,e),s=h(o.KANJI,t.KANJI,e)):(i=h(o.BYTE_KANJI,t.BYTE,e),s=[]);return n.concat(r,i,s).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function u(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return s.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function f(e,o){let c;const l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw new Error('"'+e+'" cannot be encoded with mode '+t.toString(c)+".\n Suggested mode is: "+t.toString(l));switch(c!==t.KANJI||a.isKanjiModeEnabled()||(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new s(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return"string"==typeof t?e.push(f(t,null)):t.data&&e.push(f(t.data,t.mode)),e},[])},e.fromString=function(n,r){const i=function(e){const n=[];for(let r=0;r<e.length;r++){const i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}(d(n,a.isKanjiModeEnabled())),s=function(e,n){const r={},i={start:{}};let s=["start"];for(let o=0;o<e.length;o++){const a=e[o],c=[];for(let e=0;e<a.length;e++){const l=a[e],h=""+o+e;c.push(h),r[h]={node:l,lastCount:0},i[h]={};for(let e=0;e<s.length;e++){const o=s[e];r[o]&&r[o].node.mode===l.mode?(i[o][h]=u(r[o].lastCount+l.length,l.mode)-u(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][h]=u(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}s=c}for(let e=0;e<s.length;e++)i[s[e]].end=0;return{map:i,table:r}}(i,r),o=c.find_path(s.map,"start","end"),h=[];for(let e=1;e<o.length-1;e++)h.push(s.table[o[e]].node);return e.fromArray(function(e){return e.reduce(function(e,t){const n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}(h))},e.rawSplit=function(t){return e.fromArray(d(t,a.isKanjiModeEnabled()))}}(segments);const Utils$1=utils$1$1,ECLevel=errorCorrectionLevel,BitBuffer=bitBuffer,BitMatrix=bitMatrix,AlignmentPattern=alignmentPattern,FinderPattern=finderPattern,MaskPattern=maskPattern,ECCode=errorCorrectionCode,ReedSolomonEncoder=reedSolomonEncoder,Version=version,FormatInfo=formatInfo,Mode$5=mode,Segments=segments;function setupFinderPattern(e,t){const n=e.size,r=FinderPattern.getPositions(t);for(let t=0;t<r.length;t++){const i=r[t][0],s=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)s+r<=-1||n<=s+r||(t>=0&&t<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===t||6===t)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,s+r,!0,!0):e.set(i+t,s+r,!1,!0))}}function setupTimingPattern(e){const t=e.size;for(let n=8;n<t-8;n++){const t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function setupAlignmentPattern(e,t){const n=AlignmentPattern.getPositions(t);for(let t=0;t<n.length;t++){const r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)-2===t||2===t||-2===n||2===n||0===t&&0===n?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function setupVersionInfo(e,t){const n=e.size,r=Version.getEncodedBits(t);let i,s,o;for(let t=0;t<18;t++)i=Math.floor(t/3),s=t%3+n-8-3,o=1==(r>>t&1),e.set(i,s,o,!0),e.set(s,i,o,!0)}function setupFormatInfo(e,t,n){const r=e.size,i=FormatInfo.getEncodedBits(t,n);let s,o;for(s=0;s<15;s++)o=1==(i>>s&1),s<6?e.set(s,8,o,!0):s<8?e.set(s+1,8,o,!0):e.set(r-15+s,8,o,!0),s<8?e.set(8,r-s-1,o,!0):s<9?e.set(8,15-s-1+1,o,!0):e.set(8,15-s-1,o,!0);e.set(r-8,8,1,!0)}function setupData(e,t){const n=e.size;let r=-1,i=n-1,s=7,o=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,a-n)){let r=!1;o<t.length&&(r=1==(t[o]>>>s&1)),e.set(i,a-n,r),s--,-1===s&&(o++,s=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function createData(e,t,n){const r=new BitBuffer;n.forEach(function(t){r.put(t.mode.bit,4),r.put(t.getLength(),Mode$5.getCharCountIndicator(t.mode,e)),t.write(r)});const i=8*(Utils$1.getSymbolTotalCodewords(e)-ECCode.getTotalCodewordsCount(e,t));for(r.getLengthInBits()+4<=i&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(0);const s=(i-r.getLengthInBits())/8;for(let e=0;e<s;e++)r.put(e%2?17:236,8);return createCodewords(r,e,t)}function createCodewords(e,t,n){const r=Utils$1.getSymbolTotalCodewords(t),i=r-ECCode.getTotalCodewordsCount(t,n),s=ECCode.getBlocksCount(t,n),o=s-r%s,a=Math.floor(r/s),c=Math.floor(i/s),l=c+1,h=a-c,d=new ReedSolomonEncoder(h);let u=0;const f=new Array(s),p=new Array(s);let g=0;const y=new Uint8Array(e.buffer);for(let e=0;e<s;e++){const t=e<o?c:l;f[e]=y.slice(u,u+t),p[e]=d.encode(f[e]),u+=t,g=Math.max(g,t)}const m=new Uint8Array(r);let b,w,v=0;for(b=0;b<g;b++)for(w=0;w<s;w++)b<f[w].length&&(m[v++]=f[w][b]);for(b=0;b<h;b++)for(w=0;w<s;w++)m[v++]=p[w][b];return m}function createSymbol(e,t,n,r){let i;if(Array.isArray(e))i=Segments.fromArray(e);else{if("string"!=typeof e)throw new Error("Invalid data");{let r=t;if(!r){const t=Segments.rawSplit(e);r=Version.getBestVersionForData(t,n)}i=Segments.fromString(e,r||40)}}const s=Version.getBestVersionForData(i,n);if(!s)throw new Error("The amount of data is too big to be stored in a QR Code");if(t){if(t<s)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+s+".\n")}else t=s;const o=createData(t,n,i),a=Utils$1.getSymbolSize(t),c=new BitMatrix(a);return setupFinderPattern(c,t),setupTimingPattern(c),setupAlignmentPattern(c,t),setupFormatInfo(c,n,0),t>=7&&setupVersionInfo(c,t),setupData(c,o),isNaN(r)&&(r=MaskPattern.getBestMask(c,setupFormatInfo.bind(null,c,n))),MaskPattern.applyMask(r,c),setupFormatInfo(c,n,r),{modules:c,version:t,errorCorrectionLevel:n,maskPattern:r,segments:i}}qrcode.create=function(e,t){if(void 0===e||""===e)throw new Error("No input text");let n,r,i=ECLevel.M;return void 0!==t&&(i=ECLevel.from(t.errorCorrectionLevel,ECLevel.M),n=Version.from(t.version),r=MaskPattern.from(t.maskPattern),t.toSJISFunc&&Utils$1.setToSJISFunction(t.toSJISFunc)),createSymbol(e,n,i,r)};var canvas={},utils$4={};!function(e){function t(e){if("number"==typeof e&&(e=e.toString()),"string"!=typeof e)throw new Error("Color should be defined as hex string");let t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw new Error("Invalid hex color: "+e);3!==t.length&&4!==t.length||(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),6===t.length&&t.push("F","F");const n=parseInt(t.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+t.slice(0,6).join("")}}e.getOptions=function(e){e||(e={}),e.color||(e.color={});const n=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||"#000000ff"),light:t(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},e.getImageWidth=function(t,n){const r=e.getScale(t,n);return Math.floor((t+2*n.margin)*r)},e.qrToImageData=function(t,n,r){const i=n.modules.size,s=n.modules.data,o=e.getScale(i,r),a=Math.floor((i+2*r.margin)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<a;e++)for(let n=0;n<a;n++){let h=4*(e*a+n),d=r.color.light;if(e>=c&&n>=c&&e<a-c&&n<a-c){d=l[s[Math.floor((e-c)/o)*i+Math.floor((n-c)/o)]?1:0]}t[h++]=d.r,t[h++]=d.g,t[h++]=d.b,t[h]=d.a}}}(utils$4),function(e){const t=utils$4;e.render=function(e,n,r){let i=r,s=n;void 0!==i||n&&n.getContext||(i=n,n=void 0),n||(s=function(){try{return document.createElement("canvas")}catch(e){throw new Error("You need to specify a canvas element")}}()),i=t.getOptions(i);const o=t.getImageWidth(e.modules.size,i),a=s.getContext("2d"),c=a.createImageData(o,o);return t.qrToImageData(c.data,e,i),function(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.height=n,t.width=n,t.style.height=n+"px",t.style.width=n+"px"}(a,s,o),a.putImageData(c,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;void 0!==i||n&&n.getContext||(i=n,n=void 0),i||(i={});const s=e.render(t,n,i),o=i.type||"image/png",a=i.rendererOpts||{};return s.toDataURL(o,a.quality)}}(canvas);var svgTag={};const Utils=utils$4;function getColorAttrib(e,t){const n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function svgCmd(e,t,n){let r=e+t;return void 0!==n&&(r+=" "+n),r}function qrToPath(e,t,n){let r="",i=0,s=!1,o=0;for(let a=0;a<e.length;a++){const c=Math.floor(a%t),l=Math.floor(a/t);c||s||(s=!0),e[a]?(o++,a>0&&c>0&&e[a-1]||(r+=s?svgCmd("M",c+n,.5+l+n):svgCmd("m",i,0),i=0,s=!1),c+1<t&&e[a+1]||(r+=svgCmd("h",o),o=0)):i++}return r}svgTag.render=function(e,t,n){const r=Utils.getOptions(t),i=e.modules.size,s=e.modules.data,o=i+2*r.margin,a=r.color.light.a?"<path "+getColorAttrib(r.color.light,"fill")+' d="M0 0h'+o+"v"+o+'H0z"/>':"",c="<path "+getColorAttrib(r.color.dark,"stroke")+' d="'+qrToPath(s,i,r.margin)+'"/>',l='viewBox="0 0 '+o+" "+o+'"',h='<svg xmlns="http://www.w3.org/2000/svg" '+(r.width?'width="'+r.width+'" height="'+r.width+'" ':"")+l+' shape-rendering="crispEdges">'+a+c+"</svg>\n";return"function"==typeof n&&n(null,h),h};const canPromise=canPromise$1,QRCode=qrcode,CanvasRenderer=canvas,SvgRenderer=svgTag;function renderCanvas(e,t,n,r,i){const s=[].slice.call(arguments,1),o=s.length,a="function"==typeof s[o-1];if(!a&&!canPromise())throw new Error("Callback required as last argument");if(!a){if(o<1)throw new Error("Too few arguments provided");return 1===o?(n=t,t=r=void 0):2!==o||t.getContext||(r=n,n=t,t=void 0),new Promise(function(i,s){try{const s=QRCode.create(n,r);i(e(s,t,r))}catch(e){s(e)}})}if(o<2)throw new Error("Too few arguments provided");2===o?(i=n,n=t,t=r=void 0):3===o&&(t.getContext&&void 0===i?(i=r,r=void 0):(i=r,r=n,n=t,t=void 0));try{const s=QRCode.create(n,r);i(null,e(s,t,r))}catch(e){i(e)}}browser$1.create=QRCode.create,browser$1.toCanvas=renderCanvas.bind(null,CanvasRenderer.render),browser$1.toDataURL=renderCanvas.bind(null,CanvasRenderer.renderToDataURL),browser$1.toString=renderCanvas.bind(null,function(e,t,n){return SvgRenderer.render(e,n)});const nlSigninConnectionStringCss=baseCss,NlSigninConnectionStringStyle0=nlSigninConnectionStringCss,NlSigninConnectionString=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlNostrConnectDefault=createEvent$1(this,"nlNostrConnectDefault"),this.titleLogin="Connection string",this.description="Scan or copy the connection string with key store app",this.connectionString="",this.isCopy=!1}componentDidLoad(){this.nlNostrConnectDefault.emit(),this.generateQRCode()}async generateQRCode(){if(this.connectionString&&this.canvasElement)try{await browser$1.toCanvas(this.canvasElement,this.connectionString)}catch(e){console.error("Error generating QR Code:",e)}}async copyToClipboard(){try{await navigator.clipboard.writeText(this.connectionString),this.isCopy=!0,setTimeout(()=>{this.isCopy=!1},1500)}catch(e){console.error("Failed to copy connectionString: ",e)}}render(){return h(Fragment,{key:"9e20dbd8f95690337ccab2aad02aeecc12fe6534"},h("div",{key:"fcfcc5448dae58c119375f42d2183e536c31b7fd",class:"p-4 overflow-y-auto"},h("h1",{key:"efd74afef7798a7cc1d31104f48b5ccdf2ce9084",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h("p",{key:"39c6d7154037338efba5ba4443adc7b2ba8214f7",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h("canvas",{key:"0243600d2c4720b74ed733b9fdbd3f0fe7d336e8",class:"mx-auto mb-2",ref:e=>this.canvasElement=e}),h("div",{key:"44b629d494394d9213fa9ca4610b1339ce28eed6",class:"px-4"},h("div",{key:"2a3898b77f6c9b9569c42a514556eb1ac7eab25e",class:"max-w-72 mx-auto"},h("div",{key:"0cab83e4b918a3d93ba5a150c88f251a3c7aad02",class:"relative mb-2"},h("input",{key:"bb0d74e79dd801a318025f50c55a27bc4ca46b24",type:"text",class:"nl-input peer py-3 px-4 pe-11 ps-11 block w-full border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent",placeholder:"npub or name@domain",value:this.connectionString,disabled:!0}),h("div",{key:"646c7de454027c53b3ba7961e8dd84da34003e8b",class:"absolute inset-y-0 start-0 flex items-center pointer-events-none ps-4 peer-disabled:opacity-50 peer-disabled:pointer-events-none"},h("svg",{key:"235f51d1d29644ddc3d0b6bd4fbf703280c682d5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{key:"d2f9f1d2c4c8ad459780016104ad3096a6b2bac6","stroke-linecap":"round","stroke-linejoin":"round",d:"M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"}),h("path",{key:"fc00b8344aa02d311103947bf1199df3447a1b8a","stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"}))),this.isCopy?h("div",{class:"absolute inset-y-0 end-0 flex items-center p-2 rounded-lg"},h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"#00cc00",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}))):h("div",{class:"absolute inset-y-0 end-0 flex items-center cursor-pointer p-2 rounded-lg",onClick:()=>this.copyToClipboard()},h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M16.5 8.25V6a2.25 2.25 0 0 0-2.25-2.25H6A2.25 2.25 0 0 0 3.75 6v8.25A2.25 2.25 0 0 0 6 16.5h2.25m8.25-8.25H18a2.25 2.25 0 0 1 2.25 2.25V18A2.25 2.25 0 0 1 18 20.25h-7.5A2.25 2.25 0 0 1 8.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 0 0-2.25 2.25v6"})))),h("div",{key:"1e454d90b8df857894adfc03f08a6aa96913c251",class:"mt-10 justify-center items-center flex gap-2"},h("span",{key:"8b003638e347f886377e595db7fc23616067ee52",slot:"icon-start",class:"animate-spin-loading inline-block w-[20px] h-[20px] border-[2px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}),h("span",{key:"5543d1eb3f1a8247e10219410aff9d77e5f527fd",class:"nl-footer"},"Waiting for connection")))))}static get style(){return NlSigninConnectionStringStyle0}},[0,"nl-signin-connection-string",{titleLogin:[1,"title-login"],description:[1],connectionString:[1,"connection-string"],isCopy:[32]}]);function defineCustomElement$b(){if("undefined"==typeof customElements)return;["nl-signin-connection-string"].forEach(e=>{if("nl-signin-connection-string"===e)customElements.get(e)||customElements.define(e,NlSigninConnectionString)})}defineCustomElement$b();const nlSigninOtpCss=baseCss,NlSigninOtpStyle0=nlSigninOtpCss,NlSigninOtp=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlLoginOTPUser=createEvent$1(this,"nlLoginOTPUser"),this.nlLoginOTPCode=createEvent$1(this,"nlLoginOTPCode"),this.nlCheckLogin=createEvent$1(this,"nlCheckLogin"),this.titleLogin="Log in with DM",this.description="Please enter your user name or npub, and we will send you a direct message with a one-time code.",this.titleLoginOTP="Enter the code",this.descriptionOTP="Please enter the one-time code we sent to you as a direct message on Nostr.",this.isGood=!1}handleInputChange(e){state.isOTP?state.nlSigninOTP.code=e.target.value:(state.nlSigninOTP.loginName=e.target.value,this.nlCheckLogin.emit(state.nlSigninOTP.loginName))}handleLogin(e){e.preventDefault(),state.isOTP?this.nlLoginOTPCode.emit(state.nlSigninOTP.code):this.nlLoginOTPUser.emit(state.nlSigninOTP.loginName)}render(){return h(Fragment,{key:"908b593238b5fa1b577cee0a8149e013a2cd4e81"},h("div",{key:"2d57c60631a906fc566d5f1f76cdac11773436c5",class:"p-4 overflow-y-auto"},h("h1",{key:"b08c82e952dbc3af15e25c48f318677a68f46d19",class:"nl-title font-bold text-center text-2xl"},state.isOTP?this.titleLoginOTP:this.titleLogin),h("p",{key:"64f6ec549cd2fc9c4b3672c5463d183d9626c20b",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},state.isOTP?this.descriptionOTP:this.description)),h("div",{key:"5e9bf1ba4a6a72788f605ef44f98cdafeb67e0d0",class:"max-w-72 mx-auto"},h("div",{key:"3986a554e56c5457abf19162ecdafe0cc72ceade",class:"relative mb-2"},h("input",{key:"139d115f54a0253fac37eb6bbbba5f00cec6e3b6",onInput:e=>this.handleInputChange(e),type:"text",class:"nl-input peer py-3 px-4 ps-11 block w-full border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent",placeholder:state.isOTP?"code from direct message":"npub or name@domain",value:state.isOTP?state.nlSigninOTP.code:state.nlSigninOTP.loginName}),h("div",{key:"bae2734dbce11c6c9a9f59b2ba1a57841213e8f0",class:"absolute inset-y-0 start-0 flex items-center pointer-events-none ps-4 peer-disabled:opacity-50 peer-disabled:pointer-events-none"},h("svg",{key:"8dc6fc177553d183873eae6c4ef31509d45c5784",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:this.isGood?"#00cc00":"currentColor",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{key:"dd9d07329ee6ae0491c009adffc673cf6a4103d3","stroke-linecap":"round","stroke-linejoin":"round",d:"M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"}),h("path",{key:"0357daa2fb59eb3c2cbaf62e49d69e42dde16b85","stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})))),h("div",{key:"91a36d9e0420b28eca1edcd1ec8759c25b2d51b3",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"e462b623f95c800d1589d3eef07d2216b70bdd64",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"c6b89e573097ac7d40c0648a2e87222d48e72b40",titleBtn:"Log in",disabled:state.isLoading,onClick:e=>this.handleLogin(e)},state.isLoading&&h("span",{key:"0be64571f00987f716e986af9cb043e3eb22b796",slot:"icon-start",class:"animate-spin-loading inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}))))}static get style(){return NlSigninOtpStyle0}},[0,"nl-signin-otp",{titleLogin:[1,"title-login"],description:[1],titleLoginOTP:[1,"title-login-o-t-p"],descriptionOTP:[1,"description-o-t-p"],isGood:[32]}]);function defineCustomElement$a(){if("undefined"==typeof customElements)return;["nl-signin-otp","button-base"].forEach(e=>{switch(e){case"nl-signin-otp":customElements.get(e)||customElements.define(e,NlSigninOtp);break;case"button-base":customElements.get(e)||defineCustomElement$q()}})}defineCustomElement$a();const nlSigninReadOnlyCss=baseCss,NlSigninReadOnlyStyle0=nlSigninReadOnlyCss,NlSigninReadOnly=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlLoginReadOnly=createEvent$1(this,"nlLoginReadOnly"),this.nlCheckLogin=createEvent$1(this,"nlCheckLogin"),this.titleLogin="Log in to read only",this.description="Please enter the user name or npub of any Nostr user.",this.isGood=!1}handleInputChange(e){state.nlSigninReadOnly.loginName=e.target.value,this.nlCheckLogin.emit(e.target.value)}handleLogin(e){e.preventDefault(),this.nlLoginReadOnly.emit(state.nlSigninReadOnly.loginName)}render(){return h(Fragment,{key:"5333cc7e682b148d2b2c9d3756c9fa561a9a3e86"},h("div",{key:"ed025d719382b9b4ac11a24d3814419a6f51c774",class:"p-4 overflow-y-auto"},h("h1",{key:"8b8c0c1e839b3db4529e1c6acc8ef18e29a7abee",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h("p",{key:"36f9334b55aea6c5e46bc6e143388b757a6be867",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"3197bd6ac9835cdb4a9b64ff0dea262ddb92ef13",class:"max-w-72 mx-auto"},h("div",{key:"f804f5111ac8f9aaa17b404c22d58ea875273382",class:"relative mb-2"},h("input",{key:"7828eb7e49e92a0578a73439ae16de63caa57597",onInput:e=>this.handleInputChange(e),type:"text",class:"nl-input peer py-3 px-4 ps-11 block w-full border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent",placeholder:"npub or name@domain",value:state.nlSigninReadOnly.loginName}),h("div",{key:"1557e4f05bac2eefc05e22806cb0024e5430c7f4",class:"absolute inset-y-0 start-0 flex items-center pointer-events-none ps-4 peer-disabled:opacity-50 peer-disabled:pointer-events-none"},h("svg",{key:"dfd2f9eeb07d815807bdb4885680001d3d5a1a2c",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:this.isGood?"#00cc00":"currentColor",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{key:"beb199e08cbb0d385314e4a3fcb521bbc05e7d2d","stroke-linecap":"round","stroke-linejoin":"round",d:"M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"}),h("path",{key:"988fe07d787ff2fbb15c620681b2996fcd0ff382","stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})))),h("div",{key:"652f082e184f5d871629f8054a2474c80adddf4b",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"5583f0eb95400902d72728989f32c3afaf31fc77",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"e708d09f4e1625af23d8f432c8523662ad1c82dd",titleBtn:"Log in",disabled:state.isLoading,onClick:e=>this.handleLogin(e)},state.isLoading&&h("span",{key:"5422a05cd6a2b0309fd78f95bf89b0ff03ab69e9",slot:"icon-start",class:"animate-spin-loading inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}))))}static get style(){return NlSigninReadOnlyStyle0}},[0,"nl-signin-read-only",{titleLogin:[1,"title-login"],description:[1],isGood:[32]}]);function defineCustomElement$9(){if("undefined"==typeof customElements)return;["nl-signin-read-only","button-base"].forEach(e=>{switch(e){case"nl-signin-read-only":customElements.get(e)||customElements.define(e,NlSigninReadOnly);break;case"button-base":customElements.get(e)||defineCustomElement$q()}})}defineCustomElement$9();const nlSignupCss=baseCss,NlSignupStyle0=nlSignupCss,NlSignup=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlSignup=createEvent$1(this,"nlSignup"),this.nlCheckSignup=createEvent$1(this,"nlCheckSignup"),this.fetchHandler=createEvent$1(this,"fetchHandler"),this.titleSignup="Create keys with key store",this.description="Choose some username and a key store service.",this.bunkers="nsec.app,highlighter.com",this.isAvailable=!1}formatServers(e){return e.split(",").map(e=>({name:"@"+e,value:e}))}handleInputChange(e){state.nlSignup.signupName=e.target.value,this.nlCheckSignup.emit(`${e.target.value}@${state.nlSignup.domain}`)}handleDomainSelect(e){state.nlSignup.domain=e.detail,this.nlCheckSignup.emit(`${state.nlSignup.signupName}@${e.detail}`)}handleCreateAccount(e){e.preventDefault(),this.nlSignup.emit(`${state.nlSignup.signupName}@${state.nlSignup.domain}`)}watchBunkersHandler(e){state.nlSignup.servers=this.formatServers(e)}componentWillLoad(){state.nlSignup.servers=this.formatServers(this.bunkers)}render(){return h(Fragment,{key:"558e55ea3a7177a7e035e82c1bbdf522fb2efeb4"},h("div",{key:"8f04f68da63de9317a9ea7e1b425a54fef58905e",class:"p-4 overflow-y-auto"},h("h1",{key:"a8bc4c25348f8d0416679212ba2344a3ca9a78f0",class:"nl-title font-bold text-center text-2xl"},this.titleSignup),h("p",{key:"4e978b75b8ad51e1bc9b0ab5412bd96c21343d9d",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"34b45813498214aedea41061bb60b170cdf1bc35",class:"max-w-72 mx-auto"},h("div",{key:"7a9cc7d8acacebf5001d98982e9f140164a2daf3",class:"relative mb-2"},h("input",{key:"e7f48804f026d19d8bff09c59854dd55de8b6f54",onInput:e=>this.handleInputChange(e),type:"text",class:"nl-input peer py-3 px-4 ps-11 block w-full border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent",placeholder:"Name",value:state.nlSignup.signupName}),h("div",{key:"1a3c7346fa66174c33110c7523e6598c091abeae",class:"absolute inset-y-0 start-0 flex items-center pointer-events-none ps-4 peer-disabled:opacity-50 peer-disabled:pointer-events-none"},h("svg",{key:"edaa9b8e76f3bc2c4a34d8d1fe20536571ef5749",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:this.isAvailable?"#00cc00":"currentColor",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{key:"3e0d1b3d4c9d6b2d4ffc44e699c1545b68173d67","stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z"})))),h("div",{key:"c0b07eb2e657adf2dbfc95fa3bf6351a6beda00a",class:"mb-2"},h("nl-select",{key:"632e99d1d1e074ed8f9383c0f7bd38f3415a3305",onSelectDomain:e=>this.handleDomainSelect(e),selected:0,options:state.nlSignup.servers})),h("div",{key:"96cc25d6bf9e12eb950e81dc046bebd2998f117f",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"7cd9f343b92a75efb8c26db31afa19a734893449",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"491cbb2cad036c958624947160014d3a0f12125e",disabled:state.isLoading,onClick:e=>this.handleCreateAccount(e),titleBtn:"Create profile"},state.isLoading?h("span",{slot:"icon-start",class:"animate-spin-loading inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}):h("svg",{slot:"icon-start",style:{display:"none"},xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M18 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0ZM3 19.235v-.11a6.375 6.375 0 0 1 12.75 0v.109A12.318 12.318 0 0 1 9.374 21c-2.331 0-4.512-.645-6.374-1.766Z"})))))}static get watchers(){return{bunkers:["watchBunkersHandler"]}}static get style(){return NlSignupStyle0}},[0,"nl-signup",{titleSignup:[1,"title-signup"],description:[1],bunkers:[1],isAvailable:[32]},void 0,{bunkers:["watchBunkersHandler"]}]);function defineCustomElement$8(){if("undefined"==typeof customElements)return;["nl-signup","button-base","nl-select"].forEach(e=>{switch(e){case"nl-signup":customElements.get(e)||customElements.define(e,NlSignup);break;case"button-base":customElements.get(e)||defineCustomElement$q();break;case"nl-select":customElements.get(e)||defineCustomElement$m()}})}defineCustomElement$8();const nlWelcomeCss=baseCss,NlWelcomeStyle0=nlWelcomeCss,NlWelcome=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.titleWelcome="Welcome to Nostr!",this.description="This website is part of the Nostr network. Log in with your Nostr profile or sign up to join."}handleChangeScreen(e){state.path=[...state.path,e]}render(){return h(Fragment,{key:"9fbfb07f267912a84a036ab844d3dc3e4fecb2aa"},h("div",{key:"04b7452fb9481f99e793a3a64b5febd0d644cb70",class:"p-4 overflow-y-auto"},h("h1",{key:"32ec61d34e5abead821096f50ebfceb65ac06ceb",class:"nl-title font-bold text-center text-4xl"},this.titleWelcome),h("p",{key:"fa5272e74078d89100f42a9b0f25c30eb5746460",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"9745a35fa223d2481e77258c5f40793174f5cc70",class:"max-w-52 mx-auto pb-5"},h("div",{key:"f395ddcb3e75049fde79d0b9bc797e3cef6d4e30",class:"flex gap-3 flex-col mb-2"},h("button-base",{key:"367ccec38380c93a7ab812436093ce643209ae2e",titleBtn:"Log in",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.WELCOME_LOGIN)},h("svg",{key:"ce6f3533b3a83145deb79257f68f2e8749122571",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"38cc63a69adc25366f4bc78cd966624e4da8234e","stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z"})))),h("button-base",{key:"f3bc1f5b2b971a2c25b18b00e83a1e0f66800c05",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.WELCOME_SIGNUP),titleBtn:"Sign up"},h("svg",{key:"b10cd84902c819733453a9642bd3e28dc4057c04",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"e8e2a4bfdcc92971a44f076a97c0b9043377cbe9","stroke-linecap":"round","stroke-linejoin":"round",d:"M18 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0ZM3 19.235v-.11a6.375 6.375 0 0 1 12.75 0v.109A12.318 12.318 0 0 1 9.374 21c-2.331 0-4.512-.645-6.374-1.766Z"})))))}static get style(){return NlWelcomeStyle0}},[0,"nl-welcome",{titleWelcome:[1,"title-welcome"],description:[1]}]);function defineCustomElement$7(){if("undefined"==typeof customElements)return;["nl-welcome","button-base"].forEach(e=>{switch(e){case"nl-welcome":customElements.get(e)||customElements.define(e,NlWelcome);break;case"button-base":customElements.get(e)||defineCustomElement$q()}})}defineCustomElement$7();const nlWelcomeSigninCss=baseCss,NlWelcomeSigninStyle0=nlWelcomeSigninCss,NlWelcomeSignIn=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlLoginExtension=createEvent$1(this,"nlLoginExtension"),this.titleWelcome="Log in",this.hasExtension=!1,this.authMethods=[],this.hasOTP=!1}handleChangeScreen(e){state.path=[...state.path,e],e===CURRENT_MODULE.EXTENSION&&this.nlLoginExtension.emit()}allowAuthMethod(e){return!this.authMethods.length||this.authMethods.includes(e)}renderSignInWithExtension(){return h("button-base",{onClick:()=>this.handleChangeScreen(CURRENT_MODULE.EXTENSION),titleBtn:"With extension"},h("svg",{style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3 8.25V18a2.25 2.25 0 0 0 2.25 2.25h13.5A2.25 2.25 0 0 0 21 18V8.25m-18 0V6a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 6v2.25m-18 0h18M5.25 6h.008v.008H5.25V6ZM7.5 6h.008v.008H7.5V6Zm2.25 0h.008v.008H9.75V6Z"})))}render(){return h(Fragment,{key:"f698abf1cdb2942897307d83ddf20097338f9c1a"},h("div",{key:"42973b807c9817b1014898729cd3bcf7f0920c7c",class:"p-4 overflow-y-auto"},h("h1",{key:"d0b9a8616ecd00db2db2eee058d151ff1819b225",class:"nl-title font-bold text-center text-3xl"},this.titleWelcome)),h("div",{key:"f3485be619b6faec7d5ed1829016d84a63fe13f1",class:"max-w-52 mx-auto pb-5"},h("div",{key:"171aa182f0a4c432ffe38295ae0a83c294f51cb0",class:"flex gap-3 flex-col"},this.allowAuthMethod("connect")&&h("button-base",{key:"cd223659a29446bdb8464fb88f4f72b552ca6d60",titleBtn:"Connect",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.CONNECT)},h("svg",{key:"858a77a88d412cf623b8aa334bc3e53f396078fb",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"375dd64c3d8ce48de145cf3c24b641209c127742","stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 9V5.25A2.25 2.25 0 0 1 10.5 3h6a2.25 2.25 0 0 1 2.25 2.25v13.5A2.25 2.25 0 0 1 16.5 21h-6a2.25 2.25 0 0 1-2.25-2.25V15M12 9l3 3m0 0-3 3m3-3H2.25"}))),this.allowAuthMethod("readOnly")&&h("button-base",{key:"6add4933d6818a8dbd711b60eb185d9f53abbdce",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN_READ_ONLY),titleBtn:"Read only"},h("svg",{key:"ef8c543ad07afa3e67040bf3898cbf6d450f8a35",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"06ed2df6d62c64e688a1da01af5e394c08a2e4b5","stroke-linecap":"round","stroke-linejoin":"round",d:"M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"}),h("path",{key:"17b825cc04238a369ac7fff9e18311eb449fee7c","stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"}))),this.hasOTP&&this.allowAuthMethod("otp")&&h("button-base",{key:"a93f338de78f40ff7574e6a039294d88aedaf759",titleBtn:"One-time code",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN_OTP)},h("svg",{key:"2aa34c15e0b701071b74870645a3786b2ca85483",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"4af17a7966a64ce8168d9f1faa146bfc7b737201","stroke-linecap":"round","stroke-linejoin":"round",d:"M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}))),this.hasExtension&&this.allowAuthMethod("extension")&&this.renderSignInWithExtension(),!this.allowAuthMethod("connect")&&!this.hasExtension&&h("p",{key:"502d09cbd29c35f132158b57a71afcb1a05a80ea",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},"No Nostr extension!"),!this.allowAuthMethod("connect")&&this.hasExtension&&!this.allowAuthMethod("extension")&&h("p",{key:"82762e76ad0fde7b87815398a7d821143f12c7e7",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},"Use advanced options."))))}static get style(){return NlWelcomeSigninStyle0}},[0,"nl-welcome-signin",{titleWelcome:[1,"title-welcome"],hasExtension:[4,"has-extension"],authMethods:[16],hasOTP:[4,"has-o-t-p"]}]);function defineCustomElement$6(){if("undefined"==typeof customElements)return;["nl-welcome-signin","button-base"].forEach(e=>{switch(e){case"nl-welcome-signin":customElements.get(e)||customElements.define(e,NlWelcomeSignIn);break;case"button-base":customElements.get(e)||defineCustomElement$q()}})}defineCustomElement$6();const nlWelcomeSignupCss=baseCss,NlWelcomeSignupStyle0=nlWelcomeSignupCss,NlWelcomeSignUp=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.titleWelcome="Sign up",this.description="Nostr profiles are based on cryptographic keys. You can create keys right here, or with a key storage app."}handleChangeScreen(e){state.path=[...state.path,e]}render(){return h(Fragment,{key:"ed92b261515733ad30246febe996bec581f392ee"},h("div",{key:"f8e1c53b93a766e1c086b0c0fca9fae98f6e492c",class:"p-4 overflow-y-auto"},h("h1",{key:"8766733352e5a129016b6a9cdfeeeac06af00be1",class:"nl-title font-bold text-center text-3xl"},this.titleWelcome),h("p",{key:"b758d37bcd4e09eaf981ef3057a437872b5ca5cb",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"ffb223d49d4f380406cb4eec4d9f166b7ba7694c",class:"max-w-52 mx-auto pb-5"},h("div",{key:"871ce44d253799caf575263f6e3d42227f9e24ad",class:"flex gap-3 flex-col"},h("button-base",{key:"345b1aaebcc7c72811ab1a7e9a010c011066e1fb",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOCAL_SIGNUP),titleBtn:"Create keys"},h("svg",{key:"17f0f693941020e1ad09c64e8e80ca08fd082673",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"0720ef9137e48e3b814ea1efa463925dfb3ee5e1","stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z"}))),h("button-base",{key:"09f0ac2ad4b759b29001d28d735a74300fee2c36",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.SIGNUP),titleBtn:"With key store"},h("svg",{key:"207439f7318c9dfd7ed8a70da9099ed1a8121871",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"9331b09772ce53fe1802a00063646f68ffb8971a","stroke-linecap":"round","stroke-linejoin":"round",d:"M20.25 6.375c0 2.278-3.694 4.125-8.25 4.125S3.75 8.653 3.75 6.375m16.5 0c0-2.278-3.694-4.125-8.25-4.125S3.75 4.097 3.75 6.375m16.5 0v11.25c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125V6.375m16.5 0v3.75m-16.5-3.75v3.75m16.5 0v3.75C20.25 16.153 16.556 18 12 18s-8.25-1.847-8.25-4.125v-3.75m16.5 0c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125"}))))))}static get style(){return NlWelcomeSignupStyle0}},[0,"nl-welcome-signup",{titleWelcome:[1,"title-welcome"],description:[1]}]);function defineCustomElement$5(){if("undefined"==typeof customElements)return;["nl-welcome-signup","button-base"].forEach(e=>{switch(e){case"nl-welcome-signup":customElements.get(e)||customElements.define(e,NlWelcomeSignUp);break;case"button-base":customElements.get(e)||defineCustomElement$q()}})}defineCustomElement$5();const nlAuthCss=baseCss,NlAuthStyle0=nlAuthCss,NlAuth=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.nlCloseModal=createEvent$1(this,"nlCloseModal"),this.nlChangeDarkMode=createEvent$1(this,"nlChangeDarkMode"),this.nlNostrConnectDefaultCancel=createEvent$1(this,"nlNostrConnectDefaultCancel"),this.prevPath="",this.theme="default",this.bunkers="",this.startScreen=CURRENT_MODULE.WELCOME,this.authMethods=[],this.hasExtension=!1,this.hasOTP=!1,this.isLoading=!1,this.isLoadingExtension=!1,this.isOTP=!1,this.authUrl="",this.iframeUrl="",this.error="",this.localSignup=!1,this.signupNjump=!1,this.njumpIframe="",this.accounts=[],this.recents=[],this.darkMode=!1,this.welcomeTitle="",this.welcomeDescription="",this.connectionString="",this.connectionStringServices=[]}watchLoadingHandler(e){state.isLoading=e}watchLoadingExtensionHandler(e){state.isLoadingExtension=e}watchOTPHandler(e){state.isOTP=e}watchAuthUrlHandler(e){state.authUrl=e}watchIframeUrlHandler(e){state.iframeUrl=e}watchNjumpIframeHandler(e){state.njumpIframe=e}watchErrorHandler(e){state.error=e}handleClose(){this.nlCloseModal.emit()}handleChangeDarkMode(){this.nlChangeDarkMode.emit(!this.darkMode)}componentWillLoad(){state.path=[this.startScreen],state.error="",state.iframeUrl="",state.authUrl="",state.isLoading=!1,state.isLoadingExtension=!1,state.isOTP=!1,console.log("path",state.path)}handleClickToBack(){state.path.pop(),state.path=[...state.path],state.isLoading=!1,state.isLoadingExtension=!1,state.authUrl="",state.isOTP=!1}switchSignSignUpStrategy(e){CURRENT_MODULE.LOCAL_SIGNUP!==e?state.path=[CURRENT_MODULE.WELCOME,e]:state.path=[CURRENT_MODULE.WELCOME,CURRENT_MODULE.WELCOME_SIGNUP,e]}render(){const e="w-full h-full fixed top-0 start-0 z-[80] overflow-x-hidden overflow-y-auto flex items-center "+(this.darkMode?"dark":""),t=state.path.at(-1);t!==this.prevPath&&this.prevPath===CURRENT_MODULE.CONNECTION_STRING&&this.nlNostrConnectDefaultCancel.emit(),this.prevPath=t;const n=state.isOTP||t!==CURRENT_MODULE.INFO&&t!==CURRENT_MODULE.CONFIRM_LOGOUT&&t!==CURRENT_MODULE.IMPORT_FLOW&&t!==CURRENT_MODULE.WELCOME&&t!==CURRENT_MODULE.EXTENSION&&t!==CURRENT_MODULE.IFRAME&&t!==CURRENT_MODULE.PREVIOUSLY_LOGGED,r=t!==CURRENT_MODULE.IFRAME&&(!this.authMethods.length||!this.localSignup&&this.authMethods.includes("connect")||this.localSignup&&this.authMethods.includes("local"));return h("div",{class:`theme-${this.theme}`,dir:"ltr"},h("div",{class:e},h("div",{onClick:()=>this.handleClose(),class:"absolute top-0 left-0 w-full h-full bg-gray-500 bg-opacity-75 z-[80]"}),h("div",{class:"nl-bg relative z-[81] w-full flex flex-col rounded-xl sm:max-w-lg sm:w-full sm:mx-auto"},h("div",{class:"flex justify-between items-center py-3 px-4"},h("div",{class:"flex gap-2 items-center"},h("svg",{class:"w-7 h-7",width:"225",height:"224",viewBox:"0 0 225 224",fill:"none",xmlns:"http://www.w3.org/2000/svg"},h("rect",{width:"224.047",height:"224",rx:"64",fill:"#6951FA"}),h("path",{d:"M162.441 135.941V88.0593C170.359 85.1674 176 77.5348 176 68.6696C176 57.2919 166.708 48 155.33 48C143.953 48 134.661 57.2444 134.661 68.6696C134.661 77.5822 140.302 85.1674 148.219 88.0593V135.941C147.698 136.13 147.176 136.367 146.655 136.604L87.3956 77.3452C88.6282 74.6904 89.2919 71.7511 89.2919 68.6696C89.2919 57.2444 80.0474 48 68.6696 48C57.2919 48 48 57.2444 48 68.6696C48 77.5822 53.6415 85.1674 61.5585 88.0593V135.941C53.6415 138.833 48 146.465 48 155.33C48 166.708 57.2444 176 68.6696 176C80.0948 176 89.3393 166.708 89.3393 155.33C89.3393 146.418 83.6978 138.833 75.7807 135.941V88.0593C76.3022 87.8696 76.8237 87.6326 77.3452 87.3956L136.604 146.655C135.372 149.31 134.708 152.249 134.708 155.33C134.708 166.708 143.953 176 155.378 176C166.803 176 176.047 166.708 176.047 155.33C176.047 146.418 170.406 138.833 162.489 135.941H162.441Z",fill:"white"})),h("p",{class:"font-bold nl-logo text-base"},"Nostr ",h("span",{class:"font-light"},"Login"))),h("div",{class:"flex gap-1"},h("button",{onClick:()=>this.handleChangeDarkMode(),type:"button",class:"nl-action-button flex justify-center items-center w-7 h-7 text-sm font-semibold rounded-full border border-transparent"},h("span",{class:"sr-only"},"Change theme"),this.darkMode?h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"flex-shrink-0 w-5 h-5"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"})):h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"flex-shrink-0 w-5 h-5"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"}))),!state.isLoading&&h("button",{onClick:()=>state.path=[...state.path,CURRENT_MODULE.INFO],type:"button",class:"nl-action-button flex justify-center items-center w-7 h-7 text-sm font-semibold rounded-full border border-transparent"},h("span",{class:"sr-only"},"Info"),h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"flex-shrink-0 w-5 h-5"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"}))),h("button",{onClick:()=>this.handleClose(),type:"button",class:"nl-action-button flex justify-center items-center w-7 h-7 text-sm font-semibold rounded-full border border-transparent"},h("span",{class:"sr-only"},"Close"),h("svg",{class:"flex-shrink-0 w-5 h-5",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},h("path",{d:"M18 6 6 18"}),h("path",{d:"m6 6 12 12"}))))),state.path.length>1&&!state.isLoading&&h("div",{class:"p-4"},h("button",{onClick:()=>this.handleClickToBack(),type:"button",class:"nl-action-button flex justify-center items-center w-7 h-7 text-sm font-semibold rounded-full border border-transparent dark:focus:outline-none dark:focus:ring-1 dark:focus:ring-gray-600","data-hs-overlay":"#hs-vertically-centered-modal"},h("span",{class:"sr-only"},"Back"),h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"flex-shrink-0 w-5 h-5"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18"})))),state.isLoading||state.authUrl?h("nl-loading",{path:t}):h(Fragment,null,(()=>{if(state.isOTP)return h("nl-signin-otp",null);switch(t){case CURRENT_MODULE.WELCOME:return h("nl-welcome",{titleWelcome:this.welcomeTitle||void 0,description:this.welcomeDescription||void 0});case CURRENT_MODULE.LOGIN:return h("nl-signin",null);case CURRENT_MODULE.SIGNUP:return h("nl-signup",{bunkers:this.bunkers});case CURRENT_MODULE.LOCAL_SIGNUP:return h("nl-local-signup",{signupNjump:this.signupNjump});case CURRENT_MODULE.CONFIRM_LOGOUT:return h("nl-confirm-logout",null);case CURRENT_MODULE.IMPORT_FLOW:return h("nl-import-flow",{services:this.connectionStringServices});case CURRENT_MODULE.IMPORT_OTP:return h("nl-otp-migrate",{services:this.connectionStringServices});case CURRENT_MODULE.INFO:return h("nl-info",null);case CURRENT_MODULE.EXTENSION:return h("nl-info-extension",null);case CURRENT_MODULE.LOGIN_READ_ONLY:return h("nl-signin-read-only",null);case CURRENT_MODULE.LOGIN_BUNKER_URL:return h("nl-signin-bunker-url",null);case CURRENT_MODULE.LOGIN_OTP:return h("nl-signin-otp",null);case CURRENT_MODULE.WELCOME_LOGIN:return h("nl-welcome-signin",{hasOTP:this.hasOTP,authMethods:this.authMethods,hasExtension:this.hasExtension});case CURRENT_MODULE.WELCOME_SIGNUP:return h("nl-welcome-signup",null);case CURRENT_MODULE.CONNECTION_STRING:return h("nl-signin-connection-string",{connectionString:this.connectionString});case CURRENT_MODULE.CONNECT:return h("nl-connect",{connectionStringServices:this.connectionStringServices,authMethods:this.authMethods});case CURRENT_MODULE.PREVIOUSLY_LOGGED:return h("nl-previously-logged",{accounts:this.accounts,recents:this.recents});case CURRENT_MODULE.IFRAME:return h("nl-iframe",{iframeUrl:this.authUrl});default:return h("nl-welcome",null)}})(),n&&h(Fragment,null,t===CURRENT_MODULE.WELCOME_SIGNUP||t===CURRENT_MODULE.SIGNUP||t===CURRENT_MODULE.LOCAL_SIGNUP?h("div",{class:"p-4 overflow-y-auto"},h("p",{class:"nl-footer font-light text-center text-sm pt-3 max-w-96 mx-auto"},"If you already have a profile please"," ",h("span",{onClick:()=>this.switchSignSignUpStrategy(CURRENT_MODULE.WELCOME_LOGIN),class:"cursor-pointer text-blue-400"},"log in"),".")):r&&h("div",{class:"p-4 overflow-y-auto"},h("p",{class:"nl-footer font-light text-center text-sm pt-3 max-w-96 mx-auto"},"If you don't have a profile please"," ",h("span",{onClick:()=>this.localSignup?this.switchSignSignUpStrategy(CURRENT_MODULE.LOCAL_SIGNUP):this.switchSignSignUpStrategy(CURRENT_MODULE.WELCOME_SIGNUP),class:"cursor-pointer text-blue-400"},"sign up"),".")))))))}static get watchers(){return{isLoading:["watchLoadingHandler"],isLoadingExtension:["watchLoadingExtensionHandler"],isOTP:["watchOTPHandler"],authUrl:["watchAuthUrlHandler"],iframeUrl:["watchIframeUrlHandler"],njumpIframe:["watchNjumpIframeHandler"],error:["watchErrorHandler"]}}static get style(){return NlAuthStyle0}},[1,"nl-auth",{theme:[1025],bunkers:[1],startScreen:[1,"start-screen"],authMethods:[16],hasExtension:[4,"has-extension"],hasOTP:[4,"has-o-t-p"],isLoading:[4,"is-loading"],isLoadingExtension:[4,"is-loading-extension"],isOTP:[4,"is-o-t-p"],authUrl:[1,"auth-url"],iframeUrl:[1,"iframe-url"],error:[1],localSignup:[4,"local-signup"],signupNjump:[4,"signup-njump"],njumpIframe:[1,"njump-iframe"],accounts:[1040],recents:[1040],darkMode:[1028,"dark-mode"],welcomeTitle:[1,"welcome-title"],welcomeDescription:[1,"welcome-description"],connectionString:[1,"connection-string"],connectionStringServices:[16]},void 0,{isLoading:["watchLoadingHandler"],isLoadingExtension:["watchLoadingExtensionHandler"],isOTP:["watchOTPHandler"],authUrl:["watchAuthUrlHandler"],iframeUrl:["watchIframeUrlHandler"],njumpIframe:["watchNjumpIframeHandler"],error:["watchErrorHandler"]}]);function defineCustomElement$4(){if("undefined"==typeof customElements)return;["nl-auth","button-base","nl-confirm-logout","nl-connect","nl-iframe","nl-import-flow","nl-info","nl-info-extension","nl-loading","nl-local-signup","nl-login-status","nl-otp-migrate","nl-previously-logged","nl-select","nl-signin","nl-signin-bunker-url","nl-signin-connection-string","nl-signin-otp","nl-signin-read-only","nl-signup","nl-welcome","nl-welcome-signin","nl-welcome-signup"].forEach(e=>{switch(e){case"nl-auth":customElements.get(e)||customElements.define(e,NlAuth);break;case"button-base":customElements.get(e)||defineCustomElement$q();break;case"nl-confirm-logout":customElements.get(e)||defineCustomElement$p();break;case"nl-connect":customElements.get(e)||defineCustomElement$o();break;case"nl-iframe":customElements.get(e)||defineCustomElement$n();break;case"nl-import-flow":customElements.get(e)||defineCustomElement$l();break;case"nl-info":customElements.get(e)||defineCustomElement$k();break;case"nl-info-extension":customElements.get(e)||defineCustomElement$j();break;case"nl-loading":customElements.get(e)||defineCustomElement$i();break;case"nl-local-signup":customElements.get(e)||defineCustomElement$h();break;case"nl-login-status":customElements.get(e)||defineCustomElement$g();break;case"nl-otp-migrate":customElements.get(e)||defineCustomElement$f();break;case"nl-previously-logged":customElements.get(e)||defineCustomElement$e();break;case"nl-select":customElements.get(e)||defineCustomElement$m();break;case"nl-signin":customElements.get(e)||defineCustomElement$d();break;case"nl-signin-bunker-url":customElements.get(e)||defineCustomElement$c();break;case"nl-signin-connection-string":customElements.get(e)||defineCustomElement$b();break;case"nl-signin-otp":customElements.get(e)||defineCustomElement$a();break;case"nl-signin-read-only":customElements.get(e)||defineCustomElement$9();break;case"nl-signup":customElements.get(e)||defineCustomElement$8();break;case"nl-welcome":customElements.get(e)||defineCustomElement$7();break;case"nl-welcome-signin":customElements.get(e)||defineCustomElement$6();break;case"nl-welcome-signup":customElements.get(e)||defineCustomElement$5()}})}defineCustomElement$4();const NlButton=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.theme="default",this.darkMode=!1,this.titleBtn="Open modal",this.disabled=!1}render(){return h("button-base",{key:"9f7936090efc7263cce71d1ad89490d7f5445991",theme:this.theme,darkMode:this.darkMode,titleBtn:this.titleBtn,disabled:this.disabled})}},[1,"nl-button",{theme:[1],darkMode:[4,"dark-mode"],titleBtn:[1,"title-btn"],disabled:[4]}]);function defineCustomElement$3(){if("undefined"==typeof customElements)return;["nl-button","button-base"].forEach(e=>{switch(e){case"nl-button":customElements.get(e)||customElements.define(e,NlButton);break;case"button-base":customElements.get(e)||defineCustomElement$q()}})}defineCustomElement$3();const nlChangeAccountCss=baseCss,NlChangeAccountStyle0=nlChangeAccountCss,NLChangeAccount=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.handleOpenWelcomeModal=createEvent$1(this,"handleOpenWelcomeModal"),this.handleSwitchAccount=createEvent$1(this,"handleSwitchAccount"),this.isOpen=!1,this.options=[],this.accounts=[],this.currentAccount=null,this.mode=!1,this.darkMode=!1,this.themeState="default",this.theme="default"}handleWindowClick(){this.wrapperRef.querySelector(".listClass")&&(this.isOpen=!1)}toggleDropdown(){this.isOpen=!this.isOpen,this.calculateDropdownPosition()}watchPropHandler(e){this.themeState=e}watchModeHandler(e){this.mode=e}watchAccountsHandler(e){this.options=e}connectedCallback(){this.themeState=this.theme,this.mode=this.darkMode}calculateDropdownPosition(){if(this.isOpen&&this.buttonRef){const e=this.buttonRef.getBoundingClientRect();this.ulRef.style.top=`${e.height}px`}}handleChange(e){this.handleSwitchAccount.emit(e)}handleOpenModal(){this.handleOpenWelcomeModal.emit()}render(){const e=(this.isOpen?"listClass flex flex-col gap-2":"hidden")+" w-full nl-select-list absolute z-10 left-0 shadow-md rounded-lg p-2 mt-1 after:h-4 after:absolute after:-bottom-4 after:start-0 after:w-full before:h-4 before:absolute before:-top-4 before:start-0 before:w-full",t=(this.isOpen?"rotate-180":"rotate-0")+" duration-300 flex-shrink-0 w-4 h-4 text-gray-500",n=this.options&&this.currentAccount?this.options.filter(e=>e.pubkey!==this.currentAccount.pubkey||e.authMethod!==this.currentAccount.authMethod):[];return h("div",{key:"4e15e39f7ac6a552bfc772396e3e9ef8eeca95cc",class:`theme-${this.themeState}`},h("div",{key:"eae10769ce35dc4cc072d2361c1ee1390c79c822",class:"relative",ref:e=>this.wrapperRef=e},h("button",{key:"e585a44168809f27b99201f7e13bd5db5e4f6569",ref:e=>this.buttonRef=e,onClick:()=>this.toggleDropdown(),type:"button",class:"nl-select peer py-3 px-4 flex items-center w-full justify-between border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent"},h("span",{key:"006ed9a67b57227d4dab51f0b6bcb8290cd9d3ac",class:"text-gray-500"},"Switch profile"),h("svg",{key:"5f824a479165929698fab31b8837b89418587652",class:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},h("path",{key:"600914907723c9f8d01a15da357ccb825c1d1e6a",d:"m6 9 6 6 6-6"}))),h("ul",{key:"9b5b68724a3bce995e6b8b0a9d0eb653baedf79a",ref:e=>this.ulRef=e,class:e},this.options&&n.map(e=>{const t=Boolean(null==e?void 0:e.picture),n=e.name||e.nip05||e.pubkey,r=Boolean(n);return h("li",{onClick:()=>this.handleChange(e),class:"nl-select-option flex cursor-pointer items-center gap-x-3.5 py-2 px-3 rounded-lg text-sm"},h("div",{class:"uppercase font-bold w-full max-w-6 h-6 rounded-full border border-gray-400 flex justify-center items-center"},t?h("img",{class:"w-full rounded-full",src:e.picture,alt:"Logo"}):r?n[0]:h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-full"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"}))),h("div",{class:"overflow-hidden flex flex-col w-full"},h("div",{class:"truncate overflow-hidden"},n),h("nl-login-status",{info:e})))}),h("li",{key:"936f2b75ca2dfca3483650d5d62fc50182cfc8f2",class:"first:pt-0 pt-2 border-t-[1px] first:border-none border-gray-300"},h("div",{key:"be0b4f29e70d8e2bc9fd1cc04c0fb43ad3dd5cac",onClick:()=>this.handleOpenModal(),class:"nl-select-option flex cursor-pointer items-center gap-x-3.5 py-2 px-3 rounded-lg text-sm"},h("div",{key:"bdd2a67e5763726666fcea91b0e7de67fe855994",class:"uppercase font-bold w-6 h-6 rounded-full border border-gray-400 flex justify-center items-center"},h("svg",{key:"f3a258f3e510ccb83b95bf3abecf65c248c8b0f1",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-4 h-4"},h("path",{key:"dafaa898f3e042531a923a9a77b94511895c6102","stroke-linecap":"round","stroke-linejoin":"round",d:"M12 4.5v15m7.5-7.5h-15"}))),"Add profile")))))}get element(){return this}static get watchers(){return{theme:["watchPropHandler"],darkMode:["watchModeHandler"],accounts:["watchAccountsHandler"]}}static get style(){return NlChangeAccountStyle0}},[0,"nl-change-account",{accounts:[16],currentAccount:[16],darkMode:[4,"dark-mode"],theme:[1],isOpen:[32],options:[32],mode:[32],themeState:[32]},[[8,"click","handleWindowClick"]],{theme:["watchPropHandler"],darkMode:["watchModeHandler"],accounts:["watchAccountsHandler"]}]);function defineCustomElement$2(){if("undefined"==typeof customElements)return;["nl-change-account","nl-login-status"].forEach(e=>{switch(e){case"nl-change-account":customElements.get(e)||customElements.define(e,NLChangeAccount);break;case"nl-login-status":customElements.get(e)||defineCustomElement$g()}})}defineCustomElement$2();const nlDialogCss=baseCss,NlDialogStyle0=nlDialogCss,NlDialog=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.__attachShadow()}componentDidLoad(){var e;null===(e=this.dialogElement)||void 0===e||e.showModal()}disconnectedCallback(){var e;null===(e=this.dialogElement)||void 0===e||e.close()}render(){return h("dialog",{key:"2f2dfe3ccb1f617f4a8220cf19e832de98dccce5",ref:e=>this.dialogElement=e,class:"m-auto nl-banner-dialog",style:{border:"0",backgroundColor:"transparent"}},h("slot",{key:"fcf90b01dd2cbbaae8eb97cca3ec67e75cd61d63"}))}static get style(){return NlDialogStyle0}},[1,"nl-dialog"]);function defineCustomElement$1(){if("undefined"==typeof customElements)return;["nl-dialog"].forEach(e=>{if("nl-dialog"===e)customElements.get(e)||customElements.define(e,NlDialog)})}defineCustomElement$1();const nlBannerCss=baseCss,NlBannerStyle0=nlBannerCss,NlBanner=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.handleNotifyConfirmBanner=createEvent$1(this,"handleNotifyConfirmBanner"),this.handleNotifyConfirmBannerIframe=createEvent$1(this,"handleNotifyConfirmBannerIframe"),this.handleLoginBanner=createEvent$1(this,"handleLoginBanner"),this.handleLogoutBanner=createEvent$1(this,"handleLogoutBanner"),this.handleOpenWelcomeModal=createEvent$1(this,"handleOpenWelcomeModal"),this.handleConfirmLogout=createEvent$1(this,"handleConfirmLogout"),this.handleImportModal=createEvent$1(this,"handleImportModal"),this.theme="default",this.darkMode=!1,this.hiddenMode=!1,this.titleBanner="",this.isOpen=!1,this.isLoading=!1,this.notify=null,this.userInfo=null,this.accounts=[],this.isUserImgError=!1,this.domain="",this.mode="",this.url="",this.isOpenConfirm=!1}watchNotifyHandler(e){var t,n,r,i;this.isOpen=!0,this.isOpenConfirm=!0,this.domain=(null===(t=this.userInfo)||void 0===t?void 0:t.domain)||(null===(i=null===(r=null===(n=this.userInfo)||void 0===n?void 0:n.nip05)||void 0===r?void 0:r.split("@"))||void 0===i?void 0:i[1])||"",this.mode=e.mode,this.url=e.url,this.mode||(this.isOpenConfirm=!1,this.isOpen=!1)}handleOpen(){this.userInfo?this.isOpen=!0:this.handleOpenWelcomeModal.emit()}handleClose(){this.isOpen=!1}handleLogin(){this.handleLoginBanner.emit(METHOD_MODULE.LOGIN),this.handleClose()}handleSignup(){this.handleLoginBanner.emit(METHOD_MODULE.SIGNUP),this.handleClose()}handleImport(){this.handleImportModal.emit(),this.handleClose()}handleLogout(){if(localStorage.getItem("backupKey"))return this.handleLogoutBanner.emit(METHOD_MODULE.LOGOUT),this.handleClose(),void localStorage.removeItem("backupKey");"local"===this.userInfo.authMethod?this.handleConfirmLogout.emit():this.handleLogoutBanner.emit(METHOD_MODULE.LOGOUT),this.handleClose()}handleConfirm(){switch(this.mode){case"authUrl":this.handleNotifyConfirmBanner.emit(this.url);break;case"iframeAuthUrl":this.handleNotifyConfirmBannerIframe.emit(this.url)}this.handleClose()}render(){var e,t,n,r,i,s;const o=Boolean(null===(e=this.userInfo)||void 0===e?void 0:e.picture),a=(null===(t=this.userInfo)||void 0===t?void 0:t.name)||(null===(i=null===(r=null===(n=this.userInfo)||void 0===n?void 0:n.nip05)||void 0===r?void 0:r.split("@"))||void 0===i?void 0:i[0])||(null===(s=this.userInfo)||void 0===s?void 0:s.pubkey)||"",c=Boolean(a),l=this.userInfo&&"local"===this.userInfo.authMethod,d=localStorage.getItem("backupKey"),u=h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-full"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})),f=h(Fragment,null,h("div",{class:"block w-[48px] h-[46px] relative z-10"},h("div",{onClick:()=>this.handleOpen(),class:"flex w-52 h-[46px] items-center pl-[11px]"},h("span",{class:(this.isLoading?"w-5 h-5 border-[2px] mr-3.5 ml-[2px] opacity-1":"w-0 h-0 border-[0px] mr-0 opacity-0 ml-0")+" animate-spin transition-all duration-300 ease-in-out inline-block border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}),this.userInfo?h("div",{class:"uppercase font-bold w-6 h-6 mr-2 rounded-full border border-gray-200 flex justify-center items-center"},o?this.isUserImgError?u:h("img",{class:"w-full rounded-full",src:this.userInfo.picture,alt:"Logo",onError:()=>this.isUserImgError=!0}):c?a[0]:u):h("div",{class:"flex justify-center items-center"},h("svg",{class:"w-6 h-6",width:"225",height:"224",viewBox:"0 0 225 224",fill:"none",xmlns:"http://www.w3.org/2000/svg"},h("rect",{width:"224.047",height:"224",rx:"64",fill:"#6951FA"}),h("path",{d:"M162.441 135.941V88.0593C170.359 85.1674 176 77.5348 176 68.6696C176 57.2919 166.708 48 155.33 48C143.953 48 134.661 57.2444 134.661 68.6696C134.661 77.5822 140.302 85.1674 148.219 88.0593V135.941C147.698 136.13 147.176 136.367 146.655 136.604L87.3956 77.3452C88.6282 74.6904 89.2919 71.7511 89.2919 68.6696C89.2919 57.2444 80.0474 48 68.6696 48C57.2919 48 48 57.2444 48 68.6696C48 77.5822 53.6415 85.1674 61.5585 88.0593V135.941C53.6415 138.833 48 146.465 48 155.33C48 166.708 57.2444 176 68.6696 176C80.0948 176 89.3393 166.708 89.3393 155.33C89.3393 146.418 83.6978 138.833 75.7807 135.941V88.0593C76.3022 87.8696 76.8237 87.6326 77.3452 87.3956L136.604 146.655C135.372 149.31 134.708 152.249 134.708 155.33C134.708 166.708 143.953 176 155.378 176C166.803 176 176.047 166.708 176.047 155.33C176.047 146.418 170.406 138.833 162.489 135.941H162.441Z",fill:"white"})),this.isOpen&&h("span",{class:"px-2"},h("b",null,"Nostr")," Login")),this.isOpen&&c&&h("div",{class:"show-slow truncate w-16 text-xs"},a),this.isOpen&&c&&h("nl-login-status",{info:this.userInfo}))),h("button",{onClick:()=>this.handleClose(),type:"button",class:(this.isOpen?"z-20":"z-0")+" nl-action-button absolute right-2 top-2 z-0 show-slow grid place-items-center w-7 h-7 text-sm font-semibold rounded-full border border-transparent"},h("span",{class:"sr-only"},"Close"),h("svg",{class:"flex-shrink-0 w-5 h-5",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},h("path",{d:"M18 6 6 18"}),h("path",{d:"m6 6 12 12"}))),h("div",{class:"p-3 show-slow"},this.isOpenConfirm?h("div",null,h("div",{class:"w-8 h-8 p-1/2 rounded-full border border-gray-200 bg-white mb-2 mt-2 show-slow m-auto"},h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"#5a68ff",class:"w-full"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"}))),h("p",{class:"mb-2 text-center max-w-40 min-w-40 mx-auto"},"timeout"===this.mode?"Keys not responding, check your key storage app":`Confirmation required at ${this.domain}`),"timeout"===this.mode?h("a",{onClick:()=>this.handleClose(),href:`https://${this.domain}`,target:"_blank",class:"nl-button text-nowrap py-2.5 px-3 w-full inline-flex justify-center items-center gap-x-2 text-sm font-medium rounded-lg disabled:opacity-50 disabled:pointer-events-none dark:focus:outline-none dark:focus:ring-1 dark:focus:ring-gray-600"},"Go to ",this.domain):"rebind"===this.mode?h("iframe",{src:this.url,width:"180",height:"80",frameBorder:"0"}):h("button-base",{onClick:()=>this.handleConfirm(),titleBtn:"Confirm"})):h("div",null,h("div",null,this.titleBanner&&h("p",{class:"mb-2 text-center show-slow max-w-40 min-w-40 mx-auto"},this.titleBanner),l&&h(Fragment,null,!d&&h("p",{class:"mb-2 text-center show-slow text-red-400 max-w-40 min-w-40 mx-auto"},"Your profile may be lost if you close this tab"),h("div",{class:"mb-2"},h("button-base",{onClick:()=>this.handleImport(),theme:"lemonade",titleBtn:"Back up profile"}))),h("div",{class:"mb-2"},h("nl-change-account",{currentAccount:this.userInfo,accounts:this.accounts})),this.userInfo?h("button-base",{onClick:()=>this.handleLogout(),titleBtn:"Log out"}):h("div",null,h("button-base",{onClick:()=>this.handleLogin(),titleBtn:"Log in"},h("svg",{style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"flex-shrink-0 w-4 h-4"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z"}))),h("button-base",{onClick:()=>this.handleSignup(),titleBtn:"Sign up"},h("svg",{style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"flex-shrink-0 w-4 h-4"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M18 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0ZM3 19.235v-.11a6.375 6.375 0 0 1 12.75 0v.109A12.318 12.318 0 0 1 9.374 21c-2.331 0-4.512-.645-6.374-1.766Z"}))))))));const p=function e(t,n){n=n||document.body;const r=Array.from(n.querySelectorAll(t)),i=function(n){e(t,n).forEach(e=>{r.includes(e)||r.push(e)})};n.shadowRoot&&i(n.shadowRoot);for(const e of Array.from(n.querySelectorAll("*")))e.shadowRoot&&i(e.shadowRoot);return r}("dialog"),g=!!p.find(e=>e.open&&!e.classList.contains("nl-banner-dialog"));return h("div",{class:`theme-${this.theme} ${!this.isOpen&&this.hiddenMode?"hidden":""}`},h("div",{class:this.darkMode&&"dark",dir:"ltr"},this.isOpenConfirm&&g?h("nl-dialog",null,h("div",{class:`nl-banner ${this.isOpen?"w-52 h-auto right-2 rounded-r-lg isOpen ":"rounded-r-none hover:rounded-r-lg cursor-pointer"} z-50 w-12 h-12 fixed top-52 right-0 inline-block gap-x-2 text-sm font-medium rounded-lg hover:right-2 transition-all duration-300 ease-in-out`},f)):h("div",{class:`nl-banner ${this.isOpen?"w-52 h-auto right-2 rounded-r-lg isOpen":"rounded-r-none hover:rounded-r-lg cursor-pointer"} z-50 w-12 h-12 fixed top-52 right-0 inline-block gap-x-2 text-sm font-medium rounded-lg hover:right-2 transition-all duration-300 ease-in-out`},f)))}static get watchers(){return{notify:["watchNotifyHandler"]}}static get style(){return NlBannerStyle0}},[1,"nl-banner",{theme:[1025],darkMode:[1028,"dark-mode"],hiddenMode:[1028,"hidden-mode"],titleBanner:[1,"title-banner"],isOpen:[1028,"is-open"],isLoading:[4,"is-loading"],notify:[16],userInfo:[16],accounts:[1040],isUserImgError:[32],domain:[32],mode:[32],url:[32],isOpenConfirm:[32]},void 0,{notify:["watchNotifyHandler"]}]);function defineCustomElement(){if("undefined"==typeof customElements)return;["nl-banner","button-base","nl-change-account","nl-dialog","nl-login-status"].forEach(e=>{switch(e){case"nl-banner":customElements.get(e)||customElements.define(e,NlBanner);break;case"button-base":customElements.get(e)||defineCustomElement$q();break;case"nl-change-account":customElements.get(e)||defineCustomElement$2();break;case"nl-dialog":customElements.get(e)||defineCustomElement$1();break;case"nl-login-status":customElements.get(e)||defineCustomElement$g()}})}defineCustomElement();var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var lib$1={},types={};Object.defineProperty(types,"__esModule",{value:!0});var ee={},taskCollection$1={},taskCollection={},utils$3={};function _fast_remove_single(e,t){-1!==t&&(0===t?e.shift():t===e.length-1?e.length=e.length-1:e.splice(t,1))}Object.defineProperty(utils$3,"__esModule",{value:!0}),utils$3._fast_remove_single=void 0,utils$3._fast_remove_single=_fast_remove_single;var bakeCollection={};(function(exports$1){Object.defineProperty(exports$1,"__esModule",{value:!0}),exports$1.bakeCollectionVariadic=exports$1.bakeCollectionAwait=exports$1.bakeCollection=exports$1.BAKED_EMPTY_FUNC=void 0,exports$1.BAKED_EMPTY_FUNC=function(){};var FORLOOP_FALLBACK=1500;function generateArgsDefCode(e){var t="";if(0===e)return t;for(var n=0;n<e-1;++n)t+="arg"+String(n)+", ";return t+="arg"+String(e-1)}function generateBodyPartsCode(e,t){for(var n="",r="",i=0;i<t;++i)n+="var f".concat(i," = collection[").concat(i,"];\n"),r+="f".concat(i,"(").concat(e,")\n");return{funcDefCode:n,funcCallCode:r}}function generateBodyPartsVariadicCode(e){for(var t="",n="",r=0;r<e;++r)t+="var f".concat(r," = collection[").concat(r,"];\n"),n+="f".concat(r,".apply(undefined, arguments)\n");return{funcDefCode:t,funcCallCode:n}}function bakeCollection(collection,fixedArgsNum){if(0===collection.length)return exports$1.BAKED_EMPTY_FUNC;if(1===collection.length)return collection[0];var funcFactoryCode;if(collection.length<FORLOOP_FALLBACK){var argsDefCode=generateArgsDefCode(fixedArgsNum),_a=generateBodyPartsCode(argsDefCode,collection.length),funcDefCode=_a.funcDefCode,funcCallCode=_a.funcCallCode;funcFactoryCode="(function(collection) {\n ".concat(funcDefCode,"\n collection = undefined;\n return (function(").concat(argsDefCode,") {\n ").concat(funcCallCode,"\n });\n })")}else{var argsDefCode=generateArgsDefCode(fixedArgsNum);funcFactoryCode=collection.length%10==0?"(function(collection) {\n return (function(".concat(argsDefCode,") {\n for (var i = 0; i < collection.length; i += 10) {\n collection[i](").concat(argsDefCode,");\n collection[i+1](").concat(argsDefCode,");\n collection[i+2](").concat(argsDefCode,");\n collection[i+3](").concat(argsDefCode,");\n collection[i+4](").concat(argsDefCode,");\n collection[i+5](").concat(argsDefCode,");\n collection[i+6](").concat(argsDefCode,");\n collection[i+7](").concat(argsDefCode,");\n collection[i+8](").concat(argsDefCode,");\n collection[i+9](").concat(argsDefCode,");\n }\n });\n })"):collection.length%4==0?"(function(collection) {\n return (function(".concat(argsDefCode,") {\n for (var i = 0; i < collection.length; i += 4) {\n collection[i](").concat(argsDefCode,");\n collection[i+1](").concat(argsDefCode,");\n collection[i+2](").concat(argsDefCode,");\n collection[i+3](").concat(argsDefCode,");\n }\n });\n })"):collection.length%3==0?"(function(collection) {\n return (function(".concat(argsDefCode,") {\n for (var i = 0; i < collection.length; i += 3) {\n collection[i](").concat(argsDefCode,");\n collection[i+1](").concat(argsDefCode,");\n collection[i+2](").concat(argsDefCode,");\n }\n });\n })"):"(function(collection) {\n return (function(".concat(argsDefCode,") {\n for (var i = 0; i < collection.length; ++i) {\n collection[i](").concat(argsDefCode,");\n }\n });\n })")}var funcFactory=eval(funcFactoryCode);return funcFactory(collection)}function bakeCollectionAwait(collection,fixedArgsNum){if(0===collection.length)return exports$1.BAKED_EMPTY_FUNC;if(1===collection.length)return collection[0];var funcFactoryCode;if(collection.length<FORLOOP_FALLBACK){var argsDefCode=generateArgsDefCode(fixedArgsNum),_a=generateBodyPartsCode(argsDefCode,collection.length),funcDefCode=_a.funcDefCode,funcCallCode=_a.funcCallCode;funcFactoryCode="(function(collection) {\n ".concat(funcDefCode,"\n collection = undefined;\n return (function(").concat(argsDefCode,") {\n return Promise.all([ ").concat(funcCallCode," ]);\n });\n })")}else{var argsDefCode=generateArgsDefCode(fixedArgsNum);funcFactoryCode="(function(collection) {\n return (function(".concat(argsDefCode,") {\n var promises = Array(collection.length);\n for (var i = 0; i < collection.length; ++i) {\n promises[i] = collection[i](").concat(argsDefCode,");\n }\n return Promise.all(promises);\n });\n })")}var funcFactory=eval(funcFactoryCode);return funcFactory(collection)}function bakeCollectionVariadic(collection){if(0===collection.length)return exports$1.BAKED_EMPTY_FUNC;if(1===collection.length)return collection[0];var funcFactoryCode;if(collection.length<FORLOOP_FALLBACK){var _a=generateBodyPartsVariadicCode(collection.length),funcDefCode=_a.funcDefCode,funcCallCode=_a.funcCallCode;funcFactoryCode="(function(collection) {\n ".concat(funcDefCode,"\n collection = undefined;\n return (function() {\n ").concat(funcCallCode,"\n });\n })")}else funcFactoryCode="(function(collection) {\n return (function() {\n for (var i = 0; i < collection.length; ++i) {\n collection[i].apply(undefined, arguments);\n }\n });\n })";var funcFactory=eval(funcFactoryCode);return funcFactory(collection)}exports$1.bakeCollection=bakeCollection,exports$1.bakeCollectionAwait=bakeCollectionAwait,exports$1.bakeCollectionVariadic=bakeCollectionVariadic})(bakeCollection);var __spreadArray$1=commonjsGlobal&&commonjsGlobal.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i<s;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(taskCollection,"__esModule",{value:!0}),taskCollection.TaskCollection=void 0;var utils_1$1=utils$3,bake_collection_1=bakeCollection;function push_norebuild(e,t){var n,r=this.length;if(r>1)t?((n=this._tasks).push.apply(n,arguments),this.length+=arguments.length):(this._tasks.push(e),this.length++);else if(t){var i;if(1===r)(i=Array(1+arguments.length)).push(i),i.push.apply(i,arguments),this._tasks=i;else(i=Array(arguments.length)).push.apply(i,arguments),this._tasks=i;this.length+=arguments.length}else this._tasks=1===r?[this._tasks,e]:e,this.length++}function push_rebuild(e,t){var n,r=this.length;if(r>1)t?((n=this._tasks).push.apply(n,arguments),this.length+=arguments.length):(this._tasks.push(e),this.length++);else if(t){var i;if(1===r)(i=Array(1+arguments.length)).push(i),i.push.apply(i,arguments),this._tasks=i;else(i=Array(arguments.length)).push.apply(i,arguments),this._tasks=i;this.length+=arguments.length}else this._tasks=1===r?[this._tasks,e]:e,this.length++;this.firstEmitBuildStrategy?this.call=rebuild_on_first_call:this.rebuild()}function removeLast_norebuild(e){0!==this.length&&(1===this.length?this._tasks===e&&(this.length=0):((0,utils_1$1._fast_remove_single)(this._tasks,this._tasks.lastIndexOf(e)),1===this._tasks.length?(this._tasks=this._tasks[0],this.length=1):this.length=this._tasks.length))}function removeLast_rebuild(e){if(0!==this.length){if(1===this.length)return this._tasks===e&&(this.length=0),this.firstEmitBuildStrategy?void(this.call=bake_collection_1.BAKED_EMPTY_FUNC):void this.rebuild();(0,utils_1$1._fast_remove_single)(this._tasks,this._tasks.lastIndexOf(e)),1===this._tasks.length?(this._tasks=this._tasks[0],this.length=1):this.length=this._tasks.length,this.firstEmitBuildStrategy?this.call=rebuild_on_first_call:this.rebuild()}}function insert_norebuild(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];0===this.length?(this._tasks=n,this.length=1):1===this.length?(n.unshift(this._tasks),this._tasks=n,this.length=this._tasks.length):((t=this._tasks).splice.apply(t,__spreadArray$1([e,0],n,!1)),this.length=this._tasks.length)}function insert_rebuild(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];0===this.length?(this._tasks=n,this.length=1):1===this.length?(n.unshift(this._tasks),this._tasks=n,this.length=this._tasks.length):((t=this._tasks).splice.apply(t,__spreadArray$1([e,0],n,!1)),this.length=this._tasks.length),this.firstEmitBuildStrategy?this.call=rebuild_on_first_call:this.rebuild()}function rebuild_noawait(){0===this.length?this.call=bake_collection_1.BAKED_EMPTY_FUNC:1===this.length?this.call=this._tasks:this.call=(0,bake_collection_1.bakeCollection)(this._tasks,this.argsNum)}function rebuild_await(){0===this.length?this.call=bake_collection_1.BAKED_EMPTY_FUNC:1===this.length?this.call=this._tasks:this.call=(0,bake_collection_1.bakeCollectionAwait)(this._tasks,this.argsNum)}function rebuild_on_first_call(){this.rebuild(),this.call.apply(void 0,arguments)}var TaskCollection=function(e,t,n,r){void 0===t&&(t=!0),void 0===n&&(n=null),void 0===r&&(r=!1),this.awaitTasks=r,this.call=bake_collection_1.BAKED_EMPTY_FUNC,this.argsNum=e,this.firstEmitBuildStrategy=!0,this.rebuild=r?rebuild_await.bind(this):rebuild_noawait.bind(this),this.setAutoRebuild(t),n?"function"==typeof n?(this._tasks=n,this.length=1):(this._tasks=n,this.length=n.length):(this._tasks=null,this.length=0),t&&this.rebuild()};function fastClear(){this._tasks=null,this.length=0,this.call=bake_collection_1.BAKED_EMPTY_FUNC}function clear(){this._tasks=null,this.length=0,this.call=bake_collection_1.BAKED_EMPTY_FUNC}function growArgsNum(e){this.argsNum<e&&(this.argsNum=e,this.firstEmitBuildStrategy?this.call=rebuild_on_first_call:this.rebuild())}function setAutoRebuild(e){e?(this.push=push_rebuild.bind(this),this.insert=insert_rebuild.bind(this),this.removeLast=removeLast_rebuild.bind(this)):(this.push=push_norebuild.bind(this),this.insert=insert_norebuild.bind(this),this.removeLast=removeLast_norebuild.bind(this))}function tasksAsArray(){return 0===this.length?[]:1===this.length?[this._tasks]:this._tasks}function setTasks(e){0===e.length?(this.length=0,this.call=bake_collection_1.BAKED_EMPTY_FUNC):1===e.length?(this.length=1,this.call=e[0],this._tasks=e[0]):(this.length=e.length,this._tasks=e,this.firstEmitBuildStrategy?this.call=rebuild_on_first_call:this.rebuild())}taskCollection.TaskCollection=TaskCollection,TaskCollection.prototype.fastClear=fastClear,TaskCollection.prototype.clear=clear,TaskCollection.prototype.growArgsNum=growArgsNum,TaskCollection.prototype.setAutoRebuild=setAutoRebuild,TaskCollection.prototype.tasksAsArray=tasksAsArray,TaskCollection.prototype.setTasks=setTasks,function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=commonjsGlobal&&commonjsGlobal.__exportStar||function(e,n){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(n,r)||t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(taskCollection,e)}(taskCollection$1);var utils$2={};function nullObj(){var e={__proto__:null};return e}Object.defineProperty(utils$2,"__esModule",{value:!0}),utils$2.nullObj=void 0,utils$2.nullObj=nullObj;var __spreadArray=commonjsGlobal&&commonjsGlobal.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i<s;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(ee,"__esModule",{value:!0}),ee.EventEmitter=void 0;var task_collection_1=taskCollection$1,utils_1=utils$3,utils_2=utils$2;function emit(e,t,n,r,i,s){var o=this.events[e];if(o){if(0===o.length)return!1;if(o.argsNum<6)o.call(t,n,r,i,s);else{for(var a=new Array(o.argsNum),c=0,l=a.length;c<l;++c)a[c]=arguments[c+1];o.call.apply(void 0,a)}return!0}return!1}function emitHasOnce(e,t,n,r,i,s){var o,a=this.events[e];if(void 0!==a){if(0===a.length)return!1;if(a.argsNum<6)a.call(t,n,r,i,s);else{for(var c=0,l=(o=new Array(a.argsNum)).length;c<l;++c)o[c]=arguments[c+1];a.call.apply(void 0,o)}}var h=this.onceEvents[e];if(h){if("function"==typeof h)if(this.onceEvents[e]=void 0,arguments.length<6)h(t,n,r,i,s);else{if(void 0===o)for(c=0,l=(o=new Array(arguments.length-1)).length;c<l;++c)o[c]=arguments[c+1];h.apply(void 0,o)}else{var d=h;if(this.onceEvents[e]=void 0,arguments.length<6)for(c=0;c<d.length;++c)d[c](t,n,r,i,s);else{if(void 0===o)for(c=0,l=(o=new Array(arguments.length-1)).length;c<l;++c)o[c]=arguments[c+1];for(c=0;c<d.length;++c)d[c].apply(void 0,o)}}return!0}return void 0!==a}var EventEmitter=function(){function e(){this.events=(0,utils_2.nullObj)(),this.onceEvents=(0,utils_2.nullObj)(),this._symbolKeys=new Set,this.maxListeners=1/0}return Object.defineProperty(e.prototype,"_eventsCount",{get:function(){return this.eventNames().length},enumerable:!1,configurable:!0}),e}();function once(e,t){switch(this.emit===emit&&(this.emit=emitHasOnce),typeof this.onceEvents[e]){case"undefined":this.onceEvents[e]=t,"symbol"==typeof e&&this._symbolKeys.add(e);break;case"function":this.onceEvents[e]=[this.onceEvents[e],t];break;case"object":this.onceEvents[e].push(t)}return this}function addListener(e,t,n){if(void 0===n&&(n=t.length),"function"!=typeof t)throw new TypeError("The listener must be a function");var r=this.events[e];return r?(r.push(t),r.growArgsNum(n),this.maxListeners!==1/0&&this.maxListeners<=r.length&&console.warn('Maximum event listeners for "'.concat(String(e),'" event!'))):(this.events[e]=new task_collection_1.TaskCollection(n,!0,t,!1),"symbol"==typeof e&&this._symbolKeys.add(e)),this}function removeListener(e,t){var n=this.events[e];n&&n.removeLast(t);var r=this.onceEvents[e];return r&&("function"==typeof r?this.onceEvents[e]=void 0:"object"==typeof r&&(1===r.length&&r[0]===t?this.onceEvents[e]=void 0:(0,utils_1._fast_remove_single)(r,r.lastIndexOf(t)))),this}function addListenerBound(e,t,n,r){void 0===n&&(n=this),void 0===r&&(r=t.length),this.boundFuncs||(this.boundFuncs=new Map);var i=t.bind(n);return this.boundFuncs.set(t,i),this.addListener(e,i,r)}function removeListenerBound(e,t){var n,r,i=null===(n=this.boundFuncs)||void 0===n?void 0:n.get(t);return null===(r=this.boundFuncs)||void 0===r||r.delete(t),this.removeListener(e,i)}function hasListeners(e){return this.events[e]&&!!this.events[e].length}function prependListener(e,t,n){if(void 0===n&&(n=t.length),"function"!=typeof t)throw new TypeError("The listener must be a function");var r=this.events[e];return r&&r instanceof task_collection_1.TaskCollection?(r.insert(0,t),r.growArgsNum(n),this.maxListeners!==1/0&&this.maxListeners<=r.length&&console.warn('Maximum event listeners for "'.concat(String(e),'" event!'))):(r=this.events[e]=new task_collection_1.TaskCollection(n,!0,t,!1),"symbol"==typeof e&&this._symbolKeys.add(e)),this}function prependOnceListener(e,t){this.emit===emit&&(this.emit=emitHasOnce);var n=this.onceEvents[e];return n?"object"!=typeof n?(this.onceEvents[e]=[t,n],"symbol"==typeof e&&this._symbolKeys.add(e)):(n.unshift(t),this.maxListeners!==1/0&&this.maxListeners<=n.length&&console.warn('Maximum event listeners for "'.concat(String(e),'" once event!'))):(this.onceEvents[e]=[t],"symbol"==typeof e&&this._symbolKeys.add(e)),this}function removeAllListeners(e){return void 0===e?(this.events=(0,utils_2.nullObj)(),this.onceEvents=(0,utils_2.nullObj)(),this._symbolKeys=new Set):(this.events[e]=void 0,this.onceEvents[e]=void 0,"symbol"==typeof e&&this._symbolKeys.delete(e)),this}function setMaxListeners(e){return this.maxListeners=e,this}function getMaxListeners(){return this.maxListeners}function listeners(e){return this.emit===emit?this.events[e]?this.events[e].tasksAsArray().slice():[]:this.events[e]&&this.onceEvents[e]?__spreadArray(__spreadArray([],this.events[e].tasksAsArray(),!0),"function"==typeof this.onceEvents[e]?[this.onceEvents[e]]:this.onceEvents[e],!0):this.events[e]?this.events[e].tasksAsArray():this.onceEvents[e]?"function"==typeof this.onceEvents[e]?[this.onceEvents[e]]:this.onceEvents[e]:[]}function eventNames(){var e=this;if(this.emit===emit){var t=Object.keys(this.events);return __spreadArray(__spreadArray([],t,!0),Array.from(this._symbolKeys),!0).filter(function(t){return t in e.events&&e.events[t]&&e.events[t].length})}t=Object.keys(this.events).filter(function(t){return e.events[t]&&e.events[t].length});var n=Object.keys(this.onceEvents).filter(function(t){return e.onceEvents[t]&&e.onceEvents[t].length});return __spreadArray(__spreadArray(__spreadArray([],t,!0),n,!0),Array.from(this._symbolKeys).filter(function(t){return t in e.events&&e.events[t]&&e.events[t].length||t in e.onceEvents&&e.onceEvents[t]&&e.onceEvents[t].length}),!0)}function listenerCount(e){return this.emit===emit?this.events[e]&&this.events[e].length||0:(this.events[e]&&this.events[e].length||0)+(this.onceEvents[e]&&this.onceEvents[e].length||0)}ee.EventEmitter=EventEmitter,EventEmitter.prototype.emit=emit,EventEmitter.prototype.on=addListener,EventEmitter.prototype.once=once,EventEmitter.prototype.addListener=addListener,EventEmitter.prototype.removeListener=removeListener,EventEmitter.prototype.addListenerBound=addListenerBound,EventEmitter.prototype.removeListenerBound=removeListenerBound,EventEmitter.prototype.hasListeners=hasListeners,EventEmitter.prototype.prependListener=prependListener,EventEmitter.prototype.prependOnceListener=prependOnceListener,EventEmitter.prototype.off=removeListener,EventEmitter.prototype.removeAllListeners=removeAllListeners,EventEmitter.prototype.setMaxListeners=setMaxListeners,EventEmitter.prototype.getMaxListeners=getMaxListeners,EventEmitter.prototype.listeners=listeners,EventEmitter.prototype.eventNames=eventNames,EventEmitter.prototype.listenerCount=listenerCount,function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=commonjsGlobal&&commonjsGlobal.__exportStar||function(e,n){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(n,r)||t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(types,e),n(ee,e)}(lib$1);var browser={exports:{}},ms,hasRequiredMs;function requireMs(){if(hasRequiredMs)return ms;hasRequiredMs=1;var e=1e3,t=60*e,n=60*t,r=24*n,i=7*r,s=365.25*r;function o(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}return ms=function(a,c){c=c||{};var l=typeof a;if("string"===l&&a.length>0)return function(o){if((o=String(o)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(o);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*i;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===l&&isFinite(a))return c.long?function(i){var s=Math.abs(i);if(s>=r)return o(i,s,r,"day");if(s>=n)return o(i,s,n,"hour");if(s>=t)return o(i,s,t,"minute");if(s>=e)return o(i,s,e,"second");return i+" ms"}(a):function(i){var s=Math.abs(i);if(s>=r)return Math.round(i/r)+"d";if(s>=n)return Math.round(i/n)+"h";if(s>=t)return Math.round(i/t)+"m";if(s>=e)return Math.round(i/e)+"s";return i+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}function setup(e){function t(e){let r,i,s,o=null;function a(...e){if(!a.enabled)return;const n=a,i=Number(new Date),s=i-(r||i);n.diff=s,n.prev=r,n.curr=i,r=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,i)=>{if("%%"===r)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];r=s.call(n,t),e.splice(o,1),o--}return r}),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e,t){let n=0,r=0,i=-1,s=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||"*"===t[r]))"*"===t[r]?(i=r,s=n,r++):(n++,r++);else{if(-1===i)return!1;r=i+1,s++,n=s}for(;r<t.length&&"*"===t[r];)r++;return r===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of n)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const n of t.skips)if(r(e,n))return!1;for(const n of t.names)if(r(e,n))return!0;return!1},t.humanize=requireMs(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}var common=setup;!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=common(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(browser,browser.exports);var browserExports=browser.exports,createDebug5=getDefaultExportFromCjs(browserExports);function number$7(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function bytes$7(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function hash$6(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");number$7(e.outputLen),number$7(e.blockLen)}function exists$7(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output$7(e,t){bytes$7(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const crypto$6="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,u8a$7=e=>e instanceof Uint8Array,createView$7=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),rotr$6=(e,t)=>e<<32-t|e>>>t,isLE$7=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];
2
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!isLE$7)throw new Error("Non little-endian hardware is not supported");function utf8ToBytes$b(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function toBytes$8(e){if("string"==typeof e&&(e=utf8ToBytes$b(e)),!u8a$7(e))throw new Error("expected Uint8Array, got "+typeof e);return e}function concatBytes$8(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!u8a$7(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}let Hash$6=class{clone(){return this._cloneInto()}};function wrapConstructor$5(e){const t=t=>e().update(toBytes$8(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function randomBytes$5(e=32){if(crypto$6&&"function"==typeof crypto$6.getRandomValues)return crypto$6.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function setBigUint64$7(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,a,r)}let SHA2$5=class extends Hash$6{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=createView$7(this.buffer)}update(e){exists$7(this);const{view:t,buffer:n,blockLen:r}=this,i=(e=toBytes$8(e)).length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);if(o===r){const t=createView$7(e);for(;r<=i-s;s+=r)this.process(t,s);continue}n.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){exists$7(this),output$7(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>r-s&&(this.process(n,0),s=0);for(let e=s;e<r;e++)t[e]=0;setBigUint64$7(n,r-8,BigInt(8*this.length),i),this.process(n,0);const o=createView$7(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:i,destroyed:s,pos:o}=this;return e.length=r,e.pos=o,e.finished=i,e.destroyed=s,r%t&&e.buffer.set(n),e}};const Chi$6=(e,t,n)=>e&t^~e&n,Maj$6=(e,t,n)=>e&t^e&n^t&n,SHA256_K$6=new Uint32Array([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]),IV$5=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W$6=new Uint32Array(64);let SHA256$6=class extends SHA2$5{constructor(){super(64,32,8,!1),this.A=0|IV$5[0],this.B=0|IV$5[1],this.C=0|IV$5[2],this.D=0|IV$5[3],this.E=0|IV$5[4],this.F=0|IV$5[5],this.G=0|IV$5[6],this.H=0|IV$5[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:s,G:o,H:a}=this;return[e,t,n,r,i,s,o,a]}set(e,t,n,r,i,s,o,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)SHA256_W$6[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=SHA256_W$6[e-15],n=SHA256_W$6[e-2],r=rotr$6(t,7)^rotr$6(t,18)^t>>>3,i=rotr$6(n,17)^rotr$6(n,19)^n>>>10;SHA256_W$6[e]=i+SHA256_W$6[e-7]+r+SHA256_W$6[e-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(rotr$6(o,6)^rotr$6(o,11)^rotr$6(o,25))+Chi$6(o,a,c)+SHA256_K$6[e]+SHA256_W$6[e]|0,h=(rotr$6(n,2)^rotr$6(n,13)^rotr$6(n,22))+Maj$6(n,r,i)|0;l=c,c=a,a=o,o=s+t|0,s=i,i=r,r=n,n=t+h|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,s,o,a,c,l)}roundClean(){SHA256_W$6.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const sha256$7=wrapConstructor$5(()=>new SHA256$6),_0n$i=BigInt(0),_1n$j=BigInt(1),_2n$b=BigInt(2),u8a$6=e=>e instanceof Uint8Array,hexes$7=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));
3
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function bytesToHex$7(e){if(!u8a$6(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=hexes$7[e[n]];return t}function numberToHexUnpadded$3(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function hexToNumber$3(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function hexToBytes$7(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const r=2*t,i=e.slice(r,r+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[t]=s}return n}function bytesToNumberBE$3(e){return hexToNumber$3(bytesToHex$7(e))}function bytesToNumberLE$3(e){if(!u8a$6(e))throw new Error("Uint8Array expected");return hexToNumber$3(bytesToHex$7(Uint8Array.from(e).reverse()))}function numberToBytesBE$3(e,t){return hexToBytes$7(e.toString(16).padStart(2*t,"0"))}function numberToBytesLE$3(e,t){return numberToBytesBE$3(e,t).reverse()}function numberToVarBytesBE$2(e){return hexToBytes$7(numberToHexUnpadded$3(e))}function ensureBytes$4(e,t,n){let r;if("string"==typeof t)try{r=hexToBytes$7(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!u8a$6(t))throw new Error(`${e} must be hex string or Uint8Array`);r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(`${e} expected ${n} bytes, got ${i}`);return r}function concatBytes$7(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!u8a$6(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}function equalBytes$4(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function utf8ToBytes$a(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function bitLen$3(e){let t;for(t=0;e>_0n$i;e>>=_1n$j,t+=1);return t}function bitGet$2(e,t){return e>>BigInt(t)&_1n$j}const bitSet$2=(e,t,n)=>e|(n?_1n$j:_0n$i)<<BigInt(t),bitMask$3=e=>(_2n$b<<BigInt(e-1))-_1n$j,u8n$2=e=>new Uint8Array(e),u8fr$2=e=>Uint8Array.from(e);function createHmacDrbg$3(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=u8n$2(e),i=u8n$2(e),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},a=(...e)=>n(i,r,...e),c=(e=u8n$2())=>{i=a(u8fr$2([0]),e),r=a(),0!==e.length&&(i=a(u8fr$2([1]),e),r=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=a();const t=r.slice();n.push(t),e+=r.length}return concatBytes$7(...n)};return(e,t)=>{let n;for(o(),c(e);!(n=t(l()));)c();return o(),n}}const validatorFns$2={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function validateObject$2(e,t,n={}){const r=(t,n,r)=>{const i=validatorFns$2[n];if("function"!=typeof i)throw new Error(`Invalid validator "${n}", expected function`);const s=e[t];if(!(r&&void 0===s||i(s,e)))throw new Error(`Invalid param ${String(t)}=${s} (${typeof s}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}var ut$2=Object.freeze({__proto__:null,bitGet:bitGet$2,bitLen:bitLen$3,bitMask:bitMask$3,bitSet:bitSet$2,bytesToHex:bytesToHex$7,bytesToNumberBE:bytesToNumberBE$3,bytesToNumberLE:bytesToNumberLE$3,concatBytes:concatBytes$7,createHmacDrbg:createHmacDrbg$3,ensureBytes:ensureBytes$4,equalBytes:equalBytes$4,hexToBytes:hexToBytes$7,hexToNumber:hexToNumber$3,numberToBytesBE:numberToBytesBE$3,numberToBytesLE:numberToBytesLE$3,numberToHexUnpadded:numberToHexUnpadded$3,numberToVarBytesBE:numberToVarBytesBE$2,utf8ToBytes:utf8ToBytes$a,validateObject:validateObject$2});
4
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$h=BigInt(0),_1n$i=BigInt(1),_2n$a=BigInt(2),_3n$7=BigInt(3),_4n$4=BigInt(4),_5n$3=BigInt(5),_8n$3=BigInt(8);function mod$3(e,t){const n=e%t;return n>=_0n$h?n:t+n}function pow$2(e,t,n){if(n<=_0n$h||t<_0n$h)throw new Error("Expected power/modulo > 0");if(n===_1n$i)return _0n$h;let r=_1n$i;for(;t>_0n$h;)t&_1n$i&&(r=r*e%n),e=e*e%n,t>>=_1n$i;return r}function pow2$3(e,t,n){let r=e;for(;t-- >_0n$h;)r*=r,r%=n;return r}function invert$3(e,t){if(e===_0n$h||t<=_0n$h)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=mod$3(e,t),r=t,i=_0n$h,s=_1n$i;for(;n!==_0n$h;){const e=r%n,t=i-s*(r/n);r=n,n=e,i=s,s=t}if(r!==_1n$i)throw new Error("invert: does not exist");return mod$3(i,t)}function tonelliShanks$3(e){const t=(e-_1n$i)/_2n$a;let n,r,i;for(n=e-_1n$i,r=0;n%_2n$a===_0n$h;n/=_2n$a,r++);for(i=_2n$a;i<e&&pow$2(i,t,e)!==e-_1n$i;i++);if(1===r){const t=(e+_1n$i)/_4n$4;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}const s=(n+_1n$i)/_2n$a;return function(e,o){if(e.pow(o,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=r,c=e.pow(e.mul(e.ONE,i),n),l=e.pow(o,s),h=e.pow(o,n);for(;!e.eql(h,e.ONE);){if(e.eql(h,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(h);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(c,_1n$i<<BigInt(a-t-1));c=e.sqr(n),l=e.mul(l,n),h=e.mul(h,c),a=t}return l}}function FpSqrt$3(e){if(e%_4n$4===_3n$7){const t=(e+_1n$i)/_4n$4;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%_8n$3===_5n$3){const t=(e-_5n$3)/_8n$3;return function(e,n){const r=e.mul(n,_2n$a),i=e.pow(r,t),s=e.mul(n,i),o=e.mul(e.mul(s,_2n$a),i),a=e.mul(s,e.sub(o,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return tonelliShanks$3(e)}BigInt(9),BigInt(16);const FIELD_FIELDS$3=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField$3(e){const t=FIELD_FIELDS$3.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return validateObject$2(e,t)}function FpPow$3(e,t,n){if(n<_0n$h)throw new Error("Expected power > 0");if(n===_0n$h)return e.ONE;if(n===_1n$i)return t;let r=e.ONE,i=t;for(;n>_0n$h;)n&_1n$i&&(r=e.mul(r,i)),i=e.sqr(i),n>>=_1n$i;return r}function FpInvertBatch$3(e,t){const n=new Array(t.length),r=t.reduce((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r)),e.ONE),i=e.inv(r);return t.reduceRight((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r)),i),n}function nLength$3(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Field$3(e,t,n=!1,r={}){if(e<=_0n$h)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:i,nByteLength:s}=nLength$3(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=FpSqrt$3(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:s,MASK:bitMask$3(i),ZERO:_0n$h,ONE:_1n$i,create:t=>mod$3(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return _0n$h<=t&&t<e},is0:e=>e===_0n$h,isOdd:e=>(e&_1n$i)===_1n$i,neg:t=>mod$3(-t,e),eql:(e,t)=>e===t,sqr:t=>mod$3(t*t,e),add:(t,n)=>mod$3(t+n,e),sub:(t,n)=>mod$3(t-n,e),mul:(t,n)=>mod$3(t*n,e),pow:(e,t)=>FpPow$3(a,e,t),div:(t,n)=>mod$3(t*invert$3(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>invert$3(t,e),sqrt:r.sqrt||(e=>o(a,e)),invertBatch:e=>FpInvertBatch$3(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?numberToBytesLE$3(e,s):numberToBytesBE$3(e,s),fromBytes:e=>{if(e.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${e.length}`);return n?bytesToNumberLE$3(e):bytesToNumberBE$3(e)}});return Object.freeze(a)}function getFieldBytesLength$1(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function getMinHashLength$1(e){const t=getFieldBytesLength$1(e);return t+Math.ceil(t/2)}function mapHashToField$1(e,t,n=!1){const r=e.length,i=getFieldBytesLength$1(t),s=getMinHashLength$1(t);if(r<16||r<s||r>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);const o=mod$3(n?bytesToNumberBE$3(e):bytesToNumberLE$3(e),t-_1n$i)+_1n$i;return n?numberToBytesLE$3(o,i):numberToBytesBE$3(o,i)}
5
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$g=BigInt(0),_1n$h=BigInt(1);function wNAF$3(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>_0n$g;)n&_1n$h&&(r=r.add(i)),i=i.double(),n>>=_1n$h;return r},precomputeWindow(e,t){const{windows:n,windowSize:i}=r(t),s=[];let o=e,a=o;for(let e=0;e<n;e++){a=o,s.push(a);for(let e=1;e<i;e++)a=a.add(o),s.push(a);o=a.double()}return s},wNAF(t,i,s){const{windows:o,windowSize:a}=r(t);let c=e.ZERO,l=e.BASE;const h=BigInt(2**t-1),d=2**t,u=BigInt(t);for(let e=0;e<o;e++){const t=e*a;let r=Number(s&h);s>>=u,r>a&&(r-=d,s+=_1n$h);const o=t,f=t+Math.abs(r)-1,p=e%2!=0,g=r<0;0===r?l=l.add(n(p,i[o])):c=c.add(n(g,i[f]))}return{p:c,f:l}},wNAFCached(e,t,n,r){const i=e._WINDOW_SIZE||1;let s=t.get(e);return s||(s=this.precomputeWindow(e,i),1!==i&&t.set(e,r(s))),this.wNAF(i,s,n)}}}function validateBasic$2(e){return validateField$3(e.Fp),validateObject$2(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...nLength$3(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
6
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function validatePointOpts$2(e){const t=validateBasic$2(e);validateObject$2(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:i}=t;if(n){if(!r.eql(i,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:b2n$2,hexToBytes:h2b$2}=ut$2,DER$3={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=DER$3;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(128&r[0])throw new t("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:b2n$2(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=DER$3,n="string"==typeof e?h2b$2(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:i,l:s}=DER$3._parseInt(n.subarray(2)),{d:o,l:a}=DER$3._parseInt(s);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},r=t(n(e.s)),i=t(n(e.r)),s=r.length/2,o=i.length/2,a=n(s),c=n(o);return`30${n(o+s+4)}02${c}${i}02${a}${r}`}},_0n$f=BigInt(0),_1n$g=BigInt(1);BigInt(2);const _3n$6=BigInt(3);function weierstrassPoints$2(e){const t=validatePointOpts$2(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{const i=t.toAffine();return concatBytes$7(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),i=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function s(e){const{a:r,b:i}=t,s=n.sqr(e),o=n.mul(s,e);return n.add(n.add(o,n.mul(e,r)),i)}if(!n.eql(n.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function o(e){return"bigint"==typeof e&&_0n$f<e&&e<t.n}function a(e){if(!o(e))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:i,n:s}=t;if(n&&"bigint"!=typeof e){if(e instanceof Uint8Array&&(e=bytesToHex$7(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*r,"0")}let o;try{o="bigint"==typeof e?e:bytesToNumberBE$3(ensureBytes$4("private key",e,r))}catch(t){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return i&&(o=mod$3(o,s)),a(o),o}const l=new Map;function h(e){if(!(e instanceof d))throw new Error("ProjectivePoint expected")}class d{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required")}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof d)throw new Error("projective point not allowed");const i=e=>n.eql(e,n.ZERO);return i(t)&&i(r)?d.ZERO:new d(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)}static fromHex(e){const t=d.fromAffine(i(ensureBytes$4("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw new Error("bad point: x or y not FE");const i=n.sqr(r),o=s(e);if(!n.eql(i,o))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){h(e);const{px:t,py:r,pz:i}=this,{px:s,py:o,pz:a}=e,c=n.eql(n.mul(t,a),n.mul(s,i)),l=n.eql(n.mul(r,a),n.mul(o,i));return c&&l}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,i=n.mul(r,_3n$6),{px:s,py:o,pz:a}=this;let c=n.ZERO,l=n.ZERO,h=n.ZERO,u=n.mul(s,s),f=n.mul(o,o),p=n.mul(a,a),g=n.mul(s,o);return g=n.add(g,g),h=n.mul(s,a),h=n.add(h,h),c=n.mul(e,h),l=n.mul(i,p),l=n.add(c,l),c=n.sub(f,l),l=n.add(f,l),l=n.mul(c,l),c=n.mul(g,c),h=n.mul(i,h),p=n.mul(e,p),g=n.sub(u,p),g=n.mul(e,g),g=n.add(g,h),h=n.add(u,u),u=n.add(h,u),u=n.add(u,p),u=n.mul(u,g),l=n.add(l,u),p=n.mul(o,a),p=n.add(p,p),u=n.mul(p,g),c=n.sub(c,u),h=n.mul(p,f),h=n.add(h,h),h=n.add(h,h),new d(c,l,h)}add(e){h(e);const{px:r,py:i,pz:s}=this,{px:o,py:a,pz:c}=e;let l=n.ZERO,u=n.ZERO,f=n.ZERO;const p=t.a,g=n.mul(t.b,_3n$6);let y=n.mul(r,o),m=n.mul(i,a),b=n.mul(s,c),w=n.add(r,i),v=n.add(o,a);w=n.mul(w,v),v=n.add(y,m),w=n.sub(w,v),v=n.add(r,s);let $=n.add(o,c);return v=n.mul(v,$),$=n.add(y,b),v=n.sub(v,$),$=n.add(i,s),l=n.add(a,c),$=n.mul($,l),l=n.add(m,b),$=n.sub($,l),f=n.mul(p,v),l=n.mul(g,b),f=n.add(l,f),l=n.sub(m,f),f=n.add(m,f),u=n.mul(l,f),m=n.add(y,y),m=n.add(m,y),b=n.mul(p,b),v=n.mul(g,v),m=n.add(m,b),b=n.sub(y,b),b=n.mul(p,b),v=n.add(v,b),y=n.mul(m,v),u=n.add(u,y),y=n.mul($,v),l=n.mul(w,l),l=n.sub(l,y),y=n.mul(w,m),f=n.mul($,f),f=n.add(f,y),new d(l,u,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return f.wNAFCached(this,l,e,e=>{const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)})}multiplyUnsafe(e){const r=d.ZERO;if(e===_0n$f)return r;if(a(e),e===_1n$g)return this;const{endo:i}=t;if(!i)return f.unsafeLadder(this,e);let{k1neg:s,k1:o,k2neg:c,k2:l}=i.splitScalar(e),h=r,u=r,p=this;for(;o>_0n$f||l>_0n$f;)o&_1n$g&&(h=h.add(p)),l&_1n$g&&(u=u.add(p)),p=p.double(),o>>=_1n$g,l>>=_1n$g;return s&&(h=h.negate()),c&&(u=u.negate()),u=new d(n.mul(u.px,i.beta),u.py,u.pz),h.add(u)}multiply(e){a(e);let r,i,s=e;const{endo:o}=t;if(o){const{k1neg:e,k1:t,k2neg:a,k2:c}=o.splitScalar(s);let{p:l,f:h}=this.wNAF(t),{p:u,f:p}=this.wNAF(c);l=f.constTimeNegate(e,l),u=f.constTimeNegate(a,u),u=new d(n.mul(u.px,o.beta),u.py,u.pz),r=l.add(u),i=h.add(p)}else{const{p:e,f:t}=this.wNAF(s);r=e,i=t}return d.normalizeZ([r,i])[0]}multiplyAndAddUnsafe(e,t,n){const r=d.BASE,i=(e,t)=>t!==_0n$f&&t!==_1n$g&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),s=i(this,t).add(i(e,n));return s.is0()?void 0:s}toAffine(e){const{px:t,py:r,pz:i}=this,s=this.is0();null==e&&(e=s?n.ONE:n.inv(i));const o=n.mul(t,e),a=n.mul(r,e),c=n.mul(i,e);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw new Error("invZ was invalid");return{x:o,y:a}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===_1n$g)return!0;if(n)return n(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===_1n$g?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return bytesToHex$7(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const u=t.nBitLength,f=wNAF$3(d,t.endo?Math.ceil(u/2):u);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:o}}function validateOpts$2(e){const t=validateBasic$2(e);return validateObject$2(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function weierstrass$3(e){const t=validateOpts$2(e),{Fp:n,n:r}=t,i=n.BYTES+1,s=2*n.BYTES+1;function o(e){return mod$3(e,r)}function a(e){return invert$3(e,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:h,isWithinCurveOrder:d}=weierstrassPoints$2({...t,toBytes(e,t,r){const i=t.toAffine(),s=n.toBytes(i.x),o=concatBytes$7;return r?o(Uint8Array.from([t.hasEvenY()?2:3]),s):o(Uint8Array.from([4]),s,n.toBytes(i.y))},fromBytes(e){const t=e.length,r=e[0],o=e.subarray(1);if(t!==i||2!==r&&3!==r){if(t===s&&4===r){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}{const e=bytesToNumberBE$3(o);if(!function(e){return _0n$f<e&&e<n.ORDER}(e))throw new Error("Point is not on curve");const t=h(e);let i=n.sqrt(t);return!(1&~r)!==((i&_1n$g)===_1n$g)&&(i=n.neg(i)),{x:e,y:i}}}}),u=e=>bytesToHex$7(numberToBytesBE$3(e,t.nByteLength));function f(e){return e>r>>_1n$g}const p=(e,t,n)=>bytesToNumberBE$3(e.slice(t,n));class g{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=ensureBytes$4("compactSignature",e,2*n),new g(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=DER$3.toSig(ensureBytes$4("DER",e));return new g(t,n)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:i,recovery:s}=this,l=w(ensureBytes$4("msgHash",e));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const h=2===s||3===s?r+t.n:r;if(h>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=1&s?"03":"02",f=c.fromHex(d+u(h)),p=a(h),g=o(-l*p),y=o(i*p),m=c.BASE.multiplyAndAddUnsafe(f,g,y);if(!m)throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes$7(this.toDERHex())}toDERHex(){return DER$3.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes$7(this.toCompactHex())}toCompactHex(){return u(this.r)+u(this.s)}}const y={isValidPrivateKey(e){try{return l(e),!0}catch(e){return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const e=getMinHashLength$1(t.n);return mapHashToField$1(t.randomBytes(e),t.n)},precompute:(e=8,t=c.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function m(e){const t=e instanceof Uint8Array,n="string"==typeof e,r=(t||n)&&e.length;return t?r===i||r===s:n?r===2*i||r===2*s:e instanceof c}const b=t.bits2int||function(e){const n=bytesToNumberBE$3(e),r=8*e.length-t.nBitLength;return r>0?n>>BigInt(r):n},w=t.bits2int_modN||function(e){return o(b(e))},v=bitMask$3(t.nBitLength);function $(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(_0n$f<=e&&e<v))throw new Error(`bigint expected < 2^${t.nBitLength}`);return numberToBytesBE$3(e,t.nByteLength)}function E(e,r,i=k){if(["recovered","canonical"].some(e=>e in i))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:h}=t;let{lowS:u,prehash:p,extraEntropy:y}=i;null==u&&(u=!0),e=ensureBytes$4("msgHash",e),p&&(e=ensureBytes$4("prehashed msgHash",s(e)));const m=w(e),v=l(r),E=[$(v),$(m)];if(null!=y){const e=!0===y?h(n.BYTES):y;E.push(ensureBytes$4("extraEntropy",e))}const x=concatBytes$7(...E),_=m;return{seed:x,k2sig:function(e){const t=b(e);if(!d(t))return;const n=a(t),r=c.BASE.multiply(t).toAffine(),i=o(r.x);if(i===_0n$f)return;const s=o(n*o(_+i*v));if(s===_0n$f)return;let l=(r.x===i?0:2)|Number(r.y&_1n$g),h=s;return u&&f(s)&&(h=function(e){return f(e)?o(-e):e}(s),l^=1),new g(i,h,l)}}}const k={lowS:t.lowS,prehash:!1},x={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(m(e))throw new Error("first arg must be private key");if(!m(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(l(e)).toRawBytes(n)},sign:function(e,n,r=k){const{seed:i,k2sig:s}=E(e,n,r),o=t;return createHmacDrbg$3(o.hash.outputLen,o.nByteLength,o.hmac)(i,s)},verify:function(e,n,r,i=x){const s=e;if(n=ensureBytes$4("msgHash",n),r=ensureBytes$4("publicKey",r),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:l,prehash:h}=i;let d,u;try{if("string"==typeof s||s instanceof Uint8Array)try{d=g.fromDER(s)}catch(e){if(!(e instanceof DER$3.Err))throw e;d=g.fromCompact(s)}else{if("object"!=typeof s||"bigint"!=typeof s.r||"bigint"!=typeof s.s)throw new Error("PARSE");{const{r:e,s:t}=s;d=new g(e,t)}}u=c.fromHex(r)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(l&&d.hasHighS())return!1;h&&(n=t.hash(n));const{r:f,s:p}=d,y=w(n),m=a(p),b=o(y*m),v=o(f*m),$=c.BASE.multiplyAndAddUnsafe(u,b,v)?.toAffine();return!!$&&o($.x)===f},ProjectivePoint:c,Signature:g,utils:y}}BigInt(4);let HMAC$6=class extends Hash$6{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,hash$6(e);const n=toBytes$8(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return exists$7(this),this.iHash.update(e),this}digestInto(e){exists$7(this),bytes$7(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:s,outputLen:o}=this;return e.finished=r,e.destroyed=i,e.blockLen=s,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const hmac$6=(e,t,n)=>new HMAC$6(e,t).update(n).digest();
1
+ var BUILD={allRenderFn:!1,cmpDidLoad:!0,cmpDidUnload:!1,cmpDidUpdate:!0,cmpDidRender:!0,cmpWillLoad:!0,cmpWillUpdate:!0,cmpWillRender:!0,connectedCallback:!0,disconnectedCallback:!0,element:!0,event:!0,hasRenderFn:!0,lifecycle:!0,hostListener:!0,hostListenerTargetWindow:!0,hostListenerTargetDocument:!0,hostListenerTargetBody:!0,hostListenerTargetParent:!1,hostListenerTarget:!0,member:!0,method:!0,mode:!0,observeAttribute:!0,prop:!0,propMutable:!0,reflect:!0,scoped:!0,shadowDom:!0,slot:!0,cssAnnotations:!0,state:!0,style:!0,formAssociated:!1,svg:!0,updatable:!0,vdomAttribute:!0,vdomXlink:!0,vdomClass:!0,vdomFunctional:!0,vdomKey:!0,vdomListener:!0,vdomRef:!0,vdomPropOrAttr:!0,vdomRender:!0,vdomStyle:!0,vdomText:!0,watchCallback:!0,taskQueue:!0,hotModuleReplacement:!1,isDebug:!1,isDev:!1,isTesting:!1,hydrateServerSide:!1,hydrateClientSide:!1,lifecycleDOMEvents:!1,lazyLoad:!1,profile:!1,slotRelocation:!0,appendChildSlotFix:!1,cloneNodeFix:!1,hydratedAttribute:!1,hydratedClass:!0,scriptDataOpts:!1,scopedSlotTextContentFix:!1,shadowDomShim:!1,slotChildNodesFix:!1,invisiblePrehydration:!0,propBoolean:!0,propNumber:!0,propString:!0,constructableCSS:!0,cmpShouldUpdate:!0,devTools:!1,shadowDelegatesFocus:!0,initializeNextTick:!1,asyncLoading:!1,asyncQueue:!1,transformTagName:!1,attachStyles:!0,experimentalSlotFixes:!1},__defProp$1=Object.defineProperty,__export$1=(e,t)=>{for(var n in t)__defProp$1(e,n,{get:t[n],enumerable:!0})},hostRefs=new WeakMap,getHostRef=e=>hostRefs.get(e),registerHost=(e,t)=>{const n={$flags$:0,$hostElement$:e,$cmpMeta$:t,$instanceValues$:new Map};return hostRefs.set(e,n)},isMemberInElement=(e,t)=>t in e,consoleError=(e,t)=>(0,console.error)(e,t),styles=new Map,modeResolutionChain=[],SLOT_FB_CSS="slot-fb{display:contents}slot-fb[hidden]{display:none}",XLINK_NS="http://www.w3.org/1999/xlink",win="undefined"!=typeof window?window:{},doc=win.document||{head:{}},H=win.HTMLElement||class{},plt={$flags$:0,$resourcesUrl$:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,n,r)=>e.addEventListener(t,n,r),rel:(e,t,n,r)=>e.removeEventListener(t,n,r),ce:(e,t)=>new CustomEvent(e,t)},supportsListenerOptions=(()=>{let e=!1;try{doc.addEventListener("e",null,Object.defineProperty({},"passive",{get(){e=!0}}))}catch(e){}return e})(),promiseResolve=e=>Promise.resolve(e),supportsConstructableStylesheets=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync}catch(e){}return!1})(),queuePending=!1,queueDomReads=[],queueDomWrites=[],queueTask=(e,t)=>n=>{e.push(n),queuePending||(queuePending=!0,t&&4&plt.$flags$?nextTick(flush):plt.raf(flush))},consume=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){consoleError(e)}e.length=0},flush=()=>{consume(queueDomReads),consume(queueDomWrites),(queuePending=queueDomReads.length>0)&&plt.raf(flush)},nextTick=e=>promiseResolve().then(e),writeTask=queueTask(queueDomWrites,!0),EMPTY_OBJ={},SVG_NS="http://www.w3.org/2000/svg",HTML_NS="http://www.w3.org/1999/xhtml",isDef=e=>null!=e,isComplexType=e=>"object"===(e=typeof e)||"function"===e;function queryNonceMetaTagContent(e){var t,n,r;return null!=(r=null==(n=null==(t=e.head)?void 0:t.querySelector('meta[name="csp-nonce"]'))?void 0:n.getAttribute("content"))?r:void 0}var result_exports={};__export$1(result_exports,{err:()=>err,map:()=>map,ok:()=>ok,unwrap:()=>unwrap$1,unwrapErr:()=>unwrapErr});var ok=e=>({isOk:!0,isErr:!1,value:e}),err=e=>({isOk:!1,isErr:!0,value:e});function map(e,t){if(e.isOk){const n=t(e.value);return n instanceof Promise?n.then((e=>ok(e))):ok(n)}if(e.isErr){const t=e.value;return err(t)}throw"should never get here"}var unwrap$1=e=>{if(e.isOk)return e.value;throw e.value},unwrapErr=e=>{if(e.isErr)return e.value;throw e.value},createTime=(e,t="")=>()=>{},h=(e,t,...n)=>{let r=null,o=null,s=null,i=!1,a=!1;const l=[],c=t=>{for(let n=0;n<t.length;n++)r=t[n],Array.isArray(r)?c(r):null!=r&&"boolean"!=typeof r&&((i="function"!=typeof e&&!isComplexType(r))&&(r=String(r)),i&&a?l[l.length-1].$text$+=r:l.push(i?newVNode(null,r):r),a=i)};if(c(n),t){t.key&&(o=t.key),t.name&&(s=t.name);{const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter((t=>e[t])).join(" "))}}if("function"==typeof e)return e(null===t?{}:t,l,vdomFnUtils);const d=newVNode(e,null);return d.$attrs$=t,l.length>0&&(d.$children$=l),d.$key$=o,d.$name$=s,d},newVNode=(e,t)=>{const n={$flags$:0,$tag$:e,$text$:t,$elm$:null,$children$:null,$attrs$:null,$key$:null,$name$:null};return n},Host={},isHost=e=>e&&e.$tag$===Host,vdomFnUtils={forEach:(e,t)=>e.map(convertToPublic).forEach(t),map:(e,t)=>e.map(convertToPublic).map(t).map(convertToPrivate)},convertToPublic=e=>({vattrs:e.$attrs$,vchildren:e.$children$,vkey:e.$key$,vname:e.$name$,vtag:e.$tag$,vtext:e.$text$}),convertToPrivate=e=>{if("function"==typeof e.vtag){const t={...e.vattrs};return e.vkey&&(t.key=e.vkey),e.vname&&(t.name=e.vname),h(e.vtag,t,...e.vchildren||[])}const t=newVNode(e.vtag,e.vtext);return t.$attrs$=e.vattrs,t.$children$=e.vchildren,t.$key$=e.vkey,t.$name$=e.vname,t},computeMode=e=>modeResolutionChain.map((t=>t(e))).find((e=>!!e)),parsePropertyValue=(e,t)=>null==e||isComplexType(e)?e:4&t?"false"!==e&&(""===e||!!e):2&t?parseFloat(e):1&t?String(e):e,getElement=e=>e,createEvent=(e,t,n)=>{const r=getElement(e);return{emit:e=>emitEvent(r,t,{bubbles:!0,composed:!0,cancelable:!0,detail:e})}},emitEvent=(e,t,n)=>{const r=plt.ce(t,n);return e.dispatchEvent(r),r},rootAppliedStyles=new WeakMap,registerStyle=(e,t,n)=>{let r=styles.get(e);supportsConstructableStylesheets&&n?(r=r||new CSSStyleSheet,"string"==typeof r?r=t:r.replaceSync(t)):r=t,styles.set(e,r)},addStyle=(e,t,n)=>{var r;const o=getScopeId(t,n),s=styles.get(o);if(e=11===e.nodeType?e:doc,s)if("string"==typeof s){e=e.head||e;let n,i=rootAppliedStyles.get(e);if(i||rootAppliedStyles.set(e,i=new Set),!i.has(o)){{n=doc.createElement("style"),n.innerHTML=s;const o=null!=(r=plt.$nonce$)?r:queryNonceMetaTagContent(doc);null!=o&&n.setAttribute("nonce",o);(!(1&t.$flags$)||1&t.$flags$&&"HEAD"!==e.nodeName)&&e.insertBefore(n,e.querySelector("link"))}4&t.$flags$&&(n.innerHTML+=SLOT_FB_CSS),i&&i.add(o)}}else e.adoptedStyleSheets.includes(s)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,s]);return o},attachStyles=e=>{const t=e.$cmpMeta$,n=e.$hostElement$,r=t.$flags$,o=createTime("attachStyles",t.$tagName$),s=addStyle(n.shadowRoot?n.shadowRoot:n.getRootNode(),t,e.$modeName$);10&r&&2&r&&(n["s-sc"]=s,n.classList.add(s+"-h"),2&r&&n.classList.add(s+"-s")),o()},getScopeId=(e,t)=>"sc-"+(t&&32&e.$flags$?e.$tagName$+"-"+t:e.$tagName$),setAccessor=(e,t,n,r,o,s)=>{if(n!==r){let i=isMemberInElement(e,t),a=t.toLowerCase();if("class"===t){const t=e.classList,o=parseClassList(n),s=parseClassList(r);t.remove(...o.filter((e=>e&&!s.includes(e)))),t.add(...s.filter((e=>e&&!o.includes(e))))}else if("style"===t){for(const t in n)r&&null!=r[t]||(t.includes("-")?e.style.removeProperty(t):e.style[t]="");for(const t in r)n&&r[t]===n[t]||(t.includes("-")?e.style.setProperty(t,r[t]):e.style[t]=r[t])}else if("key"===t);else if("ref"===t)r&&r(e);else if(e.__lookupSetter__(t)||"o"!==t[0]||"n"!==t[1]){const l=isComplexType(r);if((i||l&&null!==r)&&!o)try{if(e.tagName.includes("-"))e[t]=r;else{const o=null==r?"":r;"list"===t?i=!1:null!=n&&e[t]==o||(e[t]=o)}}catch(e){}let c=!1;a!==(a=a.replace(/^xlink\:?/,""))&&(t=a,c=!0),null==r||!1===r?!1===r&&""!==e.getAttribute(t)||(c?e.removeAttributeNS(XLINK_NS,t):e.removeAttribute(t)):(!i||4&s||o)&&!l&&(r=!0===r?"":r,c?e.setAttributeNS(XLINK_NS,t,r):e.setAttribute(t,r))}else if(t="-"===t[2]?t.slice(3):isMemberInElement(win,a)?a.slice(2):a[2]+t.slice(3),n||r){const o=t.endsWith(CAPTURE_EVENT_SUFFIX);t=t.replace(CAPTURE_EVENT_REGEX,""),n&&plt.rel(e,t,n,o),r&&plt.ael(e,t,r,o)}}},parseClassListRegex=/\s/,parseClassList=e=>e?e.split(parseClassListRegex):[],CAPTURE_EVENT_SUFFIX="Capture",CAPTURE_EVENT_REGEX=new RegExp(CAPTURE_EVENT_SUFFIX+"$"),updateElement=(e,t,n)=>{const r=11===t.$elm$.nodeType&&t.$elm$.host?t.$elm$.host:t.$elm$,o=e&&e.$attrs$||EMPTY_OBJ,s=t.$attrs$||EMPTY_OBJ;for(const e of sortedAttrNames(Object.keys(o)))e in s||setAccessor(r,e,o[e],void 0,n,t.$flags$);for(const e of sortedAttrNames(Object.keys(s)))setAccessor(r,e,o[e],s[e],n,t.$flags$)},scopeId,contentRef,hostTagName;function sortedAttrNames(e){return e.includes("ref")?[...e.filter((e=>"ref"!==e)),"ref"]:e}var useNativeShadowDom=!1,checkSlotFallbackVisibility=!1,checkSlotRelocate=!1,isSvgMode=!1,createElm=(e,t,n,r)=>{var o;const s=t.$children$[n];let i,a,l,c=0;if(useNativeShadowDom||(checkSlotRelocate=!0,"slot"===s.$tag$&&(scopeId&&r.classList.add(scopeId+"-s"),s.$flags$|=s.$children$?2:1)),null!==s.$text$)i=s.$elm$=doc.createTextNode(s.$text$);else if(1&s.$flags$)i=s.$elm$=doc.createTextNode("");else{isSvgMode||(isSvgMode="svg"===s.$tag$),i=s.$elm$=doc.createElementNS(isSvgMode?SVG_NS:HTML_NS,!useNativeShadowDom&&BUILD.slotRelocation&&2&s.$flags$?"slot-fb":s.$tag$),isSvgMode&&"foreignObject"===s.$tag$&&(isSvgMode=!1),updateElement(null,s,isSvgMode);if(!!i.getRootNode().querySelector("body")&&BUILD.scoped&&isDef(scopeId)&&i["s-si"]!==scopeId&&i.classList.add(i["s-si"]=scopeId),updateElementScopeIds(i,r),s.$children$)for(c=0;c<s.$children$.length;++c)a=createElm(e,s,c,i),a&&i.appendChild(a);"svg"===s.$tag$?isSvgMode=!1:"foreignObject"===i.tagName&&(isSvgMode=!0)}return i["s-hn"]=hostTagName,3&s.$flags$&&(i["s-sr"]=!0,i["s-cr"]=contentRef,i["s-sn"]=s.$name$||"",i["s-rf"]=null==(o=s.$attrs$)?void 0:o.ref,l=e&&e.$children$&&e.$children$[n],l&&l.$tag$===s.$tag$&&e.$elm$&&putBackInOriginalLocation(e.$elm$,!1)),i},putBackInOriginalLocation=(e,t)=>{plt.$flags$|=1;const n=Array.from(e.childNodes);e["s-sr"]&&BUILD.experimentalSlotFixes;for(let e=n.length-1;e>=0;e--){const r=n[e];r["s-hn"]!==hostTagName&&r["s-ol"]&&(insertBefore(parentReferenceNode(r),r,referenceNode(r)),r["s-ol"].remove(),r["s-ol"]=void 0,r["s-sh"]=void 0,checkSlotRelocate=!0),t&&putBackInOriginalLocation(r,t)}plt.$flags$&=-2},addVnodes=(e,t,n,r,o,s)=>{let i,a=e["s-cr"]&&e["s-cr"].parentNode||e;for(a.shadowRoot&&a.tagName===hostTagName&&(a=a.shadowRoot);o<=s;++o)r[o]&&(i=createElm(null,n,o,e),i&&(r[o].$elm$=i,insertBefore(a,i,referenceNode(t))))},removeVnodes=(e,t,n)=>{for(let r=t;r<=n;++r){const t=e[r];if(t){const e=t.$elm$;nullifyVNodeRefs(t),e&&(checkSlotFallbackVisibility=!0,e["s-ol"]?e["s-ol"].remove():putBackInOriginalLocation(e,!0),e.remove())}}},updateChildren=(e,t,n,r,o=!1)=>{let s,i,a=0,l=0,c=0,d=0,h=t.length-1,u=t[0],p=t[h],f=r.length-1,g=r[0],m=r[f];for(;a<=h&&l<=f;)if(null==u)u=t[++a];else if(null==p)p=t[--h];else if(null==g)g=r[++l];else if(null==m)m=r[--f];else if(isSameVnode(u,g,o))patch(u,g,o),u=t[++a],g=r[++l];else if(isSameVnode(p,m,o))patch(p,m,o),p=t[--h],m=r[--f];else if(isSameVnode(u,m,o))"slot"!==u.$tag$&&"slot"!==m.$tag$||putBackInOriginalLocation(u.$elm$.parentNode,!1),patch(u,m,o),insertBefore(e,u.$elm$,p.$elm$.nextSibling),u=t[++a],m=r[--f];else if(isSameVnode(p,g,o))"slot"!==u.$tag$&&"slot"!==m.$tag$||putBackInOriginalLocation(p.$elm$.parentNode,!1),patch(p,g,o),insertBefore(e,p.$elm$,u.$elm$),p=t[--h],g=r[++l];else{for(c=-1,d=a;d<=h;++d)if(t[d]&&null!==t[d].$key$&&t[d].$key$===g.$key$){c=d;break}c>=0?(i=t[c],i.$tag$!==g.$tag$?s=createElm(t&&t[l],n,c,e):(patch(i,g,o),t[c]=void 0,s=i.$elm$),g=r[++l]):(s=createElm(t&&t[l],n,l,e),g=r[++l]),s&&insertBefore(parentReferenceNode(u.$elm$),s,referenceNode(u.$elm$))}a>h?addVnodes(e,null==r[f+1]?null:r[f+1].$elm$,n,r,l,f):l>f&&removeVnodes(t,a,h)},isSameVnode=(e,t,n=!1)=>e.$tag$===t.$tag$&&("slot"===e.$tag$?(!("$nodeId$"in e)||!n||8===e.$elm$.nodeType)&&e.$name$===t.$name$:!!n||e.$key$===t.$key$),referenceNode=e=>e&&e["s-ol"]||e,parentReferenceNode=e=>(e["s-ol"]?e["s-ol"]:e).parentNode,patch=(e,t,n=!1)=>{const r=t.$elm$=e.$elm$,o=e.$children$,s=t.$children$,i=t.$tag$,a=t.$text$;let l;null===a?(isSvgMode="svg"===i||"foreignObject"!==i&&isSvgMode,("slot"!==i||useNativeShadowDom)&&updateElement(e,t,isSvgMode),null!==o&&null!==s?updateChildren(r,o,t,s,n):null!==s?(null!==e.$text$&&(r.textContent=""),addVnodes(r,null,t,s,0,s.length-1)):!n&&BUILD.updatable&&null!==o&&removeVnodes(o,0,o.length-1),isSvgMode&&"svg"===i&&(isSvgMode=!1)):(l=r["s-cr"])?l.parentNode.textContent=a:e.$text$!==a&&(r.data=a)},updateFallbackSlotVisibility=e=>{const t=e.childNodes;for(const e of t)if(1===e.nodeType){if(e["s-sr"]){const n=e["s-sn"];e.hidden=!1;for(const r of t)if(r!==e)if(r["s-hn"]!==e["s-hn"]||""!==n){if(1===r.nodeType&&(n===r.getAttribute("slot")||n===r["s-sn"])||3===r.nodeType&&n===r["s-sn"]){e.hidden=!0;break}}else if(1===r.nodeType||3===r.nodeType&&""!==r.textContent.trim()){e.hidden=!0;break}}updateFallbackSlotVisibility(e)}},relocateNodes=[],markSlotContentForRelocation=e=>{let t,n,r;for(const o of e.childNodes){if(o["s-sr"]&&(t=o["s-cr"])&&t.parentNode){n=t.parentNode.childNodes;const e=o["s-sn"];for(r=n.length-1;r>=0;r--)if(t=n[r],!t["s-cn"]&&!t["s-nr"]&&t["s-hn"]!==o["s-hn"])if(isNodeLocatedInSlot(t,e)){let n=relocateNodes.find((e=>e.$nodeToRelocate$===t));checkSlotFallbackVisibility=!0,t["s-sn"]=t["s-sn"]||e,n?(n.$nodeToRelocate$["s-sh"]=o["s-hn"],n.$slotRefNode$=o):(t["s-sh"]=o["s-hn"],relocateNodes.push({$slotRefNode$:o,$nodeToRelocate$:t})),t["s-sr"]&&relocateNodes.map((e=>{isNodeLocatedInSlot(e.$nodeToRelocate$,t["s-sn"])&&(n=relocateNodes.find((e=>e.$nodeToRelocate$===t)),n&&!e.$slotRefNode$&&(e.$slotRefNode$=n.$slotRefNode$))}))}else relocateNodes.some((e=>e.$nodeToRelocate$===t))||relocateNodes.push({$nodeToRelocate$:t})}1===o.nodeType&&markSlotContentForRelocation(o)}},isNodeLocatedInSlot=(e,t)=>1===e.nodeType?null===e.getAttribute("slot")&&""===t||e.getAttribute("slot")===t:e["s-sn"]===t||""===t,nullifyVNodeRefs=e=>{e.$attrs$&&e.$attrs$.ref&&e.$attrs$.ref(null),e.$children$&&e.$children$.map(nullifyVNodeRefs)},insertBefore=(e,t,n)=>{const r=null==e?void 0:e.insertBefore(t,n);return updateElementScopeIds(t,e),r},findScopeIds=e=>{const t=[];return e&&t.push(...e["s-scs"]||[],e["s-si"],e["s-sc"],...findScopeIds(e.parentElement)),t},updateElementScopeIds=(e,t,n=!1)=>{var r;if(e&&t&&1===e.nodeType){const o=new Set(findScopeIds(t).filter(Boolean));if(o.size&&(null==(r=e.classList)||r.add(...e["s-scs"]=[...o]),e["s-ol"]||n))for(const t of Array.from(e.childNodes))updateElementScopeIds(t,e,!0)}},renderVdom=(e,t,n=!1)=>{var r,o,s,i,a;const l=e.$hostElement$,c=e.$cmpMeta$,d=e.$vnode$||newVNode(null,null),u=isHost(t)?t:h(null,null,t);if(hostTagName=l.tagName,c.$attrsToReflect$&&(u.$attrs$=u.$attrs$||{},c.$attrsToReflect$.map((([e,t])=>u.$attrs$[t]=l[e]))),n&&u.$attrs$)for(const e of Object.keys(u.$attrs$))l.hasAttribute(e)&&!["key","ref","style","class"].includes(e)&&(u.$attrs$[e]=l[e]);if(u.$tag$=null,u.$flags$|=4,e.$vnode$=u,u.$elm$=d.$elm$=l.shadowRoot||l,scopeId=l["s-sc"],useNativeShadowDom=!!(1&c.$flags$),contentRef=l["s-cr"],checkSlotFallbackVisibility=!1,patch(d,u,n),plt.$flags$|=1,checkSlotRelocate){markSlotContentForRelocation(u.$elm$);for(const e of relocateNodes){const t=e.$nodeToRelocate$;if(!t["s-ol"]){const e=doc.createTextNode("");e["s-nr"]=t,insertBefore(t.parentNode,t["s-ol"]=e,t)}}for(const e of relocateNodes){const t=e.$nodeToRelocate$,a=e.$slotRefNode$;if(a){const e=a.parentNode;let n=a.nextSibling;{let s=null==(r=t["s-ol"])?void 0:r.previousSibling;for(;s;){let r=null!=(o=s["s-nr"])?o:null;if(r&&r["s-sn"]===t["s-sn"]&&e===r.parentNode){for(r=r.nextSibling;r===t||(null==r?void 0:r["s-sr"]);)r=null==r?void 0:r.nextSibling;if(!r||!r["s-nr"]){n=r;break}}s=s.previousSibling}}(!n&&e!==t.parentNode||t.nextSibling!==n)&&t!==n&&(!t["s-hn"]&&t["s-ol"]&&(t["s-hn"]=t["s-ol"].parentNode.nodeName),insertBefore(e,t,n),1===t.nodeType&&(t.hidden=null!=(s=t["s-ih"])&&s)),t&&"function"==typeof a["s-rf"]&&a["s-rf"](t)}else 1===t.nodeType&&(n&&(t["s-ih"]=null!=(i=t.hidden)&&i),t.hidden=!0)}}if(checkSlotFallbackVisibility&&updateFallbackSlotVisibility(u.$elm$),plt.$flags$&=-2,relocateNodes.length=0,BUILD.experimentalScopedSlotChanges&&2&c.$flags$)for(const e of u.$elm$.childNodes)e["s-hn"]===hostTagName||e["s-sh"]||(n&&null==e["s-ih"]&&(e["s-ih"]=null!=(a=e.hidden)&&a),e.hidden=!0);contentRef=void 0},attachToAncestor=(e,t)=>{},scheduleUpdate=(e,t)=>{e.$flags$|=16,attachToAncestor(e,e.$ancestorComponent$);return writeTask((()=>dispatchHooks(e,t)))},dispatchHooks=(e,t)=>{const n=e.$hostElement$,r=createTime("scheduleUpdate",e.$cmpMeta$.$tagName$),o=n;if(!o)throw new Error(`Can't render component <${n.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);let s;return s=safeCall(o,t?"componentWillLoad":"componentWillUpdate"),s=enqueue(s,(()=>safeCall(o,"componentWillRender"))),r(),enqueue(s,(()=>updateComponent(e,o,t)))},enqueue=(e,t)=>isPromisey(e)?e.then(t).catch((e=>{console.error(e),t()})):t(),isPromisey=e=>e instanceof Promise||e&&e.then&&"function"==typeof e.then,updateComponent=async(e,t,n)=>{const r=e.$hostElement$,o=createTime("update",e.$cmpMeta$.$tagName$);r["s-rc"],n&&attachStyles(e);const s=createTime("render",e.$cmpMeta$.$tagName$);callRender(e,t,r,n),s(),o(),postUpdateComponent(e)},renderingRef=null,callRender=(e,t,n,r)=>{try{renderingRef=t,t=t.render&&t.render(),e.$flags$&=-17,e.$flags$|=2,(BUILD.hasRenderFn||BUILD.reflect)&&(BUILD.vdomRender||BUILD.reflect)&&(BUILD.hydrateServerSide||renderVdom(e,t,r))}catch(t){consoleError(t,e.$hostElement$)}return renderingRef=null,null},getRenderingRef=()=>renderingRef,postUpdateComponent=e=>{const t=e.$cmpMeta$.$tagName$,n=e.$hostElement$,r=createTime("postUpdate",t),o=n;e.$ancestorComponent$,safeCall(o,"componentDidRender"),64&e.$flags$?(safeCall(o,"componentDidUpdate"),r()):(e.$flags$|=64,safeCall(o,"componentDidLoad"),r())},forceUpdate=e=>{{const t=getHostRef(e),n=t.$hostElement$.isConnected;return n&&2==(18&t.$flags$)&&scheduleUpdate(t,!1),n}},safeCall=(e,t,n)=>{if(e&&e[t])try{return e[t](n)}catch(e){consoleError(e)}},getValue=(e,t)=>getHostRef(e).$instanceValues$.get(t),setValue=(e,t,n,r)=>{const o=getHostRef(e),s=e,i=o.$instanceValues$.get(t),a=o.$flags$,l=s;n=parsePropertyValue(n,r.$members$[t][0]);const c=Number.isNaN(i)&&Number.isNaN(n);if(n!==i&&!c){if(o.$instanceValues$.set(t,n),r.$watchers$&&128&a){const e=r.$watchers$[t];e&&e.map((e=>{try{l[e](n,i,t)}catch(e){consoleError(e,s)}}))}if(2==(18&a)){if(l.componentShouldUpdate&&!1===l.componentShouldUpdate(n,i,t))return;scheduleUpdate(o,!1)}}},proxyComponent=(e,t,n)=>{var r,o;const s=e.prototype;if(t.$members$||t.$watchers$||e.watchers){e.watchers&&!t.$watchers$&&(t.$watchers$=e.watchers);const n=Object.entries(null!=(r=t.$members$)?r:{});n.map((([e,[n]])=>{(31&n||32&n)&&Object.defineProperty(s,e,{get(){return getValue(this,e)},set(n){setValue(this,e,n,t)},configurable:!0,enumerable:!0})}));{const r=new Map;s.attributeChangedCallback=function(e,n,o){plt.jmp((()=>{var i;const a=r.get(e);if(this.hasOwnProperty(a))o=this[a],delete this[a];else{if(s.hasOwnProperty(a)&&"number"==typeof this[a]&&this[a]==o)return;if(null==a){const r=getHostRef(this),s=null==r?void 0:r.$flags$;if(s&&!(8&s)&&128&s&&o!==n){const r=this,s=null==(i=t.$watchers$)?void 0:i[e];null==s||s.forEach((t=>{null!=r[t]&&r[t].call(r,o,n,e)}))}return}}this[a]=(null!==o||"boolean"!=typeof this[a])&&o}))},e.observedAttributes=Array.from(new Set([...Object.keys(null!=(o=t.$watchers$)?o:{}),...n.filter((([e,t])=>15&t[0])).map((([e,n])=>{var o;const s=n[1]||e;return r.set(s,e),512&n[0]&&(null==(o=t.$attrsToReflect$)||o.push([e,s])),s}))]))}}return e},initializeComponent=async(e,t,n,r)=>{let o;if(!(32&t.$flags$)){t.$flags$|=32,n.$lazyBundleId$;{o=e.constructor;const n=e.localName;customElements.whenDefined(n).then((()=>t.$flags$|=128))}if(o&&o.style){let r;"string"==typeof o.style?r=o.style:"string"!=typeof o.style&&(t.$modeName$=computeMode(e),t.$modeName$&&(r=o.style[t.$modeName$]));const s=getScopeId(n,t.$modeName$);if(!styles.has(s)){const e=createTime("registerStyles",n.$tagName$);registerStyle(s,r,!!(1&n.$flags$)),e()}}}t.$ancestorComponent$;scheduleUpdate(t,!0)},fireConnectedCallback=e=>{},connectedCallback=e=>{if(!(1&plt.$flags$)){const t=getHostRef(e),n=t.$cmpMeta$,r=createTime("connectedCallback",n.$tagName$);1&t.$flags$?(addHostEventListeners(e,t,n.$listeners$),(null==t?void 0:t.$lazyInstance$)?fireConnectedCallback(t.$lazyInstance$):(null==t?void 0:t.$onReadyPromise$)&&t.$onReadyPromise$.then((()=>fireConnectedCallback(t.$lazyInstance$)))):(t.$flags$|=1,12&n.$flags$&&setContentReference(e),n.$members$&&Object.entries(n.$members$).map((([t,[n]])=>{if(31&n&&e.hasOwnProperty(t)){const n=e[t];delete e[t],e[t]=n}})),initializeComponent(e,t,n)),r()}},setContentReference=e=>{const t=e["s-cr"]=doc.createComment("");t["s-cn"]=!0,insertBefore(e,t,e.firstChild)},disconnectedCallback=async e=>{if(!(1&plt.$flags$)){const t=getHostRef(e);t.$rmListeners$&&(t.$rmListeners$.map((e=>e())),t.$rmListeners$=void 0)}},proxyCustomElement=(e,t)=>{const n={$flags$:t[0],$tagName$:t[1]};n.$members$=t[2],n.$listeners$=t[3],n.$watchers$=e.$watchers$,n.$attrsToReflect$=[];const r=e.prototype.connectedCallback,o=e.prototype.disconnectedCallback;return Object.assign(e.prototype,{__registerHost(){registerHost(this,n)},connectedCallback(){const e=getHostRef(this);addHostEventListeners(this,e,n.$listeners$),connectedCallback(this),r&&r.call(this)},disconnectedCallback(){disconnectedCallback(this),o&&o.call(this)},__attachShadow(){if(this.shadowRoot){if("open"!==this.shadowRoot.mode)throw new Error(`Unable to re-use existing shadow root for ${n.$tagName$}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else this.attachShadow({mode:"open",delegatesFocus:!!(16&n.$flags$)})}}),e.is=n.$tagName$,proxyComponent(e,n)},Fragment=(e,t)=>t,addHostEventListeners=(e,t,n,r)=>{n&&n.map((([n,r,o])=>{const s=getHostListenerTarget(e,n),i=hostListenerProxy(t,o),a=hostListenerOpts(n);plt.ael(s,r,i,a),(t.$rmListeners$=t.$rmListeners$||[]).push((()=>plt.rel(s,r,i,a)))}))},hostListenerProxy=(e,t)=>n=>{try{BUILD.lazyLoad||e.$hostElement$[t](n)}catch(e){consoleError(e)}},getHostListenerTarget=(e,t)=>4&t?doc:8&t?win:16&t?doc.body:e,hostListenerOpts=e=>supportsListenerOptions?{passive:!!(1&e),capture:!!(2&e)}:!!(2&e),CURRENT_MODULE,METHOD_MODULE;!function(e){e.WELCOME="welcome",e.WELCOME_LOGIN="welcome-login",e.WELCOME_SIGNUP="welcome-signup",e.INFO="info",e.LOGIN_BUNKER_URL="login-bunker-url",e.LOGIN_READ_ONLY="login-read-only",e.CONFIRM_LOGOUT="confirm-logout",e.IMPORT_FLOW="import",e.IMPORT_OTP="import-otp",e.LOGIN="login",e.SIGNUP="signup",e.LOCAL_SIGNUP="local-signup",e.EXTENSION="extension",e.LOADING="loading",e.PREVIOUSLY_LOGGED="switch-account",e.LOGIN_OTP="otp",e.CONNECT="connect",e.CONNECTION_STRING="connection-string",e.IFRAME="iframe"}(CURRENT_MODULE||(CURRENT_MODULE={})),function(e){e.LOGIN="login",e.SIGNUP="signup",e.LOGOUT="logout",e.CONFIRM="confirm"}(METHOD_MODULE||(METHOD_MODULE={}));const appendToMap=(e,t,n)=>{const r=e.get(t);r?r.includes(n)||r.push(n):e.set(t,[n])},debounce=(e,t)=>{let n;return(...r)=>{n&&clearTimeout(n),n=setTimeout((()=>{n=0,e(...r)}),t)}},isConnected=e=>!("isConnected"in e)||e.isConnected,cleanupElements=debounce((e=>{for(let t of e.keys())e.set(t,e.get(t).filter(isConnected))}),2e3),stencilSubscription=()=>{if("function"!=typeof getRenderingRef)return{};const e=new Map;return{dispose:()=>e.clear(),get:t=>{const n=getRenderingRef();n&&appendToMap(e,t,n)},set:t=>{const n=e.get(t);n&&e.set(t,n.filter(forceUpdate)),cleanupElements(e)},reset:()=>{e.forEach((e=>e.forEach(forceUpdate))),cleanupElements(e)}}},unwrap=e=>"function"==typeof e?e():e,createObservableMap=(e,t=((e,t)=>e!==t))=>{const n=unwrap(e);let r=new Map(Object.entries(null!=n?n:{}));const o={dispose:[],get:[],set:[],reset:[]},s=()=>{var t;r=new Map(Object.entries(null!==(t=unwrap(e))&&void 0!==t?t:{})),o.reset.forEach((e=>e()))},i=e=>(o.get.forEach((t=>t(e))),r.get(e)),a=(e,n)=>{const s=r.get(e);t(n,s,e)&&(r.set(e,n),o.set.forEach((t=>t(e,n,s))))},l="undefined"==typeof Proxy?{}:new Proxy(n,{get:(e,t)=>i(t),ownKeys:e=>Array.from(r.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(e,t)=>r.has(t),set:(e,t,n)=>(a(t,n),!0)}),c=(e,t)=>(o[e].push(t),()=>{removeFromArray(o[e],t)});return{state:l,get:i,set:a,on:c,onChange:(t,n)=>{const r=c("set",((e,r)=>{e===t&&n(r)})),o=c("reset",(()=>n(unwrap(e)[t])));return()=>{r(),o()}},use:(...e)=>{const t=e.reduce(((e,t)=>(t.set&&e.push(c("set",t.set)),t.get&&e.push(c("get",t.get)),t.reset&&e.push(c("reset",t.reset)),t.dispose&&e.push(c("dispose",t.dispose)),e)),[]);return()=>t.forEach((e=>e()))},dispose:()=>{o.dispose.forEach((e=>e())),s()},reset:s,forceUpdate:e=>{const t=r.get(e);o.set.forEach((n=>n(e,t,t)))}}},removeFromArray=(e,t)=>{const n=e.indexOf(t);n>=0&&(e[n]=e[e.length-1],e.length--)},createStore=(e,t)=>{const n=createObservableMap(e,t);return n.use(stencilSubscription()),n},{state:state,onChange:onChange,reset:reset}=createStore({screen:CURRENT_MODULE.WELCOME,prevScreen:CURRENT_MODULE.WELCOME,path:[CURRENT_MODULE.WELCOME],error:"",isLoading:!1,isLoadingExtension:!1,isOTP:!1,authUrl:"",iframeUrl:"",njumpIframe:"",nlSignin:{loginName:""},nlSignup:{signupName:"",domain:"",servers:[{name:"@nsec.app",value:"nsec.app"},{name:"@highlighter.com",value:"highlighter.com"}]},nlSigninBunkerUrl:{loginName:""},nlSigninReadOnly:{loginName:""},nlSigninOTP:{loginName:"",code:""},nlImport:null});onChange("screen",(()=>{state.error="",state.nlSignin.loginName="",state.nlSignup.signupName="",state.nlSignup.domain=""}));const baseCss="/*! tailwindcss v3.4.10 | MIT License | https://tailwindcss.com*/*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:\"\"}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:normal;-webkit-tap-highlight-color:transparent;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:normal;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,fieldset,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{color:#9ca3af;color:#6b7280;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}[multiple],[type=date],[type=datetime-local],[type=email],[type=month],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=time],[type=url],[type=week],input:where(:not([type])),select,textarea{--tw-shadow:0 0 #0000;appearance:none;background-color:#fff;border-color:#6b7280;border-radius:0;border-width:1px;font-size:1rem;line-height:1.5rem;padding:.5rem .75rem}[multiple]:focus,[type=date]:focus,[type=datetime-local]:focus,[type=email]:focus,[type=month]:focus,[type=number]:focus,[type=password]:focus,[type=search]:focus,[type=tel]:focus,[type=text]:focus,[type=time]:focus,[type=url]:focus,[type=week]:focus,input:where(:not([type])):focus,select:focus,textarea:focus{--tw-ring-inset:var(--tw-empty, );--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#2563eb;--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);border-color:#2563eb;box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-date-and-time-value{min-height:1.5em;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-year-field{padding-bottom:0;padding-top:0}select{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E\");background-position:right .5rem center;background-repeat:no-repeat;background-size:1.5em 1.5em;padding-right:2.5rem;print-color-adjust:exact}[multiple],[size]:where(select:not([size=\"1\"])){background-image:none;background-position:0 0;background-repeat:unset;background-size:initial;padding-right:.75rem;print-color-adjust:unset}[type=checkbox],[type=radio]{--tw-shadow:0 0 #0000;appearance:none;background-color:#fff;background-origin:border-box;border-color:#6b7280;border-width:1px;color:#2563eb;display:inline-block;flex-shrink:0;height:1rem;padding:0;print-color-adjust:exact;user-select:none;vertical-align:middle;width:1rem}[type=checkbox]{border-radius:0}[type=radio]{border-radius:100%}[type=checkbox]:focus,[type=radio]:focus{--tw-ring-inset:var(--tw-empty, );--tw-ring-offset-width:2px;--tw-ring-offset-color:#fff;--tw-ring-color:#2563eb;--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}[type=checkbox]:checked,[type=radio]:checked{background-color:currentColor;background-position:50%;background-repeat:no-repeat;background-size:100% 100%;border-color:transparent}[type=checkbox]:checked{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 16 16' fill='%23fff' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 0 1 0 1.414l-5 5a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L6.5 9.086l4.293-4.293a1 1 0 0 1 1.414 0z'/%3E%3C/svg%3E\")}@media (forced-colors:active){[type=checkbox]:checked{appearance:auto}}[type=radio]:checked{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 16 16' fill='%23fff' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='8' cy='8' r='3'/%3E%3C/svg%3E\")}@media (forced-colors:active){[type=radio]:checked{appearance:auto}}[type=checkbox]:checked:focus,[type=checkbox]:checked:hover,[type=radio]:checked:focus,[type=radio]:checked:hover{background-color:currentColor;border-color:transparent}[type=checkbox]:indeterminate{background-color:currentColor;background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3E%3Cpath stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3E%3C/svg%3E\");background-position:50%;background-repeat:no-repeat;background-size:100% 100%;border-color:transparent}@media (forced-colors:active){[type=checkbox]:indeterminate{appearance:auto}}[type=checkbox]:indeterminate:focus,[type=checkbox]:indeterminate:hover{background-color:currentColor;border-color:transparent}[type=file]{background:unset;border-color:inherit;border-radius:0;border-width:0;font-size:unset;line-height:inherit;padding:0}[type=file]:focus{outline:1px solid ButtonText;outline:1px auto -webkit-focus-ring-color}::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;}.block{display:block}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.theme-default .nl-bg{--tw-bg-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(255 255 255/var(--tw-bg-opacity));box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.theme-default .dark .nl-bg{--tw-bg-opacity:1;--tw-shadow-color:rgba(51,65,85,.7);--tw-shadow:var(--tw-shadow-colored);background-color:rgb(31 41 55/var(--tw-bg-opacity))}.theme-default .nl-description,.theme-default .nl-logo,.theme-default .nl-title{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.theme-default .dark .nl-description,.theme-default .dark .nl-logo,.theme-default .dark .nl-title{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.theme-default .nl-description a{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity));text-decoration-line:underline}.theme-default .dark .nl-description a{--tw-text-opacity:1;color:rgb(191 219 254/var(--tw-text-opacity));text-decoration-line:underline}.theme-default .nl-action-button{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity));outline:2px solid transparent;outline-offset:2px}.theme-default .nl-action-button:hover{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.theme-default .dark .nl-action-button{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity));outline:2px solid transparent;outline-offset:2px}.theme-default .dark .nl-action-button:hover{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity))}.theme-default .nl-title{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.theme-default .dark .nl-title{--tw-text-opacity:1;color:rgb(229 231 235/var(--tw-text-opacity))}.theme-default .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(255 255 255/var(--tw-bg-opacity));border-color:rgb(229 231 235/var(--tw-border-opacity));border-width:1px;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);color:rgb(31 41 55/var(--tw-text-opacity))}.theme-default .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity))}.theme-default .dark .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(15 23 42/var(--tw-bg-opacity));border-color:rgb(55 65 81/var(--tw-border-opacity));color:rgb(209 213 219/var(--tw-text-opacity))}.theme-default .dark .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity))}.theme-default .nl-divider{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.theme-default .nl-divider:before{border-top-width:1px}.theme-default .nl-divider:after,.theme-default .nl-divider:before{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity));content:var(--tw-content)}.theme-default .dark .nl-divider{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity))}.theme-default .dark .nl-divider:after,.theme-default .dark .nl-divider:before{--tw-border-opacity:1;border-color:rgb(75 85 99/var(--tw-border-opacity));content:var(--tw-content)}.theme-default .nl-footer{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.theme-default .dark .nl-footer{--tw-text-opacity:1;color:rgb(229 231 235/var(--tw-text-opacity))}.theme-default .nl-error{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity))}.theme-default .dark .nl-error{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity))}.theme-default .nl-input{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.theme-default .nl-input:focus{--tw-border-opacity:1;--tw-ring-opacity:1;--tw-ring-color:rgb(168 85 247/var(--tw-ring-opacity));border-color:rgb(168 85 247/var(--tw-border-opacity))}.theme-default .dark .nl-input{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity));color:rgb(156 163 175/var(--tw-text-opacity))}.theme-default .dark .nl-input:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(75 85 99/var(--tw-ring-opacity))}.theme-default .nl-select{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.theme-default .nl-select:focus{--tw-border-opacity:1;--tw-ring-opacity:1;--tw-ring-color:rgb(168 85 247/var(--tw-ring-opacity));border-color:rgb(168 85 247/var(--tw-border-opacity))}.theme-default .dark .nl-select{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity));color:rgb(156 163 175/var(--tw-text-opacity))}.theme-default .dark .nl-select:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(75 85 99/var(--tw-ring-opacity))}.theme-default .nl-select-list{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.theme-default .dark .nl-select-list{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity))}.theme-default .nl-select-option{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.theme-default .nl-select-option:hover{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.theme-default .nl-select-option.active-option{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity));color:rgb(30 58 138/var(--tw-text-opacity))}.theme-default .dark .nl-select-option{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.theme-default .dark .nl-select-option:hover{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity));color:rgb(209 213 219/var(--tw-text-opacity))}.theme-default .nl-text-error{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity))}.theme-default .nl-text-success{--tw-text-opacity:1;color:rgb(45 212 191/var(--tw-text-opacity))}.theme-default .nl-banner{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(255 255 255/var(--tw-bg-opacity));border-color:rgb(229 231 235/var(--tw-border-opacity));border-width:1px;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);color:rgb(31 41 55/var(--tw-text-opacity))}.theme-default .dark .nl-banner{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(15 23 42/var(--tw-bg-opacity));border-color:rgb(55 65 81/var(--tw-border-opacity));color:rgb(209 213 219/var(--tw-text-opacity))}.theme-ocean .nl-bg{--tw-bg-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(191 219 254/var(--tw-bg-opacity));box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.theme-ocean .dark .nl-bg{--tw-bg-opacity:1;--tw-shadow-color:rgba(51,65,85,.7);--tw-shadow:var(--tw-shadow-colored);background-color:rgb(8 47 73/var(--tw-bg-opacity))}.theme-ocean .nl-description,.theme-ocean .nl-logo,.theme-ocean .nl-title{--tw-text-opacity:1;color:rgb(8 47 73/var(--tw-text-opacity))}.theme-ocean .dark .nl-description,.theme-ocean .dark .nl-logo,.theme-ocean .dark .nl-title{--tw-text-opacity:1;color:rgb(186 230 253/var(--tw-text-opacity))}.theme-ocean .nl-action-button{--tw-text-opacity:1;color:rgb(8 47 73/var(--tw-text-opacity));outline:2px solid transparent;outline-offset:2px}.theme-ocean .nl-action-button:hover{--tw-bg-opacity:1;background-color:rgb(224 242 254/var(--tw-bg-opacity))}.theme-ocean .dark .nl-action-button{--tw-text-opacity:1;color:rgb(186 230 253/var(--tw-text-opacity));outline:2px solid transparent;outline-offset:2px}.theme-ocean .dark .nl-action-button:hover{--tw-bg-opacity:1;background-color:rgb(12 74 110/var(--tw-bg-opacity))}.theme-ocean .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(224 242 254/var(--tw-bg-opacity));border-color:rgb(186 230 253/var(--tw-border-opacity));border-width:1px;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);color:rgb(8 47 73/var(--tw-text-opacity))}.theme-ocean .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(240 249 255/var(--tw-bg-opacity))}.theme-ocean .dark .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(7 89 133/var(--tw-bg-opacity));border-color:rgb(8 47 73/var(--tw-border-opacity));color:rgb(186 230 253/var(--tw-text-opacity))}.theme-ocean .dark .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(12 74 110/var(--tw-bg-opacity))}.theme-ocean .nl-divider{--tw-text-opacity:1;color:rgb(8 47 73/var(--tw-text-opacity))}.theme-ocean .nl-divider:after,.theme-ocean .nl-divider:before{--tw-border-opacity:1;border-color:rgb(8 47 73/var(--tw-border-opacity));content:var(--tw-content)}.theme-ocean .dark .nl-divider{--tw-text-opacity:1;color:rgb(186 230 253/var(--tw-text-opacity))}.theme-ocean .dark .nl-divider:after,.theme-ocean .dark .nl-divider:before{--tw-border-opacity:1;border-color:rgb(186 230 253/var(--tw-border-opacity));content:var(--tw-content)}.theme-ocean .nl-footer{--tw-text-opacity:1;color:rgb(8 47 73/var(--tw-text-opacity))}.theme-ocean .dark .nl-footer{--tw-text-opacity:1;color:rgb(186 230 253/var(--tw-text-opacity))}.theme-ocean .nl-error{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity))}.theme-ocean .dark .nl-error{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity))}.theme-ocean .nl-input{--tw-bg-opacity:1;background-color:rgb(224 242 254/var(--tw-bg-opacity))}.theme-ocean .nl-input:focus{--tw-border-opacity:1;--tw-ring-opacity:1;--tw-ring-color:rgb(14 165 233/var(--tw-ring-opacity));border-color:rgb(14 165 233/var(--tw-border-opacity))}.theme-ocean .dark .nl-input{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(12 74 110/var(--tw-bg-opacity));color:rgb(56 189 248/var(--tw-text-opacity))}.theme-ocean .dark .nl-input:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(2 132 199/var(--tw-ring-opacity))}.theme-ocean .nl-select{--tw-bg-opacity:1;background-color:rgb(224 242 254/var(--tw-bg-opacity))}.theme-ocean .nl-select:focus{--tw-border-opacity:1;--tw-ring-opacity:1;--tw-ring-color:rgb(14 165 233/var(--tw-ring-opacity));border-color:rgb(14 165 233/var(--tw-border-opacity))}.theme-ocean .dark .nl-select{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(12 74 110/var(--tw-bg-opacity));color:rgb(56 189 248/var(--tw-text-opacity))}.theme-ocean .dark .nl-select:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(2 132 199/var(--tw-ring-opacity))}.theme-ocean .nl-select-list{--tw-bg-opacity:1;background-color:rgb(224 242 254/var(--tw-bg-opacity))}.theme-ocean .dark .nl-select-list{--tw-bg-opacity:1;background-color:rgb(3 105 161/var(--tw-bg-opacity))}.theme-ocean .nl-select-option{--tw-text-opacity:1;color:rgb(7 89 133/var(--tw-text-opacity))}.theme-ocean .nl-select-option:hover{--tw-bg-opacity:1;background-color:rgb(186 230 253/var(--tw-bg-opacity))}.theme-ocean .dark .nl-select-option{--tw-text-opacity:1;color:rgb(56 189 248/var(--tw-text-opacity))}.theme-ocean .dark .nl-select-option:hover{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(7 89 133/var(--tw-bg-opacity));color:rgb(125 211 252/var(--tw-text-opacity))}.theme-ocean .nl-text-error{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity))}.theme-ocean .dark .nl-text-error{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity))}.theme-ocean .nl-text-success{--tw-text-opacity:1;color:rgb(13 148 136/var(--tw-text-opacity))}.theme-ocean .dark .nl-text-success{--tw-text-opacity:1;color:rgb(45 212 191/var(--tw-text-opacity))}.theme-lemonade .nl-bg{--tw-bg-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(187 247 208/var(--tw-bg-opacity));box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.theme-lemonade .dark .nl-bg{--tw-bg-opacity:1;--tw-shadow-color:rgba(51,65,85,.7);--tw-shadow:var(--tw-shadow-colored);background-color:rgb(5 46 22/var(--tw-bg-opacity))}.theme-lemonade .nl-description,.theme-lemonade .nl-logo,.theme-lemonade .nl-title{--tw-text-opacity:1;color:rgb(5 46 22/var(--tw-text-opacity))}.theme-lemonade .dark .nl-description,.theme-lemonade .dark .nl-logo,.theme-lemonade .dark .nl-title{--tw-text-opacity:1;color:rgb(187 247 208/var(--tw-text-opacity))}.theme-lemonade .nl-action-button{--tw-text-opacity:1;color:rgb(5 46 22/var(--tw-text-opacity));outline:2px solid transparent;outline-offset:2px}.theme-lemonade .nl-action-button:hover{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity))}.theme-lemonade .dark .nl-action-button{--tw-text-opacity:1;color:rgb(187 247 208/var(--tw-text-opacity));outline:2px solid transparent;outline-offset:2px}.theme-lemonade .dark .nl-action-button:hover{--tw-bg-opacity:1;background-color:rgb(20 83 45/var(--tw-bg-opacity))}.theme-lemonade .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(220 252 231/var(--tw-bg-opacity));border-color:rgb(187 247 208/var(--tw-border-opacity));border-width:1px;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);color:rgb(5 46 22/var(--tw-text-opacity))}.theme-lemonade .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity))}.theme-lemonade .dark .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(22 101 52/var(--tw-bg-opacity));border-color:rgb(5 46 22/var(--tw-border-opacity));color:rgb(187 247 208/var(--tw-text-opacity))}.theme-lemonade .dark .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(20 83 45/var(--tw-bg-opacity))}.theme-lemonade .nl-divider{--tw-text-opacity:1;color:rgb(5 46 22/var(--tw-text-opacity))}.theme-lemonade .nl-divider:after,.theme-lemonade .nl-divider:before{--tw-border-opacity:1;border-color:rgb(5 46 22/var(--tw-border-opacity));content:var(--tw-content)}.theme-lemonade .dark .nl-divider{--tw-text-opacity:1;color:rgb(187 247 208/var(--tw-text-opacity))}.theme-lemonade .dark .nl-divider:after,.theme-lemonade .dark .nl-divider:before{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity));content:var(--tw-content)}.theme-lemonade .nl-footer{--tw-text-opacity:1;color:rgb(5 46 22/var(--tw-text-opacity))}.theme-lemonade .dark .nl-footer{--tw-text-opacity:1;color:rgb(187 247 208/var(--tw-text-opacity))}.theme-lemonade .nl-error{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity))}.theme-lemonade .dark .nl-error{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity))}.theme-lemonade .nl-input{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity))}.theme-lemonade .nl-input:focus{--tw-border-opacity:1;--tw-ring-opacity:1;--tw-ring-color:rgb(34 197 94/var(--tw-ring-opacity));border-color:rgb(34 197 94/var(--tw-border-opacity))}.theme-lemonade .dark .nl-input{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(20 83 45/var(--tw-bg-opacity));color:rgb(74 222 128/var(--tw-text-opacity))}.theme-lemonade .dark .nl-input:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(22 163 74/var(--tw-ring-opacity))}.theme-lemonade .nl-select{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity))}.theme-lemonade .nl-select:focus{--tw-border-opacity:1;--tw-ring-opacity:1;--tw-ring-color:rgb(34 197 94/var(--tw-ring-opacity));border-color:rgb(34 197 94/var(--tw-border-opacity))}.theme-lemonade .dark .nl-select{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(20 83 45/var(--tw-bg-opacity));color:rgb(74 222 128/var(--tw-text-opacity))}.theme-lemonade .dark .nl-select:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(22 163 74/var(--tw-ring-opacity))}.theme-lemonade .nl-select-list{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity))}.theme-lemonade .dark .nl-select-list{--tw-bg-opacity:1;background-color:rgb(21 128 61/var(--tw-bg-opacity))}.theme-lemonade .nl-select-option{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity))}.theme-lemonade .nl-select-option:hover{--tw-bg-opacity:1;background-color:rgb(187 247 208/var(--tw-bg-opacity))}.theme-lemonade .dark .nl-select-option{--tw-text-opacity:1;color:rgb(74 222 128/var(--tw-text-opacity))}.theme-lemonade .dark .nl-select-option:hover{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(22 101 52/var(--tw-bg-opacity));color:rgb(134 239 172/var(--tw-text-opacity))}.theme-lemonade .nl-text-error{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity))}.theme-lemonade .dark .nl-text-error{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity))}.theme-lemonade .nl-text-success{--tw-text-opacity:1;color:rgb(13 148 136/var(--tw-text-opacity))}.theme-lemonade .dark .nl-text-success{--tw-text-opacity:1;color:rgb(45 212 191/var(--tw-text-opacity))}.theme-purple .nl-bg{--tw-bg-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(233 213 255/var(--tw-bg-opacity));box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.theme-purple .dark .nl-bg{--tw-bg-opacity:1;--tw-shadow-color:rgba(51,65,85,.7);--tw-shadow:var(--tw-shadow-colored);background-color:rgb(59 7 100/var(--tw-bg-opacity))}.theme-purple .nl-description,.theme-purple .nl-logo,.theme-purple .nl-title{--tw-text-opacity:1;color:rgb(59 7 100/var(--tw-text-opacity))}.theme-purple .dark .nl-description,.theme-purple .dark .nl-logo,.theme-purple .dark .nl-title{--tw-text-opacity:1;color:rgb(233 213 255/var(--tw-text-opacity))}.theme-purple .nl-action-button{--tw-text-opacity:1;color:rgb(59 7 100/var(--tw-text-opacity));outline:2px solid transparent;outline-offset:2px}.theme-purple .nl-action-button:hover{--tw-bg-opacity:1;background-color:rgb(243 232 255/var(--tw-bg-opacity))}.theme-purple .dark .nl-action-button{--tw-text-opacity:1;color:rgb(233 213 255/var(--tw-text-opacity));outline:2px solid transparent;outline-offset:2px}.theme-purple .dark .nl-action-button:hover{--tw-bg-opacity:1;background-color:rgb(88 28 135/var(--tw-bg-opacity))}.theme-purple .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(243 232 255/var(--tw-bg-opacity));border-color:rgb(233 213 255/var(--tw-border-opacity));border-width:1px;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);color:rgb(59 7 100/var(--tw-text-opacity))}.theme-purple .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(250 245 255/var(--tw-bg-opacity))}.theme-purple .dark .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(107 33 168/var(--tw-bg-opacity));border-color:rgb(59 7 100/var(--tw-border-opacity));color:rgb(233 213 255/var(--tw-text-opacity))}.theme-purple .dark .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(88 28 135/var(--tw-bg-opacity))}.theme-purple .nl-divider{--tw-text-opacity:1;color:rgb(59 7 100/var(--tw-text-opacity))}.theme-purple .nl-divider:after,.theme-purple .nl-divider:before{--tw-border-opacity:1;border-color:rgb(59 7 100/var(--tw-border-opacity));content:var(--tw-content)}.theme-purple .dark .nl-divider{--tw-text-opacity:1;color:rgb(233 213 255/var(--tw-text-opacity))}.theme-purple .dark .nl-divider:after,.theme-purple .dark .nl-divider:before{--tw-border-opacity:1;border-color:rgb(233 213 255/var(--tw-border-opacity));content:var(--tw-content)}.theme-purple .nl-footer{--tw-text-opacity:1;color:rgb(59 7 100/var(--tw-text-opacity))}.theme-purple .dark .nl-footer{--tw-text-opacity:1;color:rgb(233 213 255/var(--tw-text-opacity))}.theme-purple .nl-error{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity))}.theme-purple .dark .nl-error{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity))}.theme-purple .nl-input{--tw-bg-opacity:1;background-color:rgb(243 232 255/var(--tw-bg-opacity))}.theme-purple .nl-input:focus{--tw-border-opacity:1;--tw-ring-opacity:1;--tw-ring-color:rgb(168 85 247/var(--tw-ring-opacity));border-color:rgb(168 85 247/var(--tw-border-opacity))}.theme-purple .dark .nl-input{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(88 28 135/var(--tw-bg-opacity));color:rgb(192 132 252/var(--tw-text-opacity))}.theme-purple .dark .nl-input:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(147 51 234/var(--tw-ring-opacity))}.theme-purple .nl-select{--tw-bg-opacity:1;background-color:rgb(243 232 255/var(--tw-bg-opacity))}.theme-purple .nl-select:focus{--tw-border-opacity:1;--tw-ring-opacity:1;--tw-ring-color:rgb(168 85 247/var(--tw-ring-opacity));border-color:rgb(168 85 247/var(--tw-border-opacity))}.theme-purple .dark .nl-select{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(88 28 135/var(--tw-bg-opacity));color:rgb(192 132 252/var(--tw-text-opacity))}.theme-purple .dark .nl-select:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(147 51 234/var(--tw-ring-opacity))}.theme-purple .nl-select-list{--tw-bg-opacity:1;background-color:rgb(243 232 255/var(--tw-bg-opacity))}.theme-purple .dark .nl-select-list{--tw-bg-opacity:1;background-color:rgb(126 34 206/var(--tw-bg-opacity))}.theme-purple .nl-select-option{--tw-text-opacity:1;color:rgb(107 33 168/var(--tw-text-opacity))}.theme-purple .nl-select-option:hover{--tw-bg-opacity:1;background-color:rgb(233 213 255/var(--tw-bg-opacity))}.theme-purple .dark .nl-select-option{--tw-text-opacity:1;color:rgb(192 132 252/var(--tw-text-opacity))}.theme-purple .dark .nl-select-option:hover{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(107 33 168/var(--tw-bg-opacity));color:rgb(216 180 254/var(--tw-text-opacity))}.theme-purple .nl-text-error{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity))}.theme-purple .dark .nl-text-error{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity))}.theme-purple .nl-text-success{--tw-text-opacity:1;color:rgb(13 148 136/var(--tw-text-opacity))}.theme-purple .dark .nl-text-success{--tw-text-opacity:1;color:rgb(45 212 191/var(--tw-text-opacity))}.theme-crab .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);background-color:rgb(254 226 226/var(--tw-bg-opacity));border-color:rgb(254 202 202/var(--tw-border-opacity));border-width:1px;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);color:rgb(69 10 10/var(--tw-text-opacity))}.theme-crab .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity))}.theme-crab .dark .nl-button{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(153 27 27/var(--tw-bg-opacity));border-color:rgb(69 10 10/var(--tw-border-opacity));color:rgb(254 202 202/var(--tw-text-opacity))}.theme-crab .dark .nl-button:hover{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity))}.show-slow{display:none;opacity:0;transition:.1s}.isOpen .show-slow{display:block;opacity:1;transition:.2s;transition-delay:.2s}:host{display:block}.animate-spin-loading{animation:spin2 1s linear infinite;background:var(--qa-dark-color)}@keyframes spin2{to{transform:rotate(1turn)}}.active{animation:blink .7s infinite alternate}@keyframes blink{0%{opacity:1}to{opacity:0}}.sr-only{clip:rect(0,0,0,0);border-width:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.left-0{left:0}.start-0{inset-inline-start:0}.top-0{top:0}.z-\\[80\\]{z-index:80}.z-\\[81\\]{z-index:81}.mx-auto{margin-left:auto;margin-right:auto}.flex{display:flex}.h-5{height:20px}.h-7{height:28px}.h-full{height:100%}.w-5{width:20px}.w-7{width:28px}.w-full{width:100%}.max-w-96{max-width:384px}.flex-shrink-0{flex-shrink:0}.cursor-pointer{cursor:pointer}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:4px}.gap-2{gap:8px}.overflow-y-auto{overflow-y:auto}.overflow-x-hidden{overflow-x:hidden}.rounded-full{border-radius:9999px}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-transparent{border-color:transparent}.bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity))}.bg-opacity-75{--tw-bg-opacity:0.75}.p-4{padding:16px}.px-4{padding-left:16px;padding-right:16px}.py-3{padding-bottom:12px}.pt-3,.py-3{padding-top:12px}.text-center{text-align:center}.text-base{font-size:16px;line-height:24px}.text-sm{font-size:14px;line-height:20px}.font-bold{font-weight:700}.font-light{font-weight:300}.font-semibold{font-weight:600}.text-blue-400{--tw-text-opacity:1;color:rgb(96 165 250/var(--tw-text-opacity))}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.dark\\:focus\\:outline-none:focus:is(.dark *){outline:2px solid transparent;outline-offset:2px}.dark\\:focus\\:ring-1:focus:is(.dark *){--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.dark\\:focus\\:ring-gray-600:focus:is(.dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(75 85 99/var(--tw-ring-opacity))}@media (min-width:640px){.sm\\:mx-auto{margin-left:auto;margin-right:auto}.sm\\:w-full{width:100%}.sm\\:max-w-lg{max-width:512px}}.inline-flex{display:inline-flex}.h-4{height:16px}.w-4{width:16px}.gap-x-2{column-gap:8px}.rounded-lg{border-radius:.5rem}.px-3{padding-left:12px;padding-right:12px}.py-2\\.5{padding-bottom:10px;padding-top:10px}.font-medium{font-weight:500}.disabled\\:pointer-events-none:disabled{pointer-events:none}.disabled\\:opacity-50:disabled{opacity:.5}.mt-1{margin-top:4px}.hidden{display:none}.min-w-\\[15rem\\]{min-width:15rem}.rotate-0{--tw-rotate:0deg}.rotate-0,.rotate-180{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate:180deg}.gap-x-3\\.5{column-gap:14px}.overflow-hidden,.truncate{overflow:hidden}.truncate{text-overflow:ellipsis;white-space:nowrap}.p-2{padding:8px}.py-2{padding-bottom:8px;padding-top:8px}.text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity))}.shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.duration-300{transition-duration:.3s}.before\\:absolute:before{content:var(--tw-content);position:absolute}.before\\:-top-4:before{content:var(--tw-content);top:-16px}.before\\:start-0:before{content:var(--tw-content);inset-inline-start:0}.before\\:h-4:before{content:var(--tw-content);height:16px}.before\\:w-full:before{content:var(--tw-content);width:100%}.after\\:absolute:after{content:var(--tw-content);position:absolute}.after\\:-bottom-4:after{bottom:-16px;content:var(--tw-content)}.after\\:start-0:after{content:var(--tw-content);inset-inline-start:0}.after\\:h-4:after{content:var(--tw-content);height:16px}.after\\:w-full:after{content:var(--tw-content);width:100%}.dark\\:border-transparent:is(.dark *){border-color:transparent}.w-auto{width:auto}.border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity))}.border-orange-300{--tw-border-opacity:1;border-color:rgb(253 186 116/var(--tw-border-opacity))}.border-red-300{--tw-border-opacity:1;border-color:rgb(252 165 165/var(--tw-border-opacity))}.border-teal-300{--tw-border-opacity:1;border-color:rgb(94 234 212/var(--tw-border-opacity))}.border-yellow-300{--tw-border-opacity:1;border-color:rgb(253 224 71/var(--tw-border-opacity))}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.bg-orange-100{--tw-bg-opacity:1;background-color:rgb(255 237 213/var(--tw-bg-opacity))}.bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity))}.bg-teal-100{--tw-bg-opacity:1;background-color:rgb(204 251 241/var(--tw-bg-opacity))}.bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity))}.px-1{padding-left:4px;padding-right:4px}.text-\\[10px\\]{font-size:10px}.text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity))}.text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity))}.text-teal-600{--tw-text-opacity:1;color:rgb(13 148 136/var(--tw-text-opacity))}.text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity))}.ml-auto,.mx-auto{margin-left:auto}.mr-auto{margin-right:auto}.mt-3{margin-top:12px}.w-60{width:240px}.pt-2{padding-top:8px}.text-4xl{font-size:36px;line-height:40px}.text-lg{font-size:18px;line-height:28px}.mb-0\\.5{margin-bottom:2px}.mb-2{margin-bottom:8px}.mb-5{margin-bottom:20px}.inline-block{display:inline-block}.max-w-72{max-width:288px}.border-\\[3px\\]{border-width:3px}.border-current{border-color:currentColor}.border-t-transparent{border-top-color:transparent}.pe-4{padding-inline-end:16px}.ps-4{padding-inline-start:16px}.text-2xl{font-size:24px;line-height:32px}.text-slate-900{--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity))}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.dark\\:text-gray-300:is(.dark *){--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity))}.mb-10{margin-bottom:40px}.ml-auto{margin-left:auto}.mt-10{margin-top:40px}.h-20{height:80px}.w-20{width:80px}.w-72{width:288px}.border-\\[4px\\]{border-width:4px}.mt-0{margin-top:0}.max-h-0{max-height:0}.max-h-\\[500px\\]{max-height:500px}.max-w-52{max-width:208px}.max-w-7{max-width:28px}.gap-0\\.5{gap:2px}.gap-3{gap:12px}.overflow-hidden{overflow:hidden}.border-b-\\[1px\\]{border-bottom-width:1px}.border-dashed{border-style:dashed}.border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity))}.border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}.border-gray-400{--tw-border-opacity:1;border-color:rgb(156 163 175/var(--tw-border-opacity))}.pb-1{padding-bottom:4px}.pb-1\\.5{padding-bottom:6px}.pb-5{padding-bottom:20px}.pt-5{padding-top:20px}.text-3xl{font-size:30px;line-height:36px}.uppercase{text-transform:uppercase}.text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity))}.decoration-dashed{text-decoration-style:dashed}.duration-\\[0\\.25s\\]{transition-duration:.25s}.ease-in{transition-timing-function:cubic-bezier(.4,0,1,1)}.hover\\:bg-gray-300:hover{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity))}.h-12{height:48px}.w-12{width:48px}.text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity))}.dark\\:text-green-200:is(.dark *){--tw-text-opacity:1;color:rgb(187 247 208/var(--tw-text-opacity))}.right-\\[-2px\\]{right:-2px}.right-\\[-3px\\]{right:-3px}.top-\\[-2px\\]{top:-2px}.top-\\[-3px\\]{top:-3px}.h-1\\.5{height:6px}.h-3{height:12px}.h-6{height:24px}.w-1\\.5{width:6px}.w-3{width:12px}.max-w-6{max-width:24px}.border-2{border-width:2px}.border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity))}.border-white{--tw-border-opacity:1;border-color:rgb(255 255 255/var(--tw-border-opacity))}.bg-green-500{--tw-bg-opacity:1;background-color:rgb(34 197 94/var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.pb-3{padding-bottom:12px}.pt-0{padding-top:0}.text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity))}.hover\\:bg-gray-400:hover{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity))}.hover\\:text-red-600:hover{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity))}.group:hover .group-hover\\:border-blue-400{--tw-border-opacity:1;border-color:rgb(96 165 250/var(--tw-border-opacity))}.pb-2{padding-bottom:8px}.pointer-events-none{pointer-events:none}.inset-y-0{bottom:0;top:0}.ps-11{padding-inline-start:44px}.peer:disabled~.peer-disabled\\:pointer-events-none{pointer-events:none}.peer:disabled~.peer-disabled\\:opacity-50{opacity:.5}.end-0{inset-inline-end:0}.h-\\[20px\\]{height:20px}.w-\\[20px\\]{width:20px}.border-\\[2px\\]{border-width:2px}.pe-11{padding-inline-end:44px}.right-0{right:0}.right-2{right:8px}.top-2{top:8px}.top-52{top:208px}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-50{z-index:50}.m-auto{margin:auto}.ml-0{margin-left:0}.ml-\\[2px\\]{margin-left:2px}.mr-0{margin-right:0}.mr-2{margin-right:8px}.mr-3\\.5{margin-right:14px}.mt-2{margin-top:8px}.grid{display:grid}.h-0{height:0}.h-8{height:32px}.h-\\[46px\\]{height:46px}.h-auto{height:auto}.w-0{width:0}.w-16{width:64px}.w-52{width:208px}.w-6{width:24px}.w-8{width:32px}.w-\\[48px\\]{width:48px}.min-w-40{min-width:160px}.max-w-40{max-width:160px}@keyframes spin{to{transform:rotate(1turn)}}.animate-spin{animation:spin 1s linear infinite}.place-items-center{place-items:center}.text-nowrap{text-wrap:nowrap}.rounded-r-lg{border-bottom-right-radius:.5rem;border-top-right-radius:.5rem}.rounded-r-none{border-bottom-right-radius:0;border-top-right-radius:0}.border-\\[0px\\]{border-width:0}.p-3{padding:12px}.px-2{padding-left:8px;padding-right:8px}.pl-\\[11px\\]{padding-left:11px}.text-xs{font-size:12px;line-height:16px}.text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity))}.opacity-0{opacity:0}.transition-all{transition-duration:.15s;transition-property:all}.ease-in-out,.transition-all{transition-timing-function:cubic-bezier(.4,0,.2,1)}.hover\\:right-2:hover{right:8px}.hover\\:rounded-r-lg:hover{border-bottom-right-radius:.5rem;border-top-right-radius:.5rem}.border-t-\\[1px\\]{border-top-width:1px}.first\\:border-none:first-child{border-style:none}.first\\:pt-0:first-child{padding-top:0}",buttonBaseCss=baseCss,ButtonBaseStyle0=buttonBaseCss,ButtonBase=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.theme="default",this.darkMode=!1,this.titleBtn="Open modal",this.disabled=!1}componentDidRender(){const e=this.element.querySelector("svg");e&&(e.classList.add("flex-shrink-0","w-4","h-4","block"),e.removeAttribute("style"))}render(){return h("div",{key:"1048576f0a9839c56cac030b1de7899b25b5f39e",class:`theme-${this.theme}`},h("div",{key:"ea29f74a1f7e4268802c6e4aaca5867dfd2e4c9b",class:"animate-spin-loading active"}),h("button",{key:"71f84d47b11aa3971818b686f8dddb74e0d36eb0",disabled:this.disabled,type:"button",class:"nl-button py-2.5 px-3 w-full inline-flex justify-center items-center gap-x-2 text-sm font-medium rounded-lg disabled:opacity-50 disabled:pointer-events-none dark:focus:outline-none dark:focus:ring-1 dark:focus:ring-gray-600"},h("slot",{key:"91a91994e20dc10e3bbb2576e4214fa98533be8e",name:"icon-start"}),this.titleBtn))}get element(){return this}static get style(){return ButtonBaseStyle0}},[4,"button-base",{theme:[1025],darkMode:[1028,"dark-mode"],titleBtn:[1,"title-btn"],disabled:[4]}]);function defineCustomElement$q(){if("undefined"==typeof customElements)return;["button-base"].forEach((e=>{if("button-base"===e)customElements.get(e)||customElements.define(e,ButtonBase)}))}defineCustomElement$q();const nlConfirmLogoutCss=baseCss,NlConfirmLogoutStyle0=nlConfirmLogoutCss,NlConfirmLogout$1=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.handleLogoutBanner=createEvent(this,"handleLogoutBanner"),this.handleBackUpModal=createEvent(this,"handleBackUpModal"),this.nlCloseModal=createEvent(this,"nlCloseModal"),this.titleModal="Delete keys?",this.description="Your profile keys are stored in this browser tab and will be deleted if you log out, and your profile will be inaccessible."}handleLogout(){this.handleLogoutBanner.emit(METHOD_MODULE.LOGOUT),this.nlCloseModal.emit()}handleCancel(){this.nlCloseModal.emit()}handleBackUp(){state.path=[CURRENT_MODULE.IMPORT_FLOW]}render(){return h("div",{key:"fe605f38f9d0a440fe53e21f19288c41e4762c22",class:"p-4 overflow-y-auto"},h("h1",{key:"84d14a59035515b2fd612d262400a038887a10d7",class:"nl-title font-bold text-center text-4xl"},this.titleModal),h("p",{key:"83ef73271c76309561be95e0207f8130d75a161c",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},this.description),h("div",{key:"fce0f132846beb95dd9e41357f5ab87be7229a56",class:"mt-3 ml-auto mr-auto w-60 flex flex-col gap-2"},h("button-base",{key:"c4fc722a7c98d84e797963ed7fe928164411b701",onClick:()=>this.handleBackUp(),titleBtn:"Backup keys",theme:"lemonade"}),h("button-base",{key:"39df385a9a8dc3fcd74f4196d4191bc4a308a16d",onClick:()=>this.handleLogout(),theme:"crab",titleBtn:"Logout and delete keys"})))}static get style(){return NlConfirmLogoutStyle0}},[0,"nl-confirm-logout",{titleModal:[1,"title-modal"],description:[1]}]);function defineCustomElement$p(){if("undefined"==typeof customElements)return;["nl-confirm-logout","button-base"].forEach((e=>{switch(e){case"nl-confirm-logout":customElements.get(e)||customElements.define(e,NlConfirmLogout$1);break;case"button-base":customElements.get(e)||defineCustomElement$q()}}))}defineCustomElement$p();const nlConnectCss=baseCss,NlConnectStyle0=nlConnectCss,NlConnect=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlNostrConnect=createEvent(this,"nlNostrConnect"),this.titleWelcome="Connect to key store",this.authMethods=[],this.hasOTP=!1,this.connectionStringServices=[],this.isOpenAdvancedLogin=!1}handleChangeScreen(e){state.path=[...state.path,e]}handleOpenAdvanced(){this.isOpenAdvancedLogin=!this.isOpenAdvancedLogin}allowAuthMethod(e){return!this.authMethods.length||this.authMethods.includes(e)}componentWillLoad(){}handleOpenLink(e,t){e.preventDefault(),this.nlNostrConnect.emit(t)}handleConnectionString(){this.handleChangeScreen(CURRENT_MODULE.CONNECTION_STRING)}render(){const e=(this.isOpenAdvancedLogin?"rotate-180":"rotate-0")+" duration-300 flex-shrink-0 w-4 h-4 text-blue-500";return h(Fragment,{key:"1927cf668a1188fe3d7646e4a7854046b5476f31"},h("div",{key:"0428eec0130c32c6ac0386f5bbc7ebf5d693a459",class:"p-4 overflow-y-auto"},h("h1",{key:"e7bb4180be357e4208c319f3cf508ed93b409d87",class:"nl-title font-bold text-center text-3xl"},this.titleWelcome)),h("div",{key:"9860c1c264fe6da144590f17067139006f4e1c96",class:"p-4"},Boolean(this.connectionStringServices.length)&&h("div",{key:"dacc446ecd659a60f90f336c513aea08d464c53f",class:"max-w-96 mx-auto pt-5"},h("p",{key:"58eee01671daa814da10883363384feb3fc0026e",class:"nl-description font-medium text-sm pb-1.5"},"Select key store:"),h("ul",{key:"cbb8cd144d9b84dc6d6555f31e6d1838002301ea",class:"p-2 rounded-lg border border-gray-200 flex flex-col w-full gap-0.5"},this.connectionStringServices.map((e=>h("li",null,h("a",{href:e.link,target:"_blank",onClick:t=>this.handleOpenLink(t,e),class:"flex items-center gap-x-3.5 w-full hover:bg-gray-300 flex cursor-pointer items-center gap-x-3.5 py-2 px-3 rounded-lg text-sm justify-between"},h("div",{class:"w-full max-w-7 h-7 flex relative"},h("div",{class:"uppercase font-bold w-full h-full rounded-full border border-gray-400 flex justify-center items-center"},Boolean(e.img)?h("img",{class:"w-full rounded-full",src:e.img,alt:e.name}):h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"#9ca3af",class:"w-4 h-4 block"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z"})))),h("div",{class:"overflow-hidden flex flex-col w-full"},h("div",{class:"nl-title truncate overflow-hidden"},e.name))))))))),h("div",{key:"654367c0e9106d1e840fedf349dc25f0452d4d4f",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"42a2ede70e15abbe98ac04cc0ff6a50d4afd5aad",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("div",{key:"a923dcb9b50dd9377711a15fc1900570db8becbe",class:"max-w-52 mx-auto pb-5"},(this.allowAuthMethod("connect")||this.allowAuthMethod("readOnly"))&&h("div",{key:"ad3520c80d4052b6579893e09d3683ec002027ba",class:"flex justify-center"},h("div",{key:"7232d7a387c3cb437ef2c7cb5c8622fea4b14416",onClick:()=>this.handleOpenAdvanced(),class:"text-blue-500 mt-3 decoration-dashed cursor-pointer inline-flex gap-2 items-center pb-1 border-dashed border-b-[1px] border-blue-500 text-sm font-light"},"Advanced",h("svg",{key:"e687b41e6e2cf3605edec3a51376228db029dcc4",class:e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},h("path",{key:"39aa6f5a53580a306f0667efb5a4cd3280cdced1",d:"m6 9 6 6 6-6"})))),h("div",{key:"dce6ddf9e7079e169f9a1e85d847f53b2897e238",class:(this.isOpenAdvancedLogin?"max-h-[500px] mt-3 duration-300":"max-h-0 mt-0 duration-[0.25s]")+" transition-max-height ease-in flex gap-3 flex-col overflow-hidden"},this.allowAuthMethod("connect")&&h("button-base",{key:"e2f193770cd51db143fed6bc398bb9131f6a61e8",titleBtn:"User name",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN)},h("svg",{key:"99d92ddfd0c142f556b77ad3cf7e9a3f2b7a74f7",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor"},h("path",{key:"60c43b645f481548a1e6cc01ba8b28d645e132d7","stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z"}))),this.allowAuthMethod("connect")&&h("button-base",{key:"e36f778cfbb4a55ba6d2a020365c70471728e2f1",titleBtn:"Connection string",onClick:()=>this.handleConnectionString()},h("svg",{key:"d7e13e1643d7ce8f339813a36d9d6633398120ca",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"67e838e2045708e9ca5f13c705c59097747dec0f","stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 4.875c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5A1.125 1.125 0 0 1 3.75 9.375v-4.5ZM3.75 14.625c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5a1.125 1.125 0 0 1-1.125-1.125v-4.5ZM13.5 4.875c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5A1.125 1.125 0 0 1 13.5 9.375v-4.5Z"}),h("path",{key:"3d7c3636ce9148b8e668aebb43260cf69991004c","stroke-linecap":"round","stroke-linejoin":"round",d:"M6.75 6.75h.75v.75h-.75v-.75ZM6.75 16.5h.75v.75h-.75v-.75ZM16.5 6.75h.75v.75h-.75v-.75ZM13.5 13.5h.75v.75h-.75v-.75ZM13.5 19.5h.75v.75h-.75v-.75ZM19.5 13.5h.75v.75h-.75v-.75ZM19.5 19.5h.75v.75h-.75v-.75ZM16.5 16.5h.75v.75h-.75v-.75Z"}))),this.allowAuthMethod("connect")&&h("button-base",{key:"54157a016b76d351aa93f0f98b1cdfb6c3548561",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN_BUNKER_URL),titleBtn:"Bunker URL"},h("svg",{key:"6c637c9fc47729887720b2c76a40d0287f68bb5f",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"45eccf5015bb2afaf15a4159a213505fe5e18de1","stroke-linecap":"round","stroke-linejoin":"round",d:"M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"}))))))}static get style(){return NlConnectStyle0}},[0,"nl-connect",{titleWelcome:[1,"title-welcome"],authMethods:[16],hasOTP:[4,"has-o-t-p"],connectionStringServices:[16],isOpenAdvancedLogin:[32]}]);function defineCustomElement$o(){if("undefined"==typeof customElements)return;["nl-connect","button-base"].forEach((e=>{switch(e){case"nl-connect":customElements.get(e)||customElements.define(e,NlConnect);break;case"button-base":customElements.get(e)||defineCustomElement$q()}}))}defineCustomElement$o();const nlIframeCss=baseCss,NlIframeStyle0=nlIframeCss,NlConfirmLogout=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlCloseModal=createEvent(this,"nlCloseModal"),this.titleModal="Confirm",this.description="Your profile keys are stored in this browser tab and will be deleted if you log out, and your profile will be inaccessible.",this.iframeUrl=""}handleCancel(){this.nlCloseModal.emit()}render(){return h("div",{key:"36ee9fd43bbb16768b7634783781ecffb1c9432a",class:"p-4 overflow-y-auto"},h("div",{key:"1634e1fd37bc44030f22bfdab9f7deec2806731b",class:"mt-3 flex flex-col gap-2"},this.iframeUrl&&h("iframe",{key:"2b1ab3032b152fb109f3531bb7600bb76aa1a562",src:this.iframeUrl,style:{width:"100%",height:"600px",border:"1px solid #ccc",borderRadius:"8px"}})))}static get style(){return NlIframeStyle0}},[0,"nl-iframe",{titleModal:[1,"title-modal"],description:[1],iframeUrl:[1,"iframe-url"]}]);function defineCustomElement$n(){if("undefined"==typeof customElements)return;["nl-iframe"].forEach((e=>{if("nl-iframe"===e)customElements.get(e)||customElements.define(e,NlConfirmLogout)}))}defineCustomElement$n();const nlSelectCss=baseCss,NlSelectStyle0=nlSelectCss,NlSelect=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.selectDomain=createEvent(this,"selectDomain"),this.isOpen=!1,this.value=null,this.options=void 0,this.selected=void 0,this.mode=!1,this.darkMode=!1,this.themeState="default",this.theme="default"}handleWindowClick(){this.wrapperRef.querySelector(".listClass")&&(this.isOpen=!1)}toggleDropdown(){this.isOpen=!this.isOpen,this.calculateDropdownPosition()}watchPropHandler(e){this.themeState=e}watchModeHandler(e){this.mode=e}connectedCallback(){this.themeState=this.theme,this.mode=this.darkMode,this.value=this.options[this.selected],this.selectDomain.emit(this.value.value)}calculateDropdownPosition(){if(this.isOpen&&this.buttonRef){const e=this.buttonRef.getBoundingClientRect();this.ulRef.style.top=`${e.height}px`}}handleChange(e){this.value=e,this.isOpen=!1,this.selectDomain.emit(this.value.value)}render(){const e=(this.isOpen?"listClass":"hidden")+" min-w-[15rem] nl-select-list absolute left-0 shadow-md rounded-lg p-2 mt-1 after:h-4 after:absolute after:-bottom-4 after:start-0 after:w-full before:h-4 before:absolute before:-top-4 before:start-0 before:w-full",t=(this.isOpen?"rotate-180":"rotate-0")+" duration-300 flex-shrink-0 w-4 h-4 text-gray-500";return h("div",{key:"c86084c50712455e04682a4392e490bc0e20eb1d",class:`theme-${this.themeState}`},h("div",{key:"a90d9b4af52845a9971c39cec69c13493d511381",class:"relative",ref:e=>this.wrapperRef=e},h("button",{key:"1391137997bf8fcd0a5466cd9fa20c79b4ce27ba",ref:e=>this.buttonRef=e,onClick:()=>this.toggleDropdown(),type:"button",class:"nl-select peer py-3 px-4 flex items-center w-full justify-between border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent"},h("span",{key:"224425ab92ba3599595924972e98a0fc9cb1a189",class:"truncate overflow-hidden"},this.value.name),h("svg",{key:"8eb2a2b552cb9ea36fb1abc61d804efb423afda6",class:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},h("path",{key:"feea1a7f54f4a111b7bf01e3945445311b97ab82",d:"m6 9 6 6 6-6"}))),h("ul",{key:"fca4982f04f4133d5c2a2f613a7e7d977dd5c241",ref:e=>this.ulRef=e,class:e},this.options.map((e=>h("li",{onClick:()=>this.handleChange(e),class:"nl-select-option flex cursor-pointer items-center gap-x-3.5 py-2 px-3 rounded-lg text-sm"},e.name))))))}get element(){return this}static get watchers(){return{theme:["watchPropHandler"],darkMode:["watchModeHandler"]}}static get style(){return NlSelectStyle0}},[0,"nl-select",{options:[16],selected:[2],darkMode:[4,"dark-mode"],theme:[1],isOpen:[32],value:[32],mode:[32],themeState:[32]},[[8,"click","handleWindowClick"]],{theme:["watchPropHandler"],darkMode:["watchModeHandler"]}]);function defineCustomElement$m(){if("undefined"==typeof customElements)return;["nl-select"].forEach((e=>{if("nl-select"===e)customElements.get(e)||customElements.define(e,NlSelect)}))}defineCustomElement$m();const nlImportFlowCss=baseCss,NlImportFlowStyle0=nlImportFlowCss,NlImportFlow$1=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlImportAccount=createEvent(this,"nlImportAccount"),this.nlExportKeys=createEvent(this,"nlExportKeys"),this.titleInfo="Back up your keys",this.titleImport="Choose a service",this.services=[],this.isContinued=!1,this.isKeyBackup=!1,this.isCopy=!1}handleDomainSelect(e){const t=this.services.find((t=>t.domain===e.detail));state.nlImport=t}handleCreateAccount(e){e.preventDefault(),this.nlImportAccount.emit(state.nlImport)}handleContinue(){this.isContinued=!0}handleContinueKeyBackup(){this.isKeyBackup=!0}async copyToClipboard(){this.nlExportKeys.emit(),this.isCopy=!0,setTimeout((()=>{this.isCopy=!1}),1500)}render(){if(!this.isContinued&&!this.isKeyBackup)return h("div",{class:"p-4 overflow-y-auto"},h("h1",{class:"nl-title font-bold text-center text-2xl"},this.titleInfo),h("p",{class:"nl-description font-light text-sm pt-2 pb-2 max-w-96 mx-auto"},"Nostr profiles are controlled by cryptographic keys.",h("br",null),h("br",null),"Your keys are currently only stored in this browser tab, and may be lost if you close it.",h("br",null),h("br",null),"You should backup your keys.",h("br",null),h("br",null),"We recommend to import your keys into a key store service, to protect them and to use with other apps."),h("div",{class:"ml-auto mr-auto mb-2 w-72"},h("button-base",{onClick:()=>this.handleContinue(),titleBtn:"Import to key store"})),h("div",{class:"ml-auto mr-auto w-72"},h("button-base",{onClick:()=>this.handleContinueKeyBackup(),titleBtn:"Export keys"})));if(this.isKeyBackup)return h("div",{class:"p-4 overflow-y-auto"},h("h1",{class:"nl-title font-bold text-center text-2xl"},"Key export"),h("p",{class:"nl-description font-light text-sm pt-2 pb-2 max-w-96 mx-auto"},"Copy your keys and store them in a safe place, like a password manager.",h("br",null),h("br",null),"You can sign into other Nostr apps by pasting your keys into them.",h("br",null),h("br",null),"Your keys must be kept secret, never share them with anyone."),h("div",{class:"max-w-72 mx-auto"},h("div",{class:"ml-auto mr-auto mb-2 w-72"},h("button-base",{onClick:()=>this.copyToClipboard(),titleBtn:this.isCopy?"Copied!":"Copy to clipboard"}))));const e=this.services.filter((e=>e.canImport)).map((e=>({name:e.domain,value:e.domain})));return h(Fragment,null,h("div",{class:"p-4 overflow-y-auto"},h("h1",{class:"nl-title font-bold text-center text-2xl"},this.titleImport),h("p",{class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},"Your Nostr keys will be imported into the service you choose. You will manage your keys on their website.")),h("div",{class:"max-w-72 mx-auto mb-5"},h("div",{class:"mb-0.5"},h("nl-select",{onSelectDomain:e=>this.handleDomainSelect(e),selected:0,options:e})),h("p",{class:"nl-title font-light text-sm mb-2"},"Default provider is a fine choice to start with."),h("div",{class:"ps-4 pe-4 overflow-y-auto"},h("p",{class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{disabled:state.isLoading,onClick:e=>this.handleCreateAccount(e),titleBtn:"Start importing"},state.isLoading?h("span",{slot:"icon-start",class:"animate-spin-loading inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}):h("svg",{slot:"icon-start",style:{display:"none"},xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M18 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0ZM3 19.235v-.11a6.375 6.375 0 0 1 12.75 0v.109A12.318 12.318 0 0 1 9.374 21c-2.331 0-4.512-.645-6.374-1.766Z"})))))}static get style(){return NlImportFlowStyle0}},[0,"nl-import-flow",{titleInfo:[1025,"title-info"],titleImport:[1,"title-import"],services:[16],isContinued:[32],isKeyBackup:[32],isCopy:[32]}]);function defineCustomElement$l(){if("undefined"==typeof customElements)return;["nl-import-flow","button-base","nl-select"].forEach((e=>{switch(e){case"nl-import-flow":customElements.get(e)||customElements.define(e,NlImportFlow$1);break;case"button-base":customElements.get(e)||defineCustomElement$q();break;case"nl-select":customElements.get(e)||defineCustomElement$m()}}))}defineCustomElement$l();const nlInfoCss=baseCss,NlInfoStyle0=nlInfoCss,NlInfo=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost()}render(){return h("div",{key:"7463f42c27643903a9d6fb0160fbabe833679fcb",class:"p-4 overflow-y-auto"},h("svg",{key:"86c5f04f87b21553f3512d289425996b46eb6c57",class:"w-12 h-12 mx-auto mb-2",width:"225",height:"224",viewBox:"0 0 225 224",fill:"none",xmlns:"http://www.w3.org/2000/svg"},h("rect",{key:"6be61e0b2ff3d3f13e617e9b1df073fbe3b5678b",width:"224.047",height:"224",rx:"64",fill:"#6951FA"}),h("path",{key:"0c0aff7d5143022fe857de141cdae31397c3c2f4",d:"M162.441 135.941V88.0593C170.359 85.1674 176 77.5348 176 68.6696C176 57.2919 166.708 48 155.33 48C143.953 48 134.661 57.2444 134.661 68.6696C134.661 77.5822 140.302 85.1674 148.219 88.0593V135.941C147.698 136.13 147.176 136.367 146.655 136.604L87.3956 77.3452C88.6282 74.6904 89.2919 71.7511 89.2919 68.6696C89.2919 57.2444 80.0474 48 68.6696 48C57.2919 48 48 57.2444 48 68.6696C48 77.5822 53.6415 85.1674 61.5585 88.0593V135.941C53.6415 138.833 48 146.465 48 155.33C48 166.708 57.2444 176 68.6696 176C80.0948 176 89.3393 166.708 89.3393 155.33C89.3393 146.418 83.6978 138.833 75.7807 135.941V88.0593C76.3022 87.8696 76.8237 87.6326 77.3452 87.3956L136.604 146.655C135.372 149.31 134.708 152.249 134.708 155.33C134.708 166.708 143.953 176 155.378 176C166.803 176 176.047 166.708 176.047 155.33C176.047 146.418 170.406 138.833 162.489 135.941H162.441Z",fill:"white"})),h("h1",{key:"3a89ee5051e2d74945347dec6055749cec126f27",class:"nl-title font-bold text-center text-4xl"},"Nostr ",h("span",{key:"96a49c22dffa4a30639f387a949d7695604c6a1f",class:"font-light"},"Login")),h("p",{key:"a6dded720da9db673173a1ff02bc5544e6a66d38",class:"text-green-800 dark:text-green-200 font-light text-center text-lg pt-2 max-w-96 mx-auto"},"Version: 1.7.11"),h("p",{key:"9d9dbd36ade753d30db448139dc057921f29697d",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},"Learn more about Nostr"," ",h("a",{key:"1811ad4f1acda7f5235566ea6f2ce8e70c62c91c",target:"_blank",href:"https://nostr.how"},"here"),".",h("br",{key:"127a6127e71f43caa1c262c6ec8108a5a6f40774"}),"This is an"," ",h("a",{key:"0e18839f8577229533eb2d2ef00f8657e6396aa1",target:"_blank",href:"https://github.com/nostrband/nostr-login"},"open-source")," ","tool by"," ",h("a",{key:"9affd14ad9dedae3e5d269a1477343eae63cd46b",target:"_blank",href:"https://nostr.band"},"Nostr.Band"),"."))}static get style(){return NlInfoStyle0}},[0,"nl-info"]);function defineCustomElement$k(){if("undefined"==typeof customElements)return;["nl-info"].forEach((e=>{if("nl-info"===e)customElements.get(e)||customElements.define(e,NlInfo)}))}defineCustomElement$k();const nlInfoExtensionCss=baseCss,NlInfoExtensionStyle0=nlInfoExtensionCss,NlInfoExtension=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost()}render(){return h("div",{key:"9335feb745c6d09a213a2e771c40262036341b54",class:"p-4 overflow-y-auto"},state.isLoadingExtension?h("div",null,h("h1",{class:"nl-title font-bold text-center text-4xl"},"Signing in..."),h("div",{class:"mt-10 mb-10 ml-auto mr-auto w-20"},h("span",{slot:"icon-start",class:"animate-spin-loading ml-auto mr-auto inline-block w-20 h-20 border-[4px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"})),h("div",{class:"ps-4 pe-4 overflow-y-auto"},h("p",{class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error))):h("div",null,h("h1",{class:"nl-title font-bold text-center text-4xl"},"Install browser extension!"),h("p",{class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},"Try"," ",h("a",{href:"https://getalby.com",target:"_blank"},"Alby"),","," ",h("a",{href:"https://chromewebstore.google.com/detail/nos2x/kpgefcfmnafjgpblomihpgmejjdanjjp",target:"_blank"},"nos2x")," ","or"," ",h("a",{href:"https://apps.apple.com/us/app/nostore/id1666553677",target:"_blank"},"Nostore"))))}static get style(){return NlInfoExtensionStyle0}},[0,"nl-info-extension"]);function defineCustomElement$j(){if("undefined"==typeof customElements)return;["nl-info-extension"].forEach((e=>{if("nl-info-extension"===e)customElements.get(e)||customElements.define(e,NlInfoExtension)}))}defineCustomElement$j();const nlLoadingCss=baseCss,NlLoadingStyle0=nlLoadingCss,NlLoading=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.stopFetchHandler=createEvent(this,"stopFetchHandler"),this.handleContinue=createEvent(this,"handleContinue"),this.path=void 0}handleStop(e){e.preventDefault(),this.stopFetchHandler.emit()}handleContinueClick(e){e.preventDefault(),this.handleContinue.emit()}render(){let e="Connecting...",t="Establishing connection to your key storage.";state.njumpIframe?(e="",t=""):this.path===CURRENT_MODULE.LOCAL_SIGNUP?(e="Creating...",t="Publishing your profile on Nostr."):state.authUrl&&(state.isLoading?(e="Confirming...",t="Please confirm the connection in your key storage app."):(e="Almost ready!",t="Continue to confirm the connection to your key storage."));const n=this.path!==CURRENT_MODULE.LOCAL_SIGNUP,r=!state.isLoading&&state.iframeUrl&&state.authUrl,o=state.iframeUrl?`${state.iframeUrl}?connect=${encodeURIComponent(state.authUrl)}`:"";return h("div",{key:"ff7ae663f31e7c0e10a0f10d45314519f08d5199",class:"p-4 overflow-y-auto"},e&&h("h1",{key:"86c13915dd489fd9182263edd47835cbe6c0c24a",class:"nl-title font-bold text-center text-4xl"},e),t&&h("p",{key:"23b2cc3700b833e0c4575c4b5833dce77b51af78",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},t),!state.njumpIframe&&!state.authUrl&&state.isLoading&&h("div",{key:"8f7da53775a410de55c26a706d70a5954ff3231c",class:"mt-10 mb-10 ml-auto mr-auto w-20"},h("span",{key:"15e94a6bf7a0a4471e2d4e6bd0bce5eb5cd3dc0a",slot:"icon-start",class:"animate-spin-loading ml-auto mr-auto inline-block w-20 h-20 border-[4px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"})),h("div",{key:"c32c535e64608e4d7bc11df9d0ee5360604ec9ea",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"73e123470d5d0466a2690cd9ba947663e550afda",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),o&&h("div",{key:"e6778c319037c8621aff5d34d1d2b3f0cbfc1c1e",class:"mt-3 ml-auto mr-auto w-72 flex justify-center"},h("iframe",{key:"d202f154ef014e96eae19e3f97432113a71127d4",src:o,width:"180px",height:"80px",style:{display:r?"block":"none",border:"0"}})),state.njumpIframe&&h("div",{key:"8fdc700c3983574930b14ea04448fb8123dfb83a",class:"mt-3 ml-auto mr-auto flex justify-center"},h("iframe",{key:"eafaf5df4a3ecbfba3d191c3e1b1c63181bdb41b",srcdoc:state.njumpIframe,width:"600px",style:{border:"0",height:"80vh",borderRadius:"8px"}})),!r&&n&&h("div",{key:"1557f1de773239d199e10249c45bc3684dee1773",class:"mt-3 ml-auto mr-auto w-72"},h("button-base",{key:"1f33346f69d5b2a670f0e507e48855376b82e679",onClick:e=>{state.authUrl&&!state.isLoading?this.handleContinueClick(e):this.handleStop(e)},titleBtn:state.isLoading?"Cancel":"Continue"})))}static get style(){return NlLoadingStyle0}},[0,"nl-loading",{path:[1]}]);function defineCustomElement$i(){if("undefined"==typeof customElements)return;["nl-loading","button-base"].forEach((e=>{switch(e){case"nl-loading":customElements.get(e)||customElements.define(e,NlLoading);break;case"button-base":customElements.get(e)||defineCustomElement$q()}}))}defineCustomElement$i();const nlLocalSignupCss=baseCss,NlLocalSignupStyle0=nlLocalSignupCss,NlLocalSignup=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlLocalSignup=createEvent(this,"nlLocalSignup"),this.nlSignupNjump=createEvent(this,"nlSignupNjump"),this.fetchHandler=createEvent(this,"fetchHandler"),this.titleSignup="Create Nostr profile",this.description="Choose any username, you can always change it later.",this.descriptionNjump="Proceed to creating your Nostr profile in a new tab.",this.signupNjump=!1,this.isAvailable=!1}handleInputChange(e){state.nlSignup.signupName=e.target.value}handleCreateAccount(e){e.preventDefault(),this.signupNjump?this.nlSignupNjump.emit():this.nlLocalSignup.emit(`${state.nlSignup.signupName}`)}render(){return h(Fragment,{key:"6ea0144cad11803864f8d6b5bc7896d8d9b413cf"},h("div",{key:"be257a544937601e20521adac8ec98b46a6c8af5",class:"p-4 overflow-y-auto"},h("h1",{key:"c8e91ccc003d0a6e344010a41bb47eeec1abdbf0",class:"nl-title font-bold text-center text-2xl"},this.titleSignup),h("p",{key:"e71ee5aa6ac01059b63ee2245800c3659301ec06",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.signupNjump?this.descriptionNjump:this.description)),h("div",{key:"516c8c44b6936554b96151a4fe4a9b6af614b554",class:"max-w-72 mx-auto"},!this.signupNjump&&h("div",{key:"a74e48d36f120fe249abfd57131c2bfde7f3dce4",class:"relative mb-2"},h("input",{key:"b77730184df9033291010d4e8ead166be726e8d9",onInput:e=>this.handleInputChange(e),type:"text",class:"nl-input peer py-3 px-4 ps-11 block w-full border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent",placeholder:"Enter username",value:state.nlSignup.signupName}),h("div",{key:"cc061801a575391e879759c5873e8256fc68f547",class:"absolute inset-y-0 start-0 flex items-center pointer-events-none ps-4 peer-disabled:opacity-50 peer-disabled:pointer-events-none"},h("svg",{key:"909c6728e8f26012647a3c9b3de8f4b16ae31e80",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:this.isAvailable?"#00cc00":"currentColor",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{key:"0306f3c147c376bbd7b01b3e2eca178f339ac167","stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z"})))),h("div",{key:"77368eeb60108aeec228e83aa206ef2b2d3fa27a",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"e87a1ae66cfaf9a75cb723a29e57c5e0ff54aabd",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"99ce9506bf5db9c26d916314e1e5700bf515f1b7",disabled:state.isLoading,onClick:e=>this.handleCreateAccount(e),titleBtn:this.signupNjump?"Get started":"Create profile"},state.isLoading?h("span",{slot:"icon-start",class:"animate-spin-loading inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}):h("svg",{slot:"icon-start",style:{display:"none"},xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M18 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0ZM3 19.235v-.11a6.375 6.375 0 0 1 12.75 0v.109A12.318 12.318 0 0 1 9.374 21c-2.331 0-4.512-.645-6.374-1.766Z"})))))}static get style(){return NlLocalSignupStyle0}},[0,"nl-local-signup",{titleSignup:[1,"title-signup"],description:[1],descriptionNjump:[1,"description-njump"],signupNjump:[4,"signup-njump"],isAvailable:[32]}]);function defineCustomElement$h(){if("undefined"==typeof customElements)return;["nl-local-signup","button-base"].forEach((e=>{switch(e){case"nl-local-signup":customElements.get(e)||customElements.define(e,NlLocalSignup);break;case"button-base":customElements.get(e)||defineCustomElement$q()}}))}defineCustomElement$h();const NlLoginStatus=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.info=void 0}render(){let e="",t="";if("extension"===this.info.authMethod)e="Extension",t="border-yellow-300 text-yellow-500 bg-yellow-100";else if("readOnly"===this.info.authMethod)e="Read only",t="border-gray-300 text-gray-400 bg-gray-100";else if("connect"===this.info.authMethod)e="Connect",t="border-teal-300 text-teal-600 bg-teal-100";else if("local"===this.info.authMethod)e="Temporary",t="border-red-300 text-red-600 bg-red-100";else{if("otp"!==this.info.authMethod)throw console.log("unknown auth method",this.info),new Error("Unknown auth method");e="Delegated",t="border-orange-300 text-orange-600 bg-orange-100"}return h("div",{key:"f0e9b20820467a4c427fa60bd1879e3ac7cc7f62"},h("span",{key:"4c96936eac7dbe558e398f9cff963873659f4aec",class:`${t} rounded-xl border w-auto text-[10px] px-1 `},e))}},[0,"nl-login-status",{info:[16]}]);function defineCustomElement$g(){if("undefined"==typeof customElements)return;["nl-login-status"].forEach((e=>{if("nl-login-status"===e)customElements.get(e)||customElements.define(e,NlLoginStatus)}))}defineCustomElement$g();const nlOtpMigrateCss=baseCss,NlOtpMigrateStyle0=nlOtpMigrateCss,NlImportFlow=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlImportAccount=createEvent(this,"nlImportAccount"),this.titleInfo="Import keys to storage service",this.titleImport="Choose a service",this.textImport="You will be prompted to import keys to the chosen service, and this website will connect to your keys.",this.services=[]}handleDomainSelect(e){const t=this.services.find((t=>t.domain===e.detail));state.nlImport=t}handleCreateAccount(e){e.preventDefault(),this.nlImportAccount.emit(state.nlImport)}render(){const e=this.services.filter((e=>e.canImport)).map((e=>({name:e.domain,value:e.domain})));return h(Fragment,{key:"8295d7fd819696a264100c3c1834a7e943f3f60e"},h("div",{key:"4d0e48726fccfe24be45db8ef328b25b4778763c",class:"p-4 overflow-y-auto"},h("h1",{key:"8a035ea913fa770188e62557971649a223fe7ed8",class:"nl-title font-bold text-center text-2xl"},this.titleImport),h("p",{key:"ad9c8565205acafeea8ab3991cc405ae84a6c95a",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.textImport)),h("div",{key:"7ee07d8ac0fc0278f342e794686126465b643278",class:"max-w-72 mx-auto mb-5"},h("div",{key:"677ca636b72bcefc6092e2e09b8c0ad445a956f6",class:"mb-0.5"},h("nl-select",{key:"8ec042faaa8319c0d683818cfa5321c20b2e6a57",onSelectDomain:e=>this.handleDomainSelect(e),selected:0,options:e})),h("p",{key:"d6348d95a65a003047e0961a9b8b86835bcebf1f",class:"nl-title font-light text-sm mb-2"},"Default provider is a fine choice to start with."),h("div",{key:"df09b9b23fd192407f797d8b191a30ca3a649142",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"77901d809985d421f9be1e7ff6e5263db52aa37f",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"87eb6648d8d5e4e4990f745c507bcaacddc6676a",disabled:state.isLoading,onClick:e=>this.handleCreateAccount(e),titleBtn:"Start importing"},state.isLoading?h("span",{slot:"icon-start",class:"animate-spin-loading inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}):h("svg",{slot:"icon-start",style:{display:"none"},xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M18 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0ZM3 19.235v-.11a6.375 6.375 0 0 1 12.75 0v.109A12.318 12.318 0 0 1 9.374 21c-2.331 0-4.512-.645-6.374-1.766Z"})))))}static get style(){return NlOtpMigrateStyle0}},[0,"nl-otp-migrate",{titleInfo:[1025,"title-info"],titleImport:[1,"title-import"],textImport:[1,"text-import"],services:[16]}]);function defineCustomElement$f(){if("undefined"==typeof customElements)return;["nl-otp-migrate","button-base","nl-select"].forEach((e=>{switch(e){case"nl-otp-migrate":customElements.get(e)||customElements.define(e,NlImportFlow);break;case"button-base":customElements.get(e)||defineCustomElement$q();break;case"nl-select":customElements.get(e)||defineCustomElement$m()}}))}defineCustomElement$f();const nlPreviouslyLoggedCss=baseCss,NlPreviouslyLoggedStyle0=nlPreviouslyLoggedCss,NlPreviouslyLogged=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlSwitchAccount=createEvent(this,"nlSwitchAccount"),this.nlLoginRecentAccount=createEvent(this,"nlLoginRecentAccount"),this.nlRemoveRecent=createEvent(this,"nlRemoveRecent"),this.titlePage="Your profiles",this.description="Switch between active profiles or choose a recent one for fast login.",this.accounts=[],this.recents=[]}handleGoToWelcome(){state.path=[CURRENT_MODULE.WELCOME]}switchToWelcomeIfEmpty(){this.recents.length||this.accounts.length||(state.path=[CURRENT_MODULE.WELCOME])}watchAccounts(){this.switchToWelcomeIfEmpty()}watchRecents(){this.switchToWelcomeIfEmpty()}handleRemoveRecent(e){this.nlRemoveRecent.emit(e)}handleSwitch(e){this.nlSwitchAccount.emit(e)}handleLoginRecentAccount(e){this.nlLoginRecentAccount.emit(e)}render(){return h(Fragment,{key:"cd2b0c3c8949cf948e41ded42e7f75ef079fccc4"},h("div",{key:"32115943896e66bc20490610e26bd01f9e14457a",class:"p-4 pt-0 overflow-y-auto"},h("h1",{key:"a889d10b7704cdc080f48cde372f505896b456b6",class:"nl-title font-bold text-center text-4xl"},this.titlePage),h("p",{key:"030784a7a9b4366bd4dcf1755b470f2bfbdf4c14",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"a8c2afeeebc96527e1ca5b36cb3a2a544f6d50b4",class:"p-4"},Boolean(this.accounts.length)&&h("div",{key:"1f504e1448c1c60c9cf97eb5e18328d8935af54d",class:"max-w-96 mx-auto"},h("p",{key:"fed353027e7847653d869bef971229b6e862b6f3",class:"nl-description font-medium text-sm pb-1.5"},"Active profiles"),h("ul",{key:"d8aa546725b5248e180d88bb384521076eeb3a30",class:"p-2 rounded-lg border border-blue-200 flex flex-col w-full gap-0.5"},this.accounts.map((e=>{const t=Boolean(null==e?void 0:e.picture),n=e.name||e.nip05||e.pubkey,r=Boolean(n);return h("li",{onClick:()=>this.handleSwitch(e),class:"group hover:bg-gray-400 flex cursor-pointer gap-x-3.5 py-2 px-3 rounded-lg text-sm items-center justify-between"},h("div",{class:"flex items-center gap-x-3.5 w-full"},h("div",{class:"w-full max-w-7 h-7 flex relative"},h("div",{class:"absolute top-[-2px] right-[-2px] bg-white border-2 border-white rounded-xl"},h("div",{class:"active h-1.5 w-1.5 bg-green-500 rounded-xl"})),h("div",{class:"group-hover:border-blue-400 uppercase font-bold w-full h-full rounded-full border border-gray-400 flex justify-center items-center"},t?h("img",{class:"w-full rounded-full",src:e.picture,alt:"Logo"}):r?n[0]:h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-full"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})))),h("div",{class:"overflow-hidden flex flex-col w-full"},h("div",{class:"nl-title truncate overflow-hidden"},n),h("nl-login-status",{info:e}))))})))),Boolean(this.recents.length)&&h("div",{key:"15a0033a26712020d4cdc0665335047215dcb6fc",class:"max-w-96 mx-auto pt-5"},h("p",{key:"95d4c1270ebe75291b4ccb0b98ad8002a6e6d6b3",class:"nl-description font-medium text-sm pb-1.5"},"Recent profiles"),h("ul",{key:"9e126af579e621e51c9b3cc66585b0285c941e52",class:"p-2 rounded-lg border border-gray-200 flex flex-col w-full gap-0.5"},this.recents.map((e=>{const t=Boolean(null==e?void 0:e.picture),n=e.name||e.nip05||e.pubkey,r=Boolean(n);return h("li",{onClick:()=>this.handleLoginRecentAccount(e),class:"flex items-center gap-x-3.5 w-full hover:bg-gray-400 flex cursor-pointer items-center gap-x-3.5 py-2 px-3 rounded-lg text-sm justify-between"},h("div",{class:"w-full max-w-7 h-7 flex relative"},h("div",{class:"absolute top-[-3px] right-[-3px] bg-white border border-white rounded-xl"},h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-3 h-3"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}))),h("div",{class:"uppercase font-bold w-full h-full rounded-full border border-gray-400 flex justify-center items-center"},t?h("img",{class:"w-full rounded-full",src:e.picture,alt:"Logo"}):r?n[0]:h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-full"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})))),h("div",{class:"overflow-hidden flex flex-col w-full"},h("div",{class:"nl-title truncate overflow-hidden"},n),h("nl-login-status",{info:e})),h("svg",{onClick:t=>{t.stopPropagation(),this.handleRemoveRecent(e)},xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-full max-w-6 h-6 text-red-500 hover:text-red-600 ml-auto"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})))}))))),h("div",{key:"4c1788fd1722ec954333fc024b502b56c397c5b8",class:"p-4 overflow-y-auto"},h("p",{key:"6f7ab030e88c3cb08b45533c465ab4dc4ca1cacb",class:"nl-footer font-light text-center text-sm max-w-96 mx-auto"},"You can also"," ",h("span",{key:"bf4e2b5222afab40c8098ebd22025596df85bf7f",onClick:()=>this.handleGoToWelcome(),class:"cursor-pointer pb-3 text-blue-500"},"add another profile"))))}static get watchers(){return{accounts:["watchAccounts"],recents:["watchRecents"]}}static get style(){return NlPreviouslyLoggedStyle0}},[0,"nl-previously-logged",{titlePage:[1,"title-page"],description:[1],accounts:[16],recents:[16]},void 0,{accounts:["watchAccounts"],recents:["watchRecents"]}]);function defineCustomElement$e(){if("undefined"==typeof customElements)return;["nl-previously-logged","nl-login-status"].forEach((e=>{switch(e){case"nl-previously-logged":customElements.get(e)||customElements.define(e,NlPreviouslyLogged);break;case"nl-login-status":customElements.get(e)||defineCustomElement$g()}}))}defineCustomElement$e();const nlSigninCss=baseCss,NlSigninStyle0=nlSigninCss,NlSignin=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlLogin=createEvent(this,"nlLogin"),this.nlCheckLogin=createEvent(this,"nlCheckLogin"),this.titleLogin="Connect to key store",this.description="Please enter your user name.",this.isGood=!1}handleInputChange(e){state.nlSignin.loginName=e.target.value,this.nlCheckLogin.emit(e.target.value)}handleLogin(e){e.preventDefault(),this.nlLogin.emit(state.nlSignin.loginName)}render(){return h(Fragment,{key:"9375186e2638a4ec14c0fd6bd4954c68a6695d0a"},h("div",{key:"915342c0300b6ac7f6c5c84060117cf4b54c1bb2",class:"p-4 overflow-y-auto"},h("h1",{key:"c43f028b47c5ac566afda65cca1728fdade271a8",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h("p",{key:"d55111de6c8da0e06b957eb97fc66c3f25dd19a0",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"4105fbbe19bf83b1eb23d2b75bf936abc121db52",class:"max-w-72 mx-auto"},h("div",{key:"319964a6a9cdce3e2857a3722212f9f2c14a9657",class:"relative mb-2"},h("input",{key:"5016006907ecde3717f9ef32a04a5a93e5e8dd1c",onInput:e=>this.handleInputChange(e),type:"text",class:"nl-input peer py-3 px-4 ps-11 block w-full border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent",placeholder:"name@domain.com",value:state.nlSignin.loginName}),h("div",{key:"1a02c7e5b6ece79557e05c67f10fae224b3eab13",class:"absolute inset-y-0 start-0 flex items-center pointer-events-none ps-4 peer-disabled:opacity-50 peer-disabled:pointer-events-none"},h("svg",{key:"4ed7bc02af0383f5d378132df916a40eab90594d",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:this.isGood?"#00cc00":"currentColor",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{key:"f6d18366b44aaa84f72a7f4c8c6bc4de9d914254","stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z"})))),h("div",{key:"9325a0734cee2e749f8d0bd24177f0ae98031769",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"692b415ff9e06d6c79cd893bb01eadb6cc0dcaf6",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"b53079a6c2d6551ab18f9abe46d28bcfa3ee1e63",titleBtn:"Connect",disabled:state.isLoading,onClick:e=>this.handleLogin(e)},state.isLoading?h("span",{slot:"icon-start",class:"animate-spin-loading inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}):h("svg",{style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 9V5.25A2.25 2.25 0 0 1 10.5 3h6a2.25 2.25 0 0 1 2.25 2.25v13.5A2.25 2.25 0 0 1 16.5 21h-6a2.25 2.25 0 0 1-2.25-2.25V15M12 9l3 3m0 0-3 3m3-3H2.25"})))))}static get style(){return NlSigninStyle0}},[0,"nl-signin",{titleLogin:[1,"title-login"],description:[1],isGood:[32]}]);function defineCustomElement$d(){if("undefined"==typeof customElements)return;["nl-signin","button-base"].forEach((e=>{switch(e){case"nl-signin":customElements.get(e)||customElements.define(e,NlSignin);break;case"button-base":customElements.get(e)||defineCustomElement$q()}}))}defineCustomElement$d();const nlSigninBunkerUrlCss=baseCss,NlSigninBunkerUrlStyle0=nlSigninBunkerUrlCss,NlSigninBunkerUrl=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlLogin=createEvent(this,"nlLogin"),this.nlCheckLogin=createEvent(this,"nlCheckLogin"),this.titleLogin="Connect with bunker url",this.description="Please enter a bunker url provided by key store.",this.isGood=!1}handleInputChange(e){state.nlSigninBunkerUrl.loginName=e.target.value,this.nlCheckLogin.emit(e.target.value)}handleLogin(e){e.preventDefault(),this.nlLogin.emit(state.nlSigninBunkerUrl.loginName)}render(){return h(Fragment,{key:"3a422253215916369f1c65894fd90e17732a735e"},h("div",{key:"ace79364c3c4c858b43746a5c5e05f925c78402b",class:"p-4 overflow-y-auto"},h("h1",{key:"1c7cdc50eff87cac91f4387b96f89109ca84f7cd",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h("p",{key:"dd25754386d05d8cc4035e29b9aa555de08756e1",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"1684b906cd07ec17d55db1f1f1aad37ba9b72121",class:"max-w-72 mx-auto"},h("div",{key:"ec6a77d2793a0e4ea383991ddcc593c8235e3443",class:"relative mb-2"},h("input",{key:"2f8440550f9db57b131556c5d4e88228cc2db277",onInput:e=>this.handleInputChange(e),type:"text",class:"nl-input peer py-3 px-4 ps-11 block w-full border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent",placeholder:"bunker://...",value:state.nlSigninBunkerUrl.loginName}),h("div",{key:"7718e520a18b35bdd89b6c4f835e01c304b9dcbb",class:"absolute inset-y-0 start-0 flex items-center pointer-events-none ps-4 peer-disabled:opacity-50 peer-disabled:pointer-events-none"},h("svg",{key:"f0c09de6a0cc3040cd7a52815e83318e270706b4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:this.isGood?"#00cc00":"currentColor",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{key:"93069f3407609c925ee8d14bea26245cf12afe9b","stroke-linecap":"round","stroke-linejoin":"round",d:"M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"})))),h("div",{key:"94a2a34d9275dbf6fa9819f71eb819f1fcffcdf0",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"9bfbaadcac84780014802805aa82ff8b079dd698",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"30534a179e1fbdfd3849de2b7d2dcc9b15351444",titleBtn:"Connect",disabled:state.isLoading,onClick:e=>this.handleLogin(e)},state.isLoading?h("span",{slot:"icon-start",class:"animate-spin-loading inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}):h("svg",{style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 9V5.25A2.25 2.25 0 0 1 10.5 3h6a2.25 2.25 0 0 1 2.25 2.25v13.5A2.25 2.25 0 0 1 16.5 21h-6a2.25 2.25 0 0 1-2.25-2.25V15M12 9l3 3m0 0-3 3m3-3H2.25"})))))}static get style(){return NlSigninBunkerUrlStyle0}},[0,"nl-signin-bunker-url",{titleLogin:[1,"title-login"],description:[1],isGood:[32]}]);function defineCustomElement$c(){if("undefined"==typeof customElements)return;["nl-signin-bunker-url","button-base"].forEach((e=>{switch(e){case"nl-signin-bunker-url":customElements.get(e)||customElements.define(e,NlSigninBunkerUrl);break;case"button-base":customElements.get(e)||defineCustomElement$q()}}))}defineCustomElement$c();var browser$1={},canPromise$1=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then},qrcode={},utils$1$1={};let toSJISFunction;const CODEWORDS_COUNT=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];utils$1$1.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return 4*e+17},utils$1$1.getSymbolTotalCodewords=function(e){return CODEWORDS_COUNT[e]},utils$1$1.getBCHDigit=function(e){let t=0;for(;0!==e;)t++,e>>>=1;return t},utils$1$1.setToSJISFunction=function(e){if("function"!=typeof e)throw new Error('"toSJISFunc" is not a valid function.');toSJISFunction=e},utils$1$1.isKanjiModeEnabled=function(){return void 0!==toSJISFunction},utils$1$1.toSJIS=function(e){return toSJISFunction(e)};var errorCorrectionLevel={},exports$1;function BitBuffer$1(){this.buffer=[],this.length=0}exports$1=errorCorrectionLevel,exports$1.L={bit:1},exports$1.M={bit:0},exports$1.Q={bit:3},exports$1.H={bit:2},exports$1.isValid=function(e){return e&&void 0!==e.bit&&e.bit>=0&&e.bit<4},exports$1.from=function(e,t){if(exports$1.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return exports$1.L;case"m":case"medium":return exports$1.M;case"q":case"quartile":return exports$1.Q;case"h":case"high":return exports$1.H;default:throw new Error("Unknown EC Level: "+e)}}(e)}catch(e){return t}},BitBuffer$1.prototype={get:function(e){const t=Math.floor(e/8);return 1==(this.buffer[t]>>>7-e%8&1)},put:function(e,t){for(let n=0;n<t;n++)this.putBit(1==(e>>>t-n-1&1))},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var bitBuffer=BitBuffer$1;function BitMatrix$1(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}BitMatrix$1.prototype.set=function(e,t,n,r){const o=e*this.size+t;this.data[o]=n,r&&(this.reservedBit[o]=!0)},BitMatrix$1.prototype.get=function(e,t){return this.data[e*this.size+t]},BitMatrix$1.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},BitMatrix$1.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var bitMatrix=BitMatrix$1,alignmentPattern={};!function(e){const t=utils$1$1.getSymbolSize;e.getRowColCoords=function(e){if(1===e)return[];const n=Math.floor(e/7)+2,r=t(e),o=145===r?26:2*Math.ceil((r-13)/(2*n-2)),s=[r-7];for(let e=1;e<n-1;e++)s[e]=s[e-1]-o;return s.push(6),s.reverse()},e.getPositions=function(t){const n=[],r=e.getRowColCoords(t),o=r.length;for(let e=0;e<o;e++)for(let t=0;t<o;t++)0===e&&0===t||0===e&&t===o-1||e===o-1&&0===t||n.push([r[e],r[t]]);return n}}(alignmentPattern);var finderPattern={};const getSymbolSize=utils$1$1.getSymbolSize,FINDER_PATTERN_SIZE=7;finderPattern.getPositions=function(e){const t=getSymbolSize(e);return[[0,0],[t-FINDER_PATTERN_SIZE,0],[0,t-FINDER_PATTERN_SIZE]]};var maskPattern={};!function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t=3,n=3,r=40,o=10;function s(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}}e.isValid=function(e){return null!=e&&""!==e&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){const n=e.size;let r=0,o=0,s=0,i=null,a=null;for(let l=0;l<n;l++){o=s=0,i=a=null;for(let c=0;c<n;c++){let n=e.get(l,c);n===i?o++:(o>=5&&(r+=t+(o-5)),i=n,o=1),n=e.get(c,l),n===a?s++:(s>=5&&(r+=t+(s-5)),a=n,s=1)}o>=5&&(r+=t+(o-5)),s>=5&&(r+=t+(s-5))}return r},e.getPenaltyN2=function(e){const t=e.size;let r=0;for(let n=0;n<t-1;n++)for(let o=0;o<t-1;o++){const t=e.get(n,o)+e.get(n,o+1)+e.get(n+1,o)+e.get(n+1,o+1);4!==t&&0!==t||r++}return r*n},e.getPenaltyN3=function(e){const t=e.size;let n=0,o=0,s=0;for(let r=0;r<t;r++){o=s=0;for(let i=0;i<t;i++)o=o<<1&2047|e.get(r,i),i>=10&&(1488===o||93===o)&&n++,s=s<<1&2047|e.get(i,r),i>=10&&(1488===s||93===s)&&n++}return n*r},e.getPenaltyN4=function(e){let t=0;const n=e.data.length;for(let r=0;r<n;r++)t+=e.data[r];return Math.abs(Math.ceil(100*t/n/5)-10)*o},e.applyMask=function(e,t){const n=t.size;for(let r=0;r<n;r++)for(let o=0;o<n;o++)t.isReserved(o,r)||t.xor(o,r,s(e,o,r))},e.getBestMask=function(t,n){const r=Object.keys(e.Patterns).length;let o=0,s=1/0;for(let i=0;i<r;i++){n(i),e.applyMask(i,t);const r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(i,t),r<s&&(s=r,o=i)}return o}}(maskPattern);var errorCorrectionCode={};const ECLevel$1=errorCorrectionLevel,EC_BLOCKS_TABLE=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],EC_CODEWORDS_TABLE=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];errorCorrectionCode.getBlocksCount=function(e,t){switch(t){case ECLevel$1.L:return EC_BLOCKS_TABLE[4*(e-1)+0];case ECLevel$1.M:return EC_BLOCKS_TABLE[4*(e-1)+1];case ECLevel$1.Q:return EC_BLOCKS_TABLE[4*(e-1)+2];case ECLevel$1.H:return EC_BLOCKS_TABLE[4*(e-1)+3];default:return}},errorCorrectionCode.getTotalCodewordsCount=function(e,t){switch(t){case ECLevel$1.L:return EC_CODEWORDS_TABLE[4*(e-1)+0];case ECLevel$1.M:return EC_CODEWORDS_TABLE[4*(e-1)+1];case ECLevel$1.Q:return EC_CODEWORDS_TABLE[4*(e-1)+2];case ECLevel$1.H:return EC_CODEWORDS_TABLE[4*(e-1)+3];default:return}};var polynomial={},galoisField={};const EXP_TABLE=new Uint8Array(512),LOG_TABLE=new Uint8Array(256);!function(){let e=1;for(let t=0;t<255;t++)EXP_TABLE[t]=e,LOG_TABLE[e]=t,e<<=1,256&e&&(e^=285);for(let e=255;e<512;e++)EXP_TABLE[e]=EXP_TABLE[e-255]}(),galoisField.log=function(e){if(e<1)throw new Error("log("+e+")");return LOG_TABLE[e]},galoisField.exp=function(e){return EXP_TABLE[e]},galoisField.mul=function(e,t){return 0===e||0===t?0:EXP_TABLE[LOG_TABLE[e]+LOG_TABLE[t]]},function(e){const t=galoisField;e.mul=function(e,n){const r=new Uint8Array(e.length+n.length-1);for(let o=0;o<e.length;o++)for(let s=0;s<n.length;s++)r[o+s]^=t.mul(e[o],n[s]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){const e=r[0];for(let o=0;o<n.length;o++)r[o]^=t.mul(n[o],e);let o=0;for(;o<r.length&&0===r[o];)o++;r=r.slice(o)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let o=0;o<n;o++)r=e.mul(r,new Uint8Array([1,t.exp(o)]));return r}}(polynomial);const Polynomial=polynomial;function ReedSolomonEncoder$1(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}ReedSolomonEncoder$1.prototype.initialize=function(e){this.degree=e,this.genPoly=Polynomial.generateECPolynomial(this.degree)},ReedSolomonEncoder$1.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");const t=new Uint8Array(e.length+this.degree);t.set(e);const n=Polynomial.mod(t,this.genPoly),r=this.degree-n.length;if(r>0){const e=new Uint8Array(this.degree);return e.set(n,r),e}return n};var reedSolomonEncoder=ReedSolomonEncoder$1,version={},mode={},versionCheck={isValid:function(e){return!isNaN(e)&&e>=1&&e<=40}},regex$1={};const numeric="[0-9]+",alphanumeric="[A-Z $%*+\\-./:]+";let kanji="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";kanji=kanji.replace(/u/g,"\\u");const byte="(?:(?![A-Z0-9 $%*+\\-./:]|"+kanji+")(?:.|[\r\n]))+";regex$1.KANJI=new RegExp(kanji,"g"),regex$1.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),regex$1.BYTE=new RegExp(byte,"g"),regex$1.NUMERIC=new RegExp(numeric,"g"),regex$1.ALPHANUMERIC=new RegExp(alphanumeric,"g");const TEST_KANJI=new RegExp("^"+kanji+"$"),TEST_NUMERIC=new RegExp("^"+numeric+"$"),TEST_ALPHANUMERIC=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");regex$1.testKanji=function(e){return TEST_KANJI.test(e)},regex$1.testNumeric=function(e){return TEST_NUMERIC.test(e)},regex$1.testAlphanumeric=function(e){return TEST_ALPHANUMERIC.test(e)},function(e){const t=versionCheck,n=regex$1;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!t.isValid(n))throw new Error("Invalid version: "+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")},e.isValid=function(e){return e&&e.bit&&e.ccBits},e.from=function(t,n){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+t)}}(t)}catch(e){return n}}}(mode),function(e){const t=utils$1$1,n=errorCorrectionCode,r=errorCorrectionLevel,o=mode,s=versionCheck,i=t.getBCHDigit(7973);function a(e,t){return o.getCharCountIndicator(e,t)+4}function l(e,t){let n=0;return e.forEach((function(e){const r=a(e.mode,t);n+=r+e.getBitsLength()})),n}e.from=function(e,t){return s.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,i){if(!s.isValid(e))throw new Error("Invalid QR Code version");void 0===i&&(i=o.BYTE);const l=8*(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r));if(i===o.MIXED)return l;const c=l-a(i,e);switch(i){case o.NUMERIC:return Math.floor(c/10*3);case o.ALPHANUMERIC:return Math.floor(c/11*2);case o.KANJI:return Math.floor(c/13);case o.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(t,n){let s;const i=r.from(n,r.M);if(Array.isArray(t)){if(t.length>1)return function(t,n){for(let r=1;r<=40;r++)if(l(t,r)<=e.getCapacity(r,n,o.MIXED))return r}(t,i);if(0===t.length)return 1;s=t[0]}else s=t;return function(t,n,r){for(let o=1;o<=40;o++)if(n<=e.getCapacity(o,r,t))return o}(s.mode,s.getLength(),i)},e.getEncodedBits=function(e){if(!s.isValid(e)||e<7)throw new Error("Invalid QR Code version");let n=e<<12;for(;t.getBCHDigit(n)-i>=0;)n^=7973<<t.getBCHDigit(n)-i;return e<<12|n}}(version);var formatInfo={};const Utils$3=utils$1$1,G15=1335,G15_MASK=21522,G15_BCH=Utils$3.getBCHDigit(G15);formatInfo.getEncodedBits=function(e,t){const n=e.bit<<3|t;let r=n<<10;for(;Utils$3.getBCHDigit(r)-G15_BCH>=0;)r^=G15<<Utils$3.getBCHDigit(r)-G15_BCH;return(n<<10|r)^G15_MASK};var segments={};const Mode$4=mode;function NumericData(e){this.mode=Mode$4.NUMERIC,this.data=e.toString()}NumericData.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},NumericData.prototype.getLength=function(){return this.data.length},NumericData.prototype.getBitsLength=function(){return NumericData.getBitsLength(this.data.length)},NumericData.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);const o=this.data.length-t;o>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,3*o+1))};var numericData=NumericData;const Mode$3=mode,ALPHA_NUM_CHARS=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function AlphanumericData(e){this.mode=Mode$3.ALPHANUMERIC,this.data=e}AlphanumericData.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},AlphanumericData.prototype.getLength=function(){return this.data.length},AlphanumericData.prototype.getBitsLength=function(){return AlphanumericData.getBitsLength(this.data.length)},AlphanumericData.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=45*ALPHA_NUM_CHARS.indexOf(this.data[t]);n+=ALPHA_NUM_CHARS.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(ALPHA_NUM_CHARS.indexOf(this.data[t]),6)};var alphanumericData=AlphanumericData;const Mode$2=mode;function ByteData(e){this.mode=Mode$2.BYTE,this.data="string"==typeof e?(new TextEncoder).encode(e):new Uint8Array(e)}ByteData.getBitsLength=function(e){return 8*e},ByteData.prototype.getLength=function(){return this.data.length},ByteData.prototype.getBitsLength=function(){return ByteData.getBitsLength(this.data.length)},ByteData.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var byteData=ByteData;const Mode$1=mode,Utils$2=utils$1$1;function KanjiData(e){this.mode=Mode$1.KANJI,this.data=e}KanjiData.getBitsLength=function(e){return 13*e},KanjiData.prototype.getLength=function(){return this.data.length},KanjiData.prototype.getBitsLength=function(){return KanjiData.getBitsLength(this.data.length)},KanjiData.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=Utils$2.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[t]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),e.put(n,13)}};var kanjiData=KanjiData,dijkstra={exports:{}};!function(e){var t={single_source_shortest_paths:function(e,n,r){var o={},s={};s[n]=0;var i,a,l,c,d,h,u,p=t.PriorityQueue.make();for(p.push(n,0);!p.empty();)for(l in a=(i=p.pop()).value,c=i.cost,d=e[a]||{})d.hasOwnProperty(l)&&(h=c+d[l],u=s[l],(void 0===s[l]||u>h)&&(s[l]=h,p.push(l,h),o[l]=a));if(void 0!==r&&void 0===s[r]){var f=["Could not find a path from ",n," to ",r,"."].join("");throw new Error(f)}return o},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),r=e[r];return n.reverse(),n},find_path:function(e,n,r){var o=t.single_source_shortest_paths(e,n,r);return t.extract_shortest_path_from_predecessor_list(o,r)},PriorityQueue:{make:function(e){var n,r=t.PriorityQueue,o={};for(n in e=e||{},r)r.hasOwnProperty(n)&&(o[n]=r[n]);return o.queue=[],o.sorter=e.sorter||r.default_sorter,o},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};e.exports=t}(dijkstra),function(e){const t=mode,n=numericData,r=alphanumericData,o=byteData,s=kanjiData,i=regex$1,a=utils$1$1,l=dijkstra.exports;function c(e){return unescape(encodeURIComponent(e)).length}function d(e,t,n){const r=[];let o;for(;null!==(o=e.exec(n));)r.push({data:o[0],index:o.index,mode:t,length:o[0].length});return r}function h(e){const n=d(i.NUMERIC,t.NUMERIC,e),r=d(i.ALPHANUMERIC,t.ALPHANUMERIC,e);let o,s;a.isKanjiModeEnabled()?(o=d(i.BYTE,t.BYTE,e),s=d(i.KANJI,t.KANJI,e)):(o=d(i.BYTE_KANJI,t.BYTE,e),s=[]);return n.concat(r,o,s).sort((function(e,t){return e.index-t.index})).map((function(e){return{data:e.data,mode:e.mode,length:e.length}}))}function u(e,i){switch(i){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return s.getBitsLength(e);case t.BYTE:return o.getBitsLength(e)}}function p(e,i){let l;const c=t.getBestModeForData(e);if(l=t.from(i,c),l!==t.BYTE&&l.bit<c.bit)throw new Error('"'+e+'" cannot be encoded with mode '+t.toString(l)+".\n Suggested mode is: "+t.toString(c));switch(l!==t.KANJI||a.isKanjiModeEnabled()||(l=t.BYTE),l){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new s(e);case t.BYTE:return new o(e)}}e.fromArray=function(e){return e.reduce((function(e,t){return"string"==typeof t?e.push(p(t,null)):t.data&&e.push(p(t.data,t.mode)),e}),[])},e.fromString=function(n,r){const o=function(e){const n=[];for(let r=0;r<e.length;r++){const o=e[r];switch(o.mode){case t.NUMERIC:n.push([o,{data:o.data,mode:t.ALPHANUMERIC,length:o.length},{data:o.data,mode:t.BYTE,length:o.length}]);break;case t.ALPHANUMERIC:n.push([o,{data:o.data,mode:t.BYTE,length:o.length}]);break;case t.KANJI:n.push([o,{data:o.data,mode:t.BYTE,length:c(o.data)}]);break;case t.BYTE:n.push([{data:o.data,mode:t.BYTE,length:c(o.data)}])}}return n}(h(n,a.isKanjiModeEnabled())),s=function(e,n){const r={},o={start:{}};let s=["start"];for(let i=0;i<e.length;i++){const a=e[i],l=[];for(let e=0;e<a.length;e++){const c=a[e],d=""+i+e;l.push(d),r[d]={node:c,lastCount:0},o[d]={};for(let e=0;e<s.length;e++){const i=s[e];r[i]&&r[i].node.mode===c.mode?(o[i][d]=u(r[i].lastCount+c.length,c.mode)-u(r[i].lastCount,c.mode),r[i].lastCount+=c.length):(r[i]&&(r[i].lastCount=c.length),o[i][d]=u(c.length,c.mode)+4+t.getCharCountIndicator(c.mode,n))}}s=l}for(let e=0;e<s.length;e++)o[s[e]].end=0;return{map:o,table:r}}(o,r),i=l.find_path(s.map,"start","end"),d=[];for(let e=1;e<i.length-1;e++)d.push(s.table[i[e]].node);return e.fromArray(function(e){return e.reduce((function(e,t){const n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)}),[])}(d))},e.rawSplit=function(t){return e.fromArray(h(t,a.isKanjiModeEnabled()))}}(segments);const Utils$1=utils$1$1,ECLevel=errorCorrectionLevel,BitBuffer=bitBuffer,BitMatrix=bitMatrix,AlignmentPattern=alignmentPattern,FinderPattern=finderPattern,MaskPattern=maskPattern,ECCode=errorCorrectionCode,ReedSolomonEncoder=reedSolomonEncoder,Version=version,FormatInfo=formatInfo,Mode=mode,Segments=segments;function setupFinderPattern(e,t){const n=e.size,r=FinderPattern.getPositions(t);for(let t=0;t<r.length;t++){const o=r[t][0],s=r[t][1];for(let t=-1;t<=7;t++)if(!(o+t<=-1||n<=o+t))for(let r=-1;r<=7;r++)s+r<=-1||n<=s+r||(t>=0&&t<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===t||6===t)||t>=2&&t<=4&&r>=2&&r<=4?e.set(o+t,s+r,!0,!0):e.set(o+t,s+r,!1,!0))}}function setupTimingPattern(e){const t=e.size;for(let n=8;n<t-8;n++){const t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function setupAlignmentPattern(e,t){const n=AlignmentPattern.getPositions(t);for(let t=0;t<n.length;t++){const r=n[t][0],o=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)-2===t||2===t||-2===n||2===n||0===t&&0===n?e.set(r+t,o+n,!0,!0):e.set(r+t,o+n,!1,!0)}}function setupVersionInfo(e,t){const n=e.size,r=Version.getEncodedBits(t);let o,s,i;for(let t=0;t<18;t++)o=Math.floor(t/3),s=t%3+n-8-3,i=1==(r>>t&1),e.set(o,s,i,!0),e.set(s,o,i,!0)}function setupFormatInfo(e,t,n){const r=e.size,o=FormatInfo.getEncodedBits(t,n);let s,i;for(s=0;s<15;s++)i=1==(o>>s&1),s<6?e.set(s,8,i,!0):s<8?e.set(s+1,8,i,!0):e.set(r-15+s,8,i,!0),s<8?e.set(8,r-s-1,i,!0):s<9?e.set(8,15-s-1+1,i,!0):e.set(8,15-s-1,i,!0);e.set(r-8,8,1,!0)}function setupData(e,t){const n=e.size;let r=-1,o=n-1,s=7,i=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!e.isReserved(o,a-n)){let r=!1;i<t.length&&(r=1==(t[i]>>>s&1)),e.set(o,a-n,r),s--,-1===s&&(i++,s=7)}if(o+=r,o<0||n<=o){o-=r,r=-r;break}}}function createData(e,t,n){const r=new BitBuffer;n.forEach((function(t){r.put(t.mode.bit,4),r.put(t.getLength(),Mode.getCharCountIndicator(t.mode,e)),t.write(r)}));const o=8*(Utils$1.getSymbolTotalCodewords(e)-ECCode.getTotalCodewordsCount(e,t));for(r.getLengthInBits()+4<=o&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(0);const s=(o-r.getLengthInBits())/8;for(let e=0;e<s;e++)r.put(e%2?17:236,8);return createCodewords(r,e,t)}function createCodewords(e,t,n){const r=Utils$1.getSymbolTotalCodewords(t),o=r-ECCode.getTotalCodewordsCount(t,n),s=ECCode.getBlocksCount(t,n),i=s-r%s,a=Math.floor(r/s),l=Math.floor(o/s),c=l+1,d=a-l,h=new ReedSolomonEncoder(d);let u=0;const p=new Array(s),f=new Array(s);let g=0;const m=new Uint8Array(e.buffer);for(let e=0;e<s;e++){const t=e<i?l:c;p[e]=m.slice(u,u+t),f[e]=h.encode(p[e]),u+=t,g=Math.max(g,t)}const b=new Uint8Array(r);let y,w,v=0;for(y=0;y<g;y++)for(w=0;w<s;w++)y<p[w].length&&(b[v++]=p[w][y]);for(y=0;y<d;y++)for(w=0;w<s;w++)b[v++]=f[w][y];return b}function createSymbol(e,t,n,r){let o;if(Array.isArray(e))o=Segments.fromArray(e);else{if("string"!=typeof e)throw new Error("Invalid data");{let r=t;if(!r){const t=Segments.rawSplit(e);r=Version.getBestVersionForData(t,n)}o=Segments.fromString(e,r||40)}}const s=Version.getBestVersionForData(o,n);if(!s)throw new Error("The amount of data is too big to be stored in a QR Code");if(t){if(t<s)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+s+".\n")}else t=s;const i=createData(t,n,o),a=Utils$1.getSymbolSize(t),l=new BitMatrix(a);return setupFinderPattern(l,t),setupTimingPattern(l),setupAlignmentPattern(l,t),setupFormatInfo(l,n,0),t>=7&&setupVersionInfo(l,t),setupData(l,i),isNaN(r)&&(r=MaskPattern.getBestMask(l,setupFormatInfo.bind(null,l,n))),MaskPattern.applyMask(r,l),setupFormatInfo(l,n,r),{modules:l,version:t,errorCorrectionLevel:n,maskPattern:r,segments:o}}qrcode.create=function(e,t){if(void 0===e||""===e)throw new Error("No input text");let n,r,o=ECLevel.M;return void 0!==t&&(o=ECLevel.from(t.errorCorrectionLevel,ECLevel.M),n=Version.from(t.version),r=MaskPattern.from(t.maskPattern),t.toSJISFunc&&Utils$1.setToSJISFunction(t.toSJISFunc)),createSymbol(e,n,o,r)};var canvas={},utils$3={};!function(e){function t(e){if("number"==typeof e&&(e=e.toString()),"string"!=typeof e)throw new Error("Color should be defined as hex string");let t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw new Error("Invalid hex color: "+e);3!==t.length&&4!==t.length||(t=Array.prototype.concat.apply([],t.map((function(e){return[e,e]})))),6===t.length&&t.push("F","F");const n=parseInt(t.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+t.slice(0,6).join("")}}e.getOptions=function(e){e||(e={}),e.color||(e.color={});const n=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,o=e.scale||4;return{width:r,scale:r?4:o,margin:n,color:{dark:t(e.color.dark||"#000000ff"),light:t(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},e.getImageWidth=function(t,n){const r=e.getScale(t,n);return Math.floor((t+2*n.margin)*r)},e.qrToImageData=function(t,n,r){const o=n.modules.size,s=n.modules.data,i=e.getScale(o,r),a=Math.floor((o+2*r.margin)*i),l=r.margin*i,c=[r.color.light,r.color.dark];for(let e=0;e<a;e++)for(let n=0;n<a;n++){let d=4*(e*a+n),h=r.color.light;if(e>=l&&n>=l&&e<a-l&&n<a-l){h=c[s[Math.floor((e-l)/i)*o+Math.floor((n-l)/i)]?1:0]}t[d++]=h.r,t[d++]=h.g,t[d++]=h.b,t[d]=h.a}}}(utils$3),function(e){const t=utils$3;e.render=function(e,n,r){let o=r,s=n;void 0!==o||n&&n.getContext||(o=n,n=void 0),n||(s=function(){try{return document.createElement("canvas")}catch(e){throw new Error("You need to specify a canvas element")}}()),o=t.getOptions(o);const i=t.getImageWidth(e.modules.size,o),a=s.getContext("2d"),l=a.createImageData(i,i);return t.qrToImageData(l.data,e,o),function(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.height=n,t.width=n,t.style.height=n+"px",t.style.width=n+"px"}(a,s,i),a.putImageData(l,0,0),s},e.renderToDataURL=function(t,n,r){let o=r;void 0!==o||n&&n.getContext||(o=n,n=void 0),o||(o={});const s=e.render(t,n,o),i=o.type||"image/png",a=o.rendererOpts||{};return s.toDataURL(i,a.quality)}}(canvas);var svgTag={};const Utils=utils$3;function getColorAttrib(e,t){const n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function svgCmd(e,t,n){let r=e+t;return void 0!==n&&(r+=" "+n),r}function qrToPath(e,t,n){let r="",o=0,s=!1,i=0;for(let a=0;a<e.length;a++){const l=Math.floor(a%t),c=Math.floor(a/t);l||s||(s=!0),e[a]?(i++,a>0&&l>0&&e[a-1]||(r+=s?svgCmd("M",l+n,.5+c+n):svgCmd("m",o,0),o=0,s=!1),l+1<t&&e[a+1]||(r+=svgCmd("h",i),i=0)):o++}return r}svgTag.render=function(e,t,n){const r=Utils.getOptions(t),o=e.modules.size,s=e.modules.data,i=o+2*r.margin,a=r.color.light.a?"<path "+getColorAttrib(r.color.light,"fill")+' d="M0 0h'+i+"v"+i+'H0z"/>':"",l="<path "+getColorAttrib(r.color.dark,"stroke")+' d="'+qrToPath(s,o,r.margin)+'"/>',c='viewBox="0 0 '+i+" "+i+'"',d='<svg xmlns="http://www.w3.org/2000/svg" '+(r.width?'width="'+r.width+'" height="'+r.width+'" ':"")+c+' shape-rendering="crispEdges">'+a+l+"</svg>\n";return"function"==typeof n&&n(null,d),d};const canPromise=canPromise$1,QRCode=qrcode,CanvasRenderer=canvas,SvgRenderer=svgTag;function renderCanvas(e,t,n,r,o){const s=[].slice.call(arguments,1),i=s.length,a="function"==typeof s[i-1];if(!a&&!canPromise())throw new Error("Callback required as last argument");if(!a){if(i<1)throw new Error("Too few arguments provided");return 1===i?(n=t,t=r=void 0):2!==i||t.getContext||(r=n,n=t,t=void 0),new Promise((function(o,s){try{const s=QRCode.create(n,r);o(e(s,t,r))}catch(e){s(e)}}))}if(i<2)throw new Error("Too few arguments provided");2===i?(o=n,n=t,t=r=void 0):3===i&&(t.getContext&&void 0===o?(o=r,r=void 0):(o=r,r=n,n=t,t=void 0));try{const s=QRCode.create(n,r);o(null,e(s,t,r))}catch(e){o(e)}}browser$1.create=QRCode.create,browser$1.toCanvas=renderCanvas.bind(null,CanvasRenderer.render),browser$1.toDataURL=renderCanvas.bind(null,CanvasRenderer.renderToDataURL),browser$1.toString=renderCanvas.bind(null,(function(e,t,n){return SvgRenderer.render(e,n)}));const nlSigninConnectionStringCss=baseCss,NlSigninConnectionStringStyle0=nlSigninConnectionStringCss,NlSigninConnectionString=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlNostrConnectDefault=createEvent(this,"nlNostrConnectDefault"),this.titleLogin="Connection string",this.description="Scan or copy the connection string with key store app",this.connectionString="",this.isCopy=!1}componentDidLoad(){this.nlNostrConnectDefault.emit(),this.generateQRCode()}async generateQRCode(){if(this.connectionString&&this.canvasElement)try{await browser$1.toCanvas(this.canvasElement,this.connectionString)}catch(e){console.error("Error generating QR Code:",e)}}async copyToClipboard(){try{await navigator.clipboard.writeText(this.connectionString),this.isCopy=!0,setTimeout((()=>{this.isCopy=!1}),1500)}catch(e){console.error("Failed to copy connectionString: ",e)}}render(){return h(Fragment,{key:"9e20dbd8f95690337ccab2aad02aeecc12fe6534"},h("div",{key:"fcfcc5448dae58c119375f42d2183e536c31b7fd",class:"p-4 overflow-y-auto"},h("h1",{key:"efd74afef7798a7cc1d31104f48b5ccdf2ce9084",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h("p",{key:"39c6d7154037338efba5ba4443adc7b2ba8214f7",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h("canvas",{key:"0243600d2c4720b74ed733b9fdbd3f0fe7d336e8",class:"mx-auto mb-2",ref:e=>this.canvasElement=e}),h("div",{key:"44b629d494394d9213fa9ca4610b1339ce28eed6",class:"px-4"},h("div",{key:"2a3898b77f6c9b9569c42a514556eb1ac7eab25e",class:"max-w-72 mx-auto"},h("div",{key:"0cab83e4b918a3d93ba5a150c88f251a3c7aad02",class:"relative mb-2"},h("input",{key:"bb0d74e79dd801a318025f50c55a27bc4ca46b24",type:"text",class:"nl-input peer py-3 px-4 pe-11 ps-11 block w-full border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent",placeholder:"npub or name@domain",value:this.connectionString,disabled:!0}),h("div",{key:"646c7de454027c53b3ba7961e8dd84da34003e8b",class:"absolute inset-y-0 start-0 flex items-center pointer-events-none ps-4 peer-disabled:opacity-50 peer-disabled:pointer-events-none"},h("svg",{key:"235f51d1d29644ddc3d0b6bd4fbf703280c682d5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{key:"d2f9f1d2c4c8ad459780016104ad3096a6b2bac6","stroke-linecap":"round","stroke-linejoin":"round",d:"M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"}),h("path",{key:"fc00b8344aa02d311103947bf1199df3447a1b8a","stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"}))),this.isCopy?h("div",{class:"absolute inset-y-0 end-0 flex items-center p-2 rounded-lg"},h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"#00cc00",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}))):h("div",{class:"absolute inset-y-0 end-0 flex items-center cursor-pointer p-2 rounded-lg",onClick:()=>this.copyToClipboard()},h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M16.5 8.25V6a2.25 2.25 0 0 0-2.25-2.25H6A2.25 2.25 0 0 0 3.75 6v8.25A2.25 2.25 0 0 0 6 16.5h2.25m8.25-8.25H18a2.25 2.25 0 0 1 2.25 2.25V18A2.25 2.25 0 0 1 18 20.25h-7.5A2.25 2.25 0 0 1 8.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 0 0-2.25 2.25v6"})))),h("div",{key:"1e454d90b8df857894adfc03f08a6aa96913c251",class:"mt-10 justify-center items-center flex gap-2"},h("span",{key:"8b003638e347f886377e595db7fc23616067ee52",slot:"icon-start",class:"animate-spin-loading inline-block w-[20px] h-[20px] border-[2px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}),h("span",{key:"5543d1eb3f1a8247e10219410aff9d77e5f527fd",class:"nl-footer"},"Waiting for connection")))))}static get style(){return NlSigninConnectionStringStyle0}},[0,"nl-signin-connection-string",{titleLogin:[1,"title-login"],description:[1],connectionString:[1,"connection-string"],isCopy:[32]}]);function defineCustomElement$b(){if("undefined"==typeof customElements)return;["nl-signin-connection-string"].forEach((e=>{if("nl-signin-connection-string"===e)customElements.get(e)||customElements.define(e,NlSigninConnectionString)}))}defineCustomElement$b();const nlSigninOtpCss=baseCss,NlSigninOtpStyle0=nlSigninOtpCss,NlSigninOtp=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlLoginOTPUser=createEvent(this,"nlLoginOTPUser"),this.nlLoginOTPCode=createEvent(this,"nlLoginOTPCode"),this.nlCheckLogin=createEvent(this,"nlCheckLogin"),this.titleLogin="Log in with DM",this.description="Please enter your user name or npub, and we will send you a direct message with a one-time code.",this.titleLoginOTP="Enter the code",this.descriptionOTP="Please enter the one-time code we sent to you as a direct message on Nostr.",this.isGood=!1}handleInputChange(e){state.isOTP?state.nlSigninOTP.code=e.target.value:(state.nlSigninOTP.loginName=e.target.value,this.nlCheckLogin.emit(state.nlSigninOTP.loginName))}handleLogin(e){e.preventDefault(),state.isOTP?this.nlLoginOTPCode.emit(state.nlSigninOTP.code):this.nlLoginOTPUser.emit(state.nlSigninOTP.loginName)}render(){return h(Fragment,{key:"908b593238b5fa1b577cee0a8149e013a2cd4e81"},h("div",{key:"2d57c60631a906fc566d5f1f76cdac11773436c5",class:"p-4 overflow-y-auto"},h("h1",{key:"b08c82e952dbc3af15e25c48f318677a68f46d19",class:"nl-title font-bold text-center text-2xl"},state.isOTP?this.titleLoginOTP:this.titleLogin),h("p",{key:"64f6ec549cd2fc9c4b3672c5463d183d9626c20b",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},state.isOTP?this.descriptionOTP:this.description)),h("div",{key:"5e9bf1ba4a6a72788f605ef44f98cdafeb67e0d0",class:"max-w-72 mx-auto"},h("div",{key:"3986a554e56c5457abf19162ecdafe0cc72ceade",class:"relative mb-2"},h("input",{key:"139d115f54a0253fac37eb6bbbba5f00cec6e3b6",onInput:e=>this.handleInputChange(e),type:"text",class:"nl-input peer py-3 px-4 ps-11 block w-full border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent",placeholder:state.isOTP?"code from direct message":"npub or name@domain",value:state.isOTP?state.nlSigninOTP.code:state.nlSigninOTP.loginName}),h("div",{key:"bae2734dbce11c6c9a9f59b2ba1a57841213e8f0",class:"absolute inset-y-0 start-0 flex items-center pointer-events-none ps-4 peer-disabled:opacity-50 peer-disabled:pointer-events-none"},h("svg",{key:"8dc6fc177553d183873eae6c4ef31509d45c5784",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:this.isGood?"#00cc00":"currentColor",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{key:"dd9d07329ee6ae0491c009adffc673cf6a4103d3","stroke-linecap":"round","stroke-linejoin":"round",d:"M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"}),h("path",{key:"0357daa2fb59eb3c2cbaf62e49d69e42dde16b85","stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})))),h("div",{key:"91a36d9e0420b28eca1edcd1ec8759c25b2d51b3",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"e462b623f95c800d1589d3eef07d2216b70bdd64",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"c6b89e573097ac7d40c0648a2e87222d48e72b40",titleBtn:"Log in",disabled:state.isLoading,onClick:e=>this.handleLogin(e)},state.isLoading&&h("span",{key:"0be64571f00987f716e986af9cb043e3eb22b796",slot:"icon-start",class:"animate-spin-loading inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}))))}static get style(){return NlSigninOtpStyle0}},[0,"nl-signin-otp",{titleLogin:[1,"title-login"],description:[1],titleLoginOTP:[1,"title-login-o-t-p"],descriptionOTP:[1,"description-o-t-p"],isGood:[32]}]);function defineCustomElement$a(){if("undefined"==typeof customElements)return;["nl-signin-otp","button-base"].forEach((e=>{switch(e){case"nl-signin-otp":customElements.get(e)||customElements.define(e,NlSigninOtp);break;case"button-base":customElements.get(e)||defineCustomElement$q()}}))}defineCustomElement$a();const nlSigninReadOnlyCss=baseCss,NlSigninReadOnlyStyle0=nlSigninReadOnlyCss,NlSigninReadOnly=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlLoginReadOnly=createEvent(this,"nlLoginReadOnly"),this.nlCheckLogin=createEvent(this,"nlCheckLogin"),this.titleLogin="Log in to read only",this.description="Please enter the user name or npub of any Nostr user.",this.isGood=!1}handleInputChange(e){state.nlSigninReadOnly.loginName=e.target.value,this.nlCheckLogin.emit(e.target.value)}handleLogin(e){e.preventDefault(),this.nlLoginReadOnly.emit(state.nlSigninReadOnly.loginName)}render(){return h(Fragment,{key:"5333cc7e682b148d2b2c9d3756c9fa561a9a3e86"},h("div",{key:"ed025d719382b9b4ac11a24d3814419a6f51c774",class:"p-4 overflow-y-auto"},h("h1",{key:"8b8c0c1e839b3db4529e1c6acc8ef18e29a7abee",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h("p",{key:"36f9334b55aea6c5e46bc6e143388b757a6be867",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"3197bd6ac9835cdb4a9b64ff0dea262ddb92ef13",class:"max-w-72 mx-auto"},h("div",{key:"f804f5111ac8f9aaa17b404c22d58ea875273382",class:"relative mb-2"},h("input",{key:"7828eb7e49e92a0578a73439ae16de63caa57597",onInput:e=>this.handleInputChange(e),type:"text",class:"nl-input peer py-3 px-4 ps-11 block w-full border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent",placeholder:"npub or name@domain",value:state.nlSigninReadOnly.loginName}),h("div",{key:"1557e4f05bac2eefc05e22806cb0024e5430c7f4",class:"absolute inset-y-0 start-0 flex items-center pointer-events-none ps-4 peer-disabled:opacity-50 peer-disabled:pointer-events-none"},h("svg",{key:"dfd2f9eeb07d815807bdb4885680001d3d5a1a2c",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:this.isGood?"#00cc00":"currentColor",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{key:"beb199e08cbb0d385314e4a3fcb521bbc05e7d2d","stroke-linecap":"round","stroke-linejoin":"round",d:"M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"}),h("path",{key:"988fe07d787ff2fbb15c620681b2996fcd0ff382","stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})))),h("div",{key:"652f082e184f5d871629f8054a2474c80adddf4b",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"5583f0eb95400902d72728989f32c3afaf31fc77",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"e708d09f4e1625af23d8f432c8523662ad1c82dd",titleBtn:"Log in",disabled:state.isLoading,onClick:e=>this.handleLogin(e)},state.isLoading&&h("span",{key:"5422a05cd6a2b0309fd78f95bf89b0ff03ab69e9",slot:"icon-start",class:"animate-spin-loading inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}))))}static get style(){return NlSigninReadOnlyStyle0}},[0,"nl-signin-read-only",{titleLogin:[1,"title-login"],description:[1],isGood:[32]}]);function defineCustomElement$9(){if("undefined"==typeof customElements)return;["nl-signin-read-only","button-base"].forEach((e=>{switch(e){case"nl-signin-read-only":customElements.get(e)||customElements.define(e,NlSigninReadOnly);break;case"button-base":customElements.get(e)||defineCustomElement$q()}}))}defineCustomElement$9();const nlSignupCss=baseCss,NlSignupStyle0=nlSignupCss,NlSignup=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlSignup=createEvent(this,"nlSignup"),this.nlCheckSignup=createEvent(this,"nlCheckSignup"),this.fetchHandler=createEvent(this,"fetchHandler"),this.titleSignup="Create keys with key store",this.description="Choose some username and a key store service.",this.bunkers="nsec.app,highlighter.com",this.isAvailable=!1}formatServers(e){return e.split(",").map((e=>({name:"@"+e,value:e})))}handleInputChange(e){state.nlSignup.signupName=e.target.value,this.nlCheckSignup.emit(`${e.target.value}@${state.nlSignup.domain}`)}handleDomainSelect(e){state.nlSignup.domain=e.detail,this.nlCheckSignup.emit(`${state.nlSignup.signupName}@${e.detail}`)}handleCreateAccount(e){e.preventDefault(),this.nlSignup.emit(`${state.nlSignup.signupName}@${state.nlSignup.domain}`)}watchBunkersHandler(e){state.nlSignup.servers=this.formatServers(e)}componentWillLoad(){state.nlSignup.servers=this.formatServers(this.bunkers)}render(){return h(Fragment,{key:"558e55ea3a7177a7e035e82c1bbdf522fb2efeb4"},h("div",{key:"8f04f68da63de9317a9ea7e1b425a54fef58905e",class:"p-4 overflow-y-auto"},h("h1",{key:"a8bc4c25348f8d0416679212ba2344a3ca9a78f0",class:"nl-title font-bold text-center text-2xl"},this.titleSignup),h("p",{key:"4e978b75b8ad51e1bc9b0ab5412bd96c21343d9d",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"34b45813498214aedea41061bb60b170cdf1bc35",class:"max-w-72 mx-auto"},h("div",{key:"7a9cc7d8acacebf5001d98982e9f140164a2daf3",class:"relative mb-2"},h("input",{key:"e7f48804f026d19d8bff09c59854dd55de8b6f54",onInput:e=>this.handleInputChange(e),type:"text",class:"nl-input peer py-3 px-4 ps-11 block w-full border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent",placeholder:"Name",value:state.nlSignup.signupName}),h("div",{key:"1a3c7346fa66174c33110c7523e6598c091abeae",class:"absolute inset-y-0 start-0 flex items-center pointer-events-none ps-4 peer-disabled:opacity-50 peer-disabled:pointer-events-none"},h("svg",{key:"edaa9b8e76f3bc2c4a34d8d1fe20536571ef5749",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:this.isAvailable?"#00cc00":"currentColor",class:"flex-shrink-0 w-4 h-4 text-gray-500"},h("path",{key:"3e0d1b3d4c9d6b2d4ffc44e699c1545b68173d67","stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z"})))),h("div",{key:"c0b07eb2e657adf2dbfc95fa3bf6351a6beda00a",class:"mb-2"},h("nl-select",{key:"632e99d1d1e074ed8f9383c0f7bd38f3415a3305",onSelectDomain:e=>this.handleDomainSelect(e),selected:0,options:state.nlSignup.servers})),h("div",{key:"96cc25d6bf9e12eb950e81dc046bebd2998f117f",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"7cd9f343b92a75efb8c26db31afa19a734893449",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"491cbb2cad036c958624947160014d3a0f12125e",disabled:state.isLoading,onClick:e=>this.handleCreateAccount(e),titleBtn:"Create profile"},state.isLoading?h("span",{slot:"icon-start",class:"animate-spin-loading inline-block w-4 h-4 border-[3px] border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}):h("svg",{slot:"icon-start",style:{display:"none"},xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M18 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0ZM3 19.235v-.11a6.375 6.375 0 0 1 12.75 0v.109A12.318 12.318 0 0 1 9.374 21c-2.331 0-4.512-.645-6.374-1.766Z"})))))}static get watchers(){return{bunkers:["watchBunkersHandler"]}}static get style(){return NlSignupStyle0}},[0,"nl-signup",{titleSignup:[1,"title-signup"],description:[1],bunkers:[1],isAvailable:[32]},void 0,{bunkers:["watchBunkersHandler"]}]);function defineCustomElement$8(){if("undefined"==typeof customElements)return;["nl-signup","button-base","nl-select"].forEach((e=>{switch(e){case"nl-signup":customElements.get(e)||customElements.define(e,NlSignup);break;case"button-base":customElements.get(e)||defineCustomElement$q();break;case"nl-select":customElements.get(e)||defineCustomElement$m()}}))}defineCustomElement$8();const nlWelcomeCss=baseCss,NlWelcomeStyle0=nlWelcomeCss,NlWelcome=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.titleWelcome="Welcome to Nostr!",this.description="This website is part of the Nostr network. Log in with your Nostr profile or sign up to join."}handleChangeScreen(e){state.path=[...state.path,e]}render(){return h(Fragment,{key:"9fbfb07f267912a84a036ab844d3dc3e4fecb2aa"},h("div",{key:"04b7452fb9481f99e793a3a64b5febd0d644cb70",class:"p-4 overflow-y-auto"},h("h1",{key:"32ec61d34e5abead821096f50ebfceb65ac06ceb",class:"nl-title font-bold text-center text-4xl"},this.titleWelcome),h("p",{key:"fa5272e74078d89100f42a9b0f25c30eb5746460",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"9745a35fa223d2481e77258c5f40793174f5cc70",class:"max-w-52 mx-auto pb-5"},h("div",{key:"f395ddcb3e75049fde79d0b9bc797e3cef6d4e30",class:"flex gap-3 flex-col mb-2"},h("button-base",{key:"367ccec38380c93a7ab812436093ce643209ae2e",titleBtn:"Log in",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.WELCOME_LOGIN)},h("svg",{key:"ce6f3533b3a83145deb79257f68f2e8749122571",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"38cc63a69adc25366f4bc78cd966624e4da8234e","stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z"})))),h("button-base",{key:"f3bc1f5b2b971a2c25b18b00e83a1e0f66800c05",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.WELCOME_SIGNUP),titleBtn:"Sign up"},h("svg",{key:"b10cd84902c819733453a9642bd3e28dc4057c04",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"e8e2a4bfdcc92971a44f076a97c0b9043377cbe9","stroke-linecap":"round","stroke-linejoin":"round",d:"M18 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0ZM3 19.235v-.11a6.375 6.375 0 0 1 12.75 0v.109A12.318 12.318 0 0 1 9.374 21c-2.331 0-4.512-.645-6.374-1.766Z"})))))}static get style(){return NlWelcomeStyle0}},[0,"nl-welcome",{titleWelcome:[1,"title-welcome"],description:[1]}]);function defineCustomElement$7(){if("undefined"==typeof customElements)return;["nl-welcome","button-base"].forEach((e=>{switch(e){case"nl-welcome":customElements.get(e)||customElements.define(e,NlWelcome);break;case"button-base":customElements.get(e)||defineCustomElement$q()}}))}defineCustomElement$7();const nlWelcomeSigninCss=baseCss,NlWelcomeSigninStyle0=nlWelcomeSigninCss,NlWelcomeSignIn=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlLoginExtension=createEvent(this,"nlLoginExtension"),this.titleWelcome="Log in",this.hasExtension=!1,this.authMethods=[],this.hasOTP=!1}handleChangeScreen(e){state.path=[...state.path,e],e===CURRENT_MODULE.EXTENSION&&this.nlLoginExtension.emit()}allowAuthMethod(e){return!this.authMethods.length||this.authMethods.includes(e)}renderSignInWithExtension(){return h("button-base",{onClick:()=>this.handleChangeScreen(CURRENT_MODULE.EXTENSION),titleBtn:"With extension"},h("svg",{style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3 8.25V18a2.25 2.25 0 0 0 2.25 2.25h13.5A2.25 2.25 0 0 0 21 18V8.25m-18 0V6a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 6v2.25m-18 0h18M5.25 6h.008v.008H5.25V6ZM7.5 6h.008v.008H7.5V6Zm2.25 0h.008v.008H9.75V6Z"})))}render(){return h(Fragment,{key:"f698abf1cdb2942897307d83ddf20097338f9c1a"},h("div",{key:"42973b807c9817b1014898729cd3bcf7f0920c7c",class:"p-4 overflow-y-auto"},h("h1",{key:"d0b9a8616ecd00db2db2eee058d151ff1819b225",class:"nl-title font-bold text-center text-3xl"},this.titleWelcome)),h("div",{key:"f3485be619b6faec7d5ed1829016d84a63fe13f1",class:"max-w-52 mx-auto pb-5"},h("div",{key:"171aa182f0a4c432ffe38295ae0a83c294f51cb0",class:"flex gap-3 flex-col"},this.allowAuthMethod("connect")&&h("button-base",{key:"cd223659a29446bdb8464fb88f4f72b552ca6d60",titleBtn:"Connect",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.CONNECT)},h("svg",{key:"858a77a88d412cf623b8aa334bc3e53f396078fb",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"375dd64c3d8ce48de145cf3c24b641209c127742","stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 9V5.25A2.25 2.25 0 0 1 10.5 3h6a2.25 2.25 0 0 1 2.25 2.25v13.5A2.25 2.25 0 0 1 16.5 21h-6a2.25 2.25 0 0 1-2.25-2.25V15M12 9l3 3m0 0-3 3m3-3H2.25"}))),this.allowAuthMethod("readOnly")&&h("button-base",{key:"6add4933d6818a8dbd711b60eb185d9f53abbdce",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN_READ_ONLY),titleBtn:"Read only"},h("svg",{key:"ef8c543ad07afa3e67040bf3898cbf6d450f8a35",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"06ed2df6d62c64e688a1da01af5e394c08a2e4b5","stroke-linecap":"round","stroke-linejoin":"round",d:"M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"}),h("path",{key:"17b825cc04238a369ac7fff9e18311eb449fee7c","stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"}))),this.hasOTP&&this.allowAuthMethod("otp")&&h("button-base",{key:"a93f338de78f40ff7574e6a039294d88aedaf759",titleBtn:"One-time code",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN_OTP)},h("svg",{key:"2aa34c15e0b701071b74870645a3786b2ca85483",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"4af17a7966a64ce8168d9f1faa146bfc7b737201","stroke-linecap":"round","stroke-linejoin":"round",d:"M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}))),this.hasExtension&&this.allowAuthMethod("extension")&&this.renderSignInWithExtension(),!this.allowAuthMethod("connect")&&!this.hasExtension&&h("p",{key:"502d09cbd29c35f132158b57a71afcb1a05a80ea",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},"No Nostr extension!"),!this.allowAuthMethod("connect")&&this.hasExtension&&!this.allowAuthMethod("extension")&&h("p",{key:"82762e76ad0fde7b87815398a7d821143f12c7e7",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},"Use advanced options."))))}static get style(){return NlWelcomeSigninStyle0}},[0,"nl-welcome-signin",{titleWelcome:[1,"title-welcome"],hasExtension:[4,"has-extension"],authMethods:[16],hasOTP:[4,"has-o-t-p"]}]);function defineCustomElement$6(){if("undefined"==typeof customElements)return;["nl-welcome-signin","button-base"].forEach((e=>{switch(e){case"nl-welcome-signin":customElements.get(e)||customElements.define(e,NlWelcomeSignIn);break;case"button-base":customElements.get(e)||defineCustomElement$q()}}))}defineCustomElement$6();const nlWelcomeSignupCss=baseCss,NlWelcomeSignupStyle0=nlWelcomeSignupCss,NlWelcomeSignUp=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.titleWelcome="Sign up",this.description="Nostr profiles are based on cryptographic keys. You can create keys right here, or with a key storage app."}handleChangeScreen(e){state.path=[...state.path,e]}render(){return h(Fragment,{key:"ed92b261515733ad30246febe996bec581f392ee"},h("div",{key:"f8e1c53b93a766e1c086b0c0fca9fae98f6e492c",class:"p-4 overflow-y-auto"},h("h1",{key:"8766733352e5a129016b6a9cdfeeeac06af00be1",class:"nl-title font-bold text-center text-3xl"},this.titleWelcome),h("p",{key:"b758d37bcd4e09eaf981ef3057a437872b5ca5cb",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"ffb223d49d4f380406cb4eec4d9f166b7ba7694c",class:"max-w-52 mx-auto pb-5"},h("div",{key:"871ce44d253799caf575263f6e3d42227f9e24ad",class:"flex gap-3 flex-col"},h("button-base",{key:"345b1aaebcc7c72811ab1a7e9a010c011066e1fb",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOCAL_SIGNUP),titleBtn:"Create keys"},h("svg",{key:"17f0f693941020e1ad09c64e8e80ca08fd082673",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"0720ef9137e48e3b814ea1efa463925dfb3ee5e1","stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z"}))),h("button-base",{key:"09f0ac2ad4b759b29001d28d735a74300fee2c36",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.SIGNUP),titleBtn:"With key store"},h("svg",{key:"207439f7318c9dfd7ed8a70da9099ed1a8121871",style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},h("path",{key:"9331b09772ce53fe1802a00063646f68ffb8971a","stroke-linecap":"round","stroke-linejoin":"round",d:"M20.25 6.375c0 2.278-3.694 4.125-8.25 4.125S3.75 8.653 3.75 6.375m16.5 0c0-2.278-3.694-4.125-8.25-4.125S3.75 4.097 3.75 6.375m16.5 0v11.25c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125V6.375m16.5 0v3.75m-16.5-3.75v3.75m16.5 0v3.75C20.25 16.153 16.556 18 12 18s-8.25-1.847-8.25-4.125v-3.75m16.5 0c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125"}))))))}static get style(){return NlWelcomeSignupStyle0}},[0,"nl-welcome-signup",{titleWelcome:[1,"title-welcome"],description:[1]}]);function defineCustomElement$5(){if("undefined"==typeof customElements)return;["nl-welcome-signup","button-base"].forEach((e=>{switch(e){case"nl-welcome-signup":customElements.get(e)||customElements.define(e,NlWelcomeSignUp);break;case"button-base":customElements.get(e)||defineCustomElement$q()}}))}defineCustomElement$5();const nlAuthCss=baseCss,NlAuthStyle0=nlAuthCss,NlAuth=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.nlCloseModal=createEvent(this,"nlCloseModal"),this.nlChangeDarkMode=createEvent(this,"nlChangeDarkMode"),this.nlNostrConnectDefaultCancel=createEvent(this,"nlNostrConnectDefaultCancel"),this.prevPath="",this.theme="default",this.bunkers="",this.startScreen=CURRENT_MODULE.WELCOME,this.authMethods=[],this.hasExtension=!1,this.hasOTP=!1,this.isLoading=!1,this.isLoadingExtension=!1,this.isOTP=!1,this.authUrl="",this.iframeUrl="",this.error="",this.localSignup=!1,this.signupNjump=!1,this.njumpIframe="",this.accounts=[],this.recents=[],this.darkMode=!1,this.welcomeTitle="",this.welcomeDescription="",this.connectionString="",this.connectionStringServices=[]}watchLoadingHandler(e){state.isLoading=e}watchLoadingExtensionHandler(e){state.isLoadingExtension=e}watchOTPHandler(e){state.isOTP=e}watchAuthUrlHandler(e){state.authUrl=e}watchIframeUrlHandler(e){state.iframeUrl=e}watchNjumpIframeHandler(e){state.njumpIframe=e}watchErrorHandler(e){state.error=e}handleClose(){this.nlCloseModal.emit()}handleChangeDarkMode(){this.nlChangeDarkMode.emit(!this.darkMode)}componentWillLoad(){state.path=[this.startScreen],state.error="",state.iframeUrl="",state.authUrl="",state.isLoading=!1,state.isLoadingExtension=!1,state.isOTP=!1,console.log("path",state.path)}handleClickToBack(){state.path.pop(),state.path=[...state.path],state.isLoading=!1,state.isLoadingExtension=!1,state.authUrl="",state.isOTP=!1}switchSignSignUpStrategy(e){CURRENT_MODULE.LOCAL_SIGNUP!==e?state.path=[CURRENT_MODULE.WELCOME,e]:state.path=[CURRENT_MODULE.WELCOME,CURRENT_MODULE.WELCOME_SIGNUP,e]}render(){const e="w-full h-full fixed top-0 start-0 z-[80] overflow-x-hidden overflow-y-auto flex items-center "+(this.darkMode?"dark":""),t=state.path.at(-1);t!==this.prevPath&&this.prevPath===CURRENT_MODULE.CONNECTION_STRING&&this.nlNostrConnectDefaultCancel.emit(),this.prevPath=t;const n=state.isOTP||t!==CURRENT_MODULE.INFO&&t!==CURRENT_MODULE.CONFIRM_LOGOUT&&t!==CURRENT_MODULE.IMPORT_FLOW&&t!==CURRENT_MODULE.WELCOME&&t!==CURRENT_MODULE.EXTENSION&&t!==CURRENT_MODULE.IFRAME&&t!==CURRENT_MODULE.PREVIOUSLY_LOGGED,r=t!==CURRENT_MODULE.IFRAME&&(!this.authMethods.length||!this.localSignup&&this.authMethods.includes("connect")||this.localSignup&&this.authMethods.includes("local"));return h("div",{class:`theme-${this.theme}`,dir:"ltr"},h("div",{class:e},h("div",{onClick:()=>this.handleClose(),class:"absolute top-0 left-0 w-full h-full bg-gray-500 bg-opacity-75 z-[80]"}),h("div",{class:"nl-bg relative z-[81] w-full flex flex-col rounded-xl sm:max-w-lg sm:w-full sm:mx-auto"},h("div",{class:"flex justify-between items-center py-3 px-4"},h("div",{class:"flex gap-2 items-center"},h("svg",{class:"w-7 h-7",width:"225",height:"224",viewBox:"0 0 225 224",fill:"none",xmlns:"http://www.w3.org/2000/svg"},h("rect",{width:"224.047",height:"224",rx:"64",fill:"#6951FA"}),h("path",{d:"M162.441 135.941V88.0593C170.359 85.1674 176 77.5348 176 68.6696C176 57.2919 166.708 48 155.33 48C143.953 48 134.661 57.2444 134.661 68.6696C134.661 77.5822 140.302 85.1674 148.219 88.0593V135.941C147.698 136.13 147.176 136.367 146.655 136.604L87.3956 77.3452C88.6282 74.6904 89.2919 71.7511 89.2919 68.6696C89.2919 57.2444 80.0474 48 68.6696 48C57.2919 48 48 57.2444 48 68.6696C48 77.5822 53.6415 85.1674 61.5585 88.0593V135.941C53.6415 138.833 48 146.465 48 155.33C48 166.708 57.2444 176 68.6696 176C80.0948 176 89.3393 166.708 89.3393 155.33C89.3393 146.418 83.6978 138.833 75.7807 135.941V88.0593C76.3022 87.8696 76.8237 87.6326 77.3452 87.3956L136.604 146.655C135.372 149.31 134.708 152.249 134.708 155.33C134.708 166.708 143.953 176 155.378 176C166.803 176 176.047 166.708 176.047 155.33C176.047 146.418 170.406 138.833 162.489 135.941H162.441Z",fill:"white"})),h("p",{class:"font-bold nl-logo text-base"},"Nostr ",h("span",{class:"font-light"},"Login"))),h("div",{class:"flex gap-1"},h("button",{onClick:()=>this.handleChangeDarkMode(),type:"button",class:"nl-action-button flex justify-center items-center w-7 h-7 text-sm font-semibold rounded-full border border-transparent"},h("span",{class:"sr-only"},"Change theme"),this.darkMode?h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"flex-shrink-0 w-5 h-5"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"})):h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"flex-shrink-0 w-5 h-5"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"}))),!state.isLoading&&h("button",{onClick:()=>state.path=[...state.path,CURRENT_MODULE.INFO],type:"button",class:"nl-action-button flex justify-center items-center w-7 h-7 text-sm font-semibold rounded-full border border-transparent"},h("span",{class:"sr-only"},"Info"),h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"flex-shrink-0 w-5 h-5"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"}))),h("button",{onClick:()=>this.handleClose(),type:"button",class:"nl-action-button flex justify-center items-center w-7 h-7 text-sm font-semibold rounded-full border border-transparent"},h("span",{class:"sr-only"},"Close"),h("svg",{class:"flex-shrink-0 w-5 h-5",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},h("path",{d:"M18 6 6 18"}),h("path",{d:"m6 6 12 12"}))))),state.path.length>1&&!state.isLoading&&h("div",{class:"p-4"},h("button",{onClick:()=>this.handleClickToBack(),type:"button",class:"nl-action-button flex justify-center items-center w-7 h-7 text-sm font-semibold rounded-full border border-transparent dark:focus:outline-none dark:focus:ring-1 dark:focus:ring-gray-600","data-hs-overlay":"#hs-vertically-centered-modal"},h("span",{class:"sr-only"},"Back"),h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"flex-shrink-0 w-5 h-5"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18"})))),state.isLoading||state.authUrl?h("nl-loading",{path:t}):h(Fragment,null,(()=>{if(state.isOTP)return h("nl-signin-otp",null);switch(t){case CURRENT_MODULE.WELCOME:return h("nl-welcome",{titleWelcome:this.welcomeTitle||void 0,description:this.welcomeDescription||void 0});case CURRENT_MODULE.LOGIN:return h("nl-signin",null);case CURRENT_MODULE.SIGNUP:return h("nl-signup",{bunkers:this.bunkers});case CURRENT_MODULE.LOCAL_SIGNUP:return h("nl-local-signup",{signupNjump:this.signupNjump});case CURRENT_MODULE.CONFIRM_LOGOUT:return h("nl-confirm-logout",null);case CURRENT_MODULE.IMPORT_FLOW:return h("nl-import-flow",{services:this.connectionStringServices});case CURRENT_MODULE.IMPORT_OTP:return h("nl-otp-migrate",{services:this.connectionStringServices});case CURRENT_MODULE.INFO:return h("nl-info",null);case CURRENT_MODULE.EXTENSION:return h("nl-info-extension",null);case CURRENT_MODULE.LOGIN_READ_ONLY:return h("nl-signin-read-only",null);case CURRENT_MODULE.LOGIN_BUNKER_URL:return h("nl-signin-bunker-url",null);case CURRENT_MODULE.LOGIN_OTP:return h("nl-signin-otp",null);case CURRENT_MODULE.WELCOME_LOGIN:return h("nl-welcome-signin",{hasOTP:this.hasOTP,authMethods:this.authMethods,hasExtension:this.hasExtension});case CURRENT_MODULE.WELCOME_SIGNUP:return h("nl-welcome-signup",null);case CURRENT_MODULE.CONNECTION_STRING:return h("nl-signin-connection-string",{connectionString:this.connectionString});case CURRENT_MODULE.CONNECT:return h("nl-connect",{connectionStringServices:this.connectionStringServices,authMethods:this.authMethods});case CURRENT_MODULE.PREVIOUSLY_LOGGED:return h("nl-previously-logged",{accounts:this.accounts,recents:this.recents});case CURRENT_MODULE.IFRAME:return h("nl-iframe",{iframeUrl:this.authUrl});default:return h("nl-welcome",null)}})(),n&&h(Fragment,null,t===CURRENT_MODULE.WELCOME_SIGNUP||t===CURRENT_MODULE.SIGNUP||t===CURRENT_MODULE.LOCAL_SIGNUP?h("div",{class:"p-4 overflow-y-auto"},h("p",{class:"nl-footer font-light text-center text-sm pt-3 max-w-96 mx-auto"},"If you already have a profile please"," ",h("span",{onClick:()=>this.switchSignSignUpStrategy(CURRENT_MODULE.WELCOME_LOGIN),class:"cursor-pointer text-blue-400"},"log in"),".")):r&&h("div",{class:"p-4 overflow-y-auto"},h("p",{class:"nl-footer font-light text-center text-sm pt-3 max-w-96 mx-auto"},"If you don't have a profile please"," ",h("span",{onClick:()=>this.localSignup?this.switchSignSignUpStrategy(CURRENT_MODULE.LOCAL_SIGNUP):this.switchSignSignUpStrategy(CURRENT_MODULE.WELCOME_SIGNUP),class:"cursor-pointer text-blue-400"},"sign up"),".")))))))}static get watchers(){return{isLoading:["watchLoadingHandler"],isLoadingExtension:["watchLoadingExtensionHandler"],isOTP:["watchOTPHandler"],authUrl:["watchAuthUrlHandler"],iframeUrl:["watchIframeUrlHandler"],njumpIframe:["watchNjumpIframeHandler"],error:["watchErrorHandler"]}}static get style(){return NlAuthStyle0}},[1,"nl-auth",{theme:[1025],bunkers:[1],startScreen:[1,"start-screen"],authMethods:[16],hasExtension:[4,"has-extension"],hasOTP:[4,"has-o-t-p"],isLoading:[4,"is-loading"],isLoadingExtension:[4,"is-loading-extension"],isOTP:[4,"is-o-t-p"],authUrl:[1,"auth-url"],iframeUrl:[1,"iframe-url"],error:[1],localSignup:[4,"local-signup"],signupNjump:[4,"signup-njump"],njumpIframe:[1,"njump-iframe"],accounts:[1040],recents:[1040],darkMode:[1028,"dark-mode"],welcomeTitle:[1,"welcome-title"],welcomeDescription:[1,"welcome-description"],connectionString:[1,"connection-string"],connectionStringServices:[16]},void 0,{isLoading:["watchLoadingHandler"],isLoadingExtension:["watchLoadingExtensionHandler"],isOTP:["watchOTPHandler"],authUrl:["watchAuthUrlHandler"],iframeUrl:["watchIframeUrlHandler"],njumpIframe:["watchNjumpIframeHandler"],error:["watchErrorHandler"]}]);function defineCustomElement$4(){if("undefined"==typeof customElements)return;["nl-auth","button-base","nl-confirm-logout","nl-connect","nl-iframe","nl-import-flow","nl-info","nl-info-extension","nl-loading","nl-local-signup","nl-login-status","nl-otp-migrate","nl-previously-logged","nl-select","nl-signin","nl-signin-bunker-url","nl-signin-connection-string","nl-signin-otp","nl-signin-read-only","nl-signup","nl-welcome","nl-welcome-signin","nl-welcome-signup"].forEach((e=>{switch(e){case"nl-auth":customElements.get(e)||customElements.define(e,NlAuth);break;case"button-base":customElements.get(e)||defineCustomElement$q();break;case"nl-confirm-logout":customElements.get(e)||defineCustomElement$p();break;case"nl-connect":customElements.get(e)||defineCustomElement$o();break;case"nl-iframe":customElements.get(e)||defineCustomElement$n();break;case"nl-import-flow":customElements.get(e)||defineCustomElement$l();break;case"nl-info":customElements.get(e)||defineCustomElement$k();break;case"nl-info-extension":customElements.get(e)||defineCustomElement$j();break;case"nl-loading":customElements.get(e)||defineCustomElement$i();break;case"nl-local-signup":customElements.get(e)||defineCustomElement$h();break;case"nl-login-status":customElements.get(e)||defineCustomElement$g();break;case"nl-otp-migrate":customElements.get(e)||defineCustomElement$f();break;case"nl-previously-logged":customElements.get(e)||defineCustomElement$e();break;case"nl-select":customElements.get(e)||defineCustomElement$m();break;case"nl-signin":customElements.get(e)||defineCustomElement$d();break;case"nl-signin-bunker-url":customElements.get(e)||defineCustomElement$c();break;case"nl-signin-connection-string":customElements.get(e)||defineCustomElement$b();break;case"nl-signin-otp":customElements.get(e)||defineCustomElement$a();break;case"nl-signin-read-only":customElements.get(e)||defineCustomElement$9();break;case"nl-signup":customElements.get(e)||defineCustomElement$8();break;case"nl-welcome":customElements.get(e)||defineCustomElement$7();break;case"nl-welcome-signin":customElements.get(e)||defineCustomElement$6();break;case"nl-welcome-signup":customElements.get(e)||defineCustomElement$5()}}))}defineCustomElement$4();const NlButton=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.theme="default",this.darkMode=!1,this.titleBtn="Open modal",this.disabled=!1}render(){return h("button-base",{key:"9f7936090efc7263cce71d1ad89490d7f5445991",theme:this.theme,darkMode:this.darkMode,titleBtn:this.titleBtn,disabled:this.disabled})}},[1,"nl-button",{theme:[1],darkMode:[4,"dark-mode"],titleBtn:[1,"title-btn"],disabled:[4]}]);function defineCustomElement$3(){if("undefined"==typeof customElements)return;["nl-button","button-base"].forEach((e=>{switch(e){case"nl-button":customElements.get(e)||customElements.define(e,NlButton);break;case"button-base":customElements.get(e)||defineCustomElement$q()}}))}defineCustomElement$3();const nlChangeAccountCss=baseCss,NlChangeAccountStyle0=nlChangeAccountCss,NLChangeAccount=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.handleOpenWelcomeModal=createEvent(this,"handleOpenWelcomeModal"),this.handleSwitchAccount=createEvent(this,"handleSwitchAccount"),this.isOpen=!1,this.options=[],this.accounts=[],this.currentAccount=null,this.mode=!1,this.darkMode=!1,this.themeState="default",this.theme="default"}handleWindowClick(){this.wrapperRef.querySelector(".listClass")&&(this.isOpen=!1)}toggleDropdown(){this.isOpen=!this.isOpen,this.calculateDropdownPosition()}watchPropHandler(e){this.themeState=e}watchModeHandler(e){this.mode=e}watchAccountsHandler(e){this.options=e}connectedCallback(){this.themeState=this.theme,this.mode=this.darkMode}calculateDropdownPosition(){if(this.isOpen&&this.buttonRef){const e=this.buttonRef.getBoundingClientRect();this.ulRef.style.top=`${e.height}px`}}handleChange(e){this.handleSwitchAccount.emit(e)}handleOpenModal(){this.handleOpenWelcomeModal.emit()}render(){const e=(this.isOpen?"listClass flex flex-col gap-2":"hidden")+" w-full nl-select-list absolute z-10 left-0 shadow-md rounded-lg p-2 mt-1 after:h-4 after:absolute after:-bottom-4 after:start-0 after:w-full before:h-4 before:absolute before:-top-4 before:start-0 before:w-full",t=(this.isOpen?"rotate-180":"rotate-0")+" duration-300 flex-shrink-0 w-4 h-4 text-gray-500",n=this.options&&this.currentAccount?this.options.filter((e=>e.pubkey!==this.currentAccount.pubkey||e.authMethod!==this.currentAccount.authMethod)):[];return h("div",{key:"4e15e39f7ac6a552bfc772396e3e9ef8eeca95cc",class:`theme-${this.themeState}`},h("div",{key:"eae10769ce35dc4cc072d2361c1ee1390c79c822",class:"relative",ref:e=>this.wrapperRef=e},h("button",{key:"e585a44168809f27b99201f7e13bd5db5e4f6569",ref:e=>this.buttonRef=e,onClick:()=>this.toggleDropdown(),type:"button",class:"nl-select peer py-3 px-4 flex items-center w-full justify-between border-transparent rounded-lg text-sm disabled:opacity-50 disabled:pointer-events-none dark:border-transparent"},h("span",{key:"006ed9a67b57227d4dab51f0b6bcb8290cd9d3ac",class:"text-gray-500"},"Switch profile"),h("svg",{key:"5f824a479165929698fab31b8837b89418587652",class:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},h("path",{key:"600914907723c9f8d01a15da357ccb825c1d1e6a",d:"m6 9 6 6 6-6"}))),h("ul",{key:"9b5b68724a3bce995e6b8b0a9d0eb653baedf79a",ref:e=>this.ulRef=e,class:e},this.options&&n.map((e=>{const t=Boolean(null==e?void 0:e.picture),n=e.name||e.nip05||e.pubkey,r=Boolean(n);return h("li",{onClick:()=>this.handleChange(e),class:"nl-select-option flex cursor-pointer items-center gap-x-3.5 py-2 px-3 rounded-lg text-sm"},h("div",{class:"uppercase font-bold w-full max-w-6 h-6 rounded-full border border-gray-400 flex justify-center items-center"},t?h("img",{class:"w-full rounded-full",src:e.picture,alt:"Logo"}):r?n[0]:h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-full"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"}))),h("div",{class:"overflow-hidden flex flex-col w-full"},h("div",{class:"truncate overflow-hidden"},n),h("nl-login-status",{info:e})))})),h("li",{key:"936f2b75ca2dfca3483650d5d62fc50182cfc8f2",class:"first:pt-0 pt-2 border-t-[1px] first:border-none border-gray-300"},h("div",{key:"be0b4f29e70d8e2bc9fd1cc04c0fb43ad3dd5cac",onClick:()=>this.handleOpenModal(),class:"nl-select-option flex cursor-pointer items-center gap-x-3.5 py-2 px-3 rounded-lg text-sm"},h("div",{key:"bdd2a67e5763726666fcea91b0e7de67fe855994",class:"uppercase font-bold w-6 h-6 rounded-full border border-gray-400 flex justify-center items-center"},h("svg",{key:"f3a258f3e510ccb83b95bf3abecf65c248c8b0f1",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-4 h-4"},h("path",{key:"dafaa898f3e042531a923a9a77b94511895c6102","stroke-linecap":"round","stroke-linejoin":"round",d:"M12 4.5v15m7.5-7.5h-15"}))),"Add profile")))))}get element(){return this}static get watchers(){return{theme:["watchPropHandler"],darkMode:["watchModeHandler"],accounts:["watchAccountsHandler"]}}static get style(){return NlChangeAccountStyle0}},[0,"nl-change-account",{accounts:[16],currentAccount:[16],darkMode:[4,"dark-mode"],theme:[1],isOpen:[32],options:[32],mode:[32],themeState:[32]},[[8,"click","handleWindowClick"]],{theme:["watchPropHandler"],darkMode:["watchModeHandler"],accounts:["watchAccountsHandler"]}]);function defineCustomElement$2(){if("undefined"==typeof customElements)return;["nl-change-account","nl-login-status"].forEach((e=>{switch(e){case"nl-change-account":customElements.get(e)||customElements.define(e,NLChangeAccount);break;case"nl-login-status":customElements.get(e)||defineCustomElement$g()}}))}defineCustomElement$2();const nlDialogCss=baseCss,NlDialogStyle0=nlDialogCss,NlDialog=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.__attachShadow()}componentDidLoad(){var e;null===(e=this.dialogElement)||void 0===e||e.showModal()}disconnectedCallback(){var e;null===(e=this.dialogElement)||void 0===e||e.close()}render(){return h("dialog",{key:"2f2dfe3ccb1f617f4a8220cf19e832de98dccce5",ref:e=>this.dialogElement=e,class:"m-auto nl-banner-dialog",style:{border:"0",backgroundColor:"transparent"}},h("slot",{key:"fcf90b01dd2cbbaae8eb97cca3ec67e75cd61d63"}))}static get style(){return NlDialogStyle0}},[1,"nl-dialog"]);function defineCustomElement$1(){if("undefined"==typeof customElements)return;["nl-dialog"].forEach((e=>{if("nl-dialog"===e)customElements.get(e)||customElements.define(e,NlDialog)}))}defineCustomElement$1();const nlBannerCss=baseCss,NlBannerStyle0=nlBannerCss,NlBanner=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.handleNotifyConfirmBanner=createEvent(this,"handleNotifyConfirmBanner"),this.handleNotifyConfirmBannerIframe=createEvent(this,"handleNotifyConfirmBannerIframe"),this.handleLoginBanner=createEvent(this,"handleLoginBanner"),this.handleLogoutBanner=createEvent(this,"handleLogoutBanner"),this.handleOpenWelcomeModal=createEvent(this,"handleOpenWelcomeModal"),this.handleConfirmLogout=createEvent(this,"handleConfirmLogout"),this.handleImportModal=createEvent(this,"handleImportModal"),this.theme="default",this.darkMode=!1,this.hiddenMode=!1,this.titleBanner="",this.isOpen=!1,this.isLoading=!1,this.notify=null,this.userInfo=null,this.accounts=[],this.isUserImgError=!1,this.domain="",this.mode="",this.url="",this.isOpenConfirm=!1}watchNotifyHandler(e){var t,n,r,o;this.isOpen=!0,this.isOpenConfirm=!0,this.domain=(null===(t=this.userInfo)||void 0===t?void 0:t.domain)||(null===(o=null===(r=null===(n=this.userInfo)||void 0===n?void 0:n.nip05)||void 0===r?void 0:r.split("@"))||void 0===o?void 0:o[1])||"",this.mode=e.mode,this.url=e.url,this.mode||(this.isOpenConfirm=!1,this.isOpen=!1)}handleOpen(){this.userInfo?this.isOpen=!0:this.handleOpenWelcomeModal.emit()}handleClose(){this.isOpen=!1}handleLogin(){this.handleLoginBanner.emit(METHOD_MODULE.LOGIN),this.handleClose()}handleSignup(){this.handleLoginBanner.emit(METHOD_MODULE.SIGNUP),this.handleClose()}handleImport(){this.handleImportModal.emit(),this.handleClose()}handleLogout(){if(localStorage.getItem("backupKey"))return this.handleLogoutBanner.emit(METHOD_MODULE.LOGOUT),this.handleClose(),void localStorage.removeItem("backupKey");"local"===this.userInfo.authMethod?this.handleConfirmLogout.emit():this.handleLogoutBanner.emit(METHOD_MODULE.LOGOUT),this.handleClose()}handleConfirm(){switch(this.mode){case"authUrl":this.handleNotifyConfirmBanner.emit(this.url);break;case"iframeAuthUrl":this.handleNotifyConfirmBannerIframe.emit(this.url)}this.handleClose()}render(){var e,t,n,r,o,s;const i=Boolean(null===(e=this.userInfo)||void 0===e?void 0:e.picture),a=(null===(t=this.userInfo)||void 0===t?void 0:t.name)||(null===(o=null===(r=null===(n=this.userInfo)||void 0===n?void 0:n.nip05)||void 0===r?void 0:r.split("@"))||void 0===o?void 0:o[0])||(null===(s=this.userInfo)||void 0===s?void 0:s.pubkey)||"",l=Boolean(a),c=this.userInfo&&"local"===this.userInfo.authMethod,d=localStorage.getItem("backupKey"),u=h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-full"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})),p=h(Fragment,null,h("div",{class:"block w-[48px] h-[46px] relative z-10"},h("div",{onClick:()=>this.handleOpen(),class:"flex w-52 h-[46px] items-center pl-[11px]"},h("span",{class:(this.isLoading?"w-5 h-5 border-[2px] mr-3.5 ml-[2px] opacity-1":"w-0 h-0 border-[0px] mr-0 opacity-0 ml-0")+" animate-spin transition-all duration-300 ease-in-out inline-block border-current border-t-transparent text-slate-900 dark:text-gray-300 rounded-full",role:"status","aria-label":"loading"}),this.userInfo?h("div",{class:"uppercase font-bold w-6 h-6 mr-2 rounded-full border border-gray-200 flex justify-center items-center"},i?this.isUserImgError?u:h("img",{class:"w-full rounded-full",src:this.userInfo.picture,alt:"Logo",onError:()=>this.isUserImgError=!0}):l?a[0]:u):h("div",{class:"flex justify-center items-center"},h("svg",{class:"w-6 h-6",width:"225",height:"224",viewBox:"0 0 225 224",fill:"none",xmlns:"http://www.w3.org/2000/svg"},h("rect",{width:"224.047",height:"224",rx:"64",fill:"#6951FA"}),h("path",{d:"M162.441 135.941V88.0593C170.359 85.1674 176 77.5348 176 68.6696C176 57.2919 166.708 48 155.33 48C143.953 48 134.661 57.2444 134.661 68.6696C134.661 77.5822 140.302 85.1674 148.219 88.0593V135.941C147.698 136.13 147.176 136.367 146.655 136.604L87.3956 77.3452C88.6282 74.6904 89.2919 71.7511 89.2919 68.6696C89.2919 57.2444 80.0474 48 68.6696 48C57.2919 48 48 57.2444 48 68.6696C48 77.5822 53.6415 85.1674 61.5585 88.0593V135.941C53.6415 138.833 48 146.465 48 155.33C48 166.708 57.2444 176 68.6696 176C80.0948 176 89.3393 166.708 89.3393 155.33C89.3393 146.418 83.6978 138.833 75.7807 135.941V88.0593C76.3022 87.8696 76.8237 87.6326 77.3452 87.3956L136.604 146.655C135.372 149.31 134.708 152.249 134.708 155.33C134.708 166.708 143.953 176 155.378 176C166.803 176 176.047 166.708 176.047 155.33C176.047 146.418 170.406 138.833 162.489 135.941H162.441Z",fill:"white"})),this.isOpen&&h("span",{class:"px-2"},h("b",null,"Nostr")," Login")),this.isOpen&&l&&h("div",{class:"show-slow truncate w-16 text-xs"},a),this.isOpen&&l&&h("nl-login-status",{info:this.userInfo}))),h("button",{onClick:()=>this.handleClose(),type:"button",class:(this.isOpen?"z-20":"z-0")+" nl-action-button absolute right-2 top-2 z-0 show-slow grid place-items-center w-7 h-7 text-sm font-semibold rounded-full border border-transparent"},h("span",{class:"sr-only"},"Close"),h("svg",{class:"flex-shrink-0 w-5 h-5",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},h("path",{d:"M18 6 6 18"}),h("path",{d:"m6 6 12 12"}))),h("div",{class:"p-3 show-slow"},this.isOpenConfirm?h("div",null,h("div",{class:"w-8 h-8 p-1/2 rounded-full border border-gray-200 bg-white mb-2 mt-2 show-slow m-auto"},h("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"#5a68ff",class:"w-full"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"}))),h("p",{class:"mb-2 text-center max-w-40 min-w-40 mx-auto"},"timeout"===this.mode?"Keys not responding, check your key storage app":`Confirmation required at ${this.domain}`),"timeout"===this.mode?h("a",{onClick:()=>this.handleClose(),href:`https://${this.domain}`,target:"_blank",class:"nl-button text-nowrap py-2.5 px-3 w-full inline-flex justify-center items-center gap-x-2 text-sm font-medium rounded-lg disabled:opacity-50 disabled:pointer-events-none dark:focus:outline-none dark:focus:ring-1 dark:focus:ring-gray-600"},"Go to ",this.domain):"rebind"===this.mode?h("iframe",{src:this.url,width:"180",height:"80",frameBorder:"0"}):h("button-base",{onClick:()=>this.handleConfirm(),titleBtn:"Confirm"})):h("div",null,h("div",null,this.titleBanner&&h("p",{class:"mb-2 text-center show-slow max-w-40 min-w-40 mx-auto"},this.titleBanner),c&&h(Fragment,null,!d&&h("p",{class:"mb-2 text-center show-slow text-red-400 max-w-40 min-w-40 mx-auto"},"Your profile may be lost if you close this tab"),h("div",{class:"mb-2"},h("button-base",{onClick:()=>this.handleImport(),theme:"lemonade",titleBtn:"Back up profile"}))),h("div",{class:"mb-2"},h("nl-change-account",{currentAccount:this.userInfo,accounts:this.accounts})),this.userInfo?h("button-base",{onClick:()=>this.handleLogout(),titleBtn:"Log out"}):h("div",null,h("button-base",{onClick:()=>this.handleLogin(),titleBtn:"Log in"},h("svg",{style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"flex-shrink-0 w-4 h-4"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z"}))),h("button-base",{onClick:()=>this.handleSignup(),titleBtn:"Sign up"},h("svg",{style:{display:"none"},slot:"icon-start",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"flex-shrink-0 w-4 h-4"},h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M18 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0ZM3 19.235v-.11a6.375 6.375 0 0 1 12.75 0v.109A12.318 12.318 0 0 1 9.374 21c-2.331 0-4.512-.645-6.374-1.766Z"}))))))));const f=function e(t,n){n=n||document.body;const r=Array.from(n.querySelectorAll(t)),o=function(n){e(t,n).forEach((e=>{r.includes(e)||r.push(e)}))};n.shadowRoot&&o(n.shadowRoot);for(const e of Array.from(n.querySelectorAll("*")))e.shadowRoot&&o(e.shadowRoot);return r}("dialog"),g=!!f.find((e=>e.open&&!e.classList.contains("nl-banner-dialog")));return h("div",{class:`theme-${this.theme} ${!this.isOpen&&this.hiddenMode?"hidden":""}`},h("div",{class:this.darkMode&&"dark",dir:"ltr"},this.isOpenConfirm&&g?h("nl-dialog",null,h("div",{class:`nl-banner ${this.isOpen?"w-52 h-auto right-2 rounded-r-lg isOpen ":"rounded-r-none hover:rounded-r-lg cursor-pointer"} z-50 w-12 h-12 fixed top-52 right-0 inline-block gap-x-2 text-sm font-medium rounded-lg hover:right-2 transition-all duration-300 ease-in-out`},p)):h("div",{class:`nl-banner ${this.isOpen?"w-52 h-auto right-2 rounded-r-lg isOpen":"rounded-r-none hover:rounded-r-lg cursor-pointer"} z-50 w-12 h-12 fixed top-52 right-0 inline-block gap-x-2 text-sm font-medium rounded-lg hover:right-2 transition-all duration-300 ease-in-out`},p)))}static get watchers(){return{notify:["watchNotifyHandler"]}}static get style(){return NlBannerStyle0}},[1,"nl-banner",{theme:[1025],darkMode:[1028,"dark-mode"],hiddenMode:[1028,"hidden-mode"],titleBanner:[1,"title-banner"],isOpen:[1028,"is-open"],isLoading:[4,"is-loading"],notify:[16],userInfo:[16],accounts:[1040],isUserImgError:[32],domain:[32],mode:[32],url:[32],isOpenConfirm:[32]},void 0,{notify:["watchNotifyHandler"]}]);function defineCustomElement(){if("undefined"==typeof customElements)return;["nl-banner","button-base","nl-change-account","nl-dialog","nl-login-status"].forEach((e=>{switch(e){case"nl-banner":customElements.get(e)||customElements.define(e,NlBanner);break;case"button-base":customElements.get(e)||defineCustomElement$q();break;case"nl-change-account":customElements.get(e)||defineCustomElement$2();break;case"nl-dialog":customElements.get(e)||defineCustomElement$1();break;case"nl-login-status":customElements.get(e)||defineCustomElement$g()}}))}defineCustomElement();var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var lib$1={},types={};Object.defineProperty(types,"__esModule",{value:!0});var ee={},taskCollection$1={},taskCollection={},bakeCollection={};(function(exports$1){Object.defineProperty(exports$1,"__esModule",{value:!0}),exports$1.bakeCollectionVariadic=exports$1.bakeCollectionAwait=exports$1.bakeCollection=exports$1.BAKED_EMPTY_FUNC=void 0,exports$1.BAKED_EMPTY_FUNC=function(){};var FORLOOP_FALLBACK=1500;function generateArgsDefCode(e){var t="";if(0===e)return t;for(var n=0;n<e-1;++n)t+="arg"+String(n)+", ";return t+="arg"+String(e-1)}function generateBodyPartsCode(e,t){for(var n="",r="",o=0;o<t;++o)n+="var f".concat(o," = collection[").concat(o,"];\n"),r+="f".concat(o,"(").concat(e,")\n");return{funcDefCode:n,funcCallCode:r}}function generateBodyPartsVariadicCode(e){for(var t="",n="",r=0;r<e;++r)t+="var f".concat(r," = collection[").concat(r,"];\n"),n+="f".concat(r,".apply(undefined, arguments)\n");return{funcDefCode:t,funcCallCode:n}}function bakeCollection(collection,fixedArgsNum){if(0===collection.length)return exports$1.BAKED_EMPTY_FUNC;if(1===collection.length)return collection[0];var funcFactoryCode;if(collection.length<FORLOOP_FALLBACK){var argsDefCode=generateArgsDefCode(fixedArgsNum),_a=generateBodyPartsCode(argsDefCode,collection.length),funcDefCode=_a.funcDefCode,funcCallCode=_a.funcCallCode;funcFactoryCode="(function(collection) {\n ".concat(funcDefCode,"\n collection = undefined;\n return (function(").concat(argsDefCode,") {\n ").concat(funcCallCode,"\n });\n })")}else{var argsDefCode=generateArgsDefCode(fixedArgsNum);funcFactoryCode=collection.length%10==0?"(function(collection) {\n return (function(".concat(argsDefCode,") {\n for (var i = 0; i < collection.length; i += 10) {\n collection[i](").concat(argsDefCode,");\n collection[i+1](").concat(argsDefCode,");\n collection[i+2](").concat(argsDefCode,");\n collection[i+3](").concat(argsDefCode,");\n collection[i+4](").concat(argsDefCode,");\n collection[i+5](").concat(argsDefCode,");\n collection[i+6](").concat(argsDefCode,");\n collection[i+7](").concat(argsDefCode,");\n collection[i+8](").concat(argsDefCode,");\n collection[i+9](").concat(argsDefCode,");\n }\n });\n })"):collection.length%4==0?"(function(collection) {\n return (function(".concat(argsDefCode,") {\n for (var i = 0; i < collection.length; i += 4) {\n collection[i](").concat(argsDefCode,");\n collection[i+1](").concat(argsDefCode,");\n collection[i+2](").concat(argsDefCode,");\n collection[i+3](").concat(argsDefCode,");\n }\n });\n })"):collection.length%3==0?"(function(collection) {\n return (function(".concat(argsDefCode,") {\n for (var i = 0; i < collection.length; i += 3) {\n collection[i](").concat(argsDefCode,");\n collection[i+1](").concat(argsDefCode,");\n collection[i+2](").concat(argsDefCode,");\n }\n });\n })"):"(function(collection) {\n return (function(".concat(argsDefCode,") {\n for (var i = 0; i < collection.length; ++i) {\n collection[i](").concat(argsDefCode,");\n }\n });\n })")}var funcFactory=eval(funcFactoryCode);return funcFactory(collection)}function bakeCollectionAwait(collection,fixedArgsNum){if(0===collection.length)return exports$1.BAKED_EMPTY_FUNC;if(1===collection.length)return collection[0];var funcFactoryCode;if(collection.length<FORLOOP_FALLBACK){var argsDefCode=generateArgsDefCode(fixedArgsNum),_a=generateBodyPartsCode(argsDefCode,collection.length),funcDefCode=_a.funcDefCode,funcCallCode=_a.funcCallCode;funcFactoryCode="(function(collection) {\n ".concat(funcDefCode,"\n collection = undefined;\n return (function(").concat(argsDefCode,") {\n return Promise.all([ ").concat(funcCallCode," ]);\n });\n })")}else{var argsDefCode=generateArgsDefCode(fixedArgsNum);funcFactoryCode="(function(collection) {\n return (function(".concat(argsDefCode,") {\n var promises = Array(collection.length);\n for (var i = 0; i < collection.length; ++i) {\n promises[i] = collection[i](").concat(argsDefCode,");\n }\n return Promise.all(promises);\n });\n })")}var funcFactory=eval(funcFactoryCode);return funcFactory(collection)}function bakeCollectionVariadic(collection){if(0===collection.length)return exports$1.BAKED_EMPTY_FUNC;if(1===collection.length)return collection[0];var funcFactoryCode;if(collection.length<FORLOOP_FALLBACK){var _a=generateBodyPartsVariadicCode(collection.length),funcDefCode=_a.funcDefCode,funcCallCode=_a.funcCallCode;funcFactoryCode="(function(collection) {\n ".concat(funcDefCode,"\n collection = undefined;\n return (function() {\n ").concat(funcCallCode,"\n });\n })")}else funcFactoryCode="(function(collection) {\n return (function() {\n for (var i = 0; i < collection.length; ++i) {\n collection[i].apply(undefined, arguments);\n }\n });\n })";var funcFactory=eval(funcFactoryCode);return funcFactory(collection)}exports$1.bakeCollection=bakeCollection,exports$1.bakeCollectionAwait=bakeCollectionAwait,exports$1.bakeCollectionVariadic=bakeCollectionVariadic})(bakeCollection);var __spreadArray$1=commonjsGlobal&&commonjsGlobal.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(taskCollection,"__esModule",{value:!0}),taskCollection.TaskCollection=taskCollection._fast_remove_single=void 0;var bake_collection_1=bakeCollection;function push_norebuild(e,t){var n,r=this.length;if(r>1)t?((n=this._tasks).push.apply(n,arguments),this.length+=arguments.length):(this._tasks.push(e),this.length++);else if(t){var o;if(1===r)(o=Array(1+arguments.length)).push(o),o.push.apply(o,arguments),this._tasks=o;else(o=Array(arguments.length)).push.apply(o,arguments),this._tasks=o;this.length+=arguments.length}else this._tasks=1===r?[this._tasks,e]:e,this.length++}function push_rebuild(e,t){var n,r=this.length;if(r>1)t?((n=this._tasks).push.apply(n,arguments),this.length+=arguments.length):(this._tasks.push(e),this.length++);else if(t){var o;if(1===r)(o=Array(1+arguments.length)).push(o),o.push.apply(o,arguments),this._tasks=o;else(o=Array(arguments.length)).push.apply(o,arguments),this._tasks=o;this.length+=arguments.length}else this._tasks=1===r?[this._tasks,e]:e,this.length++;this.firstEmitBuildStrategy?this.call=rebuild_on_first_call:this.rebuild()}function _fast_remove_single(e,t){-1!==t&&(0===t?e.shift():t===e.length-1?e.length=e.length-1:e.splice(t,1))}function removeLast_norebuild(e){0!==this.length&&(1===this.length?this._tasks===e&&(this.length=0):(_fast_remove_single(this._tasks,this._tasks.lastIndexOf(e)),1===this._tasks.length?(this._tasks=this._tasks[0],this.length=1):this.length=this._tasks.length))}function removeLast_rebuild(e){if(0!==this.length){if(1===this.length)return this._tasks===e&&(this.length=0),this.firstEmitBuildStrategy?void(this.call=bake_collection_1.BAKED_EMPTY_FUNC):void this.rebuild();_fast_remove_single(this._tasks,this._tasks.lastIndexOf(e)),1===this._tasks.length?(this._tasks=this._tasks[0],this.length=1):this.length=this._tasks.length,this.firstEmitBuildStrategy?this.call=rebuild_on_first_call:this.rebuild()}}function insert_norebuild(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];0===this.length?(this._tasks=n,this.length=1):1===this.length?(n.unshift(this._tasks),this._tasks=n,this.length=this._tasks.length):((t=this._tasks).splice.apply(t,__spreadArray$1([e,0],n,!1)),this.length=this._tasks.length)}function insert_rebuild(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];0===this.length?(this._tasks=n,this.length=1):1===this.length?(n.unshift(this._tasks),this._tasks=n,this.length=this._tasks.length):((t=this._tasks).splice.apply(t,__spreadArray$1([e,0],n,!1)),this.length=this._tasks.length),this.firstEmitBuildStrategy?this.call=rebuild_on_first_call:this.rebuild()}function rebuild_noawait(){0===this.length?this.call=bake_collection_1.BAKED_EMPTY_FUNC:1===this.length?this.call=this._tasks:this.call=(0,bake_collection_1.bakeCollection)(this._tasks,this.argsNum)}function rebuild_await(){0===this.length?this.call=bake_collection_1.BAKED_EMPTY_FUNC:1===this.length?this.call=this._tasks:this.call=(0,bake_collection_1.bakeCollectionAwait)(this._tasks,this.argsNum)}function rebuild_on_first_call(){this.rebuild(),this.call.apply(void 0,arguments)}taskCollection._fast_remove_single=_fast_remove_single;var TaskCollection=function(e,t,n,r){void 0===t&&(t=!0),void 0===n&&(n=null),void 0===r&&(r=!1),this.awaitTasks=r,this.call=bake_collection_1.BAKED_EMPTY_FUNC,this.argsNum=e,this.firstEmitBuildStrategy=!0,this.rebuild=r?rebuild_await.bind(this):rebuild_noawait.bind(this),this.setAutoRebuild(t),n?"function"==typeof n?(this._tasks=n,this.length=1):(this._tasks=n,this.length=n.length):(this._tasks=null,this.length=0),t&&this.rebuild()};function fastClear(){this._tasks=null,this.length=0,this.call=bake_collection_1.BAKED_EMPTY_FUNC}function clear(){this._tasks=null,this.length=0,this.call=bake_collection_1.BAKED_EMPTY_FUNC}function growArgsNum(e){this.argsNum<e&&(this.argsNum=e,this.firstEmitBuildStrategy?this.call=rebuild_on_first_call:this.rebuild())}function setAutoRebuild(e){e?(this.push=push_rebuild.bind(this),this.insert=insert_rebuild.bind(this),this.removeLast=removeLast_rebuild.bind(this)):(this.push=push_norebuild.bind(this),this.insert=insert_norebuild.bind(this),this.removeLast=removeLast_norebuild.bind(this))}function tasksAsArray(){return 0===this.length?[]:1===this.length?[this._tasks]:this._tasks}function setTasks(e){0===e.length?(this.length=0,this.call=bake_collection_1.BAKED_EMPTY_FUNC):1===e.length?(this.length=1,this.call=e[0],this._tasks=e[0]):(this.length=e.length,this._tasks=e,this.firstEmitBuildStrategy?this.call=rebuild_on_first_call:this.rebuild())}taskCollection.TaskCollection=TaskCollection,TaskCollection.prototype.fastClear=fastClear,TaskCollection.prototype.clear=clear,TaskCollection.prototype.growArgsNum=growArgsNum,TaskCollection.prototype.setAutoRebuild=setAutoRebuild,TaskCollection.prototype.tasksAsArray=tasksAsArray,TaskCollection.prototype.setTasks=setTasks,function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=commonjsGlobal&&commonjsGlobal.__exportStar||function(e,n){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(n,r)||t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(taskCollection,e)}(taskCollection$1);var utils$2={};function nullObj(){var e={__proto__:null,prototype:null};return e}Object.defineProperty(utils$2,"__esModule",{value:!0}),utils$2.nullObj=void 0,utils$2.nullObj=nullObj;var __spreadArray=commonjsGlobal&&commonjsGlobal.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(ee,"__esModule",{value:!0}),ee.EventEmitter=void 0;var task_collection_1=taskCollection$1,utils_1=utils$2;function emit(e,t,n,r,o,s){var i=this.events[e];return!!i&&(0!==i.length&&(i.argsNum<6?i.call(t,n,r,o,s):i.call.apply(void 0,arguments),!0))}function emitHasOnce(e,t,n,r,o,s){var i=this.events[e];if(i){if(0===i.length)return!1;i.argsNum<6?i.call(t,n,r,o,s):i.call.apply(void 0,arguments)}var a=this.onceEvents[e];if(a){if("function"==typeof a)this.onceEvents[e]=void 0,arguments.length<6?a(t,n,r,o,s):a.apply(void 0,arguments);else{var l=a;if(this.onceEvents[e]=void 0,arguments.length<6)for(var c=0;c<l.length;++c)l[c](t,n,r,o,s);else for(c=0;c<l.length;++c)l[c].apply(void 0,arguments)}return!0}return!!i}var EventEmitter=function(){function e(){this.events=(0,utils_1.nullObj)(),this.onceEvents=(0,utils_1.nullObj)(),this._symbolKeys=new Set,this.maxListeners=1/0}return Object.defineProperty(e.prototype,"_eventsCount",{get:function(){return this.eventNames().length},enumerable:!1,configurable:!0}),e}();function once(e,t){switch(this.emit===emit&&(this.emit=emitHasOnce),typeof this.onceEvents[e]){case"undefined":this.onceEvents[e]=t,"symbol"==typeof e&&this._symbolKeys.add(e);break;case"function":this.onceEvents[e]=[this.onceEvents[e],t];break;case"object":this.onceEvents[e].push(t)}return this}function addListener(e,t,n){if(void 0===n&&(n=t.length),"function"!=typeof t)throw new TypeError("The listener must be a function");var r=this.events[e];return r?(r.push(t),r.growArgsNum(n),this.maxListeners!==1/0&&this.maxListeners<=r.length&&console.warn('Maximum event listeners for "'.concat(String(e),'" event!'))):(this.events[e]=new task_collection_1.TaskCollection(n,!0,t,!1),"symbol"==typeof e&&this._symbolKeys.add(e)),this}function removeListener(e,t){var n=this.events[e];n&&n.removeLast(t);var r=this.onceEvents[e];return r&&("function"==typeof r?this.onceEvents[e]=void 0:"object"==typeof r&&(1===r.length&&r[0]===t?this.onceEvents[e]=void 0:(0,task_collection_1._fast_remove_single)(r,r.lastIndexOf(t)))),this}function addListenerBound(e,t,n,r){void 0===n&&(n=this),void 0===r&&(r=t.length),this.boundFuncs||(this.boundFuncs=new Map);var o=t.bind(n);return this.boundFuncs.set(t,o),this.addListener(e,o,r)}function removeListenerBound(e,t){var n,r,o=null===(n=this.boundFuncs)||void 0===n?void 0:n.get(t);return null===(r=this.boundFuncs)||void 0===r||r.delete(t),this.removeListener(e,o)}function hasListeners(e){return this.events[e]&&!!this.events[e].length}function prependListener(e,t,n){if(void 0===n&&(n=t.length),"function"!=typeof t)throw new TypeError("The listener must be a function");var r=this.events[e];return r&&r instanceof task_collection_1.TaskCollection?(r.insert(0,t),r.growArgsNum(n),this.maxListeners!==1/0&&this.maxListeners<=r.length&&console.warn('Maximum event listeners for "'.concat(String(e),'" event!'))):(r=this.events[e]=new task_collection_1.TaskCollection(n,!0,t,!1),"symbol"==typeof e&&this._symbolKeys.add(e)),this}function prependOnceListener(e,t){this.emit===emit&&(this.emit=emitHasOnce);var n=this.onceEvents[e];return n?"object"!=typeof n?(this.onceEvents[e]=[t,n],"symbol"==typeof e&&this._symbolKeys.add(e)):(n.unshift(t),this.maxListeners!==1/0&&this.maxListeners<=n.length&&console.warn('Maximum event listeners for "'.concat(String(e),'" once event!'))):(this.onceEvents[e]=[t],"symbol"==typeof e&&this._symbolKeys.add(e)),this}function removeAllListeners(e){return void 0===e?(this.events=(0,utils_1.nullObj)(),this.onceEvents=(0,utils_1.nullObj)(),this._symbolKeys=new Set):(this.events[e]=void 0,this.onceEvents[e]=void 0,"symbol"==typeof e&&this._symbolKeys.delete(e)),this}function setMaxListeners(e){return this.maxListeners=e,this}function getMaxListeners(){return this.maxListeners}function listeners(e){return this.emit===emit?this.events[e]?this.events[e].tasksAsArray().slice():[]:this.events[e]&&this.onceEvents[e]?__spreadArray(__spreadArray([],this.events[e].tasksAsArray(),!0),"function"==typeof this.onceEvents[e]?[this.onceEvents[e]]:this.onceEvents[e],!0):this.events[e]?this.events[e].tasksAsArray():this.onceEvents[e]?"function"==typeof this.onceEvents[e]?[this.onceEvents[e]]:this.onceEvents[e]:[]}function eventNames(){var e=this;if(this.emit===emit){var t=Object.keys(this.events);return __spreadArray(__spreadArray([],t,!0),Array.from(this._symbolKeys),!0).filter((function(t){return t in e.events&&e.events[t]&&e.events[t].length}))}t=Object.keys(this.events).filter((function(t){return e.events[t]&&e.events[t].length}));var n=Object.keys(this.onceEvents).filter((function(t){return e.onceEvents[t]&&e.onceEvents[t].length}));return __spreadArray(__spreadArray(__spreadArray([],t,!0),n,!0),Array.from(this._symbolKeys).filter((function(t){return t in e.events&&e.events[t]&&e.events[t].length||t in e.onceEvents&&e.onceEvents[t]&&e.onceEvents[t].length})),!0)}function listenerCount(e){return this.emit===emit?this.events[e]&&this.events[e].length||0:(this.events[e]&&this.events[e].length||0)+(this.onceEvents[e]&&this.onceEvents[e].length||0)}function number$3(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function bool$3(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)}function bytes$3(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function hash$3(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");number$3(e.outputLen),number$3(e.blockLen)}function exists$3(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output$3(e,t){bytes$3(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}ee.EventEmitter=EventEmitter,EventEmitter.prototype.emit=emit,EventEmitter.prototype.on=addListener,EventEmitter.prototype.once=once,EventEmitter.prototype.addListener=addListener,EventEmitter.prototype.removeListener=removeListener,EventEmitter.prototype.addListenerBound=addListenerBound,EventEmitter.prototype.removeListenerBound=removeListenerBound,EventEmitter.prototype.hasListeners=hasListeners,EventEmitter.prototype.prependListener=prependListener,EventEmitter.prototype.prependOnceListener=prependOnceListener,EventEmitter.prototype.off=removeListener,EventEmitter.prototype.removeAllListeners=removeAllListeners,EventEmitter.prototype.setMaxListeners=setMaxListeners,EventEmitter.prototype.getMaxListeners=getMaxListeners,EventEmitter.prototype.listeners=listeners,EventEmitter.prototype.eventNames=eventNames,EventEmitter.prototype.listenerCount=listenerCount,function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=commonjsGlobal&&commonjsGlobal.__exportStar||function(e,n){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(n,r)||t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(types,e),n(ee,e)}(lib$1);const assert$3={number:number$3,bool:bool$3,bytes:bytes$3,hash:hash$3,exists:exists$3,output:output$3},crypto$3="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,u8a$3=e=>e instanceof Uint8Array,createView$2=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),rotr$2=(e,t)=>e<<32-t|e>>>t,isLE$3=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!isLE$3)throw new Error("Non little-endian hardware is not supported");function utf8ToBytes$4(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function toBytes$3(e){if("string"==typeof e&&(e=utf8ToBytes$4(e)),!u8a$3(e))throw new Error("expected Uint8Array, got "+typeof e);return e}function concatBytes$3(...e){const t=new Uint8Array(e.reduce(((e,t)=>e+t.length),0));let n=0;return e.forEach((e=>{if(!u8a$3(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length})),t}Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));let Hash$2=class{clone(){return this._cloneInto()}};function wrapConstructor$2(e){const t=t=>e().update(toBytes$3(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function randomBytes$2(e=32){if(crypto$3&&"function"==typeof crypto$3.getRandomValues)return crypto$3.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function setBigUint64$2(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),a=Number(n&s),l=r?4:0,c=r?0:4;e.setUint32(t+l,i,r),e.setUint32(t+c,a,r)}let SHA2$2=class extends Hash$2{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=createView$2(this.buffer)}update(e){assert$3.exists(this);const{view:t,buffer:n,blockLen:r}=this,o=(e=toBytes$3(e)).length;for(let s=0;s<o;){const i=Math.min(r-this.pos,o-s);if(i!==r)n.set(e.subarray(s,s+i),this.pos),this.pos+=i,s+=i,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=createView$2(e);for(;r<=o-s;s+=r)this.process(t,s)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){assert$3.exists(this),assert$3.output(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>r-s&&(this.process(n,0),s=0);for(let e=s;e<r;e++)t[e]=0;setBigUint64$2(n,r-8,BigInt(8*this.length),o),this.process(n,0);const i=createView$2(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)i.setUint32(4*e,c[e],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:o,destroyed:s,pos:i}=this;return e.length=r,e.pos=i,e.finished=o,e.destroyed=s,r%t&&e.buffer.set(n),e}};const Chi$2=(e,t,n)=>e&t^~e&n,Maj$2=(e,t,n)=>e&t^e&n^t&n,SHA256_K$2=new Uint32Array([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]),IV$2=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W$2=new Uint32Array(64);let SHA256$2=class extends SHA2$2{constructor(){super(64,32,8,!1),this.A=0|IV$2[0],this.B=0|IV$2[1],this.C=0|IV$2[2],this.D=0|IV$2[3],this.E=0|IV$2[4],this.F=0|IV$2[5],this.G=0|IV$2[6],this.H=0|IV$2[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:s,G:i,H:a}=this;return[e,t,n,r,o,s,i,a]}set(e,t,n,r,o,s,i,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|s,this.G=0|i,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)SHA256_W$2[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=SHA256_W$2[e-15],n=SHA256_W$2[e-2],r=rotr$2(t,7)^rotr$2(t,18)^t>>>3,o=rotr$2(n,17)^rotr$2(n,19)^n>>>10;SHA256_W$2[e]=o+SHA256_W$2[e-7]+r+SHA256_W$2[e-16]|0}let{A:n,B:r,C:o,D:s,E:i,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){const t=c+(rotr$2(i,6)^rotr$2(i,11)^rotr$2(i,25))+Chi$2(i,a,l)+SHA256_K$2[e]+SHA256_W$2[e]|0,d=(rotr$2(n,2)^rotr$2(n,13)^rotr$2(n,22))+Maj$2(n,r,o)|0;c=l,l=a,a=i,i=s+t|0,s=o,o=r,r=n,n=t+d|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,s=s+this.D|0,i=i+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,o,s,i,a,l,c)}roundClean(){SHA256_W$2.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},SHA224$1=class extends SHA256$2{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};const sha256$2=wrapConstructor$2((()=>new SHA256$2));wrapConstructor$2((()=>new SHA224$1));
7
2
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
8
- function getHash$2(e){return{hash:e,hmac:(t,...n)=>hmac$6(e,t,concatBytes$8(...n)),randomBytes:randomBytes$5}}function createCurve$3(e,t){const n=t=>weierstrass$3({...e,...getHash$2(t)});return Object.freeze({...n(t),create:n})}
9
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */hmac$6.create=(e,t)=>new HMAC$6(e,t);const secp256k1P$2=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N$2=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n$f=BigInt(1),_2n$9=BigInt(2),divNearest$3=(e,t)=>(e+t/_2n$9)/t;function sqrtMod$3(e){const t=secp256k1P$2,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,h=l*l*e%t,d=pow2$3(h,n,t)*h%t,u=pow2$3(d,n,t)*h%t,f=pow2$3(u,_2n$9,t)*l%t,p=pow2$3(f,i,t)*f%t,g=pow2$3(p,s,t)*p%t,y=pow2$3(g,a,t)*g%t,m=pow2$3(y,c,t)*y%t,b=pow2$3(m,a,t)*g%t,w=pow2$3(b,n,t)*h%t,v=pow2$3(w,o,t)*p%t,$=pow2$3(v,r,t)*l%t,E=pow2$3($,_2n$9,t);if(!Fp$2.eql(Fp$2.sqr(E),e))throw new Error("Cannot find square root");return E}const Fp$2=Field$3(secp256k1P$2,void 0,void 0,{sqrt:sqrtMod$3}),secp256k1$3=createCurve$3({a:BigInt(0),b:BigInt(7),Fp:Fp$2,n:secp256k1N$2,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=secp256k1N$2,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-_1n$f*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,o=BigInt("0x100000000000000000000000000000000"),a=divNearest$3(s*e,t),c=divNearest$3(-r*e,t);let l=mod$3(e-a*n-c*i,t),h=mod$3(-a*r-c*s,t);const d=l>o,u=h>o;if(d&&(l=t-l),u&&(h=t-h),l>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:l,k2neg:u,k2:h}}}},sha256$7),_0n$e=BigInt(0),fe$1=e=>"bigint"==typeof e&&_0n$e<e&&e<secp256k1P$2,ge$1=e=>"bigint"==typeof e&&_0n$e<e&&e<secp256k1N$2,TAGGED_HASH_PREFIXES$2={};function taggedHash$2(e,...t){let n=TAGGED_HASH_PREFIXES$2[e];if(void 0===n){const t=sha256$7(Uint8Array.from(e,e=>e.charCodeAt(0)));n=concatBytes$7(t,t),TAGGED_HASH_PREFIXES$2[e]=n}return sha256$7(concatBytes$7(n,...t))}const pointToBytes$2=e=>e.toRawBytes(!0).slice(1),numTo32b$1=e=>numberToBytesBE$3(e,32),modP$1=e=>mod$3(e,secp256k1P$2),modN$1=e=>mod$3(e,secp256k1N$2),Point$2=secp256k1$3.ProjectivePoint,GmulAdd$1=(e,t,n)=>Point$2.BASE.multiplyAndAddUnsafe(e,t,n);function schnorrGetExtPubKey$2(e){let t=secp256k1$3.utils.normPrivateKeyToScalar(e),n=Point$2.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:modN$1(-t),bytes:pointToBytes$2(n)}}function lift_x$2(e){if(!fe$1(e))throw new Error("bad x: need 0 < x < p");const t=modP$1(e*e);let n=sqrtMod$3(modP$1(t*e+BigInt(7)));n%_2n$9!==_0n$e&&(n=modP$1(-n));const r=new Point$2(e,n,_1n$f);return r.assertValidity(),r}function challenge$2(...e){return modN$1(bytesToNumberBE$3(taggedHash$2("BIP0340/challenge",...e)))}function schnorrGetPublicKey$2(e){return schnorrGetExtPubKey$2(e).bytes}function schnorrSign$2(e,t,n=randomBytes$5(32)){const r=ensureBytes$4("message",e),{bytes:i,scalar:s}=schnorrGetExtPubKey$2(t),o=ensureBytes$4("auxRand",n,32),a=numTo32b$1(s^bytesToNumberBE$3(taggedHash$2("BIP0340/aux",o))),c=taggedHash$2("BIP0340/nonce",a,i,r),l=modN$1(bytesToNumberBE$3(c));if(l===_0n$e)throw new Error("sign failed: k is zero");const{bytes:h,scalar:d}=schnorrGetExtPubKey$2(l),u=challenge$2(h,i,r),f=new Uint8Array(64);if(f.set(h,0),f.set(numTo32b$1(modN$1(d+u*s)),32),!schnorrVerify$2(f,r,i))throw new Error("sign: Invalid signature produced");return f}function schnorrVerify$2(e,t,n){const r=ensureBytes$4("signature",e,64),i=ensureBytes$4("message",t),s=ensureBytes$4("publicKey",n,32);try{const e=lift_x$2(bytesToNumberBE$3(s)),t=bytesToNumberBE$3(r.subarray(0,32));if(!fe$1(t))return!1;const n=bytesToNumberBE$3(r.subarray(32,64));if(!ge$1(n))return!1;const o=challenge$2(numTo32b$1(t),pointToBytes$2(e),i),a=GmulAdd$1(e,n,modN$1(-o));return!(!a||!a.hasEvenY()||a.toAffine().x!==t)}catch(e){return!1}}const schnorr$2=(()=>({getPublicKey:schnorrGetPublicKey$2,sign:schnorrSign$2,verify:schnorrVerify$2,utils:{randomPrivateKey:secp256k1$3.utils.randomPrivateKey,lift_x:lift_x$2,pointToBytes:pointToBytes$2,numberToBytesBE:numberToBytesBE$3,bytesToNumberBE:bytesToNumberBE$3,taggedHash:taggedHash$2,mod:mod$3}}))(),crypto$5="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,u8a$5=e=>e instanceof Uint8Array,u32$2=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),createView$6=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),rotr$5=(e,t)=>e<<32-t|e>>>t,isLE$6=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!isLE$6)throw new Error("Non little-endian hardware is not supported");const hexes$6=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function bytesToHex$6(e){if(!u8a$5(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=hexes$6[e[n]];return t}function hexToBytes$6(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const r=2*t,i=e.slice(r,r+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[t]=s}return n}function utf8ToBytes$9(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function toBytes$7(e){if("string"==typeof e&&(e=utf8ToBytes$9(e)),!u8a$5(e))throw new Error("expected Uint8Array, got "+typeof e);return e}function concatBytes$6(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!u8a$5(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}let Hash$5=class{clone(){return this._cloneInto()}};const isPlainObject$1=e=>"[object Object]"===Object.prototype.toString.call(e)&&e.constructor===Object;function checkOpts$3(e,t){if(void 0!==t&&("object"!=typeof t||!isPlainObject$1(t)))throw new Error("Options should be object or undefined");return Object.assign(e,t)}function wrapConstructor$4(e){const t=t=>e().update(toBytes$7(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function randomBytes$4(e=32){if(crypto$5&&"function"==typeof crypto$5.getRandomValues)return crypto$5.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function number$6(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function bool$5(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)}function bytes$6(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function hash$5(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");number$6(e.outputLen),number$6(e.blockLen)}function exists$6(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output$6(e,t){bytes$6(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const assert$4={number:number$6,bool:bool$5,bytes:bytes$6,hash:hash$5,exists:exists$6,output:output$6};function setBigUint64$6(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,a,r)}let SHA2$4=class extends Hash$5{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=createView$6(this.buffer)}update(e){assert$4.exists(this);const{view:t,buffer:n,blockLen:r}=this,i=(e=toBytes$7(e)).length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);if(o===r){const t=createView$6(e);for(;r<=i-s;s+=r)this.process(t,s);continue}n.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){assert$4.exists(this),assert$4.output(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>r-s&&(this.process(n,0),s=0);for(let e=s;e<r;e++)t[e]=0;setBigUint64$6(n,r-8,BigInt(8*this.length),i),this.process(n,0);const o=createView$6(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:i,destroyed:s,pos:o}=this;return e.length=r,e.pos=o,e.finished=i,e.destroyed=s,r%t&&e.buffer.set(n),e}};const Chi$5=(e,t,n)=>e&t^~e&n,Maj$5=(e,t,n)=>e&t^e&n^t&n,SHA256_K$5=new Uint32Array([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]),IV$4=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W$5=new Uint32Array(64);let SHA256$5=class extends SHA2$4{constructor(){super(64,32,8,!1),this.A=0|IV$4[0],this.B=0|IV$4[1],this.C=0|IV$4[2],this.D=0|IV$4[3],this.E=0|IV$4[4],this.F=0|IV$4[5],this.G=0|IV$4[6],this.H=0|IV$4[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:s,G:o,H:a}=this;return[e,t,n,r,i,s,o,a]}set(e,t,n,r,i,s,o,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)SHA256_W$5[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=SHA256_W$5[e-15],n=SHA256_W$5[e-2],r=rotr$5(t,7)^rotr$5(t,18)^t>>>3,i=rotr$5(n,17)^rotr$5(n,19)^n>>>10;SHA256_W$5[e]=i+SHA256_W$5[e-7]+r+SHA256_W$5[e-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(rotr$5(o,6)^rotr$5(o,11)^rotr$5(o,25))+Chi$5(o,a,c)+SHA256_K$5[e]+SHA256_W$5[e]|0,h=(rotr$5(n,2)^rotr$5(n,13)^rotr$5(n,22))+Maj$5(n,r,i)|0;l=c,c=a,a=o,o=s+t|0,s=i,i=r,r=n,n=t+h|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,s,o,a,c,l)}roundClean(){SHA256_W$5.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},SHA224$2=class extends SHA256$5{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};const sha256$6=wrapConstructor$4(()=>new SHA256$5);
10
- /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
11
- function assertNumber$1(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function chain$3(...e){const t=(e,t)=>n=>e(t(n)),n=Array.from(e).reverse().reduce((e,n)=>e?t(e,n.encode):n.encode,void 0),r=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:r}}function alphabet$3(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map(t=>{if(assertNumber$1(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]})},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map(t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})}}}function join$3(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function padding$2(e,t="="){if(assertNumber$1(e),"string"!=typeof t)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;n.length*e%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let r=n.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function normalize$3(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function convertRadix$3(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const i=[],s=Array.from(e);for(s.forEach(e=>{if(assertNumber$1(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)});;){let e=0,o=!0;for(let i=r;i<s.length;i++){const a=s[i],c=t*e+a;if(!Number.isSafeInteger(c)||t*e/t!==e||c-a!==t*e)throw new Error("convertRadix: carry overflow");if(e=c%n,s[i]=Math.floor(c/n),!Number.isSafeInteger(s[i])||s[i]*n+e!==c)throw new Error("convertRadix: carry overflow");o&&(s[i]?o=!1:r=i)}if(i.push(e),o)break}for(let t=0;t<e.length-1&&0===e[t];t++)i.push(0);return i.reverse()}wrapConstructor$4(()=>new SHA224$2);const gcd$2=(e,t)=>t?gcd$2(t,e%t):e,radix2carry$2=(e,t)=>e+(t-gcd$2(e,t));function convertRadix2$2(e,t,n,r){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(radix2carry$2(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${radix2carry$2(t,n)}`);let i=0,s=0;const o=2**n-1,a=[];for(const r of e){if(assertNumber$1(r),r>=2**t)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(i=i<<t|r,s+t>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)a.push((i>>s-n&o)>>>0);i&=2**s-1}if(i=i<<n-s&o,!r&&s>=t)throw new Error("Excess padding");if(!r&&i)throw new Error(`Non-zero padding: ${i}`);return r&&s>0&&a.push(i>>>0),a}function radix$3(e){return assertNumber$1(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return convertRadix$3(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(convertRadix$3(t,e,256))}}}function radix2$2(e,t=!1){if(assertNumber$1(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(radix2carry$2(8,e)>32||radix2carry$2(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return convertRadix2$2(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(convertRadix2$2(n,e,8,t))}}}function unsafeWrapper$1(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}const base16$1=chain$3(radix2$2(4),alphabet$3("0123456789ABCDEF"),join$3("")),base32$1=chain$3(radix2$2(5),alphabet$3("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),padding$2(5),join$3(""));chain$3(radix2$2(5),alphabet$3("0123456789ABCDEFGHIJKLMNOPQRSTUV"),padding$2(5),join$3("")),chain$3(radix2$2(5),alphabet$3("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),join$3(""),normalize$3(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const base64$1=chain$3(radix2$2(6),alphabet$3("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),padding$2(6),join$3("")),base64url$1=chain$3(radix2$2(6),alphabet$3("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),padding$2(6),join$3("")),genBase58$2=e=>chain$3(radix$3(58),alphabet$3(e),join$3("")),base58$2=genBase58$2("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");genBase58$2("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),genBase58$2("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const XMR_BLOCK_LEN$1=[0,2,3,5,6,7,9,10,11],base58xmr$1={encode(e){let t="";for(let n=0;n<e.length;n+=8){const r=e.subarray(n,n+8);t+=base58$2.encode(r).padStart(XMR_BLOCK_LEN$1[r.length],"1")}return t},decode(e){let t=[];for(let n=0;n<e.length;n+=11){const r=e.slice(n,n+11),i=XMR_BLOCK_LEN$1.indexOf(r.length),s=base58$2.decode(r);for(let e=0;e<s.length-i;e++)if(0!==s[e])throw new Error("base58xmr: wrong padding");t=t.concat(Array.from(s.slice(s.length-i)))}return Uint8Array.from(t)}},BECH_ALPHABET$1=chain$3(alphabet$3("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),join$3("")),POLYMOD_GENERATORS$1=[996825010,642813549,513874426,1027748829,705979059];function bech32Polymod$1(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e<POLYMOD_GENERATORS$1.length;e++)1==(t>>e&1)&&(n^=POLYMOD_GENERATORS$1[e]);return n}function bechChecksum$1(e,t,n=1){const r=e.length;let i=1;for(let t=0;t<r;t++){const n=e.charCodeAt(t);if(n<33||n>126)throw new Error(`Invalid prefix (${e})`);i=bech32Polymod$1(i)^n>>5}i=bech32Polymod$1(i);for(let t=0;t<r;t++)i=bech32Polymod$1(i)^31&e.charCodeAt(t);for(let e of t)i=bech32Polymod$1(i)^e;for(let e=0;e<6;e++)i=bech32Polymod$1(i);return i^=n,BECH_ALPHABET$1.encode(convertRadix2$2([i%2**30],30,5,!1))}function genBech32$1(e){const t="bech32"===e?1:734539939,n=radix2$2(5),r=n.decode,i=n.encode,s=unsafeWrapper$1(r);function o(e,n=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==n&&e.length>n)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=(e=r).lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const s=e.slice(0,i),o=e.slice(i+1);if(o.length<6)throw new Error("Data must be at least 6 characters long");const a=BECH_ALPHABET$1.decode(o).slice(0,-6),c=bechChecksum$1(s,a,t);if(!o.endsWith(c))throw new Error(`Invalid checksum in ${e}: expected "${c}"`);return{prefix:s,words:a}}return{encode:function(e,n,r=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const i=e.length+7+n.length;if(!1!==r&&i>r)throw new TypeError(`Length ${i} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${BECH_ALPHABET$1.encode(n)}${bechChecksum$1(e,n,t)}`},decode:o,decodeToBytes:function(e){const{prefix:t,words:n}=o(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:unsafeWrapper$1(o),fromWords:r,fromWordsUnsafe:s,toWords:i}}const bech32$2=genBech32$1("bech32");genBech32$1("bech32m");const utf8$2={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},hex$2=chain$3(radix2$2(4),alphabet$3("0123456789abcdef"),join$3(""),normalize$3(e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})),CODERS$1={utf8:utf8$2,hex:hex$2,base16:base16$1,base32:base32$1,base64:base64$1,base64url:base64url$1,base58:base58$2,base58xmr:base58xmr$1};function number$5(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function bool$4(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function isBytes$7(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function bytes$5(e,...t){if(!isBytes$7(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function exists$5(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output$5(e,t){bytes$5(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}
12
- /*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */Object.keys(CODERS$1).join(", ");const u32$1=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),createView$5=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),isLE$5=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!isLE$5)throw new Error("Non little-endian hardware is not supported");const hexes$5=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function bytesToHex$5(e){bytes$5(e);let t="";for(let n=0;n<e.length;n++)t+=hexes$5[e[n]];return t}const asciis$2={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function asciiToBase16$2(e){return e>=asciis$2._0&&e<=asciis$2._9?e-asciis$2._0:e>=asciis$2._A&&e<=asciis$2._F?e-(asciis$2._A-10):e>=asciis$2._a&&e<=asciis$2._f?e-(asciis$2._a-10):void 0}function hexToBytes$5(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){const n=asciiToBase16$2(e.charCodeAt(i)),s=asciiToBase16$2(e.charCodeAt(i+1));if(void 0===n||void 0===s){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+s}return r}function utf8ToBytes$8(e){if("string"!=typeof e)throw new Error("string expected, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function toBytes$6(e){if("string"==typeof e)e=utf8ToBytes$8(e);else{if(!isBytes$7(e))throw new Error("Uint8Array expected, got "+typeof e);e=e.slice()}return e}function checkOpts$2(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)}function equalBytes$3(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n}const wrapCipher=(e,t)=>(Object.assign(t,e),t);function setBigUint64$5(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s);e.setUint32(t+4,o,r),e.setUint32(t+0,a,r)}const BLOCK_SIZE=16,POLY=283;function mul2(e){return e<<1^POLY&-(e>>7)}function mul(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=mul2(e);return n}const sbox=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=mul2(n))e[t]=n;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return t})(),invSbox=sbox.map((e,t)=>sbox.indexOf(t)),rotr32_8=e=>e<<24|e>>>8,rotl32_8=e=>e<<8|e>>>24;function genTtable(e,t){if(256!==e.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((n,r)=>t(e[r])),r=n.map(rotl32_8),i=r.map(rotl32_8),s=i.map(rotl32_8),o=new Uint32Array(65536),a=new Uint32Array(65536),c=new Uint16Array(65536);for(let t=0;t<256;t++)for(let l=0;l<256;l++){const h=256*t+l;o[h]=n[t]^r[l],a[h]=i[t]^s[l],c[h]=e[t]<<8|e[l]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:i,T3:s,T01:o,T23:a}}const tableEncoding=genTtable(sbox,e=>mul(e,3)<<24|e<<16|e<<8|mul(e,2)),tableDecoding=genTtable(invSbox,e=>mul(e,11)<<24|mul(e,13)<<16|mul(e,9)<<8|mul(e,14)),xPowers=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=mul2(n))e[t]=n;return e})();function expandKeyLE(e){bytes$5(e);const t=e.length;if(![16,24,32].includes(t))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);const{sbox2:n}=tableEncoding,r=u32$1(e),i=r.length,s=e=>applySbox(n,e,e,e,e),o=new Uint32Array(t+28);o.set(r);for(let e=i;e<o.length;e++){let t=o[e-1];e%i===0?t=s(rotr32_8(t))^xPowers[e/i-1]:i>6&&e%i===4&&(t=s(t)),o[e]=o[e-i]^t}return o}function expandKeyDecLE(e){const t=expandKeyLE(e),n=t.slice(),r=t.length,{sbox2:i}=tableEncoding,{T0:s,T1:o,T2:a,T3:c}=tableDecoding;for(let e=0;e<r;e+=4)for(let i=0;i<4;i++)n[e+i]=t[r-e-4+i];t.fill(0);for(let e=4;e<r-4;e++){const t=n[e],r=applySbox(i,t,t,t,t);n[e]=s[255&r]^o[r>>>8&255]^a[r>>>16&255]^c[r>>>24]}return n}function apply0123(e,t,n,r,i,s){return e[n<<8&65280|r>>>8&255]^t[i>>>8&65280|s>>>24&255]}function applySbox(e,t,n,r,i){return e[255&t|65280&n]|e[r>>>16&255|i>>>16&65280]<<16}function encrypt$4(e,t,n,r,i){const{sbox2:s,T01:o,T23:a}=tableEncoding;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];const l=e.length/4-2;for(let s=0;s<l;s++){const s=e[c++]^apply0123(o,a,t,n,r,i),l=e[c++]^apply0123(o,a,n,r,i,t),h=e[c++]^apply0123(o,a,r,i,t,n),d=e[c++]^apply0123(o,a,i,t,n,r);t=s,n=l,r=h,i=d}return{s0:e[c++]^applySbox(s,t,n,r,i),s1:e[c++]^applySbox(s,n,r,i,t),s2:e[c++]^applySbox(s,r,i,t,n),s3:e[c++]^applySbox(s,i,t,n,r)}}function decrypt$4(e,t,n,r,i){const{sbox2:s,T01:o,T23:a}=tableDecoding;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];const l=e.length/4-2;for(let s=0;s<l;s++){const s=e[c++]^apply0123(o,a,t,i,r,n),l=e[c++]^apply0123(o,a,n,t,i,r),h=e[c++]^apply0123(o,a,r,n,t,i),d=e[c++]^apply0123(o,a,i,r,n,t);t=s,n=l,r=h,i=d}return{s0:e[c++]^applySbox(s,t,i,r,n),s1:e[c++]^applySbox(s,n,t,i,r),s2:e[c++]^applySbox(s,r,n,t,i),s3:e[c++]^applySbox(s,i,r,n,t)}}function getDst(e,t){if(!t)return new Uint8Array(e);if(bytes$5(t),t.length<e)throw new Error(`aes: wrong destination length, expected at least ${e}, got: ${t.length}`);return t}function validateBlockDecrypt(e){if(bytes$5(e),e.length%BLOCK_SIZE!==0)throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${BLOCK_SIZE}`)}function validateBlockEncrypt(e,t,n){let r=e.length;const i=r%BLOCK_SIZE;if(!t&&0!==i)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const s=u32$1(e);if(t){let e=BLOCK_SIZE-i;e||(e=BLOCK_SIZE),r+=e}const o=getDst(r,n);return{b:s,o:u32$1(o),out:o}}function validatePCKS(e,t){if(!t)return e;const n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=e[n-1];if(r<=0||r>16)throw new Error(`aes/pcks5: wrong padding byte: ${r}`);const i=e.subarray(0,-r);for(let t=0;t<r;t++)if(e[n-t-1]!==r)throw new Error("aes/pcks5: wrong padding");return i}function padPCKS(e){const t=new Uint8Array(16),n=u32$1(t);t.set(e);const r=BLOCK_SIZE-e.length;for(let e=BLOCK_SIZE-r;e<BLOCK_SIZE;e++)t[e]=r;return n}const cbc=wrapCipher({blockSize:16,nonceLength:16},function(e,t,n={}){bytes$5(e),bytes$5(t,16);const r=!n.disablePadding;return{encrypt:(n,i)=>{const s=expandKeyLE(e),{b:o,o:a,out:c}=validateBlockEncrypt(n,r,i),l=u32$1(t);let h=l[0],d=l[1],u=l[2],f=l[3],p=0;for(;p+4<=o.length;)h^=o[p+0],d^=o[p+1],u^=o[p+2],f^=o[p+3],({s0:h,s1:d,s2:u,s3:f}=encrypt$4(s,h,d,u,f)),a[p++]=h,a[p++]=d,a[p++]=u,a[p++]=f;if(r){const e=padPCKS(n.subarray(4*p));h^=e[0],d^=e[1],u^=e[2],f^=e[3],({s0:h,s1:d,s2:u,s3:f}=encrypt$4(s,h,d,u,f)),a[p++]=h,a[p++]=d,a[p++]=u,a[p++]=f}return s.fill(0),c},decrypt:(n,i)=>{validateBlockDecrypt(n);const s=expandKeyDecLE(e),o=u32$1(t),a=getDst(n.length,i),c=u32$1(n),l=u32$1(a);let h=o[0],d=o[1],u=o[2],f=o[3];for(let e=0;e+4<=c.length;){const t=h,n=d,r=u,i=f;h=c[e+0],d=c[e+1],u=c[e+2],f=c[e+3];const{s0:o,s1:a,s2:p,s3:g}=decrypt$4(s,h,d,u,f);l[e++]=o^t,l[e++]=a^n,l[e++]=p^r,l[e++]=g^i}return s.fill(0),validatePCKS(a,r)}}}),u8to16$1=(e,t)=>255&e[t++]|(255&e[t++])<<8;let Poly1305$1=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,bytes$5(e=toBytes$6(e),32);const t=u8to16$1(e,0),n=u8to16$1(e,2),r=u8to16$1(e,4),i=u8to16$1(e,6),s=u8to16$1(e,8),o=u8to16$1(e,10),a=u8to16$1(e,12),c=u8to16$1(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|n<<3),this.r[2]=7939&(n>>>10|r<<6),this.r[3]=8191&(r>>>7|i<<9),this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,this.r[6]=8191&(s>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=u8to16$1(e,16+2*t)}process(e,t,n=!1){const r=n?0:2048,{h:i,r:s}=this,o=s[0],a=s[1],c=s[2],l=s[3],h=s[4],d=s[5],u=s[6],f=s[7],p=s[8],g=s[9],y=u8to16$1(e,t+0),m=u8to16$1(e,t+2),b=u8to16$1(e,t+4),w=u8to16$1(e,t+6),v=u8to16$1(e,t+8),$=u8to16$1(e,t+10),E=u8to16$1(e,t+12),k=u8to16$1(e,t+14);let x=i[0]+(8191&y),_=i[1]+(8191&(y>>>13|m<<3)),S=i[2]+(8191&(m>>>10|b<<6)),C=i[3]+(8191&(b>>>7|w<<9)),A=i[4]+(8191&(w>>>4|v<<12)),N=i[5]+(v>>>1&8191),R=i[6]+(8191&(v>>>14|$<<2)),T=i[7]+(8191&($>>>11|E<<5)),B=i[8]+(8191&(E>>>8|k<<8)),L=i[9]+(k>>>5|r),I=0,U=I+x*o+_*(5*g)+S*(5*p)+C*(5*f)+A*(5*u);I=U>>>13,U&=8191,U+=N*(5*d)+R*(5*h)+T*(5*l)+B*(5*c)+L*(5*a),I+=U>>>13,U&=8191;let O=I+x*a+_*o+S*(5*g)+C*(5*p)+A*(5*f);I=O>>>13,O&=8191,O+=N*(5*u)+R*(5*d)+T*(5*h)+B*(5*l)+L*(5*c),I+=O>>>13,O&=8191;let P=I+x*c+_*a+S*o+C*(5*g)+A*(5*p);I=P>>>13,P&=8191,P+=N*(5*f)+R*(5*u)+T*(5*d)+B*(5*h)+L*(5*l),I+=P>>>13,P&=8191;let M=I+x*l+_*c+S*a+C*o+A*(5*g);I=M>>>13,M&=8191,M+=N*(5*p)+R*(5*f)+T*(5*u)+B*(5*d)+L*(5*h),I+=M>>>13,M&=8191;let D=I+x*h+_*l+S*c+C*a+A*o;I=D>>>13,D&=8191,D+=N*(5*g)+R*(5*p)+T*(5*f)+B*(5*u)+L*(5*d),I+=D>>>13,D&=8191;let H=I+x*d+_*h+S*l+C*c+A*a;I=H>>>13,H&=8191,H+=N*o+R*(5*g)+T*(5*p)+B*(5*f)+L*(5*u),I+=H>>>13,H&=8191;let F=I+x*u+_*d+S*h+C*l+A*c;I=F>>>13,F&=8191,F+=N*a+R*o+T*(5*g)+B*(5*p)+L*(5*f),I+=F>>>13,F&=8191;let K=I+x*f+_*u+S*d+C*h+A*l;I=K>>>13,K&=8191,K+=N*c+R*a+T*o+B*(5*g)+L*(5*p),I+=K>>>13,K&=8191;let V=I+x*p+_*f+S*u+C*d+A*h;I=V>>>13,V&=8191,V+=N*l+R*c+T*a+B*o+L*(5*g),I+=V>>>13,V&=8191;let j=I+x*g+_*p+S*f+C*u+A*d;I=j>>>13,j&=8191,j+=N*h+R*l+T*c+B*a+L*o,I+=j>>>13,j&=8191,I=(I<<2)+I|0,I=I+U|0,U=8191&I,I>>>=13,O+=I,i[0]=U,i[1]=O,i[2]=P,i[3]=M,i[4]=D,i[5]=H,i[6]=F,i[7]=K,i[8]=V,i[9]=j}finalize(){const{h:e,pad:t}=this,n=new Uint16Array(10);let r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=8191;e[0]+=5*r,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,n[0]=e[0]+5,r=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+r,r=n[t]>>>13,n[t]&=8191;n[9]-=8192;let i=(1^r)-1;for(let e=0;e<10;e++)n[e]&=i;i=~i;for(let t=0;t<10;t++)e[t]=e[t]&i|n[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let s=e[0]+t[0];e[0]=65535&s;for(let n=1;n<8;n++)s=(e[n]+t[n]|0)+(s>>>16)|0,e[n]=65535&s}update(e){exists$5(this);const{buffer:t,blockLen:n}=this,r=(e=toBytes$6(e)).length;for(let i=0;i<r;){const s=Math.min(n-this.pos,r-i);if(s!==n)t.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===n&&(this.process(t,0,!1),this.pos=0);else for(;n<=r-i;i+=n)this.process(e,i)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(e){exists$5(this),output$5(e,this),this.finished=!0;const{buffer:t,h:n}=this;let{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let t=0;t<8;t++)e[i++]=n[t]>>>0,e[i++]=n[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}};function wrapConstructorWithKey$1(e){const t=(t,n)=>e(n).update(toBytes$6(t)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}const poly1305=wrapConstructorWithKey$1(e=>new Poly1305$1(e)),_utf8ToBytes=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),sigma16$1=_utf8ToBytes("expand 16-byte k"),sigma32$1=_utf8ToBytes("expand 32-byte k"),sigma16_32$1=u32$1(sigma16$1),sigma32_32$1=u32$1(sigma32$1);function rotl$3(e,t){return e<<t|e>>>32-t}function isAligned32$1(e){return e.byteOffset%4==0}sigma32_32$1.slice();const BLOCK_LEN=64,BLOCK_LEN32=16,MAX_COUNTER=2**32-1,U32_EMPTY=new Uint32Array;function runCipher(e,t,n,r,i,s,o,a){const c=i.length,l=new Uint8Array(BLOCK_LEN),h=u32$1(l),d=isAligned32$1(i)&&isAligned32$1(s),u=d?u32$1(i):U32_EMPTY,f=d?u32$1(s):U32_EMPTY;for(let p=0;p<c;o++){if(e(t,n,r,h,o,a),o>=MAX_COUNTER)throw new Error("arx: counter overflow");const g=Math.min(BLOCK_LEN,c-p);if(d&&g===BLOCK_LEN){const e=p/4;if(p%4!=0)throw new Error("arx: invalid block position");for(let t,n=0;n<BLOCK_LEN32;n++)t=e+n,f[t]=u[t]^h[n];p+=BLOCK_LEN;continue}for(let e,t=0;t<g;t++)e=p+t,s[e]=i[e]^l[t];p+=g}}function createCipher(e,t){const{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:s,rounds:o}=checkOpts$2({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return number$5(i),number$5(o),bool$4(s),bool$4(n),(t,a,c,l,h=0)=>{bytes$5(t),bytes$5(a),bytes$5(c);const d=c.length;if(l||(l=new Uint8Array(d)),bytes$5(l),number$5(h),h<0||h>=MAX_COUNTER)throw new Error("arx: counter overflow");if(l.length<d)throw new Error(`arx: output (${l.length}) is shorter than data (${d})`);const u=[];let f,p,g=t.length;if(32===g)f=t.slice(),u.push(f),p=sigma32_32$1;else{if(16!==g||!n)throw new Error(`arx: invalid 32-byte key, got length=${g}`);f=new Uint8Array(32),f.set(t),f.set(t,16),p=sigma16_32$1,u.push(f)}isAligned32$1(a)||(a=a.slice(),u.push(a));const y=u32$1(f);if(r){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");r(p,y,u32$1(a.subarray(0,16)),y),a=a.subarray(16)}const m=16-i;if(m!==a.length)throw new Error(`arx: nonce must be ${m} or 16 bytes`);if(12!==m){const e=new Uint8Array(12);e.set(a,s?0:12-a.length),a=e,u.push(a)}const b=u32$1(a);for(runCipher(e,p,y,b,c,l,h,o);u.length>0;)u.pop().fill(0);return l}}function chachaCore$1(e,t,n,r,i,s=20){let o=e[0],a=e[1],c=e[2],l=e[3],h=t[0],d=t[1],u=t[2],f=t[3],p=t[4],g=t[5],y=t[6],m=t[7],b=i,w=n[0],v=n[1],$=n[2],E=o,k=a,x=c,_=l,S=h,C=d,A=u,N=f,R=p,T=g,B=y,L=m,I=b,U=w,O=v,P=$;for(let e=0;e<s;e+=2)E=E+S|0,I=rotl$3(I^E,16),R=R+I|0,S=rotl$3(S^R,12),E=E+S|0,I=rotl$3(I^E,8),R=R+I|0,S=rotl$3(S^R,7),k=k+C|0,U=rotl$3(U^k,16),T=T+U|0,C=rotl$3(C^T,12),k=k+C|0,U=rotl$3(U^k,8),T=T+U|0,C=rotl$3(C^T,7),x=x+A|0,O=rotl$3(O^x,16),B=B+O|0,A=rotl$3(A^B,12),x=x+A|0,O=rotl$3(O^x,8),B=B+O|0,A=rotl$3(A^B,7),_=_+N|0,P=rotl$3(P^_,16),L=L+P|0,N=rotl$3(N^L,12),_=_+N|0,P=rotl$3(P^_,8),L=L+P|0,N=rotl$3(N^L,7),E=E+C|0,P=rotl$3(P^E,16),B=B+P|0,C=rotl$3(C^B,12),E=E+C|0,P=rotl$3(P^E,8),B=B+P|0,C=rotl$3(C^B,7),k=k+A|0,I=rotl$3(I^k,16),L=L+I|0,A=rotl$3(A^L,12),k=k+A|0,I=rotl$3(I^k,8),L=L+I|0,A=rotl$3(A^L,7),x=x+N|0,U=rotl$3(U^x,16),R=R+U|0,N=rotl$3(N^R,12),x=x+N|0,U=rotl$3(U^x,8),R=R+U|0,N=rotl$3(N^R,7),_=_+S|0,O=rotl$3(O^_,16),T=T+O|0,S=rotl$3(S^T,12),_=_+S|0,O=rotl$3(O^_,8),T=T+O|0,S=rotl$3(S^T,7);let M=0;r[M++]=o+E|0,r[M++]=a+k|0,r[M++]=c+x|0,r[M++]=l+_|0,r[M++]=h+S|0,r[M++]=d+C|0,r[M++]=u+A|0,r[M++]=f+N|0,r[M++]=p+R|0,r[M++]=g+T|0,r[M++]=y+B|0,r[M++]=m+L|0,r[M++]=b+I|0,r[M++]=w+U|0,r[M++]=v+O|0,r[M++]=$+P|0}function hchacha(e,t,n,r){let i=e[0],s=e[1],o=e[2],a=e[3],c=t[0],l=t[1],h=t[2],d=t[3],u=t[4],f=t[5],p=t[6],g=t[7],y=n[0],m=n[1],b=n[2],w=n[3];for(let e=0;e<20;e+=2)i=i+c|0,y=rotl$3(y^i,16),u=u+y|0,c=rotl$3(c^u,12),i=i+c|0,y=rotl$3(y^i,8),u=u+y|0,c=rotl$3(c^u,7),s=s+l|0,m=rotl$3(m^s,16),f=f+m|0,l=rotl$3(l^f,12),s=s+l|0,m=rotl$3(m^s,8),f=f+m|0,l=rotl$3(l^f,7),o=o+h|0,b=rotl$3(b^o,16),p=p+b|0,h=rotl$3(h^p,12),o=o+h|0,b=rotl$3(b^o,8),p=p+b|0,h=rotl$3(h^p,7),a=a+d|0,w=rotl$3(w^a,16),g=g+w|0,d=rotl$3(d^g,12),a=a+d|0,w=rotl$3(w^a,8),g=g+w|0,d=rotl$3(d^g,7),i=i+l|0,w=rotl$3(w^i,16),p=p+w|0,l=rotl$3(l^p,12),i=i+l|0,w=rotl$3(w^i,8),p=p+w|0,l=rotl$3(l^p,7),s=s+h|0,y=rotl$3(y^s,16),g=g+y|0,h=rotl$3(h^g,12),s=s+h|0,y=rotl$3(y^s,8),g=g+y|0,h=rotl$3(h^g,7),o=o+d|0,m=rotl$3(m^o,16),u=u+m|0,d=rotl$3(d^u,12),o=o+d|0,m=rotl$3(m^o,8),u=u+m|0,d=rotl$3(d^u,7),a=a+c|0,b=rotl$3(b^a,16),f=f+b|0,c=rotl$3(c^f,12),a=a+c|0,b=rotl$3(b^a,8),f=f+b|0,c=rotl$3(c^f,7);let v=0;r[v++]=i,r[v++]=s,r[v++]=o,r[v++]=a,r[v++]=y,r[v++]=m,r[v++]=b,r[v++]=w}const chacha20$1=createCipher(chachaCore$1,{counterRight:!1,counterLength:4,allowShortKeys:!1}),xchacha20=createCipher(chachaCore$1,{counterRight:!1,counterLength:8,extendNonceFn:hchacha,allowShortKeys:!1}),ZEROS16=new Uint8Array(16),updatePadded=(e,t)=>{e.update(t);const n=t.length%16;n&&e.update(ZEROS16.subarray(n))},ZEROS32=new Uint8Array(32);function computeTag(e,t,n,r,i){const s=e(t,n,ZEROS32),o=poly1305.create(s);i&&updatePadded(o,i),updatePadded(o,r);const a=new Uint8Array(16),c=createView$5(a);setBigUint64$5(c,0,BigInt(i?i.length:0),!0),setBigUint64$5(c,8,BigInt(r.length),!0),o.update(a);const l=o.digest();return s.fill(0),l}const _poly1305_aead=e=>(t,n,r)=>{const i=16;return bytes$5(t,32),bytes$5(n),{encrypt:(s,o)=>{const a=s.length,c=a+i;o?bytes$5(o,c):o=new Uint8Array(c),e(t,n,s,o,1);const l=computeTag(e,t,n,o.subarray(0,-16),r);return o.set(l,a),o},decrypt:(s,o)=>{const a=s.length,c=a-i;if(a<i)throw new Error("encrypted data must be at least 16 bytes");o?bytes$5(o,c):o=new Uint8Array(c);const l=s.subarray(0,-16);if(!equalBytes$3(s.subarray(-16),computeTag(e,t,n,l,r)))throw new Error("invalid tag");return e(t,n,l,o,1),o}}},xchacha20poly1305=wrapCipher({blockSize:64,nonceLength:24,tagLength:16},_poly1305_aead(xchacha20));let HMAC$5=class extends Hash$5{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,assert$4.hash(e);const n=toBytes$7(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return assert$4.exists(this),this.iHash.update(e),this}digestInto(e){assert$4.exists(this),assert$4.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:s,outputLen:o}=this;return e.finished=r,e.destroyed=i,e.blockLen=s,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const hmac$5=(e,t,n)=>new HMAC$5(e,t).update(n).digest();function extract$1(e,t,n){return assert$4.hash(e),hmac$5(e,toBytes$7(n),toBytes$7(t))}hmac$5.create=(e,t)=>new HMAC$5(e,t);const HKDF_COUNTER$1=new Uint8Array([0]),EMPTY_BUFFER$1=new Uint8Array;function expand$1(e,t,n,r=32){if(assert$4.hash(e),assert$4.number(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/e.outputLen);void 0===n&&(n=EMPTY_BUFFER$1);const s=new Uint8Array(i*e.outputLen),o=hmac$5.create(e,t),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let t=0;t<i;t++)HKDF_COUNTER$1[0]=t+1,a.update(0===t?EMPTY_BUFFER$1:c).update(n).update(HKDF_COUNTER$1).digestInto(c),s.set(c,e.outputLen*t),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),HKDF_COUNTER$1.fill(0),s.slice(0,r)}var __defProp$2=Object.defineProperty,__export$1=(e,t)=>{for(var n in t)__defProp$2(e,n,{get:t[n],enumerable:!0})},verifiedSymbol$1=Symbol("verified"),isRecord$1=e=>e instanceof Object;function validateEvent$1(e){if(!isRecord$1(e))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let n=e.tags[t];if(!Array.isArray(n))return!1;for(let e=0;e<n.length;e++)if("string"!=typeof n[e])return!1}return!0}var utils_exports$1={};__export$1(utils_exports$1,{Queue:()=>Queue$1,QueueNode:()=>QueueNode,binarySearch:()=>binarySearch,bytesToHex:()=>bytesToHex$6,hexToBytes:()=>hexToBytes$6,insertEventIntoAscendingList:()=>insertEventIntoAscendingList$1,insertEventIntoDescendingList:()=>insertEventIntoDescendingList$1,normalizeURL:()=>normalizeURL$1,utf8Decoder:()=>utf8Decoder$2,utf8Encoder:()=>utf8Encoder$2});var utf8Decoder$2=new TextDecoder("utf-8"),utf8Encoder$2=new TextEncoder;function normalizeURL$1(e){try{-1===e.indexOf("://")&&(e="wss://"+e);let t=new URL(e);return"http:"===t.protocol?t.protocol="ws:":"https:"===t.protocol&&(t.protocol="wss:"),t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),("80"===t.port&&"ws:"===t.protocol||"443"===t.port&&"wss:"===t.protocol)&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}catch(t){throw new Error(`Invalid URL: ${e}`)}}function insertEventIntoDescendingList$1(e,t){const[n,r]=binarySearch(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return r||e.splice(n,0,t),e}function insertEventIntoAscendingList$1(e,t){const[n,r]=binarySearch(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:t.created_at-e.created_at);return r||e.splice(n,0,t),e}function binarySearch(e,t){let n=0,r=e.length-1;for(;n<=r;){const i=Math.floor((n+r)/2),s=t(e[i]);if(0===s)return[i,!0];s<0?r=i-1:n=i+1}return[n,!1]}var QueueNode=class{value;next=null;prev=null;constructor(e){this.value=e}},Queue$1=class{first;last;constructor(){this.first=null,this.last=null}enqueue(e){const t=new QueueNode(e);return this.last?this.last===this.first?(this.last=t,this.last.prev=this.first,this.first.next=t):(t.prev=this.last,this.last.next=t,this.last=t):(this.first=t,this.last=t),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const e=this.first;return this.first=null,this.last=null,e.value}const e=this.first;return this.first=e.next,this.first&&(this.first.prev=null),e.value}},JS=class{generateSecretKey(){return schnorr$2.utils.randomPrivateKey()}getPublicKey(e){return bytesToHex$6(schnorr$2.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=bytesToHex$6(schnorr$2.getPublicKey(t)),n.id=getEventHash$2(n),n.sig=bytesToHex$6(schnorr$2.sign(getEventHash$2(n),t)),n[verifiedSymbol$1]=!0,n}verifyEvent(e){if("boolean"==typeof e[verifiedSymbol$1])return e[verifiedSymbol$1];const t=getEventHash$2(e);if(t!==e.id)return e[verifiedSymbol$1]=!1,!1;try{const n=schnorr$2.verify(e.sig,t,e.pubkey);return e[verifiedSymbol$1]=n,n}catch(t){return e[verifiedSymbol$1]=!1,!1}}};function serializeEvent$1(e){if(!validateEvent$1(e))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}function getEventHash$2(e){return bytesToHex$6(sha256$6(utf8Encoder$2.encode(serializeEvent$1(e))))}var i=new JS,generateSecretKey=i.generateSecretKey,getPublicKey$1=i.getPublicKey,finalizeEvent=i.finalizeEvent,verifyEvent=i.verifyEvent,kinds_exports={};function isRegularKind(e){return e<1e4&&0!==e&&3!==e}function isReplaceableKind(e){return 0===e||3===e||1e4<=e&&e<2e4}function isEphemeralKind(e){return 2e4<=e&&e<3e4}function isAddressableKind(e){return 3e4<=e&&e<4e4}function classifyKind(e){return isRegularKind(e)?"regular":isReplaceableKind(e)?"replaceable":isEphemeralKind(e)?"ephemeral":isAddressableKind(e)?"parameterized":"unknown"}function isKind(e,t){const n=t instanceof Array?t:[t];return validateEvent$1(e)&&n.includes(e.kind)||!1}__export$1(kinds_exports,{Application:()=>Application,BadgeAward:()=>BadgeAward,BadgeDefinition:()=>BadgeDefinition,BlockedRelaysList:()=>BlockedRelaysList,BlossomServerList:()=>BlossomServerList,BookmarkList:()=>BookmarkList,Bookmarksets:()=>Bookmarksets,Calendar:()=>Calendar,CalendarEventRSVP:()=>CalendarEventRSVP,ChannelCreation:()=>ChannelCreation,ChannelHideMessage:()=>ChannelHideMessage,ChannelMessage:()=>ChannelMessage,ChannelMetadata:()=>ChannelMetadata,ChannelMuteUser:()=>ChannelMuteUser,ChatMessage:()=>ChatMessage,ClassifiedListing:()=>ClassifiedListing,ClientAuth:()=>ClientAuth,Comment:()=>Comment,CommunitiesList:()=>CommunitiesList,CommunityDefinition:()=>CommunityDefinition,CommunityPostApproval:()=>CommunityPostApproval,Contacts:()=>Contacts,CreateOrUpdateProduct:()=>CreateOrUpdateProduct,CreateOrUpdateStall:()=>CreateOrUpdateStall,Curationsets:()=>Curationsets,Date:()=>Date2,DirectMessageRelaysList:()=>DirectMessageRelaysList,DraftClassifiedListing:()=>DraftClassifiedListing,DraftLong:()=>DraftLong,Emojisets:()=>Emojisets,EncryptedDirectMessage:()=>EncryptedDirectMessage,EventDeletion:()=>EventDeletion,FavoriteRelays:()=>FavoriteRelays,FileMessage:()=>FileMessage,FileMetadata:()=>FileMetadata,FileServerPreference:()=>FileServerPreference,Followsets:()=>Followsets,ForumThread:()=>ForumThread,GenericRepost:()=>GenericRepost,Genericlists:()=>Genericlists,GiftWrap:()=>GiftWrap,GroupMetadata:()=>GroupMetadata,HTTPAuth:()=>HTTPAuth,Handlerinformation:()=>Handlerinformation,Handlerrecommendation:()=>Handlerrecommendation,Highlights:()=>Highlights,InterestsList:()=>InterestsList,Interestsets:()=>Interestsets,JobFeedback:()=>JobFeedback,JobRequest:()=>JobRequest,JobResult:()=>JobResult,Label:()=>Label,LightningPubRPC:()=>LightningPubRPC,LiveChatMessage:()=>LiveChatMessage,LiveEvent:()=>LiveEvent,LongFormArticle:()=>LongFormArticle,Metadata:()=>Metadata,Mutelist:()=>Mutelist,NWCWalletInfo:()=>NWCWalletInfo,NWCWalletRequest:()=>NWCWalletRequest,NWCWalletResponse:()=>NWCWalletResponse,NormalVideo:()=>NormalVideo,NostrConnect:()=>NostrConnect,OpenTimestamps:()=>OpenTimestamps,Photo:()=>Photo,Pinlist:()=>Pinlist,Poll:()=>Poll,PollResponse:()=>PollResponse,PrivateDirectMessage:()=>PrivateDirectMessage,ProblemTracker:()=>ProblemTracker,ProfileBadges:()=>ProfileBadges,PublicChatsList:()=>PublicChatsList,Reaction:()=>Reaction,RecommendRelay:()=>RecommendRelay,RelayList:()=>RelayList,RelayReview:()=>RelayReview,Relaysets:()=>Relaysets,Report:()=>Report,Reporting:()=>Reporting,Repost:()=>Repost,Seal:()=>Seal,SearchRelaysList:()=>SearchRelaysList,ShortTextNote:()=>ShortTextNote,ShortVideo:()=>ShortVideo,Time:()=>Time,UserEmojiList:()=>UserEmojiList,UserStatuses:()=>UserStatuses,Voice:()=>Voice,VoiceComment:()=>VoiceComment,Zap:()=>Zap,ZapGoal:()=>ZapGoal,ZapRequest:()=>ZapRequest,classifyKind:()=>classifyKind,isAddressableKind:()=>isAddressableKind,isEphemeralKind:()=>isEphemeralKind,isKind:()=>isKind,isRegularKind:()=>isRegularKind,isReplaceableKind:()=>isReplaceableKind});var Metadata=0,ShortTextNote=1,RecommendRelay=2,Contacts=3,EncryptedDirectMessage=4,EventDeletion=5,Repost=6,Reaction=7,BadgeAward=8,ChatMessage=9,ForumThread=11,Seal=13,PrivateDirectMessage=14,FileMessage=15,GenericRepost=16,Photo=20,NormalVideo=21,ShortVideo=22,ChannelCreation=40,ChannelMetadata=41,ChannelMessage=42,ChannelHideMessage=43,ChannelMuteUser=44,OpenTimestamps=1040,GiftWrap=1059,Poll=1068,FileMetadata=1063,Comment=1111,LiveChatMessage=1311,Voice=1222,VoiceComment=1244,ProblemTracker=1971,Report=1984,Reporting=1984,Label=1985,CommunityPostApproval=4550,JobRequest=5999,JobResult=6999,JobFeedback=7e3,ZapGoal=9041,ZapRequest=9734,Zap=9735,Highlights=9802,PollResponse=1018,Mutelist=1e4,Pinlist=10001,RelayList=10002,BookmarkList=10003,CommunitiesList=10004,PublicChatsList=10005,BlockedRelaysList=10006,SearchRelaysList=10007,FavoriteRelays=10012,InterestsList=10015,UserEmojiList=10030,DirectMessageRelaysList=10050,FileServerPreference=10096,BlossomServerList=10063,NWCWalletInfo=13194,LightningPubRPC=21e3,ClientAuth=22242,NWCWalletRequest=23194,NWCWalletResponse=23195,NostrConnect=24133,HTTPAuth=27235,Followsets=3e4,Genericlists=30001,Relaysets=30002,Bookmarksets=30003,Curationsets=30004,ProfileBadges=30008,BadgeDefinition=30009,Interestsets=30015,CreateOrUpdateStall=30017,CreateOrUpdateProduct=30018,LongFormArticle=30023,DraftLong=30024,Emojisets=30030,Application=30078,LiveEvent=30311,UserStatuses=30315,ClassifiedListing=30402,DraftClassifiedListing=30403,Date2=31922,Time=31923,Calendar=31924,CalendarEventRSVP=31925,RelayReview=31987,Handlerrecommendation=31989,Handlerinformation=31990,CommunityDefinition=34550,GroupMetadata=39e3;function matchFilter(e,t){if(e.ids&&-1===e.ids.indexOf(t.id))return!1;if(e.kinds&&-1===e.kinds.indexOf(t.kind))return!1;if(e.authors&&-1===e.authors.indexOf(t.pubkey))return!1;for(let n in e)if("#"===n[0]){let r=e[`#${n.slice(1)}`];if(r&&!t.tags.find(([e,t])=>e===n.slice(1)&&-1!==r.indexOf(t)))return!1}return!(e.since&&t.created_at<e.since)&&!(e.until&&t.created_at>e.until)}function matchFilters(e,t){for(let n=0;n<e.length;n++)if(matchFilter(e[n],t))return!0;return!1}var fakejson_exports$1={};function getHex64$1(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,i=e.slice(r).indexOf('"')+r+1;return e.slice(i,i+64)}function getInt$1(e,t){let n=t.length,r=e.indexOf(`"${t}":`)+n+3,i=e.slice(r),s=Math.min(i.indexOf(","),i.indexOf("}"));return parseInt(i.slice(0,s),10)}function getSubscriptionId$1(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let r=t+7+1+n,i=e.slice(r+1,80).indexOf('"');if(-1===i)return null;let s=r+1+i;return e.slice(r+1,s)}function matchEventId$1(e,t){return t===getHex64$1(e,"id")}function matchEventPubkey$1(e,t){return t===getHex64$1(e,"pubkey")}function matchEventKind$1(e,t){return t===getInt$1(e,"kind")}__export$1(fakejson_exports$1,{getHex64:()=>getHex64$1,getInt:()=>getInt$1,getSubscriptionId:()=>getSubscriptionId$1,matchEventId:()=>matchEventId$1,matchEventKind:()=>matchEventKind$1,matchEventPubkey:()=>matchEventPubkey$1});var nip42_exports$1={},_WebSocket,_WebSocket2;function makeAuthEvent(e,t){return{kind:ClientAuth,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}__export$1(nip42_exports$1,{makeAuthEvent:()=>makeAuthEvent});try{_WebSocket=WebSocket}catch{}try{_WebSocket2=WebSocket}catch{}var nip19_exports$2={};__export$1(nip19_exports$2,{BECH32_REGEX:()=>BECH32_REGEX$3,Bech32MaxSize:()=>Bech32MaxSize$3,NostrTypeGuard:()=>NostrTypeGuard$1,decode:()=>decode$2,decodeNostrURI:()=>decodeNostrURI$1,encodeBytes:()=>encodeBytes$3,naddrEncode:()=>naddrEncode$2,neventEncode:()=>neventEncode$2,noteEncode:()=>noteEncode$2,nprofileEncode:()=>nprofileEncode$2,npubEncode:()=>npubEncode$2,nsecEncode:()=>nsecEncode$2});var NostrTypeGuard$1={isNProfile:e=>/^nprofile1[a-z\d]+$/.test(e||""),isNEvent:e=>/^nevent1[a-z\d]+$/.test(e||""),isNAddr:e=>/^naddr1[a-z\d]+$/.test(e||""),isNSec:e=>/^nsec1[a-z\d]{58}$/.test(e||""),isNPub:e=>/^npub1[a-z\d]{58}$/.test(e||""),isNote:e=>/^note1[a-z\d]+$/.test(e||""),isNcryptsec:e=>/^ncryptsec1[a-z\d]+$/.test(e||"")},Bech32MaxSize$3=5e3,BECH32_REGEX$3=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function integerToUint8Array$2(e){const t=new Uint8Array(4);return t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t}function decodeNostrURI$1(e){try{return e.startsWith("nostr:")&&(e=e.substring(6)),decode$2(e)}catch(e){return{type:"invalid",data:null}}}function decode$2(e){let{prefix:t,words:n}=bech32$2.decode(e,Bech32MaxSize$3),r=new Uint8Array(bech32$2.fromWords(n));switch(t){case"nprofile":{let e=parseTLV$2(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:bytesToHex$6(e[0][0]),relays:e[1]?e[1].map(e=>utf8Decoder$2.decode(e)):[]}}}case"nevent":{let e=parseTLV$2(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(e[3]&&4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:bytesToHex$6(e[0][0]),relays:e[1]?e[1].map(e=>utf8Decoder$2.decode(e)):[],author:e[2]?.[0]?bytesToHex$6(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(bytesToHex$6(e[3][0]),16):void 0}}}case"naddr":{let e=parseTLV$2(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:utf8Decoder$2.decode(e[0][0]),pubkey:bytesToHex$6(e[2][0]),kind:parseInt(bytesToHex$6(e[3][0]),16),relays:e[1]?e[1].map(e=>utf8Decoder$2.decode(e)):[]}}}case"nsec":return{type:t,data:r};case"npub":case"note":return{type:t,data:bytesToHex$6(r)};default:throw new Error(`unknown prefix ${t}`)}}function parseTLV$2(e){let t={},n=e;for(;n.length>0;){let e=n[0],r=n[1],i=n.slice(2,2+r);if(n=n.slice(2+r),i.length<r)throw new Error(`not enough data to read on TLV ${e}`);t[e]=t[e]||[],t[e].push(i)}return t}function nsecEncode$2(e){return encodeBytes$3("nsec",e)}function npubEncode$2(e){return encodeBytes$3("npub",hexToBytes$6(e))}function noteEncode$2(e){return encodeBytes$3("note",hexToBytes$6(e))}function encodeBech32$3(e,t){let n=bech32$2.toWords(t);return bech32$2.encode(e,n,Bech32MaxSize$3)}function encodeBytes$3(e,t){return encodeBech32$3(e,t)}function nprofileEncode$2(e){return encodeBech32$3("nprofile",encodeTLV$2({0:[hexToBytes$6(e.pubkey)],1:(e.relays||[]).map(e=>utf8Encoder$2.encode(e))}))}function neventEncode$2(e){let t;return void 0!==e.kind&&(t=integerToUint8Array$2(e.kind)),encodeBech32$3("nevent",encodeTLV$2({0:[hexToBytes$6(e.id)],1:(e.relays||[]).map(e=>utf8Encoder$2.encode(e)),2:e.author?[hexToBytes$6(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function naddrEncode$2(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),encodeBech32$3("naddr",encodeTLV$2({0:[utf8Encoder$2.encode(e.identifier)],1:(e.relays||[]).map(e=>utf8Encoder$2.encode(e)),2:[hexToBytes$6(e.pubkey)],3:[new Uint8Array(t)]}))}function encodeTLV$2(e){let t=[];return Object.entries(e).reverse().forEach(([e,n])=>{n.forEach(n=>{let r=new Uint8Array(n.length+2);r.set([parseInt(e)],0),r.set([n.length],1),r.set(n,2),t.push(r)})}),concatBytes$6(...t)}var nip04_exports$1={};function encrypt$3(e,t,n){const r=e instanceof Uint8Array?bytesToHex$6(e):e,i=getNormalizedX$1(secp256k1$3.getSharedSecret(r,"02"+t));let s=Uint8Array.from(randomBytes$4(16)),o=utf8Encoder$2.encode(n),a=cbc(i,s).encrypt(o);return`${base64$1.encode(new Uint8Array(a))}?iv=${base64$1.encode(new Uint8Array(s.buffer))}`}function decrypt$3(e,t,n){const r=e instanceof Uint8Array?bytesToHex$6(e):e;let[i,s]=n.split("?iv="),o=getNormalizedX$1(secp256k1$3.getSharedSecret(r,"02"+t)),a=base64$1.decode(s),c=base64$1.decode(i),l=cbc(o,a).decrypt(c);return utf8Decoder$2.decode(l)}function getNormalizedX$1(e){return e.slice(1,33)}__export$1(nip04_exports$1,{decrypt:()=>decrypt$3,encrypt:()=>encrypt$3});var nip05_exports$1={};__export$1(nip05_exports$1,{NIP05_REGEX:()=>NIP05_REGEX$2,isNip05:()=>isNip05,isValid:()=>isValid,queryProfile:()=>queryProfile$1,searchDomain:()=>searchDomain$1,useFetchImplementation:()=>useFetchImplementation$1});var NIP05_REGEX$2=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,isNip05=e=>NIP05_REGEX$2.test(e||""),_fetch$1;try{_fetch$1=fetch}catch(e){}function useFetchImplementation$1(e){_fetch$1=e}async function searchDomain$1(e,t=""){try{const n=`https://${e}/.well-known/nostr.json?name=${t}`,r=await _fetch$1(n,{redirect:"manual"});if(200!==r.status)throw Error("Wrong response code");return(await r.json()).names}catch(e){return{}}}async function queryProfile$1(e){const t=e.match(NIP05_REGEX$2);if(!t)return null;const[,n="_",r]=t;try{const e=`https://${r}/.well-known/nostr.json?name=${n}`,t=await _fetch$1(e,{redirect:"manual"});if(200!==t.status)throw Error("Wrong response code");const i=await t.json(),s=i.names[n];return s?{pubkey:s,relays:i.relays?.[s]}:null}catch(e){return null}}async function isValid(e,t){const n=await queryProfile$1(t);return!!n&&n.pubkey===e}var nip10_exports$1={};function parse$1(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,r;for(let i=e.tags.length-1;i>=0;i--){const s=e.tags[i];if("e"===s[0]&&s[1]){const[e,i,o,a,c]=s,l={id:i,relays:o?[o]:[],author:c};if("root"===a){t.root=l;continue}if("reply"===a){t.reply=l;continue}if("mention"===a){t.mentions.push(l);continue}n?r=l:n=l,t.mentions.push(l);continue}if("q"===s[0]&&s[1]){const[e,n,r]=s;t.quotes.push({id:n,relays:r?[r]:[]})}"p"===s[0]&&s[1]&&t.profiles.push({pubkey:s[1],relays:s[2]?[s[2]]:[]})}return t.root||(t.root=r||n||t.reply),t.reply||(t.reply=n||t.root),[t.reply,t.root].forEach(e=>{if(!e)return;let n=t.mentions.indexOf(e);if(-1!==n&&t.mentions.splice(n,1),e.author){let n=t.profiles.find(t=>t.pubkey===e.author);n&&n.relays&&(e.relays||(e.relays=[]),n.relays.forEach(t=>{-1===e.relays?.indexOf(t)&&e.relays.push(t)}),n.relays=e.relays)}}),t.mentions.forEach(e=>{if(e.author){let n=t.profiles.find(t=>t.pubkey===e.author);n&&n.relays&&(e.relays||(e.relays=[]),n.relays.forEach(t=>{-1===e.relays.indexOf(t)&&e.relays.push(t)}),n.relays=e.relays)}}),t}__export$1(nip10_exports$1,{parse:()=>parse$1});var nip11_exports={},_fetch2$1;__export$1(nip11_exports,{fetchRelayInformation:()=>fetchRelayInformation$1,useFetchImplementation:()=>useFetchImplementation2$1});try{_fetch2$1=fetch}catch{}function useFetchImplementation2$1(e){_fetch2$1=e}async function fetchRelayInformation$1(e){return await(await fetch(e.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}var nip13_exports$1={};function getPow$1(e){let t=0;for(let n=0;n<64;n+=8){const r=parseInt(e.substring(n,n+8),16);if(0!==r){t+=Math.clz32(r);break}t+=32}return t}function minePow$1(e,t){let n=0;const r=e,i=["nonce",n.toString(),t.toString()];for(r.tags.push(i);;){const e=Math.floor((new Date).getTime()/1e3);if(e!==r.created_at&&(n=0,r.created_at=e),i[1]=(++n).toString(),r.id=fastEventHash(r),getPow$1(r.id)>=t)break}return r}function fastEventHash(e){return bytesToHex$6(sha256$6(utf8Encoder$2.encode(JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content]))))}__export$1(nip13_exports$1,{fastEventHash:()=>fastEventHash,getPow:()=>getPow$1,minePow:()=>minePow$1});var nip17_exports={};__export$1(nip17_exports,{unwrapEvent:()=>unwrapEvent2,unwrapManyEvents:()=>unwrapManyEvents2,wrapEvent:()=>wrapEvent2,wrapManyEvents:()=>wrapManyEvents2});var nip59_exports={};__export$1(nip59_exports,{createRumor:()=>createRumor,createSeal:()=>createSeal,createWrap:()=>createWrap,unwrapEvent:()=>unwrapEvent,unwrapManyEvents:()=>unwrapManyEvents,wrapEvent:()=>wrapEvent$1,wrapManyEvents:()=>wrapManyEvents});var nip44_exports$1={};__export$1(nip44_exports$1,{decrypt:()=>decrypt2$1,encrypt:()=>encrypt2$1,getConversationKey:()=>getConversationKey,v2:()=>v2});var minPlaintextSize=1,maxPlaintextSize=65535;function getConversationKey(e,t){const n=secp256k1$3.getSharedSecret(e,"02"+t).subarray(1,33);return extract$1(sha256$6,n,"nip44-v2")}function getMessageKeys(e,t){const n=expand$1(sha256$6,e,t,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function calcPaddedLen(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("expected positive integer");if(e<=32)return 32;const t=1<<Math.floor(Math.log2(e-1))+1,n=t<=256?32:t/8;return n*(Math.floor((e-1)/n)+1)}function writeU16BE(e){if(!Number.isSafeInteger(e)||e<minPlaintextSize||e>maxPlaintextSize)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e,!1),t}function pad(e){const t=utf8Encoder$2.encode(e),n=t.length;return concatBytes$6(writeU16BE(n),t,new Uint8Array(calcPaddedLen(n)-n))}function unpad(e){const t=new DataView(e.buffer).getUint16(0),n=e.subarray(2,2+t);if(t<minPlaintextSize||t>maxPlaintextSize||n.length!==t||e.length!==2+calcPaddedLen(t))throw new Error("invalid padding");return utf8Decoder$2.decode(n)}function hmacAad(e,t,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const r=concatBytes$6(n,t);return hmac$5(sha256$6,e,r)}function decodePayload(e){if("string"!=typeof e)throw new Error("payload must be a valid string");const t=e.length;if(t<132||t>87472)throw new Error("invalid payload length: "+t);if("#"===e[0])throw new Error("unknown encryption version");let n;try{n=base64$1.decode(e)}catch(e){throw new Error("invalid base64: "+e.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const i=n[0];if(2!==i)throw new Error("unknown encryption version "+i);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}function encrypt2$1(e,t,n=randomBytes$4(32)){const{chacha_key:r,chacha_nonce:i,hmac_key:s}=getMessageKeys(t,n),o=pad(e),a=chacha20$1(r,i,o),c=hmacAad(s,a,n);return base64$1.encode(concatBytes$6(new Uint8Array([2]),n,a,c))}function decrypt2$1(e,t){const{nonce:n,ciphertext:r,mac:i}=decodePayload(e),{chacha_key:s,chacha_nonce:o,hmac_key:a}=getMessageKeys(t,n);if(!equalBytes$3(hmacAad(a,r,n),i))throw new Error("invalid MAC");return unpad(chacha20$1(s,o,r))}var v2={utils:{getConversationKey:getConversationKey,calcPaddedLen:calcPaddedLen},encrypt:encrypt2$1,decrypt:decrypt2$1},TWO_DAYS=172800,now=()=>Math.round(Date.now()/1e3),randomNow=()=>Math.round(now()-Math.random()*TWO_DAYS),nip44ConversationKey=(e,t)=>getConversationKey(e,t),nip44Encrypt=(e,t,n)=>encrypt2$1(JSON.stringify(e),nip44ConversationKey(t,n)),nip44Decrypt=(e,t)=>JSON.parse(decrypt2$1(e.content,nip44ConversationKey(t,e.pubkey)));function createRumor(e,t){const n={created_at:now(),content:"",tags:[],...e,pubkey:getPublicKey$1(t)};return n.id=getEventHash$2(n),n}function createSeal(e,t,n){return finalizeEvent({kind:Seal,content:nip44Encrypt(e,t,n),created_at:randomNow(),tags:[]},t)}function createWrap(e,t){const n=generateSecretKey();return finalizeEvent({kind:GiftWrap,content:nip44Encrypt(e,n,t),created_at:randomNow(),tags:[["p",t]]},n)}function wrapEvent$1(e,t,n){return createWrap(createSeal(createRumor(e,t),t,n),n)}function wrapManyEvents(e,t,n){if(!n||0===n.length)throw new Error("At least one recipient is required.");const r=getPublicKey$1(t),i=[wrapEvent$1(e,t,r)];return n.forEach(n=>{i.push(wrapEvent$1(e,t,n))}),i}function unwrapEvent(e,t){const n=nip44Decrypt(e,t);return nip44Decrypt(n,t)}function unwrapManyEvents(e,t){let n=[];return e.forEach(e=>{n.push(unwrapEvent(e,t))}),n.sort((e,t)=>e.created_at-t.created_at),n}function createEvent(e,t,n,r){const i={created_at:Math.ceil(Date.now()/1e3),kind:PrivateDirectMessage,tags:[],content:t};return(Array.isArray(e)?e:[e]).forEach(({publicKey:e,relayUrl:t})=>{i.tags.push(t?["p",e,t]:["p",e])}),r&&i.tags.push(["e",r.eventId,r.relayUrl||"","reply"]),n&&i.tags.push(["subject",n]),i}function wrapEvent2(e,t,n,r,i){return wrapEvent$1(createEvent(t,n,r,i),e,t.publicKey)}function wrapManyEvents2(e,t,n,r,i){if(!t||0===t.length)throw new Error("At least one recipient is required.");return[{publicKey:getPublicKey$1(e)},...t].map(t=>wrapEvent2(e,t,n,r,i))}var unwrapEvent2=unwrapEvent,unwrapManyEvents2=unwrapManyEvents,nip18_exports$1={};function finishRepostEvent$1(e,t,n,r){let i;const s=[...e.tags??[],["e",t.id,n],["p",t.pubkey]];return t.kind===ShortTextNote?i=Repost:(i=GenericRepost,s.push(["k",String(t.kind)])),finalizeEvent({kind:i,tags:s,content:""===e.content||t.tags?.find(e=>"-"===e[0])?"":JSON.stringify(t),created_at:e.created_at},r)}function getRepostedEventPointer$1(e){if(![Repost,GenericRepost].includes(e.kind))return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const i=e.tags[r];i.length>=2&&("e"===i[0]&&void 0===t?t=i:"p"===i[0]&&void 0===n&&(n=i))}return void 0!==t?{id:t[1],relays:[t[2],n?.[2]].filter(e=>"string"==typeof e),author:n?.[1]}:void 0}function getRepostedEvent$1(e,{skipVerification:t}={}){const n=getRepostedEventPointer$1(e);if(void 0===n||""===e.content)return;let r;try{r=JSON.parse(e.content)}catch(e){return}return r.id===n.id&&(t||verifyEvent(r))?r:void 0}__export$1(nip18_exports$1,{finishRepostEvent:()=>finishRepostEvent$1,getRepostedEvent:()=>getRepostedEvent$1,getRepostedEventPointer:()=>getRepostedEventPointer$1});var nip21_exports$1={};__export$1(nip21_exports$1,{NOSTR_URI_REGEX:()=>NOSTR_URI_REGEX$1,parse:()=>parse2$1,test:()=>test$1});var NOSTR_URI_REGEX$1=new RegExp(`nostr:(${BECH32_REGEX$3.source})`);function test$1(e){return"string"==typeof e&&new RegExp(`^${NOSTR_URI_REGEX$1.source}$`).test(e)}function parse2$1(e){const t=e.match(new RegExp(`^${NOSTR_URI_REGEX$1.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:decode$2(t[1])}}var nip25_exports$1={};function finishReactionEvent$1(e,t,n){const r=t.tags.filter(e=>e.length>=2&&("e"===e[0]||"p"===e[0]));return finalizeEvent({...e,kind:Reaction,tags:[...e.tags??[],...r,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function getReactedEventPointer$1(e){if(e.kind!==Reaction)return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const i=e.tags[r];i.length>=2&&("e"===i[0]&&void 0===t?t=i:"p"===i[0]&&void 0===n&&(n=i))}return void 0!==t&&void 0!==n?{id:t[1],relays:[t[2],n[2]].filter(e=>void 0!==e),author:n[1]}:void 0}__export$1(nip25_exports$1,{finishReactionEvent:()=>finishReactionEvent$1,getReactedEventPointer:()=>getReactedEventPointer$1});var nip27_exports$1={};__export$1(nip27_exports$1,{parse:()=>parse3});var noCharacter=/\W/m,noURLCharacter=/\W |\W$|$|,| /m,MAX_HASHTAG_LENGTH=42;function*parse3(e){let t=[];if("string"!=typeof e){for(let n=0;n<e.tags.length;n++){const r=e.tags[n];"emoji"===r[0]&&r.length>=3&&t.push({type:"emoji",shortcode:r[1],url:r[2]})}e=e.content}const n=e.length;let r=0,i=0;e:for(;i<n;){const s=e.indexOf(":",i),o=e.indexOf("#",i);if(-1===s&&-1===o)break e;if(-1===s||o>=0&&o<s){if(0===o||" "===e[o-1]){const t=e.slice(o+1,o+MAX_HASHTAG_LENGTH).match(noCharacter),s=t?o+1+t.index:n;yield{type:"text",text:e.slice(r,o)},yield{type:"hashtag",value:e.slice(o+1,s)},i=s,r=i;continue e}i=o+1}else if("nostr"===e.slice(s-5,s)){const t=e.slice(s+60).match(noCharacter),o=t?s+60+t.index:n;try{let t,{data:n,type:a}=decode$2(e.slice(s+1,o));switch(a){case"npub":t={pubkey:n};break;case"nsec":case"note":i=o+1;continue;default:t=n}r!==s-5&&(yield{type:"text",text:e.slice(r,s-5)}),yield{type:"reference",pointer:t},i=o,r=i;continue e}catch(e){i=s+1;continue e}}else if("https"===e.slice(s-5,s)||"http"===e.slice(s-4,s)){const t=e.slice(s+4).match(noURLCharacter),o=t?s+4+t.index:n,a="s"===e[s-1]?5:4;try{let t=new URL(e.slice(s-a,o));if(-1===t.hostname.indexOf("."))throw new Error("invalid url");if(r!==s-a&&(yield{type:"text",text:e.slice(r,s-a)}),/\.(png|jpe?g|gif|webp|heic|svg)$/i.test(t.pathname)){yield{type:"image",url:t.toString()},i=o,r=i;continue e}if(/\.(mp4|avi|webm|mkv|mov)$/i.test(t.pathname)){yield{type:"video",url:t.toString()},i=o,r=i;continue e}if(/\.(mp3|aac|ogg|opus|wav|flac)$/i.test(t.pathname)){yield{type:"audio",url:t.toString()},i=o,r=i;continue e}yield{type:"url",url:t.toString()},i=o,r=i;continue e}catch(e){i=o+1;continue e}}else{if("wss"!==e.slice(s-3,s)&&"ws"!==e.slice(s-2,s)){for(let n=0;n<t.length;n++){const o=t[n];if(":"===e[s+o.shortcode.length+1]&&e.slice(s+1,s+o.shortcode.length+1)===o.shortcode){r!==s&&(yield{type:"text",text:e.slice(r,s)}),yield o,i=s+o.shortcode.length+2,r=i;continue e}}i=s+1;continue e}{const t=e.slice(s+4).match(noURLCharacter),o=t?s+4+t.index:n,a="s"===e[s-1]?3:2;try{let t=new URL(e.slice(s-a,o));if(-1===t.hostname.indexOf("."))throw new Error("invalid ws url");r!==s-a&&(yield{type:"text",text:e.slice(r,s-a)}),yield{type:"relay",url:t.toString()},i=o,r=i;continue e}catch(e){i=o+1;continue e}}}}r!==n&&(yield{type:"text",text:e.slice(r)})}var nip28_exports$1={};__export$1(nip28_exports$1,{channelCreateEvent:()=>channelCreateEvent$1,channelHideMessageEvent:()=>channelHideMessageEvent$1,channelMessageEvent:()=>channelMessageEvent$1,channelMetadataEvent:()=>channelMetadataEvent$1,channelMuteUserEvent:()=>channelMuteUserEvent$1});var channelCreateEvent$1=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return finalizeEvent({kind:ChannelCreation,tags:[...e.tags??[]],content:n,created_at:e.created_at},t)},channelMetadataEvent$1=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return finalizeEvent({kind:ChannelMetadata,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},channelMessageEvent$1=(e,t)=>{const n=[["e",e.channel_create_event_id,e.relay_url,"root"]];return e.reply_to_channel_message_event_id&&n.push(["e",e.reply_to_channel_message_event_id,e.relay_url,"reply"]),finalizeEvent({kind:ChannelMessage,tags:[...n,...e.tags??[]],content:e.content,created_at:e.created_at},t)},channelHideMessageEvent$1=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return finalizeEvent({kind:ChannelHideMessage,tags:[["e",e.channel_message_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},channelMuteUserEvent$1=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return finalizeEvent({kind:ChannelMuteUser,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)},nip30_exports={};__export$1(nip30_exports,{EMOJI_SHORTCODE_REGEX:()=>EMOJI_SHORTCODE_REGEX,matchAll:()=>matchAll$1,regex:()=>regex$1,replaceAll:()=>replaceAll$1});var EMOJI_SHORTCODE_REGEX=/:(\w+):/,regex$1=()=>new RegExp(`\\B${EMOJI_SHORTCODE_REGEX.source}\\B`,"g");function*matchAll$1(e){const t=e.matchAll(regex$1());for(const e of t)try{const[t,n]=e;yield{shortcode:t,name:n,start:e.index,end:e.index+t.length}}catch(e){}}function replaceAll$1(e,t){return e.replaceAll(regex$1(),(e,n)=>t({shortcode:e,name:n}))}var nip39_exports$1={},_fetch3$1;__export$1(nip39_exports$1,{useFetchImplementation:()=>useFetchImplementation3$1,validateGithub:()=>validateGithub$1});try{_fetch3$1=fetch}catch{}function useFetchImplementation3$1(e){_fetch3$1=e}async function validateGithub$1(e,t,n){try{return await(await _fetch3$1(`https://gist.github.com/${t}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch(e){return!1}}var nip47_exports$1={};function parseConnectionString$1(e){const{host:t,pathname:n,searchParams:r}=new URL(e),i=n||t,s=r.get("relay"),o=r.get("secret");if(!i||!s||!o)throw new Error("invalid connection string");return{pubkey:i,relay:s,secret:o}}async function makeNwcRequestEvent$1(e,t,n){const r={method:"pay_invoice",params:{invoice:n}},i=encrypt$3(t,e,JSON.stringify(r)),s={kind:NWCWalletRequest,created_at:Math.round(Date.now()/1e3),content:i,tags:[["p",e]]};return finalizeEvent(s,t)}__export$1(nip47_exports$1,{makeNwcRequestEvent:()=>makeNwcRequestEvent$1,parseConnectionString:()=>parseConnectionString$1});var nip54_exports={};function normalizeIdentifier(e){return e=(e=e.trim().toLowerCase()).normalize("NFKC"),Array.from(e).map(e=>/\p{Letter}/u.test(e)||/\p{Number}/u.test(e)?e:"-").join("")}__export$1(nip54_exports,{normalizeIdentifier:()=>normalizeIdentifier});var nip57_exports$1={},_fetch4;__export$1(nip57_exports$1,{getSatoshisAmountFromBolt11:()=>getSatoshisAmountFromBolt11,getZapEndpoint:()=>getZapEndpoint$1,makeZapReceipt:()=>makeZapReceipt$1,makeZapRequest:()=>makeZapRequest$1,useFetchImplementation:()=>useFetchImplementation4,validateZapRequest:()=>validateZapRequest$1});try{_fetch4=fetch}catch{}function useFetchImplementation4(e){_fetch4=e}async function getZapEndpoint$1(e){try{let t="",{lud06:n,lud16:r}=JSON.parse(e.content);if(r){let[e,n]=r.split("@");t=new URL(`/.well-known/lnurlp/${e}`,`https://${n}`).toString()}else{if(!n)return null;{let{words:e}=bech32$2.decode(n,1e3),r=bech32$2.fromWords(e);t=utf8Decoder$2.decode(r)}}let i=await _fetch4(t),s=await i.json();if(s.allowsNostr&&s.nostrPubkey)return s.callback}catch(e){}return null}function makeZapRequest$1(e){let t={kind:9734,created_at:Math.round(Date.now()/1e3),content:e.comment||"",tags:[["p","pubkey"in e?e.pubkey:e.event.pubkey],["amount",e.amount.toString()],["relays",...e.relays]]};if("event"in e){if(t.tags.push(["e",e.event.id]),isReplaceableKind(e.event.kind)){const n=["a",`${e.event.kind}:${e.event.pubkey}:`];t.tags.push(n)}else if(isAddressableKind(e.event.kind)){let n=e.event.tags.find(([e,t])=>"d"===e&&t);if(!n)throw new Error("d tag not found or is empty");const r=["a",`${e.event.kind}:${e.event.pubkey}:${n[1]}`];t.tags.push(r)}t.tags.push(["k",e.event.kind.toString()])}return t}function validateZapRequest$1(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!validateEvent$1(t))return"Zap request is not a valid Nostr event.";if(!verifyEvent(t))return"Invalid signature on zap request.";let n=t.tags.find(([e,t])=>"p"===e&&t);if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let r=t.tags.find(([e,t])=>"e"===e&&t);return r&&!r[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":t.tags.find(([e,t])=>"relays"===e&&t)?null:"Zap request doesn't have a 'relays' tag."}function makeZapReceipt$1({zapRequest:e,preimage:t,bolt11:n,paidAt:r}){let i=JSON.parse(e),s=i.tags.filter(([e])=>"e"===e||"p"===e||"a"===e),o={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...s,["P",i.pubkey],["bolt11",n],["description",e]]};return t&&o.tags.push(["preimage",t]),o}function getSatoshisAmountFromBolt11(e){if(e.length<50)return 0;const t=(e=e.substring(0,50)).lastIndexOf("1");if(-1===t)return 0;const n=e.substring(0,t);if(!n.startsWith("lnbc"))return 0;const r=n.substring(4);if(r.length<1)return 0;const i=r[r.length-1],s=i.charCodeAt(0)-"0".charCodeAt(0),o=s>=0&&s<=9;let a=r.length-1;if(o&&a++,a<1)return 0;const c=parseInt(r.substring(0,a));switch(i){case"m":return 1e5*c;case"u":return 100*c;case"n":return c/10;case"p":return c/1e4;default:return 1e8*c}}var nip77_exports={};__export$1(nip77_exports,{Negentropy:()=>Negentropy,NegentropyStorageVector:()=>NegentropyStorageVector,NegentropySync:()=>NegentropySync});var PROTOCOL_VERSION=97,ID_SIZE=32,FINGERPRINT_SIZE=16,Mode={Skip:0,Fingerprint:1,IdList:2},WrappedBuffer=class{_raw;length;constructor(e){"number"==typeof e?(this._raw=new Uint8Array(e),this.length=0):e instanceof Uint8Array?(this._raw=new Uint8Array(e),this.length=e.length):(this._raw=new Uint8Array(512),this.length=0)}unwrap(){return this._raw.subarray(0,this.length)}get capacity(){return this._raw.byteLength}extend(e){if(e instanceof WrappedBuffer&&(e=e.unwrap()),"number"!=typeof e.length)throw Error("bad length");const t=e.length+this.length;if(this.capacity<t){const e=this._raw,n=Math.max(2*this.capacity,t);this._raw=new Uint8Array(n),this._raw.set(e)}this._raw.set(e,this.length),this.length+=e.length}shift(){const e=this._raw[0];return this._raw=this._raw.subarray(1),this.length--,e}shiftN(e=1){const t=this._raw.subarray(0,e);return this._raw=this._raw.subarray(e),this.length-=e,t}};function decodeVarInt(e){let t=0;for(;;){if(0===e.length)throw Error("parse ends prematurely");let n=e.shift();if(t=t<<7|127&n,!(128&n))break}return t}function encodeVarInt(e){if(0===e)return new WrappedBuffer(new Uint8Array([0]));let t=[];for(;0!==e;)t.push(127&e),e>>>=7;t.reverse();for(let e=0;e<t.length-1;e++)t[e]|=128;return new WrappedBuffer(new Uint8Array(t))}function getByte(e){return getBytes(e,1)[0]}function getBytes(e,t){if(e.length<t)throw Error("parse ends prematurely");return e.shiftN(t)}var Accumulator=class{buf;constructor(){this.setToZero()}setToZero(){this.buf=new Uint8Array(ID_SIZE)}add(e){let t=0,n=0,r=new DataView(this.buf.buffer),i=new DataView(e.buffer);for(let e=0;e<8;e++){let s=4*e,o=r.getUint32(s,!0);o+=t,o+=i.getUint32(s,!0),o>4294967295&&(n=1),r.setUint32(s,4294967295&o,!0),t=n,n=0}}negate(){let e=new DataView(this.buf.buffer);for(let t=0;t<8;t++){let n=4*t;e.setUint32(n,~e.getUint32(n,!0))}let t=new Uint8Array(ID_SIZE);t[0]=1,this.add(t)}getFingerprint(e){let t=new WrappedBuffer;return t.extend(this.buf),t.extend(encodeVarInt(e)),sha256$6(t.unwrap()).subarray(0,FINGERPRINT_SIZE)}},NegentropyStorageVector=class{items;sealed;constructor(){this.items=[],this.sealed=!1}insert(e,t){if(this.sealed)throw Error("already sealed");const n=hexToBytes$5(t);if(n.byteLength!==ID_SIZE)throw Error("bad id size for added item");this.items.push({timestamp:e,id:n})}seal(){if(this.sealed)throw Error("already sealed");this.sealed=!0,this.items.sort(itemCompare);for(let e=1;e<this.items.length;e++)if(0===itemCompare(this.items[e-1],this.items[e]))throw Error("duplicate item inserted")}unseal(){this.sealed=!1}size(){return this._checkSealed(),this.items.length}getItem(e){if(this._checkSealed(),e>=this.items.length)throw Error("out of range");return this.items[e]}iterate(e,t,n){this._checkSealed(),this._checkBounds(e,t);for(let r=e;r<t&&n(this.items[r],r);++r);}findLowerBound(e,t,n){return this._checkSealed(),this._checkBounds(e,t),this._binarySearch(this.items,e,t,e=>itemCompare(e,n)<0)}fingerprint(e,t){let n=new Accumulator;return n.setToZero(),this.iterate(e,t,e=>(n.add(e.id),!0)),n.getFingerprint(t-e)}_checkSealed(){if(!this.sealed)throw Error("not sealed")}_checkBounds(e,t){if(e>t||t>this.items.length)throw Error("bad range")}_binarySearch(e,t,n,r){let i=n-t;for(;i>0;){let n=t,s=Math.floor(i/2);n+=s,r(e[n])?(t=++n,i-=s+1):i=s}return t}},Negentropy=class{storage;frameSizeLimit;lastTimestampIn;lastTimestampOut;constructor(e,t=6e4){if(t<4096)throw Error("frameSizeLimit too small");this.storage=e,this.frameSizeLimit=t,this.lastTimestampIn=0,this.lastTimestampOut=0}_bound(e,t){return{timestamp:e,id:t||new Uint8Array(0)}}initiate(){let e=new WrappedBuffer;return e.extend(new Uint8Array([PROTOCOL_VERSION])),this.splitRange(0,this.storage.size(),this._bound(Number.MAX_VALUE),e),bytesToHex$5(e.unwrap())}reconcile(e,t,n){const r=new WrappedBuffer(hexToBytes$5(e));this.lastTimestampIn=this.lastTimestampOut=0;let i=new WrappedBuffer;i.extend(new Uint8Array([PROTOCOL_VERSION]));let s=getByte(r);if(s<96||s>111)throw Error("invalid negentropy protocol version byte");if(s!==PROTOCOL_VERSION)throw Error("unsupported negentropy protocol version requested: "+(s-96));let o=this.storage.size(),a=this._bound(0),c=0,l=!1;for(;0!==r.length;){let e=new WrappedBuffer,s=()=>{l&&(l=!1,e.extend(this.encodeBound(a)),e.extend(encodeVarInt(Mode.Skip)))},h=this.decodeBound(r),d=decodeVarInt(r),u=c,f=this.storage.findLowerBound(c,o,h);if(d===Mode.Skip)l=!0;else if(d===Mode.Fingerprint){0!==compareUint8Array(getBytes(r,FINGERPRINT_SIZE),this.storage.fingerprint(u,f))?(s(),this.splitRange(u,f,h,e)):l=!0}else{if(d!==Mode.IdList)throw Error("unexpected mode");{let e=decodeVarInt(r),i={};for(let t=0;t<e;t++){let e=getBytes(r,ID_SIZE);i[bytesToHex$5(e)]=e}if(l=!0,this.storage.iterate(u,f,e=>{let n=e.id;const r=bytesToHex$5(n);return i[r]?delete i[bytesToHex$5(n)]:t?.(r),!0}),n)for(let e of Object.values(i))n(bytesToHex$5(e))}}if(this.exceededFrameSizeLimit(i.length+e.length)){let e=this.storage.fingerprint(f,o);i.extend(this.encodeBound(this._bound(Number.MAX_VALUE))),i.extend(encodeVarInt(Mode.Fingerprint)),i.extend(e);break}i.extend(e),c=f,a=h}return 1===i.length?null:bytesToHex$5(i.unwrap())}splitRange(e,t,n,r){let i=t-e;if(i<32)r.extend(this.encodeBound(n)),r.extend(encodeVarInt(Mode.IdList)),r.extend(encodeVarInt(i)),this.storage.iterate(e,t,e=>(r.extend(e.id),!0));else{let s=Math.floor(i/16),o=i%16,a=e;for(let e=0;e<16;e++){let i,c=s+(e<o?1:0),l=this.storage.fingerprint(a,a+c);if(a+=c,a===t)i=n;else{let e,t;this.storage.iterate(a-1,a+1,(n,r)=>(r===a-1?e=n:t=n,!0)),i=this.getMinimalBound(e,t)}r.extend(this.encodeBound(i)),r.extend(encodeVarInt(Mode.Fingerprint)),r.extend(l)}}}exceededFrameSizeLimit(e){return e>this.frameSizeLimit-200}decodeTimestampIn(e){let t=decodeVarInt(e);return t=0===t?Number.MAX_VALUE:t-1,this.lastTimestampIn===Number.MAX_VALUE||t===Number.MAX_VALUE?(this.lastTimestampIn=Number.MAX_VALUE,Number.MAX_VALUE):(t+=this.lastTimestampIn,this.lastTimestampIn=t,t)}decodeBound(e){let t=this.decodeTimestampIn(e),n=decodeVarInt(e);if(n>ID_SIZE)throw Error("bound key too long");return{timestamp:t,id:getBytes(e,n)}}encodeTimestampOut(e){if(e===Number.MAX_VALUE)return this.lastTimestampOut=Number.MAX_VALUE,encodeVarInt(0);let t=e;return e-=this.lastTimestampOut,this.lastTimestampOut=t,encodeVarInt(e+1)}encodeBound(e){let t=new WrappedBuffer;return t.extend(this.encodeTimestampOut(e.timestamp)),t.extend(encodeVarInt(e.id.length)),t.extend(e.id),t}getMinimalBound(e,t){if(t.timestamp!==e.timestamp)return this._bound(t.timestamp);{let n=0,r=t.id,i=e.id;for(let e=0;e<ID_SIZE&&r[e]===i[e];e++)n++;return this._bound(t.timestamp,t.id.subarray(0,n+1))}}};function compareUint8Array(e,t){for(let n=0;n<e.byteLength;n++){if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return e.byteLength>t.byteLength?1:e.byteLength<t.byteLength?-1:0}function itemCompare(e,t){return e.timestamp===t.timestamp?compareUint8Array(e.id,t.id):e.timestamp-t.timestamp}var NegentropySync=class{relay;storage;neg;filter;subscription;onhave;onneed;constructor(e,t,n,r={}){this.relay=e,this.storage=t,this.neg=new Negentropy(t),this.onhave=r.onhave,this.onneed=r.onneed,this.filter=n,this.subscription=this.relay.prepareSubscription([{}],{label:r.label||"negentropy"}),this.subscription.oncustom=e=>{switch(e[0]){case"NEG-MSG":e.length<3&&console.warn(`got invalid NEG-MSG from ${this.relay.url}: ${e}`);try{const t=this.neg.reconcile(e[2],this.onhave,this.onneed);t?this.relay.send(`["NEG-MSG", "${this.subscription.id}", "${t}"]`):(this.close(),r.onclose?.())}catch(e){console.error("negentropy reconcile error:",e),r?.onclose?.(`reconcile error: ${e}`)}break;case"NEG-CLOSE":{const t=e[2];console.warn("negentropy error:",t),r.onclose?.(t);break}case"NEG-ERR":r.onclose?.()}}}async start(){const e=this.neg.initiate();this.relay.send(`["NEG-OPEN","${this.subscription.id}",${JSON.stringify(this.filter)},"${e}"]`)}close(){this.relay.send(`["NEG-CLOSE","${this.subscription.id}"]`),this.subscription.close()}},nip98_exports$1={};__export$1(nip98_exports$1,{getToken:()=>getToken$1,hashPayload:()=>hashPayload,unpackEventFromToken:()=>unpackEventFromToken$1,validateEvent:()=>validateEvent2$1,validateEventKind:()=>validateEventKind,validateEventMethodTag:()=>validateEventMethodTag,validateEventPayloadTag:()=>validateEventPayloadTag,validateEventTimestamp:()=>validateEventTimestamp,validateEventUrlTag:()=>validateEventUrlTag,validateToken:()=>validateToken$1});var _authorizationScheme$1="Nostr ";async function getToken$1(e,t,n,r=!1,i){const s={kind:HTTPAuth,tags:[["u",e],["method",t]],created_at:Math.round((new Date).getTime()/1e3),content:""};i&&s.tags.push(["payload",hashPayload(i)]);const o=await n(s);return(r?_authorizationScheme$1:"")+base64$1.encode(utf8Encoder$2.encode(JSON.stringify(o)))}async function validateToken$1(e,t,n){const r=await unpackEventFromToken$1(e).catch(e=>{throw e});return await validateEvent2$1(r,t,n).catch(e=>{throw e})}async function unpackEventFromToken$1(e){if(!e)throw new Error("Missing token");e=e.replace(_authorizationScheme$1,"");const t=utf8Decoder$2.decode(base64$1.decode(e));if(!t||0===t.length||!t.startsWith("{"))throw new Error("Invalid token");return JSON.parse(t)}function validateEventTimestamp(e){return!!e.created_at&&Math.round((new Date).getTime()/1e3)-e.created_at<60}function validateEventKind(e){return e.kind===HTTPAuth}function validateEventUrlTag(e,t){const n=e.tags.find(e=>"u"===e[0]);return!!n&&(n.length>0&&n[1]===t)}function validateEventMethodTag(e,t){const n=e.tags.find(e=>"method"===e[0]);return!!n&&(n.length>0&&n[1].toLowerCase()===t.toLowerCase())}function hashPayload(e){return bytesToHex$6(sha256$6(utf8Encoder$2.encode(JSON.stringify(e))))}function validateEventPayloadTag(e,t){const n=e.tags.find(e=>"payload"===e[0]);if(!n)return!1;const r=hashPayload(t);return n.length>0&&n[1]===r}async function validateEvent2$1(e,t,n,r){if(!verifyEvent(e))throw new Error("Invalid nostr event, signature invalid");if(!validateEventKind(e))throw new Error("Invalid nostr event, kind invalid");if(!validateEventTimestamp(e))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!validateEventUrlTag(e,t))throw new Error("Invalid nostr event, url tag invalid");if(!validateEventMethodTag(e,n))throw new Error("Invalid nostr event, method tag invalid");if(Boolean(r)&&"object"==typeof r&&Object.keys(r).length>0&&!validateEventPayloadTag(e,r))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}const crypto$4="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;
13
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function isBytes$6(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function anumber(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function abytes(e,...t){if(!isBytes$6(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ahash(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");anumber(e.outputLen),anumber(e.blockLen)}function aexists(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function aoutput(e,t){abytes(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function clean(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function createView$4(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function rotr$4(e,t){return e<<32-t|e>>>t}const hasHexBuiltin=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),hexes$4=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function bytesToHex$4(e){if(abytes(e),hasHexBuiltin)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=hexes$4[e[n]];return t}const asciis$1={_0:48,_9:57,A:65,F:70,a:97,f:102};function asciiToBase16$1(e){return e>=asciis$1._0&&e<=asciis$1._9?e-asciis$1._0:e>=asciis$1.A&&e<=asciis$1.F?e-(asciis$1.A-10):e>=asciis$1.a&&e<=asciis$1.f?e-(asciis$1.a-10):void 0}function hexToBytes$4(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(hasHexBuiltin)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){const n=asciiToBase16$1(e.charCodeAt(i)),s=asciiToBase16$1(e.charCodeAt(i+1));if(void 0===n||void 0===s){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+s}return r}function utf8ToBytes$7(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function toBytes$5(e){return"string"==typeof e&&(e=utf8ToBytes$7(e)),abytes(e),e}function concatBytes$5(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];abytes(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const i=e[t];n.set(i,r),r+=i.length}return n}let Hash$4=class{};function createHasher(e){const t=t=>e().update(toBytes$5(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function randomBytes$3(e=32){if(crypto$4&&"function"==typeof crypto$4.getRandomValues)return crypto$4.getRandomValues(new Uint8Array(e));if(crypto$4&&"function"==typeof crypto$4.randomBytes)return Uint8Array.from(crypto$4.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function setBigUint64$4(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,a,r)}function Chi$4(e,t,n){return e&t^~e&n}function Maj$4(e,t,n){return e&t^e&n^t&n}class HashMD extends Hash$4{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=createView$4(this.buffer)}update(e){aexists(this),abytes(e=toBytes$5(e));const{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);if(o===r){const t=createView$4(e);for(;r<=i-s;s+=r)this.process(t,s);continue}n.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){aexists(this),aoutput(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:s}=this;t[s++]=128,clean(this.buffer.subarray(s)),this.padOffset>r-s&&(this.process(n,0),s=0);for(let e=s;e<r;e++)t[e]=0;setBigUint64$4(n,r-8,BigInt(8*this.length),i),this.process(n,0);const o=createView$4(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:i,destroyed:s,pos:o}=this;return e.destroyed=s,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const SHA256_IV=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_K$4=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]),SHA256_W$4=new Uint32Array(64);let SHA256$4=class extends HashMD{constructor(e=32){super(64,e,8,!1),this.A=0|SHA256_IV[0],this.B=0|SHA256_IV[1],this.C=0|SHA256_IV[2],this.D=0|SHA256_IV[3],this.E=0|SHA256_IV[4],this.F=0|SHA256_IV[5],this.G=0|SHA256_IV[6],this.H=0|SHA256_IV[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:s,G:o,H:a}=this;return[e,t,n,r,i,s,o,a]}set(e,t,n,r,i,s,o,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)SHA256_W$4[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=SHA256_W$4[e-15],n=SHA256_W$4[e-2],r=rotr$4(t,7)^rotr$4(t,18)^t>>>3,i=rotr$4(n,17)^rotr$4(n,19)^n>>>10;SHA256_W$4[e]=i+SHA256_W$4[e-7]+r+SHA256_W$4[e-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(rotr$4(o,6)^rotr$4(o,11)^rotr$4(o,25))+Chi$4(o,a,c)+SHA256_K$4[e]+SHA256_W$4[e]|0,h=(rotr$4(n,2)^rotr$4(n,13)^rotr$4(n,22))+Maj$4(n,r,i)|0;l=c,c=a,a=o,o=s+t|0,s=i,i=r,r=n,n=t+h|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,s,o,a,c,l)}roundClean(){clean(SHA256_W$4)}destroy(){this.set(0,0,0,0,0,0,0,0),clean(this.buffer)}};const sha256$5=createHasher(()=>new SHA256$4);let HMAC$4=class extends Hash$4{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ahash(e);const n=toBytes$5(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),clean(i)}update(e){return aexists(this),this.iHash.update(e),this}digestInto(e){aexists(this),abytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:s,outputLen:o}=this;return e.finished=r,e.destroyed=i,e.blockLen=s,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const hmac$4=(e,t,n)=>new HMAC$4(e,t).update(n).digest();hmac$4.create=(e,t)=>new HMAC$4(e,t);
3
+ const _0n$4=BigInt(0),_1n$4=BigInt(1),_2n$2=BigInt(2),u8a$2=e=>e instanceof Uint8Array,hexes$2=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function bytesToHex$2(e){if(!u8a$2(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=hexes$2[e[n]];return t}function numberToHexUnpadded(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function hexToNumber(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function hexToBytes$2(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const r=2*t,o=e.slice(r,r+2),s=Number.parseInt(o,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[t]=s}return n}function bytesToNumberBE(e){return hexToNumber(bytesToHex$2(e))}function bytesToNumberLE(e){if(!u8a$2(e))throw new Error("Uint8Array expected");return hexToNumber(bytesToHex$2(Uint8Array.from(e).reverse()))}function numberToBytesBE(e,t){return hexToBytes$2(e.toString(16).padStart(2*t,"0"))}function numberToBytesLE(e,t){return numberToBytesBE(e,t).reverse()}function numberToVarBytesBE(e){return hexToBytes$2(numberToHexUnpadded(e))}function ensureBytes$1(e,t,n){let r;if("string"==typeof t)try{r=hexToBytes$2(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!u8a$2(t))throw new Error(`${e} must be hex string or Uint8Array`);r=Uint8Array.from(t)}const o=r.length;if("number"==typeof n&&o!==n)throw new Error(`${e} expected ${n} bytes, got ${o}`);return r}function concatBytes$2(...e){const t=new Uint8Array(e.reduce(((e,t)=>e+t.length),0));let n=0;return e.forEach((e=>{if(!u8a$2(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length})),t}function equalBytes$1(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function utf8ToBytes$3(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function bitLen(e){let t;for(t=0;e>_0n$4;e>>=_1n$4,t+=1);return t}function bitGet(e,t){return e>>BigInt(t)&_1n$4}const bitSet=(e,t,n)=>e|(n?_1n$4:_0n$4)<<BigInt(t),bitMask=e=>(_2n$2<<BigInt(e-1))-_1n$4,u8n=e=>new Uint8Array(e),u8fr=e=>Uint8Array.from(e);function createHmacDrbg(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=u8n(e),o=u8n(e),s=0;const i=()=>{r.fill(1),o.fill(0),s=0},a=(...e)=>n(o,r,...e),l=(e=u8n())=>{o=a(u8fr([0]),e),r=a(),0!==e.length&&(o=a(u8fr([1]),e),r=a())},c=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=a();const t=r.slice();n.push(t),e+=r.length}return concatBytes$2(...n)};return(e,t)=>{let n;for(i(),l(e);!(n=t(c()));)l();return i(),n}}const validatorFns={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function validateObject(e,t,n={}){const r=(t,n,r)=>{const o=validatorFns[n];if("function"!=typeof o)throw new Error(`Invalid validator "${n}", expected function`);const s=e[t];if(!(r&&void 0===s||o(s,e)))throw new Error(`Invalid param ${String(t)}=${s} (${typeof s}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}var ut=Object.freeze({__proto__:null,bitGet:bitGet,bitLen:bitLen,bitMask:bitMask,bitSet:bitSet,bytesToHex:bytesToHex$2,bytesToNumberBE:bytesToNumberBE,bytesToNumberLE:bytesToNumberLE,concatBytes:concatBytes$2,createHmacDrbg:createHmacDrbg,ensureBytes:ensureBytes$1,equalBytes:equalBytes$1,hexToBytes:hexToBytes$2,hexToNumber:hexToNumber,numberToBytesBE:numberToBytesBE,numberToBytesLE:numberToBytesLE,numberToHexUnpadded:numberToHexUnpadded,numberToVarBytesBE:numberToVarBytesBE,utf8ToBytes:utf8ToBytes$3,validateObject:validateObject});
4
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$3=BigInt(0),_1n$3=BigInt(1),_2n$1=BigInt(2),_3n$1=BigInt(3),_4n=BigInt(4),_5n=BigInt(5),_8n=BigInt(8);function mod(e,t){const n=e%t;return n>=_0n$3?n:t+n}function pow(e,t,n){if(n<=_0n$3||t<_0n$3)throw new Error("Expected power/modulo > 0");if(n===_1n$3)return _0n$3;let r=_1n$3;for(;t>_0n$3;)t&_1n$3&&(r=r*e%n),e=e*e%n,t>>=_1n$3;return r}function pow2(e,t,n){let r=e;for(;t-- >_0n$3;)r*=r,r%=n;return r}function invert(e,t){if(e===_0n$3||t<=_0n$3)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=mod(e,t),r=t,o=_0n$3,s=_1n$3;for(;n!==_0n$3;){const e=r%n,t=o-s*(r/n);r=n,n=e,o=s,s=t}if(r!==_1n$3)throw new Error("invert: does not exist");return mod(o,t)}function tonelliShanks(e){const t=(e-_1n$3)/_2n$1;let n,r,o;for(n=e-_1n$3,r=0;n%_2n$1===_0n$3;n/=_2n$1,r++);for(o=_2n$1;o<e&&pow(o,t,e)!==e-_1n$3;o++);if(1===r){const t=(e+_1n$3)/_4n;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}const s=(n+_1n$3)/_2n$1;return function(e,i){if(e.pow(i,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=r,l=e.pow(e.mul(e.ONE,o),n),c=e.pow(i,s),d=e.pow(i,n);for(;!e.eql(d,e.ONE);){if(e.eql(d,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(d);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(l,_1n$3<<BigInt(a-t-1));l=e.sqr(n),c=e.mul(c,n),d=e.mul(d,l),a=t}return c}}function FpSqrt(e){if(e%_4n===_3n$1){const t=(e+_1n$3)/_4n;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%_8n===_5n){const t=(e-_5n)/_8n;return function(e,n){const r=e.mul(n,_2n$1),o=e.pow(r,t),s=e.mul(n,o),i=e.mul(e.mul(s,_2n$1),o),a=e.mul(s,e.sub(i,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return tonelliShanks(e)}BigInt(9),BigInt(16);const FIELD_FIELDS=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField(e){const t=FIELD_FIELDS.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return validateObject(e,t)}function FpPow(e,t,n){if(n<_0n$3)throw new Error("Expected power > 0");if(n===_0n$3)return e.ONE;if(n===_1n$3)return t;let r=e.ONE,o=t;for(;n>_0n$3;)n&_1n$3&&(r=e.mul(r,o)),o=e.sqr(o),n>>=_1n$3;return r}function FpInvertBatch(e,t){const n=new Array(t.length),r=t.reduce(((t,r,o)=>e.is0(r)?t:(n[o]=t,e.mul(t,r))),e.ONE),o=e.inv(r);return t.reduceRight(((t,r,o)=>e.is0(r)?t:(n[o]=e.mul(t,n[o]),e.mul(t,r))),o),n}function nLength(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Field(e,t,n=!1,r={}){if(e<=_0n$3)throw new Error(`Expected Fp ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:s}=nLength(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const i=FpSqrt(e),a=Object.freeze({ORDER:e,BITS:o,BYTES:s,MASK:bitMask(o),ZERO:_0n$3,ONE:_1n$3,create:t=>mod(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return _0n$3<=t&&t<e},is0:e=>e===_0n$3,isOdd:e=>(e&_1n$3)===_1n$3,neg:t=>mod(-t,e),eql:(e,t)=>e===t,sqr:t=>mod(t*t,e),add:(t,n)=>mod(t+n,e),sub:(t,n)=>mod(t-n,e),mul:(t,n)=>mod(t*n,e),pow:(e,t)=>FpPow(a,e,t),div:(t,n)=>mod(t*invert(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>invert(t,e),sqrt:r.sqrt||(e=>i(a,e)),invertBatch:e=>FpInvertBatch(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?numberToBytesLE(e,s):numberToBytesBE(e,s),fromBytes:e=>{if(e.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${e.length}`);return n?bytesToNumberLE(e):bytesToNumberBE(e)}});return Object.freeze(a)}function hashToPrivateScalar(e,t,n=!1){const r=(e=ensureBytes$1("privateHash",e)).length,o=nLength(t).nByteLength+8;if(o<24||r<o||r>1024)throw new Error(`hashToPrivateScalar: expected ${o}-1024 bytes of input, got ${r}`);return mod(n?bytesToNumberLE(e):bytesToNumberBE(e),t-_1n$3)+_1n$3}
5
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$2=BigInt(0),_1n$2=BigInt(1);function wNAF(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,o=t;for(;n>_0n$2;)n&_1n$2&&(r=r.add(o)),o=o.double(),n>>=_1n$2;return r},precomputeWindow(e,t){const{windows:n,windowSize:o}=r(t),s=[];let i=e,a=i;for(let e=0;e<n;e++){a=i,s.push(a);for(let e=1;e<o;e++)a=a.add(i),s.push(a);i=a.double()}return s},wNAF(t,o,s){const{windows:i,windowSize:a}=r(t);let l=e.ZERO,c=e.BASE;const d=BigInt(2**t-1),h=2**t,u=BigInt(t);for(let e=0;e<i;e++){const t=e*a;let r=Number(s&d);s>>=u,r>a&&(r-=h,s+=_1n$2);const i=t,p=t+Math.abs(r)-1,f=e%2!=0,g=r<0;0===r?c=c.add(n(f,o[i])):l=l.add(n(g,o[p]))}return{p:l,f:c}},wNAFCached(e,t,n,r){const o=e._WINDOW_SIZE||1;let s=t.get(e);return s||(s=this.precomputeWindow(e,o),1!==o&&t.set(e,r(s))),this.wNAF(o,s,n)}}}function validateBasic(e){return validateField(e.Fp),validateObject(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...nLength(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
6
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function validatePointOpts(e){const t=validateBasic(e);validateObject(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:o}=t;if(n){if(!r.eql(o,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:b2n,hexToBytes:h2b}=ut,DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=DER;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(128&r[0])throw new t("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:b2n(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=DER,n="string"==typeof e?h2b(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:o,l:s}=DER._parseInt(n.subarray(2)),{d:i,l:a}=DER._parseInt(s);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s:i}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},r=t(n(e.s)),o=t(n(e.r)),s=r.length/2,i=o.length/2,a=n(s),l=n(i);return`30${n(i+s+4)}02${l}${o}02${a}${r}`}},_0n$1=BigInt(0),_1n$1=BigInt(1);BigInt(2);const _3n=BigInt(3);function weierstrassPoints(e){const t=validatePointOpts(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{const o=t.toAffine();return concatBytes$2(Uint8Array.from([4]),n.toBytes(o.x),n.toBytes(o.y))}),o=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function s(e){const{a:r,b:o}=t,s=n.sqr(e),i=n.mul(s,e);return n.add(n.add(i,n.mul(e,r)),o)}if(!n.eql(n.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function i(e){return"bigint"==typeof e&&_0n$1<e&&e<t.n}function a(e){if(!i(e))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:o,n:s}=t;if(n&&"bigint"!=typeof e){if(e instanceof Uint8Array&&(e=bytesToHex$2(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*r,"0")}let i;try{i="bigint"==typeof e?e:bytesToNumberBE(ensureBytes$1("private key",e,r))}catch(t){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return o&&(i=mod(i,s)),a(i),i}const c=new Map;function d(e){if(!(e instanceof h))throw new Error("ProjectivePoint expected")}class h{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required")}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof h)throw new Error("projective point not allowed");const o=e=>n.eql(e,n.ZERO);return o(t)&&o(r)?h.ZERO:new h(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(h.fromAffine)}static fromHex(e){const t=h.fromAffine(o(ensureBytes$1("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return h.BASE.multiply(l(e))}_setWindowSize(e){this._WINDOW_SIZE=e,c.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw new Error("bad point: x or y not FE");const o=n.sqr(r),i=s(e);if(!n.eql(o,i))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){d(e);const{px:t,py:r,pz:o}=this,{px:s,py:i,pz:a}=e,l=n.eql(n.mul(t,a),n.mul(s,o)),c=n.eql(n.mul(r,a),n.mul(i,o));return l&&c}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,o=n.mul(r,_3n),{px:s,py:i,pz:a}=this;let l=n.ZERO,c=n.ZERO,d=n.ZERO,u=n.mul(s,s),p=n.mul(i,i),f=n.mul(a,a),g=n.mul(s,i);return g=n.add(g,g),d=n.mul(s,a),d=n.add(d,d),l=n.mul(e,d),c=n.mul(o,f),c=n.add(l,c),l=n.sub(p,c),c=n.add(p,c),c=n.mul(l,c),l=n.mul(g,l),d=n.mul(o,d),f=n.mul(e,f),g=n.sub(u,f),g=n.mul(e,g),g=n.add(g,d),d=n.add(u,u),u=n.add(d,u),u=n.add(u,f),u=n.mul(u,g),c=n.add(c,u),f=n.mul(i,a),f=n.add(f,f),u=n.mul(f,g),l=n.sub(l,u),d=n.mul(f,p),d=n.add(d,d),d=n.add(d,d),new h(l,c,d)}add(e){d(e);const{px:r,py:o,pz:s}=this,{px:i,py:a,pz:l}=e;let c=n.ZERO,u=n.ZERO,p=n.ZERO;const f=t.a,g=n.mul(t.b,_3n);let m=n.mul(r,i),b=n.mul(o,a),y=n.mul(s,l),w=n.add(r,o),v=n.add(i,a);w=n.mul(w,v),v=n.add(m,b),w=n.sub(w,v),v=n.add(r,s);let k=n.add(i,l);return v=n.mul(v,k),k=n.add(m,y),v=n.sub(v,k),k=n.add(o,s),c=n.add(a,l),k=n.mul(k,c),c=n.add(b,y),k=n.sub(k,c),p=n.mul(f,v),c=n.mul(g,y),p=n.add(c,p),c=n.sub(b,p),p=n.add(b,p),u=n.mul(c,p),b=n.add(m,m),b=n.add(b,m),y=n.mul(f,y),v=n.mul(g,v),b=n.add(b,y),y=n.sub(m,y),y=n.mul(f,y),v=n.add(v,y),m=n.mul(b,v),u=n.add(u,m),m=n.mul(k,v),c=n.mul(w,c),c=n.sub(c,m),m=n.mul(w,b),p=n.mul(k,p),p=n.add(p,m),new h(c,u,p)}subtract(e){return this.add(e.negate())}is0(){return this.equals(h.ZERO)}wNAF(e){return p.wNAFCached(this,c,e,(e=>{const t=n.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(h.fromAffine)}))}multiplyUnsafe(e){const r=h.ZERO;if(e===_0n$1)return r;if(a(e),e===_1n$1)return this;const{endo:o}=t;if(!o)return p.unsafeLadder(this,e);let{k1neg:s,k1:i,k2neg:l,k2:c}=o.splitScalar(e),d=r,u=r,f=this;for(;i>_0n$1||c>_0n$1;)i&_1n$1&&(d=d.add(f)),c&_1n$1&&(u=u.add(f)),f=f.double(),i>>=_1n$1,c>>=_1n$1;return s&&(d=d.negate()),l&&(u=u.negate()),u=new h(n.mul(u.px,o.beta),u.py,u.pz),d.add(u)}multiply(e){a(e);let r,o,s=e;const{endo:i}=t;if(i){const{k1neg:e,k1:t,k2neg:a,k2:l}=i.splitScalar(s);let{p:c,f:d}=this.wNAF(t),{p:u,f:f}=this.wNAF(l);c=p.constTimeNegate(e,c),u=p.constTimeNegate(a,u),u=new h(n.mul(u.px,i.beta),u.py,u.pz),r=c.add(u),o=d.add(f)}else{const{p:e,f:t}=this.wNAF(s);r=e,o=t}return h.normalizeZ([r,o])[0]}multiplyAndAddUnsafe(e,t,n){const r=h.BASE,o=(e,t)=>t!==_0n$1&&t!==_1n$1&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),s=o(this,t).add(o(e,n));return s.is0()?void 0:s}toAffine(e){const{px:t,py:r,pz:o}=this,s=this.is0();null==e&&(e=s?n.ONE:n.inv(o));const i=n.mul(t,e),a=n.mul(r,e),l=n.mul(o,e);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(l,n.ONE))throw new Error("invZ was invalid");return{x:i,y:a}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===_1n$1)return!0;if(n)return n(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===_1n$1?this:n?n(h,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(h,this,e)}toHex(e=!0){return bytesToHex$2(this.toRawBytes(e))}}h.BASE=new h(t.Gx,t.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const u=t.nBitLength,p=wNAF(h,t.endo?Math.ceil(u/2):u);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:l,weierstrassEquation:s,isWithinCurveOrder:i}}function validateOpts(e){const t=validateBasic(e);return validateObject(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function weierstrass(e){const t=validateOpts(e),{Fp:n,n:r}=t,o=n.BYTES+1,s=2*n.BYTES+1;function i(e){return mod(e,r)}function a(e){return invert(e,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:d,isWithinCurveOrder:h}=weierstrassPoints({...t,toBytes(e,t,r){const o=t.toAffine(),s=n.toBytes(o.x),i=concatBytes$2;return r?i(Uint8Array.from([t.hasEvenY()?2:3]),s):i(Uint8Array.from([4]),s,n.toBytes(o.y))},fromBytes(e){const t=e.length,r=e[0],i=e.subarray(1);if(t!==o||2!==r&&3!==r){if(t===s&&4===r){return{x:n.fromBytes(i.subarray(0,n.BYTES)),y:n.fromBytes(i.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${o} compressed bytes or ${s} uncompressed bytes`)}{const e=bytesToNumberBE(i);if(!(_0n$1<(a=e)&&a<n.ORDER))throw new Error("Point is not on curve");const t=d(e);let o=n.sqrt(t);return!(1&~r)!==((o&_1n$1)===_1n$1)&&(o=n.neg(o)),{x:e,y:o}}var a}}),u=e=>bytesToHex$2(numberToBytesBE(e,t.nByteLength));function p(e){return e>r>>_1n$1}const f=(e,t,n)=>bytesToNumberBE(e.slice(t,n));class g{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=ensureBytes$1("compactSignature",e,2*n),new g(f(e,0,n),f(e,n,2*n))}static fromDER(e){const{r:t,s:n}=DER.toSig(ensureBytes$1("DER",e));return new g(t,n)}assertValidity(){if(!h(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!h(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:o,recovery:s}=this,c=w(ensureBytes$1("msgHash",e));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const d=2===s||3===s?r+t.n:r;if(d>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=1&s?"03":"02",p=l.fromHex(h+u(d)),f=a(d),g=i(-c*f),m=i(o*f),b=l.BASE.multiplyAndAddUnsafe(p,g,m);if(!b)throw new Error("point at infinify");return b.assertValidity(),b}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes$2(this.toDERHex())}toDERHex(){return DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes$2(this.toCompactHex())}toCompactHex(){return u(this.r)+u(this.s)}}const m={isValidPrivateKey(e){try{return c(e),!0}catch(e){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>numberToBytesBE(hashToPrivateScalar(t.randomBytes(n.BYTES+8),r),t.nByteLength),precompute:(e=8,t=l.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function b(e){const t=e instanceof Uint8Array,n="string"==typeof e,r=(t||n)&&e.length;return t?r===o||r===s:n?r===2*o||r===2*s:e instanceof l}const y=t.bits2int||function(e){const n=bytesToNumberBE(e),r=8*e.length-t.nBitLength;return r>0?n>>BigInt(r):n},w=t.bits2int_modN||function(e){return i(y(e))},v=bitMask(t.nBitLength);function k(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(_0n$1<=e&&e<v))throw new Error(`bigint expected < 2^${t.nBitLength}`);return numberToBytesBE(e,t.nByteLength)}function x(e,r,o=E){if(["recovered","canonical"].some((e=>e in o)))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:d}=t;let{lowS:u,prehash:f,extraEntropy:m}=o;null==u&&(u=!0),e=ensureBytes$1("msgHash",e),f&&(e=ensureBytes$1("prehashed msgHash",s(e)));const b=w(e),v=c(r),x=[k(v),k(b)];if(null!=m){const e=!0===m?d(n.BYTES):m;x.push(ensureBytes$1("extraEntropy",e,n.BYTES))}const C=concatBytes$2(...x),$=b;return{seed:C,k2sig:function(e){const t=y(e);if(!h(t))return;const n=a(t),r=l.BASE.multiply(t).toAffine(),o=i(r.x);if(o===_0n$1)return;const s=i(n*i($+o*v));if(s===_0n$1)return;let c=(r.x===o?0:2)|Number(r.y&_1n$1),d=s;return u&&p(s)&&(d=function(e){return p(e)?i(-e):e}(s),c^=1),new g(o,d,c)}}}const E={lowS:t.lowS,prehash:!1},C={lowS:t.lowS,prehash:!1};return l.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return l.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(b(e))throw new Error("first arg must be private key");if(!b(t))throw new Error("second arg must be public key");return l.fromHex(t).multiply(c(e)).toRawBytes(n)},sign:function(e,n,r=E){const{seed:o,k2sig:s}=x(e,n,r),i=t;return createHmacDrbg(i.hash.outputLen,i.nByteLength,i.hmac)(o,s)},verify:function(e,n,r,o=C){const s=e;if(n=ensureBytes$1("msgHash",n),r=ensureBytes$1("publicKey",r),"strict"in o)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:d}=o;let h,u;try{if("string"==typeof s||s instanceof Uint8Array)try{h=g.fromDER(s)}catch(e){if(!(e instanceof DER.Err))throw e;h=g.fromCompact(s)}else{if("object"!=typeof s||"bigint"!=typeof s.r||"bigint"!=typeof s.s)throw new Error("PARSE");{const{r:e,s:t}=s;h=new g(e,t)}}u=l.fromHex(r)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&h.hasHighS())return!1;d&&(n=t.hash(n));const{r:p,s:f}=h,m=w(n),b=a(f),y=i(m*b),v=i(p*b),k=l.BASE.multiplyAndAddUnsafe(u,y,v)?.toAffine();return!!k&&i(k.x)===p},ProjectivePoint:l,Signature:g,utils:m}}BigInt(4);let HMAC$2=class extends Hash$2{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,assert$3.hash(e);const n=toBytes$3(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<o.length;e++)o[e]^=54;this.iHash.update(o),this.oHash=e.create();for(let e=0;e<o.length;e++)o[e]^=106;this.oHash.update(o),o.fill(0)}update(e){return assert$3.exists(this),this.iHash.update(e),this}digestInto(e){assert$3.exists(this),assert$3.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:o,blockLen:s,outputLen:i}=this;return e.finished=r,e.destroyed=o,e.blockLen=s,e.outputLen=i,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const hmac$2=(e,t,n)=>new HMAC$2(e,t).update(n).digest();
14
7
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
15
- const _0n$d=BigInt(0),_1n$e=BigInt(1);function _abool2(e,t=""){if("boolean"!=typeof e){throw new Error((t&&`"${t}"`)+"expected boolean, got type="+typeof e)}return e}function _abytes2(e,t,n=""){const r=isBytes$6(e),i=e?.length,s=void 0!==t;if(!r||s&&i!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${t}`:"")+", got "+(r?`length=${i}`:"type="+typeof e))}return e}function numberToHexUnpadded$2(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function hexToNumber$2(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?_0n$d:BigInt("0x"+e)}function bytesToNumberBE$2(e){return hexToNumber$2(bytesToHex$4(e))}function bytesToNumberLE$2(e){return abytes(e),hexToNumber$2(bytesToHex$4(Uint8Array.from(e).reverse()))}function numberToBytesBE$2(e,t){return hexToBytes$4(e.toString(16).padStart(2*t,"0"))}function numberToBytesLE$2(e,t){return numberToBytesBE$2(e,t).reverse()}function ensureBytes$3(e,t,n){let r;if("string"==typeof t)try{r=hexToBytes$4(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!isBytes$6(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(e+" of length "+n+" expected, got "+i);return r}const isPosBig=e=>"bigint"==typeof e&&_0n$d<=e;function inRange(e,t,n){return isPosBig(e)&&isPosBig(t)&&isPosBig(n)&&t<=e&&e<n}function aInRange(e,t,n,r){if(!inRange(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function bitLen$2(e){let t;for(t=0;e>_0n$d;e>>=_1n$e,t+=1);return t}const bitMask$2=e=>(_1n$e<<BigInt(e))-_1n$e;function createHmacDrbg$2(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");const r=e=>new Uint8Array(e),i=e=>Uint8Array.of(e);let s=r(e),o=r(e),a=0;const c=()=>{s.fill(1),o.fill(0),a=0},l=(...e)=>n(o,s,...e),h=(e=r(0))=>{o=l(i(0),e),s=l(),0!==e.length&&(o=l(i(1),e),s=l())},d=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){s=l();const t=s.slice();n.push(t),e+=s.length}return concatBytes$5(...n)};return(e,t)=>{let n;for(c(),h(e);!(n=t(d()));)h();return c(),n}}function _validateObject(e,t,n={}){if(!e||"object"!=typeof e)throw new Error("expected valid options object");function r(t,n,r){const i=e[t];if(r&&void 0===i)return;const s=typeof i;if(s!==n||null===i)throw new Error(`param "${t}" is invalid: expected ${n}, got ${s}`)}Object.entries(t).forEach(([e,t])=>r(e,t,!1)),Object.entries(n).forEach(([e,t])=>r(e,t,!0))}function memoized(e){const t=new WeakMap;return(n,...r)=>{const i=t.get(n);if(void 0!==i)return i;const s=e(n,...r);return t.set(n,s),s}}
16
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$c=BigInt(0),_1n$d=BigInt(1),_2n$8=BigInt(2),_3n$5=BigInt(3),_4n$3=BigInt(4),_5n$2=BigInt(5),_7n=BigInt(7),_8n$2=BigInt(8),_9n=BigInt(9),_16n=BigInt(16);function mod$2(e,t){const n=e%t;return n>=_0n$c?n:t+n}function pow2$2(e,t,n){let r=e;for(;t-- >_0n$c;)r*=r,r%=n;return r}function invert$2(e,t){if(e===_0n$c)throw new Error("invert: expected non-zero number");if(t<=_0n$c)throw new Error("invert: expected positive modulus, got "+t);let n=mod$2(e,t),r=t,i=_0n$c,s=_1n$d;for(;n!==_0n$c;){const e=r%n,t=i-s*(r/n);r=n,n=e,i=s,s=t}if(r!==_1n$d)throw new Error("invert: does not exist");return mod$2(i,t)}function assertIsSquare(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function sqrt3mod4(e,t){const n=(e.ORDER+_1n$d)/_4n$3,r=e.pow(t,n);return assertIsSquare(e,r,t),r}function sqrt5mod8(e,t){const n=(e.ORDER-_5n$2)/_8n$2,r=e.mul(t,_2n$8),i=e.pow(r,n),s=e.mul(t,i),o=e.mul(e.mul(s,_2n$8),i),a=e.mul(s,e.sub(o,e.ONE));return assertIsSquare(e,a,t),a}function sqrt9mod16(e){const t=Field$2(e),n=tonelliShanks$2(e),r=n(t,t.neg(t.ONE)),i=n(t,r),s=n(t,t.neg(r)),o=(e+_7n)/_16n;return(e,t)=>{let n=e.pow(t,o),a=e.mul(n,r);const c=e.mul(n,i),l=e.mul(n,s),h=e.eql(e.sqr(a),t),d=e.eql(e.sqr(c),t);n=e.cmov(n,a,h),a=e.cmov(l,c,d);const u=e.eql(e.sqr(a),t),f=e.cmov(n,a,u);return assertIsSquare(e,f,t),f}}function tonelliShanks$2(e){if(e<_3n$5)throw new Error("sqrt is not defined for small field");let t=e-_1n$d,n=0;for(;t%_2n$8===_0n$c;)t/=_2n$8,n++;let r=_2n$8;const i=Field$2(e);for(;1===FpLegendre(i,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return sqrt3mod4;let s=i.pow(r,t);const o=(t+_1n$d)/_2n$8;return function(e,r){if(e.is0(r))return r;if(1!==FpLegendre(e,r))throw new Error("Cannot find square root");let i=n,a=e.mul(e.ONE,s),c=e.pow(r,t),l=e.pow(r,o);for(;!e.eql(c,e.ONE);){if(e.is0(c))return e.ZERO;let t=1,n=e.sqr(c);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===i)throw new Error("Cannot find square root");const r=_1n$d<<BigInt(i-t-1),s=e.pow(a,r);i=t,a=e.sqr(s),c=e.mul(c,a),l=e.mul(l,s)}return l}}function FpSqrt$2(e){return e%_4n$3===_3n$5?sqrt3mod4:e%_8n$2===_5n$2?sqrt5mod8:e%_16n===_9n?sqrt9mod16(e):tonelliShanks$2(e)}const FIELD_FIELDS$2=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField$2(e){const t=FIELD_FIELDS$2.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});return _validateObject(e,t),e}function FpPow$2(e,t,n){if(n<_0n$c)throw new Error("invalid exponent, negatives unsupported");if(n===_0n$c)return e.ONE;if(n===_1n$d)return t;let r=e.ONE,i=t;for(;n>_0n$c;)n&_1n$d&&(r=e.mul(r,i)),i=e.sqr(i),n>>=_1n$d;return r}function FpInvertBatch$2(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),i=t.reduce((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n)),e.ONE),s=e.inv(i);return t.reduceRight((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n)),s),r}function FpLegendre(e,t){const n=(e.ORDER-_1n$d)/_2n$8,r=e.pow(t,n),i=e.eql(r,e.ONE),s=e.eql(r,e.ZERO),o=e.eql(r,e.neg(e.ONE));if(!i&&!s&&!o)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function nLength$2(e,t){void 0!==t&&anumber(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Field$2(e,t,n=!1,r={}){if(e<=_0n$c)throw new Error("invalid field: expected ORDER > 0, got "+e);let i,s,o,a=!1;if("object"==typeof t&&null!=t){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const e=t;e.BITS&&(i=e.BITS),e.sqrt&&(s=e.sqrt),"boolean"==typeof e.isLE&&(n=e.isLE),"boolean"==typeof e.modFromBytes&&(a=e.modFromBytes),o=e.allowedLengths}else"number"==typeof t&&(i=t),r.sqrt&&(s=r.sqrt);const{nBitLength:c,nByteLength:l}=nLength$2(e,i);if(l>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let h;const d=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:l,MASK:bitMask$2(c),ZERO:_0n$c,ONE:_1n$d,allowedLengths:o,create:t=>mod$2(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return _0n$c<=t&&t<e},is0:e=>e===_0n$c,isValidNot0:e=>!d.is0(e)&&d.isValid(e),isOdd:e=>(e&_1n$d)===_1n$d,neg:t=>mod$2(-t,e),eql:(e,t)=>e===t,sqr:t=>mod$2(t*t,e),add:(t,n)=>mod$2(t+n,e),sub:(t,n)=>mod$2(t-n,e),mul:(t,n)=>mod$2(t*n,e),pow:(e,t)=>FpPow$2(d,e,t),div:(t,n)=>mod$2(t*invert$2(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>invert$2(t,e),sqrt:s||(t=>(h||(h=FpSqrt$2(e)),h(d,t))),toBytes:e=>n?numberToBytesLE$2(e,l):numberToBytesBE$2(e,l),fromBytes:(t,r=!0)=>{if(o){if(!o.includes(t.length)||t.length>l)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);const e=new Uint8Array(l);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==l)throw new Error("Field.fromBytes: expected "+l+" bytes, got "+t.length);let i=n?bytesToNumberLE$2(t):bytesToNumberBE$2(t);if(a&&(i=mod$2(i,e)),!r&&!d.isValid(i))throw new Error("invalid field element: outside of range 0..ORDER");return i},invertBatch:e=>FpInvertBatch$2(d,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(d)}function getFieldBytesLength(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function getMinHashLength(e){const t=getFieldBytesLength(e);return t+Math.ceil(t/2)}function mapHashToField(e,t,n=!1){const r=e.length,i=getFieldBytesLength(t),s=getMinHashLength(t);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const o=mod$2(n?bytesToNumberLE$2(e):bytesToNumberBE$2(e),t-_1n$d)+_1n$d;return n?numberToBytesLE$2(o,i):numberToBytesBE$2(o,i)}
17
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$b=BigInt(0),_1n$c=BigInt(1);function negateCt(e,t){const n=t.negate();return e?n:t}function normalizeZ(e,t){const n=FpInvertBatch$2(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function validateW(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function calcWOpts(e,t){validateW(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:bitMask$2(e),maxNumber:n,shiftBy:BigInt(e)}}function calcOffsets(e,t,n){const{windowSize:r,mask:i,maxNumber:s,shiftBy:o}=n;let a=Number(e&i),c=e>>o;a>r&&(a-=s,c+=_1n$c);const l=t*r;return{nextN:c,offset:l+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:t%2!=0,offsetF:l}}function validateMSMPoints(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function validateMSMScalars(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}const pointPrecomputes=new WeakMap,pointWindowSizes=new WeakMap;function getW(e){return pointWindowSizes.get(e)||1}function assert0(e){if(e!==_0n$b)throw new Error("invalid wNAF")}let wNAF$2=class{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>_0n$b;)t&_1n$c&&(n=n.add(r)),r=r.double(),t>>=_1n$c;return n}precomputeWindow(e,t){const{windows:n,windowSize:r}=calcWOpts(t,this.bits),i=[];let s=e,o=s;for(let e=0;e<n;e++){o=s,i.push(o);for(let e=1;e<r;e++)o=o.add(s),i.push(o);s=o.double()}return i}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let r=this.ZERO,i=this.BASE;const s=calcWOpts(e,this.bits);for(let e=0;e<s.windows;e++){const{nextN:o,offset:a,isZero:c,isNeg:l,isNegF:h,offsetF:d}=calcOffsets(n,e,s);n=o,c?i=i.add(negateCt(h,t[d])):r=r.add(negateCt(l,t[a]))}return assert0(n),{p:r,f:i}}wNAFUnsafe(e,t,n,r=this.ZERO){const i=calcWOpts(e,this.bits);for(let e=0;e<i.windows&&n!==_0n$b;e++){const{nextN:s,offset:o,isZero:a,isNeg:c}=calcOffsets(n,e,i);if(n=s,!a){const e=t[o];r=r.add(c?e.negate():e)}}return assert0(n),r}getPrecomputes(e,t,n){let r=pointPrecomputes.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&("function"==typeof n&&(r=n(r)),pointPrecomputes.set(t,r))),r}cached(e,t,n){const r=getW(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){const i=getW(e);return 1===i?this._unsafeLadder(e,t,r):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,r)}createCache(e,t){validateW(t,this.bits),pointWindowSizes.set(e,t),pointPrecomputes.delete(e)}hasCache(e){return 1!==getW(e)}};function mulEndoUnsafe(e,t,n,r){let i=t,s=e.ZERO,o=e.ZERO;for(;n>_0n$b||r>_0n$b;)n&_1n$c&&(s=s.add(i)),r&_1n$c&&(o=o.add(i)),i=i.double(),n>>=_1n$c,r>>=_1n$c;return{p1:s,p2:o}}function pippenger(e,t,n,r){validateMSMPoints(n,e),validateMSMScalars(r,t);const i=n.length,s=r.length;if(i!==s)throw new Error("arrays of points and scalars must have equal length");const o=e.ZERO,a=bitLen$2(BigInt(i));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const l=bitMask$2(c),h=new Array(Number(l)+1).fill(o);let d=o;for(let e=Math.floor((t.BITS-1)/c)*c;e>=0;e-=c){h.fill(o);for(let t=0;t<s;t++){const i=r[t],s=Number(i>>BigInt(e)&l);h[s]=h[s].add(n[t])}let t=o;for(let e=h.length-1,n=o;e>0;e--)n=n.add(h[e]),t=t.add(n);if(d=d.add(t),0!==e)for(let e=0;e<c;e++)d=d.double()}return d}function createField(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return validateField$2(t),t}return Field$2(e,{isLE:n})}function _createCurveFields(e,t,n={},r){if(void 0===r&&(r="edwards"===e),!t||"object"!=typeof t)throw new Error(`expected valid ${e} CURVE object`);for(const e of["p","n","h"]){const n=t[e];if(!("bigint"==typeof n&&n>_0n$b))throw new Error(`CURVE.${e} must be positive bigint`)}const i=createField(t.p,n.Fp,r),s=createField(t.n,n.Fn,r),o=["Gx","Gy","a","b"];for(const e of o)if(!i.isValid(t[e]))throw new Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:i,Fn:s}}
18
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const divNearest$2=(e,t)=>(e+(e>=0?t:-t)/_2n$7)/t;function _splitEndoScalar(e,t,n){const[[r,i],[s,o]]=t,a=divNearest$2(o*e,n),c=divNearest$2(-i*e,n);let l=e-a*r-c*s,h=-a*i-c*o;const d=l<_0n$a,u=h<_0n$a;d&&(l=-l),u&&(h=-h);const f=bitMask$2(Math.ceil(bitLen$2(n)/2))+_1n$b;if(l<_0n$a||l>=f||h<_0n$a||h>=f)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:d,k1:l,k2neg:u,k2:h}}function validateSigFormat(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function validateSigOpts(e,t){const n={};for(let r of Object.keys(t))n[r]=void 0===e[r]?t[r]:e[r];return _abool2(n.lowS,"lowS"),_abool2(n.prehash,"prehash"),void 0!==n.format&&validateSigFormat(n.format),n}class DERErr extends Error{constructor(e=""){super(e)}}const DER$2={Err:DERErr,_tlv:{encode:(e,t)=>{const{Err:n}=DER$2;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const r=t.length/2,i=numberToHexUnpadded$2(r);if(i.length/2&128)throw new n("tlv.encode: long form length too big");const s=r>127?numberToHexUnpadded$2(i.length/2|128):"";return numberToHexUnpadded$2(e)+s+i+t},decode(e,t){const{Err:n}=DER$2;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const i=t[r++];let s=0;if(!!(128&i)){const e=127&i;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const o=t.subarray(r,r+e);if(o.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===o[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of o)s=s<<8|e;if(r+=e,s<128)throw new n("tlv.decode(long): not minimal encoding")}else s=i;const o=t.subarray(r,r+s);if(o.length!==s)throw new n("tlv.decode: wrong value length");return{v:o,l:t.subarray(r+s)}}},_int:{encode(e){const{Err:t}=DER$2;if(e<_0n$a)throw new t("integer: negative integers are not allowed");let n=numberToHexUnpadded$2(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=DER$2;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return bytesToNumberBE$2(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=DER$2,i=ensureBytes$3("signature",e),{v:s,l:o}=r.decode(48,i);if(o.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,s),{v:l,l:h}=r.decode(2,c);if(h.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(l)}},hexFromSig(e){const{_tlv:t,_int:n}=DER$2,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},_0n$a=BigInt(0),_1n$b=BigInt(1),_2n$7=BigInt(2),_3n$4=BigInt(3),_4n$2=BigInt(4);function _normFnElement(e,t){const{BYTES:n}=e;let r;if("bigint"==typeof t)r=t;else{let i=ensureBytes$3("private key",t);try{r=e.fromBytes(i)}catch(e){throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function weierstrassN(e,t={}){const n=_createCurveFields("weierstrass",e,t),{Fp:r,Fn:i}=n;let s=n.CURVE;const{h:o,n:a}=s;_validateObject(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:c}=t;if(c&&(!r.is0(s.a)||"bigint"!=typeof c.beta||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const l=getWLengths(r,i);function h(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const d=t.toBytes||function(e,t,n){const{x:i,y:s}=t.toAffine(),o=r.toBytes(i);if(_abool2(n,"isCompressed"),n){h();return concatBytes$5(pprefix(!r.isOdd(s)),o)}return concatBytes$5(Uint8Array.of(4),o,r.toBytes(s))},u=t.fromBytes||function(e){_abytes2(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=l,i=e.length,s=e[0],o=e.subarray(1);if(i!==t||2!==s&&3!==s){if(i===n&&4===s){const e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,2*e));if(!p(t,n))throw new Error("bad point: is not on curve");return{x:t,y:n}}throw new Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}{const e=r.fromBytes(o);if(!r.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=f(e);let n;try{n=r.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}h();return!(1&~s)!==r.isOdd(n)&&(n=r.neg(n)),{x:e,y:n}}};function f(e){const t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,s.a)),s.b)}function p(e,t){const n=r.sqr(t),i=f(e);return r.eql(n,i)}if(!p(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const g=r.mul(r.pow(s.a,_3n$4),_4n$2),y=r.mul(r.sqr(s.b),BigInt(27));if(r.is0(r.add(g,y)))throw new Error("bad curve params: a or b");function m(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function b(e){if(!(e instanceof k))throw new Error("ProjectivePoint expected")}function w(e){if(!c||!c.basises)throw new Error("no endo");return _splitEndoScalar(e,c.basises,i.ORDER)}const v=memoized((e,t)=>{const{X:n,Y:i,Z:s}=e;if(r.eql(s,r.ONE))return{x:n,y:i};const o=e.is0();null==t&&(t=o?r.ONE:r.inv(s));const a=r.mul(n,t),c=r.mul(i,t),l=r.mul(s,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(l,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}}),$=memoized(e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:n,y:i}=e.toAffine();if(!r.isValid(n)||!r.isValid(i))throw new Error("bad point: x or y not field elements");if(!p(n,i))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function E(e,t,n,i,s){return n=new k(r.mul(n.X,e),n.Y,n.Z),t=negateCt(i,t),n=negateCt(s,n),t.add(n)}class k{constructor(e,t,n){this.X=m("x",e),this.Y=m("y",t,!0),this.Z=m("z",n),Object.freeze(this)}static CURVE(){return s}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof k)throw new Error("projective point not allowed");return r.is0(t)&&r.is0(n)?k.ZERO:new k(t,n,r.ONE)}static fromBytes(e){const t=k.fromAffine(u(_abytes2(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return k.fromBytes(ensureBytes$3("pointHex",e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return _.createCache(this,e),t||this.multiply(_3n$4),this}assertValidity(){$(this)}hasEvenY(){const{y:e}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(e)}equals(e){b(e);const{X:t,Y:n,Z:i}=this,{X:s,Y:o,Z:a}=e,c=r.eql(r.mul(t,a),r.mul(s,i)),l=r.eql(r.mul(n,a),r.mul(o,i));return c&&l}negate(){return new k(this.X,r.neg(this.Y),this.Z)}double(){const{a:e,b:t}=s,n=r.mul(t,_3n$4),{X:i,Y:o,Z:a}=this;let c=r.ZERO,l=r.ZERO,h=r.ZERO,d=r.mul(i,i),u=r.mul(o,o),f=r.mul(a,a),p=r.mul(i,o);return p=r.add(p,p),h=r.mul(i,a),h=r.add(h,h),c=r.mul(e,h),l=r.mul(n,f),l=r.add(c,l),c=r.sub(u,l),l=r.add(u,l),l=r.mul(c,l),c=r.mul(p,c),h=r.mul(n,h),f=r.mul(e,f),p=r.sub(d,f),p=r.mul(e,p),p=r.add(p,h),h=r.add(d,d),d=r.add(h,d),d=r.add(d,f),d=r.mul(d,p),l=r.add(l,d),f=r.mul(o,a),f=r.add(f,f),d=r.mul(f,p),c=r.sub(c,d),h=r.mul(f,u),h=r.add(h,h),h=r.add(h,h),new k(c,l,h)}add(e){b(e);const{X:t,Y:n,Z:i}=this,{X:o,Y:a,Z:c}=e;let l=r.ZERO,h=r.ZERO,d=r.ZERO;const u=s.a,f=r.mul(s.b,_3n$4);let p=r.mul(t,o),g=r.mul(n,a),y=r.mul(i,c),m=r.add(t,n),w=r.add(o,a);m=r.mul(m,w),w=r.add(p,g),m=r.sub(m,w),w=r.add(t,i);let v=r.add(o,c);return w=r.mul(w,v),v=r.add(p,y),w=r.sub(w,v),v=r.add(n,i),l=r.add(a,c),v=r.mul(v,l),l=r.add(g,y),v=r.sub(v,l),d=r.mul(u,w),l=r.mul(f,y),d=r.add(l,d),l=r.sub(g,d),d=r.add(g,d),h=r.mul(l,d),g=r.add(p,p),g=r.add(g,p),y=r.mul(u,y),w=r.mul(f,w),g=r.add(g,y),y=r.sub(p,y),y=r.mul(u,y),w=r.add(w,y),p=r.mul(g,w),h=r.add(h,p),p=r.mul(v,w),l=r.mul(m,l),l=r.sub(l,p),p=r.mul(m,g),d=r.mul(v,d),d=r.add(d,p),new k(l,h,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(k.ZERO)}multiply(e){const{endo:n}=t;if(!i.isValidNot0(e))throw new Error("invalid scalar: out of range");let r,s;const o=e=>_.cached(this,e,e=>normalizeZ(k,e));if(n){const{k1neg:t,k1:i,k2neg:a,k2:c}=w(e),{p:l,f:h}=o(i),{p:d,f:u}=o(c);s=h.add(u),r=E(n.beta,l,d,t,a)}else{const{p:t,f:n}=o(e);r=t,s=n}return normalizeZ(k,[r,s])[0]}multiplyUnsafe(e){const{endo:n}=t,r=this;if(!i.isValid(e))throw new Error("invalid scalar: out of range");if(e===_0n$a||r.is0())return k.ZERO;if(e===_1n$b)return r;if(_.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:i,k2neg:s,k2:o}=w(e),{p1:a,p2:c}=mulEndoUnsafe(k,r,i,o);return E(n.beta,a,c,t,s)}return _.unsafe(r,e)}multiplyAndAddUnsafe(e,t,n){const r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return r.is0()?void 0:r}toAffine(e){return v(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return o===_1n$b||(e?e(k,this):_.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return o===_1n$b?this:e?e(k,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(e=!0){return _abool2(e,"isCompressed"),this.assertValidity(),d(k,this,e)}toHex(e=!0){return bytesToHex$4(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return normalizeZ(k,e)}static msm(e,t){return pippenger(k,i,e,t)}static fromPrivateKey(e){return k.BASE.multiply(_normFnElement(i,e))}}k.BASE=new k(s.Gx,s.Gy,r.ONE),k.ZERO=new k(r.ZERO,r.ONE,r.ZERO),k.Fp=r,k.Fn=i;const x=i.BITS,_=new wNAF$2(k,t.endo?Math.ceil(x/2):x);return k.BASE.precompute(8),k}function pprefix(e){return Uint8Array.of(e?2:3)}function getWLengths(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function ecdh(e,t={}){const{Fn:n}=e,r=t.randomBytes||randomBytes$3,i=Object.assign(getWLengths(e.Fp,n),{seed:getMinHashLength(n.ORDER)});function s(e){try{return!!_normFnElement(n,e)}catch(e){return!1}}function o(e=r(i.seed)){return mapHashToField(_abytes2(e,i.seed,"seed"),n.ORDER)}function a(t,r=!0){return e.BASE.multiply(_normFnElement(n,t)).toBytes(r)}function c(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;const{secretKey:r,publicKey:s,publicKeyUncompressed:o}=i;if(n.allowedLengths||r===s)return;const a=ensureBytes$3("key",t).length;return a===s||a===o}const l={isValidSecretKey:s,isValidPublicKey:function(t,n){const{publicKey:r,publicKeyUncompressed:s}=i;try{const i=t.length;return(!0!==n||i===r)&&((!1!==n||i===s)&&!!e.fromBytes(t))}catch(e){return!1}},randomSecretKey:o,isValidPrivateKey:s,randomPrivateKey:o,normPrivateKeyToScalar:e=>_normFnElement(n,e),precompute:(t=8,n=e.BASE)=>n.precompute(t,!1)};return Object.freeze({getPublicKey:a,getSharedSecret:function(t,r,i=!0){if(!0===c(t))throw new Error("first arg must be private key");if(!1===c(r))throw new Error("second arg must be public key");const s=_normFnElement(n,t);return e.fromHex(r).multiply(s).toBytes(i)},keygen:function(e){const t=o(e);return{secretKey:t,publicKey:a(t)}},Point:e,utils:l,lengths:i})}function ecdsa(e,t,n={}){ahash(t),_validateObject(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||randomBytes$3,i=n.hmac||((e,...n)=>hmac$4(t,e,concatBytes$5(...n))),{Fp:s,Fn:o}=e,{ORDER:a,BITS:c}=o,{keygen:l,getPublicKey:h,getSharedSecret:d,utils:u,lengths:f}=ecdh(e,n),p={prehash:!1,lowS:"boolean"==typeof n.lowS&&n.lowS,format:void 0,extraEntropy:!1},g="compact";function y(e){return e>a>>_1n$b}function m(e,t){if(!o.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class b{constructor(e,t,n){this.r=m("r",e),this.s=m("s",t),null!=n&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,t=g){let n;if(function(e,t){validateSigFormat(t);const n=f.signature;_abytes2(e,"compact"===t?n:"recovered"===t?n+1:void 0,`${t} signature`)}(e,t),"der"===t){const{r:t,s:n}=DER$2.toSig(_abytes2(e));return new b(t,n)}"recovered"===t&&(n=e[0],t="compact",e=e.subarray(1));const r=o.BYTES,i=e.subarray(0,r),s=e.subarray(r,2*r);return new b(o.fromBytes(i),o.fromBytes(s),n)}static fromHex(e,t){return this.fromBytes(hexToBytes$4(e),t)}addRecoveryBit(e){return new b(this.r,this.s,e)}recoverPublicKey(t){const n=s.ORDER,{r:r,s:i,recovery:c}=this;if(null==c||![0,1,2,3].includes(c))throw new Error("recovery id invalid");if(a*_2n$7<n&&c>1)throw new Error("recovery id is ambiguous for h>1 curve");const l=2===c||3===c?r+a:r;if(!s.isValid(l))throw new Error("recovery id 2 or 3 invalid");const h=s.toBytes(l),d=e.fromBytes(concatBytes$5(pprefix(!(1&c)),h)),u=o.inv(l),f=v(ensureBytes$3("msgHash",t)),p=o.create(-f*u),g=o.create(i*u),y=e.BASE.multiplyUnsafe(p).add(d.multiplyUnsafe(g));if(y.is0())throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return y(this.s)}toBytes(e=g){if(validateSigFormat(e),"der"===e)return hexToBytes$4(DER$2.hexFromSig(this));const t=o.toBytes(this.r),n=o.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return concatBytes$5(Uint8Array.of(this.recovery),t,n)}return concatBytes$5(t,n)}toHex(e){return bytesToHex$4(this.toBytes(e))}assertValidity(){}static fromCompact(e){return b.fromBytes(ensureBytes$3("sig",e),"compact")}static fromDER(e){return b.fromBytes(ensureBytes$3("sig",e),"der")}normalizeS(){return this.hasHighS()?new b(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return bytesToHex$4(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return bytesToHex$4(this.toBytes("compact"))}}const w=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=bytesToNumberBE$2(e),n=8*e.length-c;return n>0?t>>BigInt(n):t},v=n.bits2int_modN||function(e){return o.create(w(e))},$=bitMask$2(c);function E(e){return aInRange("num < 2^"+c,e,_0n$a,$),o.toBytes(e)}function k(e,n){return _abytes2(e,void 0,"message"),n?_abytes2(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:l,getPublicKey:h,getSharedSecret:d,utils:u,lengths:f,Point:e,sign:function(n,s,a={}){n=ensureBytes$3("message",n);const{seed:c,k2sig:l}=function(t,n,i){if(["recovered","canonical"].some(e=>e in i))throw new Error("sign() legacy options not supported");const{lowS:s,prehash:a,extraEntropy:c}=validateSigOpts(i,p);t=k(t,a);const l=v(t),h=_normFnElement(o,n),d=[E(h),E(l)];if(null!=c&&!1!==c){const e=!0===c?r(f.secretKey):c;d.push(ensureBytes$3("extraEntropy",e))}const u=concatBytes$5(...d),g=l;return{seed:u,k2sig:function(t){const n=w(t);if(!o.isValidNot0(n))return;const r=o.inv(n),i=e.BASE.multiply(n).toAffine(),a=o.create(i.x);if(a===_0n$a)return;const c=o.create(r*o.create(g+a*h));if(c===_0n$a)return;let l=(i.x===a?0:2)|Number(i.y&_1n$b),d=c;return s&&y(c)&&(d=o.neg(c),l^=1),new b(a,d,l)}}}(n,s,a);return createHmacDrbg$2(t.outputLen,o.BYTES,i)(c,l)},verify:function(t,n,r,i={}){const{lowS:s,prehash:a,format:c}=validateSigOpts(i,p);if(r=ensureBytes$3("publicKey",r),n=k(ensureBytes$3("message",n),a),"strict"in i)throw new Error("options.strict was renamed to lowS");const l=void 0===c?function(e){let t;const n="string"==typeof e||isBytes$6(e),r=!n&&null!==e&&"object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!n&&!r)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(r)t=new b(e.r,e.s);else if(n){try{t=b.fromBytes(ensureBytes$3("sig",e),"der")}catch(e){if(!(e instanceof DER$2.Err))throw e}if(!t)try{t=b.fromBytes(ensureBytes$3("sig",e),"compact")}catch(e){return!1}}return t||!1}(t):b.fromBytes(ensureBytes$3("sig",t),c);if(!1===l)return!1;try{const t=e.fromBytes(r);if(s&&l.hasHighS())return!1;const{r:i,s:a}=l,c=v(n),h=o.inv(a),d=o.create(c*h),u=o.create(i*h),f=e.BASE.multiplyUnsafe(d).add(t.multiplyUnsafe(u));if(f.is0())return!1;return o.create(f.x)===i}catch(e){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:r}=validateSigOpts(n,p);return t=k(t,r),b.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:b,hash:t})}function _weierstrass_legacy_opts_to_new(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(e=>Math.ceil(e/2)))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:Field$2(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}function _ecdsa_legacy_opts_to_new(e){const{CURVE:t,curveOpts:n}=_weierstrass_legacy_opts_to_new(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function _ecdsa_new_output_to_legacy(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,nLength$2(n.Fn.ORDER,n.Fn.BITS))})}function weierstrass$2(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:i}=_ecdsa_legacy_opts_to_new(e);return _ecdsa_new_output_to_legacy(e,ecdsa(weierstrassN(t,n),r,i))}
19
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function createCurve$2(e,t){const n=t=>weierstrass$2({...e,hash:t});return{...n(t),create:n}}
20
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1_CURVE={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},secp256k1_ENDO={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},_0n$9=BigInt(0),_1n$a=BigInt(1),_2n$6=BigInt(2);function sqrtMod$2(e){const t=secp256k1_CURVE.p,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,h=l*l*e%t,d=pow2$2(h,n,t)*h%t,u=pow2$2(d,n,t)*h%t,f=pow2$2(u,_2n$6,t)*l%t,p=pow2$2(f,i,t)*f%t,g=pow2$2(p,s,t)*p%t,y=pow2$2(g,a,t)*g%t,m=pow2$2(y,c,t)*y%t,b=pow2$2(m,a,t)*g%t,w=pow2$2(b,n,t)*h%t,v=pow2$2(w,o,t)*p%t,$=pow2$2(v,r,t)*l%t,E=pow2$2($,_2n$6,t);if(!Fpk1.eql(Fpk1.sqr(E),e))throw new Error("Cannot find square root");return E}const Fpk1=Field$2(secp256k1_CURVE.p,{sqrt:sqrtMod$2}),secp256k1$2=createCurve$2({...secp256k1_CURVE,Fp:Fpk1,lowS:!0,endo:secp256k1_ENDO},sha256$5),TAGGED_HASH_PREFIXES$1={};function taggedHash$1(e,...t){let n=TAGGED_HASH_PREFIXES$1[e];if(void 0===n){const t=sha256$5(utf8ToBytes$7(e));n=concatBytes$5(t,t),TAGGED_HASH_PREFIXES$1[e]=n}return sha256$5(concatBytes$5(n,...t))}const pointToBytes$1=e=>e.toBytes(!0).slice(1),Pointk1=(()=>secp256k1$2.Point)(),hasEven=e=>e%_2n$6===_0n$9;function schnorrGetExtPubKey$1(e){const{Fn:t,BASE:n}=Pointk1,r=_normFnElement(t,e),i=n.multiply(r);return{scalar:hasEven(i.y)?r:t.neg(r),bytes:pointToBytes$1(i)}}function lift_x$1(e){const t=Fpk1;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x ≥ p");const n=t.create(e*e),r=t.create(n*e+BigInt(7));let i=t.sqrt(r);hasEven(i)||(i=t.neg(i));const s=Pointk1.fromAffine({x:e,y:i});return s.assertValidity(),s}const num=bytesToNumberBE$2;function challenge$1(...e){return Pointk1.Fn.create(num(taggedHash$1("BIP0340/challenge",...e)))}function schnorrGetPublicKey$1(e){return schnorrGetExtPubKey$1(e).bytes}function schnorrSign$1(e,t,n=randomBytes$3(32)){const{Fn:r}=Pointk1,i=ensureBytes$3("message",e),{bytes:s,scalar:o}=schnorrGetExtPubKey$1(t),a=ensureBytes$3("auxRand",n,32),c=r.toBytes(o^num(taggedHash$1("BIP0340/aux",a))),l=taggedHash$1("BIP0340/nonce",c,s,i),{bytes:h,scalar:d}=schnorrGetExtPubKey$1(l),u=challenge$1(h,s,i),f=new Uint8Array(64);if(f.set(h,0),f.set(r.toBytes(r.create(d+u*o)),32),!schnorrVerify$1(f,i,s))throw new Error("sign: Invalid signature produced");return f}function schnorrVerify$1(e,t,n){const{Fn:r,BASE:i}=Pointk1,s=ensureBytes$3("signature",e,64),o=ensureBytes$3("message",t),a=ensureBytes$3("publicKey",n,32);try{const e=lift_x$1(num(a)),t=num(s.subarray(0,32));if(!inRange(t,_1n$a,secp256k1_CURVE.p))return!1;const n=num(s.subarray(32,64));if(!inRange(n,_1n$a,secp256k1_CURVE.n))return!1;const c=challenge$1(r.toBytes(t),pointToBytes$1(e),o),l=i.multiplyUnsafe(n).add(e.multiplyUnsafe(r.neg(c))),{x:h,y:d}=l.toAffine();return!(l.is0()||!hasEven(d)||h!==t)}catch(e){return!1}}const schnorr$1=(()=>{const e=(e=randomBytes$3(48))=>mapHashToField(e,secp256k1_CURVE.n);return secp256k1$2.utils.randomSecretKey,{keygen:function(t){const n=e(t);return{secretKey:n,publicKey:schnorrGetPublicKey$1(n)}},getPublicKey:schnorrGetPublicKey$1,sign:schnorrSign$1,verify:schnorrVerify$1,Point:Pointk1,utils:{randomSecretKey:e,randomPrivateKey:e,taggedHash:taggedHash$1,lift_x:lift_x$1,pointToBytes:pointToBytes$1,numberToBytesBE:numberToBytesBE$2,bytesToNumberBE:bytesToNumberBE$2,mod:mod$2},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})(),sha256$4=sha256$5;var dist={},LRUCache$1={},LRUCacheNode$1={};Object.defineProperty(LRUCacheNode$1,"__esModule",{value:!0}),LRUCacheNode$1.LRUCacheNode=void 0;class LRUCacheNode{constructor(e,t,n){const{entryExpirationTimeInMS:r=null,next:i=null,prev:s=null,onEntryEvicted:o,onEntryMarkedAsMostRecentlyUsed:a,clone:c,cloneFn:l}=null!=n?n:{};if("number"==typeof r&&(r<=0||Number.isNaN(r)))throw new Error("entryExpirationTimeInMS must either be null (no expiry) or greater than 0");this.clone=null!=c&&c,this.cloneFn=null!=l?l:this.defaultClone,this.key=e,this.internalValue=this.clone?this.cloneFn(t):t,this.created=Date.now(),this.entryExpirationTimeInMS=r,this.next=i,this.prev=s,this.onEntryEvicted=o,this.onEntryMarkedAsMostRecentlyUsed=a}get value(){return this.clone?this.cloneFn(this.internalValue):this.internalValue}get isExpired(){return"number"==typeof this.entryExpirationTimeInMS&&Date.now()-this.created>this.entryExpirationTimeInMS}invokeOnEvicted(){if(this.onEntryEvicted){const{key:e,value:t,isExpired:n}=this;this.onEntryEvicted({key:e,value:t,isExpired:n})}}invokeOnEntryMarkedAsMostRecentlyUsed(){if(this.onEntryMarkedAsMostRecentlyUsed){const{key:e,value:t}=this;this.onEntryMarkedAsMostRecentlyUsed({key:e,value:t})}}defaultClone(e){return"boolean"==typeof e||"string"==typeof e||"number"==typeof e?e:JSON.parse(JSON.stringify(e))}}LRUCacheNode$1.LRUCacheNode=LRUCacheNode,Object.defineProperty(LRUCache$1,"__esModule",{value:!0}),LRUCache$1.LRUCache=void 0;const LRUCacheNode_1=LRUCacheNode$1;class LRUCache{constructor(e){this.lookupTable=new Map,this.head=null,this.tail=null;const{maxSize:t=25,entryExpirationTimeInMS:n=null,onEntryEvicted:r,onEntryMarkedAsMostRecentlyUsed:i,cloneFn:s,clone:o}=null!=e?e:{};if(Number.isNaN(t)||t<=0)throw new Error("maxSize must be greater than 0.");if("number"==typeof n&&(n<=0||Number.isNaN(n)))throw new Error("entryExpirationTimeInMS must either be null (no expiry) or greater than 0");this.maxSizeInternal=t,this.entryExpirationTimeInMS=n,this.onEntryEvicted=r,this.onEntryMarkedAsMostRecentlyUsed=i,this.clone=o,this.cloneFn=s}get size(){return this.cleanCache(),this.lookupTable.size}get remainingSize(){return this.maxSizeInternal-this.size}get newest(){return this.head?this.head.isExpired?(this.removeNodeFromListAndLookupTable(this.head),this.newest):this.mapNodeToEntry(this.head):null}get oldest(){return this.tail?this.tail.isExpired?(this.removeNodeFromListAndLookupTable(this.tail),this.oldest):this.mapNodeToEntry(this.tail):null}get maxSize(){return this.maxSizeInternal}set maxSize(e){if(Number.isNaN(e)||e<=0)throw new Error("maxSize must be greater than 0.");this.maxSizeInternal=e,this.enforceSizeLimit()}set(e,t,n){const r=this.lookupTable.get(e);r&&this.removeNodeFromListAndLookupTable(r);const i=new LRUCacheNode_1.LRUCacheNode(e,t,{entryExpirationTimeInMS:this.entryExpirationTimeInMS,onEntryEvicted:this.onEntryEvicted,onEntryMarkedAsMostRecentlyUsed:this.onEntryMarkedAsMostRecentlyUsed,clone:this.clone,cloneFn:this.cloneFn,...n});return this.setNodeAsHead(i),this.lookupTable.set(e,i),this.enforceSizeLimit(),this}get(e){const t=this.lookupTable.get(e);return t?t.isExpired?(this.removeNodeFromListAndLookupTable(t),null):(this.setNodeAsHead(t),t.value):null}peek(e){const t=this.lookupTable.get(e);return t?t.isExpired?(this.removeNodeFromListAndLookupTable(t),null):t.value:null}delete(e){const t=this.lookupTable.get(e);return!!t&&this.removeNodeFromListAndLookupTable(t)}has(e){const t=this.lookupTable.get(e);return!!t&&(!t.isExpired||(this.removeNodeFromListAndLookupTable(t),!1))}clear(){this.head=null,this.tail=null,this.lookupTable.clear()}find(e){let t=this.head;for(;t;){if(t.isExpired){const e=t.next;this.removeNodeFromListAndLookupTable(t),t=e;continue}const n=this.mapNodeToEntry(t);if(e(n))return this.setNodeAsHead(t),n;t=t.next}return null}forEach(e){let t=this.head,n=0;for(;t;){if(t.isExpired){const e=t.next;this.removeNodeFromListAndLookupTable(t),t=e;continue}e(t.value,t.key,n),t=t.next,n++}}*values(){let e=this.head;for(;e;){if(e.isExpired){const t=e.next;this.removeNodeFromListAndLookupTable(e),e=t;continue}yield e.value,e=e.next}}*keys(){let e=this.head;for(;e;){if(e.isExpired){const t=e.next;this.removeNodeFromListAndLookupTable(e),e=t;continue}yield e.key,e=e.next}}*entries(){let e=this.head;for(;e;){if(e.isExpired){const t=e.next;this.removeNodeFromListAndLookupTable(e),e=t;continue}yield this.mapNodeToEntry(e),e=e.next}}*[Symbol.iterator](){let e=this.head;for(;e;){if(e.isExpired){const t=e.next;this.removeNodeFromListAndLookupTable(e),e=t;continue}yield this.mapNodeToEntry(e),e=e.next}}enforceSizeLimit(){let e=this.tail;for(;null!==e&&this.size>this.maxSizeInternal;){const t=e.prev;this.removeNodeFromListAndLookupTable(e),e=t}}mapNodeToEntry({key:e,value:t}){return{key:e,value:t}}setNodeAsHead(e){this.removeNodeFromList(e),this.head?(e.next=this.head,this.head.prev=e,this.head=e):(this.head=e,this.tail=e),e.invokeOnEntryMarkedAsMostRecentlyUsed()}removeNodeFromList(e){null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.head===e&&(this.head=e.next),this.tail===e&&(this.tail=e.prev),e.next=null,e.prev=null}removeNodeFromListAndLookupTable(e){return e.invokeOnEvicted(),this.removeNodeFromList(e),this.lookupTable.delete(e.key)}cleanCache(){if(!this.entryExpirationTimeInMS)return;const e=[];for(const t of this.lookupTable.values())t.isExpired&&e.push(t);e.forEach(e=>this.removeNodeFromListAndLookupTable(e))}}function pbkdf2Init$1(e,t,n,r){assert$4.hash(e);const i=checkOpts$3({dkLen:32,asyncTick:10},r),{c:s,dkLen:o,asyncTick:a}=i;if(assert$4.number(s),assert$4.number(o),assert$4.number(a),s<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const c=toBytes$7(t),l=toBytes$7(n),h=new Uint8Array(o),d=hmac$5.create(e,c),u=d._cloneInto().update(l);return{c:s,dkLen:o,asyncTick:a,DK:h,PRF:d,PRFSalt:u}}function pbkdf2Output$1(e,t,n,r,i){return e.destroy(),t.destroy(),r&&r.destroy(),i.fill(0),n}function pbkdf2$1(e,t,n,r){const{c:i,dkLen:s,DK:o,PRF:a,PRFSalt:c}=pbkdf2Init$1(e,t,n,r);let l;const h=new Uint8Array(4),d=createView$6(h),u=new Uint8Array(a.outputLen);for(let e=1,t=0;t<s;e++,t+=a.outputLen){const n=o.subarray(t,t+a.outputLen);d.setInt32(0,e,!1),(l=c._cloneInto(l)).update(h).digestInto(u),n.set(u.subarray(0,n.length));for(let e=1;e<i;e++){a._cloneInto(l).update(u).digestInto(u);for(let e=0;e<n.length;e++)n[e]^=u[e]}}return pbkdf2Output$1(a,c,o,l,u)}LRUCache$1.LRUCache=LRUCache,function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=commonjsGlobal&&commonjsGlobal.__exportStar||function(e,n){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(n,r)||t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(LRUCache$1,e)}(dist);const rotl$2=(e,t)=>e<<t|e>>>32-t;function XorAndSalsa(e,t,n,r,i,s){let o=e[t++]^n[r++],a=e[t++]^n[r++],c=e[t++]^n[r++],l=e[t++]^n[r++],h=e[t++]^n[r++],d=e[t++]^n[r++],u=e[t++]^n[r++],f=e[t++]^n[r++],p=e[t++]^n[r++],g=e[t++]^n[r++],y=e[t++]^n[r++],m=e[t++]^n[r++],b=e[t++]^n[r++],w=e[t++]^n[r++],v=e[t++]^n[r++],$=e[t++]^n[r++],E=o,k=a,x=c,_=l,S=h,C=d,A=u,N=f,R=p,T=g,B=y,L=m,I=b,U=w,O=v,P=$;for(let e=0;e<8;e+=2)S^=rotl$2(E+I|0,7),R^=rotl$2(S+E|0,9),I^=rotl$2(R+S|0,13),E^=rotl$2(I+R|0,18),T^=rotl$2(C+k|0,7),U^=rotl$2(T+C|0,9),k^=rotl$2(U+T|0,13),C^=rotl$2(k+U|0,18),O^=rotl$2(B+A|0,7),x^=rotl$2(O+B|0,9),A^=rotl$2(x+O|0,13),B^=rotl$2(A+x|0,18),_^=rotl$2(P+L|0,7),N^=rotl$2(_+P|0,9),L^=rotl$2(N+_|0,13),P^=rotl$2(L+N|0,18),k^=rotl$2(E+_|0,7),x^=rotl$2(k+E|0,9),_^=rotl$2(x+k|0,13),E^=rotl$2(_+x|0,18),A^=rotl$2(C+S|0,7),N^=rotl$2(A+C|0,9),S^=rotl$2(N+A|0,13),C^=rotl$2(S+N|0,18),L^=rotl$2(B+T|0,7),R^=rotl$2(L+B|0,9),T^=rotl$2(R+L|0,13),B^=rotl$2(T+R|0,18),I^=rotl$2(P+O|0,7),U^=rotl$2(I+P|0,9),O^=rotl$2(U+I|0,13),P^=rotl$2(O+U|0,18);i[s++]=o+E|0,i[s++]=a+k|0,i[s++]=c+x|0,i[s++]=l+_|0,i[s++]=h+S|0,i[s++]=d+C|0,i[s++]=u+A|0,i[s++]=f+N|0,i[s++]=p+R|0,i[s++]=g+T|0,i[s++]=y+B|0,i[s++]=m+L|0,i[s++]=b+I|0,i[s++]=w+U|0,i[s++]=v+O|0,i[s++]=$+P|0}function BlockMix(e,t,n,r,i){let s=r+0,o=r+16*i;for(let r=0;r<16;r++)n[o+r]=e[t+16*(2*i-1)+r];for(let r=0;r<i;r++,s+=16,t+=16)XorAndSalsa(n,o,e,t,n,s),r>0&&(o+=16),XorAndSalsa(n,s,e,t+=16,n,o)}function scryptInit(e,t,n){const r=checkOpts$3({dkLen:32,asyncTick:10,maxmem:1073742848},n),{N:i,r:s,p:o,dkLen:a,asyncTick:c,maxmem:l,onProgress:h}=r;if(assert$4.number(i),assert$4.number(s),assert$4.number(o),assert$4.number(a),assert$4.number(c),assert$4.number(l),void 0!==h&&"function"!=typeof h)throw new Error("progressCb should be function");const d=128*s,u=d/4;if(i<=1||i&i-1||i>=2**(d/8)||i>2**32)throw new Error("Scrypt: N must be larger than 1, a power of 2, less than 2^(128 * r / 8) and less than 2^32");if(o<0||o>137438953440/d)throw new Error("Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)");if(a<0||a>137438953440)throw new Error("Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32");const f=d*(i+o);if(f>l)throw new Error(`Scrypt: parameters too large, ${f} (128 * r * (N + p)) > ${l} (maxmem)`);const p=pbkdf2$1(sha256$6,e,t,{c:1,dkLen:d*o}),g=u32$2(p),y=u32$2(new Uint8Array(d*i)),m=u32$2(new Uint8Array(d));let b=()=>{};if(h){const e=2*i*o,t=Math.max(Math.floor(e/1e4),1);let n=0;b=()=>{n++,!h||n%t&&n!==e||h(n/e)}}return{N:i,r:s,p:o,dkLen:a,blockSize32:u,V:y,B32:g,B:p,tmp:m,blockMixCb:b,asyncTick:c}}function scryptOutput(e,t,n,r,i){const s=pbkdf2$1(sha256$6,e,n,{c:1,dkLen:t});return n.fill(0),r.fill(0),i.fill(0),s}function scrypt(e,t,n){const{N:r,r:i,p:s,dkLen:o,blockSize32:a,V:c,B32:l,B:h,tmp:d,blockMixCb:u}=scryptInit(e,t,n);for(let e=0;e<s;e++){const t=a*e;for(let e=0;e<a;e++)c[e]=l[t+e];for(let e=0,t=0;e<r-1;e++)BlockMix(c,t,c,t+=a,i),u();BlockMix(c,(r-1)*a,l,t,i),u();for(let e=0;e<r;e++){const e=l[t+a-16]%r;for(let n=0;n<a;n++)d[n]=l[t+n]^c[e*a+n];BlockMix(d,0,l,t,i),u()}}return scryptOutput(e,o,h,c,d)}var Bech32MaxSize$2=5e3;function encodeBech32$2(e,t){let n=bech32$2.toWords(t);return bech32$2.encode(e,n,Bech32MaxSize$2)}function encodeBytes$2(e,t){return encodeBech32$2(e,t)}function encrypt$2(e,t,n=16,r=2){let i=randomBytes$4(16),s=2**n,o=scrypt(t.normalize("NFKC"),i,{N:s,r:8,p:1,dkLen:32}),a=randomBytes$4(24),c=Uint8Array.from([r]),l=xchacha20poly1305(o,a,c).encrypt(e);return encodeBytes$2("ncryptsec",concatBytes$6(Uint8Array.from([2]),Uint8Array.from([n]),i,a,c,l))}function decrypt$2(e,t){let{prefix:n,words:r}=bech32$2.decode(e,Bech32MaxSize$2);if("ncryptsec"!==n)throw new Error(`invalid prefix ${n}, expected 'ncryptsec'`);let i=new Uint8Array(bech32$2.fromWords(r)),s=i[0];if(2!==s)throw new Error(`invalid version ${s}, expected 0x02`);let o=2**i[1],a=i.slice(2,18),c=i.slice(18,42),l=i[42],h=Uint8Array.from([l]),d=i.slice(43),u=scrypt(t.normalize("NFKC"),a,{N:o,r:8,p:1,dkLen:32});return xchacha20poly1305(u,c,h).decrypt(d)}var nip49_star=Object.freeze({__proto__:null,decrypt:decrypt$2,encrypt:encrypt$2}),utf8Decoder$1=new TextDecoder("utf-8"),utf8Encoder$1=new TextEncoder,NostrTypeGuard={isNProfile:e=>/^nprofile1[a-z\d]+$/.test(e||""),isNEvent:e=>/^nevent1[a-z\d]+$/.test(e||""),isNAddr:e=>/^naddr1[a-z\d]+$/.test(e||""),isNSec:e=>/^nsec1[a-z\d]{58}$/.test(e||""),isNPub:e=>/^npub1[a-z\d]{58}$/.test(e||""),isNote:e=>/^note1[a-z\d]+$/.test(e||""),isNcryptsec:e=>/^ncryptsec1[a-z\d]+$/.test(e||"")},Bech32MaxSize$1=5e3,BECH32_REGEX$2=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function integerToUint8Array$1(e){const t=new Uint8Array(4);return t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t}function decodeNostrURI(e){try{return e.startsWith("nostr:")&&(e=e.substring(6)),decode$1(e)}catch(e){return{type:"invalid",data:null}}}function decode$1(e){let{prefix:t,words:n}=bech32$2.decode(e,Bech32MaxSize$1),r=new Uint8Array(bech32$2.fromWords(n));switch(t){case"nprofile":{let e=parseTLV$1(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:bytesToHex$6(e[0][0]),relays:e[1]?e[1].map(e=>utf8Decoder$1.decode(e)):[]}}}case"nevent":{let e=parseTLV$1(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(e[3]&&4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:bytesToHex$6(e[0][0]),relays:e[1]?e[1].map(e=>utf8Decoder$1.decode(e)):[],author:e[2]?.[0]?bytesToHex$6(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(bytesToHex$6(e[3][0]),16):void 0}}}case"naddr":{let e=parseTLV$1(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:utf8Decoder$1.decode(e[0][0]),pubkey:bytesToHex$6(e[2][0]),kind:parseInt(bytesToHex$6(e[3][0]),16),relays:e[1]?e[1].map(e=>utf8Decoder$1.decode(e)):[]}}}case"nsec":return{type:t,data:r};case"npub":case"note":return{type:t,data:bytesToHex$6(r)};default:throw new Error(`unknown prefix ${t}`)}}function parseTLV$1(e){let t={},n=e;for(;n.length>0;){let e=n[0],r=n[1],i=n.slice(2,2+r);if(n=n.slice(2+r),i.length<r)throw new Error(`not enough data to read on TLV ${e}`);t[e]=t[e]||[],t[e].push(i)}return t}function nsecEncode$1(e){return encodeBytes$1("nsec",e)}function npubEncode$1(e){return encodeBytes$1("npub",hexToBytes$6(e))}function noteEncode$1(e){return encodeBytes$1("note",hexToBytes$6(e))}function encodeBech32$1(e,t){let n=bech32$2.toWords(t);return bech32$2.encode(e,n,Bech32MaxSize$1)}function encodeBytes$1(e,t){return encodeBech32$1(e,t)}function nprofileEncode$1(e){return encodeBech32$1("nprofile",encodeTLV$1({0:[hexToBytes$6(e.pubkey)],1:(e.relays||[]).map(e=>utf8Encoder$1.encode(e))}))}function neventEncode$1(e){let t;return void 0!==e.kind&&(t=integerToUint8Array$1(e.kind)),encodeBech32$1("nevent",encodeTLV$1({0:[hexToBytes$6(e.id)],1:(e.relays||[]).map(e=>utf8Encoder$1.encode(e)),2:e.author?[hexToBytes$6(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function naddrEncode$1(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),encodeBech32$1("naddr",encodeTLV$1({0:[utf8Encoder$1.encode(e.identifier)],1:(e.relays||[]).map(e=>utf8Encoder$1.encode(e)),2:[hexToBytes$6(e.pubkey)],3:[new Uint8Array(t)]}))}function encodeTLV$1(e){let t=[];return Object.entries(e).reverse().forEach(([e,n])=>{n.forEach(n=>{let r=new Uint8Array(n.length+2);r.set([parseInt(e)],0),r.set([n.length],1),r.set(n,2),t.push(r)})}),concatBytes$6(...t)}var nip19_star=Object.freeze({__proto__:null,BECH32_REGEX:BECH32_REGEX$2,Bech32MaxSize:Bech32MaxSize$1,NostrTypeGuard:NostrTypeGuard,decode:decode$1,decodeNostrURI:decodeNostrURI,encodeBytes:encodeBytes$1,naddrEncode:naddrEncode$1,neventEncode:neventEncode$1,noteEncode:noteEncode$1,nprofileEncode:nprofileEncode$1,npubEncode:npubEncode$1,nsecEncode:nsecEncode$1}),lib={};!function(e){function t(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function n(...e){const t=(e,t)=>n=>e(t(n)),n=Array.from(e).reverse().reduce((e,n)=>e?t(e,n.encode):n.encode,void 0),r=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:r}}function r(e){return{encode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("alphabet.encode input should be an array of numbers");return n.map(n=>{if(t(n),n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map(t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})}}}function i(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function s(e,n="="){if(t(e),"string"!=typeof n)throw new Error("padding chr should be string");return{encode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;t.length*e%8;)t.push(n);return t},decode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let r=t.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&t[r-1]===n;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return t.slice(0,r)}}}function o(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function a(e,n,r){if(n<2)throw new Error(`convertRadix: wrong from=${n}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let i=0;const s=[],o=Array.from(e);for(o.forEach(e=>{if(t(e),e<0||e>=n)throw new Error(`Wrong integer: ${e}`)});;){let e=0,t=!0;for(let s=i;s<o.length;s++){const a=o[s],c=n*e+a;if(!Number.isSafeInteger(c)||n*e/n!==e||c-a!==n*e)throw new Error("convertRadix: carry overflow");if(e=c%r,o[s]=Math.floor(c/r),!Number.isSafeInteger(o[s])||o[s]*r+e!==c)throw new Error("convertRadix: carry overflow");t&&(o[s]?t=!1:i=s)}if(s.push(e),t)break}for(let t=0;t<e.length-1&&0===e[t];t++)s.push(0);return s.reverse()}
8
+ function getHash(e){return{hash:e,hmac:(t,...n)=>hmac$2(e,t,concatBytes$3(...n)),randomBytes:randomBytes$2}}function createCurve(e,t){const n=t=>weierstrass({...e,...getHash(t)});return Object.freeze({...n(t),create:n})}
9
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */hmac$2.create=(e,t)=>new HMAC$2(e,t);const secp256k1P=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n=BigInt(1),_2n=BigInt(2),divNearest=(e,t)=>(e+t/_2n)/t;function sqrtMod(e){const t=secp256k1P,n=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),l=BigInt(88),c=e*e*e%t,d=c*c*e%t,h=pow2(d,n,t)*d%t,u=pow2(h,n,t)*d%t,p=pow2(u,_2n,t)*c%t,f=pow2(p,o,t)*p%t,g=pow2(f,s,t)*f%t,m=pow2(g,a,t)*g%t,b=pow2(m,l,t)*m%t,y=pow2(b,a,t)*g%t,w=pow2(y,n,t)*d%t,v=pow2(w,i,t)*f%t,k=pow2(v,r,t)*c%t,x=pow2(k,_2n,t);if(!Fp.eql(Fp.sqr(x),e))throw new Error("Cannot find square root");return x}const Fp=Field(secp256k1P,void 0,void 0,{sqrt:sqrtMod}),secp256k1=createCurve({a:BigInt(0),b:BigInt(7),Fp:Fp,n:secp256k1N,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=secp256k1N,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-_1n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,i=BigInt("0x100000000000000000000000000000000"),a=divNearest(s*e,t),l=divNearest(-r*e,t);let c=mod(e-a*n-l*o,t),d=mod(-a*r-l*s,t);const h=c>i,u=d>i;if(h&&(c=t-c),u&&(d=t-d),c>i||d>i)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:h,k1:c,k2neg:u,k2:d}}}},sha256$2),_0n=BigInt(0),fe=e=>"bigint"==typeof e&&_0n<e&&e<secp256k1P,ge=e=>"bigint"==typeof e&&_0n<e&&e<secp256k1N,TAGGED_HASH_PREFIXES={};function taggedHash(e,...t){let n=TAGGED_HASH_PREFIXES[e];if(void 0===n){const t=sha256$2(Uint8Array.from(e,(e=>e.charCodeAt(0))));n=concatBytes$2(t,t),TAGGED_HASH_PREFIXES[e]=n}return sha256$2(concatBytes$2(n,...t))}const pointToBytes=e=>e.toRawBytes(!0).slice(1),numTo32b=e=>numberToBytesBE(e,32),modP=e=>mod(e,secp256k1P),modN=e=>mod(e,secp256k1N),Point$1=secp256k1.ProjectivePoint,GmulAdd=(e,t,n)=>Point$1.BASE.multiplyAndAddUnsafe(e,t,n);function schnorrGetExtPubKey(e){let t=secp256k1.utils.normPrivateKeyToScalar(e),n=Point$1.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:modN(-t),bytes:pointToBytes(n)}}function lift_x(e){if(!fe(e))throw new Error("bad x: need 0 < x < p");const t=modP(e*e);let n=sqrtMod(modP(t*e+BigInt(7)));n%_2n!==_0n&&(n=modP(-n));const r=new Point$1(e,n,_1n);return r.assertValidity(),r}function challenge(...e){return modN(bytesToNumberBE(taggedHash("BIP0340/challenge",...e)))}function schnorrGetPublicKey(e){return schnorrGetExtPubKey(e).bytes}function schnorrSign(e,t,n=randomBytes$2(32)){const r=ensureBytes$1("message",e),{bytes:o,scalar:s}=schnorrGetExtPubKey(t),i=ensureBytes$1("auxRand",n,32),a=numTo32b(s^bytesToNumberBE(taggedHash("BIP0340/aux",i))),l=taggedHash("BIP0340/nonce",a,o,r),c=modN(bytesToNumberBE(l));if(c===_0n)throw new Error("sign failed: k is zero");const{bytes:d,scalar:h}=schnorrGetExtPubKey(c),u=challenge(d,o,r),p=new Uint8Array(64);if(p.set(d,0),p.set(numTo32b(modN(h+u*s)),32),!schnorrVerify(p,r,o))throw new Error("sign: Invalid signature produced");return p}function schnorrVerify(e,t,n){const r=ensureBytes$1("signature",e,64),o=ensureBytes$1("message",t),s=ensureBytes$1("publicKey",n,32);try{const e=lift_x(bytesToNumberBE(s)),t=bytesToNumberBE(r.subarray(0,32));if(!fe(t))return!1;const n=bytesToNumberBE(r.subarray(32,64));if(!ge(n))return!1;const i=challenge(numTo32b(t),pointToBytes(e),o),a=GmulAdd(e,n,modN(-i));return!(!a||!a.hasEvenY()||a.toAffine().x!==t)}catch(e){return!1}}const schnorr=(()=>({getPublicKey:schnorrGetPublicKey,sign:schnorrSign,verify:schnorrVerify,utils:{randomPrivateKey:secp256k1.utils.randomPrivateKey,lift_x:lift_x,pointToBytes:pointToBytes,numberToBytesBE:numberToBytesBE,bytesToNumberBE:bytesToNumberBE,taggedHash:taggedHash,mod:mod}}))(),crypto$2="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,u8a$1=e=>e instanceof Uint8Array,createView$1=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),rotr$1=(e,t)=>e<<32-t|e>>>t,isLE$2=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!isLE$2)throw new Error("Non little-endian hardware is not supported");const hexes$1=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function bytesToHex$1(e){if(!u8a$1(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=hexes$1[e[n]];return t}function hexToBytes$1(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const r=2*t,o=e.slice(r,r+2),s=Number.parseInt(o,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[t]=s}return n}function utf8ToBytes$2(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function toBytes$2(e){if("string"==typeof e&&(e=utf8ToBytes$2(e)),!u8a$1(e))throw new Error("expected Uint8Array, got "+typeof e);return e}function concatBytes$1(...e){const t=new Uint8Array(e.reduce(((e,t)=>e+t.length),0));let n=0;return e.forEach((e=>{if(!u8a$1(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length})),t}let Hash$1=class{clone(){return this._cloneInto()}};function wrapConstructor$1(e){const t=t=>e().update(toBytes$2(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function randomBytes$1(e=32){if(crypto$2&&"function"==typeof crypto$2.getRandomValues)return crypto$2.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function number$2(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function bool$2(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)}function bytes$2(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function hash$2(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");number$2(e.outputLen),number$2(e.blockLen)}function exists$2(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output$2(e,t){bytes$2(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const assert$2={number:number$2,bool:bool$2,bytes:bytes$2,hash:hash$2,exists:exists$2,output:output$2};function setBigUint64$1(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),a=Number(n&s),l=r?4:0,c=r?0:4;e.setUint32(t+l,i,r),e.setUint32(t+c,a,r)}let SHA2$1=class extends Hash$1{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=createView$1(this.buffer)}update(e){assert$2.exists(this);const{view:t,buffer:n,blockLen:r}=this,o=(e=toBytes$2(e)).length;for(let s=0;s<o;){const i=Math.min(r-this.pos,o-s);if(i!==r)n.set(e.subarray(s,s+i),this.pos),this.pos+=i,s+=i,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=createView$1(e);for(;r<=o-s;s+=r)this.process(t,s)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){assert$2.exists(this),assert$2.output(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>r-s&&(this.process(n,0),s=0);for(let e=s;e<r;e++)t[e]=0;setBigUint64$1(n,r-8,BigInt(8*this.length),o),this.process(n,0);const i=createView$1(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)i.setUint32(4*e,c[e],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:o,destroyed:s,pos:i}=this;return e.length=r,e.pos=i,e.finished=o,e.destroyed=s,r%t&&e.buffer.set(n),e}};const Chi$1=(e,t,n)=>e&t^~e&n,Maj$1=(e,t,n)=>e&t^e&n^t&n,SHA256_K$1=new Uint32Array([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]),IV$1=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W$1=new Uint32Array(64);let SHA256$1=class extends SHA2$1{constructor(){super(64,32,8,!1),this.A=0|IV$1[0],this.B=0|IV$1[1],this.C=0|IV$1[2],this.D=0|IV$1[3],this.E=0|IV$1[4],this.F=0|IV$1[5],this.G=0|IV$1[6],this.H=0|IV$1[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:s,G:i,H:a}=this;return[e,t,n,r,o,s,i,a]}set(e,t,n,r,o,s,i,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|s,this.G=0|i,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)SHA256_W$1[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=SHA256_W$1[e-15],n=SHA256_W$1[e-2],r=rotr$1(t,7)^rotr$1(t,18)^t>>>3,o=rotr$1(n,17)^rotr$1(n,19)^n>>>10;SHA256_W$1[e]=o+SHA256_W$1[e-7]+r+SHA256_W$1[e-16]|0}let{A:n,B:r,C:o,D:s,E:i,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){const t=c+(rotr$1(i,6)^rotr$1(i,11)^rotr$1(i,25))+Chi$1(i,a,l)+SHA256_K$1[e]+SHA256_W$1[e]|0,d=(rotr$1(n,2)^rotr$1(n,13)^rotr$1(n,22))+Maj$1(n,r,o)|0;c=l,l=a,a=i,i=s+t|0,s=o,o=r,r=n,n=t+d|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,s=s+this.D|0,i=i+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,o,s,i,a,l,c)}roundClean(){SHA256_W$1.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};class SHA224 extends SHA256$1{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const sha256$1=wrapConstructor$1((()=>new SHA256$1));
21
10
  /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
22
- Object.defineProperty(e,"__esModule",{value:!0}),e.bytes=e.stringToBytes=e.str=e.bytesToString=e.hex=e.utf8=e.bech32m=e.bech32=e.base58check=e.base58xmr=e.base58xrp=e.base58flickr=e.base58=e.base64url=e.base64=e.base32crockford=e.base32hex=e.base32=e.base16=e.utils=e.assertNumber=void 0,e.assertNumber=t;const c=(e,t)=>t?c(t,e%t):e,l=(e,t)=>e+(t-c(e,t));function h(e,n,r,i){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(n<=0||n>32)throw new Error(`convertRadix2: wrong from=${n}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(l(n,r)>32)throw new Error(`convertRadix2: carry overflow from=${n} to=${r} carryBits=${l(n,r)}`);let s=0,o=0;const a=2**r-1,c=[];for(const i of e){if(t(i),i>=2**n)throw new Error(`convertRadix2: invalid data word=${i} from=${n}`);if(s=s<<n|i,o+n>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${n}`);for(o+=n;o>=r;o-=r)c.push((s>>o-r&a)>>>0);s&=2**o-1}if(s=s<<r-o&a,!i&&o>=n)throw new Error("Excess padding");if(!i&&s)throw new Error(`Non-zero padding: ${s}`);return i&&o>0&&c.push(s>>>0),c}function d(e){return t(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return a(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(a(t,e,256))}}}function u(e,n=!1){if(t(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(l(8,e)>32||l(e,8)>32)throw new Error("radix2: carry overflow");return{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return h(Array.from(t),8,e,!n)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(h(t,e,8,n))}}}function f(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function p(e,n){if(t(e),"function"!=typeof n)throw new Error("checksum fn should be function");return{encode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const r=n(t).slice(0,e),i=new Uint8Array(t.length+e);return i.set(t),i.set(r,t.length),i},decode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const r=t.slice(0,-e),i=n(r).slice(0,e),s=t.slice(-e);for(let t=0;t<e;t++)if(i[t]!==s[t])throw new Error("Invalid checksum");return r}}}e.utils={alphabet:r,chain:n,checksum:p,radix:d,radix2:u,join:i,padding:s},e.base16=n(u(4),r("0123456789ABCDEF"),i("")),e.base32=n(u(5),r("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),s(5),i("")),e.base32hex=n(u(5),r("0123456789ABCDEFGHIJKLMNOPQRSTUV"),s(5),i("")),e.base32crockford=n(u(5),r("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),i(""),o(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),e.base64=n(u(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),s(6),i("")),e.base64url=n(u(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),s(6),i(""));const g=e=>n(d(58),r(e),i(""));e.base58=g("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),e.base58flickr=g("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),e.base58xrp=g("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const y=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let n="";for(let r=0;r<t.length;r+=8){const i=t.subarray(r,r+8);n+=e.base58.encode(i).padStart(y[i.length],"1")}return n},decode(t){let n=[];for(let r=0;r<t.length;r+=11){const i=t.slice(r,r+11),s=y.indexOf(i.length),o=e.base58.decode(i);for(let e=0;e<o.length-s;e++)if(0!==o[e])throw new Error("base58xmr: wrong padding");n=n.concat(Array.from(o.slice(o.length-s)))}return Uint8Array.from(n)}};e.base58check=t=>n(p(4,e=>t(t(e))),e.base58);const m=n(r("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),i("")),b=[996825010,642813549,513874426,1027748829,705979059];function w(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e<b.length;e++)1==(t>>e&1)&&(n^=b[e]);return n}function v(e,t,n=1){const r=e.length;let i=1;for(let t=0;t<r;t++){const n=e.charCodeAt(t);if(n<33||n>126)throw new Error(`Invalid prefix (${e})`);i=w(i)^n>>5}i=w(i);for(let t=0;t<r;t++)i=w(i)^31&e.charCodeAt(t);for(let e of t)i=w(i)^e;for(let e=0;e<6;e++)i=w(i);return i^=n,m.encode(h([i%2**30],30,5,!1))}function $(e){const t="bech32"===e?1:734539939,n=u(5),r=n.decode,i=n.encode,s=f(r);function o(e,n=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==n&&e.length>n)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=(e=r).lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const s=e.slice(0,i),o=e.slice(i+1);if(o.length<6)throw new Error("Data must be at least 6 characters long");const a=m.decode(o).slice(0,-6),c=v(s,a,t);if(!o.endsWith(c))throw new Error(`Invalid checksum in ${e}: expected "${c}"`);return{prefix:s,words:a}}return{encode:function(e,n,r=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const i=e.length+7+n.length;if(!1!==r&&i>r)throw new TypeError(`Length ${i} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${m.encode(n)}${v(e,n,t)}`},decode:o,decodeToBytes:function(e){const{prefix:t,words:n}=o(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:f(o),fromWords:r,fromWordsUnsafe:s,toWords:i}}e.bech32=$("bech32"),e.bech32m=$("bech32m"),e.utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},e.hex=n(u(4),r("0123456789abcdef"),i(""),o(e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));const E={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},k=`Invalid encoding type. Available types: ${Object.keys(E).join(", ")}`;e.bytesToString=(e,t)=>{if("string"!=typeof e||!E.hasOwnProperty(e))throw new TypeError(k);if(!(t instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return E[e].encode(t)},e.str=e.bytesToString;e.stringToBytes=(e,t)=>{if(!E.hasOwnProperty(e))throw new TypeError(k);if("string"!=typeof t)throw new TypeError("stringToBytes() expects string");return E[e].decode(t)},e.bytes=e.stringToBytes}(lib);const{bech32:bech32$1,hex:hex$1,utf8:utf8$1}=lib;BigInt(1e3),BigInt(1e6),BigInt(1e9),BigInt(1e12),BigInt("2100000000000000000"),BigInt(1e11);const TAGCODES={payment_hash:1,payment_secret:16,description:13,payee:19,description_hash:23,expiry:6,min_final_cltv_expiry:24,fallback_address:9,route_hint:3,feature_bits:5,metadata:27};for(let e=0,t=Object.keys(TAGCODES);e<t.length;e++)t[e],TAGCODES[t[e]].toString();var __defProp$1=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__copyProps=(e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of __getOwnPropNames(t))__hasOwnProp.call(e,i)||i===n||__defProp$1(e,i,{get:()=>t[i],enumerable:!(r=__getOwnPropDesc(t,i))||r.enumerable});return e},__reExport=(e,t,n)=>(__copyProps(e,t,"default"),n);function getRelaysForSync(e,t,n="write"){if(!e.outboxTracker)return;const r=e.outboxTracker.data.get(t);return r?"write"===n?r.writeRelays:r.readRelays:void 0}async function getWriteRelaysFor(e,t,n="write"){if(e.outboxTracker)return e.outboxTracker.data.has(t)||await e.outboxTracker.trackUsers([t]),getRelaysForSync(e,t,n)}function getTopRelaysForAuthors(e,t){const n=new Map;t.forEach(t=>{const r=getRelaysForSync(e,t);r&&r.forEach(e=>{const t=n.get(e)||0;n.set(e,t+1)})});return Array.from(n.entries()).sort((e,t)=>t[1]-e[1]).map(e=>e[0])}function getAllRelaysForAllPubkeys(e,t,n="read"){const r=new Map,i=new Set;return t.forEach(t=>{const s=getRelaysForSync(e,t,n);s&&s.size>0?(s.forEach(e=>{(r.get(e)||new Set).add(t)}),r.set(t,s)):i.add(t)}),{pubkeysToRelays:r,authorsMissingRelays:i}}function chooseRelayCombinationForPubkeys(e,t,n,{count:r,preferredRelays:i}={}){r??=2,i??=new Set;const s=e.pool,o=s.connectedRelays();o.forEach(e=>{i?.add(e.url)});const a=new Map,{pubkeysToRelays:c,authorsMissingRelays:l}=getAllRelaysForAllPubkeys(e,t,n),h=getTopRelaysForAuthors(e,t),d=(e,t)=>{const n=a.get(t)||[];n.push(e),a.set(t,n)};for(const[e,t]of c.entries()){let n=r;const i=new Set;for(const r of o)t.has(r.url)&&(d(e,r.url),i.add(r.url),n--);for(const r of t)i.has(r)||a.has(r)&&(d(e,r),i.add(r),n--);if(!(n<=0))for(const r of h){if(n<=0)break;i.has(r)||t.has(r)&&(d(e,r),i.add(r),n--)}}for(const e of l)s.permanentAndConnectedRelays().forEach(t=>{const n=a.get(t.url)||[];n.push(e),a.set(t.url,n)});return a}function getRelaysForFilterWithAuthors(e,t,n=2){return chooseRelayCombinationForPubkeys(e,t,"write",{count:n})}function tryNormalizeRelayUrl(e){try{return normalizeRelayUrl(e)}catch{return}}function normalizeRelayUrl(e){let t=normalizeUrl(e,{stripAuthentication:!1,stripWWW:!1,stripHash:!0});return t.endsWith("/")||(t+="/"),t}function normalize$2(e){const t=new Set;for(const n of e)try{t.add(normalizeRelayUrl(n))}catch{}return Array.from(t)}var DATA_URL_DEFAULT_MIME_TYPE="text/plain",DATA_URL_DEFAULT_CHARSET="us-ascii",testParameter=(e,t)=>t.some(t=>t instanceof RegExp?t.test(e):t===e),supportedProtocols=new Set(["https:","http:","file:"]),hasCustomProtocol=e=>{try{const{protocol:t}=new URL(e);return t.endsWith(":")&&!t.includes(".")&&!supportedProtocols.has(t)}catch{return!1}},normalizeDataURL=(e,{stripHash:t})=>{const n=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(e);if(!n)throw new Error(`Invalid URL: ${e}`);const r=n.groups?.type??"",i=n.groups?.data??"";let s=n.groups?.hash??"";const o=r.split(";");s=t?"":s;let a=!1;"base64"===o[o.length-1]&&(o.pop(),a=!0);const c=o.shift()?.toLowerCase()??"",l=[...o.map(e=>{let[t,n=""]=e.split("=").map(e=>e.trim());return"charset"===t&&(n=n.toLowerCase(),n===DATA_URL_DEFAULT_CHARSET)?"":`${t}${n?`=${n}`:""}`}).filter(Boolean)];return a&&l.push("base64"),(l.length>0||c&&c!==DATA_URL_DEFAULT_MIME_TYPE)&&l.unshift(c),`data:${l.join(";")},${a?i.trim():i}${s?`#${s}`:""}`};function normalizeUrl(e,t={}){if("string"!=typeof(t={defaultProtocol:"http",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,removeExplicitPort:!1,sortQueryParameters:!0,...t}).defaultProtocol||t.defaultProtocol.endsWith(":")||(t.defaultProtocol=`${t.defaultProtocol}:`),e=e.trim(),/^data:/i.test(e))return normalizeDataURL(e,t);if(hasCustomProtocol(e))return e;const n=e.startsWith("//");!n&&/^\.*\//.test(e)||(e=e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));const r=new URL(e);if(r.hostname=r.hostname.toLowerCase(),t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&"https:"===r.protocol&&(r.protocol="http:"),t.forceHttps&&"http:"===r.protocol&&(r.protocol="https:"),t.stripAuthentication&&(r.username="",r.password=""),t.stripHash?r.hash="":t.stripTextFragment&&(r.hash=r.hash.replace(/#?:~:text.*?$/i,"")),r.pathname){const e=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g;let t=0,n="";for(;;){const i=e.exec(r.pathname);if(!i)break;const s=i[0],o=i.index;n+=r.pathname.slice(t,o).replace(/\/{2,}/g,"/"),n+=s,t=o+s.length}n+=r.pathname.slice(t,r.pathname.length).replace(/\/{2,}/g,"/"),r.pathname=n}if(r.pathname)try{r.pathname=decodeURI(r.pathname)}catch{}if(!0===t.removeDirectoryIndex&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let e=r.pathname.split("/");const n=e[e.length-1];testParameter(n,t.removeDirectoryIndex)&&(e=e.slice(0,-1),r.pathname=`${e.slice(1).join("/")}/`)}if(r.hostname&&(r.hostname=r.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(r.hostname)&&(r.hostname=r.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(const e of[...r.searchParams.keys()])testParameter(e,t.removeQueryParameters)&&r.searchParams.delete(e);if(Array.isArray(t.keepQueryParameters)||!0!==t.removeQueryParameters||(r.search=""),Array.isArray(t.keepQueryParameters)&&t.keepQueryParameters.length>0)for(const e of[...r.searchParams.keys()])testParameter(e,t.keepQueryParameters)||r.searchParams.delete(e);if(t.sortQueryParameters){r.searchParams.sort();try{r.search=decodeURIComponent(r.search)}catch{}}t.removeTrailingSlash&&(r.pathname=r.pathname.replace(/\/$/,"")),t.removeExplicitPort&&r.port&&(r.port="");const i=e;return e=r.toString(),t.removeSingleSlash||"/"!==r.pathname||i.endsWith("/")||""!==r.hash||(e=e.replace(/\/$/,"")),(t.removeTrailingSlash||"/"===r.pathname)&&""===r.hash&&t.removeSingleSlash&&(e=e.replace(/\/$/,"")),n&&!t.normalizeProtocol&&(e=e.replace(/^http:\/\//,"//")),t.stripProtocol&&(e=e.replace(/^(?:https?:)?\/\//,"")),e}var NDKRelayKeepalive=class{constructor(e=3e4,t){this.onSilenceDetected=t,this.timeout=e}lastActivity=Date.now();timer;timeout;isRunning=!1;recordActivity(){this.lastActivity=Date.now(),this.isRunning&&this.resetTimer()}start(){this.isRunning||(this.isRunning=!0,this.lastActivity=Date.now(),this.resetTimer())}stop(){this.isRunning=!1,this.timer&&(clearTimeout(this.timer),this.timer=void 0)}resetTimer(){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{const e=Date.now()-this.lastActivity;if(e>=this.timeout)this.onSilenceDetected();else{const t=this.timeout-e;this.timer=setTimeout(()=>{this.onSilenceDetected()},t)}},this.timeout)}};async function probeRelayConnection(e){const t=`probe-${Math.random().toString(36).substring(7)}`;return new Promise(n=>{let r=!1;const i=setTimeout(()=>{r||(r=!0,e.send(["CLOSE",t]),n(!1))},5e3);e.once("message",()=>{r||(r=!0,clearTimeout(i),e.send(["CLOSE",t]),n(!0))}),e.send(["REQ",t,{kinds:[99999],limit:0}])})}var MAX_RECONNECT_ATTEMPTS=5,FLAPPING_THRESHOLD_MS=1e3,NDKRelayConnectivity=class{ndkRelay;ws;_status;timeoutMs;connectedAt;_connectionStats={attempts:0,success:0,durations:[]};debug;netDebug;connectTimeout;reconnectTimeout;ndk;openSubs=new Map;openCountRequests=new Map;openEventPublishes=new Map;pendingAuthPublishes=new Map;serial=0;baseEoseTimeout=4400;keepalive;wsStateMonitor;sleepDetector;lastSleepCheck=Date.now();lastMessageSent=Date.now();wasIdle=!1;constructor(e,t){this.ndkRelay=e,this._status=1;const n=Math.floor(1e3*Math.random());this.debug=this.ndkRelay.debug.extend(`connectivity${n}`),this.ndk=t,this.setupMonitoring()}setupMonitoring(){this.keepalive=new NDKRelayKeepalive(12e4,async()=>{this.debug("Relay silence detected, probing connection");await probeRelayConnection({send:e=>this.send(JSON.stringify(e)),once:(e,t)=>{const n=e=>{try{const r=JSON.parse(e.data);"EOSE"!==r[0]&&"EVENT"!==r[0]&&"NOTICE"!==r[0]||(t(),this.ws?.removeEventListener("message",n))}catch{}};this.ws?.addEventListener("message",n)}})||(this.debug("Probe failed, connection is stale"),this.handleStaleConnection())}),this.wsStateMonitor=setInterval(()=>{5===this._status&&(this.ws&&this.ws.readyState===WebSocket.OPEN||(this.debug("WebSocket died silently, reconnecting"),this.handleStaleConnection()))},5e3),this.sleepDetector=setInterval(()=>{const e=Date.now(),t=e-this.lastSleepCheck;t>15e3&&(this.debug(`Detected possible sleep/wake (${t}ms gap)`),this.handlePossibleWake()),this.lastSleepCheck=e},1e4)}handleStaleConnection(){this._status=1,this.wasIdle=!0,this.onDisconnect()}handlePossibleWake(){this.debug("System wake detected, checking all connections"),this.wasIdle=!0,this._status>=5&&(this.ws&&this.ws.readyState===WebSocket.OPEN?probeRelayConnection({send:e=>this.send(JSON.stringify(e)),once:(e,t)=>{const n=e=>{try{const r=JSON.parse(e.data);"EOSE"!==r[0]&&"EVENT"!==r[0]&&"NOTICE"!==r[0]||(t(),this.ws?.removeEventListener("message",n))}catch{}};this.ws?.addEventListener("message",n)}}).then(e=>{e||this.handleStaleConnection()}):this.handleStaleConnection())}resetReconnectionState(){this.wasIdle=!0,this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0)}async connect(e,t=!0){if(this.ws&&this.ws.readyState!==WebSocket.OPEN&&this.ws.readyState!==WebSocket.CONNECTING){this.debug("Cleaning up stale WebSocket connection");try{this.ws.close()}catch(e){}this.ws=void 0,this._status=1}if(2!==this._status&&1!==this._status||this.reconnectTimeout)this.debug("Relay requested to be connected but was in state %s or it had a reconnect timeout",this._status);else{this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0),e??=this.timeoutMs,!this.timeoutMs&&e&&(this.timeoutMs=e),this.timeoutMs&&(this.connectTimeout=setTimeout(()=>this.onConnectionError(t),this.timeoutMs));try{this.updateConnectionStats.attempt(),1===this._status?this._status=4:this._status=2,this.ws=new WebSocket(this.ndkRelay.url),this.ws.onopen=this.onConnect.bind(this),this.ws.onclose=this.onDisconnect.bind(this),this.ws.onmessage=this.onMessage.bind(this),this.ws.onerror=this.onError.bind(this)}catch(e){throw this.debug(`Failed to connect to ${this.ndkRelay.url}`,e),this._status=1,t?this.handleReconnection():this.ndkRelay.emit("delayed-connect",1728e5),e}}}disconnect(){this._status=0,this.keepalive?.stop(),this.wsStateMonitor&&(clearInterval(this.wsStateMonitor),this.wsStateMonitor=void 0),this.sleepDetector&&(clearInterval(this.sleepDetector),this.sleepDetector=void 0);try{this.ws?.close()}catch(e){this.debug("Failed to disconnect",e),this._status=1}}onConnectionError(e){this.debug(`Error connecting to ${this.ndkRelay.url}`,this.timeoutMs),e&&!this.reconnectTimeout&&this.handleReconnection()}onConnect(){this.netDebug?.("connected",this.ndkRelay),this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0),this.updateConnectionStats.connected(),this._status=5,this.keepalive?.start(),this.wasIdle=!1,this.ndkRelay.emit("connect"),this.ndkRelay.emit("ready")}onDisconnect(){this.netDebug?.("disconnected",this.ndkRelay),this.updateConnectionStats.disconnected(),this.keepalive?.stop(),this.clearPendingPublishes(new Error(`Relay ${this.ndkRelay.url} disconnected`)),5===this._status&&this.handleReconnection(),this._status=1,this.ndkRelay.emit("disconnect")}onMessage(e){this.netDebug?.(e.data,this.ndkRelay,"recv"),this.keepalive?.recordActivity();try{const t=JSON.parse(e.data),[n,r,...i]=t,s=this.ndkRelay.getProtocolHandler(n);if(s)return void s(this.ndkRelay,t);switch(n){case"EVENT":{const e=this.openSubs.get(r),n=t[2];return e?void e.onevent(n):void this.debug(`Received event for unknown subscription ${r}`)}case"COUNT":{const e=t[2],n=this.openCountRequests.get(r);return void(n&&(n.resolve(e.count),this.openCountRequests.delete(r)))}case"EOSE":{const e=this.openSubs.get(r);if(!e)return;return void e.oneose(r)}case"OK":{const e=t[2],n=t[3],i=this.openEventPublishes.get(r),s=i?.pop();if(!i||!s)return void this.debug("Received OK for unknown event publish",r);if(e)s.resolve(n),this.pendingAuthPublishes.delete(r);else{if(n&&(n.toLowerCase().includes("auth-required")||n.toLowerCase().includes("not authorized")||n.toLowerCase().includes("blocked: not authorized"))){this.pendingAuthPublishes.get(r)?(this.debug("Publish failed due to auth-required, will retry after auth",r),i.push(s),this.openEventPublishes.set(r,i)):s.reject(new Error(n))}else s.reject(new Error(n)),this.pendingAuthPublishes.delete(r)}return void(0===i.length?this.openEventPublishes.delete(r):e||n?.toLowerCase().includes("auth-required")||n?.toLowerCase().includes("not authorized")||n?.toLowerCase().includes("blocked: not authorized")||this.openEventPublishes.set(r,i))}case"CLOSED":{const e=this.openSubs.get(r);if(!e)return;return void e.onclosed(t[2])}case"NOTICE":return void this.onNotice(t[1]);case"AUTH":return void this.onAuthRequested(t[1])}}catch(e){return void this.debug(`Error parsing message from ${this.ndkRelay.url}: ${e.message}`,e?.stack)}}async onAuthRequested(e){const t=this.ndkRelay.authPolicy??this.ndk?.relayAuthDefaultPolicy;if(this.debug("Relay requested authentication",{havePolicy:!!t}),7!==this._status)if(this._status=6,t){if(this._status>=5){let n;this._status=7;try{n=await t(this.ndkRelay,e)}catch(e){this.debug("Authentication policy threw an error",e),n=!1}if(this.debug("Authentication policy returned",!!n),n instanceof NDKEvent||!0===n){n instanceof NDKEvent&&await this.auth(n);const t=async()=>{if(this._status>=5&&this._status<8){const t=new NDKEvent(this.ndk);t.kind=22242,t.tags=[["relay",this.ndkRelay.url],["challenge",e]],await t.sign(),this.auth(t).then(()=>{this._status=8,this.ndkRelay.emit("authed"),this.debug("Authentication successful"),this.retryPendingAuthPublishes()}).catch(e=>{this._status=6,this.ndkRelay.emit("auth:failed",e),this.debug("Authentication failed",e),this.rejectPendingAuthPublishes(e)})}else this.debug("Authentication failed, it changed status, status is %d",this._status)};!0===n&&(this.ndk?.signer?t().catch(e=>{console.error("Error authenticating",e)}):(this.debug("No signer available for authentication localhost"),this.ndk?.once("signer:ready",t))),this._status=5,this.ndkRelay.emit("authed")}}}else this.ndkRelay.emit("auth",e);else this.debug("Already authenticating, ignoring")}onError(e){this.debug(`WebSocket error on ${this.ndkRelay.url}:`,e)}get status(){return this._status}isAvailable(){return 5===this._status}isFlapping(){const e=this._connectionStats.durations;if(e.length%3!=0)return!1;const t=e.reduce((e,t)=>e+t,0)/e.length,n=e.map(e=>(e-t)**2).reduce((e,t)=>e+t,0)/e.length;return Math.sqrt(n)<FLAPPING_THRESHOLD_MS}async onNotice(e){this.ndkRelay.emit("notice",e)}handleReconnection(e=0){if(this.reconnectTimeout)return;if(this.isFlapping())return this.ndkRelay.emit("flapping",this._connectionStats),void(this._status=3);let t;if(this.wasIdle){const n=[0,1e3,2e3,5e3,1e4,3e4];t=n[Math.min(e,n.length-1)],this.debug(`Using aggressive reconnect after idle, attempt ${e}, delay ${t}ms`)}else this.connectedAt?t=Math.max(0,6e4-(Date.now()-this.connectedAt)):(t=Math.min(1e3*2**e,3e4),this.debug(`Using standard backoff, attempt ${e}, delay ${t}ms`));this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=void 0,this._status=2,this.connect().catch(t=>{e<MAX_RECONNECT_ATTEMPTS?this.handleReconnection(e+1):(this.debug("Max reconnect attempts reached"),this.wasIdle=!1)})},t),this.ndkRelay.emit("delayed-connect",t),this.debug("Reconnecting in",t),this._connectionStats.nextReconnectAt=Date.now()+t}async send(e){Date.now()-this.lastMessageSent>12e4&&(this.wasIdle=!0),this._status>=5&&this.ws?.readyState===WebSocket.OPEN?(this.ws?.send(e),this.netDebug?.(e,this.ndkRelay,"send"),this.lastMessageSent=Date.now()):(this.debug(`Not connected to ${this.ndkRelay.url} (%d), not sending message ${e}`,this._status),this._status>=5&&this.ws?.readyState!==WebSocket.OPEN&&(this.debug(`Stale connection detected, WebSocket state: ${this.ws?.readyState}`),this.handleStaleConnection()))}async auth(e){const t=new Promise((t,n)=>{const r=this.openEventPublishes.get(e.id)??[];r.push({resolve:t,reject:n}),this.openEventPublishes.set(e.id,r)});return this.send(`["AUTH",${JSON.stringify(e.rawEvent())}]`),t}clearPendingPublishes(e){this.rejectPendingAuthPublishes(e);for(const[t,n]of this.openEventPublishes.entries()){for(;n.length>0;){const t=n.shift();t&&t.reject(e)}this.openEventPublishes.delete(t)}}retryPendingAuthPublishes(){if(0!==this.pendingAuthPublishes.size){this.debug(`Retrying ${this.pendingAuthPublishes.size} pending publishes after auth`);for(const[e,t]of this.pendingAuthPublishes.entries())this.debug(`Retrying publish for event ${e}`),this.send(`["EVENT",${JSON.stringify(t)}]`);this.pendingAuthPublishes.clear()}}rejectPendingAuthPublishes(e){if(0!==this.pendingAuthPublishes.size){this.debug(`Rejecting ${this.pendingAuthPublishes.size} pending publishes due to auth failure`);for(const[t]of this.pendingAuthPublishes.entries()){const n=this.openEventPublishes.get(t);if(n&&n.length>0){const r=n.pop();r&&r.reject(new Error(`Authentication failed: ${e.message}`)),0===n.length&&this.openEventPublishes.delete(t)}}this.pendingAuthPublishes.clear()}}async publish(e){const t=new Promise((t,n)=>{const r=this.openEventPublishes.get(e.id)??[];r.length>0&&console.warn(`Duplicate event publishing detected, you are publishing event ${e.id} twice`),r.push({resolve:t,reject:n}),this.openEventPublishes.set(e.id,r)});return this.pendingAuthPublishes.set(e.id,e),this.send(`["EVENT",${JSON.stringify(e)}]`),t}async count(e,t){this.serial++;const n=t?.id||`count:${this.serial}`,r=new Promise((e,t)=>{this.openCountRequests.set(n,{resolve:e,reject:t})});return this.send(`["COUNT","${n}",${JSON.stringify(e).substring(1)}`),r}close(e,t){this.send(`["CLOSE","${e}"]`);const n=this.openSubs.get(e);this.openSubs.delete(e),n&&n.onclose(t)}req(e){this.send(`["REQ","${e.subId}",${JSON.stringify(e.executeFilters).substring(1)}`),this.openSubs.set(e.subId,e)}updateConnectionStats={connected:()=>{this._connectionStats.success++,this._connectionStats.connectedAt=Date.now()},disconnected:()=>{this._connectionStats.connectedAt&&(this._connectionStats.durations.push(Date.now()-this._connectionStats.connectedAt),this._connectionStats.durations.length>100&&this._connectionStats.durations.shift()),this._connectionStats.connectedAt=void 0},attempt:()=>{this._connectionStats.attempts++,this._connectionStats.connectedAt=Date.now()}};get connectionStats(){return this._connectionStats}get url(){return this.ndkRelay.url}get connected(){return this._status>=5&&this.ws?.readyState===WebSocket.OPEN}};async function fetchRelayInformation(e){const t=e.replace(/^wss:\/\//,"https://").replace(/^ws:\/\//,"http://"),n=await fetch(t,{headers:{Accept:"application/nostr+json"}});if(!n.ok)throw new Error(`Failed to fetch relay information: ${n.status} ${n.statusText}`);return await n.json()}var NDKRelayPublisher=class{ndkRelay;debug;constructor(e){this.ndkRelay=e,this.debug=e.debug.extend("publisher")}async publish(e,t=2500){let n;const r=()=>new Promise((t,n)=>{try{this.publishEvent(e).then(n=>{this.ndkRelay.emit("published",e),e.emit("relay:published",this.ndkRelay),t(!0)}).catch(n)}catch(e){n(e)}}),i=new Promise((e,r)=>{n=setTimeout(()=>{n=void 0,r(new Error(`Timeout: ${t}ms`))},t)}),s=()=>{r().then(e=>o(e)).catch(e=>a(e))};let o,a;const c=t=>{throw this.ndkRelay.debug("Publish failed",t,e.id),this.ndkRelay.emit("publish:failed",e,t),e.emit("relay:publish:failed",this.ndkRelay,t),t},l=()=>{n&&clearTimeout(n),this.ndkRelay.removeListener("connect",s)};return this.ndkRelay.status>=5?Promise.race([r(),i]).catch(c).finally(l):(this.ndkRelay.status<=1?(console.warn("Relay is disconnected, trying to connect to publish an event",this.ndkRelay.url),this.ndkRelay.connect()):console.warn("Relay not connected, waiting for connection to publish an event",this.ndkRelay.url),Promise.race([new Promise((e,t)=>{o=e,a=t,this.ndkRelay.on("connect",s)}),i]).catch(c).finally(l))}async publishEvent(e){return this.ndkRelay.connectivity.publish(e.rawEvent())}};function filterFingerprint(e,t){const n=[];for(const t of e){const e=Object.entries(t||{}).map(([e,t])=>["since","until"].includes(e)?`${e}:${t}`:e).sort().join("-");n.push(e)}let r=t?"+":"";return r+=n.join("|"),r}function mergeFilters(e){const t=[],n={};return e.filter(e=>!!e.limit).forEach(e=>t.push(e)),e=e.filter(e=>!e.limit),0===e.length?t:(e.forEach(e=>{Object.entries(e).forEach(([e,t])=>{Array.isArray(t)?void 0===n[e]?n[e]=[...t]:n[e]=Array.from(new Set([...n[e],...t])):n[e]=t})}),[...t,n])}var MAX_ITEMS=3;function formatArray(e,t){const n=(t?e.slice(0,MAX_ITEMS).map(t):e.slice(0,MAX_ITEMS)).join(",");return e.length>MAX_ITEMS?`${n}+${e.length-MAX_ITEMS}`:n}function formatFilters(e){return e.map(e=>{const t=[];e.ids?.length&&t.push(`ids:[${formatArray(e.ids,e=>String(e).slice(0,8))}]`),e.kinds?.length&&t.push(`kinds:[${formatArray(e.kinds)}]`),e.authors?.length&&t.push(`authors:[${formatArray(e.authors,e=>String(e).slice(0,8))}]`),e.since&&t.push(`since:${e.since}`),e.until&&t.push(`until:${e.until}`),e.limit&&t.push(`limit:${e.limit}`),e.search&&t.push(`search:"${String(e.search).slice(0,20)}"`);for(const[n,r]of Object.entries(e))n.startsWith("#")&&Array.isArray(r)&&r.length>0&&t.push(`${n}:[${formatArray(r,e=>String(e).slice(0,8))}]`);return`{${t.join(" ")}}`}).join(", ")}var NDKRelaySubscription=class{fingerprint;items=new Map;topSubManager;debug;status=0;onClose;relay;eosed=!1;executionTimer;fireTime;delayType;executeFilters;id=Math.random().toString(36).substring(7);constructor(e,t,n){this.relay=e,this.topSubManager=n,this.debug=e.debug.extend(`sub[${this.id}]`),this.fingerprint=t||Math.random().toString(36).substring(7)}_subId;get subId(){return this._subId||(this._subId=this.fingerprint.slice(0,15)),this._subId}subIdParts=new Set;addSubIdPart(e){this.subIdParts.add(e)}addItem(e,t){if(this.debug("Adding item",{filters:formatFilters(t),internalId:e.internalId,status:this.status,fingerprint:this.fingerprint,id:this.subId,itemsSize:this.items.size}),!this.items.has(e.internalId))switch(e.on("close",this.removeItem.bind(this,e)),this.items.set(e.internalId,{subscription:e,filters:t}),3!==this.status&&e.subId&&(!this._subId||this._subId.length<25)&&(0!==this.status&&1!==this.status||this.addSubIdPart(e.subId)),this.status){case 0:case 1:this.evaluateExecutionPlan(e);break;case 3:break;case 4:throw this.debug("Subscription is closed, cannot add new items",{filters:formatFilters(t),subId:e.subId,internalId:e.internalId}),new Error("Cannot add new items to a closed subscription")}}removeItem(e){if(this.items.delete(e.internalId),0===this.items.size){if(!this.eosed)return;this.close(),this.cleanup()}}close(){if(4===this.status)return;const e=this.status;if(this.status=4,3===e)try{this.relay.close(this.subId)}catch(e){this.debug("Error closing subscription",e,this)}else this.debug("Subscription wanted to close but it wasn't running, this is probably ok",{subId:this.subId,prevStatus:e,sub:this});this.cleanup()}cleanup(){this.executionTimer&&clearTimeout(this.executionTimer),this.relay.off("ready",this.executeOnRelayReady),this.relay.off("authed",this.reExecuteAfterAuth),this.onClose&&this.onClose(this)}evaluateExecutionPlan(e){if(!e.isGroupable())return this.status=1,void this.execute();if(e.filters.find(e=>!!e.limit)&&(this.executeFilters=this.compileFilters(),this.executeFilters.length>=10))return this.status=1,void this.execute();const t=e.groupableDelay,n=e.groupableDelayType;if(!t)throw new Error("Cannot group a subscription without a delay");if(0===this.status)this.schedule(t,n);else{const e=this.delayType,r=this.fireTime-Date.now();if("at-least"===e&&"at-least"===n)r<t&&(this.executionTimer&&clearTimeout(this.executionTimer),this.schedule(t,n));else if("at-least"===e&&"at-most"===n)r>t&&(this.executionTimer&&clearTimeout(this.executionTimer),this.schedule(t,n));else if("at-most"===e&&"at-most"===n)r>t&&(this.executionTimer&&clearTimeout(this.executionTimer),this.schedule(t,n));else{if("at-most"!==e||"at-least"!==n)throw new Error(`Unknown delay type combination ${e} ${n}`);r>t&&(this.executionTimer&&clearTimeout(this.executionTimer),this.schedule(t,n))}}}schedule(e,t){this.status=1;const n=Date.now();this.fireTime=n+e,this.delayType=t;const r=setTimeout(this.execute.bind(this),e);"at-least"===t&&(this.executionTimer=r)}executeOnRelayReady=()=>{if(2===this.status){if(0===this.items.size)return this.debug("No items to execute; this relay was probably too slow to respond and the caller gave up",{status:this.status,fingerprint:this.fingerprint,id:this.id,subId:this.subId}),void this.cleanup();this.debug("Executing on relay ready",{status:this.status,fingerprint:this.fingerprint,itemsSize:this.items.size,filters:formatFilters(this.compileFilters())}),this.status=1,this.execute()}};finalizeSubId(){if(this.subIdParts.size>0){let e=Array.from(this.subIdParts).map(e=>e.substring(0,10)).join("-");e.length>20&&(e=e.substring(0,20)),this._subId=e}else this._subId=this.fingerprint.slice(0,15);this._subId+=`-${Math.random().toString(36).substring(2,7)}`}reExecuteAfterAuth=(()=>{const e=this.subId;this.debug("Re-executing after auth",this.items.size),this.eosed?this.relay.close(this.subId):this.debug("We are abandoning an opened subscription, once it EOSE's, the handler will close it",{oldSubId:e}),this._subId=void 0,this.status=1,this.execute(),this.debug("Re-executed after auth %s 👉 %s",e,this.subId)}).bind(this);execute(){if(1===this.status){if(!this.relay.connected)return this.status=2,this.debug("Waiting for relay to be ready",{status:this.status,id:this.subId,fingerprint:this.fingerprint,itemsSize:this.items.size}),void this.relay.once("ready",this.executeOnRelayReady);this.relay.status<8&&this.relay.once("authed",this.reExecuteAfterAuth),this.status=3,this.finalizeSubId(),this.executeFilters=this.compileFilters(),this.relay.req(this)}}onstart(){}onevent(e){this.topSubManager.dispatchEvent(e,this.relay)}oneose(e){if(this.eosed=!0,e!==this.subId)return this.debug("Received EOSE for an abandoned subscription",e,this.subId),void this.relay.close(e);0===this.items.size&&this.close();for(const{subscription:e}of this.items.values())e.eoseReceived(this.relay),e.closeOnEose&&(this.debug("Removing item because of EOSE",{filters:formatFilters(e.filters),internalId:e.internalId,status:this.status,fingerprint:this.fingerprint,itemsSize:this.items.size}),this.removeItem(e))}onclose(e){this.status=4}onclosed(e){if(e)for(const{subscription:t}of this.items.values())t.closedReceived(this.relay,e)}compileFilters(){const e=[],t=Array.from(this.items.values()).map(e=>e.filters);if(!t[0])return this.debug("👀 No filters to merge",{itemsSize:this.items.size}),[];const n=t[0].length;for(let r=0;r<n;r++){const n=mergeFilters(t.map(e=>e[r]));e.push(...n)}return e}},NDKRelaySubscriptionManager=class{relay;subscriptions;generalSubManager;constructor(e,t){this.relay=e,this.subscriptions=new Map,this.generalSubManager=t}addSubscription(e,t){let n;if(e.isGroupable()){const r=filterFingerprint(t,e.closeOnEose);if(r){n=(this.subscriptions.get(r)||[]).find(e=>e.status<3)}n??=this.createSubscription(e,t,r)}else n=this.createSubscription(e,t);n.addItem(e,t)}createSubscription(e,t,n){const r=new NDKRelaySubscription(this.relay,n||null,this.generalSubManager);r.onClose=this.onRelaySubscriptionClose.bind(this);const i=this.subscriptions.get(r.fingerprint)??[];return this.subscriptions.set(r.fingerprint,[...i,r]),r}onRelaySubscriptionClose(e){let t=this.subscriptions.get(e.fingerprint)??[];t?1===t.length?this.subscriptions.delete(e.fingerprint):(t=t.filter(t=>t.id!==e.id),this.subscriptions.set(e.fingerprint,t)):console.warn("Unexpectedly did not find a subscription with fingerprint",e.fingerprint)}},NDKRelay=class e extends lib$1.EventEmitter{url;scores;connectivity;subs;publisher;authPolicy;protocolHandlers=new Map;_relayInfo;lowestValidationRatio;targetValidationRatio;validationRatioFn;validatedEventCount=0;nonValidatedEventCount=0;trusted=!1;complaining=!1;debug;static defaultValidationRatioUpdateFn=(e,t,n)=>{if(void 0===e.lowestValidationRatio||void 0===e.targetValidationRatio)return 1;let r=e.validationRatio;if(e.validationRatio>e.targetValidationRatio){const n=t/100;r=Math.max(e.lowestValidationRatio,e.validationRatio-n)}return r<e.validationRatio?r:e.validationRatio};constructor(t,n,r){super(),this.url=normalizeRelayUrl(t),this.scores=new Map,this.debug=createDebug5(`ndk:relay:${t}`),this.connectivity=new NDKRelayConnectivity(this,r),this.connectivity.netDebug=r?.netDebug,this.req=this.connectivity.req.bind(this.connectivity),this.close=this.connectivity.close.bind(this.connectivity),this.subs=new NDKRelaySubscriptionManager(this,r.subManager),this.publisher=new NDKRelayPublisher(this),this.authPolicy=n,this.targetValidationRatio=r?.initialValidationRatio,this.lowestValidationRatio=r?.lowestValidationRatio,this.validationRatioFn=(r?.validationRatioFn??e.defaultValidationRatioUpdateFn).bind(this),this.updateValidationRatio(),r||console.trace("relay created without ndk")}updateValidationRatio(){if(this.validationRatioFn&&this.validatedEventCount>0){const e=this.validationRatioFn(this,this.validatedEventCount,this.nonValidatedEventCount);this.targetValidationRatio=e}setTimeout(()=>{this.updateValidationRatio()},3e4)}get status(){return this.connectivity.status}get connectionStats(){return this.connectivity.connectionStats}async connect(e,t=!0){return this.connectivity.connect(e,t)}disconnect(){1!==this.status&&this.connectivity.disconnect()}subscribe(e,t){this.subs.addSubscription(e,t)}async publish(e,t=2500){return this.publisher.publish(e,t)}referenceTags(){return[["r",this.url]]}addValidatedEvent(){this.validatedEventCount++}addNonValidatedEvent(){this.nonValidatedEventCount++}get validationRatio(){return 0===this.nonValidatedEventCount?1:this.validatedEventCount/(this.validatedEventCount+this.nonValidatedEventCount)}shouldValidateEvent(){return!this.trusted&&(void 0===this.targetValidationRatio||(this.targetValidationRatio>=1||Math.random()<this.targetValidationRatio))}get connected(){return this.connectivity.connected}req;close;registerProtocolHandler(e,t){this.protocolHandlers.set(e,t)}unregisterProtocolHandler(e){this.protocolHandlers.delete(e)}getProtocolHandler(e){return this.protocolHandlers.get(e)}async fetchInfo(e=!1){const t=this.connectivity.ndk;if(!e&&t?.cacheAdapter?.getRelayStatus){const e=await t.cacheAdapter.getRelayStatus(this.url);if(e?.nip11&&Date.now()-e.nip11.fetchedAt<864e5)return this._relayInfo=e.nip11.data,e.nip11.data}return!e&&this._relayInfo||(this._relayInfo=await fetchRelayInformation(this.url),t?.cacheAdapter?.updateRelayStatus&&await t.cacheAdapter.updateRelayStatus(this.url,{nip11:{data:this._relayInfo,fetchedAt:Date.now()}})),this._relayInfo}get info(){return this._relayInfo}},NDKPublishError=class extends Error{errors;publishedToRelays;intendedRelaySet;constructor(e,t,n,r){super(e),this.errors=t,this.publishedToRelays=n,this.intendedRelaySet=r}get relayErrors(){const e=[];for(const[t,n]of this.errors)e.push(`${t.url}: ${n}`);return e.join("\n")}},NDKRelaySet=class e{relays;debug;ndk;pool;constructor(e,t,n){this.relays=e,this.ndk=t,this.pool=n??t.pool,this.debug=t.debug.extend("relayset")}addRelay(e){this.relays.add(e)}get relayUrls(){return Array.from(this.relays).map(e=>e.url)}static fromRelayUrls(t,n,r=!0,i){if(!(i=i??n.pool))throw new Error("No pool provided");const s=new Set;for(const e of t){const o=i.relays.get(normalizeRelayUrl(e));if(o)o.status<5&&r&&o.connect(),s.add(o);else{const r=new NDKRelay(normalizeRelayUrl(e),n?.relayAuthDefaultPolicy,n);i.useTemporaryRelay(r,void 0,`requested from fromRelayUrls ${t}`),s.add(r)}}return new e(new Set(s),n,i)}async publish(e,t,n=1){const r=new Set,i=new Map,s=e.isEphemeral();e.publishStatus="pending";const o=e=>{r.add(e)};e.on("relay:published",o);try{const o=Array.from(this.relays).map(n=>new Promise(o=>{const a=t?setTimeout(()=>{r.has(n)||(i.set(n,new Error(`Publish timeout after ${t}ms`)),o(!1))},t):null;n.publish(e,t).then(e=>{a&&clearTimeout(a),e?(r.add(n),o(!0)):o(!1)}).catch(e=>{a&&clearTimeout(a),s||i.set(n,e),o(!1)})}));if(await Promise.all(o),r.size<n){if(!s){const t=new NDKPublishError("Not enough relays received the event ("+r.size+" published, "+n+" required)",i,r,this);throw e.publishStatus="error",e.publishError=t,this.ndk?.emit("event:publish-failed",e,t,this.relayUrls),t}}else e.publishStatus="success",e.emit("published",{relaySet:this,publishedToRelays:r});return r}finally{e.off("relay:published",o)}}get size(){return this.relays.size}},d=createDebug5("ndk:outbox:calculate");async function calculateRelaySetFromEvent(e,t,n){const r=new Set,i=await getWriteRelaysFor(e,t.pubkey);i&&i.forEach(t=>{const n=e.pool?.getRelay(t);n&&r.add(n)});let s=t.tags.filter(e=>["a","e"].includes(e[0])).map(e=>e[2]).filter(e=>e?.startsWith("wss://")).filter(e=>{try{return new URL(e),!0}catch{return!1}}).map(e=>normalizeRelayUrl(e));s=Array.from(new Set(s)).slice(0,5),s.forEach(t=>{const n=e.pool?.getRelay(t,!0,!0);n&&(d("Adding relay hint %s",t),r.add(n))});const o=t.getMatchingTags("p").map(e=>e[1]);if(o.length<5){Array.from(chooseRelayCombinationForPubkeys(e,o,"read",{preferredRelays:new Set(i)}).keys()).forEach(t=>{const n=e.pool?.getRelay(t,!1,!0);n&&(d("Adding p-tagged relay %s",t),r.add(n))})}else d("Too many p-tags to consider %d",o.length);if(e.pool?.permanentAndConnectedRelays().forEach(e=>r.add(e)),n&&r.size<n){const t=e.explicitRelayUrls?.filter(e=>!Array.from(r).some(t=>t.url===e)).slice(0,n-r.size);t?.forEach(t=>{const n=e.pool?.getRelay(t,!1,!0);n&&(d("Adding explicit relay %s",t),r.add(n))})}return new NDKRelaySet(r,e)}function calculateRelaySetsFromFilter(e,t,n,r){const i=new Map,s=new Set;if(t.forEach(e=>{e.authors&&e.authors.forEach(e=>s.add(e))}),s.size>0){const n=getRelaysForFilterWithAuthors(e,Array.from(s),r);for(const e of n.keys())i.set(e,[]);for(const e of t)if(e.authors)for(const[t,r]of n.entries()){const n=e.authors.filter(e=>r.includes(e));i.set(t,[...i.get(t),{...e,authors:n}])}else for(const t of n.keys())i.set(t,[...i.get(t),e])}else e.explicitRelayUrls&&e.explicitRelayUrls.forEach(e=>{i.set(e,t)});return 0===i.size&&n.permanentAndConnectedRelays().slice(0,5).forEach(e=>{i.set(e.url,t)}),i}function calculateRelaySetsFromFilters(e,t,n,r){return calculateRelaySetsFromFilter(e,t,n,r)}function isValidHex64(e){if("string"!=typeof e||64!==e.length)return!1;for(let t=0;t<64;t++){const n=e.charCodeAt(t);if(!(n>=48&&n<=57||n>=97&&n<=102||n>=65&&n<=70))return!1}return!0}function isValidPubkey(e){return isValidHex64(e)}function isValidNip05(e){if("string"!=typeof e)return!1;for(let t=0;t<e.length;t++)if(46===e.charCodeAt(t))return!0;return!1}function mergeTags(e,t){const n=new Map,r=(e,t)=>e.every((e,n)=>e===t[n]);return e.concat(t).forEach(e=>{for(const[t,i]of n)if(r(i,e)||r(e,i))return void(e.length>=i.length&&n.set(t,e));n.set((e=>e.join(","))(e),e)}),Array.from(n.values())}var hashtagRegex=/(?<=\s|^)(#[^\s!@#$%^&*()=+./,[{\]};:'"?><]+)/g;function generateHashtags(e){const t=e.match(hashtagRegex),n=new Set,r=new Set;if(t)for(const e of t)n.has(e.slice(1))||(r.add(e.slice(1)),n.add(e.slice(1)));return Array.from(r)}async function generateContentTags(e,t=[],n,r){if(n?.skipContentTagging)return{content:e,tags:t};const i=[],s=e=>{t.find(t=>["q",e[0]].includes(t[0])&&t[1]===e[1])||t.push(e)};if(e=e.replace(/(@|nostr:)(npub|nprofile|note|nevent|naddr)[a-zA-Z0-9]+/g,e=>{try{const t=e.split(/(@|nostr:)/)[2],{type:r,data:o}=nip19_exports$2.decode(t);let a;if(n?.filters){const t=!n.filters.includeTypes||n.filters.includeTypes.includes(r),i=n.filters.excludeTypes?.includes(r);if(!t||i)return e}switch(r){case"npub":!1!==n?.pTags&&(a=["p",o]);break;case"nprofile":!1!==n?.pTags&&(a=["p",o.pubkey]);break;case"note":i.push(new Promise(async e=>{const n=await maybeGetEventRelayUrl(t);s(["q",o,n]),e()}));break;case"nevent":i.push(new Promise(async e=>{const{id:r,author:i}=o;let{relays:a}=o;a&&0!==a.length||(a=[await maybeGetEventRelayUrl(t)]),s(["q",r,a[0]]),i&&!1!==n?.pTags&&!1!==n?.pTagOnQTags&&s(["p",i]),e()}));break;case"naddr":i.push(new Promise(async e=>{const r=[o.kind,o.pubkey,o.identifier].join(":");let i=o.relays??[];0===i.length&&(i=[await maybeGetEventRelayUrl(t)]),s(["q",r,i[0]]),!1!==n?.pTags&&!1!==n?.pTagOnQTags&&!1!==n?.pTagOnATags&&s(["p",o.pubkey]),e()}));break;default:return e}return a&&s(a),`nostr:${t}`}catch(t){return e}}),await Promise.all(i),!n?.filters?.excludeTypes?.includes("hashtag")){const n=generateHashtags(e).map(e=>["t",e]);t=mergeTags(t,n)}if(!1!==n?.pTags&&n?.copyPTagsFromTarget&&r){const e=r.getMatchingTags("p");for(const n of e)n[1]&&isValidPubkey(n[1])&&(t.find(e=>"p"===e[0]&&e[1]===n[1])||t.push(n))}return{content:e,tags:t}}async function maybeGetEventRelayUrl(e){return""}async function encrypt$1(e,t,n="nip44"){let r;if(!this.ndk)throw new Error("No NDK instance found!");let i=t;if(i||(this.ndk.assertSigner(),i=this.ndk.signer),!i)throw new Error("no NDK signer");const s=e||(()=>{const e=this.getMatchingTags("p");if(1!==e.length)throw new Error("No recipient could be determined and no explicit recipient was provided");return this.ndk.getUser({pubkey:e[0][1]})})();if("nip44"===n&&await isEncryptionEnabled(i,"nip44")&&(r=await i.encrypt(s,this.content,"nip44")),r&&"nip04"!==n||!await isEncryptionEnabled(i,"nip04")||(r=await i.encrypt(s,this.content,"nip04")),!r)throw new Error("Failed to encrypt event.");this.content=r}async function decrypt$1(e,t,n){if(this.ndk?.cacheAdapter?.getDecryptedEvent){const e=await this.ndk.cacheAdapter.getDecryptedEvent(this.id);if(e)return void(this.content=e.content)}let r;if(!this.ndk)throw new Error("No NDK instance found!");let i=t;if(i||(this.ndk.assertSigner(),i=this.ndk.signer),!i)throw new Error("no NDK signer");const s=e||this.author;if(!s)throw new Error("No sender provided and no author available");const o=n||(this.content.match(/\\?iv=/)?"nip04":"nip44");if(("nip04"===o||4===this.kind)&&await isEncryptionEnabled(i,"nip04")&&this.content.search("\\?iv=")&&(r=await i.decrypt(s,this.content,"nip04")),!r&&"nip44"===o&&await isEncryptionEnabled(i,"nip44")&&(r=await i.decrypt(s,this.content,"nip44")),!r)throw new Error("Failed to decrypt event.");this.content=r,this.ndk?.cacheAdapter?.addDecryptedEvent&&this.ndk.cacheAdapter.addDecryptedEvent(this.id,this)}async function isEncryptionEnabled(e,t){return!!e.encryptionEnabled&&(!t||Boolean(await e.encryptionEnabled(t)))}function eventHasETagMarkers(e){for(const t of e.tags)if("e"===t[0]&&(t[3]??"").length>0)return!0;return!1}function getRootTag(e,t){t??=e.tagType();const n=e.tags.find(isTagRootTag);if(!n){if(eventHasETagMarkers(e))return;const n=e.getMatchingTags(t);if(n.length<3)return n[0]}return n}var nip22RootTags=new Set(["A","E","I"]),nip22ReplyTags=new Set(["a","e","i"]);function getReplyTag(e,t){if(1111===e.kind){let t;for(const n of e.tags)if(nip22RootTags.has(n[0]))t=n;else if(nip22ReplyTags.has(n[0])){t=n;break}return t}t??=e.tagType();let n,r=!1;for(const i of e.tags)if(i[0]===t){if((i[3]??"").length>0&&(r=!0),r&&"reply"===i[3])return i;r&&"root"===i[3]&&(n=i),r||(n=i)}return n}function isTagRootTag(e){return"E"===e[0]||"root"===e[3]}async function fetchTaggedEvent(e,t){if(!this.ndk)throw new Error("NDK instance not found");const n=this.getMatchingTags(e,t);if(0===n.length)return;const[r,i,s]=n[0],o=""!==s?this.ndk.pool.getRelay(s):void 0;return await this.ndk.fetchEvent(i,{},o)}async function fetchRootEvent(e){if(!this.ndk)throw new Error("NDK instance not found");const t=getRootTag(this);if(t)return this.ndk.fetchEventFromTag(t,this,e)}async function fetchReplyEvent(e){if(!this.ndk)throw new Error("NDK instance not found");const t=getReplyTag(this);if(t)return this.ndk.fetchEventFromTag(t,this,e)}function isReplaceable(){if(void 0===this.kind)throw new Error("Kind not set");return[0,3].includes(this.kind)||this.kind>=1e4&&this.kind<2e4||this.kind>=3e4&&this.kind<4e4}function isEphemeral(){if(void 0===this.kind)throw new Error("Kind not set");return this.kind>=2e4&&this.kind<3e4}function isParamReplaceable(){if(void 0===this.kind)throw new Error("Kind not set");return this.kind>=3e4&&this.kind<4e4}var DEFAULT_RELAY_COUNT=2,worker;function encode(e=DEFAULT_RELAY_COUNT){let t=[];return this.onRelays.length>0?t=this.onRelays.map(e=>e.url):this.relay&&(t=[this.relay.url]),t.length>e&&(t=t.slice(0,e)),this.isParamReplaceable()?nip19_exports$2.naddrEncode({kind:this.kind,pubkey:this.pubkey,identifier:this.replaceableDTag(),relays:t}):t.length>0?nip19_exports$2.neventEncode({id:this.tagId(),relays:t,author:this.pubkey}):nip19_exports$2.noteEncode(this.tagId())}async function repost(e=!0,t){if(!t&&e){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner(),t=this.ndk.signer}const n=new NDKEvent(this.ndk,{kind:getKind(this)});return this.isProtected||(n.content=JSON.stringify(this.rawEvent())),n.tag(this),1!==this.kind&&n.tags.push(["k",`${this.kind}`]),t&&await n.sign(t),e&&await n.publish(),n}function getKind(e){return 1===e.kind?6:16}function getEventDetails(e){return"inspect"in e&&"string"==typeof e.inspect?e.inspect:JSON.stringify(e)}function validateForSerialization(e){if("number"!=typeof e.kind)throw new Error(`Can't serialize event with invalid properties: kind (must be number, got ${typeof e.kind}). Event: ${getEventDetails(e)}`);if("string"!=typeof e.content)throw new Error(`Can't serialize event with invalid properties: content (must be string, got ${typeof e.content}). Event: ${getEventDetails(e)}`);if("number"!=typeof e.created_at)throw new Error(`Can't serialize event with invalid properties: created_at (must be number, got ${typeof e.created_at}). Event: ${getEventDetails(e)}`);if("string"!=typeof e.pubkey)throw new Error(`Can't serialize event with invalid properties: pubkey (must be string, got ${typeof e.pubkey}). Event: ${getEventDetails(e)}`);if(!Array.isArray(e.tags))throw new Error(`Can't serialize event with invalid properties: tags (must be array, got ${typeof e.tags}). Event: ${getEventDetails(e)}`);for(let t=0;t<e.tags.length;t++){const n=e.tags[t];if(!Array.isArray(n))throw new Error(`Can't serialize event with invalid properties: tags[${t}] (must be array, got ${typeof n}). Event: ${getEventDetails(e)}`);for(let r=0;r<n.length;r++)if("string"!=typeof n[r])throw new Error(`Can't serialize event with invalid properties: tags[${t}][${r}] (must be string, got ${typeof n[r]}). Event: ${getEventDetails(e)}`)}}function serialize(e=!1,t=!1){validateForSerialization(this);const n=[0,this.pubkey,this.created_at,this.kind,this.tags,this.content];return e&&n.push(this.sig),t&&n.push(this.id),JSON.stringify(n)}function deserialize(e){const t=JSON.parse(e),n={pubkey:t[1],created_at:t[2],kind:t[3],tags:t[4],content:t[5]};if(t.length>=7){const e=t[6],r=t[7];e&&128===e.length?(n.sig=e,r&&64===r.length&&(n.id=r)):e&&64===e.length&&(n.id=e,r&&128===r.length&&(n.sig=r))}return n}var processingQueue={};function signatureVerificationInit(e){(worker=e).onmessage=e=>{if(!Array.isArray(e.data)||2!==e.data.length)return void console.error("[NDK] ❌ Signature verification worker received incompatible message format.","\n\n📋 Expected format: [eventId, boolean]","\n📦 Received:",e.data,"\n\n🔍 This likely means:","\n 1. You have a STALE worker.js file that needs updating","\n 2. Version mismatch between @nostr-dev-kit/ndk and deployed worker","\n 3. Wrong worker is being used for signature verification","\n\n✅ Solution: Update your worker files:","\n cp node_modules/@nostr-dev-kit/ndk/dist/workers/sig-verification.js public/","\n cp node_modules/@nostr-dev-kit/cache-sqlite-wasm/dist/worker.js public/","\n\n💡 Or use Vite/bundler imports instead of static files:",'\n import SigWorker from "@nostr-dev-kit/ndk/workers/sig-verification?worker"');const[t,n]=e.data,r=processingQueue[t];if(r){delete processingQueue[t];for(const e of r.resolves)e(n)}else console.error("No record found for event",t)}}async function verifySignatureAsync(e,t,n){const r=e.ndk,i=Date.now();let s;return s=r.signatureVerificationFunction?await r.signatureVerificationFunction(e):await new Promise(t=>{const r=e.serialize();let i=!1;processingQueue[e.id]||(processingQueue[e.id]={event:e,resolves:[],relay:n},i=!0),processingQueue[e.id].resolves.push(t),i&&worker?.postMessage({serialized:r,id:e.id,sig:e.sig,pubkey:e.pubkey})}),r.signatureVerificationTimeMs+=Date.now()-i,s}var PUBKEY_REGEX=/^[a-f0-9]{64}$/;function validate(){if("number"!=typeof this.kind)return!1;if("string"!=typeof this.content)return!1;if("number"!=typeof this.created_at)return!1;if("string"!=typeof this.pubkey)return!1;if(!this.pubkey.match(PUBKEY_REGEX))return!1;if(!Array.isArray(this.tags))return!1;for(let e=0;e<this.tags.length;e++){const t=this.tags[e];if(!Array.isArray(t))return!1;for(let e=0;e<t.length;e++)if("object"==typeof t[e])return!1}return!0}var verifiedSignatures=new dist.LRUCache({maxSize:1e3,entryExpirationTimeInMS:6e4});function verifySignature$1(e){if("boolean"==typeof this.signatureVerified)return this.signatureVerified;const t=verifiedSignatures.get(this.id);if(null!==t)return this.signatureVerified=!!t,this.signatureVerified;try{if(!this.ndk?.asyncSigVerification){const e=sha256$4((new TextEncoder).encode(this.serialize())),t=schnorr$1.verify(this.sig,e,this.pubkey);return t?verifiedSignatures.set(this.id,this.sig):verifiedSignatures.set(this.id,!1),this.signatureVerified=t,t}{const t=this.relay;verifySignatureAsync(this,e,t).then(n=>{e&&(this.signatureVerified=n,n&&verifiedSignatures.set(this.id,this.sig)),n?t&&t.addValidatedEvent():(t?this.ndk?.reportInvalidSignature(this,t):this.ndk?.reportInvalidSignature(this),verifiedSignatures.set(this.id,!1))}).catch(e=>{console.error("signature verification error",this.id,e)})}}catch(e){return this.signatureVerified=!1,!1}}function getEventHash$1(){return getEventHashFromSerializedEvent(this.serialize())}function getEventHashFromSerializedEvent(e){return bytesToHex$4(sha256$4((new TextEncoder).encode(e)))}var skipClientTagOnKinds=new Set([0,4,1059,13,3,9734,5]),NDKEvent=class e extends lib$1.EventEmitter{ndk;created_at;content="";tags=[];kind;id="";sig;pubkey="";signatureVerified;_author=void 0;relay;get onRelays(){let e=[];return this.ndk?e=this.ndk.subManager.seenEvents.get(this.id)||[]:this.relay&&e.push(this.relay),e}publishStatus="success";publishError;constructor(t,n){super(),this.ndk=t,this.created_at=n?.created_at,this.content=n?.content||"",this.tags=n?.tags||[],this.id=n?.id||"",this.sig=n?.sig,this.pubkey=n?.pubkey||"",this.kind=n?.kind,n instanceof e&&(this.relay&&(this.relay=n.relay,this.ndk?.subManager.seenEvent(n.id,this.relay)),this.publishStatus=n.publishStatus,this.publishError=n.publishError)}static deserialize(t,n){return new e(t,deserialize(n))}rawEvent(){return{created_at:this.created_at,content:this.content,tags:this.tags,kind:this.kind,pubkey:this.pubkey,id:this.id,sig:this.sig}}set author(e){this.pubkey=e.pubkey,this._author=e,this._author.ndk??=this.ndk}get author(){if(this._author)return this._author;if(!this.ndk)throw new Error("No NDK instance found");const e=this.ndk.getUser({pubkey:this.pubkey});return this._author=e,e}tagExternal(e,t,n){const r=["i"],i=["k"];switch(t){case"url":{const t=new URL(e);t.hash="",r.push(t.toString()),i.push(`${t.protocol}//${t.host}`);break}case"hashtag":r.push(`#${e.toLowerCase()}`),i.push("#");break;case"geohash":r.push(`geo:${e.toLowerCase()}`),i.push("geo");break;case"isbn":r.push(`isbn:${e.replace(/-/g,"")}`),i.push("isbn");break;case"podcast:guid":r.push(`podcast:guid:${e}`),i.push("podcast:guid");break;case"podcast:item:guid":r.push(`podcast:item:guid:${e}`),i.push("podcast:item:guid");break;case"podcast:publisher:guid":r.push(`podcast:publisher:guid:${e}`),i.push("podcast:publisher:guid");break;case"isan":r.push(`isan:${e.split("-").slice(0,4).join("-")}`),i.push("isan");break;case"doi":r.push(`doi:${e.toLowerCase()}`),i.push("doi");break;default:throw new Error(`Unsupported NIP-73 entity type: ${t}`)}n&&r.push(n),this.tags.push(r),this.tags.push(i)}tag(t,n,r,i,s){let o=[];if(void 0!==t.fetchProfile){if(i??="p","p"===i&&!1===s?.pTags)return;const e=[i,t.pubkey];n&&e.push("",n),o.push(e)}else if(t instanceof e){const e=t;if(r??=e?.pubkey===this.pubkey,o=e.referenceTags(n,r,i,s),!1!==s?.pTags)for(const t of e.getMatchingTags("p"))t[1]&&isValidPubkey(t[1])&&t[1]!==this.pubkey&&(this.tags.find(e=>"p"===e[0]&&e[1]===t[1])||this.tags.push(["p",t[1]]))}else{if(!Array.isArray(t))throw new Error("Invalid argument",t);o=[t]}this.tags=mergeTags(this.tags,o)}async toNostrEvent(e,t){if(!e&&""===this.pubkey){const e=await(this.ndk?.signer?.user());this.pubkey=e?.pubkey||""}this.created_at||(this.created_at=Math.floor(Date.now()/1e3));const{content:n,tags:r}=await this.generateTags(t);this.content=n||"",this.tags=r;try{this.id=this.getEventHash()}catch(e){}return this.rawEvent()}serialize=serialize.bind(this);getEventHash=getEventHash$1.bind(this);validate=validate.bind(this);verifySignature=verifySignature$1.bind(this);isReplaceable=isReplaceable.bind(this);isEphemeral=isEphemeral.bind(this);isDvm=()=>this.kind&&this.kind>=5e3&&this.kind<=7e3;isParamReplaceable=isParamReplaceable.bind(this);encode=encode.bind(this);encrypt=encrypt$1.bind(this);decrypt=decrypt$1.bind(this);getMatchingTags(e,t){const n=this.tags.filter(t=>t[0]===e);return void 0===t?n:n.filter(e=>e[3]===t)}hasTag(e,t){return this.tags.some(n=>n[0]===e&&(!t||n[3]===t))}tagValue(e,t){const n=this.getMatchingTags(e,t);if(0!==n.length)return n[0][1]}get alt(){return this.tagValue("alt")}set alt(e){this.removeTag("alt"),e&&this.tags.push(["alt",e])}get dTag(){return this.tagValue("d")}set dTag(e){this.removeTag("d"),e&&this.tags.push(["d",e])}removeTag(e,t){const n=Array.isArray(e)?e:[e];this.tags=this.tags.filter(e=>{const r=n.includes(e[0]),i=!t||e[3]===t;return!(r&&i)})}replaceTag(e){this.removeTag(e[0]),this.tags.push(e)}async sign(e,t){this.ndk?.aiGuardrails?.event?.signing(this),e?this.author=await e.user():(this.ndk?.assertSigner(),e=this.ndk?.signer);const n=await this.toNostrEvent(void 0,t);return this.sig=await e.sign(n),this.sig}async publishReplaceable(e,t,n){return this.id="",this.created_at=Math.floor(Date.now()/1e3),this.sig="",this.publish(e,t,n)}async publish(e,t,n,r){if(n||(n=1),this.sig||await this.sign(void 0,r),!this.ndk)throw new Error("NDKEvent must be associated with an NDK instance to publish");if(this.ndk.aiGuardrails?.event?.publishing(this),e&&0!==e.size||(e=this.ndk.devWriteRelaySet||await calculateRelaySetFromEvent(this.ndk,this,n)),5===this.kind&&this.ndk.cacheAdapter?.deleteEventIds){const e=this.getMatchingTags("e").map(e=>e[1]);this.ndk.cacheAdapter.deleteEventIds(e)}const i=this.rawEvent();if(this.ndk.cacheAdapter?.addUnpublishedEvent&&shouldTrackUnpublishedEvent(this))try{this.ndk.cacheAdapter.addUnpublishedEvent(this,e.relayUrls)}catch(e){console.error("Error adding unpublished event to cache",e)}5===this.kind&&this.ndk.cacheAdapter?.deleteEventIds&&this.ndk.cacheAdapter.deleteEventIds(this.getMatchingTags("e").map(e=>e[1])),this.ndk.subManager.dispatchEvent(i,void 0,!0);const s=await e.publish(this,t,n);return s.forEach(e=>this.ndk?.subManager.seenEvent(this.id,e)),s}async generateTags(e){let t=[];const n=await generateContentTags(this.content,this.tags,e,this),r=n.content;if(t=n.tags,this.kind&&this.isParamReplaceable()){if(!this.getMatchingTags("d")[0]){const e=this.tagValue("title");let n=[...Array(e?6:16)].map(()=>Math.random().toString(36)[2]).join("");e&&e.length>0&&(n=`${e.replace(/[^a-z0-9]+/gi,"-").replace(/^-|-$/g,"")}-${n}`),t.push(["d",n])}}if(this.shouldAddClientTag){const e=["client",this.ndk?.clientName??""];this.ndk?.clientNip89&&e.push(this.ndk?.clientNip89),t.push(e)}else this.shouldStripClientTag&&(t=t.filter(e=>"client"!==e[0]));return{content:r||"",tags:t}}get shouldAddClientTag(){return!(!this.ndk?.clientName&&!this.ndk?.clientNip89)&&(!skipClientTagOnKinds.has(this.kind)&&(!this.isEphemeral()&&(!(this.isReplaceable()&&!this.isParamReplaceable())&&(!this.isDvm()&&!this.hasTag("client")))))}get shouldStripClientTag(){return skipClientTagOnKinds.has(this.kind)}muted(){return this.ndk?.muteFilter&&this.ndk.muteFilter(this)?"muted":null}replaceableDTag(){if(this.kind&&this.kind>=3e4&&this.kind<=4e4){const e=this.getMatchingTags("d")[0];return e?e[1]:""}throw new Error("Event is not a parameterized replaceable event")}deduplicationKey(){return 0===this.kind||3===this.kind||this.kind&&this.kind>=1e4&&this.kind<2e4?`${this.kind}:${this.pubkey}`:this.tagId()}tagId(){return this.isParamReplaceable()?this.tagAddress():this.id}tagAddress(){if(this.isParamReplaceable()){const e=this.dTag??"";return`${this.kind}:${this.pubkey}:${e}`}if(this.isReplaceable())return`${this.kind}:${this.pubkey}:`;throw new Error("Event is not a replaceable event")}tagType(){return this.isParamReplaceable()?"a":"e"}tagReference(e){let t;return t=this.isParamReplaceable()?["a",this.tagAddress()]:["e",this.tagId()],this.relay?t.push(this.relay.url):t.push(""),t.push(e??""),this.isParamReplaceable()||t.push(this.pubkey),t}referenceTags(e,t,n,r){let i=[];return i=this.isParamReplaceable()?[[n??"a",this.tagAddress()],[n??"e",this.id]]:[[n??"e",this.id]],i=i.map(t=>("e"===t[0]||e?t.push(this.relay?.url??""):this.relay?.url&&t.push(this.relay?.url),t)),i.forEach(t=>{"e"===t[0]?(t.push(e??""),t.push(this.pubkey)):e&&t.push(e)}),i=[...i,...this.getMatchingTags("h")],t||!1===r?.pTags||i.push(...this.author.referenceTags()),i}filter(){return this.isParamReplaceable()?{"#a":[this.tagId()]}:{"#e":[this.tagId()]}}nip22Filter(){return this.isParamReplaceable()?{"#A":[this.tagId()]}:{"#E":[this.tagId()]}}async delete(t,n=!0){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner();const r=new e(this.ndk,{kind:5,content:t||""});return r.tag(this,void 0,!0),r.tags.push(["k",this.kind?.toString()]),n&&(this.emit("deleted"),await r.publish()),r}set isProtected(e){this.removeTag("-"),e&&this.tags.push(["-"])}get isProtected(){return this.hasTag("-")}fetchTaggedEvent=fetchTaggedEvent.bind(this);fetchRootEvent=fetchRootEvent.bind(this);fetchReplyEvent=fetchReplyEvent.bind(this);repost=repost.bind(this);async react(t,n=!0){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner();const r=new e(this.ndk,{kind:7,content:t});return r.tag(this),1!==this.kind&&r.tags.push(["k",`${this.kind}`]),n&&await r.publish(),r}get isValid(){return this.validate()}get inspect(){return JSON.stringify(this.rawEvent(),null,4)}dump(){console.debug(JSON.stringify(this.rawEvent(),null,4)),console.debug("Event on relays:",this.onRelays.map(e=>e.url).join(", "))}reply(t,n){const r=new e(this.ndk);if(this.ndk?.aiGuardrails?.event?.creatingReply(r),1!==this.kind||t){r.kind=1111;const e=["A","E","I","P"],t=this.tags.filter(t=>e.includes(t[0]));if(t.length>0){const e=this.tagValue("K");let n;if(r.tags.push(...t),e&&r.tags.push(["K",e]),this.isParamReplaceable()){n=["a",this.tagAddress()];const e=this.relay?.url??"";e&&n.push(e)}else{n=["e",this.tagId()];const e=this.relay?.url??"";n.push(e),n.push(this.pubkey)}r.tags.push(n)}else{let e,t;const i=this.relay?.url??"";this.isParamReplaceable()?(e=["a",this.tagAddress(),i],t=["A",this.tagAddress(),i]):(e=["e",this.tagId(),i,this.pubkey],t=["E",this.tagId(),i,this.pubkey]),r.tags.push(e),r.tags.push(t),r.tags.push(["K",this.kind?.toString()]),!1!==n?.pTags&&!1!==n?.pTagOnATags&&r.tags.push(["P",this.pubkey])}r.tags.push(["k",this.kind?.toString()]),!1!==n?.pTags&&(r.tags.push(...this.getMatchingTags("p")),r.tags.push(["p",this.pubkey]))}else{r.kind=1;this.hasTag("e")?r.tags=[...r.tags,...this.getMatchingTags("e"),...this.getMatchingTags("p"),...this.getMatchingTags("a"),...this.referenceTags("reply",!1,void 0,n)]:r.tag(this,"root",!1,void 0,n)}return r}},untrackedUnpublishedEvents=new Set([24133,13194,23194,23195]);function shouldTrackUnpublishedEvent(e){return!untrackedUnpublishedEvents.has(e.kind)}var NDKPool=class extends lib$1.EventEmitter{_relays=new Map;status="idle";autoConnectRelays=new Set;debug;temporaryRelayTimers=new Map;flappingRelays=new Set;backoffTimes=new Map;ndk;disconnectionTimes=new Map;systemEventDetector;constructor(e,t,{debug:n,name:r}={}){super(),this.debug=n??t.debug.extend("pool"),r&&(this._name=r),this.ndk=t,this.relayUrls=e,this.ndk.pools&&this.ndk.pools.push(this)}get relays(){return this._relays}set relayUrls(e){this._relays.clear();for(const t of e){const e=new NDKRelay(t,void 0,this.ndk);e.connectivity.netDebug=this.ndk.netDebug,this.addRelay(e)}}_name="unnamed";get name(){return this._name}set name(e){this._name=e,this.debug=this.debug.extend(e)}useTemporaryRelay(e,t=3e4,n){const r=this.relays.has(e.url);r||(this.addRelay(e),this.debug("Adding temporary relay %s for filters %o",e.url,n));const i=this.temporaryRelayTimers.get(e.url);if(i&&clearTimeout(i),!r||i){const n=setTimeout(()=>{this.ndk.explicitRelayUrls?.includes(e.url)||this.removeRelay(e.url)},t);this.temporaryRelayTimers.set(e.url,n)}}addRelay(e,t=!0){const n=this.relays.has(e.url),r=e.url.includes("/npub1");let i=!0;const s=e.url;if(n)return;if(this.ndk.relayConnectionFilter&&!this.ndk.relayConnectionFilter(s))return void this.debug(`Refusing to add relay ${s}: blocked by relayConnectionFilter`);if(r)return void this.debug(`Refusing to add relay ${s}: is a filter relay`);if(this.ndk.cacheAdapter?.getRelayStatus){const n=this.ndk.cacheAdapter.getRelayStatus(s),r=n instanceof Promise?void 0:n;if(r?.dontConnectBefore){if(r.dontConnectBefore>Date.now()){const n=r.dontConnectBefore-Date.now();return this.debug(`Refusing to add relay ${s}: delayed connect for ${n}ms`),void setTimeout(()=>{this.addRelay(e,t)},n)}i=!1}}const o=t=>this.emit("notice",e,t),a=()=>this.handleRelayConnect(s),c=()=>this.handleRelayReady(e),l=()=>{this.recordDisconnection(e),this.emit("relay:disconnect",e)},h=()=>this.handleFlapping(e),d=t=>this.emit("relay:auth",e,t),u=()=>this.emit("relay:authed",e);e.off("notice",o),e.off("connect",a),e.off("ready",c),e.off("disconnect",l),e.off("flapping",h),e.off("auth",d),e.off("authed",u),e.on("notice",o),e.on("connect",a),e.on("ready",c),e.on("disconnect",l),e.on("flapping",h),e.on("auth",d),e.on("authed",u),e.on("delayed-connect",t=>{this.ndk.cacheAdapter?.updateRelayStatus&&this.ndk.cacheAdapter.updateRelayStatus(e.url,{dontConnectBefore:Date.now()+t})}),this._relays.set(s,e),t&&this.autoConnectRelays.add(s),t&&"active"===this.status&&(this.emit("relay:connecting",e),e.connect(void 0,i).catch(e=>{this.debug(`Failed to connect to relay ${s}`,e)}))}removeRelay(e){const t=this.relays.get(e);if(t)return t.disconnect(),this.relays.delete(e),this.autoConnectRelays.delete(e),this.emit("relay:disconnect",t),!0;const n=this.temporaryRelayTimers.get(e);return n&&(clearTimeout(n),this.temporaryRelayTimers.delete(e)),!1}isRelayConnected(e){const t=normalizeRelayUrl(e),n=this.relays.get(t);return!!n&&5===n.status}getRelay(e,t=!0,n=!1,r){let i=this.relays.get(normalizeRelayUrl(e));return i||(i=new NDKRelay(e,void 0,this.ndk),i.connectivity.netDebug=this.ndk.netDebug,n?this.useTemporaryRelay(i,3e4,r):this.addRelay(i,t)),i}handleRelayConnect(e){const t=this.relays.get(e);t?(this.emit("relay:connect",t),this.stats().connected===this.relays.size&&this.emit("connect")):console.error("NDK BUG: relay not found in pool",{relayUrl:e})}handleRelayReady(e){this.emit("relay:ready",e)}async connect(e){this.status="active",this.debug(`Connecting to ${this.relays.size} relays${e?`, timeout ${e}ms`:""}...`);const t=Array.from(this.autoConnectRelays.keys()).map(e=>this.relays.get(e)).filter(e=>!!e);for(const e of t)5!==e.status&&4!==e.status&&(this.emit("relay:connecting",e),e.connect().catch(t=>{this.debug(`Failed to connect to relay ${e.url}: ${t??"No reason specified"}`)}));const n=()=>t.every(e=>5===e.status),r=new Promise(e=>{if(n())return void e();const r=[];for(const i of t){const s=()=>{if(n()){for(let e=0;e<t.length;e++)t[e].off("connect",r[e]);e()}};r.push(s),i.on("connect",s)}}),i=new Promise("number"==typeof e?t=>setTimeout(t,e):()=>{});await Promise.race([r,i])}checkOnFlappingRelays(){if(this.flappingRelays.size/this.relays.size>=.8)for(const e of this.flappingRelays)this.backoffTimes.set(e,0)}recordDisconnection(e){const t=Date.now();this.disconnectionTimes.set(e.url,t);for(const[e,n]of this.disconnectionTimes.entries())t-n>1e4&&this.disconnectionTimes.delete(e);this.checkForSystemWideDisconnection()}checkForSystemWideDisconnection(){const e=Date.now(),t=[];for(const n of this.disconnectionTimes.values())e-n<5e3&&t.push(n);t.length>this.relays.size/2&&this.relays.size>1&&(this.debug(`System-wide disconnection detected: ${t.length}/${this.relays.size} relays disconnected`),this.handleSystemWideReconnection())}handleSystemWideReconnection(){if(this.systemEventDetector)this.debug("System-wide reconnection already in progress, skipping");else{this.debug("Initiating system-wide reconnection with reset backoff"),this.systemEventDetector=setTimeout(()=>{this.systemEventDetector=void 0},1e4);for(const e of this.relays.values())e.connectivity&&(e.connectivity.resetReconnectionState(),5!==e.status&&4!==e.status&&e.connect().catch(t=>{this.debug(`Failed to reconnect relay ${e.url} after system event: ${t}`)}));this.disconnectionTimes.clear()}}handleFlapping(e){this.debug(`Relay ${e.url} is flapping`);let t=this.backoffTimes.get(e.url)||5e3;t*=2,this.backoffTimes.set(e.url,t),this.debug(`Backoff time for ${e.url} is ${t}ms`),setTimeout(()=>{this.debug(`Attempting to reconnect to ${e.url}`),this.emit("relay:connecting",e),e.connect(),this.checkOnFlappingRelays()},t),e.disconnect(),this.emit("flapping",e)}size(){return this.relays.size}stats(){const e={total:0,connected:0,disconnected:0,connecting:0};for(const t of this.relays.values())e.total++,5===t.status?e.connected++:1===t.status?e.disconnected++:4===t.status&&e.connecting++;return e}connectedRelays(){return Array.from(this.relays.values()).filter(e=>e.status>=5)}permanentAndConnectedRelays(){return Array.from(this.relays.values()).filter(e=>e.status>=5&&!this.temporaryRelayTimers.has(e.url))}urls(){return Array.from(this.relays.keys())}},NDKDVMJobFeedback=class e extends NDKEvent{static kinds=[7e3];constructor(e,t){super(e,t),this.kind??=7e3}static async from(t){const n=new e(t.ndk,t.rawEvent());return n.encrypted&&await n.dvmDecrypt(),n}get status(){return this.tagValue("status")}set status(e){this.removeTag("status"),void 0!==e&&this.tags.push(["status",e])}get encrypted(){return!!this.getMatchingTags("encrypted")[0]}async dvmDecrypt(){await this.decrypt();const e=JSON.parse(this.content);this.tags.push(...e)}},NDKCashuMintList=class e extends NDKEvent{static kind=10019;static kinds=[10019];_p2pk;constructor(e,t){super(e,t),this.kind??=10019}static from(t){return new e(t.ndk,t)}set relays(e){this.tags=this.tags.filter(e=>"relay"!==e[0]);for(const t of e)this.tags.push(["relay",t])}get relays(){const e=[];for(const t of this.tags)"relay"===t[0]&&e.push(t[1]);return e}set mints(e){this.tags=this.tags.filter(e=>"mint"!==e[0]);for(const t of e)this.tags.push(["mint",t])}get mints(){const e=[];for(const t of this.tags)"mint"===t[0]&&e.push(t[1]);return Array.from(new Set(e))}get p2pk(){return this._p2pk||(this._p2pk=this.tagValue("pubkey")??this.pubkey),this._p2pk}set p2pk(e){this._p2pk=e,this.removeTag("pubkey"),e&&this.tags.push(["pubkey",e])}get relaySet(){return NDKRelaySet.fromRelayUrls(this.relays,this.ndk)}},NDKArticle=class e extends NDKEvent{static kind=30023;static kinds=[30023];constructor(e,t){super(e,t),this.kind??=30023}static from(t){return new e(t.ndk,t)}get title(){return this.tagValue("title")}set title(e){this.removeTag("title"),e&&this.tags.push(["title",e])}get image(){return this.tagValue("image")}set image(e){this.removeTag("image"),e&&this.tags.push(["image",e])}get summary(){return this.tagValue("summary")}set summary(e){this.removeTag("summary"),e&&this.tags.push(["summary",e])}get published_at(){const e=this.tagValue("published_at");if(e){let t=Number.parseInt(e);return t>1e12&&(t=Math.floor(t/1e3)),t}}set published_at(e){this.removeTag("published_at"),void 0!==e&&this.tags.push(["published_at",e.toString()])}async generateTags(){return super.generateTags(),this.published_at||(this.published_at=this.created_at),super.generateTags()}get url(){return this.tagValue("url")}set url(e){e?this.tags.push(["url",e]):this.removeTag("url")}},NDKBlossomList=class e extends NDKEvent{static kinds=[10063];constructor(e,t){super(e,t),this.kind??=10063}static from(t){return new e(t.ndk,t.rawEvent())}get servers(){return this.tags.filter(e=>"server"===e[0]).map(e=>e[1])}set servers(e){this.tags=this.tags.filter(e=>"server"!==e[0]);for(const t of e)this.tags.push(["server",t])}get default(){const e=this.servers;return e.length>0?e[0]:void 0}set default(e){if(!e)return;const t=this.servers.filter(t=>t!==e);this.servers=[e,...t]}addServer(e){if(!e)return;const t=this.servers;t.includes(e)||(this.servers=[...t,e])}removeServer(e){if(!e)return;const t=this.servers;this.servers=t.filter(t=>t!==e)}},NDKFedimintMint=class e extends NDKEvent{static kind=38173;static kinds=[38173];constructor(e,t){super(e,t),this.kind??=38173}static async from(t){return new e(t.ndk,t)}get identifier(){return this.tagValue("d")}set identifier(e){this.removeTag("d"),e&&this.tags.push(["d",e])}get inviteCodes(){return this.getMatchingTags("u").map(e=>e[1])}set inviteCodes(e){this.removeTag("u");for(const t of e)this.tags.push(["u",t])}get modules(){return this.getMatchingTags("modules").map(e=>e[1])}set modules(e){this.removeTag("modules");for(const t of e)this.tags.push(["modules",t])}get network(){return this.tagValue("n")}set network(e){this.removeTag("n"),e&&this.tags.push(["n",e])}get metadata(){if(this.content)try{return JSON.parse(this.content)}catch{return}}set metadata(e){this.content=e?JSON.stringify(e):""}},NDKCashuMintAnnouncement=class e extends NDKEvent{static kind=38172;static kinds=[38172];constructor(e,t){super(e,t),this.kind??=38172}static async from(t){return new e(t.ndk,t)}get identifier(){return this.tagValue("d")}set identifier(e){this.removeTag("d"),e&&this.tags.push(["d",e])}get url(){return this.tagValue("u")}set url(e){this.removeTag("u"),e&&this.tags.push(["u",e])}get nuts(){return this.getMatchingTags("nuts").map(e=>e[1])}set nuts(e){this.removeTag("nuts");for(const t of e)this.tags.push(["nuts",t])}get network(){return this.tagValue("n")}set network(e){this.removeTag("n"),e&&this.tags.push(["n",e])}get metadata(){if(this.content)try{return JSON.parse(this.content)}catch{return}}set metadata(e){this.content=e?JSON.stringify(e):""}},NDKMintRecommendation=class e extends NDKEvent{static kind=38e3;static kinds=[38e3];constructor(e,t){super(e,t),this.kind??=38e3}static async from(t){return new e(t.ndk,t)}get recommendedKind(){const e=this.tagValue("k");return e?Number(e):void 0}set recommendedKind(e){this.removeTag("k"),e&&this.tags.push(["k",e.toString()])}get identifier(){return this.tagValue("d")}set identifier(e){this.removeTag("d"),e&&this.tags.push(["d",e])}get urls(){return this.getMatchingTags("u").map(e=>e[1])}set urls(e){this.removeTag("u");for(const t of e)this.tags.push(["u",t])}get mintEventPointers(){return this.getMatchingTags("a").map(e=>({kind:Number(e[1].split(":")[0]),identifier:e[1].split(":")[2],relay:e[2]}))}addMintEventPointer(e,t,n,r){const i=["a",`${e}:${t}:${n}`];r&&i.push(r),this.tags.push(i)}get review(){return this.content}set review(e){this.content=e}},NDKClassified=class e extends NDKEvent{static kinds=[30402];constructor(e,t){super(e,t),this.kind??=30402}static from(t){return new e(t.ndk,t)}get title(){return this.tagValue("title")}set title(e){this.removeTag("title"),e&&this.tags.push(["title",e])}get summary(){return this.tagValue("summary")}set summary(e){this.removeTag("summary"),e&&this.tags.push(["summary",e])}get published_at(){const e=this.tagValue("published_at");if(e)return Number.parseInt(e)}set published_at(e){this.removeTag("published_at"),void 0!==e&&this.tags.push(["published_at",e.toString()])}get location(){return this.tagValue("location")}set location(e){this.removeTag("location"),e&&this.tags.push(["location",e])}get price(){const e=this.tags.find(e=>"price"===e[0]);if(e)return{amount:Number.parseFloat(e[1]),currency:e[2],frequency:e[3]}}set price(e){if("string"==typeof e&&(e={amount:Number.parseFloat(e)}),e?.amount){const t=["price",e.amount.toString()];e.currency&&t.push(e.currency),e.frequency&&t.push(e.frequency),this.tags.push(t)}else this.removeTag("price")}async generateTags(){return super.generateTags(),this.published_at||(this.published_at=this.created_at),super.generateTags()}},NDKDraft=class e extends NDKEvent{_event;static kind=31234;static kinds=[31234,1234];counterparty;constructor(e,t){super(e,t),this.kind??=31234}static from(t){return new e(t.ndk,t)}set identifier(e){this.removeTag("d"),this.tags.push(["d",e])}get identifier(){return this.dTag}set event(e){this._event=e instanceof NDKEvent?e:new NDKEvent(void 0,e),this.prepareEvent()}set checkpoint(e){e?(this.tags.push(e.tagReference()),this.kind=1234):(this.removeTag("a"),this.kind=31234)}get isCheckpoint(){return 1234===this.kind}get isProposal(){const e=this.tagValue("p");return!!e&&e!==this.pubkey}async getEvent(e){if(this._event)return this._event;if(e??=this.ndk?.signer,!e)throw new Error("No signer available");if(!(this.content&&this.content.length>0))return null;try{const t=e.pubkey,n=[this.tagValue("p"),this.pubkey].filter(Boolean).find(e=>e!==t);let r;r=new NDKUser({pubkey:n??t}),await this.decrypt(r,e);const i=JSON.parse(this.content);return this._event=await wrapEvent(new NDKEvent(this.ndk,i)),this._event}catch(e){return void console.error(e)}}prepareEvent(){if(!this._event)throw new Error("No event has been provided");this.removeTag("k"),this._event.kind&&this.tags.push(["k",this._event.kind.toString()]),this.content=JSON.stringify(this._event.rawEvent())}async save({signer:e,publish:t,relaySet:n}){if(e??=this.ndk?.signer,!e)throw new Error("No signer available");const r=this.counterparty||await e.user();if(await this.encrypt(r,e),this.counterparty){const e=this.counterparty.pubkey;this.removeTag("p"),this.tags.push(["p",e])}if(!1!==t)return this.publishReplaceable(n)}};function mapImetaTag(e){const t={};if(2===e.length){const n=e[1].split(" ");for(let e=0;e<n.length;e+=2){const r=n[e],i=n[e+1];"fallback"===r?(t.fallback||(t.fallback=[]),t.fallback.push(i)):t[r]=i}return t}const n=e.slice(1);for(const e of n){const n=e.split(" "),r=n[0],i=n.slice(1).join(" ");"fallback"===r?(t.fallback||(t.fallback=[]),t.fallback.push(i)):t[r]=i}return t}function imetaTagToTag(e){const t=["imeta"];for(const[n,r]of Object.entries(e))if(Array.isArray(r))for(const e of r)t.push(`${n} ${e}`);else r&&t.push(`${n} ${r}`);return t}var NDKFollowPack=class e extends NDKEvent{static kind=39089;static kinds=[39089,39092];constructor(e,t){super(e,t),this.kind??=39089}static from(t){return new e(t.ndk,t)}get title(){return this.tagValue("title")}set title(e){this.removeTag("title"),e&&this.tags.push(["title",e])}get image(){const e=this.tags.find(e=>"imeta"===e[0]);if(e){const t=mapImetaTag(e);if(t.url)return t.url}return this.tagValue("image")}set image(e){this.tags=this.tags.filter(e=>"imeta"!==e[0]&&"image"!==e[0]),"string"==typeof e?void 0!==e&&this.tags.push(["image",e]):e&&"object"==typeof e&&(this.tags.push(imetaTagToTag(e)),e.url&&this.tags.push(["image",e.url]))}get pubkeys(){return Array.from(new Set(this.tags.filter(e=>"p"===e[0]&&e[1]&&isValidPubkey(e[1])).map(e=>e[1])))}set pubkeys(e){this.tags=this.tags.filter(e=>"p"!==e[0]);for(const t of e)this.tags.push(["p",t])}get description(){return this.tagValue("description")}set description(e){this.removeTag("description"),e&&this.tags.push(["description",e])}},NDKHighlight=class e extends NDKEvent{_article;static kind=9802;static kinds=[9802];constructor(e,t){super(e,t),this.kind??=9802}static from(t){return new e(t.ndk,t)}get url(){return this.tagValue("r")}set context(e){void 0===e?this.tags=this.tags.filter(([e,t])=>"context"!==e):(this.tags=this.tags.filter(([e,t])=>"context"!==e),this.tags.push(["context",e]))}get context(){return this.tags.find(([e,t])=>"context"===e)?.[1]??void 0}get article(){return this._article}set article(e){this._article=e,"string"==typeof e?this.tags.push(["r",e]):this.tag(e)}getArticleTag(){return this.getMatchingTags("a")[0]||this.getMatchingTags("e")[0]||this.getMatchingTags("r")[0]}async getArticle(){if(void 0!==this._article)return this._article;let e;const t=this.getArticleTag();if(t){switch(t[0]){case"a":{const[n,r,i]=t[1].split(":");e=nip19_exports$2.naddrEncode({kind:Number.parseInt(n),pubkey:r,identifier:i});break}case"e":e=nip19_exports$2.noteEncode(t[1]);break;case"r":this._article=t[1]}if(e){let t=await(this.ndk?.fetchEvent(e));t&&(30023===t.kind&&(t=NDKArticle.from(t)),this._article=t)}return this._article}}},NDKImage=class e extends NDKEvent{static kind=20;static kinds=[20];_imetas;constructor(e,t){super(e,t),this.kind??=20}static from(t){return new e(t.ndk,t.rawEvent())}get isValid(){return this.imetas.length>0}get imetas(){return this._imetas||(this._imetas=this.tags.filter(e=>"imeta"===e[0]).map(mapImetaTag).filter(e=>!!e.url)),this._imetas}set imetas(e){this._imetas=e,this.tags=this.tags.filter(e=>"imeta"!==e[0]),this.tags.push(...e.map(imetaTagToTag))}},NDKList=class e extends NDKEvent{_encryptedTags;static kinds=[30001,10004,10050,10030,10015,10001,10002,10007,10006,10003];encryptedTagsLength;constructor(e,t){super(e,t),this.kind??=30001}static from(t){return new e(t.ndk,t)}get title(){const e=this.tagValue("title")||this.tagValue("name");return e||(3===this.kind?"Contacts":1e4===this.kind?"Mute":10001===this.kind?"Pinned Notes":10002===this.kind?"Relay Metadata":10003===this.kind?"Bookmarks":10004===this.kind?"Communities":10005===this.kind?"Public Chats":10006===this.kind?"Blocked Relays":10007===this.kind?"Search Relays":10050===this.kind?"Direct Message Receive Relays":10015===this.kind?"Interests":10030===this.kind?"Emojis":this.tagValue("d"))}set title(e){this.removeTag(["title","name"]),e&&this.tags.push(["title",e])}get name(){return this.title}set name(e){this.title=e}get description(){return this.tagValue("description")}set description(e){this.removeTag("description"),e&&this.tags.push(["description",e])}get image(){return this.tagValue("image")}set image(e){this.removeTag("image"),e&&this.tags.push(["image",e])}isEncryptedTagsCacheValid(){return!(!this._encryptedTags||this.encryptedTagsLength!==this.content.length)}async encryptedTags(e=!0){if(e&&this.isEncryptedTagsCacheValid())return this._encryptedTags;if(!this.ndk)throw new Error("NDK instance not set");if(!this.ndk.signer)throw new Error("NDK signer not set");const t=await this.ndk.signer.user();try{if(this.content.length>0)try{const e=await this.ndk.signer.decrypt(t,this.content),n=JSON.parse(e);return n?.[0]?(this.encryptedTagsLength=this.content.length,this._encryptedTags=n):(this.encryptedTagsLength=this.content.length,this._encryptedTags=[])}catch(e){}}catch(e){}return[]}validateTag(e){return!0}getItems(e){return this.tags.filter(t=>t[0]===e)}get items(){return this.tags.filter(e=>!["d","L","l","title","name","description","published_at","summary","image","thumb","alt","expiration","subject","client"].includes(e[0]))}async addItem(e,t=void 0,n=!1,r="bottom"){if(!this.ndk)throw new Error("NDK instance not set");if(!this.ndk.signer)throw new Error("NDK signer not set");let i;if(e instanceof NDKEvent)i=[e.tagReference(t)];else if(e instanceof NDKUser)i=e.referenceTags();else if(e instanceof NDKRelay)i=e.referenceTags();else{if(!Array.isArray(e))throw new Error("Invalid object type");i=[e]}if(t&&i[0].push(t),n){const e=await this.ndk.signer.user(),t=await this.encryptedTags();"top"===r?t.unshift(...i):t.push(...i),this._encryptedTags=t,this.encryptedTagsLength=this.content.length,this.content=JSON.stringify(t),await this.encrypt(e)}else"top"===r?this.tags.unshift(...i):this.tags.push(...i);this.created_at=Math.floor(Date.now()/1e3),this.emit("change")}async removeItemByValue(e,t=!0){if(!this.ndk)throw new Error("NDK instance not set");if(!this.ndk.signer)throw new Error("NDK signer not set");const n=this.tags.findIndex(t=>t[1]===e);n>=0&&this.tags.splice(n,1);const r=await this.ndk.signer.user(),i=await this.encryptedTags(),s=i.findIndex(t=>t[1]===e);if(s>=0&&(i.splice(s,1),this._encryptedTags=i,this.encryptedTagsLength=this.content.length,this.content=JSON.stringify(i),await this.encrypt(r)),t)return this.publishReplaceable();this.created_at=Math.floor(Date.now()/1e3),this.emit("change")}async removeItem(e,t){if(!this.ndk)throw new Error("NDK instance not set");if(!this.ndk.signer)throw new Error("NDK signer not set");if(t){const t=await this.ndk.signer.user(),n=await this.encryptedTags();n.splice(e,1),this._encryptedTags=n,this.encryptedTagsLength=this.content.length,this.content=JSON.stringify(n),await this.encrypt(t)}else this.tags.splice(e,1);return this.created_at=Math.floor(Date.now()/1e3),this.emit("change"),this}has(e){return this.items.some(t=>t[1]===e)}filterForItems(){const e=new Set,t=new Map,n=[];for(const n of this.items)if("e"===n[0]&&n[1])e.add(n[1]);else if("a"===n[0]&&n[1]){const[e,r,i]=n[1].split(":");if(!e||!r)continue;const s=`${e}:${r}`,o=t.get(s)||[];o.push(i||""),t.set(s,o)}if(e.size>0&&n.push({ids:Array.from(e)}),t.size>0)for(const[e,r]of t.entries()){const[t,i]=e.split(":");n.push({kinds:[Number.parseInt(t)],authors:[i],"#d":r})}return n}},NDKAppHandlerEvent=class e extends NDKEvent{profile;static kinds=[31990];constructor(e,t){super(e,t),this.kind??=31990}static from(t){const n=new e(t.ndk,t.rawEvent());return n.isValid?n:null}get isValid(){const e=new Map,t=e=>[e[0],e[2]].join(":").toLowerCase(),n=["web","android","ios"];for(const r of this.tags)if(n.includes(r[0])){const n=t(r);if(e.has(n)&&e.get(n)!==r[1].toLowerCase())return!1;e.set(n,r[1].toLowerCase())}return!0}async fetchProfile(){if(void 0===this.profile&&this.content.length>0)try{const e=JSON.parse(this.content);if(e?.name)return e;this.profile=null}catch(e){this.profile=null}return new Promise((e,t)=>{const n=this.author;n.fetchProfile().then(()=>{e(n.profile)}).catch(t)})}},NDKNutzap=class e extends NDKEvent{debug;_proofs=[];static kind=9321;static kinds=[e.kind];constructor(e,t){super(e,t),this.kind??=9321,this.debug=e?.debug.extend("nutzap")??createDebug5("ndk:nutzap"),this.alt||(this.alt="This is a nutzap");try{const e=this.getMatchingTags("proof");e.length?this._proofs=e.map(e=>JSON.parse(e[1])):this._proofs=JSON.parse(this.content)}catch{return}}static from(t){const n=new e(t.ndk,t);if(n._proofs&&n._proofs.length)return n}set comment(e){this.content=e??""}get comment(){const e=this.tagValue("comment");return e||this.content}set proofs(e){this._proofs=e,this.tags=this.tags.filter(e=>"proof"!==e[0]);for(const t of e)this.tags.push(["proof",JSON.stringify(t)])}get proofs(){return this._proofs}get rawP2pk(){const e=this.proofs[0];try{const t=JSON.parse(e.secret);let n;if("string"==typeof t?(n=JSON.parse(t),this.debug("stringified payload",e.secret)):"object"==typeof t&&(n=t),Array.isArray(n)&&"P2PK"===n[0]&&n.length>1&&"object"==typeof n[1]&&null!==n[1])return n[1].data;if("object"==typeof n&&null!==n&&"string"==typeof n[1]?.data)return n[1].data}catch(e){this.debug("error parsing p2pk pubkey",e,this.proofs[0])}}get p2pk(){const e=this.rawP2pk;if(e)return e.startsWith("02")?e.slice(2):e}get mint(){return this.tagValue("u")}set mint(e){this.replaceTag(["u",e])}get unit(){let e=this.tagValue("unit")??"sat";return e?.startsWith("msat")&&(e="sat"),e}set unit(e){if(this.removeTag("unit"),e?.startsWith("msat"))throw new Error("msat is not allowed, use sat denomination instead");e&&this.tag(["unit",e])}get amount(){return this.proofs.reduce((e,t)=>e+t.amount,0)}sender=this.author;set target(e){this.tags=this.tags.filter(e=>"p"!==e[0]),e instanceof NDKEvent&&this.tags.push(e.tagReference())}set recipientPubkey(e){this.removeTag("p"),this.tag(["p",e])}get recipientPubkey(){return this.tagValue("p")}get recipient(){const e=this.recipientPubkey;return this.ndk?this.ndk.getUser({pubkey:e}):new NDKUser({pubkey:e})}async toNostrEvent(){"msat"===this.unit&&(this.unit="sat"),this.removeTag("amount"),this.tags.push(["amount",this.amount.toString()]);const e=await super.toNostrEvent();return e.content=this.comment,e}get isValid(){let e=0,t=0,n=0;for(const r of this.tags)"e"===r[0]&&e++,"p"===r[0]&&t++,"u"===r[0]&&n++;return 1===t&&1===n&&e<=1&&this.proofs.length>0}},NDKProject=class e extends NDKEvent{static kind=31933;static kinds=[31933];_signer;constructor(e,t){super(e,t),this.kind=31933}static from(t){return new e(t.ndk,t.rawEvent())}set repo(e){this.removeTag("repo"),e&&this.tags.push(["repo",e])}set hashtags(e){this.removeTag("hashtags"),e.filter(e=>e.length>0).length&&this.tags.push(["hashtags",...e])}get hashtags(){const e=this.tags.find(e=>"hashtags"===e[0]);return e?e.slice(1):[]}get repo(){return this.tagValue("repo")}get title(){return this.tagValue("title")}set title(e){this.removeTag("title"),e&&this.tags.push(["title",e])}get picture(){return this.tagValue("picture")}set picture(e){this.removeTag("picture"),e&&this.tags.push(["picture",e])}set description(e){this.content=e}get description(){return this.content}get slug(){return this.dTag??"empty-dtag"}async getSigner(){if(this._signer)return this._signer;const e=this.tagValue("key");if(e){const t=await(this.ndk?.signer?.decrypt(this.ndk.activeUser,e));if(!t)throw new Error("Failed to decrypt project key or missing signer context.");this._signer=new NDKPrivateKeySigner(t)}else this._signer=NDKPrivateKeySigner.generate(),await this.encryptAndSaveNsec();return this._signer}async getNsec(){return(await this.getSigner()).privateKey}async setNsec(e){this._signer=new NDKPrivateKeySigner(e),await this.encryptAndSaveNsec()}async encryptAndSaveNsec(){if(!this._signer)throw new Error("Signer is not set.");const e=this._signer.privateKey,t=await(this.ndk?.signer?.encrypt(this.ndk.activeUser,e));t&&(this.removeTag("key"),this.tags.push(["key",t]))}},NDKProjectTemplate=class e extends NDKEvent{static kind=30717;static kinds=[30717];constructor(e,t){super(e,t),this.kind=30717}static from(t){return new e(t.ndk,t.rawEvent())}get templateId(){return this.dTag??""}set templateId(e){this.dTag=e}get name(){return this.tagValue("title")??""}set name(e){this.removeTag("title"),e&&this.tags.push(["title",e])}get description(){return this.tagValue("description")??""}set description(e){this.removeTag("description"),e&&this.tags.push(["description",e])}get repoUrl(){return this.tagValue("uri")??""}set repoUrl(e){this.removeTag("uri"),e&&this.tags.push(["uri",e])}get image(){return this.tagValue("image")}set image(e){this.removeTag("image"),e&&this.tags.push(["image",e])}get command(){return this.tagValue("command")}set command(e){this.removeTag("command"),e&&this.tags.push(["command",e])}get agentConfig(){const e=this.tagValue("agent");if(e)try{return JSON.parse(e)}catch{return}}set agentConfig(e){this.removeTag("agent"),e&&this.tags.push(["agent",JSON.stringify(e)])}get templateTags(){return this.getMatchingTags("t").map(e=>e[1]).filter(Boolean)}set templateTags(e){this.tags=this.tags.filter(e=>"t"!==e[0]),e.forEach(e=>{e&&this.tags.push(["t",e])})}},READ_MARKER="read",WRITE_MARKER="write",NDKRelayList=class e extends NDKEvent{static kinds=[10002];constructor(e,t){super(e,t),this.kind??=10002}static from(t){return new e(t.ndk,t.rawEvent())}get readRelayUrls(){return this.tags.filter(e=>"r"===e[0]||"relay"===e[0]).filter(e=>!e[2]||e[2]&&e[2]===READ_MARKER).map(e=>tryNormalizeRelayUrl(e[1])).filter(e=>!!e)}set readRelayUrls(e){for(const t of e)this.tags.push(["r",t,READ_MARKER])}get writeRelayUrls(){return this.tags.filter(e=>"r"===e[0]||"relay"===e[0]).filter(e=>!e[2]||e[2]&&e[2]===WRITE_MARKER).map(e=>tryNormalizeRelayUrl(e[1])).filter(e=>!!e)}set writeRelayUrls(e){for(const t of e)this.tags.push(["r",t,WRITE_MARKER])}get bothRelayUrls(){return this.tags.filter(e=>"r"===e[0]||"relay"===e[0]).filter(e=>!e[2]).map(e=>e[1])}set bothRelayUrls(e){for(const t of e)this.tags.push(["r",t])}get relays(){return this.tags.filter(e=>"r"===e[0]||"relay"===e[0]).map(e=>e[1])}get relaySet(){if(!this.ndk)throw new Error("NDKRelayList has no NDK instance");return new NDKRelaySet(new Set(this.relays.map(e=>this.ndk?.pool.getRelay(e)).filter(e=>!!e)),this.ndk)}};function relayListFromKind3(e,t){try{const n=JSON.parse(t.content),r=new NDKRelayList(e),i=new Set,s=new Set;for(let[e,t]of Object.entries(n)){try{e=normalizeRelayUrl(e)}catch{continue}if(t){const n=t;n.write&&s.add(e),n.read&&i.add(e)}else i.add(e),s.add(e)}return r.readRelayUrls=Array.from(i),r.writeRelayUrls=Array.from(s),r}catch{}}var NDKRepost=class e extends NDKEvent{_repostedEvents;static kinds=[6,16];static from(t){return new e(t.ndk,t.rawEvent())}async repostedEvents(e,t){const n=[];if(!this.ndk)throw new Error("NDK instance not set");if(void 0!==this._repostedEvents)return this._repostedEvents;for(const r of this.repostedEventIds()){const i=filterForId(r),s=await this.ndk.fetchEvent(i,t);s&&n.push(e?e.from(s):s)}return n}repostedEventIds(){return this.tags.filter(e=>"e"===e[0]||"a"===e[0]).map(e=>e[1])}};function filterForId(e){if(e.match(/:/)){const[t,n,r]=e.split(":");return{kinds:[Number.parseInt(t)],authors:[n],"#d":[r]}}return{ids:[e]}}var NDKSimpleGroupMemberList=class e extends NDKEvent{relaySet;memberSet=new Set;static kind=39002;static kinds=[39002];constructor(e,t){super(e,t),this.kind??=39002,this.memberSet=new Set(this.members)}static from(t){return new e(t.ndk,t)}get members(){return this.getMatchingTags("p").map(e=>e[1])}hasMember(e){return this.memberSet.has(e)}async publish(e,t,n){return e??=this.relaySet,super.publishReplaceable(e,t,n)}},NDKSimpleGroupMetadata=class e extends NDKEvent{static kind=39e3;static kinds=[39e3];constructor(e,t){super(e,t),this.kind??=39e3}static from(t){return new e(t.ndk,t)}get name(){return this.tagValue("name")}get picture(){return this.tagValue("picture")}get about(){return this.tagValue("about")}get scope(){return this.getMatchingTags("public").length>0?"public":this.getMatchingTags("public").length>0?"private":void 0}set scope(e){this.removeTag("public"),this.removeTag("private"),"public"===e?this.tags.push(["public",""]):"private"===e&&this.tags.push(["private",""])}get access(){return this.getMatchingTags("open").length>0?"open":this.getMatchingTags("closed").length>0?"closed":void 0}set access(e){this.removeTag("open"),this.removeTag("closed"),"open"===e?this.tags.push(["open",""]):"closed"===e&&this.tags.push(["closed",""])}};function strToPosition(e){const[t,n]=e.split(",").map(Number);return{x:t,y:n}}function strToDimension(e){const[t,n]=e.split("x").map(Number);return{width:t,height:n}}var NDKStorySticker=class e{static Text="text";static Pubkey="pubkey";static Event="event";static Prompt="prompt";static Countdown="countdown";type;value;position;dimension;properties;constructor(e){if(Array.isArray(e)){const t=e;if("sticker"!==t[0]||t.length<5)throw new Error("Invalid sticker tag");this.type=t[1],this.value=t[2],this.position=strToPosition(t[3]),this.dimension=strToDimension(t[4]);const n={};for(let e=5;e<t.length;e++){const[r,...i]=t[e].split(" ");n[r]=i.join(" ")}Object.keys(n).length>0&&(this.properties=n)}else this.type=e,this.value=void 0,this.position={x:0,y:0},this.dimension={width:0,height:0}}static fromTag(t){try{return new e(t)}catch{return null}}get style(){return this.properties?.style}set style(e){e?this.properties={...this.properties,style:e}:delete this.properties?.style}get rotation(){return this.properties?.rot?Number.parseFloat(this.properties.rot):void 0}set rotation(e){void 0!==e?this.properties={...this.properties,rot:e.toString()}:delete this.properties?.rot}get isValid(){return this.hasValidDimensions()&&this.hasValidPosition()}hasValidDimensions=()=>"number"==typeof this.dimension.width&&"number"==typeof this.dimension.height&&!Number.isNaN(this.dimension.width)&&!Number.isNaN(this.dimension.height);hasValidPosition=()=>"number"==typeof this.position.x&&"number"==typeof this.position.y&&!Number.isNaN(this.position.x)&&!Number.isNaN(this.position.y);toTag(){if(!this.isValid){const e=[this.hasValidDimensions()?void 0:"dimensions is invalid",this.hasValidPosition()?void 0:"position is invalid"].filter(Boolean);throw new Error(`Invalid sticker: ${e.join(", ")}`)}let e;switch(this.type){case"event":e=this.value.tagId();break;case"pubkey":e=this.value.pubkey;break;default:e=this.value}const t=["sticker",this.type,e,coordinates(this.position),dimension(this.dimension)];if(this.properties)for(const[e,n]of Object.entries(this.properties))t.push(`${e} ${n}`);return t}},NDKStory=class e extends NDKEvent{static kind=23;static kinds=[23];_imeta;_dimensions;constructor(e,t){if(super(e,t),this.kind??=23,t)for(const e of t.tags)switch(e[0]){case"imeta":this._imeta=mapImetaTag(e);break;case"dim":this.dimensions=strToDimension(e[1])}}static from(t){return new e(t.ndk,t)}get isValid(){return!!this.imeta}get imeta(){return this._imeta}set imeta(e){this._imeta=e,this.tags=this.tags.filter(e=>"imeta"!==e[0]),e&&this.tags.push(imetaTagToTag(e))}get dimensions(){const e=this.tagValue("dim");if(e)return strToDimension(e)}set dimensions(e){this.removeTag("dim"),e&&this.tags.push(["dim",`${e.width}x${e.height}`])}get duration(){const e=this.tagValue("dur");if(e)return Number.parseInt(e)}set duration(e){this.removeTag("dur"),void 0!==e&&this.tags.push(["dur",e.toString()])}get stickers(){const e=[];for(const t of this.tags){if("sticker"!==t[0]||t.length<5)continue;const n=NDKStorySticker.fromTag(t);n&&e.push(n)}return e}addSticker(e){let t;if(e instanceof NDKStorySticker)t=e;else{const n=["sticker",e.type,"string"==typeof e.value?e.value:"",coordinates(e.position),dimension(e.dimension)];if(e.properties)for(const[t,r]of Object.entries(e.properties))n.push(`${t} ${r}`);t=new NDKStorySticker(n),t.value=e.value}("pubkey"===t.type||"event"===t.type)&&this.tag(t.value),this.tags.push(t.toTag())}removeSticker(e){const t=this.stickers;if(e<0||e>=t.length)return;let n=0;for(let t=0;t<this.tags.length;t++)if("sticker"===this.tags[t][0]){if(n===e){this.tags.splice(t,1);break}n++}}},coordinates=e=>`${e.x},${e.y}`,dimension=e=>`${e.width}x${e.height}`,NDKSubscriptionReceipt=class e extends NDKEvent{debug;static kinds=[7003];constructor(e,t){super(e,t),this.kind??=7003,this.debug=e?.debug.extend("subscription-start")??createDebug5("ndk:subscription-start")}static from(t){return new e(t.ndk,t.rawEvent())}get recipient(){const e=this.getMatchingTags("p")?.[0];if(!e)return;return new NDKUser({pubkey:e[1]})}set recipient(e){this.removeTag("p"),e&&this.tags.push(["p",e.pubkey])}get subscriber(){const e=this.getMatchingTags("P")?.[0];if(!e)return;return new NDKUser({pubkey:e[1]})}set subscriber(e){this.removeTag("P"),e&&this.tags.push(["P",e.pubkey])}set subscriptionStart(e){this.debug(`before setting subscription start: ${this.rawEvent}`),this.removeTag("e"),this.tag(e,"subscription",!0),this.debug(`after setting subscription start: ${this.rawEvent}`)}get tierName(){const e=this.getMatchingTags("tier")?.[0];return e?.[1]}get isValid(){const e=this.validPeriod;if(!e)return!1;if(e.start>e.end)return!1;const t=this.getMatchingTags("p"),n=this.getMatchingTags("P");return 1===t.length&&1===n.length}get validPeriod(){const e=this.getMatchingTags("valid")?.[0];if(e)try{return{start:new Date(1e3*Number.parseInt(e[1])),end:new Date(1e3*Number.parseInt(e[2]))}}catch{return}}set validPeriod(e){this.removeTag("valid"),e&&this.tags.push(["valid",Math.floor(e.start.getTime()/1e3).toString(),Math.floor(e.end.getTime()/1e3).toString()])}get startPeriod(){return this.validPeriod?.start}get endPeriod(){return this.validPeriod?.end}isActive(e){e??=new Date;const t=this.validPeriod;return!!t&&(!(e<t.start)&&!(e>t.end))}},possibleIntervalFrequencies=["daily","weekly","monthly","quarterly","yearly"];function newAmount(e,t,n){return["amount",e.toString(),t,n]}function parseTagToSubscriptionAmount(e){const t=Number.parseInt(e[1]);if(Number.isNaN(t)||null==t||t<=0)return;const n=e[2];if(void 0===n||""===n)return;const r=e[3];return void 0!==r&&possibleIntervalFrequencies.includes(r)?{amount:t,currency:n,term:r}:void 0}var NDKSubscriptionTier=class e extends NDKArticle{static kind=37001;static kinds=[37001];constructor(e,t){const n=t?.kind??37001;super(e,t),this.kind=n}static from(t){return new e(t.ndk,t)}get perks(){return this.getMatchingTags("perk").map(e=>e[1]).filter(e=>void 0!==e)}addPerk(e){this.tags.push(["perk",e])}get amounts(){return this.getMatchingTags("amount").map(e=>parseTagToSubscriptionAmount(e)).filter(e=>void 0!==e)}addAmount(e,t,n){this.tags.push(newAmount(e,t,n))}set relayUrl(e){this.tags.push(["r",e])}get relayUrls(){return this.getMatchingTags("r").map(e=>e[1]).filter(e=>void 0!==e)}get verifierPubkey(){return this.tagValue("p")}set verifierPubkey(e){this.removeTag("p"),e&&this.tags.push(["p",e])}get isValid(){return void 0!==this.title&&this.amounts.length>0}},NDKSubscriptionStart=class e extends NDKEvent{debug;static kinds=[7001];constructor(e,t){super(e,t),this.kind??=7001,this.debug=e?.debug.extend("subscription-start")??createDebug5("ndk:subscription-start")}static from(t){return new e(t.ndk,t.rawEvent())}get recipient(){const e=this.getMatchingTags("p")?.[0];if(!e)return;return new NDKUser({pubkey:e[1]})}set recipient(e){this.removeTag("p"),e&&this.tags.push(["p",e.pubkey])}get amount(){const e=this.getMatchingTags("amount")?.[0];if(e)return parseTagToSubscriptionAmount(e)}set amount(e){this.removeTag("amount"),e&&this.tags.push(newAmount(e.amount,e.currency,e.term))}get tierId(){const e=this.getMatchingTags("e")?.[0],t=this.getMatchingTags("a")?.[0];if(e&&t)return e[1]??t[1]}set tier(e){this.removeTag("e"),this.removeTag("a"),this.removeTag("event"),e&&(this.tag(e),this.removeTag("p"),this.tags.push(["p",e.pubkey]),this.tags.push(["event",JSON.stringify(e.rawEvent())]))}async fetchTier(){const e=this.tagValue("event");if(e)try{const t=JSON.parse(e);return new NDKSubscriptionTier(this.ndk,t)}catch{this.debug("Failed to parse event tag")}const t=this.tierId;if(!t)return;const n=await(this.ndk?.fetchEvent(t));return n?NDKSubscriptionTier.from(n):void 0}get isValid(){return 1!==this.getMatchingTags("amount").length?(this.debug("Invalid # of amount tag"),!1):this.amount?1!==this.getMatchingTags("p").length?(this.debug("Invalid # of p tag"),!1):!!this.recipient||(this.debug("Invalid p tag"),!1):(this.debug("Invalid amount tag"),!1)}},NDKTask=class e extends NDKEvent{static kind=1934;static kinds=[1934];constructor(e,t){super(e,t),this.kind=1934}static from(t){return new e(t.ndk,t.rawEvent())}set title(e){this.removeTag("title"),e&&this.tags.push(["title",e])}get title(){return this.tagValue("title")}set project(e){this.removeTag("a"),this.tags.push(e.tagReference())}get projectSlug(){const e=this.getMatchingTags("a")[0];return e?e[1].split(/:/)?.[2]:void 0}},NDKThread=class e extends NDKEvent{static kind=11;static kinds=[11];constructor(e,t){super(e,t),this.kind??=11}static from(t){return new e(t.ndk,t)}get title(){return this.tagValue("title")}set title(e){this.removeTag("title"),e&&this.tags.push(["title",e])}},NDKVideo=class e extends NDKEvent{static kind=21;static kinds=[34235,34236,22,21];_imetas;static from(t){return new e(t.ndk,t.rawEvent())}get title(){return this.tagValue("title")}set title(e){this.removeTag("title"),e&&this.tags.push(["title",e])}get thumbnail(){let e;return this.imetas&&this.imetas.length>0&&(e=this.imetas[0].image?.[0]),e??this.tagValue("thumb")}get imetas(){return this._imetas||(this._imetas=this.tags.filter(e=>"imeta"===e[0]).map(mapImetaTag)),this._imetas}set imetas(e){this._imetas=e,this.tags=this.tags.filter(e=>"imeta"!==e[0]),this.tags.push(...e.map(imetaTagToTag))}get url(){return this.imetas&&this.imetas.length>0?this.imetas[0].url:this.tagValue("url")}get published_at(){const e=this.tagValue("published_at");if(e)return Number.parseInt(e)}async generateTags(){if(super.generateTags(),!this.kind&&this.imetas?.[0]?.dim){const[e,t]=this.imetas[0].dim.split("x"),n=e&&t&&Number.parseInt(e)<Number.parseInt(t),r=this.duration&&this.duration<120;this.kind=r&&n?22:21}return super.generateTags()}get duration(){const e=this.tagValue("duration");if(e)return Number.parseInt(e)}set duration(e){this.removeTag("duration"),void 0!==e&&this.tags.push(["duration",Math.floor(e).toString()])}},NDKWiki=class e extends NDKArticle{static kind=30818;static kinds=[30818];static from(t){return new e(t.ndk,t.rawEvent())}get isDefered(){return this.hasTag("a","defer")}get deferedId(){return this.tagValue("a","defer")}set defer(e){this.removeTag("a","defer"),this.tag(e,"defer")}},NDKWikiMergeRequest=class e extends NDKEvent{static kinds=[818];static from(t){return new e(t.ndk,t.rawEvent())}get targetId(){return this.tagValue("a")}set target(e){this.tags=this.tags.filter(e=>"a"===e[0]||("e"===e[0]&&"source"!==e[3]||void 0)),this.tag(e)}get sourceId(){return this.tagValue("e","source")}set source(e){this.removeTag("e","source"),this.tag(e,"source",!1,"e")}},registeredEventClasses=new Set;function wrapEvent(e){const t=new Map,n=[...[NDKImage,NDKVideo,NDKCashuMintList,NDKArticle,NDKHighlight,NDKDraft,NDKWiki,NDKWikiMergeRequest,NDKNutzap,NDKProject,NDKTask,NDKProjectTemplate,NDKSimpleGroupMemberList,NDKSimpleGroupMetadata,NDKSubscriptionTier,NDKSubscriptionStart,NDKSubscriptionReceipt,NDKList,NDKRelayList,NDKStory,NDKBlossomList,NDKFollowPack,NDKThread,NDKRepost,NDKClassified,NDKAppHandlerEvent,NDKDVMJobFeedback,NDKCashuMintAnnouncement,NDKFedimintMint,NDKMintRecommendation],...registeredEventClasses];for(const e of n)for(const n of e.kinds)t.set(n,e);const r=t.get(e.kind);return r?r.from(e):e}function checkMissingKind(e,t){void 0!==e.kind&&null!==e.kind||t("event-missing-kind",`Cannot sign event without 'kind'.\n\n📦 Event data:\n • content: ${e.content?`"${e.content.substring(0,50)}${e.content.length>50?"...":""}"`:"(empty)"}\n • tags: ${e.tags.length} tag${1!==e.tags.length?"s":""}\n • kind: ${e.kind} ❌\n\nSet event.kind before signing.`,"Example: event.kind = 1; // for text note",!1)}function checkContentIsObject(e,t){if("object"==typeof e.content){const n=JSON.stringify(e.content,null,2).substring(0,200);t("event-content-is-object",`Event content is an object. Content must be a string.\n\n📦 Your content (${typeof e.content}):\n${n}${JSON.stringify(e.content).length>200?"...":""}\n\n❌ event.content = { ... } // WRONG\n✅ event.content = JSON.stringify({ ... }) // CORRECT`,"Use JSON.stringify() for structured data: event.content = JSON.stringify(data)",!1)}}function checkCreatedAtMilliseconds(e,t){if(e.created_at&&e.created_at>1e10){const n=Math.floor(e.created_at/1e3),r=new Date(e.created_at).toISOString();t("event-created-at-milliseconds",`Event created_at is in milliseconds, not seconds.\n\n📦 Your value:\n • created_at: ${e.created_at} ❌\n • Interpreted as: ${r}\n • Should be: ${n} ✅\n\nNostr timestamps MUST be in seconds since Unix epoch.`,"Use Math.floor(Date.now() / 1000) instead of Date.now()",!1)}}function checkInvalidPTags(e,t){e.getMatchingTags("p").forEach((e,n)=>{if(e[1]&&!/^[0-9a-f]{64}$/i.test(e[1])){const r=JSON.stringify(e);t("tag-invalid-p-tag",`p-tag[${n}] has invalid pubkey.\n\n📦 Your tag:\n ${r}\n\n❌ Invalid value: "${e[1]}"\n • Length: ${e[1].length} (expected 64)\n • Format: ${e[1].startsWith("npub")?"bech32 (npub)":"unknown"}\n\np-tags MUST contain 64-character hex pubkeys.`,e[1].startsWith("npub")?"Use ndkUser.pubkey instead of npub:\n ✅ event.tags.push(['p', ndkUser.pubkey])\n ❌ event.tags.push(['p', 'npub1...'])":"p-tags must contain valid hex pubkeys (64 characters, 0-9a-f)",!1)}})}function checkInvalidETags(e,t){e.getMatchingTags("e").forEach((e,n)=>{if(e[1]&&!/^[0-9a-f]{64}$/i.test(e[1])){const r=JSON.stringify(e),i=e[1].startsWith("note")||e[1].startsWith("nevent");t("tag-invalid-e-tag",`e-tag[${n}] has invalid event ID.\n\n📦 Your tag:\n ${r}\n\n❌ Invalid value: "${e[1]}"\n • Length: ${e[1].length} (expected 64)\n • Format: ${i?"bech32 (note/nevent)":"unknown"}\n\ne-tags MUST contain 64-character hex event IDs.`,i?"Use event.id instead of bech32:\n ✅ event.tags.push(['e', referencedEvent.id])\n ❌ event.tags.push(['e', 'note1...'])":"e-tags must contain valid hex event IDs (64 characters, 0-9a-f)",!1)}})}function checkManualReplyMarkers(e,t,n){if(1!==e.kind)return;if(n.has(e))return;const r=e.tags.filter(e=>"e"===e[0]&&("reply"===e[3]||"root"===e[3]));if(r.length>0){const e=r.map((e,t)=>` ${t+1}. ${JSON.stringify(e)}`).join("\n");t("event-manual-reply-markers",`Event has ${r.length} e-tag(s) with manual reply/root markers.\n\n📦 Your tags with markers:\n${e}\n\n⚠️ Manual reply markers detected! This will cause incorrect threading.`,"Reply events MUST be created using .reply():\n\n ✅ CORRECT:\n const replyEvent = originalEvent.reply();\n replyEvent.content = 'good point!';\n await replyEvent.publish();\n\n ❌ WRONG:\n event.tags.push(['e', eventId, '', 'reply']);\n\nNDK handles all reply threading automatically - never add reply/root markers manually.")}}function checkHashtagsWithPrefix(e,t){e.getMatchingTags("t").forEach((e,n)=>{if(e[1]&&e[1].startsWith("#")){const r=JSON.stringify(e);t("tag-hashtag-with-prefix",`t-tag[${n}] contains hashtag with # prefix.\n\n📦 Your tag:\n ${r}\n\n❌ Invalid value: "${e[1]}"\n\nHashtag tags should NOT include the # symbol.`,"Remove the # prefix from hashtag tags:\n ✅ event.tags.push(['t', 'nostr'])\n ❌ event.tags.push(['t', '#nostr'])",!1)}})}function checkReplaceableWithOldTimestamp(e,t){if(void 0===e.kind||null===e.kind||!e.created_at)return;if(!e.isReplaceable())return;const n=Math.floor(Date.now()/1e3),r=n-e.created_at;if(r>10){const i=Math.floor(r/60),s=i>0?`${i} minute${1!==i?"s":""}`:`${r} seconds`;t("event-replaceable-old-timestamp",`Publishing a replaceable event with an old created_at timestamp.\n\n📦 Event details:\n • kind: ${e.kind} (replaceable)\n • created_at: ${e.created_at}\n • age: ${s} old\n • current time: ${n}\n\n⚠️ This is wrong and will be rejected by relays.`,"For replaceable events, use publishReplaceable():\n\n ✅ CORRECT:\n await event.publishReplaceable();\n // Automatically updates created_at to now\n\n ❌ WRONG:\n await event.publish();\n // Uses old created_at")}}function signing(e,t,n,r){checkMissingKind(e,t),checkContentIsObject(e,t),checkCreatedAtMilliseconds(e,t),checkInvalidPTags(e,t),checkInvalidETags(e,t),checkHashtagsWithPrefix(e,t),checkManualReplyMarkers(e,n,r)}function publishing(e,t){checkReplaceableWithOldTimestamp(e,t)}function isNip33Pattern(e){const t=Array.isArray(e)?e:[e];if(1!==t.length)return!1;const n=t[0];return n.kinds&&Array.isArray(n.kinds)&&1===n.kinds.length&&n.authors&&Array.isArray(n.authors)&&1===n.authors.length&&n["#d"]&&Array.isArray(n["#d"])&&1===n["#d"].length}function isReplaceableEventFilter(e){const t=Array.isArray(e)?e:[e];return 0!==t.length&&t.every(e=>{if(!e.kinds||!Array.isArray(e.kinds)||0===e.kinds.length)return!1;if(!e.authors||!Array.isArray(e.authors)||0===e.authors.length)return!1;return e.kinds.every(e=>0===e||3===e||e>=1e4&&e<=19999)})}function formatFilter(e){return JSON.stringify(e,null,2).split("\n").map((e,t)=>0===t?e:` ${e}`).join("\n")}function fetchingEvents(e,t,n,r,i){if(i(),"ONLY_CACHE"===t?.cacheUsage)return;const s=Array.isArray(e)?e:[e],o=s.map(formatFilter).join("\n\n ---\n\n ");if(isNip33Pattern(e))s[0],n("fetch-events-usage","For fetching a NIP-33 addressable event, use fetchEvent() with the naddr directly.\n\n📦 Your filter:\n "+o+"\n\n ❌ BAD: const decoded = nip19.decode(naddr);\n const events = await ndk.fetchEvents({\n kinds: [decoded.data.kind],\n authors: [decoded.data.pubkey],\n \"#d\": [decoded.data.identifier]\n });\n const event = Array.from(events)[0];\n\n ✅ GOOD: const event = await ndk.fetchEvent(naddr);\n ✅ GOOD: const event = await ndk.fetchEvent('naddr1...');\n\nfetchEvent() handles naddr decoding automatically and returns the event directly.");else{if(isReplaceableEventFilter(e))return;{if(!r())return;let e="";const t=s.some(e=>void 0!==e.limit),i=new Set(s.flatMap(e=>e.kinds||[])).size,a=new Set(s.flatMap(e=>e.authors||[])).size;if(t){const t=Math.max(...s.map(e=>e.limit||0));e+=`\n • Limit: ${t} event${1!==t?"s":""}`}i>0&&(e+=`\n • Kinds: ${i} type${1!==i?"s":""}`),a>0&&(e+=`\n • Authors: ${a} author${1!==a?"s":""}`),n("fetch-events-usage","fetchEvents() is a BLOCKING operation that waits for EOSE.\nIn most cases, you should use subscribe() instead.\n\n📦 Your filter"+(s.length>1?"s":"")+":\n "+o+(e?"\n\n📊 Filter analysis:"+e:"")+"\n\n ❌ BAD: const events = await ndk.fetchEvents(filter);\n ✅ GOOD: ndk.subscribe(filter, { onEvent: (e) => ... });\n\nOnly use fetchEvents() when you MUST block until data arrives.","For one-time queries, use fetchEvent() instead of fetchEvents() when expecting a single result.")}}}var GuardrailCheckId={NDK_NO_CACHE:"ndk-no-cache",FILTER_BECH32_IN_ARRAY:"filter-bech32-in-array",FILTER_INVALID_HEX:"filter-invalid-hex",FILTER_ONLY_LIMIT:"filter-only-limit",FILTER_EMPTY:"filter-empty",FILTER_SINCE_AFTER_UNTIL:"filter-since-after-until",FILTER_INVALID_A_TAG:"filter-invalid-a-tag",FILTER_HASHTAG_WITH_PREFIX:"filter-hashtag-with-prefix"};function checkCachePresence(e,t){t(GuardrailCheckId.NDK_NO_CACHE)&&setTimeout(()=>{if(!e.cacheAdapter){const e=`\n🤖 AI_GUARDRAILS WARNING: NDK initialized without a cache adapter. Apps perform significantly better with caching.\n\n💡 ${"undefined"!=typeof window?"Consider using @nostr-dev-kit/ndk-cache-dexie or @nostr-dev-kit/ndk-cache-sqlite-wasm":"Consider using @nostr-dev-kit/ndk-cache-redis or @nostr-dev-kit/ndk-cache-sqlite"}\n\n🔇 To disable this check:\n ndk.aiGuardrails.skip('${GuardrailCheckId.NDK_NO_CACHE}')\n or set: ndk.aiGuardrails = { skip: new Set(['${GuardrailCheckId.NDK_NO_CACHE}']) }`;console.warn(e)}},2500)}var AIGuardrails=class{enabled=!1;skipSet=new Set;extensions=new Map;_nextCallDisabled=null;_replyEvents=new WeakSet;_fetchEventsCount=0;_subscribeCount=0;constructor(e=!1){this.setMode(e)}register(e,t){this.extensions.has(e)&&console.warn(`AIGuardrails: Extension '${e}' already registered, overwriting`);const n={};for(const[e,r]of Object.entries(t))"function"==typeof r&&(n[e]=(...e)=>{this.enabled&&r(...e,this.shouldCheck.bind(this),this.error.bind(this),this.warn.bind(this))});this.extensions.set(e,n),this[e]=n}setMode(e){"boolean"==typeof e?(this.enabled=e,this.skipSet.clear()):e&&"object"==typeof e&&(this.enabled=!0,this.skipSet=e.skip||new Set)}isEnabled(){return this.enabled}shouldCheck(e){return!!this.enabled&&(!this.skipSet.has(e)&&("all"!==this._nextCallDisabled&&(!this._nextCallDisabled||!this._nextCallDisabled.has(e))))}skip(e){this.skipSet.add(e)}enable(e){this.skipSet.delete(e)}getSkipped(){return Array.from(this.skipSet)}captureAndClearNextCallDisabled(){const e=this._nextCallDisabled;return this._nextCallDisabled=null,e}incrementFetchEventsCount(){this._fetchEventsCount++}incrementSubscribeCount(){this._subscribeCount++}shouldWarnAboutFetchEventsRatio(){const e=this._fetchEventsCount+this._subscribeCount;if(e<=6)return!1;return this._fetchEventsCount/e>.5}error(e,t,n,r=!0){if(!this.shouldCheck(e))return;const i=this.formatMessage(e,"ERROR",t,n,r);throw console.error(i),new Error(i)}warn(e,t,n){if(!this.shouldCheck(e))return;const r=this.formatMessage(e,"WARNING",t,n,!0);throw console.error(r),new Error(r)}formatMessage(e,t,n,r,i=!0){let s=`\n🤖 AI_GUARDRAILS ${t}: ${n}`;return r&&(s+=`\n\n💡 ${r}`),i&&(s+=`\n\n🔇 To disable this check:\n ndk.guardrailOff('${e}').yourMethod() // For one call`,s+=`\n ndk.aiGuardrails.skip('${e}') // Permanently`,s+=`\n or set: ndk.aiGuardrails = { skip: new Set(['${e}']) }`),s}ndkInstantiated(e){this.enabled&&checkCachePresence(e,this.shouldCheck.bind(this))}ndk={fetchingEvents:(e,t)=>{this.enabled&&fetchingEvents(e,t,this.warn.bind(this),this.shouldWarnAboutFetchEventsRatio.bind(this),this.incrementFetchEventsCount.bind(this))}};event={signing:e=>{this.enabled&&signing(e,this.error.bind(this),this.warn.bind(this),this._replyEvents)},publishing:e=>{this.enabled&&publishing(e,this.warn.bind(this))},received:(e,t)=>{this.enabled},creatingReply:e=>{this.enabled&&this._replyEvents.add(e)}};subscription={created:(e,t)=>{this.enabled&&this.incrementSubscribeCount()}};relay={connected:e=>{this.enabled}}};function processFilters(e,t="validate",n,r){if("ignore"===t)return e;const i=[],s=e.map((e,s)=>{r?.aiGuardrails.isEnabled()&&runAIGuardrailsForFilter(e,s,r);return processFilter(e,t,s,i,n)});if("validate"===t&&i.length>0)throw new Error(`Invalid filter(s) detected:\n${i.join("\n")}`);return s}function processFilter(e,t,n,r,i){const s="validate"===t,o=s?e:{...e};if(e.ids){const t=[];e.ids.forEach((e,o)=>{void 0===e?s?r.push(`Filter[${n}].ids[${o}] is undefined`):i?.(`Fixed: Removed undefined value at ids[${o}]`):"string"!=typeof e?s?r.push(`Filter[${n}].ids[${o}] is not a string (got ${typeof e})`):i?.(`Fixed: Removed non-string value at ids[${o}] (was ${typeof e})`):isValidHex64(e)?t.push(e):s?r.push(`Filter[${n}].ids[${o}] is not a valid 64-char hex string: "${e}"`):i?.(`Fixed: Removed invalid hex string at ids[${o}]`)}),s||(o.ids=t.length>0?t:void 0)}if(e.authors){const t=[];e.authors.forEach((e,o)=>{void 0===e?s?r.push(`Filter[${n}].authors[${o}] is undefined`):i?.(`Fixed: Removed undefined value at authors[${o}]`):"string"!=typeof e?s?r.push(`Filter[${n}].authors[${o}] is not a string (got ${typeof e})`):i?.(`Fixed: Removed non-string value at authors[${o}] (was ${typeof e})`):isValidHex64(e)?t.push(e):s?r.push(`Filter[${n}].authors[${o}] is not a valid 64-char hex pubkey: "${e}"`):i?.(`Fixed: Removed invalid hex pubkey at authors[${o}]`)}),s||(o.authors=t.length>0?t:void 0)}if(e.kinds){const t=[];e.kinds.forEach((e,o)=>{void 0===e?s?r.push(`Filter[${n}].kinds[${o}] is undefined`):i?.(`Fixed: Removed undefined value at kinds[${o}]`):"number"!=typeof e?s?r.push(`Filter[${n}].kinds[${o}] is not a number (got ${typeof e})`):i?.(`Fixed: Removed non-number value at kinds[${o}] (was ${typeof e})`):Number.isInteger(e)?e<0||e>65535?s?r.push(`Filter[${n}].kinds[${o}] is out of valid range (0-65535): ${e}`):i?.(`Fixed: Removed out-of-range kind at kinds[${o}]: ${e}`):t.push(e):s?r.push(`Filter[${n}].kinds[${o}] is not an integer: ${e}`):i?.(`Fixed: Removed non-integer value at kinds[${o}]: ${e}`)}),s||(o.kinds=t.length>0?t:void 0)}for(const t in e)if(t.startsWith("#")&&2===t.length){const a=e[t];if(Array.isArray(a)){const e=[];a.forEach((o,a)=>{void 0===o?s?r.push(`Filter[${n}].${t}[${a}] is undefined`):i?.(`Fixed: Removed undefined value at ${t}[${a}]`):"string"!=typeof o?s?r.push(`Filter[${n}].${t}[${a}] is not a string (got ${typeof o})`):i?.(`Fixed: Removed non-string value at ${t}[${a}] (was ${typeof o})`):"#e"!==t&&"#p"!==t||isValidHex64(o)?e.push(o):s?r.push(`Filter[${n}].${t}[${a}] is not a valid 64-char hex string: "${o}"`):i?.(`Fixed: Removed invalid hex string at ${t}[${a}]`)}),s||(o[t]=e.length>0?e:void 0)}}return s||Object.keys(o).forEach(e=>{void 0===o[e]&&delete o[e]}),o}function runAIGuardrailsForFilter(e,t,n){const r=n.aiGuardrails,i=JSON.stringify(e,null,2);if(1===Object.keys(e).length&&void 0!==e.limit&&r.error(GuardrailCheckId.FILTER_ONLY_LIMIT,`Filter[${t}] contains only 'limit' without any filtering criteria.\n\n📦 Your filter:\n${i}\n\n⚠️ This will fetch random events from relays without any criteria.`,"Add filtering criteria:\n ✅ { kinds: [1], limit: 10 }\n ✅ { authors: [pubkey], limit: 10 }\n ❌ { limit: 10 }"),0===Object.keys(e).length&&r.error(GuardrailCheckId.FILTER_EMPTY,`Filter[${t}] is empty.\n\n📦 Your filter:\n${i}\n\n⚠️ This will request ALL events from relays, which is never what you want.`,"Add filtering criteria like 'kinds', 'authors', or tags.",!1),void 0!==e.since&&void 0!==e.until&&e.since>e.until){const n=new Date(1e3*e.since).toISOString(),s=new Date(1e3*e.until).toISOString();r.error(GuardrailCheckId.FILTER_SINCE_AFTER_UNTIL,`Filter[${t}] has 'since' AFTER 'until'.\n\n📦 Your filter:\n${i}\n\n❌ since: ${e.since} (${n})\n❌ until: ${e.until} (${s})\n\nNo events can match this time range!`,"'since' must be BEFORE 'until'. Both are Unix timestamps in seconds.",!1)}const s=/^n(addr|event|ote|pub|profile)1/;e.ids&&e.ids.forEach((e,n)=>{"string"==typeof e&&(s.test(e)?r.error(GuardrailCheckId.FILTER_BECH32_IN_ARRAY,`Filter[${t}].ids[${n}] contains bech32: "${e}". IDs must be hex, not bech32.`,'Use filterFromId() to decode bech32 first: import { filterFromId } from "@nostr-dev-kit/ndk"',!1):isValidHex64(e)||r.error(GuardrailCheckId.FILTER_INVALID_HEX,`Filter[${t}].ids[${n}] is not a valid 64-char hex string: "${e}"`,"Event IDs must be 64-character hexadecimal strings. Invalid IDs often come from corrupted data in user-generated lists. Always validate hex strings before using them in filters:\n\n const validIds = ids.filter(id => /^[0-9a-f]{64}$/i.test(id));",!1))}),e.authors&&e.authors.forEach((e,n)=>{"string"==typeof e&&(s.test(e)?r.error(GuardrailCheckId.FILTER_BECH32_IN_ARRAY,`Filter[${t}].authors[${n}] contains bech32: "${e}". Authors must be hex pubkeys, not npub.`,"Use ndkUser.pubkey instead. Example: { authors: [ndkUser.pubkey] }",!1):isValidHex64(e)||r.error(GuardrailCheckId.FILTER_INVALID_HEX,`Filter[${t}].authors[${n}] is not a valid 64-char hex pubkey: "${e}"`,'Kind:3 follow lists can contain invalid entries like labels ("Follow List"), partial strings ("highlig"), or other corrupted data. You MUST validate all pubkeys before using them in filters.\n\n Example:\n const validPubkeys = pubkeys.filter(p => /^[0-9a-f]{64}$/i.test(p));\n ndk.subscribe({ authors: validPubkeys, kinds: [1] });',!1))});for(const n in e)if(n.startsWith("#")&&2===n.length){const i=e[n];Array.isArray(i)&&i.forEach((e,i)=>{"string"==typeof e&&("#e"!==n&&"#p"!==n||(s.test(e)?r.error(GuardrailCheckId.FILTER_BECH32_IN_ARRAY,`Filter[${t}].${n}[${i}] contains bech32: "${e}". Tag values must be decoded.`,"Use filterFromId() or nip19.decode() to get the hex value first.",!1):isValidHex64(e)||r.error(GuardrailCheckId.FILTER_INVALID_HEX,`Filter[${t}].${n}[${i}] is not a valid 64-char hex string: "${e}"`,("#e"===n?"Event IDs":"Public keys")+" in tag filters must be 64-character hexadecimal strings. Kind:3 follow lists and other user-generated content can contain invalid data. Always filter before using:\n\n const validValues = values.filter(v => /^[0-9a-f]{64}$/i.test(v));",!1)))})}if(e["#a"]){const n=e["#a"];n?.forEach((e,n)=>{if("string"==typeof e)if(/^\d+:[0-9a-f]{64}:.*$/.test(e)){const i=Number.parseInt(e.split(":")[0],10);(i<3e4||i>39999)&&r.error(GuardrailCheckId.FILTER_INVALID_A_TAG,`Filter[${t}].#a[${n}] uses non-addressable kind ${i}: "${e}". #a filters are only for addressable events (kinds 30000-39999).`,`Addressable events include:\n • 30000-30039: Parameterized Replaceable Events (profiles, settings, etc.)\n • 30040-39999: Other addressable events\n\nFor regular events (kind ${i}), use:\n • #e filter for specific event IDs\n • kinds + authors filters for event queries`,!1)}else r.error(GuardrailCheckId.FILTER_INVALID_A_TAG,`Filter[${t}].#a[${n}] has invalid format: "${e}". Must be "kind:pubkey:d-tag".`,'Example: "30023:fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52:my-article"',!1)})}if(e["#t"]){const n=e["#t"];n?.forEach((e,n)=>{"string"==typeof e&&e.startsWith("#")&&r.error(GuardrailCheckId.FILTER_HASHTAG_WITH_PREFIX,`Filter[${t}].#t[${n}] contains hashtag with # prefix: "${e}". Hashtag values should NOT include the # symbol.`,'Remove the # prefix from hashtag filters:\n ✅ { "#t": ["nostr"] }\n ❌ { "#t": ["#nostr"] }',!1)})}}function queryFullyFilled(e){return!(!filterIncludesIds(e.filter)||!resultHasAllRequestedIds(e))}function filterIncludesIds(e){return!!e.ids}function resultHasAllRequestedIds(e){const t=e.filter.ids;return!!t&&t.length===e.eventFirstSeen.size}function filterFromId(e){let t;if(e.match(NIP33_A_REGEX)){const[t,n,r]=e.split(":"),i={authors:[n],kinds:[Number.parseInt(t)]};return r&&(i["#d"]=[r]),i}if(e.match(BECH32_REGEX$1))try{switch(t=nip19_exports$2.decode(e),t.type){case"nevent":{const e={ids:[t.data.id]};return t.data.author&&(e.authors=[t.data.author]),t.data.kind&&(e.kinds=[t.data.kind]),e}case"note":return{ids:[t.data]};case"naddr":{const e={authors:[t.data.pubkey],kinds:[t.data.kind]};return t.data.identifier&&(e["#d"]=[t.data.identifier]),e}}}catch(t){console.error("Error decoding",e,t)}return{ids:[e]}}function isNip33AValue(e){return null!==e.match(NIP33_A_REGEX)}var NIP33_A_REGEX=/^(\d+):([0-9A-Fa-f]+)(?::(.*))?$/,BECH32_REGEX$1=/^n(event|ote|profile|pub|addr)1[\d\w]+$/;function relaysFromBech32(e,t){try{const n=nip19_exports$2.decode(e);if(["naddr","nevent"].includes(n?.type)){const e=n.data;if(e?.relays)return e.relays.map(e=>new NDKRelay(e,t.relayAuthDefaultPolicy,t))}}catch(e){}return[]}var NDKSubscriptionCacheUsage=(e=>(e.ONLY_CACHE="ONLY_CACHE",e.CACHE_FIRST="CACHE_FIRST",e.PARALLEL="PARALLEL",e.ONLY_RELAY="ONLY_RELAY",e))(NDKSubscriptionCacheUsage||{}),defaultOpts={closeOnEose:!1,cacheUsage:"CACHE_FIRST",dontSaveToCache:!1,groupable:!0,groupableDelay:100,groupableDelayType:"at-most",cacheUnconstrainFilter:["limit","since","until"],includeMuted:!1},NDKSubscription=class extends lib$1.EventEmitter{subId;filters;opts;pool;skipVerification=!1;skipValidation=!1;exclusiveRelay=!1;relayFilters;relaySet;ndk;debug;eventFirstSeen=new Map;eosesSeen=new Set;lastEventReceivedAt;mostRecentCacheEventTimestamp;internalId;closeOnEose;poolMonitor;skipOptimisticPublishEvent=!1;cacheUnconstrainFilter;constructor(e,t,n,r){super(),this.ndk=e,this.opts={...defaultOpts,...n||{}},this.pool=this.opts.pool||e.pool;const i=Array.isArray(t)?t:[t],s="validate"===e.filterValidationMode?"validate":"fix"===e.filterValidationMode?"fix":"ignore";if(this.filters=processFilters(i,s,e.debug,e),0===this.filters.length)throw new Error("Subscription must have at least one filter");this.subId=r||this.opts.subId,this.internalId=Math.random().toString(36).substring(7),this.debug=e.debug.extend(`subscription[${this.opts.subId??this.internalId}]`),this.opts.relaySet?this.relaySet=this.opts.relaySet:this.opts.relayUrls&&(this.relaySet=NDKRelaySet.fromRelayUrls(this.opts.relayUrls,this.ndk)),this.skipVerification=this.opts.skipVerification||!1,this.skipValidation=this.opts.skipValidation||!1,this.closeOnEose=this.opts.closeOnEose||!1,this.skipOptimisticPublishEvent=this.opts.skipOptimisticPublishEvent||!1,this.cacheUnconstrainFilter=this.opts.cacheUnconstrainFilter,this.exclusiveRelay=this.opts.exclusiveRelay||!1,this.opts.onEvent&&this.on("event",this.opts.onEvent),this.opts.onEose&&this.on("eose",this.opts.onEose),this.opts.onClose&&this.on("close",this.opts.onClose)}relaysMissingEose(){if(!this.relayFilters)return[];return Array.from(this.relayFilters?.keys()).filter(e=>!this.eosesSeen.has(this.pool.getRelay(e,!1,!1)))}get filter(){return this.filters[0]}get groupableDelay(){if(this.isGroupable())return this.opts?.groupableDelay}get groupableDelayType(){return this.opts?.groupableDelayType||"at-most"}isGroupable(){return this.opts?.groupable||!1}shouldQueryCache(){if(this.opts.addSinceFromCache)return!0;if("ONLY_RELAY"===this.opts?.cacheUsage)return!1;this.filters.some(e=>e.kinds?.some(e=>kindIsEphemeral(e)));return!0}shouldQueryRelays(){return"ONLY_CACHE"!==this.opts?.cacheUsage}shouldWaitForCache(){return!!this.opts.addSinceFromCache||!!this.opts.closeOnEose&&!!this.ndk.cacheAdapter?.locking&&"PARALLEL"!==this.opts.cacheUsage}start(e=!0){let t;const n=n=>{for(const e of n)e.created_at&&(!this.mostRecentCacheEventTimestamp||e.created_at>this.mostRecentCacheEventTimestamp)&&(this.mostRecentCacheEventTimestamp=e.created_at),this.eventReceived(e,void 0,!0,!1);e||(t=n)},r=()=>{this.shouldQueryRelays()?(this.startWithRelays(),this.startPoolMonitor()):this.emit("eose",this)};return this.shouldQueryCache()?(t=this.startWithCache(),t instanceof Promise?this.shouldWaitForCache()?(t.then(e=>{n(e),queryFullyFilled(this)?this.emit("eose",this):r()}),null):(t.then(e=>{n(e),this.shouldQueryRelays()||this.emit("eose",this)}),this.shouldQueryRelays()&&r(),null):(n(t),queryFullyFilled(this)?this.emit("eose",this):r(),t)):(r(),null)}startPoolMonitor(){this.debug.extend("pool-monitor"),this.poolMonitor=e=>{if(this.relayFilters?.has(e.url))return;calculateRelaySetsFromFilters(this.ndk,this.filters,this.pool,this.opts.relayGoalPerAuthor).get(e.url)&&(this.relayFilters?.set(e.url,this.filters),e.subscribe(this,this.filters))},this.pool.on("relay:connect",this.poolMonitor)}onStopped;stop(){this.emit("close",this),this.poolMonitor&&this.pool.off("relay:connect",this.poolMonitor),this.onStopped?.()}hasAuthorsFilter(){return this.filters.some(e=>e.authors?.length)}startWithCache(){return this.ndk.cacheAdapter?.query?this.ndk.cacheAdapter.query(this):[]}startWithRelays(){let e=this.filters;if(this.opts.addSinceFromCache&&this.mostRecentCacheEventTimestamp){const t=this.mostRecentCacheEventTimestamp+1;e=e.map(e=>({...e,since:Math.max(e.since||0,t)}))}if(this.relaySet&&0!==this.relaySet.relays.size){this.relayFilters=new Map;for(const t of this.relaySet.relays)this.relayFilters.set(t.url,e)}else this.relayFilters=calculateRelaySetsFromFilters(this.ndk,e,this.pool,this.opts.relayGoalPerAuthor);for(const[e,t]of this.relayFilters){this.pool.getRelay(e,!0,!0,t).subscribe(this,t)}}refreshRelayConnections(){if(this.relaySet&&this.relaySet.relays.size>0)return;const e=calculateRelaySetsFromFilters(this.ndk,this.filters,this.pool,this.opts.relayGoalPerAuthor);for(const[t,n]of e)if(!this.relayFilters?.has(t)){this.relayFilters?.set(t,n);this.pool.getRelay(t,!0,!0,n).subscribe(this,n)}}eventReceived(e,t,n=!1,r=!1){const i=e.id,s=this.eventFirstSeen.has(i);let o;if(e instanceof NDKEvent&&(o=e),s){const s=Date.now()-(this.eventFirstSeen.get(i)||0);if(this.emit("event:dup",e,t,s,this,n,r),this.opts?.onEventDup&&this.opts.onEventDup(e,t,s,this,n,r),n||r||!t||!this.ndk.cacheAdapter?.setEventDup||this.opts.dontSaveToCache||(o??=e instanceof NDKEvent?e:new NDKEvent(this.ndk,e),this.ndk.cacheAdapter.setEventDup(o,t)),t){const n=verifiedSignatures.get(i);if(n&&"string"==typeof n)if(e.sig===n)t.addValidatedEvent();else{const n=e instanceof NDKEvent?e:new NDKEvent(this.ndk,e);this.ndk.reportInvalidSignature(n,t)}}}else{if(o??=new NDKEvent(this.ndk,e),o.ndk=this.ndk,o.relay=t,!n&&!r){if(!this.skipValidation&&!o.isValid)return void this.debug("Event failed validation %s from relay %s",i,t?.url);if(t){if(t.shouldValidateEvent()&&!this.skipVerification)if(o.relay=t,this.ndk.asyncSigVerification)o.verifySignature(!0);else{if(!o.verifySignature(!0))return this.debug("Event failed signature validation",e),void this.ndk.reportInvalidSignature(o,t);t.addValidatedEvent()}else t.addNonValidatedEvent()}this.ndk.cacheAdapter&&!this.opts.dontSaveToCache&&this.ndk.cacheAdapter.setEvent(o,this.filters,t)}if(!this.opts.includeMuted&&this.ndk.muteFilter&&this.ndk.muteFilter(o))return void this.debug("Event muted, skipping");r&&!0===this.skipOptimisticPublishEvent||(this.emitEvent(this.opts?.wrap??!1,o,t,n,r),this.eventFirstSeen.set(i,Date.now()))}this.lastEventReceivedAt=Date.now()}emitEvent(e,t,n,r,i){const s=e?wrapEvent(t):t;s instanceof Promise?s.then(e=>this.emitEvent(!1,e,n,r,i)):s&&this.emit("event",s,n,this,r,i)}closedReceived(e,t){this.emit("closed",e,t)}eoseTimeout;eosed=!1;eoseReceived(e){this.debug("EOSE received from %s",e.url),this.eosesSeen.add(e);let t=this.lastEventReceivedAt?Date.now()-this.lastEventReceivedAt:void 0;const n=this.eosesSeen.size===this.relayFilters?.size,r=queryFullyFilled(this),i=e=>{this.debug("Performing EOSE: %s %d",e,this.eosed),this.eosed||(this.eoseTimeout&&clearTimeout(this.eoseTimeout),this.emit("eose",this),this.eosed=!0,this.opts?.closeOnEose&&this.stop())};if(r||n)i("query filled or seen all");else if(this.relayFilters){let e=1e3;const n=new Set(this.pool.connectedRelays().map(e=>e.url)),r=Array.from(this.relayFilters.keys()).filter(e=>n.has(e));if(0===r.length)return void this.debug("No connected relays, waiting for all relays to connect",Array.from(this.relayFilters.keys()).join(", "));const s=this.eosesSeen.size/r.length;if(this.debug("Percentage of relays that have sent EOSE",{subId:this.subId,percentageOfRelaysThatHaveSentEose:s,seen:this.eosesSeen.size,total:r.length}),this.eosesSeen.size>=2&&s>=.5){if(e*=1-s,0===e)return void i("time to wait was 0");this.eoseTimeout&&clearTimeout(this.eoseTimeout);const n=()=>{t=this.lastEventReceivedAt?Date.now()-this.lastEventReceivedAt:void 0,void 0!==t&&t<20?this.eoseTimeout=setTimeout(n,e):i(`send eose timeout: ${e}`)};this.eoseTimeout=setTimeout(n,e)}}}},kindIsEphemeral=e=>e>=2e4&&e<3e4;async function follows(e,t,n=3){if(!this.ndk)throw new Error("NDK not set");const r=await this.ndk.fetchEvent({kinds:[n],authors:[this.pubkey]},e||{groupable:!1});if(r){const e=new Set;return r.tags.forEach(t=>{"p"===t[0]&&t[1]&&isValidPubkey(t[1])&&e.add(t[1])}),t&&this.ndk?.outboxTracker?.trackUsers(Array.from(e)),[...e].reduce((e,t)=>{const n=new NDKUser({pubkey:t});return n.ndk=this.ndk,e.add(n),e},new Set)}return new Set}var NIP05_REGEX$1=/^(?:([\w.+-]+)@)?([\w.-]+)$/;async function getNip05For(e,t,n=fetch,r={}){return await e.queuesNip05.add({id:t,func:async()=>{if(e.cacheAdapter?.loadNip05){const n=await e.cacheAdapter.loadNip05(t);if("missing"!==n){if(n){const t=new NDKUser({pubkey:n.pubkey,relayUrls:n.relays,nip46Urls:n.nip46});return t.ndk=e,t}if("no-cache"!==r.cache)return null}}const i=t.match(NIP05_REGEX$1);if(!i)return null;const[s,o="_",a]=i;try{const i=await n(`https://${a}/.well-known/nostr.json?name=${o}`,r),{names:s,relays:c,nip46:l}=parseNIP05Result$1(await i.json()),h=s[o.toLowerCase()];let d=null;return h&&(d={pubkey:h,relays:c?.[h],nip46:l?.[h]}),e?.cacheAdapter?.saveNip05&&e.cacheAdapter.saveNip05(t,d),d}catch(n){return e?.cacheAdapter?.saveNip05&&e?.cacheAdapter.saveNip05(t,null),console.error("Failed to fetch NIP05 for",t,n),null}}})}function parseNIP05Result$1(e){const t={names:{}};for(const[n,r]of Object.entries(e.names))"string"==typeof n&&"string"==typeof r&&(t.names[n.toLowerCase()]=r);if(e.relays){t.relays={};for(const[n,r]of Object.entries(e.relays))"string"==typeof n&&Array.isArray(r)&&(t.relays[n]=r.filter(e=>"string"==typeof e))}if(e.nip46){t.nip46={};for(const[n,r]of Object.entries(e.nip46))"string"==typeof n&&Array.isArray(r)&&(t.nip46[n]=r.filter(e=>"string"==typeof e))}return t}function profileFromEvent(e){const t={};let n;try{n=JSON.parse(e.content)}catch(e){throw new Error(`Failed to parse profile event: ${e}`)}t.profileEvent=JSON.stringify(e.rawEvent());for(const e of Object.keys(n))switch(e){case"name":t.name=n.name;break;case"display_name":t.displayName=n.display_name;break;case"image":case"picture":t.picture=n.picture||n.image,t.image=t.picture;break;case"banner":t.banner=n.banner;break;case"bio":t.bio=n.bio;break;case"nip05":t.nip05=n.nip05;break;case"lud06":t.lud06=n.lud06;break;case"lud16":t.lud16=n.lud16;break;case"about":t.about=n.about;break;case"website":t.website=n.website;break;default:t[e]=n[e]}return t.created_at=e.created_at,t}function serializeProfile(e){const t={};for(const[n,r]of Object.entries(e))switch(n){case"username":case"name":t.name=r;break;case"displayName":t.display_name=r;break;case"image":case"picture":t.picture=r;break;case"bio":case"about":t.about=r;break;default:t[n]=r}return JSON.stringify(t)}var NDKUser=class e{ndk;profile;profileEvent;_npub;_pubkey;relayUrls=[];nip46Urls=[];constructor(e){if(e.npub&&(this._npub=e.npub),e.hexpubkey&&(this._pubkey=e.hexpubkey),e.pubkey&&(this._pubkey=e.pubkey),e.relayUrls&&(this.relayUrls=e.relayUrls),e.nip46Urls&&(this.nip46Urls=e.nip46Urls),e.nprofile)try{const t=nip19_exports$2.decode(e.nprofile);"nprofile"===t.type&&(this._pubkey=t.data.pubkey,t.data.relays&&t.data.relays.length>0&&this.relayUrls.push(...t.data.relays))}catch(e){console.error("Failed to decode nprofile",e)}}get npub(){if(!this._npub){if(!this._pubkey)throw new Error("pubkey not set");this._npub=nip19_exports$2.npubEncode(this.pubkey)}return this._npub}get nprofile(){const e=this.profileEvent?.onRelays?.map(e=>e.url);return nip19_exports$2.nprofileEncode({pubkey:this.pubkey,relays:e})}set npub(e){this._npub=e}get pubkey(){if(!this._pubkey){if(!this._npub)throw new Error("npub not set");this._pubkey=nip19_exports$2.decode(this.npub).data}return this._pubkey}set pubkey(e){this._pubkey=e}filter(){return{"#p":[this.pubkey]}}async getZapInfo(e){if(!this.ndk)throw new Error("No NDK instance found");const t=async t=>{if(!e)return t;let n;const r=new Promise((t,r)=>{n=setTimeout(()=>r(new Error("Timeout")),e)});try{const e=await Promise.race([t,r]);return n&&clearTimeout(n),e}catch(e){if(e instanceof Error&&"Timeout"===e.message)try{return await t}catch(e){return}return}},[n,r]=await Promise.all([t(this.fetchProfile()),t(this.ndk.fetchEvent({kinds:[10019],authors:[this.pubkey]}))]),i=new Map;if(r){const e=NDKCashuMintList.from(r);e.mints.length>0&&i.set("nip61",{mints:e.mints,relays:e.relays,p2pk:e.p2pk})}if(n){const{lud06:e,lud16:t}=n;i.set("nip57",{lud06:e,lud16:t})}return i}static async fromNip05(t,n,r=!1){if(!n)throw new Error("No NDK instance found");const i={};r&&(i.cache="no-cache");const s=await getNip05For(n,t,n?.httpFetch,i);if(s){const t=new e({pubkey:s.pubkey,relayUrls:s.relays,nip46Urls:s.nip46});return t.ndk=n,t}}async fetchProfile(e,t=!1){if(!this.ndk)throw new Error("NDK not set");let n=null;if(this.ndk.cacheAdapter&&(this.ndk.cacheAdapter.fetchProfile||this.ndk.cacheAdapter.fetchProfileSync)&&"ONLY_RELAY"!==e?.cacheUsage){let e=null;if(this.ndk.cacheAdapter.fetchProfileSync?e=this.ndk.cacheAdapter.fetchProfileSync(this.pubkey):this.ndk.cacheAdapter.fetchProfile&&(e=await this.ndk.cacheAdapter.fetchProfile(this.pubkey)),e)return this.profile=e,e}return e??={},e.cacheUsage??="ONLY_RELAY",e.closeOnEose??=!0,e.groupable??=!0,e.groupableDelay??=250,n||(n=await this.ndk.fetchEvent({kinds:[0],authors:[this.pubkey]},e)),n?(this.profile=profileFromEvent(n),t&&this.profile&&this.ndk.cacheAdapter&&this.ndk.cacheAdapter.saveProfile&&this.ndk.cacheAdapter.saveProfile(this.pubkey,this.profile),this.profile):null}follows=follows.bind(this);async followSet(e,t,n=3){const r=await this.follows(e,t,n);return new Set(Array.from(r).map(e=>e.pubkey))}tagReference(){return["p",this.pubkey]}referenceTags(e){const t=[["p",this.pubkey]];return e?(t[0].push("",e),t):t}async publish(){if(!this.ndk)throw new Error("No NDK instance found");if(!this.profile)throw new Error("No profile available");this.ndk.assertSigner();const e=new NDKEvent(this.ndk,{kind:0,content:serializeProfile(this.profile)});await e.publish()}async follow(e,t,n=3){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner(),t||(t=await this.follows(void 0,void 0,n));const r="string"==typeof e?e:e.pubkey;if(Array.from(t).some(e=>"string"==typeof e?e===r:e.pubkey===r))return!1;t.add(e);const i=new NDKEvent(this.ndk,{kind:n});for(const e of t)"string"==typeof e?i.tags.push(["p",e]):i.tag(e);return await i.publish(),!0}async unfollow(e,t,n=3){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner(),t||(t=await this.follows(void 0,void 0,n));const r="string"==typeof e?e:e.pubkey,i=new Set;let s=!1;for(const e of t){("string"==typeof e?e:e.pubkey)!==r?i.add(e):s=!0}if(!s)return!1;const o=new NDKEvent(this.ndk,{kind:n});for(const e of i)"string"==typeof e?o.tags.push(["p",e]):o.tag(e);return await o.publish()}async validateNip05(e){if(!this.ndk)throw new Error("No NDK instance found");const t=await getNip05For(this.ndk,e);return null===t?null:t.pubkey===this.pubkey}},signerRegistry=new Map;function registerSigner(e,t){signerRegistry.set(e,t)}var NDKPrivateKeySigner=class e{_user;_privateKey;_pubkey;constructor(e,t){if("string"==typeof e)if(e.startsWith("nsec1")){const{type:t,data:n}=nip19_exports$2.decode(e);if("nsec"!==t)throw new Error("Invalid private key provided.");this._privateKey=n}else{if(64!==e.length)throw new Error("Invalid private key provided.");this._privateKey=hexToBytes$4(e)}else this._privateKey=e;this._pubkey=getPublicKey$1(this._privateKey),t&&(this._user=t.getUser({pubkey:this._pubkey})),this._user??=new NDKUser({pubkey:this._pubkey})}get privateKey(){if(!this._privateKey)throw new Error("Not ready");return bytesToHex$4(this._privateKey)}get pubkey(){if(!this._pubkey)throw new Error("Not ready");return this._pubkey}get nsec(){if(!this._privateKey)throw new Error("Not ready");return nip19_exports$2.nsecEncode(this._privateKey)}get npub(){if(!this._pubkey)throw new Error("Not ready");return nip19_exports$2.npubEncode(this._pubkey)}encryptToNcryptsec(e,t=16,n=2){if(!this._privateKey)throw new Error("Private key not available");return encrypt$2(this._privateKey,e,t,n)}static generate(){const t=generateSecretKey();return new e(t)}static fromNcryptsec(t,n,r){const i=decrypt$2(t,n);return new e(i,r)}async blockUntilReady(){return this._user}async user(){return this._user}get userSync(){return this._user}async sign(e){if(!this._privateKey)throw Error("Attempted to sign without a private key");return finalizeEvent(e,this._privateKey).sig}async encryptionEnabled(e){const t=[];return e&&"nip04"!==e||t.push("nip04"),e&&"nip44"!==e||t.push("nip44"),t}async encrypt(e,t,n){if(!this._privateKey||!this.privateKey)throw Error("Attempted to encrypt without a private key");const r=e.pubkey;if("nip44"===n){const e=nip44_exports$1.v2.utils.getConversationKey(this._privateKey,r);return await nip44_exports$1.v2.encrypt(t,e)}return await nip04_exports$1.encrypt(this._privateKey,r,t)}async decrypt(e,t,n){if(!this._privateKey||!this.privateKey)throw Error("Attempted to decrypt without a private key");const r=e.pubkey;if("nip44"===n){const e=nip44_exports$1.v2.utils.getConversationKey(this._privateKey,r);return await nip44_exports$1.v2.decrypt(t,e)}return await nip04_exports$1.decrypt(this._privateKey,r,t)}toPayload(){if(!this._privateKey)throw new Error("Private key not available");const e={type:"private-key",payload:this.privateKey};return JSON.stringify(e)}static async fromPayload(t,n){const r=JSON.parse(t);if("private-key"!==r.type)throw new Error(`Invalid payload type: expected 'private-key', got ${r.type}`);if(!r.payload||"string"!=typeof r.payload)throw new Error("Invalid payload content for private-key signer");return new e(r.payload,n)}};function dedup(e,t){return e.created_at>t.created_at?e:t}async function getRelayListForUser(e,t){return(await getRelayListForUsers([e],t)).get(e)}async function getRelayListForUsers(e,t,n=!1,r=1e3,i){const s=t.outboxPool||t.pool,o=new Set;for(const e of s.relays.values())o.add(e);if(i)for(const e of i.values())for(const t of e){const e=s.getRelay(t,!0,!0);e&&o.add(e)}const a=new Map,c=new Map,l=new NDKRelaySet(o,t);if(t.cacheAdapter?.locking&&!n){const n=await t.fetchEvents({kinds:[3,10002],authors:Array.from(new Set(e))},{cacheUsage:"ONLY_CACHE",subId:"ndk-relay-list-fetch"});for(const e of n)10002===e.kind&&a.set(e.pubkey,NDKRelayList.from(e));for(const e of n)if(3===e.kind){if(a.has(e.pubkey))continue;const n=relayListFromKind3(t,e);n&&c.set(e.pubkey,n)}e=e.filter(e=>!a.has(e)&&!c.has(e))}if(0===e.length)return a;const h=new Map,d=new Map;return new Promise(n=>{let i=!1;(async()=>{const c={closeOnEose:!0,pool:s,groupable:!0,subId:"ndk-relay-list-fetch",addSinceFromCache:!0,relaySet:l};l&&(c.relaySet=l),t.subscribe({kinds:[3,10002],authors:e},c,{onEvent:e=>{if(10002===e.kind){const t=h.get(e.pubkey);if(t&&t.created_at>e.created_at)return;h.set(e.pubkey,e)}else if(3===e.kind){const t=d.get(e.pubkey);if(t&&t.created_at>e.created_at)return;d.set(e.pubkey,e)}},onEose:()=>{if(!i){i=!0,t.debug(`[getRelayListForUsers] EOSE - relayListEvents: ${h.size}, contactListEvents: ${d.size}`);for(const e of h.values())a.set(e.pubkey,NDKRelayList.from(e));for(const n of e){if(a.has(n))continue;const e=d.get(n);if(!e)continue;const r=relayListFromKind3(t,e);r&&a.set(n,r)}t.debug(`[getRelayListForUsers] Returning ${a.size} relay lists for ${e.length} pubkeys`),n(a)}}});const u=Array.from(o).some(e=>e.status<=2),f=Array.from(o).some(e=>4===e.status);let p=r;(u||f)&&(p=r+3e3),t.debug(`[getRelayListForUsers] Setting fallback timeout to ${p}ms (disconnected: ${u}, connecting: ${f})`,{pubkeys:e}),setTimeout(()=>{i||(i=!0,t.debug(`[getRelayListForUsers] Timeout reached, returning ${a.size} relay lists`),n(a))},p)})()})}registerSigner("private-key",NDKPrivateKeySigner);var OutboxItem=class{type;relayUrlScores;readRelays;writeRelays;constructor(e){this.type=e,this.relayUrlScores=new Map,this.readRelays=new Set,this.writeRelays=new Set}},OutboxTracker=class extends lib$1.EventEmitter{data;ndk;debug;constructor(e){super(),this.ndk=e,this.debug=e.debug.extend("outbox-tracker"),this.data=new dist.LRUCache({maxSize:1e5,entryExpirationTimeInMS:12e4})}async trackUsers(e,t=!1){const n=[];for(let r=0;r<e.length;r+=400){const i=e.slice(r,r+400),s=i.map(e=>getKeyFromItem(e)).filter(e=>!this.data.has(e));if(0===s.length)continue;for(const e of s)this.data.set(e,new OutboxItem("user"));const o=new Map;for(const e of i)e instanceof NDKUser&&e.relayUrls.length>0&&o.set(e.pubkey,e.relayUrls);n.push(new Promise(e=>{getRelayListForUsers(s,this.ndk,t,1e3,o).then(e=>{this.debug(`Received relay lists for ${e.size} pubkeys out of ${s.length} requested`);for(const[t,n]of e){let e=this.data.get(t);if(e??=new OutboxItem("user"),n){if(e.readRelays=new Set(normalize$2(n.readRelayUrls)),e.writeRelays=new Set(normalize$2(n.writeRelayUrls)),this.ndk.relayConnectionFilter){for(const t of e.readRelays)this.ndk.relayConnectionFilter(t)||e.readRelays.delete(t);for(const t of e.writeRelays)this.ndk.relayConnectionFilter(t)||e.writeRelays.delete(t)}this.data.set(t,e),this.emit("user:relay-list-updated",t,e),this.debug(`Adding ${e.readRelays.size} read relays and ${e.writeRelays.size} write relays for ${t}`,n?.rawEvent())}}}).finally(e)}))}return Promise.all(n)}track(e,t,n=!0){const r=getKeyFromItem(e);t??=getTypeFromItem(e);let i=this.data.get(r);return i||(i=new OutboxItem(t),e instanceof NDKUser&&this.trackUsers([e])),i}};function getKeyFromItem(e){return e instanceof NDKUser?e.pubkey:e}function getTypeFromItem(e){return e instanceof NDKUser?"user":"kind"}function correctRelaySet(e,t){const n=t.connectedRelays();if(!Array.from(e.relays).some(e=>n.map(e=>e.url).includes(e.url)))for(const t of n)e.addRelay(t);if(0===n.length)for(const n of t.relays.values())e.addRelay(n);return e}var NDKSubscriptionManager=class{subscriptions;seenEvents=new dist.LRUCache({maxSize:1e4,entryExpirationTimeInMS:3e5});constructor(){this.subscriptions=new Map}add(e){this.subscriptions.set(e.internalId,e),e.onStopped,e.onStopped=()=>{this.subscriptions.delete(e.internalId)},e.on("close",()=>{this.subscriptions.delete(e.internalId)})}seenEvent(e,t){const n=this.seenEvents.get(e)||[];n.some(e=>e.url===t.url)||n.push(t),this.seenEvents.set(e,n)}dispatchEvent(e,t,n=!1){t&&this.seenEvent(e.id,t);const r=this.subscriptions.values(),i=[];for(const t of r)matchFilters(t.filters,e)&&i.push(t);for(const r of i){if(r.exclusiveRelay&&r.relaySet){let i=!1;if(n)i=!r.skipOptimisticPublishEvent;else if(t)i=r.relaySet.relays.has(t);else{i=(this.seenEvents.get(e.id)||[]).some(e=>r.relaySet.relays.has(e))}if(!i){r.debug.extend("exclusive-relay")("Rejected event %s from %s (relay not in exclusive set)",e.id,t?.url||(n?"optimistic":"cache"));continue}}r.eventReceived(e,t,!1,n)}}},debug6=createDebug5("ndk:active-user");async function getUserRelayList(e){if(!this.autoConnectUserRelays)return;const t=await getRelayListForUser(e.pubkey,this);if(t){for(const e of t.relays){let t=this.pool.relays.get(e);t||(t=new NDKRelay(e,this.relayAuthDefaultPolicy,this),this.pool.addRelay(t))}return debug6("Connected to %d user relays",t.relays.length),t}}async function setActiveUser(e){if(!this.autoConnectUserRelays)return;const t=this.outboxPool||this.pool;t.connectedRelays.length>0?await getUserRelayList.call(this,e):t.once("connect",async()=>{await getUserRelayList.call(this,e)})}function getEntity(e){try{const t=nip19_exports$2.decode(e);return"npub"===t.type?npub(this,t.data):"nprofile"===t.type?nprofile(this,t.data):t}catch(e){return null}}function npub(e,t){return e.getUser({pubkey:t})}function nprofile(e,t){const n=e.getUser({pubkey:t.pubkey});return t.relays&&(n.relayUrls=t.relays),n}function isValidHint(e){if(!e||""===e)return!1;try{return new URL(e),!0}catch(e){return!1}}async function fetchEventFromTag(e,t,n,r={type:"timeout"}){const i=this.debug.extend("fetch-event-from-tag"),[s,o,a]=e;i("fetching event from tag",e,n={},r);const c=getRelaysForSync(this,t.pubkey);if(c&&c.size>0){i("fetching event from author relays %o",Array.from(c));const e=NDKRelaySet.fromRelayUrls(Array.from(c),this),t=await this.fetchEvent(o,n,e);if(t)return t}else i("no author relays found for %s",t.pubkey,t);const l=calculateRelaySetsFromFilters(this,[{ids:[o]}],this.pool);i("fetching event without relay hint",l);const h=await this.fetchEvent(o,n);if(h)return h;if(a&&""!==a){const e=await this.fetchEvent(o,n,this.pool.getRelay(a,!0,!0,[{ids:[o]}]));if(e)return e}let d;const u=isValidHint(a)?this.pool.getRelay(a,!1,!0,[{ids:[o]}]):void 0,f=new Promise(e=>{this.fetchEvent(o,n,u).then(e)});if(!isValidHint(a)||"none"===r.type)return f;const p=new Promise(async e=>{const t=r.relaySet,s=r.timeout??1500,a=new Promise(e=>setTimeout(e,s));if("timeout"===r.type&&await a,d)e(d);else{i("fallback fetch triggered");e(await this.fetchEvent(o,n,t))}});switch(r.type){case"timeout":return Promise.race([f,p]);case"eose":return d=await f,d||p}}var Queue=class{queue=[];maxConcurrency;processing=new Set;promises=new Map;constructor(e,t){this.maxConcurrency=t}add(e){if(this.promises.has(e.id))return this.promises.get(e.id);const t=new Promise((t,n)=>{this.queue.push({...e,func:()=>e.func().then(e=>(t(e),e),e=>{throw n(e),e})}),this.process()});return this.promises.set(e.id,t),t.finally(()=>{this.promises.delete(e.id),this.processing.delete(e.id),this.process()}),t}process(){if(this.processing.size>=this.maxConcurrency||0===this.queue.length)return;const e=this.queue.shift();e&&!this.processing.has(e.id)&&(this.processing.add(e.id),e.func())}clear(){this.queue=[]}clearProcessing(){this.processing.clear()}clearAll(){this.clear(),this.clearProcessing()}length(){return this.queue.length}},DEFAULT_OUTBOX_RELAYS=["wss://purplepag.es/","wss://nos.lol/"],NDK=class extends lib$1.EventEmitter{_explicitRelayUrls;pool;outboxPool;_signer;_activeUser;cacheAdapter;debug;devWriteRelaySet;outboxTracker;muteFilter;relayConnectionFilter;clientName;clientNip89;queuesZapConfig;queuesNip05;asyncSigVerification=!1;initialValidationRatio=1;lowestValidationRatio=.1;validationRatioFn;filterValidationMode="validate";subManager;aiGuardrails;_signatureVerificationFunction;_signatureVerificationWorker;signatureVerificationTimeMs=0;publishingFailureHandled=!1;pools=[];relayAuthDefaultPolicy;httpFetch;netDebug;autoConnectUserRelays=!0;_wallet;walletConfig;constructor(e={}){super(),this.debug=e.debug||createDebug5("ndk"),this.netDebug=e.netDebug,this._explicitRelayUrls=e.explicitRelayUrls||[],this.subManager=new NDKSubscriptionManager,this.pool=new NDKPool(e.explicitRelayUrls||[],this),this.pool.name="Main",this.pool.on("relay:auth",async(e,t)=>{this.relayAuthDefaultPolicy&&await this.relayAuthDefaultPolicy(e,t)}),this.autoConnectUserRelays=e.autoConnectUserRelays??!0,this.clientName=e.clientName,this.clientNip89=e.clientNip89,this.relayAuthDefaultPolicy=e.relayAuthDefaultPolicy,!1!==e.enableOutboxModel&&(this.outboxPool=new NDKPool(e.outboxRelayUrls||DEFAULT_OUTBOX_RELAYS,this,{debug:this.debug.extend("outbox-pool"),name:"Outbox Pool"}),this.outboxTracker=new OutboxTracker(this),this.outboxTracker.on("user:relay-list-updated",(e,t)=>{this.debug(`Outbox relay list updated for ${e}`);for(const t of this.subManager.subscriptions.values()){t.filters.some(t=>t.authors?.includes(e))&&"function"==typeof t.refreshRelayConnections&&(this.debug(`Refreshing relay connections for subscription ${t.internalId}`),t.refreshRelayConnections())}})),this.signer=e.signer,this.cacheAdapter=e.cacheAdapter,this.muteFilter=e.muteFilter,this.relayConnectionFilter=e.relayConnectionFilter,e.devWriteRelayUrls&&(this.devWriteRelaySet=NDKRelaySet.fromRelayUrls(e.devWriteRelayUrls,this)),this.queuesZapConfig=new Queue("zaps",3),this.queuesNip05=new Queue("nip05",10),e.signatureVerificationWorker&&(this.signatureVerificationWorker=e.signatureVerificationWorker),e.signatureVerificationFunction&&(this.signatureVerificationFunction=e.signatureVerificationFunction),this.initialValidationRatio=e.initialValidationRatio||1,this.lowestValidationRatio=e.lowestValidationRatio||.1,this.validationRatioFn=e.validationRatioFn||this.defaultValidationRatioFn,this.filterValidationMode=e.filterValidationMode||"validate",this.aiGuardrails=new AIGuardrails(e.aiGuardrails||!1),this.aiGuardrails.ndkInstantiated(this);try{this.httpFetch=fetch}catch{}}set explicitRelayUrls(e){this._explicitRelayUrls=e.map(normalizeRelayUrl),this.pool.relayUrls=e}get explicitRelayUrls(){return this._explicitRelayUrls||[]}set signatureVerificationWorker(e){this._signatureVerificationWorker=e,e?(signatureVerificationInit(e),this.asyncSigVerification=!0):this.asyncSigVerification=!1}set signatureVerificationFunction(e){this._signatureVerificationFunction=e,this.asyncSigVerification=!!e}get signatureVerificationFunction(){return this._signatureVerificationFunction}addExplicitRelay(e,t,n=!0){let r;return r="string"==typeof e?new NDKRelay(e,t,this):e,this.pool.addRelay(r,n),this.explicitRelayUrls?.push(r.url),r}toJSON(){return{relayCount:this.pool.relays.size}.toString()}get activeUser(){return this._activeUser}set activeUser(e){const t=this._activeUser?.pubkey!==e?.pubkey;this._activeUser=e,t&&this.emit("activeUser:change",e),e&&t&&setActiveUser.call(this,e)}get signer(){return this._signer}set signer(e){this._signer=e,e&&this.emit("signer:ready",e),e?.user().then(e=>{e.ndk=this,this.activeUser=e})}async connect(e){if(this._signer&&this.autoConnectUserRelays&&(this.debug("Attempting to connect to user relays specified by signer %o",await(this._signer.relays?.(this))),this._signer.relays)){(await this._signer.relays(this)).forEach(e=>this.pool.addRelay(e))}const t=[this.pool.connect(e)];return this.outboxPool&&t.push(this.outboxPool.connect(e)),this.cacheAdapter?.initializeAsync&&t.push(this.cacheAdapter.initializeAsync(this)),Promise.allSettled(t).then(()=>{})}reportInvalidSignature(e,t){this.debug(`Invalid signature detected for event ${e.id}${t?` from relay ${t.url}`:""}`),this.emit("event:invalid-sig",e,t)}defaultValidationRatioFn(e,t,n){if(t<10)return this.initialValidationRatio;const r=Math.min(t/100,1),i=this.initialValidationRatio*(1-r)+this.lowestValidationRatio*r;return Math.max(i,this.lowestValidationRatio)}getUser(e){if("string"==typeof e){if(e.startsWith("npub1")){const{type:t,data:n}=nip19_exports$2.decode(e);if("npub"!==t)throw new Error(`Invalid npub: ${e}`);return this.getUser({pubkey:n})}if(e.startsWith("nprofile1")){const{type:t,data:n}=nip19_exports$2.decode(e);if("nprofile"!==t)throw new Error(`Invalid nprofile: ${e}`);return this.getUser({pubkey:n.pubkey,relayUrls:n.relays})}return this.getUser({pubkey:e})}const t=new NDKUser(e);return t.ndk=this,t}async getUserFromNip05(e,t=!1){return NDKUser.fromNip05(e,this,t)}async fetchUser(e,t=!1){if(isValidNip05(e))return NDKUser.fromNip05(e,this,t);if(e.startsWith("npub1")){const{type:t,data:n}=nip19_exports$2.decode(e);if("npub"!==t)throw new Error(`Invalid npub: ${e}`);const r=new NDKUser({pubkey:n});return r.ndk=this,r}if(e.startsWith("nprofile1")){const{type:t,data:n}=nip19_exports$2.decode(e);if("nprofile"!==t)throw new Error(`Invalid nprofile: ${e}`);const r=new NDKUser({pubkey:n.pubkey,relayUrls:n.relays});return r.ndk=this,r}{const t=new NDKUser({pubkey:e});return t.ndk=this,t}}subscribe(e,t,n=!0,r=!0){let i,s=t?.relaySet,o=r;n instanceof NDKRelaySet?(console.warn("relaySet is deprecated, use opts.relaySet instead. This will be removed in version v2.14.0"),s=n,o=r):"boolean"!=typeof n&&"object"!=typeof n||(o=n);const a={relaySet:s,...t};o&&"object"==typeof o&&(o.onEvent&&(a.onEvent=o.onEvent),o.onEose&&(a.onEose=o.onEose),o.onClose&&(a.onClose=o.onClose),o.onEvents&&(i=o.onEvents));const c=new NDKSubscription(this,e,a);this.subManager.add(c),this.aiGuardrails?.subscription?.created(Array.isArray(e)?e:[e],a);const l=c.pool;if(c.relaySet)for(const e of c.relaySet.relays)l.useTemporaryRelay(e,void 0,c.filters);if(this.outboxPool&&c.hasAuthorsFilter()){const e=c.filters.filter(e=>e.authors&&e.authors?.length>0).flatMap(e=>e.authors);this.outboxTracker?.trackUsers(e)}return o&&setTimeout(async()=>{this.cacheAdapter?.initializeAsync&&!this.cacheAdapter.ready&&await this.cacheAdapter.initializeAsync(this);const e=c.start(!i);e&&e.length>0&&i&&i(e)},0),c}fetchEventFromTag=fetchEventFromTag.bind(this);fetchEventSync(e){if(!this.cacheAdapter)throw new Error("Cache adapter not set");let t;t="string"==typeof e?[filterFromId(e)]:e;const n=new NDKSubscription(this,t),r=this.cacheAdapter.query(n);if(r instanceof Promise)throw new Error("Cache adapter is async");return r.map(e=>(e.ndk=this,e))}async fetchEvent(e,t,n){let r,i;if(n instanceof NDKRelay?i=new NDKRelaySet(new Set([n]),this):n instanceof NDKRelaySet&&(i=n),!n&&"string"==typeof e&&!isNip33AValue(e)){const t=relaysFromBech32(e,this);t.length>0&&(i=new NDKRelaySet(new Set(t),this),i=correctRelaySet(i,this.pool))}if(r="string"==typeof e?[filterFromId(e)]:Array.isArray(e)?e:[e],"string"!=typeof e&&this.aiGuardrails?.ndk?.fetchingEvents(r),0===r.length)throw new Error(`Invalid filter: ${JSON.stringify(e)}`);return new Promise((e,n)=>{let s=null;const o={...t||{},closeOnEose:!0};i&&(o.relaySet=i);const a=setTimeout(()=>{c.stop(),this.aiGuardrails._nextCallDisabled=null,e(s)},1e4),c=this.subscribe(r,o,{onEvent:t=>{t.ndk=this,t.isReplaceable()?(!s||s.created_at<t.created_at)&&(s=t):(clearTimeout(a),this.aiGuardrails._nextCallDisabled=null,e(t))},onEose:()=>{clearTimeout(a),this.aiGuardrails._nextCallDisabled=null,e(s)}})})}async fetchEvents(e,t,n){return this.aiGuardrails?.ndk?.fetchingEvents(e,t),new Promise(r=>{const i=new Map,s={...t||{},closeOnEose:!0};n&&(s.relaySet=n);this.subscribe(e,{...s,onEvent:e=>{let t;t=e instanceof NDKEvent?e:new NDKEvent(void 0,e);const n=t.deduplicationKey(),r=i.get(n);r&&(t=dedup(r,t)),t.ndk=this,i.set(n,t)},onEose:()=>{this.aiGuardrails._nextCallDisabled=null,r(new Set(i.values()))}})})}assertSigner(){if(!this.signer)throw this.emit("signer:required"),new Error("Signer required")}getEntity=getEntity.bind(this);guardrailOff(e){return this.aiGuardrails._nextCallDisabled=e?"string"==typeof e?new Set([e]):new Set(e):"all",this}set wallet(e){if(!e)return this._wallet=void 0,void(this.walletConfig=void 0);this._wallet=e,this.walletConfig??={},this.walletConfig.lnPay=e?.lnPay?.bind(e),this.walletConfig.cashuPay=e?.cashuPay?.bind(e)}get wallet(){return this._wallet}},nip19_exports$1={};__reExport(nip19_exports$1,nip19_star);var nip49_exports={};function disconnect(e,t){return t??=createDebug5("ndk:relay:auth-policies:disconnect"),async n=>{t?.(`Relay ${n.url} requested authentication, disconnecting`),e.removeRelay(n.url)}}async function signAndAuth(e,t,n,r,i,s){try{await e.sign(n),i(e)}catch(n){r?.(`Failed to publish auth event to relay ${t.url}`,n),s(e)}}function signIn({ndk:e,signer:t,debug:n}={}){return n??=createDebug5("ndk:auth-policies:signIn"),async(r,i)=>{n?.(`Relay ${r.url} requested authentication, signing in`);const s=new NDKEvent(e);return s.kind=22242,s.tags=[["relay",r.url],["challenge",i]],t??=e?.signer,new Promise(async(i,o)=>{t?await signAndAuth(s,r,t,n,i,o):e?.once("signer:ready",async e=>{await signAndAuth(s,r,e,n,i,o)})})}}__reExport(nip49_exports,nip49_star);var NDKRelayAuthPolicies={disconnect:disconnect,signIn:signIn};async function ndkSignerFromPayload(e,t){let n;try{n=JSON.parse(e)}catch(t){return void console.error("Failed to parse signer payload string",e,t)}if(!n||"string"!=typeof n.type)return void console.error("Failed to parse signer payload string",e,new Error("Missing type field"));const r=signerRegistry.get(n.type);if(!r)throw new Error(`Unknown signer type: ${n.type}`);try{return await r.fromPayload(e,t)}catch(e){const t=e instanceof Error?e.message:String(e);throw new Error(`Failed to deserialize signer type ${n.type}: ${t}`)}}var NDKNip07Signer=class e{_userPromise;encryptionQueue=[];encryptionProcessing=!1;debug;waitTimeout;_pubkey;ndk;_user;constructor(e=1e3,t){this.debug=createDebug5("ndk:nip07"),this.waitTimeout=e,this.ndk=t}get pubkey(){if(!this._pubkey)throw new Error("Not ready");return this._pubkey}async blockUntilReady(){await this.waitForExtension();const e=await(window.nostr?.getPublicKey());if(!e)throw new Error("User rejected access");let t;return this._pubkey=e,t=this.ndk?this.ndk.getUser({pubkey:e}):new NDKUser({pubkey:e}),this._user=t,t}async user(){return this._userPromise||(this._userPromise=this.blockUntilReady()),this._userPromise}get userSync(){if(!this._user)throw new Error("User not ready");return this._user}async sign(e){await this.waitForExtension();const t=await(window.nostr?.signEvent(e));if(!t)throw new Error("Failed to sign event");return t.sig}async relays(e){await this.waitForExtension();const t=await(window.nostr?.getRelays?.())||{},n=[];for(const e of Object.keys(t))t[e].read&&t[e].write&&n.push(e);return n.map(t=>new NDKRelay(t,e?.relayAuthDefaultPolicy,e))}async encryptionEnabled(e){const t=[];return e&&"nip04"!==e||!Boolean(window.nostr?.nip04)||t.push("nip04"),e&&"nip44"!==e||!Boolean(window.nostr?.nip44)||t.push("nip44"),t}async encrypt(e,t,n="nip04"){if(!await this.encryptionEnabled(n))throw new Error(`${n}encryption is not available from your browser extension`);await this.waitForExtension();const r=e.pubkey;return this.queueEncryption(n,"encrypt",r,t)}async decrypt(e,t,n="nip04"){if(!await this.encryptionEnabled(n))throw new Error(`${n}encryption is not available from your browser extension`);await this.waitForExtension();const r=e.pubkey;return this.queueEncryption(n,"decrypt",r,t)}async queueEncryption(e,t,n,r){return new Promise((i,s)=>{this.encryptionQueue.push({scheme:e,method:t,counterpartyHexpubkey:n,value:r,resolve:i,reject:s}),this.encryptionProcessing||this.processEncryptionQueue()})}async processEncryptionQueue(e,t=0){if(!e&&0===this.encryptionQueue.length)return void(this.encryptionProcessing=!1);this.encryptionProcessing=!0;const n=e||this.encryptionQueue.shift();if(!n)return void(this.encryptionProcessing=!1);const{scheme:r,method:i,counterpartyHexpubkey:s,value:o,resolve:a,reject:c}=n;this.debug("Processing encryption queue item",{method:i,counterpartyHexpubkey:s,value:o});try{const e=await(window.nostr?.[r]?.[i](s,o));if(!e)throw new Error("Failed to encrypt/decrypt");a(e)}catch(e){const r=e instanceof Error?e.message:String(e);if(r.includes("call already executing")&&t<5)return this.debug("Retrying encryption queue item",{method:i,counterpartyHexpubkey:s,value:o,retries:t}),void setTimeout(()=>{this.processEncryptionQueue(n,t+1)},50*t);c(e instanceof Error?e:new Error(r))}this.processEncryptionQueue()}waitForExtension(){return new Promise((e,t)=>{if(window.nostr)return void e();let n;const r=setInterval(()=>{window.nostr&&(clearTimeout(n),clearInterval(r),e())},100);n=setTimeout(()=>{clearInterval(r),t(new Error("NIP-07 extension not available"))},this.waitTimeout)})}toPayload(){return JSON.stringify({type:"nip07",payload:""})}static async fromPayload(t,n){const r=JSON.parse(t);if("nip07"!==r.type)throw new Error(`Invalid payload type: expected 'nip07', got ${r.type}`);return new e(void 0,n)}};registerSigner("nip07",NDKNip07Signer);var NDKNostrRpc=class extends lib$1.EventEmitter{ndk;signer;relaySet;debug;encryptionType="nip04";pool;constructor(e,t,n,r){if(super(),this.ndk=e,this.signer=t,r){this.pool=new NDKPool(r,e,{debug:n.extend("rpc-pool"),name:"Nostr RPC"}),this.relaySet=new NDKRelaySet(new Set,e,this.pool);for(const i of r){const r=this.pool.getRelay(i,!1,!1);r.authPolicy=NDKRelayAuthPolicies.signIn({ndk:e,signer:t,debug:n}),this.relaySet.addRelay(r),r.connect()}}this.debug=n.extend("rpc")}subscribe(e){return new Promise(t=>{const n=this.ndk.subscribe(e,{closeOnEose:!1,groupable:!1,cacheUsage:"ONLY_RELAY",pool:this.pool,relaySet:this.relaySet,onEvent:async e=>{try{const t=await this.parseEvent(e);t.method?this.emit("request",t):(this.emit(`response-${t.id}`,t),this.emit("response",t))}catch(t){this.debug("error parsing event",t,e.rawEvent())}},onEose:()=>{this.debug("eosed"),t(n)}})})}async parseEvent(e){"nip44"===this.encryptionType&&e.content.includes("?iv=")?this.encryptionType="nip04":"nip04"!==this.encryptionType||e.content.includes("?iv=")||(this.encryptionType="nip44");const t=this.ndk.getUser({pubkey:e.pubkey});let n;t.ndk=this.ndk;try{n=await this.signer.decrypt(t,e.content,this.encryptionType)}catch(r){const i="nip04"===this.encryptionType?"nip44":"nip04";n=await this.signer.decrypt(t,e.content,i),this.encryptionType=i}const r=JSON.parse(n),{id:i,method:s,params:o,result:a,error:c}=r;return s?{id:i,pubkey:e.pubkey,method:s,params:o,event:e}:{id:i,result:a,error:c,event:e}}async sendResponse(e,t,n,r=24133,i){const s={id:e,result:n};i&&(s.error=i);const o=await this.signer.user(),a=this.ndk.getUser({pubkey:t}),c=new NDKEvent(this.ndk,{kind:r,content:JSON.stringify(s),tags:[["p",t]],pubkey:o.pubkey});c.content=await this.signer.encrypt(a,c.content,this.encryptionType),await c.sign(this.signer),await c.publish(this.relaySet)}async sendRequest(e,t,n=[],r=24133,i){const s=Math.random().toString(36).substring(7),o=await this.signer.user(),a=this.ndk.getUser({pubkey:e}),c={id:s,method:t,params:n},l=new Promise(()=>{const e=t=>{"auth_url"===t.result?(this.once(`response-${s}`,e),this.emit("authUrl",t.error)):i&&i(t)};this.once(`response-${s}`,e)}),h=new NDKEvent(this.ndk,{kind:r,content:JSON.stringify(c),tags:[["p",e]],pubkey:o.pubkey});return h.content=await this.signer.encrypt(a,h.content,this.encryptionType),await h.sign(this.signer),await h.publish(this.relaySet),l}};function nostrConnectGenerateSecret(){return Math.random().toString(36).substring(2,15)}function generateNostrConnectUri(e,t,n,r){const i=r?.name?encodeURIComponent(r.name):"",s=r?.url?encodeURIComponent(r.url):"";let o=`nostrconnect://${e}?image=${r?.image?encodeURIComponent(r.image):""}&url=${s}&name=${i}&perms=${r?.perms?encodeURIComponent(r.perms):""}&secret=${encodeURIComponent(t)}`;return n&&(o+=`&relay=${encodeURIComponent(n)}`),o}var NDKNip46Signer=class e extends lib$1.EventEmitter{ndk;_user;bunkerPubkey;userPubkey;get pubkey(){if(!this.userPubkey)throw new Error("Not ready");return this.userPubkey}secret;localSigner;nip05;rpc;debug;relayUrls;subscription;nostrConnectUri;nostrConnectSecret;constructor(e,t,n,r,i){super(),this.ndk=e,this.debug=e.debug.extend("nip46:signer"),this.relayUrls=r,this.localSigner=n?"string"==typeof n?new NDKPrivateKeySigner(n):n:NDKPrivateKeySigner.generate(),!1===t||(t?t.startsWith("bunker://")?this.bunkerFlowInit(t):this.nip05Init(t):this.nostrconnectFlowInit(i)),this.rpc=new NDKNostrRpc(this.ndk,this.localSigner,this.debug,this.relayUrls)}static bunker(t,n,r){return new e(t,n,r)}static nostrconnect(t,n,r,i){return new e(t,void 0,r,[n],i)}nostrconnectFlowInit(e){this.nostrConnectSecret=nostrConnectGenerateSecret();const t=this.localSigner.pubkey;this.nostrConnectUri=generateNostrConnectUri(t,this.nostrConnectSecret,this.relayUrls?.[0],e)}bunkerFlowInit(e){const t=new URL(e),n=t.hostname||t.pathname.replace(/^\/\//,""),r=t.searchParams.get("pubkey"),i=t.searchParams.getAll("relay"),s=t.searchParams.get("secret");this.bunkerPubkey=n,this.userPubkey=r,this.relayUrls=i,this.secret=s}nip05Init(e){this.nip05=e}async startListening(){if(this.subscription)return;const e=await this.localSigner.user();if(!e)throw new Error("Local signer not ready");this.subscription=await this.rpc.subscribe({kinds:[24133],"#p":[e.pubkey]})}async user(){return this._user?this._user:this.blockUntilReady()}get userSync(){if(!this._user)throw new Error("Remote user not ready synchronously");return this._user}async blockUntilReadyNostrConnect(){return new Promise((e,t)=>{const n=t=>{t.result===this.nostrConnectSecret&&(this._user=t.event.author,this.userPubkey=t.event.pubkey,this.bunkerPubkey=t.event.pubkey,this.rpc.off("response",n),e(this._user))};this.startListening(),this.rpc.on("response",n)})}async blockUntilReady(){if(!this.bunkerPubkey&&!this.nostrConnectSecret&&!this.nip05)throw new Error("Bunker pubkey not set");if(this.nostrConnectSecret)return this.blockUntilReadyNostrConnect();if(this.nip05&&!this.userPubkey){const e=await NDKUser.fromNip05(this.nip05,this.ndk);e&&(this._user=e,this.userPubkey=e.pubkey,this.relayUrls=e.nip46Urls,this.rpc=new NDKNostrRpc(this.ndk,this.localSigner,this.debug,this.relayUrls))}if(!this.bunkerPubkey&&this.userPubkey)this.bunkerPubkey=this.userPubkey;else if(!this.bunkerPubkey)throw new Error("Bunker pubkey not set");return await this.startListening(),this.rpc.on("authUrl",(...e)=>{this.emit("authUrl",...e)}),new Promise((e,t)=>{const n=[this.userPubkey??""];if(this.secret&&n.push(this.secret),!this.bunkerPubkey)throw new Error("Bunker pubkey not set");this.rpc.sendRequest(this.bunkerPubkey,"connect",n,24133,n=>{"ack"===n.result?this.getPublicKey().then(t=>{this.userPubkey=t,this._user=this.ndk.getUser({pubkey:t}),e(this._user)}):t(n.error)})})}stop(){this.subscription?.stop(),this.subscription=void 0}async getPublicKey(){return this.userPubkey?this.userPubkey:new Promise((e,t)=>{if(!this.bunkerPubkey)throw new Error("Bunker pubkey not set");this.rpc.sendRequest(this.bunkerPubkey,"get_public_key",[],24133,t=>{e(t.result)})})}async encryptionEnabled(e){return e?[e]:Promise.resolve(["nip04","nip44"])}async encrypt(e,t,n="nip04"){return this.encryption(e,t,n,"encrypt")}async decrypt(e,t,n="nip04"){return this.encryption(e,t,n,"decrypt")}async encryption(e,t,n,r){return new Promise((i,s)=>{if(!this.bunkerPubkey)throw new Error("Bunker pubkey not set");this.rpc.sendRequest(this.bunkerPubkey,`${n}_${r}`,[e.pubkey,t],24133,e=>{e.error?s(e.error):i(e.result)})})}async sign(e){return new Promise((t,n)=>{if(!this.bunkerPubkey)throw new Error("Bunker pubkey not set");this.rpc.sendRequest(this.bunkerPubkey,"sign_event",[JSON.stringify(e)],24133,e=>{if(e.error)n(e.error);else{const n=JSON.parse(e.result);t(n.sig)}})})}async createAccount(e,t,n){await this.startListening();const r=[];return e&&r.push(e),t&&r.push(t),n&&r.push(n),new Promise((e,t)=>{if(!this.bunkerPubkey)throw new Error("Bunker pubkey not set");this.rpc.sendRequest(this.bunkerPubkey,"create_account",r,24133,n=>{if(n.error)t(n.error);else{const t=n.result;e(t)}})})}toPayload(){if(!this.bunkerPubkey||!this.userPubkey)throw new Error("NIP-46 signer is not fully initialized for serialization");const e={type:"nip46",payload:{bunkerPubkey:this.bunkerPubkey,userPubkey:this.userPubkey,relayUrls:this.relayUrls,secret:this.secret,localSignerPayload:this.localSigner.toPayload(),nip05:this.nip05||null}};return JSON.stringify(e)}static async fromPayload(t,n){if(!n)throw new Error("NDK instance is required to deserialize NIP-46 signer");const r=JSON.parse(t);if("nip46"!==r.type)throw new Error(`Invalid payload type: expected 'nip46', got ${r.type}`);const i=r.payload;if(!i||"object"!=typeof i||!i.localSignerPayload)throw new Error("Invalid payload content for nip46 signer");const s=await ndkSignerFromPayload(i.localSignerPayload,n);if(!s)throw new Error("Failed to deserialize local signer for NIP-46");if(!(s instanceof NDKPrivateKeySigner))throw new Error("Local signer must be an instance of NDKPrivateKeySigner");let o;return o=new e(n,!1,s,i.relayUrls),o.userPubkey=i.userPubkey,o.bunkerPubkey=i.bunkerPubkey,o.relayUrls=i.relayUrls,o.secret=i.secret,i.userPubkey&&(o._user=new NDKUser({pubkey:i.userPubkey}),o._user&&(o._user.ndk=n)),o}};function number$4(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function bool$3(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)}function bytes$4(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function hash$4(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");number$4(e.outputLen),number$4(e.blockLen)}function exists$4(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output$4(e,t){bytes$4(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}registerSigner("nip46",NDKNip46Signer),createDebug5("ndk:zapper:ln"),createDebug5("ndk:zapper");const assert$3={number:number$4,bool:bool$3,bytes:bytes$4,hash:hash$4,exists:exists$4,output:output$4},crypto$3="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,u8a$4=e=>e instanceof Uint8Array,createView$3=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),rotr$3=(e,t)=>e<<32-t|e>>>t,isLE$4=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!isLE$4)throw new Error("Non little-endian hardware is not supported");const hexes$3=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function bytesToHex$3(e){if(!u8a$4(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=hexes$3[e[n]];return t}function hexToBytes$3(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const r=2*t,i=e.slice(r,r+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[t]=s}return n}function utf8ToBytes$6(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function toBytes$4(e){if("string"==typeof e&&(e=utf8ToBytes$6(e)),!u8a$4(e))throw new Error("expected Uint8Array, got "+typeof e);return e}function concatBytes$4(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!u8a$4(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}let Hash$3=class{clone(){return this._cloneInto()}};function wrapConstructor$3(e){const t=t=>e().update(toBytes$4(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function randomBytes$2(e=32){if(crypto$3&&"function"==typeof crypto$3.getRandomValues)return crypto$3.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function setBigUint64$3(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,a,r)}let SHA2$3=class extends Hash$3{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=createView$3(this.buffer)}update(e){assert$3.exists(this);const{view:t,buffer:n,blockLen:r}=this,i=(e=toBytes$4(e)).length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);if(o===r){const t=createView$3(e);for(;r<=i-s;s+=r)this.process(t,s);continue}n.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){assert$3.exists(this),assert$3.output(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>r-s&&(this.process(n,0),s=0);for(let e=s;e<r;e++)t[e]=0;setBigUint64$3(n,r-8,BigInt(8*this.length),i),this.process(n,0);const o=createView$3(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:i,destroyed:s,pos:o}=this;return e.length=r,e.pos=o,e.finished=i,e.destroyed=s,r%t&&e.buffer.set(n),e}};const Chi$3=(e,t,n)=>e&t^~e&n,Maj$3=(e,t,n)=>e&t^e&n^t&n,SHA256_K$3=new Uint32Array([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]),IV$3=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W$3=new Uint32Array(64);let SHA256$3=class extends SHA2$3{constructor(){super(64,32,8,!1),this.A=0|IV$3[0],this.B=0|IV$3[1],this.C=0|IV$3[2],this.D=0|IV$3[3],this.E=0|IV$3[4],this.F=0|IV$3[5],this.G=0|IV$3[6],this.H=0|IV$3[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:s,G:o,H:a}=this;return[e,t,n,r,i,s,o,a]}set(e,t,n,r,i,s,o,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)SHA256_W$3[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=SHA256_W$3[e-15],n=SHA256_W$3[e-2],r=rotr$3(t,7)^rotr$3(t,18)^t>>>3,i=rotr$3(n,17)^rotr$3(n,19)^n>>>10;SHA256_W$3[e]=i+SHA256_W$3[e-7]+r+SHA256_W$3[e-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(rotr$3(o,6)^rotr$3(o,11)^rotr$3(o,25))+Chi$3(o,a,c)+SHA256_K$3[e]+SHA256_W$3[e]|0,h=(rotr$3(n,2)^rotr$3(n,13)^rotr$3(n,22))+Maj$3(n,r,i)|0;l=c,c=a,a=o,o=s+t|0,s=i,i=r,r=n,n=t+h|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,s,o,a,c,l)}roundClean(){SHA256_W$3.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},SHA224$1=class extends SHA256$3{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};const sha256$3=wrapConstructor$3(()=>new SHA256$3);wrapConstructor$3(()=>new SHA224$1);
23
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
24
- const _0n$8=BigInt(0),_1n$9=BigInt(1),_2n$5=BigInt(2),u8a$3=e=>e instanceof Uint8Array,hexes$2=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function bytesToHex$2(e){if(!u8a$3(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=hexes$2[e[n]];return t}function numberToHexUnpadded$1(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function hexToNumber$1(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function hexToBytes$2(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const r=2*t,i=e.slice(r,r+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[t]=s}return n}function bytesToNumberBE$1(e){return hexToNumber$1(bytesToHex$2(e))}function bytesToNumberLE$1(e){if(!u8a$3(e))throw new Error("Uint8Array expected");return hexToNumber$1(bytesToHex$2(Uint8Array.from(e).reverse()))}function numberToBytesBE$1(e,t){return hexToBytes$2(e.toString(16).padStart(2*t,"0"))}function numberToBytesLE$1(e,t){return numberToBytesBE$1(e,t).reverse()}function numberToVarBytesBE$1(e){return hexToBytes$2(numberToHexUnpadded$1(e))}function ensureBytes$2(e,t,n){let r;if("string"==typeof t)try{r=hexToBytes$2(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!u8a$3(t))throw new Error(`${e} must be hex string or Uint8Array`);r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(`${e} expected ${n} bytes, got ${i}`);return r}function concatBytes$3(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!u8a$3(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}function equalBytes$2(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function utf8ToBytes$5(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function bitLen$1(e){let t;for(t=0;e>_0n$8;e>>=_1n$9,t+=1);return t}function bitGet$1(e,t){return e>>BigInt(t)&_1n$9}const bitSet$1=(e,t,n)=>e|(n?_1n$9:_0n$8)<<BigInt(t),bitMask$1=e=>(_2n$5<<BigInt(e-1))-_1n$9,u8n$1=e=>new Uint8Array(e),u8fr$1=e=>Uint8Array.from(e);function createHmacDrbg$1(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=u8n$1(e),i=u8n$1(e),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},a=(...e)=>n(i,r,...e),c=(e=u8n$1())=>{i=a(u8fr$1([0]),e),r=a(),0!==e.length&&(i=a(u8fr$1([1]),e),r=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=a();const t=r.slice();n.push(t),e+=r.length}return concatBytes$3(...n)};return(e,t)=>{let n;for(o(),c(e);!(n=t(l()));)c();return o(),n}}const validatorFns$1={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function validateObject$1(e,t,n={}){const r=(t,n,r)=>{const i=validatorFns$1[n];if("function"!=typeof i)throw new Error(`Invalid validator "${n}", expected function`);const s=e[t];if(!(r&&void 0===s||i(s,e)))throw new Error(`Invalid param ${String(t)}=${s} (${typeof s}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}var ut$1=Object.freeze({__proto__:null,bitGet:bitGet$1,bitLen:bitLen$1,bitMask:bitMask$1,bitSet:bitSet$1,bytesToHex:bytesToHex$2,bytesToNumberBE:bytesToNumberBE$1,bytesToNumberLE:bytesToNumberLE$1,concatBytes:concatBytes$3,createHmacDrbg:createHmacDrbg$1,ensureBytes:ensureBytes$2,equalBytes:equalBytes$2,hexToBytes:hexToBytes$2,hexToNumber:hexToNumber$1,numberToBytesBE:numberToBytesBE$1,numberToBytesLE:numberToBytesLE$1,numberToHexUnpadded:numberToHexUnpadded$1,numberToVarBytesBE:numberToVarBytesBE$1,utf8ToBytes:utf8ToBytes$5,validateObject:validateObject$1});
25
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$7=BigInt(0),_1n$8=BigInt(1),_2n$4=BigInt(2),_3n$3=BigInt(3),_4n$1=BigInt(4),_5n$1=BigInt(5),_8n$1=BigInt(8);function mod$1(e,t){const n=e%t;return n>=_0n$7?n:t+n}function pow$1(e,t,n){if(n<=_0n$7||t<_0n$7)throw new Error("Expected power/modulo > 0");if(n===_1n$8)return _0n$7;let r=_1n$8;for(;t>_0n$7;)t&_1n$8&&(r=r*e%n),e=e*e%n,t>>=_1n$8;return r}function pow2$1(e,t,n){let r=e;for(;t-- >_0n$7;)r*=r,r%=n;return r}function invert$1(e,t){if(e===_0n$7||t<=_0n$7)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=mod$1(e,t),r=t,i=_0n$7,s=_1n$8;for(;n!==_0n$7;){const e=r%n,t=i-s*(r/n);r=n,n=e,i=s,s=t}if(r!==_1n$8)throw new Error("invert: does not exist");return mod$1(i,t)}function tonelliShanks$1(e){const t=(e-_1n$8)/_2n$4;let n,r,i;for(n=e-_1n$8,r=0;n%_2n$4===_0n$7;n/=_2n$4,r++);for(i=_2n$4;i<e&&pow$1(i,t,e)!==e-_1n$8;i++);if(1===r){const t=(e+_1n$8)/_4n$1;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}const s=(n+_1n$8)/_2n$4;return function(e,o){if(e.pow(o,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=r,c=e.pow(e.mul(e.ONE,i),n),l=e.pow(o,s),h=e.pow(o,n);for(;!e.eql(h,e.ONE);){if(e.eql(h,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(h);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(c,_1n$8<<BigInt(a-t-1));c=e.sqr(n),l=e.mul(l,n),h=e.mul(h,c),a=t}return l}}function FpSqrt$1(e){if(e%_4n$1===_3n$3){const t=(e+_1n$8)/_4n$1;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%_8n$1===_5n$1){const t=(e-_5n$1)/_8n$1;return function(e,n){const r=e.mul(n,_2n$4),i=e.pow(r,t),s=e.mul(n,i),o=e.mul(e.mul(s,_2n$4),i),a=e.mul(s,e.sub(o,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return tonelliShanks$1(e)}BigInt(9),BigInt(16);const FIELD_FIELDS$1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField$1(e){const t=FIELD_FIELDS$1.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return validateObject$1(e,t)}function FpPow$1(e,t,n){if(n<_0n$7)throw new Error("Expected power > 0");if(n===_0n$7)return e.ONE;if(n===_1n$8)return t;let r=e.ONE,i=t;for(;n>_0n$7;)n&_1n$8&&(r=e.mul(r,i)),i=e.sqr(i),n>>=_1n$8;return r}function FpInvertBatch$1(e,t){const n=new Array(t.length),r=t.reduce((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r)),e.ONE),i=e.inv(r);return t.reduceRight((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r)),i),n}function nLength$1(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Field$1(e,t,n=!1,r={}){if(e<=_0n$7)throw new Error(`Expected Fp ORDER > 0, got ${e}`);const{nBitLength:i,nByteLength:s}=nLength$1(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=FpSqrt$1(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:s,MASK:bitMask$1(i),ZERO:_0n$7,ONE:_1n$8,create:t=>mod$1(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return _0n$7<=t&&t<e},is0:e=>e===_0n$7,isOdd:e=>(e&_1n$8)===_1n$8,neg:t=>mod$1(-t,e),eql:(e,t)=>e===t,sqr:t=>mod$1(t*t,e),add:(t,n)=>mod$1(t+n,e),sub:(t,n)=>mod$1(t-n,e),mul:(t,n)=>mod$1(t*n,e),pow:(e,t)=>FpPow$1(a,e,t),div:(t,n)=>mod$1(t*invert$1(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>invert$1(t,e),sqrt:r.sqrt||(e=>o(a,e)),invertBatch:e=>FpInvertBatch$1(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?numberToBytesLE$1(e,s):numberToBytesBE$1(e,s),fromBytes:e=>{if(e.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${e.length}`);return n?bytesToNumberLE$1(e):bytesToNumberBE$1(e)}});return Object.freeze(a)}function hashToPrivateScalar$1(e,t,n=!1){const r=(e=ensureBytes$2("privateHash",e)).length,i=nLength$1(t).nByteLength+8;if(i<24||r<i||r>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${r}`);return mod$1(n?bytesToNumberLE$1(e):bytesToNumberBE$1(e),t-_1n$8)+_1n$8}
26
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$6=BigInt(0),_1n$7=BigInt(1);function wNAF$1(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>_0n$6;)n&_1n$7&&(r=r.add(i)),i=i.double(),n>>=_1n$7;return r},precomputeWindow(e,t){const{windows:n,windowSize:i}=r(t),s=[];let o=e,a=o;for(let e=0;e<n;e++){a=o,s.push(a);for(let e=1;e<i;e++)a=a.add(o),s.push(a);o=a.double()}return s},wNAF(t,i,s){const{windows:o,windowSize:a}=r(t);let c=e.ZERO,l=e.BASE;const h=BigInt(2**t-1),d=2**t,u=BigInt(t);for(let e=0;e<o;e++){const t=e*a;let r=Number(s&h);s>>=u,r>a&&(r-=d,s+=_1n$7);const o=t,f=t+Math.abs(r)-1,p=e%2!=0,g=r<0;0===r?l=l.add(n(p,i[o])):c=c.add(n(g,i[f]))}return{p:c,f:l}},wNAFCached(e,t,n,r){const i=e._WINDOW_SIZE||1;let s=t.get(e);return s||(s=this.precomputeWindow(e,i),1!==i&&t.set(e,r(s))),this.wNAF(i,s,n)}}}function validateBasic$1(e){return validateField$1(e.Fp),validateObject$1(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...nLength$1(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
27
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function validatePointOpts$1(e){const t=validateBasic$1(e);validateObject$1(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:i}=t;if(n){if(!r.eql(i,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:b2n$1,hexToBytes:h2b$1}=ut$1,DER$1={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=DER$1;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(128&r[0])throw new t("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:b2n$1(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=DER$1,n="string"==typeof e?h2b$1(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:i,l:s}=DER$1._parseInt(n.subarray(2)),{d:o,l:a}=DER$1._parseInt(s);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},r=t(n(e.s)),i=t(n(e.r)),s=r.length/2,o=i.length/2,a=n(s),c=n(o);return`30${n(o+s+4)}02${c}${i}02${a}${r}`}},_0n$5=BigInt(0),_1n$6=BigInt(1);BigInt(2);const _3n$2=BigInt(3);function weierstrassPoints$1(e){const t=validatePointOpts$1(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{const i=t.toAffine();return concatBytes$3(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),i=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function s(e){const{a:r,b:i}=t,s=n.sqr(e),o=n.mul(s,e);return n.add(n.add(o,n.mul(e,r)),i)}if(!n.eql(n.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function o(e){return"bigint"==typeof e&&_0n$5<e&&e<t.n}function a(e){if(!o(e))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:i,n:s}=t;if(n&&"bigint"!=typeof e){if(e instanceof Uint8Array&&(e=bytesToHex$2(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*r,"0")}let o;try{o="bigint"==typeof e?e:bytesToNumberBE$1(ensureBytes$2("private key",e,r))}catch(t){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return i&&(o=mod$1(o,s)),a(o),o}const l=new Map;function h(e){if(!(e instanceof d))throw new Error("ProjectivePoint expected")}class d{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required")}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof d)throw new Error("projective point not allowed");const i=e=>n.eql(e,n.ZERO);return i(t)&&i(r)?d.ZERO:new d(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)}static fromHex(e){const t=d.fromAffine(i(ensureBytes$2("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw new Error("bad point: x or y not FE");const i=n.sqr(r),o=s(e);if(!n.eql(i,o))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){h(e);const{px:t,py:r,pz:i}=this,{px:s,py:o,pz:a}=e,c=n.eql(n.mul(t,a),n.mul(s,i)),l=n.eql(n.mul(r,a),n.mul(o,i));return c&&l}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,i=n.mul(r,_3n$2),{px:s,py:o,pz:a}=this;let c=n.ZERO,l=n.ZERO,h=n.ZERO,u=n.mul(s,s),f=n.mul(o,o),p=n.mul(a,a),g=n.mul(s,o);return g=n.add(g,g),h=n.mul(s,a),h=n.add(h,h),c=n.mul(e,h),l=n.mul(i,p),l=n.add(c,l),c=n.sub(f,l),l=n.add(f,l),l=n.mul(c,l),c=n.mul(g,c),h=n.mul(i,h),p=n.mul(e,p),g=n.sub(u,p),g=n.mul(e,g),g=n.add(g,h),h=n.add(u,u),u=n.add(h,u),u=n.add(u,p),u=n.mul(u,g),l=n.add(l,u),p=n.mul(o,a),p=n.add(p,p),u=n.mul(p,g),c=n.sub(c,u),h=n.mul(p,f),h=n.add(h,h),h=n.add(h,h),new d(c,l,h)}add(e){h(e);const{px:r,py:i,pz:s}=this,{px:o,py:a,pz:c}=e;let l=n.ZERO,u=n.ZERO,f=n.ZERO;const p=t.a,g=n.mul(t.b,_3n$2);let y=n.mul(r,o),m=n.mul(i,a),b=n.mul(s,c),w=n.add(r,i),v=n.add(o,a);w=n.mul(w,v),v=n.add(y,m),w=n.sub(w,v),v=n.add(r,s);let $=n.add(o,c);return v=n.mul(v,$),$=n.add(y,b),v=n.sub(v,$),$=n.add(i,s),l=n.add(a,c),$=n.mul($,l),l=n.add(m,b),$=n.sub($,l),f=n.mul(p,v),l=n.mul(g,b),f=n.add(l,f),l=n.sub(m,f),f=n.add(m,f),u=n.mul(l,f),m=n.add(y,y),m=n.add(m,y),b=n.mul(p,b),v=n.mul(g,v),m=n.add(m,b),b=n.sub(y,b),b=n.mul(p,b),v=n.add(v,b),y=n.mul(m,v),u=n.add(u,y),y=n.mul($,v),l=n.mul(w,l),l=n.sub(l,y),y=n.mul(w,m),f=n.mul($,f),f=n.add(f,y),new d(l,u,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return f.wNAFCached(this,l,e,e=>{const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)})}multiplyUnsafe(e){const r=d.ZERO;if(e===_0n$5)return r;if(a(e),e===_1n$6)return this;const{endo:i}=t;if(!i)return f.unsafeLadder(this,e);let{k1neg:s,k1:o,k2neg:c,k2:l}=i.splitScalar(e),h=r,u=r,p=this;for(;o>_0n$5||l>_0n$5;)o&_1n$6&&(h=h.add(p)),l&_1n$6&&(u=u.add(p)),p=p.double(),o>>=_1n$6,l>>=_1n$6;return s&&(h=h.negate()),c&&(u=u.negate()),u=new d(n.mul(u.px,i.beta),u.py,u.pz),h.add(u)}multiply(e){a(e);let r,i,s=e;const{endo:o}=t;if(o){const{k1neg:e,k1:t,k2neg:a,k2:c}=o.splitScalar(s);let{p:l,f:h}=this.wNAF(t),{p:u,f:p}=this.wNAF(c);l=f.constTimeNegate(e,l),u=f.constTimeNegate(a,u),u=new d(n.mul(u.px,o.beta),u.py,u.pz),r=l.add(u),i=h.add(p)}else{const{p:e,f:t}=this.wNAF(s);r=e,i=t}return d.normalizeZ([r,i])[0]}multiplyAndAddUnsafe(e,t,n){const r=d.BASE,i=(e,t)=>t!==_0n$5&&t!==_1n$6&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),s=i(this,t).add(i(e,n));return s.is0()?void 0:s}toAffine(e){const{px:t,py:r,pz:i}=this,s=this.is0();null==e&&(e=s?n.ONE:n.inv(i));const o=n.mul(t,e),a=n.mul(r,e),c=n.mul(i,e);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw new Error("invZ was invalid");return{x:o,y:a}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===_1n$6)return!0;if(n)return n(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===_1n$6?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return bytesToHex$2(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const u=t.nBitLength,f=wNAF$1(d,t.endo?Math.ceil(u/2):u);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:o}}function validateOpts$1(e){const t=validateBasic$1(e);return validateObject$1(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function weierstrass$1(e){const t=validateOpts$1(e),{Fp:n,n:r}=t,i=n.BYTES+1,s=2*n.BYTES+1;function o(e){return mod$1(e,r)}function a(e){return invert$1(e,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:h,isWithinCurveOrder:d}=weierstrassPoints$1({...t,toBytes(e,t,r){const i=t.toAffine(),s=n.toBytes(i.x),o=concatBytes$3;return r?o(Uint8Array.from([t.hasEvenY()?2:3]),s):o(Uint8Array.from([4]),s,n.toBytes(i.y))},fromBytes(e){const t=e.length,r=e[0],o=e.subarray(1);if(t!==i||2!==r&&3!==r){if(t===s&&4===r){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}{const e=bytesToNumberBE$1(o);if(!function(e){return _0n$5<e&&e<n.ORDER}(e))throw new Error("Point is not on curve");const t=h(e);let i=n.sqrt(t);return!(1&~r)!==((i&_1n$6)===_1n$6)&&(i=n.neg(i)),{x:e,y:i}}}}),u=e=>bytesToHex$2(numberToBytesBE$1(e,t.nByteLength));function f(e){return e>r>>_1n$6}const p=(e,t,n)=>bytesToNumberBE$1(e.slice(t,n));class g{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=ensureBytes$2("compactSignature",e,2*n),new g(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=DER$1.toSig(ensureBytes$2("DER",e));return new g(t,n)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:i,recovery:s}=this,l=w(ensureBytes$2("msgHash",e));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const h=2===s||3===s?r+t.n:r;if(h>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=1&s?"03":"02",f=c.fromHex(d+u(h)),p=a(h),g=o(-l*p),y=o(i*p),m=c.BASE.multiplyAndAddUnsafe(f,g,y);if(!m)throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes$2(this.toDERHex())}toDERHex(){return DER$1.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes$2(this.toCompactHex())}toCompactHex(){return u(this.r)+u(this.s)}}const y={isValidPrivateKey(e){try{return l(e),!0}catch(e){return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>numberToBytesBE$1(hashToPrivateScalar$1(t.randomBytes(n.BYTES+8),r),t.nByteLength),precompute:(e=8,t=c.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function m(e){const t=e instanceof Uint8Array,n="string"==typeof e,r=(t||n)&&e.length;return t?r===i||r===s:n?r===2*i||r===2*s:e instanceof c}const b=t.bits2int||function(e){const n=bytesToNumberBE$1(e),r=8*e.length-t.nBitLength;return r>0?n>>BigInt(r):n},w=t.bits2int_modN||function(e){return o(b(e))},v=bitMask$1(t.nBitLength);function $(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(_0n$5<=e&&e<v))throw new Error(`bigint expected < 2^${t.nBitLength}`);return numberToBytesBE$1(e,t.nByteLength)}function E(e,r,i=k){if(["recovered","canonical"].some(e=>e in i))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:h}=t;let{lowS:u,prehash:p,extraEntropy:y}=i;null==u&&(u=!0),e=ensureBytes$2("msgHash",e),p&&(e=ensureBytes$2("prehashed msgHash",s(e)));const m=w(e),v=l(r),E=[$(v),$(m)];if(null!=y){const e=!0===y?h(n.BYTES):y;E.push(ensureBytes$2("extraEntropy",e,n.BYTES))}const x=concatBytes$3(...E),_=m;return{seed:x,k2sig:function(e){const t=b(e);if(!d(t))return;const n=a(t),r=c.BASE.multiply(t).toAffine(),i=o(r.x);if(i===_0n$5)return;const s=o(n*o(_+i*v));if(s===_0n$5)return;let l=(r.x===i?0:2)|Number(r.y&_1n$6),h=s;return u&&f(s)&&(h=function(e){return f(e)?o(-e):e}(s),l^=1),new g(i,h,l)}}}const k={lowS:t.lowS,prehash:!1},x={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(m(e))throw new Error("first arg must be private key");if(!m(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(l(e)).toRawBytes(n)},sign:function(e,n,r=k){const{seed:i,k2sig:s}=E(e,n,r),o=t;return createHmacDrbg$1(o.hash.outputLen,o.nByteLength,o.hmac)(i,s)},verify:function(e,n,r,i=x){const s=e;if(n=ensureBytes$2("msgHash",n),r=ensureBytes$2("publicKey",r),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:l,prehash:h}=i;let d,u;try{if("string"==typeof s||s instanceof Uint8Array)try{d=g.fromDER(s)}catch(e){if(!(e instanceof DER$1.Err))throw e;d=g.fromCompact(s)}else{if("object"!=typeof s||"bigint"!=typeof s.r||"bigint"!=typeof s.s)throw new Error("PARSE");{const{r:e,s:t}=s;d=new g(e,t)}}u=c.fromHex(r)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(l&&d.hasHighS())return!1;h&&(n=t.hash(n));const{r:f,s:p}=d,y=w(n),m=a(p),b=o(y*m),v=o(f*m),$=c.BASE.multiplyAndAddUnsafe(u,b,v)?.toAffine();return!!$&&o($.x)===f},ProjectivePoint:c,Signature:g,utils:y}}BigInt(4);let HMAC$3=class extends Hash$3{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,assert$3.hash(e);const n=toBytes$4(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return assert$3.exists(this),this.iHash.update(e),this}digestInto(e){assert$3.exists(this),assert$3.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:s,outputLen:o}=this;return e.finished=r,e.destroyed=i,e.blockLen=s,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const hmac$3=(e,t,n)=>new HMAC$3(e,t).update(n).digest();
28
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
29
- function getHash$1(e){return{hash:e,hmac:(t,...n)=>hmac$3(e,t,concatBytes$4(...n)),randomBytes:randomBytes$2}}function createCurve$1(e,t){const n=t=>weierstrass$1({...e,...getHash$1(t)});return Object.freeze({...n(t),create:n})}
30
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */hmac$3.create=(e,t)=>new HMAC$3(e,t);const secp256k1P$1=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N$1=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n$5=BigInt(1),_2n$3=BigInt(2),divNearest$1=(e,t)=>(e+t/_2n$3)/t;function sqrtMod$1(e){const t=secp256k1P$1,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,h=l*l*e%t,d=pow2$1(h,n,t)*h%t,u=pow2$1(d,n,t)*h%t,f=pow2$1(u,_2n$3,t)*l%t,p=pow2$1(f,i,t)*f%t,g=pow2$1(p,s,t)*p%t,y=pow2$1(g,a,t)*g%t,m=pow2$1(y,c,t)*y%t,b=pow2$1(m,a,t)*g%t,w=pow2$1(b,n,t)*h%t,v=pow2$1(w,o,t)*p%t,$=pow2$1(v,r,t)*l%t,E=pow2$1($,_2n$3,t);if(!Fp$1.eql(Fp$1.sqr(E),e))throw new Error("Cannot find square root");return E}const Fp$1=Field$1(secp256k1P$1,void 0,void 0,{sqrt:sqrtMod$1}),secp256k1$1=createCurve$1({a:BigInt(0),b:BigInt(7),Fp:Fp$1,n:secp256k1N$1,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=secp256k1N$1,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-_1n$5*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,o=BigInt("0x100000000000000000000000000000000"),a=divNearest$1(s*e,t),c=divNearest$1(-r*e,t);let l=mod$1(e-a*n-c*i,t),h=mod$1(-a*r-c*s,t);const d=l>o,u=h>o;if(d&&(l=t-l),u&&(h=t-h),l>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:l,k2neg:u,k2:h}}}},sha256$3),_0n$4=BigInt(0),fe=e=>"bigint"==typeof e&&_0n$4<e&&e<secp256k1P$1,ge=e=>"bigint"==typeof e&&_0n$4<e&&e<secp256k1N$1,TAGGED_HASH_PREFIXES={};function taggedHash(e,...t){let n=TAGGED_HASH_PREFIXES[e];if(void 0===n){const t=sha256$3(Uint8Array.from(e,e=>e.charCodeAt(0)));n=concatBytes$3(t,t),TAGGED_HASH_PREFIXES[e]=n}return sha256$3(concatBytes$3(n,...t))}const pointToBytes=e=>e.toRawBytes(!0).slice(1),numTo32b=e=>numberToBytesBE$1(e,32),modP=e=>mod$1(e,secp256k1P$1),modN=e=>mod$1(e,secp256k1N$1),Point$1=secp256k1$1.ProjectivePoint,GmulAdd=(e,t,n)=>Point$1.BASE.multiplyAndAddUnsafe(e,t,n);function schnorrGetExtPubKey(e){let t=secp256k1$1.utils.normPrivateKeyToScalar(e),n=Point$1.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:modN(-t),bytes:pointToBytes(n)}}function lift_x(e){if(!fe(e))throw new Error("bad x: need 0 < x < p");const t=modP(e*e);let n=sqrtMod$1(modP(t*e+BigInt(7)));n%_2n$3!==_0n$4&&(n=modP(-n));const r=new Point$1(e,n,_1n$5);return r.assertValidity(),r}function challenge(...e){return modN(bytesToNumberBE$1(taggedHash("BIP0340/challenge",...e)))}function schnorrGetPublicKey(e){return schnorrGetExtPubKey(e).bytes}function schnorrSign(e,t,n=randomBytes$2(32)){const r=ensureBytes$2("message",e),{bytes:i,scalar:s}=schnorrGetExtPubKey(t),o=ensureBytes$2("auxRand",n,32),a=numTo32b(s^bytesToNumberBE$1(taggedHash("BIP0340/aux",o))),c=taggedHash("BIP0340/nonce",a,i,r),l=modN(bytesToNumberBE$1(c));if(l===_0n$4)throw new Error("sign failed: k is zero");const{bytes:h,scalar:d}=schnorrGetExtPubKey(l),u=challenge(h,i,r),f=new Uint8Array(64);if(f.set(h,0),f.set(numTo32b(modN(d+u*s)),32),!schnorrVerify(f,r,i))throw new Error("sign: Invalid signature produced");return f}function schnorrVerify(e,t,n){const r=ensureBytes$2("signature",e,64),i=ensureBytes$2("message",t),s=ensureBytes$2("publicKey",n,32);try{const e=lift_x(bytesToNumberBE$1(s)),t=bytesToNumberBE$1(r.subarray(0,32));if(!fe(t))return!1;const n=bytesToNumberBE$1(r.subarray(32,64));if(!ge(n))return!1;const o=challenge(numTo32b(t),pointToBytes(e),i),a=GmulAdd(e,n,modN(-o));return!(!a||!a.hasEvenY()||a.toAffine().x!==t)}catch(e){return!1}}const schnorr=(()=>({getPublicKey:schnorrGetPublicKey,sign:schnorrSign,verify:schnorrVerify,utils:{randomPrivateKey:secp256k1$1.utils.randomPrivateKey,lift_x:lift_x,pointToBytes:pointToBytes,numberToBytesBE:numberToBytesBE$1,bytesToNumberBE:bytesToNumberBE$1,taggedHash:taggedHash,mod:mod$1}}))();
31
- /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function assertNumber(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function chain$2(...e){const t=(e,t)=>n=>e(t(n)),n=Array.from(e).reverse().reduce((e,n)=>e?t(e,n.encode):n.encode,void 0),r=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:r}}function alphabet$2(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map(t=>{if(assertNumber(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]})},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map(t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})}}}function join$2(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function padding$1(e,t="="){if(assertNumber(e),"string"!=typeof t)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;n.length*e%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let r=n.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function normalize$1(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function convertRadix$2(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const i=[],s=Array.from(e);for(s.forEach(e=>{if(assertNumber(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)});;){let e=0,o=!0;for(let i=r;i<s.length;i++){const a=s[i],c=t*e+a;if(!Number.isSafeInteger(c)||t*e/t!==e||c-a!==t*e)throw new Error("convertRadix: carry overflow");if(e=c%n,s[i]=Math.floor(c/n),!Number.isSafeInteger(s[i])||s[i]*n+e!==c)throw new Error("convertRadix: carry overflow");o&&(s[i]?o=!1:r=i)}if(i.push(e),o)break}for(let t=0;t<e.length-1&&0===e[t];t++)i.push(0);return i.reverse()}const gcd$1=(e,t)=>t?gcd$1(t,e%t):e,radix2carry$1=(e,t)=>e+(t-gcd$1(e,t));function convertRadix2$1(e,t,n,r){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(radix2carry$1(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${radix2carry$1(t,n)}`);let i=0,s=0;const o=2**n-1,a=[];for(const r of e){if(assertNumber(r),r>=2**t)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(i=i<<t|r,s+t>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)a.push((i>>s-n&o)>>>0);i&=2**s-1}if(i=i<<n-s&o,!r&&s>=t)throw new Error("Excess padding");if(!r&&i)throw new Error(`Non-zero padding: ${i}`);return r&&s>0&&a.push(i>>>0),a}function radix$2(e){return assertNumber(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return convertRadix$2(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(convertRadix$2(t,e,256))}}}function radix2$1(e,t=!1){if(assertNumber(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(radix2carry$1(8,e)>32||radix2carry$1(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return convertRadix2$1(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(convertRadix2$1(n,e,8,t))}}}function unsafeWrapper(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}const base16=chain$2(radix2$1(4),alphabet$2("0123456789ABCDEF"),join$2("")),base32=chain$2(radix2$1(5),alphabet$2("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),padding$1(5),join$2(""));chain$2(radix2$1(5),alphabet$2("0123456789ABCDEFGHIJKLMNOPQRSTUV"),padding$1(5),join$2("")),chain$2(radix2$1(5),alphabet$2("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),join$2(""),normalize$1(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const base64=chain$2(radix2$1(6),alphabet$2("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),padding$1(6),join$2("")),base64url=chain$2(radix2$1(6),alphabet$2("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),padding$1(6),join$2("")),genBase58$1=e=>chain$2(radix$2(58),alphabet$2(e),join$2("")),base58$1=genBase58$1("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");genBase58$1("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),genBase58$1("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const XMR_BLOCK_LEN=[0,2,3,5,6,7,9,10,11],base58xmr={encode(e){let t="";for(let n=0;n<e.length;n+=8){const r=e.subarray(n,n+8);t+=base58$1.encode(r).padStart(XMR_BLOCK_LEN[r.length],"1")}return t},decode(e){let t=[];for(let n=0;n<e.length;n+=11){const r=e.slice(n,n+11),i=XMR_BLOCK_LEN.indexOf(r.length),s=base58$1.decode(r);for(let e=0;e<s.length-i;e++)if(0!==s[e])throw new Error("base58xmr: wrong padding");t=t.concat(Array.from(s.slice(s.length-i)))}return Uint8Array.from(t)}},BECH_ALPHABET=chain$2(alphabet$2("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),join$2("")),POLYMOD_GENERATORS=[996825010,642813549,513874426,1027748829,705979059];function bech32Polymod(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e<POLYMOD_GENERATORS.length;e++)1==(t>>e&1)&&(n^=POLYMOD_GENERATORS[e]);return n}function bechChecksum(e,t,n=1){const r=e.length;let i=1;for(let t=0;t<r;t++){const n=e.charCodeAt(t);if(n<33||n>126)throw new Error(`Invalid prefix (${e})`);i=bech32Polymod(i)^n>>5}i=bech32Polymod(i);for(let t=0;t<r;t++)i=bech32Polymod(i)^31&e.charCodeAt(t);for(let e of t)i=bech32Polymod(i)^e;for(let e=0;e<6;e++)i=bech32Polymod(i);return i^=n,BECH_ALPHABET.encode(convertRadix2$1([i%2**30],30,5,!1))}function genBech32(e){const t="bech32"===e?1:734539939,n=radix2$1(5),r=n.decode,i=n.encode,s=unsafeWrapper(r);function o(e,n=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==n&&e.length>n)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=(e=r).lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const s=e.slice(0,i),o=e.slice(i+1);if(o.length<6)throw new Error("Data must be at least 6 characters long");const a=BECH_ALPHABET.decode(o).slice(0,-6),c=bechChecksum(s,a,t);if(!o.endsWith(c))throw new Error(`Invalid checksum in ${e}: expected "${c}"`);return{prefix:s,words:a}}return{encode:function(e,n,r=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const i=e.length+7+n.length;if(!1!==r&&i>r)throw new TypeError(`Length ${i} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${BECH_ALPHABET.encode(n)}${bechChecksum(e,n,t)}`},decode:o,decodeToBytes:function(e){const{prefix:t,words:n}=o(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:unsafeWrapper(o),fromWords:r,fromWordsUnsafe:s,toWords:i}}const bech32=genBech32("bech32");genBech32("bech32m");const utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},hex=chain$2(radix2$1(4),alphabet$2("0123456789abcdef"),join$2(""),normalize$1(e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})),CODERS={utf8:utf8,hex:hex,base16:base16,base32:base32,base64:base64,base64url:base64url,base58:base58$1,base58xmr:base58xmr};Object.keys(CODERS).join(", ");const wordlist="abandon\nability\nable\nabout\nabove\nabsent\nabsorb\nabstract\nabsurd\nabuse\naccess\naccident\naccount\naccuse\nachieve\nacid\nacoustic\nacquire\nacross\nact\naction\nactor\nactress\nactual\nadapt\nadd\naddict\naddress\nadjust\nadmit\nadult\nadvance\nadvice\naerobic\naffair\nafford\nafraid\nagain\nage\nagent\nagree\nahead\naim\nair\nairport\naisle\nalarm\nalbum\nalcohol\nalert\nalien\nall\nalley\nallow\nalmost\nalone\nalpha\nalready\nalso\nalter\nalways\namateur\namazing\namong\namount\namused\nanalyst\nanchor\nancient\nanger\nangle\nangry\nanimal\nankle\nannounce\nannual\nanother\nanswer\nantenna\nantique\nanxiety\nany\napart\napology\nappear\napple\napprove\napril\narch\narctic\narea\narena\nargue\narm\narmed\narmor\narmy\naround\narrange\narrest\narrive\narrow\nart\nartefact\nartist\nartwork\nask\naspect\nassault\nasset\nassist\nassume\nasthma\nathlete\natom\nattack\nattend\nattitude\nattract\nauction\naudit\naugust\naunt\nauthor\nauto\nautumn\naverage\navocado\navoid\nawake\naware\naway\nawesome\nawful\nawkward\naxis\nbaby\nbachelor\nbacon\nbadge\nbag\nbalance\nbalcony\nball\nbamboo\nbanana\nbanner\nbar\nbarely\nbargain\nbarrel\nbase\nbasic\nbasket\nbattle\nbeach\nbean\nbeauty\nbecause\nbecome\nbeef\nbefore\nbegin\nbehave\nbehind\nbelieve\nbelow\nbelt\nbench\nbenefit\nbest\nbetray\nbetter\nbetween\nbeyond\nbicycle\nbid\nbike\nbind\nbiology\nbird\nbirth\nbitter\nblack\nblade\nblame\nblanket\nblast\nbleak\nbless\nblind\nblood\nblossom\nblouse\nblue\nblur\nblush\nboard\nboat\nbody\nboil\nbomb\nbone\nbonus\nbook\nboost\nborder\nboring\nborrow\nboss\nbottom\nbounce\nbox\nboy\nbracket\nbrain\nbrand\nbrass\nbrave\nbread\nbreeze\nbrick\nbridge\nbrief\nbright\nbring\nbrisk\nbroccoli\nbroken\nbronze\nbroom\nbrother\nbrown\nbrush\nbubble\nbuddy\nbudget\nbuffalo\nbuild\nbulb\nbulk\nbullet\nbundle\nbunker\nburden\nburger\nburst\nbus\nbusiness\nbusy\nbutter\nbuyer\nbuzz\ncabbage\ncabin\ncable\ncactus\ncage\ncake\ncall\ncalm\ncamera\ncamp\ncan\ncanal\ncancel\ncandy\ncannon\ncanoe\ncanvas\ncanyon\ncapable\ncapital\ncaptain\ncar\ncarbon\ncard\ncargo\ncarpet\ncarry\ncart\ncase\ncash\ncasino\ncastle\ncasual\ncat\ncatalog\ncatch\ncategory\ncattle\ncaught\ncause\ncaution\ncave\nceiling\ncelery\ncement\ncensus\ncentury\ncereal\ncertain\nchair\nchalk\nchampion\nchange\nchaos\nchapter\ncharge\nchase\nchat\ncheap\ncheck\ncheese\nchef\ncherry\nchest\nchicken\nchief\nchild\nchimney\nchoice\nchoose\nchronic\nchuckle\nchunk\nchurn\ncigar\ncinnamon\ncircle\ncitizen\ncity\ncivil\nclaim\nclap\nclarify\nclaw\nclay\nclean\nclerk\nclever\nclick\nclient\ncliff\nclimb\nclinic\nclip\nclock\nclog\nclose\ncloth\ncloud\nclown\nclub\nclump\ncluster\nclutch\ncoach\ncoast\ncoconut\ncode\ncoffee\ncoil\ncoin\ncollect\ncolor\ncolumn\ncombine\ncome\ncomfort\ncomic\ncommon\ncompany\nconcert\nconduct\nconfirm\ncongress\nconnect\nconsider\ncontrol\nconvince\ncook\ncool\ncopper\ncopy\ncoral\ncore\ncorn\ncorrect\ncost\ncotton\ncouch\ncountry\ncouple\ncourse\ncousin\ncover\ncoyote\ncrack\ncradle\ncraft\ncram\ncrane\ncrash\ncrater\ncrawl\ncrazy\ncream\ncredit\ncreek\ncrew\ncricket\ncrime\ncrisp\ncritic\ncrop\ncross\ncrouch\ncrowd\ncrucial\ncruel\ncruise\ncrumble\ncrunch\ncrush\ncry\ncrystal\ncube\nculture\ncup\ncupboard\ncurious\ncurrent\ncurtain\ncurve\ncushion\ncustom\ncute\ncycle\ndad\ndamage\ndamp\ndance\ndanger\ndaring\ndash\ndaughter\ndawn\nday\ndeal\ndebate\ndebris\ndecade\ndecember\ndecide\ndecline\ndecorate\ndecrease\ndeer\ndefense\ndefine\ndefy\ndegree\ndelay\ndeliver\ndemand\ndemise\ndenial\ndentist\ndeny\ndepart\ndepend\ndeposit\ndepth\ndeputy\nderive\ndescribe\ndesert\ndesign\ndesk\ndespair\ndestroy\ndetail\ndetect\ndevelop\ndevice\ndevote\ndiagram\ndial\ndiamond\ndiary\ndice\ndiesel\ndiet\ndiffer\ndigital\ndignity\ndilemma\ndinner\ndinosaur\ndirect\ndirt\ndisagree\ndiscover\ndisease\ndish\ndismiss\ndisorder\ndisplay\ndistance\ndivert\ndivide\ndivorce\ndizzy\ndoctor\ndocument\ndog\ndoll\ndolphin\ndomain\ndonate\ndonkey\ndonor\ndoor\ndose\ndouble\ndove\ndraft\ndragon\ndrama\ndrastic\ndraw\ndream\ndress\ndrift\ndrill\ndrink\ndrip\ndrive\ndrop\ndrum\ndry\nduck\ndumb\ndune\nduring\ndust\ndutch\nduty\ndwarf\ndynamic\neager\neagle\nearly\nearn\nearth\neasily\neast\neasy\necho\necology\neconomy\nedge\nedit\neducate\neffort\negg\neight\neither\nelbow\nelder\nelectric\nelegant\nelement\nelephant\nelevator\nelite\nelse\nembark\nembody\nembrace\nemerge\nemotion\nemploy\nempower\nempty\nenable\nenact\nend\nendless\nendorse\nenemy\nenergy\nenforce\nengage\nengine\nenhance\nenjoy\nenlist\nenough\nenrich\nenroll\nensure\nenter\nentire\nentry\nenvelope\nepisode\nequal\nequip\nera\nerase\nerode\nerosion\nerror\nerupt\nescape\nessay\nessence\nestate\neternal\nethics\nevidence\nevil\nevoke\nevolve\nexact\nexample\nexcess\nexchange\nexcite\nexclude\nexcuse\nexecute\nexercise\nexhaust\nexhibit\nexile\nexist\nexit\nexotic\nexpand\nexpect\nexpire\nexplain\nexpose\nexpress\nextend\nextra\neye\neyebrow\nfabric\nface\nfaculty\nfade\nfaint\nfaith\nfall\nfalse\nfame\nfamily\nfamous\nfan\nfancy\nfantasy\nfarm\nfashion\nfat\nfatal\nfather\nfatigue\nfault\nfavorite\nfeature\nfebruary\nfederal\nfee\nfeed\nfeel\nfemale\nfence\nfestival\nfetch\nfever\nfew\nfiber\nfiction\nfield\nfigure\nfile\nfilm\nfilter\nfinal\nfind\nfine\nfinger\nfinish\nfire\nfirm\nfirst\nfiscal\nfish\nfit\nfitness\nfix\nflag\nflame\nflash\nflat\nflavor\nflee\nflight\nflip\nfloat\nflock\nfloor\nflower\nfluid\nflush\nfly\nfoam\nfocus\nfog\nfoil\nfold\nfollow\nfood\nfoot\nforce\nforest\nforget\nfork\nfortune\nforum\nforward\nfossil\nfoster\nfound\nfox\nfragile\nframe\nfrequent\nfresh\nfriend\nfringe\nfrog\nfront\nfrost\nfrown\nfrozen\nfruit\nfuel\nfun\nfunny\nfurnace\nfury\nfuture\ngadget\ngain\ngalaxy\ngallery\ngame\ngap\ngarage\ngarbage\ngarden\ngarlic\ngarment\ngas\ngasp\ngate\ngather\ngauge\ngaze\ngeneral\ngenius\ngenre\ngentle\ngenuine\ngesture\nghost\ngiant\ngift\ngiggle\nginger\ngiraffe\ngirl\ngive\nglad\nglance\nglare\nglass\nglide\nglimpse\nglobe\ngloom\nglory\nglove\nglow\nglue\ngoat\ngoddess\ngold\ngood\ngoose\ngorilla\ngospel\ngossip\ngovern\ngown\ngrab\ngrace\ngrain\ngrant\ngrape\ngrass\ngravity\ngreat\ngreen\ngrid\ngrief\ngrit\ngrocery\ngroup\ngrow\ngrunt\nguard\nguess\nguide\nguilt\nguitar\ngun\ngym\nhabit\nhair\nhalf\nhammer\nhamster\nhand\nhappy\nharbor\nhard\nharsh\nharvest\nhat\nhave\nhawk\nhazard\nhead\nhealth\nheart\nheavy\nhedgehog\nheight\nhello\nhelmet\nhelp\nhen\nhero\nhidden\nhigh\nhill\nhint\nhip\nhire\nhistory\nhobby\nhockey\nhold\nhole\nholiday\nhollow\nhome\nhoney\nhood\nhope\nhorn\nhorror\nhorse\nhospital\nhost\nhotel\nhour\nhover\nhub\nhuge\nhuman\nhumble\nhumor\nhundred\nhungry\nhunt\nhurdle\nhurry\nhurt\nhusband\nhybrid\nice\nicon\nidea\nidentify\nidle\nignore\nill\nillegal\nillness\nimage\nimitate\nimmense\nimmune\nimpact\nimpose\nimprove\nimpulse\ninch\ninclude\nincome\nincrease\nindex\nindicate\nindoor\nindustry\ninfant\ninflict\ninform\ninhale\ninherit\ninitial\ninject\ninjury\ninmate\ninner\ninnocent\ninput\ninquiry\ninsane\ninsect\ninside\ninspire\ninstall\nintact\ninterest\ninto\ninvest\ninvite\ninvolve\niron\nisland\nisolate\nissue\nitem\nivory\njacket\njaguar\njar\njazz\njealous\njeans\njelly\njewel\njob\njoin\njoke\njourney\njoy\njudge\njuice\njump\njungle\njunior\njunk\njust\nkangaroo\nkeen\nkeep\nketchup\nkey\nkick\nkid\nkidney\nkind\nkingdom\nkiss\nkit\nkitchen\nkite\nkitten\nkiwi\nknee\nknife\nknock\nknow\nlab\nlabel\nlabor\nladder\nlady\nlake\nlamp\nlanguage\nlaptop\nlarge\nlater\nlatin\nlaugh\nlaundry\nlava\nlaw\nlawn\nlawsuit\nlayer\nlazy\nleader\nleaf\nlearn\nleave\nlecture\nleft\nleg\nlegal\nlegend\nleisure\nlemon\nlend\nlength\nlens\nleopard\nlesson\nletter\nlevel\nliar\nliberty\nlibrary\nlicense\nlife\nlift\nlight\nlike\nlimb\nlimit\nlink\nlion\nliquid\nlist\nlittle\nlive\nlizard\nload\nloan\nlobster\nlocal\nlock\nlogic\nlonely\nlong\nloop\nlottery\nloud\nlounge\nlove\nloyal\nlucky\nluggage\nlumber\nlunar\nlunch\nluxury\nlyrics\nmachine\nmad\nmagic\nmagnet\nmaid\nmail\nmain\nmajor\nmake\nmammal\nman\nmanage\nmandate\nmango\nmansion\nmanual\nmaple\nmarble\nmarch\nmargin\nmarine\nmarket\nmarriage\nmask\nmass\nmaster\nmatch\nmaterial\nmath\nmatrix\nmatter\nmaximum\nmaze\nmeadow\nmean\nmeasure\nmeat\nmechanic\nmedal\nmedia\nmelody\nmelt\nmember\nmemory\nmention\nmenu\nmercy\nmerge\nmerit\nmerry\nmesh\nmessage\nmetal\nmethod\nmiddle\nmidnight\nmilk\nmillion\nmimic\nmind\nminimum\nminor\nminute\nmiracle\nmirror\nmisery\nmiss\nmistake\nmix\nmixed\nmixture\nmobile\nmodel\nmodify\nmom\nmoment\nmonitor\nmonkey\nmonster\nmonth\nmoon\nmoral\nmore\nmorning\nmosquito\nmother\nmotion\nmotor\nmountain\nmouse\nmove\nmovie\nmuch\nmuffin\nmule\nmultiply\nmuscle\nmuseum\nmushroom\nmusic\nmust\nmutual\nmyself\nmystery\nmyth\nnaive\nname\nnapkin\nnarrow\nnasty\nnation\nnature\nnear\nneck\nneed\nnegative\nneglect\nneither\nnephew\nnerve\nnest\nnet\nnetwork\nneutral\nnever\nnews\nnext\nnice\nnight\nnoble\nnoise\nnominee\nnoodle\nnormal\nnorth\nnose\nnotable\nnote\nnothing\nnotice\nnovel\nnow\nnuclear\nnumber\nnurse\nnut\noak\nobey\nobject\noblige\nobscure\nobserve\nobtain\nobvious\noccur\nocean\noctober\nodor\noff\noffer\noffice\noften\noil\nokay\nold\nolive\nolympic\nomit\nonce\none\nonion\nonline\nonly\nopen\nopera\nopinion\noppose\noption\norange\norbit\norchard\norder\nordinary\norgan\norient\noriginal\norphan\nostrich\nother\noutdoor\nouter\noutput\noutside\noval\noven\nover\nown\nowner\noxygen\noyster\nozone\npact\npaddle\npage\npair\npalace\npalm\npanda\npanel\npanic\npanther\npaper\nparade\nparent\npark\nparrot\nparty\npass\npatch\npath\npatient\npatrol\npattern\npause\npave\npayment\npeace\npeanut\npear\npeasant\npelican\npen\npenalty\npencil\npeople\npepper\nperfect\npermit\nperson\npet\nphone\nphoto\nphrase\nphysical\npiano\npicnic\npicture\npiece\npig\npigeon\npill\npilot\npink\npioneer\npipe\npistol\npitch\npizza\nplace\nplanet\nplastic\nplate\nplay\nplease\npledge\npluck\nplug\nplunge\npoem\npoet\npoint\npolar\npole\npolice\npond\npony\npool\npopular\nportion\nposition\npossible\npost\npotato\npottery\npoverty\npowder\npower\npractice\npraise\npredict\nprefer\nprepare\npresent\npretty\nprevent\nprice\npride\nprimary\nprint\npriority\nprison\nprivate\nprize\nproblem\nprocess\nproduce\nprofit\nprogram\nproject\npromote\nproof\nproperty\nprosper\nprotect\nproud\nprovide\npublic\npudding\npull\npulp\npulse\npumpkin\npunch\npupil\npuppy\npurchase\npurity\npurpose\npurse\npush\nput\npuzzle\npyramid\nquality\nquantum\nquarter\nquestion\nquick\nquit\nquiz\nquote\nrabbit\nraccoon\nrace\nrack\nradar\nradio\nrail\nrain\nraise\nrally\nramp\nranch\nrandom\nrange\nrapid\nrare\nrate\nrather\nraven\nraw\nrazor\nready\nreal\nreason\nrebel\nrebuild\nrecall\nreceive\nrecipe\nrecord\nrecycle\nreduce\nreflect\nreform\nrefuse\nregion\nregret\nregular\nreject\nrelax\nrelease\nrelief\nrely\nremain\nremember\nremind\nremove\nrender\nrenew\nrent\nreopen\nrepair\nrepeat\nreplace\nreport\nrequire\nrescue\nresemble\nresist\nresource\nresponse\nresult\nretire\nretreat\nreturn\nreunion\nreveal\nreview\nreward\nrhythm\nrib\nribbon\nrice\nrich\nride\nridge\nrifle\nright\nrigid\nring\nriot\nripple\nrisk\nritual\nrival\nriver\nroad\nroast\nrobot\nrobust\nrocket\nromance\nroof\nrookie\nroom\nrose\nrotate\nrough\nround\nroute\nroyal\nrubber\nrude\nrug\nrule\nrun\nrunway\nrural\nsad\nsaddle\nsadness\nsafe\nsail\nsalad\nsalmon\nsalon\nsalt\nsalute\nsame\nsample\nsand\nsatisfy\nsatoshi\nsauce\nsausage\nsave\nsay\nscale\nscan\nscare\nscatter\nscene\nscheme\nschool\nscience\nscissors\nscorpion\nscout\nscrap\nscreen\nscript\nscrub\nsea\nsearch\nseason\nseat\nsecond\nsecret\nsection\nsecurity\nseed\nseek\nsegment\nselect\nsell\nseminar\nsenior\nsense\nsentence\nseries\nservice\nsession\nsettle\nsetup\nseven\nshadow\nshaft\nshallow\nshare\nshed\nshell\nsheriff\nshield\nshift\nshine\nship\nshiver\nshock\nshoe\nshoot\nshop\nshort\nshoulder\nshove\nshrimp\nshrug\nshuffle\nshy\nsibling\nsick\nside\nsiege\nsight\nsign\nsilent\nsilk\nsilly\nsilver\nsimilar\nsimple\nsince\nsing\nsiren\nsister\nsituate\nsix\nsize\nskate\nsketch\nski\nskill\nskin\nskirt\nskull\nslab\nslam\nsleep\nslender\nslice\nslide\nslight\nslim\nslogan\nslot\nslow\nslush\nsmall\nsmart\nsmile\nsmoke\nsmooth\nsnack\nsnake\nsnap\nsniff\nsnow\nsoap\nsoccer\nsocial\nsock\nsoda\nsoft\nsolar\nsoldier\nsolid\nsolution\nsolve\nsomeone\nsong\nsoon\nsorry\nsort\nsoul\nsound\nsoup\nsource\nsouth\nspace\nspare\nspatial\nspawn\nspeak\nspecial\nspeed\nspell\nspend\nsphere\nspice\nspider\nspike\nspin\nspirit\nsplit\nspoil\nsponsor\nspoon\nsport\nspot\nspray\nspread\nspring\nspy\nsquare\nsqueeze\nsquirrel\nstable\nstadium\nstaff\nstage\nstairs\nstamp\nstand\nstart\nstate\nstay\nsteak\nsteel\nstem\nstep\nstereo\nstick\nstill\nsting\nstock\nstomach\nstone\nstool\nstory\nstove\nstrategy\nstreet\nstrike\nstrong\nstruggle\nstudent\nstuff\nstumble\nstyle\nsubject\nsubmit\nsubway\nsuccess\nsuch\nsudden\nsuffer\nsugar\nsuggest\nsuit\nsummer\nsun\nsunny\nsunset\nsuper\nsupply\nsupreme\nsure\nsurface\nsurge\nsurprise\nsurround\nsurvey\nsuspect\nsustain\nswallow\nswamp\nswap\nswarm\nswear\nsweet\nswift\nswim\nswing\nswitch\nsword\nsymbol\nsymptom\nsyrup\nsystem\ntable\ntackle\ntag\ntail\ntalent\ntalk\ntank\ntape\ntarget\ntask\ntaste\ntattoo\ntaxi\nteach\nteam\ntell\nten\ntenant\ntennis\ntent\nterm\ntest\ntext\nthank\nthat\ntheme\nthen\ntheory\nthere\nthey\nthing\nthis\nthought\nthree\nthrive\nthrow\nthumb\nthunder\nticket\ntide\ntiger\ntilt\ntimber\ntime\ntiny\ntip\ntired\ntissue\ntitle\ntoast\ntobacco\ntoday\ntoddler\ntoe\ntogether\ntoilet\ntoken\ntomato\ntomorrow\ntone\ntongue\ntonight\ntool\ntooth\ntop\ntopic\ntopple\ntorch\ntornado\ntortoise\ntoss\ntotal\ntourist\ntoward\ntower\ntown\ntoy\ntrack\ntrade\ntraffic\ntragic\ntrain\ntransfer\ntrap\ntrash\ntravel\ntray\ntreat\ntree\ntrend\ntrial\ntribe\ntrick\ntrigger\ntrim\ntrip\ntrophy\ntrouble\ntruck\ntrue\ntruly\ntrumpet\ntrust\ntruth\ntry\ntube\ntuition\ntumble\ntuna\ntunnel\nturkey\nturn\nturtle\ntwelve\ntwenty\ntwice\ntwin\ntwist\ntwo\ntype\ntypical\nugly\numbrella\nunable\nunaware\nuncle\nuncover\nunder\nundo\nunfair\nunfold\nunhappy\nuniform\nunique\nunit\nuniverse\nunknown\nunlock\nuntil\nunusual\nunveil\nupdate\nupgrade\nuphold\nupon\nupper\nupset\nurban\nurge\nusage\nuse\nused\nuseful\nuseless\nusual\nutility\nvacant\nvacuum\nvague\nvalid\nvalley\nvalve\nvan\nvanish\nvapor\nvarious\nvast\nvault\nvehicle\nvelvet\nvendor\nventure\nvenue\nverb\nverify\nversion\nvery\nvessel\nveteran\nviable\nvibrant\nvicious\nvictory\nvideo\nview\nvillage\nvintage\nviolin\nvirtual\nvirus\nvisa\nvisit\nvisual\nvital\nvivid\nvocal\nvoice\nvoid\nvolcano\nvolume\nvote\nvoyage\nwage\nwagon\nwait\nwalk\nwall\nwalnut\nwant\nwarfare\nwarm\nwarrior\nwash\nwasp\nwaste\nwater\nwave\nway\nwealth\nweapon\nwear\nweasel\nweather\nweb\nwedding\nweekend\nweird\nwelcome\nwest\nwet\nwhale\nwhat\nwheat\nwheel\nwhen\nwhere\nwhip\nwhisper\nwide\nwidth\nwife\nwild\nwill\nwin\nwindow\nwine\nwing\nwink\nwinner\nwinter\nwire\nwisdom\nwise\nwish\nwitness\nwolf\nwoman\nwonder\nwood\nwool\nword\nwork\nworld\nworry\nworth\nwrap\nwreck\nwrestle\nwrist\nwrite\nwrong\nyard\nyear\nyellow\nyou\nyoung\nyouth\nzebra\nzero\nzone\nzoo".split("\n");function number$3(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function bool$2(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)}function isBytes$5(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function bytes$3(e,...t){if(!isBytes$5(e))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function hash$3(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");number$3(e.outputLen),number$3(e.blockLen)}function exists$3(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output$3(e,t){bytes$3(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const assert$2={number:number$3,bool:bool$2,bytes:bytes$3,hash:hash$3,exists:exists$3,output:output$3},crypto$2="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;
11
+ function assertNumber(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function chain$1(...e){const t=(e,t)=>n=>e(t(n));return{encode:Array.from(e).reverse().reduce(((e,n)=>e?t(e,n.encode):n.encode),void 0),decode:e.reduce(((e,n)=>e?t(e,n.decode):n.decode),void 0)}}function alphabet$1(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map((t=>{if(assertNumber(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]}))},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map((t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}}function join$1(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function padding$1(e,t="="){if(assertNumber(e),"string"!=typeof t)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;n.length*e%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let r=n.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function normalize$1(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function convertRadix$1(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const o=[],s=Array.from(e);for(s.forEach((e=>{if(assertNumber(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)}));;){let e=0,i=!0;for(let o=r;o<s.length;o++){const a=s[o],l=t*e+a;if(!Number.isSafeInteger(l)||t*e/t!==e||l-a!=t*e)throw new Error("convertRadix: carry overflow");if(e=l%n,s[o]=Math.floor(l/n),!Number.isSafeInteger(s[o])||s[o]*n+e!==l)throw new Error("convertRadix: carry overflow");i&&(s[o]?i=!1:r=o)}if(o.push(e),i)break}for(let t=0;t<e.length-1&&0===e[t];t++)o.push(0);return o.reverse()}wrapConstructor$1((()=>new SHA224));const gcd$1=(e,t)=>t?gcd$1(t,e%t):e,radix2carry$1=(e,t)=>e+(t-gcd$1(e,t));function convertRadix2$1(e,t,n,r){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(radix2carry$1(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${radix2carry$1(t,n)}`);let o=0,s=0;const i=2**n-1,a=[];for(const r of e){if(assertNumber(r),r>=2**t)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(o=o<<t|r,s+t>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)a.push((o>>s-n&i)>>>0);o&=2**s-1}if(o=o<<n-s&i,!r&&s>=t)throw new Error("Excess padding");if(!r&&o)throw new Error(`Non-zero padding: ${o}`);return r&&s>0&&a.push(o>>>0),a}function radix$1(e){return assertNumber(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return convertRadix$1(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(convertRadix$1(t,e,256))}}}function radix2$1(e,t=!1){if(assertNumber(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(radix2carry$1(8,e)>32||radix2carry$1(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return convertRadix2$1(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(convertRadix2$1(n,e,8,t))}}}function unsafeWrapper$1(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}const base16=chain$1(radix2$1(4),alphabet$1("0123456789ABCDEF"),join$1("")),base32=chain$1(radix2$1(5),alphabet$1("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),padding$1(5),join$1(""));chain$1(radix2$1(5),alphabet$1("0123456789ABCDEFGHIJKLMNOPQRSTUV"),padding$1(5),join$1("")),chain$1(radix2$1(5),alphabet$1("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),join$1(""),normalize$1((e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))));const base64$1=chain$1(radix2$1(6),alphabet$1("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),padding$1(6),join$1("")),base64url=chain$1(radix2$1(6),alphabet$1("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),padding$1(6),join$1("")),genBase58$1=e=>chain$1(radix$1(58),alphabet$1(e),join$1("")),base58$1=genBase58$1("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");genBase58$1("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),genBase58$1("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const XMR_BLOCK_LEN=[0,2,3,5,6,7,9,10,11],base58xmr={encode(e){let t="";for(let n=0;n<e.length;n+=8){const r=e.subarray(n,n+8);t+=base58$1.encode(r).padStart(XMR_BLOCK_LEN[r.length],"1")}return t},decode(e){let t=[];for(let n=0;n<e.length;n+=11){const r=e.slice(n,n+11),o=XMR_BLOCK_LEN.indexOf(r.length),s=base58$1.decode(r);for(let e=0;e<s.length-o;e++)if(0!==s[e])throw new Error("base58xmr: wrong padding");t=t.concat(Array.from(s.slice(s.length-o)))}return Uint8Array.from(t)}},BECH_ALPHABET$1=chain$1(alphabet$1("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),join$1("")),POLYMOD_GENERATORS$1=[996825010,642813549,513874426,1027748829,705979059];function bech32Polymod$1(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e<POLYMOD_GENERATORS$1.length;e++)1==(t>>e&1)&&(n^=POLYMOD_GENERATORS$1[e]);return n}function bechChecksum$1(e,t,n=1){const r=e.length;let o=1;for(let t=0;t<r;t++){const n=e.charCodeAt(t);if(n<33||n>126)throw new Error(`Invalid prefix (${e})`);o=bech32Polymod$1(o)^n>>5}o=bech32Polymod$1(o);for(let t=0;t<r;t++)o=bech32Polymod$1(o)^31&e.charCodeAt(t);for(let e of t)o=bech32Polymod$1(o)^e;for(let e=0;e<6;e++)o=bech32Polymod$1(o);return o^=n,BECH_ALPHABET$1.encode(convertRadix2$1([o%2**30],30,5,!1))}function genBech32$1(e){const t="bech32"===e?1:734539939,n=radix2$1(5),r=n.decode,o=n.encode,s=unsafeWrapper$1(r);function i(e,n=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==n&&e.length>n)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=(e=r).lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const s=e.slice(0,o),i=e.slice(o+1);if(i.length<6)throw new Error("Data must be at least 6 characters long");const a=BECH_ALPHABET$1.decode(i).slice(0,-6),l=bechChecksum$1(s,a,t);if(!i.endsWith(l))throw new Error(`Invalid checksum in ${e}: expected "${l}"`);return{prefix:s,words:a}}return{encode:function(e,n,r=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const o=e.length+7+n.length;if(!1!==r&&o>r)throw new TypeError(`Length ${o} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${BECH_ALPHABET$1.encode(n)}${bechChecksum$1(e,n,t)}`},decode:i,decodeToBytes:function(e){const{prefix:t,words:n}=i(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:unsafeWrapper$1(i),fromWords:r,fromWordsUnsafe:s,toWords:o}}const bech32$2=genBech32$1("bech32");genBech32$1("bech32m");const utf8$1={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},hex$1=chain$1(radix2$1(4),alphabet$1("0123456789abcdef"),join$1(""),normalize$1((e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}))),CODERS={utf8:utf8$1,hex:hex$1,base16:base16,base32:base32,base64:base64$1,base64url:base64url,base58:base58$1,base58xmr:base58xmr};Object.keys(CODERS).join(", ");const wordlist="abandon\nability\nable\nabout\nabove\nabsent\nabsorb\nabstract\nabsurd\nabuse\naccess\naccident\naccount\naccuse\nachieve\nacid\nacoustic\nacquire\nacross\nact\naction\nactor\nactress\nactual\nadapt\nadd\naddict\naddress\nadjust\nadmit\nadult\nadvance\nadvice\naerobic\naffair\nafford\nafraid\nagain\nage\nagent\nagree\nahead\naim\nair\nairport\naisle\nalarm\nalbum\nalcohol\nalert\nalien\nall\nalley\nallow\nalmost\nalone\nalpha\nalready\nalso\nalter\nalways\namateur\namazing\namong\namount\namused\nanalyst\nanchor\nancient\nanger\nangle\nangry\nanimal\nankle\nannounce\nannual\nanother\nanswer\nantenna\nantique\nanxiety\nany\napart\napology\nappear\napple\napprove\napril\narch\narctic\narea\narena\nargue\narm\narmed\narmor\narmy\naround\narrange\narrest\narrive\narrow\nart\nartefact\nartist\nartwork\nask\naspect\nassault\nasset\nassist\nassume\nasthma\nathlete\natom\nattack\nattend\nattitude\nattract\nauction\naudit\naugust\naunt\nauthor\nauto\nautumn\naverage\navocado\navoid\nawake\naware\naway\nawesome\nawful\nawkward\naxis\nbaby\nbachelor\nbacon\nbadge\nbag\nbalance\nbalcony\nball\nbamboo\nbanana\nbanner\nbar\nbarely\nbargain\nbarrel\nbase\nbasic\nbasket\nbattle\nbeach\nbean\nbeauty\nbecause\nbecome\nbeef\nbefore\nbegin\nbehave\nbehind\nbelieve\nbelow\nbelt\nbench\nbenefit\nbest\nbetray\nbetter\nbetween\nbeyond\nbicycle\nbid\nbike\nbind\nbiology\nbird\nbirth\nbitter\nblack\nblade\nblame\nblanket\nblast\nbleak\nbless\nblind\nblood\nblossom\nblouse\nblue\nblur\nblush\nboard\nboat\nbody\nboil\nbomb\nbone\nbonus\nbook\nboost\nborder\nboring\nborrow\nboss\nbottom\nbounce\nbox\nboy\nbracket\nbrain\nbrand\nbrass\nbrave\nbread\nbreeze\nbrick\nbridge\nbrief\nbright\nbring\nbrisk\nbroccoli\nbroken\nbronze\nbroom\nbrother\nbrown\nbrush\nbubble\nbuddy\nbudget\nbuffalo\nbuild\nbulb\nbulk\nbullet\nbundle\nbunker\nburden\nburger\nburst\nbus\nbusiness\nbusy\nbutter\nbuyer\nbuzz\ncabbage\ncabin\ncable\ncactus\ncage\ncake\ncall\ncalm\ncamera\ncamp\ncan\ncanal\ncancel\ncandy\ncannon\ncanoe\ncanvas\ncanyon\ncapable\ncapital\ncaptain\ncar\ncarbon\ncard\ncargo\ncarpet\ncarry\ncart\ncase\ncash\ncasino\ncastle\ncasual\ncat\ncatalog\ncatch\ncategory\ncattle\ncaught\ncause\ncaution\ncave\nceiling\ncelery\ncement\ncensus\ncentury\ncereal\ncertain\nchair\nchalk\nchampion\nchange\nchaos\nchapter\ncharge\nchase\nchat\ncheap\ncheck\ncheese\nchef\ncherry\nchest\nchicken\nchief\nchild\nchimney\nchoice\nchoose\nchronic\nchuckle\nchunk\nchurn\ncigar\ncinnamon\ncircle\ncitizen\ncity\ncivil\nclaim\nclap\nclarify\nclaw\nclay\nclean\nclerk\nclever\nclick\nclient\ncliff\nclimb\nclinic\nclip\nclock\nclog\nclose\ncloth\ncloud\nclown\nclub\nclump\ncluster\nclutch\ncoach\ncoast\ncoconut\ncode\ncoffee\ncoil\ncoin\ncollect\ncolor\ncolumn\ncombine\ncome\ncomfort\ncomic\ncommon\ncompany\nconcert\nconduct\nconfirm\ncongress\nconnect\nconsider\ncontrol\nconvince\ncook\ncool\ncopper\ncopy\ncoral\ncore\ncorn\ncorrect\ncost\ncotton\ncouch\ncountry\ncouple\ncourse\ncousin\ncover\ncoyote\ncrack\ncradle\ncraft\ncram\ncrane\ncrash\ncrater\ncrawl\ncrazy\ncream\ncredit\ncreek\ncrew\ncricket\ncrime\ncrisp\ncritic\ncrop\ncross\ncrouch\ncrowd\ncrucial\ncruel\ncruise\ncrumble\ncrunch\ncrush\ncry\ncrystal\ncube\nculture\ncup\ncupboard\ncurious\ncurrent\ncurtain\ncurve\ncushion\ncustom\ncute\ncycle\ndad\ndamage\ndamp\ndance\ndanger\ndaring\ndash\ndaughter\ndawn\nday\ndeal\ndebate\ndebris\ndecade\ndecember\ndecide\ndecline\ndecorate\ndecrease\ndeer\ndefense\ndefine\ndefy\ndegree\ndelay\ndeliver\ndemand\ndemise\ndenial\ndentist\ndeny\ndepart\ndepend\ndeposit\ndepth\ndeputy\nderive\ndescribe\ndesert\ndesign\ndesk\ndespair\ndestroy\ndetail\ndetect\ndevelop\ndevice\ndevote\ndiagram\ndial\ndiamond\ndiary\ndice\ndiesel\ndiet\ndiffer\ndigital\ndignity\ndilemma\ndinner\ndinosaur\ndirect\ndirt\ndisagree\ndiscover\ndisease\ndish\ndismiss\ndisorder\ndisplay\ndistance\ndivert\ndivide\ndivorce\ndizzy\ndoctor\ndocument\ndog\ndoll\ndolphin\ndomain\ndonate\ndonkey\ndonor\ndoor\ndose\ndouble\ndove\ndraft\ndragon\ndrama\ndrastic\ndraw\ndream\ndress\ndrift\ndrill\ndrink\ndrip\ndrive\ndrop\ndrum\ndry\nduck\ndumb\ndune\nduring\ndust\ndutch\nduty\ndwarf\ndynamic\neager\neagle\nearly\nearn\nearth\neasily\neast\neasy\necho\necology\neconomy\nedge\nedit\neducate\neffort\negg\neight\neither\nelbow\nelder\nelectric\nelegant\nelement\nelephant\nelevator\nelite\nelse\nembark\nembody\nembrace\nemerge\nemotion\nemploy\nempower\nempty\nenable\nenact\nend\nendless\nendorse\nenemy\nenergy\nenforce\nengage\nengine\nenhance\nenjoy\nenlist\nenough\nenrich\nenroll\nensure\nenter\nentire\nentry\nenvelope\nepisode\nequal\nequip\nera\nerase\nerode\nerosion\nerror\nerupt\nescape\nessay\nessence\nestate\neternal\nethics\nevidence\nevil\nevoke\nevolve\nexact\nexample\nexcess\nexchange\nexcite\nexclude\nexcuse\nexecute\nexercise\nexhaust\nexhibit\nexile\nexist\nexit\nexotic\nexpand\nexpect\nexpire\nexplain\nexpose\nexpress\nextend\nextra\neye\neyebrow\nfabric\nface\nfaculty\nfade\nfaint\nfaith\nfall\nfalse\nfame\nfamily\nfamous\nfan\nfancy\nfantasy\nfarm\nfashion\nfat\nfatal\nfather\nfatigue\nfault\nfavorite\nfeature\nfebruary\nfederal\nfee\nfeed\nfeel\nfemale\nfence\nfestival\nfetch\nfever\nfew\nfiber\nfiction\nfield\nfigure\nfile\nfilm\nfilter\nfinal\nfind\nfine\nfinger\nfinish\nfire\nfirm\nfirst\nfiscal\nfish\nfit\nfitness\nfix\nflag\nflame\nflash\nflat\nflavor\nflee\nflight\nflip\nfloat\nflock\nfloor\nflower\nfluid\nflush\nfly\nfoam\nfocus\nfog\nfoil\nfold\nfollow\nfood\nfoot\nforce\nforest\nforget\nfork\nfortune\nforum\nforward\nfossil\nfoster\nfound\nfox\nfragile\nframe\nfrequent\nfresh\nfriend\nfringe\nfrog\nfront\nfrost\nfrown\nfrozen\nfruit\nfuel\nfun\nfunny\nfurnace\nfury\nfuture\ngadget\ngain\ngalaxy\ngallery\ngame\ngap\ngarage\ngarbage\ngarden\ngarlic\ngarment\ngas\ngasp\ngate\ngather\ngauge\ngaze\ngeneral\ngenius\ngenre\ngentle\ngenuine\ngesture\nghost\ngiant\ngift\ngiggle\nginger\ngiraffe\ngirl\ngive\nglad\nglance\nglare\nglass\nglide\nglimpse\nglobe\ngloom\nglory\nglove\nglow\nglue\ngoat\ngoddess\ngold\ngood\ngoose\ngorilla\ngospel\ngossip\ngovern\ngown\ngrab\ngrace\ngrain\ngrant\ngrape\ngrass\ngravity\ngreat\ngreen\ngrid\ngrief\ngrit\ngrocery\ngroup\ngrow\ngrunt\nguard\nguess\nguide\nguilt\nguitar\ngun\ngym\nhabit\nhair\nhalf\nhammer\nhamster\nhand\nhappy\nharbor\nhard\nharsh\nharvest\nhat\nhave\nhawk\nhazard\nhead\nhealth\nheart\nheavy\nhedgehog\nheight\nhello\nhelmet\nhelp\nhen\nhero\nhidden\nhigh\nhill\nhint\nhip\nhire\nhistory\nhobby\nhockey\nhold\nhole\nholiday\nhollow\nhome\nhoney\nhood\nhope\nhorn\nhorror\nhorse\nhospital\nhost\nhotel\nhour\nhover\nhub\nhuge\nhuman\nhumble\nhumor\nhundred\nhungry\nhunt\nhurdle\nhurry\nhurt\nhusband\nhybrid\nice\nicon\nidea\nidentify\nidle\nignore\nill\nillegal\nillness\nimage\nimitate\nimmense\nimmune\nimpact\nimpose\nimprove\nimpulse\ninch\ninclude\nincome\nincrease\nindex\nindicate\nindoor\nindustry\ninfant\ninflict\ninform\ninhale\ninherit\ninitial\ninject\ninjury\ninmate\ninner\ninnocent\ninput\ninquiry\ninsane\ninsect\ninside\ninspire\ninstall\nintact\ninterest\ninto\ninvest\ninvite\ninvolve\niron\nisland\nisolate\nissue\nitem\nivory\njacket\njaguar\njar\njazz\njealous\njeans\njelly\njewel\njob\njoin\njoke\njourney\njoy\njudge\njuice\njump\njungle\njunior\njunk\njust\nkangaroo\nkeen\nkeep\nketchup\nkey\nkick\nkid\nkidney\nkind\nkingdom\nkiss\nkit\nkitchen\nkite\nkitten\nkiwi\nknee\nknife\nknock\nknow\nlab\nlabel\nlabor\nladder\nlady\nlake\nlamp\nlanguage\nlaptop\nlarge\nlater\nlatin\nlaugh\nlaundry\nlava\nlaw\nlawn\nlawsuit\nlayer\nlazy\nleader\nleaf\nlearn\nleave\nlecture\nleft\nleg\nlegal\nlegend\nleisure\nlemon\nlend\nlength\nlens\nleopard\nlesson\nletter\nlevel\nliar\nliberty\nlibrary\nlicense\nlife\nlift\nlight\nlike\nlimb\nlimit\nlink\nlion\nliquid\nlist\nlittle\nlive\nlizard\nload\nloan\nlobster\nlocal\nlock\nlogic\nlonely\nlong\nloop\nlottery\nloud\nlounge\nlove\nloyal\nlucky\nluggage\nlumber\nlunar\nlunch\nluxury\nlyrics\nmachine\nmad\nmagic\nmagnet\nmaid\nmail\nmain\nmajor\nmake\nmammal\nman\nmanage\nmandate\nmango\nmansion\nmanual\nmaple\nmarble\nmarch\nmargin\nmarine\nmarket\nmarriage\nmask\nmass\nmaster\nmatch\nmaterial\nmath\nmatrix\nmatter\nmaximum\nmaze\nmeadow\nmean\nmeasure\nmeat\nmechanic\nmedal\nmedia\nmelody\nmelt\nmember\nmemory\nmention\nmenu\nmercy\nmerge\nmerit\nmerry\nmesh\nmessage\nmetal\nmethod\nmiddle\nmidnight\nmilk\nmillion\nmimic\nmind\nminimum\nminor\nminute\nmiracle\nmirror\nmisery\nmiss\nmistake\nmix\nmixed\nmixture\nmobile\nmodel\nmodify\nmom\nmoment\nmonitor\nmonkey\nmonster\nmonth\nmoon\nmoral\nmore\nmorning\nmosquito\nmother\nmotion\nmotor\nmountain\nmouse\nmove\nmovie\nmuch\nmuffin\nmule\nmultiply\nmuscle\nmuseum\nmushroom\nmusic\nmust\nmutual\nmyself\nmystery\nmyth\nnaive\nname\nnapkin\nnarrow\nnasty\nnation\nnature\nnear\nneck\nneed\nnegative\nneglect\nneither\nnephew\nnerve\nnest\nnet\nnetwork\nneutral\nnever\nnews\nnext\nnice\nnight\nnoble\nnoise\nnominee\nnoodle\nnormal\nnorth\nnose\nnotable\nnote\nnothing\nnotice\nnovel\nnow\nnuclear\nnumber\nnurse\nnut\noak\nobey\nobject\noblige\nobscure\nobserve\nobtain\nobvious\noccur\nocean\noctober\nodor\noff\noffer\noffice\noften\noil\nokay\nold\nolive\nolympic\nomit\nonce\none\nonion\nonline\nonly\nopen\nopera\nopinion\noppose\noption\norange\norbit\norchard\norder\nordinary\norgan\norient\noriginal\norphan\nostrich\nother\noutdoor\nouter\noutput\noutside\noval\noven\nover\nown\nowner\noxygen\noyster\nozone\npact\npaddle\npage\npair\npalace\npalm\npanda\npanel\npanic\npanther\npaper\nparade\nparent\npark\nparrot\nparty\npass\npatch\npath\npatient\npatrol\npattern\npause\npave\npayment\npeace\npeanut\npear\npeasant\npelican\npen\npenalty\npencil\npeople\npepper\nperfect\npermit\nperson\npet\nphone\nphoto\nphrase\nphysical\npiano\npicnic\npicture\npiece\npig\npigeon\npill\npilot\npink\npioneer\npipe\npistol\npitch\npizza\nplace\nplanet\nplastic\nplate\nplay\nplease\npledge\npluck\nplug\nplunge\npoem\npoet\npoint\npolar\npole\npolice\npond\npony\npool\npopular\nportion\nposition\npossible\npost\npotato\npottery\npoverty\npowder\npower\npractice\npraise\npredict\nprefer\nprepare\npresent\npretty\nprevent\nprice\npride\nprimary\nprint\npriority\nprison\nprivate\nprize\nproblem\nprocess\nproduce\nprofit\nprogram\nproject\npromote\nproof\nproperty\nprosper\nprotect\nproud\nprovide\npublic\npudding\npull\npulp\npulse\npumpkin\npunch\npupil\npuppy\npurchase\npurity\npurpose\npurse\npush\nput\npuzzle\npyramid\nquality\nquantum\nquarter\nquestion\nquick\nquit\nquiz\nquote\nrabbit\nraccoon\nrace\nrack\nradar\nradio\nrail\nrain\nraise\nrally\nramp\nranch\nrandom\nrange\nrapid\nrare\nrate\nrather\nraven\nraw\nrazor\nready\nreal\nreason\nrebel\nrebuild\nrecall\nreceive\nrecipe\nrecord\nrecycle\nreduce\nreflect\nreform\nrefuse\nregion\nregret\nregular\nreject\nrelax\nrelease\nrelief\nrely\nremain\nremember\nremind\nremove\nrender\nrenew\nrent\nreopen\nrepair\nrepeat\nreplace\nreport\nrequire\nrescue\nresemble\nresist\nresource\nresponse\nresult\nretire\nretreat\nreturn\nreunion\nreveal\nreview\nreward\nrhythm\nrib\nribbon\nrice\nrich\nride\nridge\nrifle\nright\nrigid\nring\nriot\nripple\nrisk\nritual\nrival\nriver\nroad\nroast\nrobot\nrobust\nrocket\nromance\nroof\nrookie\nroom\nrose\nrotate\nrough\nround\nroute\nroyal\nrubber\nrude\nrug\nrule\nrun\nrunway\nrural\nsad\nsaddle\nsadness\nsafe\nsail\nsalad\nsalmon\nsalon\nsalt\nsalute\nsame\nsample\nsand\nsatisfy\nsatoshi\nsauce\nsausage\nsave\nsay\nscale\nscan\nscare\nscatter\nscene\nscheme\nschool\nscience\nscissors\nscorpion\nscout\nscrap\nscreen\nscript\nscrub\nsea\nsearch\nseason\nseat\nsecond\nsecret\nsection\nsecurity\nseed\nseek\nsegment\nselect\nsell\nseminar\nsenior\nsense\nsentence\nseries\nservice\nsession\nsettle\nsetup\nseven\nshadow\nshaft\nshallow\nshare\nshed\nshell\nsheriff\nshield\nshift\nshine\nship\nshiver\nshock\nshoe\nshoot\nshop\nshort\nshoulder\nshove\nshrimp\nshrug\nshuffle\nshy\nsibling\nsick\nside\nsiege\nsight\nsign\nsilent\nsilk\nsilly\nsilver\nsimilar\nsimple\nsince\nsing\nsiren\nsister\nsituate\nsix\nsize\nskate\nsketch\nski\nskill\nskin\nskirt\nskull\nslab\nslam\nsleep\nslender\nslice\nslide\nslight\nslim\nslogan\nslot\nslow\nslush\nsmall\nsmart\nsmile\nsmoke\nsmooth\nsnack\nsnake\nsnap\nsniff\nsnow\nsoap\nsoccer\nsocial\nsock\nsoda\nsoft\nsolar\nsoldier\nsolid\nsolution\nsolve\nsomeone\nsong\nsoon\nsorry\nsort\nsoul\nsound\nsoup\nsource\nsouth\nspace\nspare\nspatial\nspawn\nspeak\nspecial\nspeed\nspell\nspend\nsphere\nspice\nspider\nspike\nspin\nspirit\nsplit\nspoil\nsponsor\nspoon\nsport\nspot\nspray\nspread\nspring\nspy\nsquare\nsqueeze\nsquirrel\nstable\nstadium\nstaff\nstage\nstairs\nstamp\nstand\nstart\nstate\nstay\nsteak\nsteel\nstem\nstep\nstereo\nstick\nstill\nsting\nstock\nstomach\nstone\nstool\nstory\nstove\nstrategy\nstreet\nstrike\nstrong\nstruggle\nstudent\nstuff\nstumble\nstyle\nsubject\nsubmit\nsubway\nsuccess\nsuch\nsudden\nsuffer\nsugar\nsuggest\nsuit\nsummer\nsun\nsunny\nsunset\nsuper\nsupply\nsupreme\nsure\nsurface\nsurge\nsurprise\nsurround\nsurvey\nsuspect\nsustain\nswallow\nswamp\nswap\nswarm\nswear\nsweet\nswift\nswim\nswing\nswitch\nsword\nsymbol\nsymptom\nsyrup\nsystem\ntable\ntackle\ntag\ntail\ntalent\ntalk\ntank\ntape\ntarget\ntask\ntaste\ntattoo\ntaxi\nteach\nteam\ntell\nten\ntenant\ntennis\ntent\nterm\ntest\ntext\nthank\nthat\ntheme\nthen\ntheory\nthere\nthey\nthing\nthis\nthought\nthree\nthrive\nthrow\nthumb\nthunder\nticket\ntide\ntiger\ntilt\ntimber\ntime\ntiny\ntip\ntired\ntissue\ntitle\ntoast\ntobacco\ntoday\ntoddler\ntoe\ntogether\ntoilet\ntoken\ntomato\ntomorrow\ntone\ntongue\ntonight\ntool\ntooth\ntop\ntopic\ntopple\ntorch\ntornado\ntortoise\ntoss\ntotal\ntourist\ntoward\ntower\ntown\ntoy\ntrack\ntrade\ntraffic\ntragic\ntrain\ntransfer\ntrap\ntrash\ntravel\ntray\ntreat\ntree\ntrend\ntrial\ntribe\ntrick\ntrigger\ntrim\ntrip\ntrophy\ntrouble\ntruck\ntrue\ntruly\ntrumpet\ntrust\ntruth\ntry\ntube\ntuition\ntumble\ntuna\ntunnel\nturkey\nturn\nturtle\ntwelve\ntwenty\ntwice\ntwin\ntwist\ntwo\ntype\ntypical\nugly\numbrella\nunable\nunaware\nuncle\nuncover\nunder\nundo\nunfair\nunfold\nunhappy\nuniform\nunique\nunit\nuniverse\nunknown\nunlock\nuntil\nunusual\nunveil\nupdate\nupgrade\nuphold\nupon\nupper\nupset\nurban\nurge\nusage\nuse\nused\nuseful\nuseless\nusual\nutility\nvacant\nvacuum\nvague\nvalid\nvalley\nvalve\nvan\nvanish\nvapor\nvarious\nvast\nvault\nvehicle\nvelvet\nvendor\nventure\nvenue\nverb\nverify\nversion\nvery\nvessel\nveteran\nviable\nvibrant\nvicious\nvictory\nvideo\nview\nvillage\nvintage\nviolin\nvirtual\nvirus\nvisa\nvisit\nvisual\nvital\nvivid\nvocal\nvoice\nvoid\nvolcano\nvolume\nvote\nvoyage\nwage\nwagon\nwait\nwalk\nwall\nwalnut\nwant\nwarfare\nwarm\nwarrior\nwash\nwasp\nwaste\nwater\nwave\nway\nwealth\nweapon\nwear\nweasel\nweather\nweb\nwedding\nweekend\nweird\nwelcome\nwest\nwet\nwhale\nwhat\nwheat\nwheel\nwhen\nwhere\nwhip\nwhisper\nwide\nwidth\nwife\nwild\nwill\nwin\nwindow\nwine\nwing\nwink\nwinner\nwinter\nwire\nwisdom\nwise\nwish\nwitness\nwolf\nwoman\nwonder\nwood\nwool\nword\nwork\nworld\nworry\nworth\nwrap\nwreck\nwrestle\nwrist\nwrite\nwrong\nyard\nyear\nyellow\nyou\nyoung\nyouth\nzebra\nzero\nzone\nzoo".split("\n");function number$1(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function bool$1(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)}function isBytes$2(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function bytes$1(e,...t){if(!isBytes$2(e))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function hash$1(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");number$1(e.outputLen),number$1(e.blockLen)}function exists$1(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output$1(e,t){bytes$1(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const assert$1={number:number$1,bool:bool$1,bytes:bytes$1,hash:hash$1,exists:exists$1,output:output$1},crypto$1="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;
32
12
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
33
- function isBytes$4(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}const createView$2=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),rotr$2=(e,t)=>e<<32-t|e>>>t,isLE$3=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!isLE$3)throw new Error("Non little-endian hardware is not supported");function utf8ToBytes$4(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function toBytes$3(e){if("string"==typeof e&&(e=utf8ToBytes$4(e)),!isBytes$4(e))throw new Error("expected Uint8Array, got "+typeof e);return e}let Hash$2=class{clone(){return this._cloneInto()}};const toStr={}.toString;function checkOpts$1(e,t){if(void 0!==t&&"[object Object]"!==toStr.call(t))throw new Error("Options should be object or undefined");return Object.assign(e,t)}function wrapConstructor$2(e){const t=t=>e().update(toBytes$3(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function randomBytes$1(e=32){if(crypto$2&&"function"==typeof crypto$2.getRandomValues)return crypto$2.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}let HMAC$2=class extends Hash$2{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,hash$3(e);const n=toBytes$3(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return exists$3(this),this.iHash.update(e),this}digestInto(e){exists$3(this),bytes$3(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:s,outputLen:o}=this;return e.finished=r,e.destroyed=i,e.blockLen=s,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const hmac$2=(e,t,n)=>new HMAC$2(e,t).update(n).digest();function pbkdf2Init(e,t,n,r){hash$3(e);const i=checkOpts$1({dkLen:32,asyncTick:10},r),{c:s,dkLen:o,asyncTick:a}=i;if(number$3(s),number$3(o),number$3(a),s<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const c=toBytes$3(t),l=toBytes$3(n),h=new Uint8Array(o),d=hmac$2.create(e,c),u=d._cloneInto().update(l);return{c:s,dkLen:o,asyncTick:a,DK:h,PRF:d,PRFSalt:u}}function pbkdf2Output(e,t,n,r,i){return e.destroy(),t.destroy(),r&&r.destroy(),i.fill(0),n}function pbkdf2(e,t,n,r){const{c:i,dkLen:s,DK:o,PRF:a,PRFSalt:c}=pbkdf2Init(e,t,n,r);let l;const h=new Uint8Array(4),d=createView$2(h),u=new Uint8Array(a.outputLen);for(let e=1,t=0;t<s;e++,t+=a.outputLen){const n=o.subarray(t,t+a.outputLen);d.setInt32(0,e,!1),(l=c._cloneInto(l)).update(h).digestInto(u),n.set(u.subarray(0,n.length));for(let e=1;e<i;e++){a._cloneInto(l).update(u).digestInto(u);for(let e=0;e<n.length;e++)n[e]^=u[e]}}return pbkdf2Output(a,c,o,l,u)}function setBigUint64$2(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,a,r)}hmac$2.create=(e,t)=>new HMAC$2(e,t);let SHA2$2=class extends Hash$2{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=createView$2(this.buffer)}update(e){exists$3(this);const{view:t,buffer:n,blockLen:r}=this,i=(e=toBytes$3(e)).length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);if(o===r){const t=createView$2(e);for(;r<=i-s;s+=r)this.process(t,s);continue}n.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){exists$3(this),output$3(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>r-s&&(this.process(n,0),s=0);for(let e=s;e<r;e++)t[e]=0;setBigUint64$2(n,r-8,BigInt(8*this.length),i),this.process(n,0);const o=createView$2(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:i,destroyed:s,pos:o}=this;return e.length=r,e.pos=o,e.finished=i,e.destroyed=s,r%t&&e.buffer.set(n),e}};const Chi$2=(e,t,n)=>e&t^~e&n,Maj$2=(e,t,n)=>e&t^e&n^t&n,SHA256_K$2=new Uint32Array([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]),IV$2=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W$2=new Uint32Array(64);let SHA256$2=class extends SHA2$2{constructor(){super(64,32,8,!1),this.A=0|IV$2[0],this.B=0|IV$2[1],this.C=0|IV$2[2],this.D=0|IV$2[3],this.E=0|IV$2[4],this.F=0|IV$2[5],this.G=0|IV$2[6],this.H=0|IV$2[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:s,G:o,H:a}=this;return[e,t,n,r,i,s,o,a]}set(e,t,n,r,i,s,o,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)SHA256_W$2[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=SHA256_W$2[e-15],n=SHA256_W$2[e-2],r=rotr$2(t,7)^rotr$2(t,18)^t>>>3,i=rotr$2(n,17)^rotr$2(n,19)^n>>>10;SHA256_W$2[e]=i+SHA256_W$2[e-7]+r+SHA256_W$2[e-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(rotr$2(o,6)^rotr$2(o,11)^rotr$2(o,25))+Chi$2(o,a,c)+SHA256_K$2[e]+SHA256_W$2[e]|0,h=(rotr$2(n,2)^rotr$2(n,13)^rotr$2(n,22))+Maj$2(n,r,i)|0;l=c,c=a,a=o,o=s+t|0,s=i,i=r,r=n,n=t+h|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,s,o,a,c,l)}roundClean(){SHA256_W$2.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const sha256$2=wrapConstructor$2(()=>new SHA256$2),U32_MASK64$1=BigInt(2**32-1),_32n$1=BigInt(32);function fromBig$1(e,t=!1){return t?{h:Number(e&U32_MASK64$1),l:Number(e>>_32n$1&U32_MASK64$1)}:{h:0|Number(e>>_32n$1&U32_MASK64$1),l:0|Number(e&U32_MASK64$1)}}function split$1(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:s,l:o}=fromBig$1(e[i],t);[n[i],r[i]]=[s,o]}return[n,r]}const toBig$1=(e,t)=>BigInt(e>>>0)<<_32n$1|BigInt(t>>>0),shrSH$1=(e,t,n)=>e>>>n,shrSL$1=(e,t,n)=>e<<32-n|t>>>n,rotrSH$1=(e,t,n)=>e>>>n|t<<32-n,rotrSL$1=(e,t,n)=>e<<32-n|t>>>n,rotrBH$1=(e,t,n)=>e<<64-n|t>>>n-32,rotrBL$1=(e,t,n)=>e>>>n-32|t<<64-n,rotr32H$1=(e,t)=>t,rotr32L$1=(e,t)=>e,rotlSH$1=(e,t,n)=>e<<n|t>>>32-n,rotlSL$1=(e,t,n)=>t<<n|e>>>32-n,rotlBH$1=(e,t,n)=>t<<n-32|e>>>64-n,rotlBL$1=(e,t,n)=>e<<n-32|t>>>64-n;function add$1(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:0|i}}const add3L$1=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H$1=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L$1=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H$1=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,add5L$1=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),add5H$1=(e,t,n,r,i,s)=>t+n+r+i+s+(e/2**32|0)|0,u64$1={fromBig:fromBig$1,split:split$1,toBig:toBig$1,shrSH:shrSH$1,shrSL:shrSL$1,rotrSH:rotrSH$1,rotrSL:rotrSL$1,rotrBH:rotrBH$1,rotrBL:rotrBL$1,rotr32H:rotr32H$1,rotr32L:rotr32L$1,rotlSH:rotlSH$1,rotlSL:rotlSL$1,rotlBH:rotlBH$1,rotlBL:rotlBL$1,add:add$1,add3L:add3L$1,add3H:add3H$1,add4L:add4L$1,add4H:add4H$1,add5H:add5H$1,add5L:add5L$1},[SHA512_Kh$1,SHA512_Kl$1]=(()=>u64$1.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))))(),SHA512_W_H$1=new Uint32Array(80),SHA512_W_L$1=new Uint32Array(80);let SHA512$1=class extends SHA2$2{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:s,Dh:o,Dl:a,Eh:c,El:l,Fh:h,Fl:d,Gh:u,Gl:f,Hh:p,Hl:g}=this;return[e,t,n,r,i,s,o,a,c,l,h,d,u,f,p,g]}set(e,t,n,r,i,s,o,a,c,l,h,d,u,f,p,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|s,this.Dh=0|o,this.Dl=0|a,this.Eh=0|c,this.El=0|l,this.Fh=0|h,this.Fl=0|d,this.Gh=0|u,this.Gl=0|f,this.Hh=0|p,this.Hl=0|g}process(e,t){for(let n=0;n<16;n++,t+=4)SHA512_W_H$1[n]=e.getUint32(t),SHA512_W_L$1[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|SHA512_W_H$1[e-15],n=0|SHA512_W_L$1[e-15],r=u64$1.rotrSH(t,n,1)^u64$1.rotrSH(t,n,8)^u64$1.shrSH(t,n,7),i=u64$1.rotrSL(t,n,1)^u64$1.rotrSL(t,n,8)^u64$1.shrSL(t,n,7),s=0|SHA512_W_H$1[e-2],o=0|SHA512_W_L$1[e-2],a=u64$1.rotrSH(s,o,19)^u64$1.rotrBH(s,o,61)^u64$1.shrSH(s,o,6),c=u64$1.rotrSL(s,o,19)^u64$1.rotrBL(s,o,61)^u64$1.shrSL(s,o,6),l=u64$1.add4L(i,c,SHA512_W_L$1[e-7],SHA512_W_L$1[e-16]),h=u64$1.add4H(l,r,a,SHA512_W_H$1[e-7],SHA512_W_H$1[e-16]);SHA512_W_H$1[e]=0|h,SHA512_W_L$1[e]=0|l}let{Ah:n,Al:r,Bh:i,Bl:s,Ch:o,Cl:a,Dh:c,Dl:l,Eh:h,El:d,Fh:u,Fl:f,Gh:p,Gl:g,Hh:y,Hl:m}=this;for(let e=0;e<80;e++){const t=u64$1.rotrSH(h,d,14)^u64$1.rotrSH(h,d,18)^u64$1.rotrBH(h,d,41),b=u64$1.rotrSL(h,d,14)^u64$1.rotrSL(h,d,18)^u64$1.rotrBL(h,d,41),w=h&u^~h&p,v=d&f^~d&g,$=u64$1.add5L(m,b,v,SHA512_Kl$1[e],SHA512_W_L$1[e]),E=u64$1.add5H($,y,t,w,SHA512_Kh$1[e],SHA512_W_H$1[e]),k=0|$,x=u64$1.rotrSH(n,r,28)^u64$1.rotrBH(n,r,34)^u64$1.rotrBH(n,r,39),_=u64$1.rotrSL(n,r,28)^u64$1.rotrBL(n,r,34)^u64$1.rotrBL(n,r,39),S=n&i^n&o^i&o,C=r&s^r&a^s&a;y=0|p,m=0|g,p=0|u,g=0|f,u=0|h,f=0|d,({h:h,l:d}=u64$1.add(0|c,0|l,0|E,0|k)),c=0|o,l=0|a,o=0|i,a=0|s,i=0|n,s=0|r;const A=u64$1.add3L(k,_,C);n=u64$1.add3H(A,E,x,S),r=0|A}({h:n,l:r}=u64$1.add(0|this.Ah,0|this.Al,0|n,0|r)),({h:i,l:s}=u64$1.add(0|this.Bh,0|this.Bl,0|i,0|s)),({h:o,l:a}=u64$1.add(0|this.Ch,0|this.Cl,0|o,0|a)),({h:c,l:l}=u64$1.add(0|this.Dh,0|this.Dl,0|c,0|l)),({h:h,l:d}=u64$1.add(0|this.Eh,0|this.El,0|h,0|d)),({h:u,l:f}=u64$1.add(0|this.Fh,0|this.Fl,0|u,0|f)),({h:p,l:g}=u64$1.add(0|this.Gh,0|this.Gl,0|p,0|g)),({h:y,l:m}=u64$1.add(0|this.Hh,0|this.Hl,0|y,0|m)),this.set(n,r,i,s,o,a,c,l,h,d,u,f,p,g,y,m)}roundClean(){SHA512_W_H$1.fill(0),SHA512_W_L$1.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};const sha512$1=wrapConstructor$2(()=>new SHA512$1);
34
- /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function isBytes$3(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function chain$1(...e){const t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}function alphabet$1(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map(t=>{if(t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]})},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map(t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})}}}function join$1(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function padding(e,t="="){if("string"!=typeof t)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;n.length*e%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let r=n.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function convertRadix$1(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const i=[],s=Array.from(e);for(s.forEach(e=>{if(e<0||e>=t)throw new Error(`Wrong integer: ${e}`)});;){let e=0,o=!0;for(let i=r;i<s.length;i++){const a=s[i],c=t*e+a;if(!Number.isSafeInteger(c)||t*e/t!==e||c-a!==t*e)throw new Error("convertRadix: carry overflow");e=c%n;const l=Math.floor(c/n);if(s[i]=l,!Number.isSafeInteger(l)||l*n+e!==c)throw new Error("convertRadix: carry overflow");o&&(l?o=!1:r=i)}if(i.push(e),o)break}for(let t=0;t<e.length-1&&0===e[t];t++)i.push(0);return i.reverse()}const gcd=(e,t)=>t?gcd(t,e%t):e,radix2carry=(e,t)=>e+(t-gcd(e,t));function convertRadix2(e,t,n,r){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(radix2carry(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${radix2carry(t,n)}`);let i=0,s=0;const o=2**n-1,a=[];for(const r of e){if(r>=2**t)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(i=i<<t|r,s+t>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)a.push((i>>s-n&o)>>>0);i&=2**s-1}if(i=i<<n-s&o,!r&&s>=t)throw new Error("Excess padding");if(!r&&i)throw new Error(`Non-zero padding: ${i}`);return r&&s>0&&a.push(i>>>0),a}function radix$1(e){return{encode:t=>{if(!isBytes$3(t))throw new Error("radix.encode input should be Uint8Array");return convertRadix$1(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(convertRadix$1(t,e,256))}}}function radix2(e,t=!1){if(e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(radix2carry(8,e)>32||radix2carry(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!isBytes$3(n))throw new Error("radix2.encode input should be Uint8Array");return convertRadix2(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(convertRadix2(n,e,8,t))}}}function checksum$1(e,t){if("function"!=typeof t)throw new Error("checksum fn should be function");return{encode(n){if(!isBytes$3(n))throw new Error("checksum.encode: input should be Uint8Array");const r=t(n).slice(0,e),i=new Uint8Array(n.length+e);return i.set(n),i.set(r,n.length),i},decode(n){if(!isBytes$3(n))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-e),i=t(r).slice(0,e),s=n.slice(-e);for(let t=0;t<e;t++)if(i[t]!==s[t])throw new Error("Invalid checksum");return r}}}const utils$1={alphabet:alphabet$1,chain:chain$1,checksum:checksum$1,convertRadix:convertRadix$1,convertRadix2:convertRadix2,radix:radix$1,radix2:radix2,join:join$1,padding:padding},isJapanese=e=>"あいこくしん"===e[0];function nfkd(e){if("string"!=typeof e)throw new TypeError("Invalid mnemonic type: "+typeof e);return e.normalize("NFKD")}function normalize(e){const t=nfkd(e),n=t.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:n}}function assertEntropy(e){assert$2.bytes(e,16,20,24,28,32)}function generateMnemonic(e,t=128){if(assert$2.number(t),t%32!=0||t>256)throw new TypeError("Invalid entropy");return entropyToMnemonic(randomBytes$1(t/8),e)}const calcChecksum=e=>{const t=8-e.length/4;return new Uint8Array([sha256$2(e)[0]>>t<<t])};function getCoder(e){if(!Array.isArray(e)||2048!==e.length||"string"!=typeof e[0])throw new Error("Worlist: expected array of 2048 strings");return e.forEach(e=>{if("string"!=typeof e)throw new Error(`Wordlist: non-string element: ${e}`)}),utils$1.chain(utils$1.checksum(1,calcChecksum),utils$1.radix2(11,!0),utils$1.alphabet(e))}function mnemonicToEntropy(e,t){const{words:n}=normalize(e),r=getCoder(t).decode(n);return assertEntropy(r),r}function entropyToMnemonic(e,t){assertEntropy(e);return getCoder(t).encode(e).join(isJapanese(t)?" ":" ")}function validateMnemonic(e,t){try{mnemonicToEntropy(e,t)}catch(e){return!1}return!0}const salt=e=>nfkd(`mnemonic${e}`);function mnemonicToSeedSync(e,t=""){return pbkdf2(sha512$1,normalize(e).nfkd,salt(t),{c:2048,dkLen:64})}function number$2(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function isBytes$2(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function bytes$2(e,...t){if(!isBytes$2(e))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function hash$2(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");number$2(e.outputLen),number$2(e.blockLen)}function exists$2(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output$2(e,t){bytes$2(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}
35
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function isBytes$1(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}const createView$1=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),rotr$1=(e,t)=>e<<32-t|e>>>t,isLE$2=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!isLE$2)throw new Error("Non little-endian hardware is not supported");const hexes$1=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function bytesToHex$1(e){if(!isBytes$1(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=hexes$1[e[n]];return t}const asciis={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function asciiToBase16(e){return e>=asciis._0&&e<=asciis._9?e-asciis._0:e>=asciis._A&&e<=asciis._F?e-(asciis._A-10):e>=asciis._a&&e<=asciis._f?e-(asciis._a-10):void 0}function hexToBytes$1(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){const n=asciiToBase16(e.charCodeAt(i)),s=asciiToBase16(e.charCodeAt(i+1));if(void 0===n||void 0===s){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+s}return r}function utf8ToBytes$3(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function toBytes$2(e){if("string"==typeof e&&(e=utf8ToBytes$3(e)),!isBytes$1(e))throw new Error("expected Uint8Array, got "+typeof e);return e}function concatBytes$2(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];if(!isBytes$1(r))throw new Error("Uint8Array expected");t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const i=e[t];n.set(i,r),r+=i.length}return n}let Hash$1=class{clone(){return this._cloneInto()}};function wrapConstructor$1(e){const t=t=>e().update(toBytes$2(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}let HMAC$1=class extends Hash$1{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,hash$2(e);const n=toBytes$2(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return exists$2(this),this.iHash.update(e),this}digestInto(e){exists$2(this),bytes$2(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:s,outputLen:o}=this;return e.finished=r,e.destroyed=i,e.blockLen=s,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const hmac$1=(e,t,n)=>new HMAC$1(e,t).update(n).digest();function setBigUint64$1(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,a,r)}hmac$1.create=(e,t)=>new HMAC$1(e,t);let SHA2$1=class extends Hash$1{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=createView$1(this.buffer)}update(e){exists$2(this);const{view:t,buffer:n,blockLen:r}=this,i=(e=toBytes$2(e)).length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);if(o===r){const t=createView$1(e);for(;r<=i-s;s+=r)this.process(t,s);continue}n.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){exists$2(this),output$2(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>r-s&&(this.process(n,0),s=0);for(let e=s;e<r;e++)t[e]=0;setBigUint64$1(n,r-8,BigInt(8*this.length),i),this.process(n,0);const o=createView$1(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:i,destroyed:s,pos:o}=this;return e.length=r,e.pos=o,e.finished=i,e.destroyed=s,r%t&&e.buffer.set(n),e}};const Rho=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Id=Uint8Array.from({length:16},(e,t)=>t),Pi=Id.map(e=>(9*e+5)%16);let idxL=[Id],idxR=[Pi];for(let e=0;e<4;e++)for(let t of[idxL,idxR])t.push(t[e].map(e=>Rho[e]));const shifts=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>new Uint8Array(e)),shiftsL=idxL.map((e,t)=>e.map(e=>shifts[t][e])),shiftsR=idxR.map((e,t)=>e.map(e=>shifts[t][e])),Kl=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Kr=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),rotl$1=(e,t)=>e<<t|e>>>32-t;function f(e,t,n,r){return 0===e?t^n^r:1===e?t&n|~t&r:2===e?(t|~n)^r:3===e?t&r|n&~r:t^(n|~r)}const BUF=new Uint32Array(16);class RIPEMD160 extends SHA2$1{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:t,h2:n,h3:r,h4:i}=this;return[e,t,n,r,i]}set(e,t,n,r,i){this.h0=0|e,this.h1=0|t,this.h2=0|n,this.h3=0|r,this.h4=0|i}process(e,t){for(let n=0;n<16;n++,t+=4)BUF[n]=e.getUint32(t,!0);let n=0|this.h0,r=n,i=0|this.h1,s=i,o=0|this.h2,a=o,c=0|this.h3,l=c,h=0|this.h4,d=h;for(let e=0;e<5;e++){const t=4-e,u=Kl[e],p=Kr[e],g=idxL[e],y=idxR[e],m=shiftsL[e],b=shiftsR[e];for(let t=0;t<16;t++){const r=rotl$1(n+f(e,i,o,c)+BUF[g[t]]+u,m[t])+h|0;n=h,h=c,c=0|rotl$1(o,10),o=i,i=r}for(let e=0;e<16;e++){const n=rotl$1(r+f(t,s,a,l)+BUF[y[e]]+p,b[e])+d|0;r=d,d=l,l=0|rotl$1(a,10),a=s,s=n}}this.set(this.h1+o+l|0,this.h2+c+d|0,this.h3+h+r|0,this.h4+n+s|0,this.h0+i+a|0)}roundClean(){BUF.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const ripemd160=wrapConstructor$1(()=>new RIPEMD160),Chi$1=(e,t,n)=>e&t^~e&n,Maj$1=(e,t,n)=>e&t^e&n^t&n,SHA256_K$1=new Uint32Array([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]),IV$1=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W$1=new Uint32Array(64);let SHA256$1=class extends SHA2$1{constructor(){super(64,32,8,!1),this.A=0|IV$1[0],this.B=0|IV$1[1],this.C=0|IV$1[2],this.D=0|IV$1[3],this.E=0|IV$1[4],this.F=0|IV$1[5],this.G=0|IV$1[6],this.H=0|IV$1[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:s,G:o,H:a}=this;return[e,t,n,r,i,s,o,a]}set(e,t,n,r,i,s,o,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)SHA256_W$1[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=SHA256_W$1[e-15],n=SHA256_W$1[e-2],r=rotr$1(t,7)^rotr$1(t,18)^t>>>3,i=rotr$1(n,17)^rotr$1(n,19)^n>>>10;SHA256_W$1[e]=i+SHA256_W$1[e-7]+r+SHA256_W$1[e-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(rotr$1(o,6)^rotr$1(o,11)^rotr$1(o,25))+Chi$1(o,a,c)+SHA256_K$1[e]+SHA256_W$1[e]|0,h=(rotr$1(n,2)^rotr$1(n,13)^rotr$1(n,22))+Maj$1(n,r,i)|0;l=c,c=a,a=o,o=s+t|0,s=i,i=r,r=n,n=t+h|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,s,o,a,c,l)}roundClean(){SHA256_W$1.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const sha256$1=wrapConstructor$1(()=>new SHA256$1),U32_MASK64=BigInt(2**32-1),_32n=BigInt(32);function fromBig(e,t=!1){return t?{h:Number(e&U32_MASK64),l:Number(e>>_32n&U32_MASK64)}:{h:0|Number(e>>_32n&U32_MASK64),l:0|Number(e&U32_MASK64)}}function split(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:s,l:o}=fromBig(e[i],t);[n[i],r[i]]=[s,o]}return[n,r]}const toBig=(e,t)=>BigInt(e>>>0)<<_32n|BigInt(t>>>0),shrSH=(e,t,n)=>e>>>n,shrSL=(e,t,n)=>e<<32-n|t>>>n,rotrSH=(e,t,n)=>e>>>n|t<<32-n,rotrSL=(e,t,n)=>e<<32-n|t>>>n,rotrBH=(e,t,n)=>e<<64-n|t>>>n-32,rotrBL=(e,t,n)=>e>>>n-32|t<<64-n,rotr32H=(e,t)=>t,rotr32L=(e,t)=>e,rotlSH=(e,t,n)=>e<<n|t>>>32-n,rotlSL=(e,t,n)=>t<<n|e>>>32-n,rotlBH=(e,t,n)=>t<<n-32|e>>>64-n,rotlBL=(e,t,n)=>e<<n-32|t>>>64-n;function add(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:0|i}}const add3L=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,add5L=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),add5H=(e,t,n,r,i,s)=>t+n+r+i+s+(e/2**32|0)|0,u64={fromBig:fromBig,split:split,toBig:toBig,shrSH:shrSH,shrSL:shrSL,rotrSH:rotrSH,rotrSL:rotrSL,rotrBH:rotrBH,rotrBL:rotrBL,rotr32H:rotr32H,rotr32L:rotr32L,rotlSH:rotlSH,rotlSL:rotlSL,rotlBH:rotlBH,rotlBL:rotlBL,add:add,add3L:add3L,add3H:add3H,add4L:add4L,add4H:add4H,add5H:add5H,add5L:add5L},[SHA512_Kh,SHA512_Kl]=(()=>u64.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))))(),SHA512_W_H=new Uint32Array(80),SHA512_W_L=new Uint32Array(80);class SHA512 extends SHA2$1{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:s,Dh:o,Dl:a,Eh:c,El:l,Fh:h,Fl:d,Gh:u,Gl:f,Hh:p,Hl:g}=this;return[e,t,n,r,i,s,o,a,c,l,h,d,u,f,p,g]}set(e,t,n,r,i,s,o,a,c,l,h,d,u,f,p,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|s,this.Dh=0|o,this.Dl=0|a,this.Eh=0|c,this.El=0|l,this.Fh=0|h,this.Fl=0|d,this.Gh=0|u,this.Gl=0|f,this.Hh=0|p,this.Hl=0|g}process(e,t){for(let n=0;n<16;n++,t+=4)SHA512_W_H[n]=e.getUint32(t),SHA512_W_L[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|SHA512_W_H[e-15],n=0|SHA512_W_L[e-15],r=u64.rotrSH(t,n,1)^u64.rotrSH(t,n,8)^u64.shrSH(t,n,7),i=u64.rotrSL(t,n,1)^u64.rotrSL(t,n,8)^u64.shrSL(t,n,7),s=0|SHA512_W_H[e-2],o=0|SHA512_W_L[e-2],a=u64.rotrSH(s,o,19)^u64.rotrBH(s,o,61)^u64.shrSH(s,o,6),c=u64.rotrSL(s,o,19)^u64.rotrBL(s,o,61)^u64.shrSL(s,o,6),l=u64.add4L(i,c,SHA512_W_L[e-7],SHA512_W_L[e-16]),h=u64.add4H(l,r,a,SHA512_W_H[e-7],SHA512_W_H[e-16]);SHA512_W_H[e]=0|h,SHA512_W_L[e]=0|l}let{Ah:n,Al:r,Bh:i,Bl:s,Ch:o,Cl:a,Dh:c,Dl:l,Eh:h,El:d,Fh:u,Fl:f,Gh:p,Gl:g,Hh:y,Hl:m}=this;for(let e=0;e<80;e++){const t=u64.rotrSH(h,d,14)^u64.rotrSH(h,d,18)^u64.rotrBH(h,d,41),b=u64.rotrSL(h,d,14)^u64.rotrSL(h,d,18)^u64.rotrBL(h,d,41),w=h&u^~h&p,v=d&f^~d&g,$=u64.add5L(m,b,v,SHA512_Kl[e],SHA512_W_L[e]),E=u64.add5H($,y,t,w,SHA512_Kh[e],SHA512_W_H[e]),k=0|$,x=u64.rotrSH(n,r,28)^u64.rotrBH(n,r,34)^u64.rotrBH(n,r,39),_=u64.rotrSL(n,r,28)^u64.rotrBL(n,r,34)^u64.rotrBL(n,r,39),S=n&i^n&o^i&o,C=r&s^r&a^s&a;y=0|p,m=0|g,p=0|u,g=0|f,u=0|h,f=0|d,({h:h,l:d}=u64.add(0|c,0|l,0|E,0|k)),c=0|o,l=0|a,o=0|i,a=0|s,i=0|n,s=0|r;const A=u64.add3L(k,_,C);n=u64.add3H(A,E,x,S),r=0|A}({h:n,l:r}=u64.add(0|this.Ah,0|this.Al,0|n,0|r)),({h:i,l:s}=u64.add(0|this.Bh,0|this.Bl,0|i,0|s)),({h:o,l:a}=u64.add(0|this.Ch,0|this.Cl,0|o,0|a)),({h:c,l:l}=u64.add(0|this.Dh,0|this.Dl,0|c,0|l)),({h:h,l:d}=u64.add(0|this.Eh,0|this.El,0|h,0|d)),({h:u,l:f}=u64.add(0|this.Fh,0|this.Fl,0|u,0|f)),({h:p,l:g}=u64.add(0|this.Gh,0|this.Gl,0|p,0|g)),({h:y,l:m}=u64.add(0|this.Hh,0|this.Hl,0|y,0|m)),this.set(n,r,i,s,o,a,c,l,h,d,u,f,p,g,y,m)}roundClean(){SHA512_W_H.fill(0),SHA512_W_L.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const sha512=wrapConstructor$1(()=>new SHA512);function number$1(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function bool$1(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)}function bytes$1(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function hash$1(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");number$1(e.outputLen),number$1(e.blockLen)}function exists$1(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output$1(e,t){bytes$1(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const assert$1={number:number$1,bool:bool$1,bytes:bytes$1,hash:hash$1,exists:exists$1,output:output$1},crypto$1="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,u8a$2=e=>e instanceof Uint8Array,createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),rotr=(e,t)=>e<<32-t|e>>>t,isLE$1=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!isLE$1)throw new Error("Non little-endian hardware is not supported");function utf8ToBytes$2(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function toBytes$1(e){if("string"==typeof e&&(e=utf8ToBytes$2(e)),!u8a$2(e))throw new Error("expected Uint8Array, got "+typeof e);return e}function concatBytes$1(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!u8a$2(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));class Hash{clone(){return this._cloneInto()}}function wrapConstructor(e){const t=t=>e().update(toBytes$1(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function randomBytes(e=32){if(crypto$1&&"function"==typeof crypto$1.getRandomValues)return crypto$1.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function setBigUint64(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,a,r)}class SHA2 extends Hash{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=createView(this.buffer)}update(e){assert$1.exists(this);const{view:t,buffer:n,blockLen:r}=this,i=(e=toBytes$1(e)).length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);if(o===r){const t=createView(e);for(;r<=i-s;s+=r)this.process(t,s);continue}n.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){assert$1.exists(this),assert$1.output(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>r-s&&(this.process(n,0),s=0);for(let e=s;e<r;e++)t[e]=0;setBigUint64(n,r-8,BigInt(8*this.length),i),this.process(n,0);const o=createView(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:i,destroyed:s,pos:o}=this;return e.length=r,e.pos=o,e.finished=i,e.destroyed=s,r%t&&e.buffer.set(n),e}}const Chi=(e,t,n)=>e&t^~e&n,Maj=(e,t,n)=>e&t^e&n^t&n,SHA256_K=new Uint32Array([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]),IV=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W=new Uint32Array(64);class SHA256 extends SHA2{constructor(){super(64,32,8,!1),this.A=0|IV[0],this.B=0|IV[1],this.C=0|IV[2],this.D=0|IV[3],this.E=0|IV[4],this.F=0|IV[5],this.G=0|IV[6],this.H=0|IV[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:s,G:o,H:a}=this;return[e,t,n,r,i,s,o,a]}set(e,t,n,r,i,s,o,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)SHA256_W[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=SHA256_W[e-15],n=SHA256_W[e-2],r=rotr(t,7)^rotr(t,18)^t>>>3,i=rotr(n,17)^rotr(n,19)^n>>>10;SHA256_W[e]=i+SHA256_W[e-7]+r+SHA256_W[e-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(rotr(o,6)^rotr(o,11)^rotr(o,25))+Chi(o,a,c)+SHA256_K[e]+SHA256_W[e]|0,h=(rotr(n,2)^rotr(n,13)^rotr(n,22))+Maj(n,r,i)|0;l=c,c=a,a=o,o=s+t|0,s=i,i=r,r=n,n=t+h|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,s,o,a,c,l)}roundClean(){SHA256_W.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class SHA224 extends SHA256{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const sha256=wrapConstructor(()=>new SHA256);wrapConstructor(()=>new SHA224);
36
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
37
- const _0n$3=BigInt(0),_1n$4=BigInt(1),_2n$2=BigInt(2),u8a$1=e=>e instanceof Uint8Array,hexes=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function bytesToHex(e){if(!u8a$1(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=hexes[e[n]];return t}function numberToHexUnpadded(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function hexToNumber(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function hexToBytes(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const r=2*t,i=e.slice(r,r+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[t]=s}return n}function bytesToNumberBE(e){return hexToNumber(bytesToHex(e))}function bytesToNumberLE(e){if(!u8a$1(e))throw new Error("Uint8Array expected");return hexToNumber(bytesToHex(Uint8Array.from(e).reverse()))}function numberToBytesBE(e,t){return hexToBytes(e.toString(16).padStart(2*t,"0"))}function numberToBytesLE(e,t){return numberToBytesBE(e,t).reverse()}function numberToVarBytesBE(e){return hexToBytes(numberToHexUnpadded(e))}function ensureBytes$1(e,t,n){let r;if("string"==typeof t)try{r=hexToBytes(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!u8a$1(t))throw new Error(`${e} must be hex string or Uint8Array`);r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(`${e} expected ${n} bytes, got ${i}`);return r}function concatBytes(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!u8a$1(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}function equalBytes$1(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function utf8ToBytes$1(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function bitLen(e){let t;for(t=0;e>_0n$3;e>>=_1n$4,t+=1);return t}function bitGet(e,t){return e>>BigInt(t)&_1n$4}const bitSet=(e,t,n)=>e|(n?_1n$4:_0n$3)<<BigInt(t),bitMask=e=>(_2n$2<<BigInt(e-1))-_1n$4,u8n=e=>new Uint8Array(e),u8fr=e=>Uint8Array.from(e);function createHmacDrbg(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=u8n(e),i=u8n(e),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},a=(...e)=>n(i,r,...e),c=(e=u8n())=>{i=a(u8fr([0]),e),r=a(),0!==e.length&&(i=a(u8fr([1]),e),r=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=a();const t=r.slice();n.push(t),e+=r.length}return concatBytes(...n)};return(e,t)=>{let n;for(o(),c(e);!(n=t(l()));)c();return o(),n}}const validatorFns={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function validateObject(e,t,n={}){const r=(t,n,r)=>{const i=validatorFns[n];if("function"!=typeof i)throw new Error(`Invalid validator "${n}", expected function`);const s=e[t];if(!(r&&void 0===s||i(s,e)))throw new Error(`Invalid param ${String(t)}=${s} (${typeof s}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}var ut=Object.freeze({__proto__:null,bitGet:bitGet,bitLen:bitLen,bitMask:bitMask,bitSet:bitSet,bytesToHex:bytesToHex,bytesToNumberBE:bytesToNumberBE,bytesToNumberLE:bytesToNumberLE,concatBytes:concatBytes,createHmacDrbg:createHmacDrbg,ensureBytes:ensureBytes$1,equalBytes:equalBytes$1,hexToBytes:hexToBytes,hexToNumber:hexToNumber,numberToBytesBE:numberToBytesBE,numberToBytesLE:numberToBytesLE,numberToHexUnpadded:numberToHexUnpadded,numberToVarBytesBE:numberToVarBytesBE,utf8ToBytes:utf8ToBytes$1,validateObject:validateObject});
38
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$2=BigInt(0),_1n$3=BigInt(1),_2n$1=BigInt(2),_3n$1=BigInt(3),_4n=BigInt(4),_5n=BigInt(5),_8n=BigInt(8);function mod(e,t){const n=e%t;return n>=_0n$2?n:t+n}function pow(e,t,n){if(n<=_0n$2||t<_0n$2)throw new Error("Expected power/modulo > 0");if(n===_1n$3)return _0n$2;let r=_1n$3;for(;t>_0n$2;)t&_1n$3&&(r=r*e%n),e=e*e%n,t>>=_1n$3;return r}function pow2(e,t,n){let r=e;for(;t-- >_0n$2;)r*=r,r%=n;return r}function invert(e,t){if(e===_0n$2||t<=_0n$2)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=mod(e,t),r=t,i=_0n$2,s=_1n$3;for(;n!==_0n$2;){const e=r%n,t=i-s*(r/n);r=n,n=e,i=s,s=t}if(r!==_1n$3)throw new Error("invert: does not exist");return mod(i,t)}function tonelliShanks(e){const t=(e-_1n$3)/_2n$1;let n,r,i;for(n=e-_1n$3,r=0;n%_2n$1===_0n$2;n/=_2n$1,r++);for(i=_2n$1;i<e&&pow(i,t,e)!==e-_1n$3;i++);if(1===r){const t=(e+_1n$3)/_4n;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}const s=(n+_1n$3)/_2n$1;return function(e,o){if(e.pow(o,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=r,c=e.pow(e.mul(e.ONE,i),n),l=e.pow(o,s),h=e.pow(o,n);for(;!e.eql(h,e.ONE);){if(e.eql(h,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(h);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(c,_1n$3<<BigInt(a-t-1));c=e.sqr(n),l=e.mul(l,n),h=e.mul(h,c),a=t}return l}}function FpSqrt(e){if(e%_4n===_3n$1){const t=(e+_1n$3)/_4n;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%_8n===_5n){const t=(e-_5n)/_8n;return function(e,n){const r=e.mul(n,_2n$1),i=e.pow(r,t),s=e.mul(n,i),o=e.mul(e.mul(s,_2n$1),i),a=e.mul(s,e.sub(o,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return tonelliShanks(e)}BigInt(9),BigInt(16);const FIELD_FIELDS=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField(e){const t=FIELD_FIELDS.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return validateObject(e,t)}function FpPow(e,t,n){if(n<_0n$2)throw new Error("Expected power > 0");if(n===_0n$2)return e.ONE;if(n===_1n$3)return t;let r=e.ONE,i=t;for(;n>_0n$2;)n&_1n$3&&(r=e.mul(r,i)),i=e.sqr(i),n>>=_1n$3;return r}function FpInvertBatch(e,t){const n=new Array(t.length),r=t.reduce((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r)),e.ONE),i=e.inv(r);return t.reduceRight((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r)),i),n}function nLength(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Field(e,t,n=!1,r={}){if(e<=_0n$2)throw new Error(`Expected Fp ORDER > 0, got ${e}`);const{nBitLength:i,nByteLength:s}=nLength(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=FpSqrt(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:s,MASK:bitMask(i),ZERO:_0n$2,ONE:_1n$3,create:t=>mod(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return _0n$2<=t&&t<e},is0:e=>e===_0n$2,isOdd:e=>(e&_1n$3)===_1n$3,neg:t=>mod(-t,e),eql:(e,t)=>e===t,sqr:t=>mod(t*t,e),add:(t,n)=>mod(t+n,e),sub:(t,n)=>mod(t-n,e),mul:(t,n)=>mod(t*n,e),pow:(e,t)=>FpPow(a,e,t),div:(t,n)=>mod(t*invert(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>invert(t,e),sqrt:r.sqrt||(e=>o(a,e)),invertBatch:e=>FpInvertBatch(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?numberToBytesLE(e,s):numberToBytesBE(e,s),fromBytes:e=>{if(e.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${e.length}`);return n?bytesToNumberLE(e):bytesToNumberBE(e)}});return Object.freeze(a)}function hashToPrivateScalar(e,t,n=!1){const r=(e=ensureBytes$1("privateHash",e)).length,i=nLength(t).nByteLength+8;if(i<24||r<i||r>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${r}`);return mod(n?bytesToNumberLE(e):bytesToNumberBE(e),t-_1n$3)+_1n$3}
39
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$1=BigInt(0),_1n$2=BigInt(1);function wNAF(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>_0n$1;)n&_1n$2&&(r=r.add(i)),i=i.double(),n>>=_1n$2;return r},precomputeWindow(e,t){const{windows:n,windowSize:i}=r(t),s=[];let o=e,a=o;for(let e=0;e<n;e++){a=o,s.push(a);for(let e=1;e<i;e++)a=a.add(o),s.push(a);o=a.double()}return s},wNAF(t,i,s){const{windows:o,windowSize:a}=r(t);let c=e.ZERO,l=e.BASE;const h=BigInt(2**t-1),d=2**t,u=BigInt(t);for(let e=0;e<o;e++){const t=e*a;let r=Number(s&h);s>>=u,r>a&&(r-=d,s+=_1n$2);const o=t,f=t+Math.abs(r)-1,p=e%2!=0,g=r<0;0===r?l=l.add(n(p,i[o])):c=c.add(n(g,i[f]))}return{p:c,f:l}},wNAFCached(e,t,n,r){const i=e._WINDOW_SIZE||1;let s=t.get(e);return s||(s=this.precomputeWindow(e,i),1!==i&&t.set(e,r(s))),this.wNAF(i,s,n)}}}function validateBasic(e){return validateField(e.Fp),validateObject(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...nLength(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
40
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function validatePointOpts(e){const t=validateBasic(e);validateObject(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:i}=t;if(n){if(!r.eql(i,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:b2n,hexToBytes:h2b}=ut,DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=DER;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(128&r[0])throw new t("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:b2n(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=DER,n="string"==typeof e?h2b(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:i,l:s}=DER._parseInt(n.subarray(2)),{d:o,l:a}=DER._parseInt(s);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},r=t(n(e.s)),i=t(n(e.r)),s=r.length/2,o=i.length/2,a=n(s),c=n(o);return`30${n(o+s+4)}02${c}${i}02${a}${r}`}},_0n=BigInt(0),_1n$1=BigInt(1);BigInt(2);const _3n=BigInt(3);function weierstrassPoints(e){const t=validatePointOpts(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{const i=t.toAffine();return concatBytes(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),i=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function s(e){const{a:r,b:i}=t,s=n.sqr(e),o=n.mul(s,e);return n.add(n.add(o,n.mul(e,r)),i)}if(!n.eql(n.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function o(e){return"bigint"==typeof e&&_0n<e&&e<t.n}function a(e){if(!o(e))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:i,n:s}=t;if(n&&"bigint"!=typeof e){if(e instanceof Uint8Array&&(e=bytesToHex(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*r,"0")}let o;try{o="bigint"==typeof e?e:bytesToNumberBE(ensureBytes$1("private key",e,r))}catch(t){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return i&&(o=mod(o,s)),a(o),o}const l=new Map;function h(e){if(!(e instanceof d))throw new Error("ProjectivePoint expected")}class d{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required")}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof d)throw new Error("projective point not allowed");const i=e=>n.eql(e,n.ZERO);return i(t)&&i(r)?d.ZERO:new d(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)}static fromHex(e){const t=d.fromAffine(i(ensureBytes$1("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw new Error("bad point: x or y not FE");const i=n.sqr(r),o=s(e);if(!n.eql(i,o))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){h(e);const{px:t,py:r,pz:i}=this,{px:s,py:o,pz:a}=e,c=n.eql(n.mul(t,a),n.mul(s,i)),l=n.eql(n.mul(r,a),n.mul(o,i));return c&&l}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,i=n.mul(r,_3n),{px:s,py:o,pz:a}=this;let c=n.ZERO,l=n.ZERO,h=n.ZERO,u=n.mul(s,s),f=n.mul(o,o),p=n.mul(a,a),g=n.mul(s,o);return g=n.add(g,g),h=n.mul(s,a),h=n.add(h,h),c=n.mul(e,h),l=n.mul(i,p),l=n.add(c,l),c=n.sub(f,l),l=n.add(f,l),l=n.mul(c,l),c=n.mul(g,c),h=n.mul(i,h),p=n.mul(e,p),g=n.sub(u,p),g=n.mul(e,g),g=n.add(g,h),h=n.add(u,u),u=n.add(h,u),u=n.add(u,p),u=n.mul(u,g),l=n.add(l,u),p=n.mul(o,a),p=n.add(p,p),u=n.mul(p,g),c=n.sub(c,u),h=n.mul(p,f),h=n.add(h,h),h=n.add(h,h),new d(c,l,h)}add(e){h(e);const{px:r,py:i,pz:s}=this,{px:o,py:a,pz:c}=e;let l=n.ZERO,u=n.ZERO,f=n.ZERO;const p=t.a,g=n.mul(t.b,_3n);let y=n.mul(r,o),m=n.mul(i,a),b=n.mul(s,c),w=n.add(r,i),v=n.add(o,a);w=n.mul(w,v),v=n.add(y,m),w=n.sub(w,v),v=n.add(r,s);let $=n.add(o,c);return v=n.mul(v,$),$=n.add(y,b),v=n.sub(v,$),$=n.add(i,s),l=n.add(a,c),$=n.mul($,l),l=n.add(m,b),$=n.sub($,l),f=n.mul(p,v),l=n.mul(g,b),f=n.add(l,f),l=n.sub(m,f),f=n.add(m,f),u=n.mul(l,f),m=n.add(y,y),m=n.add(m,y),b=n.mul(p,b),v=n.mul(g,v),m=n.add(m,b),b=n.sub(y,b),b=n.mul(p,b),v=n.add(v,b),y=n.mul(m,v),u=n.add(u,y),y=n.mul($,v),l=n.mul(w,l),l=n.sub(l,y),y=n.mul(w,m),f=n.mul($,f),f=n.add(f,y),new d(l,u,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return f.wNAFCached(this,l,e,e=>{const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)})}multiplyUnsafe(e){const r=d.ZERO;if(e===_0n)return r;if(a(e),e===_1n$1)return this;const{endo:i}=t;if(!i)return f.unsafeLadder(this,e);let{k1neg:s,k1:o,k2neg:c,k2:l}=i.splitScalar(e),h=r,u=r,p=this;for(;o>_0n||l>_0n;)o&_1n$1&&(h=h.add(p)),l&_1n$1&&(u=u.add(p)),p=p.double(),o>>=_1n$1,l>>=_1n$1;return s&&(h=h.negate()),c&&(u=u.negate()),u=new d(n.mul(u.px,i.beta),u.py,u.pz),h.add(u)}multiply(e){a(e);let r,i,s=e;const{endo:o}=t;if(o){const{k1neg:e,k1:t,k2neg:a,k2:c}=o.splitScalar(s);let{p:l,f:h}=this.wNAF(t),{p:u,f:p}=this.wNAF(c);l=f.constTimeNegate(e,l),u=f.constTimeNegate(a,u),u=new d(n.mul(u.px,o.beta),u.py,u.pz),r=l.add(u),i=h.add(p)}else{const{p:e,f:t}=this.wNAF(s);r=e,i=t}return d.normalizeZ([r,i])[0]}multiplyAndAddUnsafe(e,t,n){const r=d.BASE,i=(e,t)=>t!==_0n&&t!==_1n$1&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),s=i(this,t).add(i(e,n));return s.is0()?void 0:s}toAffine(e){const{px:t,py:r,pz:i}=this,s=this.is0();null==e&&(e=s?n.ONE:n.inv(i));const o=n.mul(t,e),a=n.mul(r,e),c=n.mul(i,e);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw new Error("invZ was invalid");return{x:o,y:a}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===_1n$1)return!0;if(n)return n(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===_1n$1?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return bytesToHex(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const u=t.nBitLength,f=wNAF(d,t.endo?Math.ceil(u/2):u);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:o}}function validateOpts(e){const t=validateBasic(e);return validateObject(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function weierstrass(e){const t=validateOpts(e),{Fp:n,n:r}=t,i=n.BYTES+1,s=2*n.BYTES+1;function o(e){return mod(e,r)}function a(e){return invert(e,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:h,isWithinCurveOrder:d}=weierstrassPoints({...t,toBytes(e,t,r){const i=t.toAffine(),s=n.toBytes(i.x),o=concatBytes;return r?o(Uint8Array.from([t.hasEvenY()?2:3]),s):o(Uint8Array.from([4]),s,n.toBytes(i.y))},fromBytes(e){const t=e.length,r=e[0],o=e.subarray(1);if(t!==i||2!==r&&3!==r){if(t===s&&4===r){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}{const e=bytesToNumberBE(o);if(!function(e){return _0n<e&&e<n.ORDER}(e))throw new Error("Point is not on curve");const t=h(e);let i=n.sqrt(t);return!(1&~r)!==((i&_1n$1)===_1n$1)&&(i=n.neg(i)),{x:e,y:i}}}}),u=e=>bytesToHex(numberToBytesBE(e,t.nByteLength));function f(e){return e>r>>_1n$1}const p=(e,t,n)=>bytesToNumberBE(e.slice(t,n));class g{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=ensureBytes$1("compactSignature",e,2*n),new g(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=DER.toSig(ensureBytes$1("DER",e));return new g(t,n)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:i,recovery:s}=this,l=w(ensureBytes$1("msgHash",e));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const h=2===s||3===s?r+t.n:r;if(h>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=1&s?"03":"02",f=c.fromHex(d+u(h)),p=a(h),g=o(-l*p),y=o(i*p),m=c.BASE.multiplyAndAddUnsafe(f,g,y);if(!m)throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes(this.toDERHex())}toDERHex(){return DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes(this.toCompactHex())}toCompactHex(){return u(this.r)+u(this.s)}}const y={isValidPrivateKey(e){try{return l(e),!0}catch(e){return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>numberToBytesBE(hashToPrivateScalar(t.randomBytes(n.BYTES+8),r),t.nByteLength),precompute:(e=8,t=c.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function m(e){const t=e instanceof Uint8Array,n="string"==typeof e,r=(t||n)&&e.length;return t?r===i||r===s:n?r===2*i||r===2*s:e instanceof c}const b=t.bits2int||function(e){const n=bytesToNumberBE(e),r=8*e.length-t.nBitLength;return r>0?n>>BigInt(r):n},w=t.bits2int_modN||function(e){return o(b(e))},v=bitMask(t.nBitLength);function $(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(_0n<=e&&e<v))throw new Error(`bigint expected < 2^${t.nBitLength}`);return numberToBytesBE(e,t.nByteLength)}function E(e,r,i=k){if(["recovered","canonical"].some(e=>e in i))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:h}=t;let{lowS:u,prehash:p,extraEntropy:y}=i;null==u&&(u=!0),e=ensureBytes$1("msgHash",e),p&&(e=ensureBytes$1("prehashed msgHash",s(e)));const m=w(e),v=l(r),E=[$(v),$(m)];if(null!=y){const e=!0===y?h(n.BYTES):y;E.push(ensureBytes$1("extraEntropy",e,n.BYTES))}const x=concatBytes(...E),_=m;return{seed:x,k2sig:function(e){const t=b(e);if(!d(t))return;const n=a(t),r=c.BASE.multiply(t).toAffine(),i=o(r.x);if(i===_0n)return;const s=o(n*o(_+i*v));if(s===_0n)return;let l=(r.x===i?0:2)|Number(r.y&_1n$1),h=s;return u&&f(s)&&(h=function(e){return f(e)?o(-e):e}(s),l^=1),new g(i,h,l)}}}const k={lowS:t.lowS,prehash:!1},x={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(m(e))throw new Error("first arg must be private key");if(!m(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(l(e)).toRawBytes(n)},sign:function(e,n,r=k){const{seed:i,k2sig:s}=E(e,n,r),o=t;return createHmacDrbg(o.hash.outputLen,o.nByteLength,o.hmac)(i,s)},verify:function(e,n,r,i=x){const s=e;if(n=ensureBytes$1("msgHash",n),r=ensureBytes$1("publicKey",r),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:l,prehash:h}=i;let d,u;try{if("string"==typeof s||s instanceof Uint8Array)try{d=g.fromDER(s)}catch(e){if(!(e instanceof DER.Err))throw e;d=g.fromCompact(s)}else{if("object"!=typeof s||"bigint"!=typeof s.r||"bigint"!=typeof s.s)throw new Error("PARSE");{const{r:e,s:t}=s;d=new g(e,t)}}u=c.fromHex(r)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(l&&d.hasHighS())return!1;h&&(n=t.hash(n));const{r:f,s:p}=d,y=w(n),m=a(p),b=o(y*m),v=o(f*m),$=c.BASE.multiplyAndAddUnsafe(u,b,v)?.toAffine();return!!$&&o($.x)===f},ProjectivePoint:c,Signature:g,utils:y}}BigInt(4);class HMAC extends Hash{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,assert$1.hash(e);const n=toBytes$1(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return assert$1.exists(this),this.iHash.update(e),this}digestInto(e){assert$1.exists(this),assert$1.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:s,outputLen:o}=this;return e.finished=r,e.destroyed=i,e.blockLen=s,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const hmac=(e,t,n)=>new HMAC(e,t).update(n).digest();
41
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
42
- function getHash(e){return{hash:e,hmac:(t,...n)=>hmac(e,t,concatBytes$1(...n)),randomBytes:randomBytes}}function createCurve(e,t){const n=t=>weierstrass({...e,...getHash(t)});return Object.freeze({...n(t),create:n})}
43
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */hmac.create=(e,t)=>new HMAC(e,t);const secp256k1P=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n=BigInt(1),_2n=BigInt(2),divNearest=(e,t)=>(e+t/_2n)/t;function sqrtMod(e){const t=secp256k1P,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,h=l*l*e%t,d=pow2(h,n,t)*h%t,u=pow2(d,n,t)*h%t,f=pow2(u,_2n,t)*l%t,p=pow2(f,i,t)*f%t,g=pow2(p,s,t)*p%t,y=pow2(g,a,t)*g%t,m=pow2(y,c,t)*y%t,b=pow2(m,a,t)*g%t,w=pow2(b,n,t)*h%t,v=pow2(w,o,t)*p%t,$=pow2(v,r,t)*l%t,E=pow2($,_2n,t);if(!Fp.eql(Fp.sqr(E),e))throw new Error("Cannot find square root");return E}const Fp=Field(secp256k1P,void 0,void 0,{sqrt:sqrtMod}),secp256k1=createCurve({a:BigInt(0),b:BigInt(7),Fp:Fp,n:secp256k1N,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=secp256k1N,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-_1n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,o=BigInt("0x100000000000000000000000000000000"),a=divNearest(s*e,t),c=divNearest(-r*e,t);let l=mod(e-a*n-c*i,t),h=mod(-a*r-c*s,t);const d=l>o,u=h>o;if(d&&(l=t-l),u&&(h=t-h),l>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:l,k2neg:u,k2:h}}}},sha256);
13
+ function isBytes$1(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}const createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),rotr=(e,t)=>e<<32-t|e>>>t,isLE$1=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!isLE$1)throw new Error("Non little-endian hardware is not supported");const hexes=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function bytesToHex(e){if(!isBytes$1(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=hexes[e[n]];return t}const asciis={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function asciiToBase16(e){return e>=asciis._0&&e<=asciis._9?e-asciis._0:e>=asciis._A&&e<=asciis._F?e-(asciis._A-10):e>=asciis._a&&e<=asciis._f?e-(asciis._a-10):void 0}function hexToBytes(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,o=0;t<n;t++,o+=2){const n=asciiToBase16(e.charCodeAt(o)),s=asciiToBase16(e.charCodeAt(o+1));if(void 0===n||void 0===s){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}r[t]=16*n+s}return r}function utf8ToBytes$1(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function toBytes$1(e){if("string"==typeof e&&(e=utf8ToBytes$1(e)),!isBytes$1(e))throw new Error("expected Uint8Array, got "+typeof e);return e}function concatBytes(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];if(!isBytes$1(r))throw new Error("Uint8Array expected");t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const o=e[t];n.set(o,r),r+=o.length}return n}class Hash{clone(){return this._cloneInto()}}const toStr={}.toString;function checkOpts$1(e,t){if(void 0!==t&&"[object Object]"!==toStr.call(t))throw new Error("Options should be object or undefined");return Object.assign(e,t)}function wrapConstructor(e){const t=t=>e().update(toBytes$1(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function randomBytes(e=32){if(crypto$1&&"function"==typeof crypto$1.getRandomValues)return crypto$1.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}let HMAC$1=class extends Hash{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,hash$1(e);const n=toBytes$1(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<o.length;e++)o[e]^=54;this.iHash.update(o),this.oHash=e.create();for(let e=0;e<o.length;e++)o[e]^=106;this.oHash.update(o),o.fill(0)}update(e){return exists$1(this),this.iHash.update(e),this}digestInto(e){exists$1(this),bytes$1(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:o,blockLen:s,outputLen:i}=this;return e.finished=r,e.destroyed=o,e.blockLen=s,e.outputLen=i,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const hmac$1=(e,t,n)=>new HMAC$1(e,t).update(n).digest();function pbkdf2Init(e,t,n,r){hash$1(e);const o=checkOpts$1({dkLen:32,asyncTick:10},r),{c:s,dkLen:i,asyncTick:a}=o;if(number$1(s),number$1(i),number$1(a),s<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const l=toBytes$1(t),c=toBytes$1(n),d=new Uint8Array(i),h=hmac$1.create(e,l),u=h._cloneInto().update(c);return{c:s,dkLen:i,asyncTick:a,DK:d,PRF:h,PRFSalt:u}}function pbkdf2Output(e,t,n,r,o){return e.destroy(),t.destroy(),r&&r.destroy(),o.fill(0),n}function pbkdf2(e,t,n,r){const{c:o,dkLen:s,DK:i,PRF:a,PRFSalt:l}=pbkdf2Init(e,t,n,r);let c;const d=new Uint8Array(4),h=createView(d),u=new Uint8Array(a.outputLen);for(let e=1,t=0;t<s;e++,t+=a.outputLen){const n=i.subarray(t,t+a.outputLen);h.setInt32(0,e,!1),(c=l._cloneInto(c)).update(d).digestInto(u),n.set(u.subarray(0,n.length));for(let e=1;e<o;e++){a._cloneInto(c).update(u).digestInto(u);for(let e=0;e<n.length;e++)n[e]^=u[e]}}return pbkdf2Output(a,l,i,c,u)}function setBigUint64(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),a=Number(n&s),l=r?4:0,c=r?0:4;e.setUint32(t+l,i,r),e.setUint32(t+c,a,r)}hmac$1.create=(e,t)=>new HMAC$1(e,t);class SHA2 extends Hash{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=createView(this.buffer)}update(e){exists$1(this);const{view:t,buffer:n,blockLen:r}=this,o=(e=toBytes$1(e)).length;for(let s=0;s<o;){const i=Math.min(r-this.pos,o-s);if(i!==r)n.set(e.subarray(s,s+i),this.pos),this.pos+=i,s+=i,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=createView(e);for(;r<=o-s;s+=r)this.process(t,s)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){exists$1(this),output$1(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>r-s&&(this.process(n,0),s=0);for(let e=s;e<r;e++)t[e]=0;setBigUint64(n,r-8,BigInt(8*this.length),o),this.process(n,0);const i=createView(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)i.setUint32(4*e,c[e],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:o,destroyed:s,pos:i}=this;return e.length=r,e.pos=i,e.finished=o,e.destroyed=s,r%t&&e.buffer.set(n),e}}const Chi=(e,t,n)=>e&t^~e&n,Maj=(e,t,n)=>e&t^e&n^t&n,SHA256_K=new Uint32Array([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]),IV=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W=new Uint32Array(64);class SHA256 extends SHA2{constructor(){super(64,32,8,!1),this.A=0|IV[0],this.B=0|IV[1],this.C=0|IV[2],this.D=0|IV[3],this.E=0|IV[4],this.F=0|IV[5],this.G=0|IV[6],this.H=0|IV[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:s,G:i,H:a}=this;return[e,t,n,r,o,s,i,a]}set(e,t,n,r,o,s,i,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|s,this.G=0|i,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)SHA256_W[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=SHA256_W[e-15],n=SHA256_W[e-2],r=rotr(t,7)^rotr(t,18)^t>>>3,o=rotr(n,17)^rotr(n,19)^n>>>10;SHA256_W[e]=o+SHA256_W[e-7]+r+SHA256_W[e-16]|0}let{A:n,B:r,C:o,D:s,E:i,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){const t=c+(rotr(i,6)^rotr(i,11)^rotr(i,25))+Chi(i,a,l)+SHA256_K[e]+SHA256_W[e]|0,d=(rotr(n,2)^rotr(n,13)^rotr(n,22))+Maj(n,r,o)|0;c=l,l=a,a=i,i=s+t|0,s=o,o=r,r=n,n=t+d|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,s=s+this.D|0,i=i+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,o,s,i,a,l,c)}roundClean(){SHA256_W.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const sha256=wrapConstructor((()=>new SHA256)),U32_MASK64=BigInt(2**32-1),_32n=BigInt(32);function fromBig(e,t=!1){return t?{h:Number(e&U32_MASK64),l:Number(e>>_32n&U32_MASK64)}:{h:0|Number(e>>_32n&U32_MASK64),l:0|Number(e&U32_MASK64)}}function split(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:s,l:i}=fromBig(e[o],t);[n[o],r[o]]=[s,i]}return[n,r]}const toBig=(e,t)=>BigInt(e>>>0)<<_32n|BigInt(t>>>0),shrSH=(e,t,n)=>e>>>n,shrSL=(e,t,n)=>e<<32-n|t>>>n,rotrSH=(e,t,n)=>e>>>n|t<<32-n,rotrSL=(e,t,n)=>e<<32-n|t>>>n,rotrBH=(e,t,n)=>e<<64-n|t>>>n-32,rotrBL=(e,t,n)=>e>>>n-32|t<<64-n,rotr32H=(e,t)=>t,rotr32L=(e,t)=>e,rotlSH=(e,t,n)=>e<<n|t>>>32-n,rotlSL=(e,t,n)=>t<<n|e>>>32-n,rotlBH=(e,t,n)=>t<<n-32|e>>>64-n,rotlBL=(e,t,n)=>e<<n-32|t>>>64-n;function add(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:0|o}}const add3L=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H=(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,add5L=(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0),add5H=(e,t,n,r,o,s)=>t+n+r+o+s+(e/2**32|0)|0,u64={fromBig:fromBig,split:split,toBig:toBig,shrSH:shrSH,shrSL:shrSL,rotrSH:rotrSH,rotrSL:rotrSL,rotrBH:rotrBH,rotrBL:rotrBL,rotr32H:rotr32H,rotr32L:rotr32L,rotlSH:rotlSH,rotlSL:rotlSL,rotlBH:rotlBH,rotlBL:rotlBL,add:add,add3L:add3L,add3H:add3H,add4L:add4L,add4H:add4H,add5H:add5H,add5L:add5L},[SHA512_Kh,SHA512_Kl]=(()=>u64.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))))(),SHA512_W_H=new Uint32Array(80),SHA512_W_L=new Uint32Array(80);class SHA512 extends SHA2{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:o,Cl:s,Dh:i,Dl:a,Eh:l,El:c,Fh:d,Fl:h,Gh:u,Gl:p,Hh:f,Hl:g}=this;return[e,t,n,r,o,s,i,a,l,c,d,h,u,p,f,g]}set(e,t,n,r,o,s,i,a,l,c,d,h,u,p,f,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|o,this.Cl=0|s,this.Dh=0|i,this.Dl=0|a,this.Eh=0|l,this.El=0|c,this.Fh=0|d,this.Fl=0|h,this.Gh=0|u,this.Gl=0|p,this.Hh=0|f,this.Hl=0|g}process(e,t){for(let n=0;n<16;n++,t+=4)SHA512_W_H[n]=e.getUint32(t),SHA512_W_L[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|SHA512_W_H[e-15],n=0|SHA512_W_L[e-15],r=u64.rotrSH(t,n,1)^u64.rotrSH(t,n,8)^u64.shrSH(t,n,7),o=u64.rotrSL(t,n,1)^u64.rotrSL(t,n,8)^u64.shrSL(t,n,7),s=0|SHA512_W_H[e-2],i=0|SHA512_W_L[e-2],a=u64.rotrSH(s,i,19)^u64.rotrBH(s,i,61)^u64.shrSH(s,i,6),l=u64.rotrSL(s,i,19)^u64.rotrBL(s,i,61)^u64.shrSL(s,i,6),c=u64.add4L(o,l,SHA512_W_L[e-7],SHA512_W_L[e-16]),d=u64.add4H(c,r,a,SHA512_W_H[e-7],SHA512_W_H[e-16]);SHA512_W_H[e]=0|d,SHA512_W_L[e]=0|c}let{Ah:n,Al:r,Bh:o,Bl:s,Ch:i,Cl:a,Dh:l,Dl:c,Eh:d,El:h,Fh:u,Fl:p,Gh:f,Gl:g,Hh:m,Hl:b}=this;for(let e=0;e<80;e++){const t=u64.rotrSH(d,h,14)^u64.rotrSH(d,h,18)^u64.rotrBH(d,h,41),y=u64.rotrSL(d,h,14)^u64.rotrSL(d,h,18)^u64.rotrBL(d,h,41),w=d&u^~d&f,v=h&p^~h&g,k=u64.add5L(b,y,v,SHA512_Kl[e],SHA512_W_L[e]),x=u64.add5H(k,m,t,w,SHA512_Kh[e],SHA512_W_H[e]),E=0|k,C=u64.rotrSH(n,r,28)^u64.rotrBH(n,r,34)^u64.rotrBH(n,r,39),$=u64.rotrSL(n,r,28)^u64.rotrBL(n,r,34)^u64.rotrBL(n,r,39),S=n&o^n&i^o&i,_=r&s^r&a^s&a;m=0|f,b=0|g,f=0|u,g=0|p,u=0|d,p=0|h,({h:d,l:h}=u64.add(0|l,0|c,0|x,0|E)),l=0|i,c=0|a,i=0|o,a=0|s,o=0|n,s=0|r;const A=u64.add3L(E,$,_);n=u64.add3H(A,x,C,S),r=0|A}({h:n,l:r}=u64.add(0|this.Ah,0|this.Al,0|n,0|r)),({h:o,l:s}=u64.add(0|this.Bh,0|this.Bl,0|o,0|s)),({h:i,l:a}=u64.add(0|this.Ch,0|this.Cl,0|i,0|a)),({h:l,l:c}=u64.add(0|this.Dh,0|this.Dl,0|l,0|c)),({h:d,l:h}=u64.add(0|this.Eh,0|this.El,0|d,0|h)),({h:u,l:p}=u64.add(0|this.Fh,0|this.Fl,0|u,0|p)),({h:f,l:g}=u64.add(0|this.Gh,0|this.Gl,0|f,0|g)),({h:m,l:b}=u64.add(0|this.Hh,0|this.Hl,0|m,0|b)),this.set(n,r,o,s,i,a,l,c,d,h,u,p,f,g,m,b)}roundClean(){SHA512_W_H.fill(0),SHA512_W_L.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const sha512=wrapConstructor((()=>new SHA512));
14
+ /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function isBytes(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function chain(...e){const t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map((e=>e.encode)).reduceRight(n,t),decode:e.map((e=>e.decode)).reduce(n,t)}}function alphabet(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map((t=>{if(t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]}))},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map((t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}}function join(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function padding(e,t="="){if("string"!=typeof t)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;n.length*e%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let r=n.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function convertRadix(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const o=[],s=Array.from(e);for(s.forEach((e=>{if(e<0||e>=t)throw new Error(`Wrong integer: ${e}`)}));;){let e=0,i=!0;for(let o=r;o<s.length;o++){const a=s[o],l=t*e+a;if(!Number.isSafeInteger(l)||t*e/t!==e||l-a!=t*e)throw new Error("convertRadix: carry overflow");e=l%n;const c=Math.floor(l/n);if(s[o]=c,!Number.isSafeInteger(c)||c*n+e!==l)throw new Error("convertRadix: carry overflow");i&&(c?i=!1:r=o)}if(o.push(e),i)break}for(let t=0;t<e.length-1&&0===e[t];t++)o.push(0);return o.reverse()}const gcd=(e,t)=>t?gcd(t,e%t):e,radix2carry=(e,t)=>e+(t-gcd(e,t));function convertRadix2(e,t,n,r){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(radix2carry(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${radix2carry(t,n)}`);let o=0,s=0;const i=2**n-1,a=[];for(const r of e){if(r>=2**t)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(o=o<<t|r,s+t>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)a.push((o>>s-n&i)>>>0);o&=2**s-1}if(o=o<<n-s&i,!r&&s>=t)throw new Error("Excess padding");if(!r&&o)throw new Error(`Non-zero padding: ${o}`);return r&&s>0&&a.push(o>>>0),a}function radix(e){return{encode:t=>{if(!isBytes(t))throw new Error("radix.encode input should be Uint8Array");return convertRadix(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(convertRadix(t,e,256))}}}function radix2(e,t=!1){if(e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(radix2carry(8,e)>32||radix2carry(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!isBytes(n))throw new Error("radix2.encode input should be Uint8Array");return convertRadix2(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(convertRadix2(n,e,8,t))}}}function unsafeWrapper(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function checksum(e,t){if("function"!=typeof t)throw new Error("checksum fn should be function");return{encode(n){if(!isBytes(n))throw new Error("checksum.encode: input should be Uint8Array");const r=t(n).slice(0,e),o=new Uint8Array(n.length+e);return o.set(n),o.set(r,n.length),o},decode(n){if(!isBytes(n))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-e),o=t(r).slice(0,e),s=n.slice(-e);for(let t=0;t<e;t++)if(o[t]!==s[t])throw new Error("Invalid checksum");return r}}}const utils$1={alphabet:alphabet,chain:chain,checksum:checksum,convertRadix:convertRadix,convertRadix2:convertRadix2,radix:radix,radix2:radix2,join:join,padding:padding},base64=chain(radix2(6),alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),padding(6),join("")),genBase58=e=>chain(radix(58),alphabet(e),join("")),base58=genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),createBase58check=e=>chain(checksum(4,(t=>e(e(t)))),base58),base58check$1=createBase58check,BECH_ALPHABET=chain(alphabet("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),join("")),POLYMOD_GENERATORS=[996825010,642813549,513874426,1027748829,705979059];function bech32Polymod(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e<POLYMOD_GENERATORS.length;e++)1==(t>>e&1)&&(n^=POLYMOD_GENERATORS[e]);return n}function bechChecksum(e,t,n=1){const r=e.length;let o=1;for(let t=0;t<r;t++){const n=e.charCodeAt(t);if(n<33||n>126)throw new Error(`Invalid prefix (${e})`);o=bech32Polymod(o)^n>>5}o=bech32Polymod(o);for(let t=0;t<r;t++)o=bech32Polymod(o)^31&e.charCodeAt(t);for(let e of t)o=bech32Polymod(o)^e;for(let e=0;e<6;e++)o=bech32Polymod(o);return o^=n,BECH_ALPHABET.encode(convertRadix2([o%2**30],30,5,!1))}function genBech32(e){const t="bech32"===e?1:734539939,n=radix2(5),r=n.decode,o=n.encode,s=unsafeWrapper(r);function i(e,n=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==n&&e.length>n)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=(e=r).lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const s=e.slice(0,o),i=e.slice(o+1);if(i.length<6)throw new Error("Data must be at least 6 characters long");const a=BECH_ALPHABET.decode(i).slice(0,-6),l=bechChecksum(s,a,t);if(!i.endsWith(l))throw new Error(`Invalid checksum in ${e}: expected "${l}"`);return{prefix:s,words:a}}return{encode:function(e,n,r=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const o=e.length+7+n.length;if(!1!==r&&o>r)throw new TypeError(`Length ${o} exceeds limit ${r}`);const s=e.toLowerCase(),i=bechChecksum(s,n,t);return`${s}1${BECH_ALPHABET.encode(n)}${i}`},decode:i,decodeToBytes:function(e){const{prefix:t,words:n}=i(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:unsafeWrapper(i),fromWords:r,fromWordsUnsafe:s,toWords:o}}const bech32$1=genBech32("bech32"),isJapanese=e=>"あいこくしん"===e[0];function nfkd(e){if("string"!=typeof e)throw new TypeError("Invalid mnemonic type: "+typeof e);return e.normalize("NFKD")}function normalize(e){const t=nfkd(e),n=t.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:n}}function assertEntropy(e){assert$1.bytes(e,16,20,24,28,32)}function generateMnemonic(e,t=128){if(assert$1.number(t),t%32!=0||t>256)throw new TypeError("Invalid entropy");return entropyToMnemonic(randomBytes(t/8),e)}const calcChecksum=e=>{const t=8-e.length/4;return new Uint8Array([sha256(e)[0]>>t<<t])};function getCoder(e){if(!Array.isArray(e)||2048!==e.length||"string"!=typeof e[0])throw new Error("Worlist: expected array of 2048 strings");return e.forEach((e=>{if("string"!=typeof e)throw new Error(`Wordlist: non-string element: ${e}`)})),utils$1.chain(utils$1.checksum(1,calcChecksum),utils$1.radix2(11,!0),utils$1.alphabet(e))}function mnemonicToEntropy(e,t){const{words:n}=normalize(e),r=getCoder(t).decode(n);return assertEntropy(r),r}function entropyToMnemonic(e,t){assertEntropy(e);return getCoder(t).encode(e).join(isJapanese(t)?" ":" ")}function validateMnemonic(e,t){try{mnemonicToEntropy(e,t)}catch(e){return!1}return!0}const salt=e=>nfkd(`mnemonic${e}`);function mnemonicToSeedSync(e,t=""){return pbkdf2(sha512,normalize(e).nfkd,salt(t),{c:2048,dkLen:64})}const Rho=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Id=Uint8Array.from({length:16},((e,t)=>t)),Pi=Id.map((e=>(9*e+5)%16));let idxL=[Id],idxR=[Pi];for(let e=0;e<4;e++)for(let t of[idxL,idxR])t.push(t[e].map((e=>Rho[e])));const shifts=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((e=>new Uint8Array(e))),shiftsL=idxL.map(((e,t)=>e.map((e=>shifts[t][e])))),shiftsR=idxR.map(((e,t)=>e.map((e=>shifts[t][e])))),Kl=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Kr=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),rotl$1=(e,t)=>e<<t|e>>>32-t;function f(e,t,n,r){return 0===e?t^n^r:1===e?t&n|~t&r:2===e?(t|~n)^r:3===e?t&r|n&~r:t^(n|~r)}const BUF=new Uint32Array(16);class RIPEMD160 extends SHA2{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:t,h2:n,h3:r,h4:o}=this;return[e,t,n,r,o]}set(e,t,n,r,o){this.h0=0|e,this.h1=0|t,this.h2=0|n,this.h3=0|r,this.h4=0|o}process(e,t){for(let n=0;n<16;n++,t+=4)BUF[n]=e.getUint32(t,!0);let n=0|this.h0,r=n,o=0|this.h1,s=o,i=0|this.h2,a=i,l=0|this.h3,c=l,d=0|this.h4,h=d;for(let e=0;e<5;e++){const t=4-e,u=Kl[e],p=Kr[e],g=idxL[e],m=idxR[e],b=shiftsL[e],y=shiftsR[e];for(let t=0;t<16;t++){const r=rotl$1(n+f(e,o,i,l)+BUF[g[t]]+u,b[t])+d|0;n=d,d=l,l=0|rotl$1(i,10),i=o,o=r}for(let e=0;e<16;e++){const n=rotl$1(r+f(t,s,a,c)+BUF[m[e]]+p,y[e])+h|0;r=h,h=c,c=0|rotl$1(a,10),a=s,s=n}}this.set(this.h1+i+c|0,this.h2+l+h|0,this.h3+d+r|0,this.h4+n+s|0,this.h0+o+a|0)}roundClean(){BUF.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const ripemd160=wrapConstructor((()=>new RIPEMD160)),Point=secp256k1.ProjectivePoint,base58check=base58check$1(sha256);function bytesToNumber(e){return BigInt(`0x${bytesToHex(e)}`)}function numberToBytes(e){return hexToBytes(e.toString(16).padStart(64,"0"))}const MASTER_SECRET=utf8ToBytes$1("Bitcoin seed"),BITCOIN_VERSIONS={private:76066276,public:76067358},HARDENED_OFFSET=2147483648,hash160=e=>ripemd160(sha256(e)),fromU32=e=>createView(e).getUint32(0,!1),toU32=e=>{if(!Number.isSafeInteger(e)||e<0||e>2**32-1)throw new Error(`Invalid number=${e}. Should be from 0 to 2 ** 32 - 1`);const t=new Uint8Array(4);return createView(t).setUint32(0,e,!1),t};class HDKey{get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return fromU32(this.pubHash)}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this.privKeyBytes||null}get publicKey(){return this.pubKey||null}get privateExtendedKey(){const e=this.privateKey;if(!e)throw new Error("No private key");return base58check.encode(this.serialize(this.versions.private,concatBytes(new Uint8Array([0]),e)))}get publicExtendedKey(){if(!this.pubKey)throw new Error("No public key");return base58check.encode(this.serialize(this.versions.public,this.pubKey))}static fromMasterSeed(e,t=BITCOIN_VERSIONS){if(bytes$1(e),8*e.length<128||8*e.length>512)throw new Error(`HDKey: wrong seed length=${e.length}. Should be between 128 and 512 bits; 256 bits is advised)`);const n=hmac$1(sha512,MASTER_SECRET,e);return new HDKey({versions:t,chainCode:n.slice(32),privateKey:n.slice(0,32)})}static fromExtendedKey(e,t=BITCOIN_VERSIONS){const n=base58check.decode(e),r=createView(n),o=r.getUint32(0,!1),s={versions:t,depth:n[4],parentFingerprint:r.getUint32(5,!1),index:r.getUint32(9,!1),chainCode:n.slice(13,45)},i=n.slice(45),a=0===i[0];if(o!==t[a?"private":"public"])throw new Error("Version mismatch");return new HDKey(a?{...s,privateKey:i.slice(1)}:{...s,publicKey:i})}static fromJSON(e){return HDKey.fromExtendedKey(e.xpriv)}constructor(e){if(this.depth=0,this.index=0,this.chainCode=null,this.parentFingerprint=0,!e||"object"!=typeof e)throw new Error("HDKey.constructor must not be called directly");if(this.versions=e.versions||BITCOIN_VERSIONS,this.depth=e.depth||0,this.chainCode=e.chainCode,this.index=e.index||0,this.parentFingerprint=e.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(e.publicKey&&e.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(e.privateKey){if(!secp256k1.utils.isValidPrivateKey(e.privateKey))throw new Error("Invalid private key");this.privKey="bigint"==typeof e.privateKey?e.privateKey:bytesToNumber(e.privateKey),this.privKeyBytes=numberToBytes(this.privKey),this.pubKey=secp256k1.getPublicKey(e.privateKey,!0)}else{if(!e.publicKey)throw new Error("HDKey: no public or private key provided");this.pubKey=Point.fromHex(e.publicKey).toRawBytes(!0)}this.pubHash=hash160(this.pubKey)}derive(e){if(!/^[mM]'?/.test(e))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(e))return this;const t=e.replace(/^[mM]'?\//,"").split("/");let n=this;for(const e of t){const t=/^(\d+)('?)$/.exec(e);if(!t||3!==t.length)throw new Error(`Invalid child index: ${e}`);let r=+t[1];if(!Number.isSafeInteger(r)||r>=HARDENED_OFFSET)throw new Error("Invalid index");"'"===t[2]&&(r+=HARDENED_OFFSET),n=n.deriveChild(r)}return n}deriveChild(e){if(!this.pubKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let t=toU32(e);if(e>=HARDENED_OFFSET){const e=this.privateKey;if(!e)throw new Error("Could not derive hardened child key");t=concatBytes(new Uint8Array([0]),e,t)}else t=concatBytes(this.pubKey,t);const n=hmac$1(sha512,this.chainCode,t),r=bytesToNumber(n.slice(0,32)),o=n.slice(32);if(!secp256k1.utils.isValidPrivateKey(r))throw new Error("Tweak bigger than curve order");const s={versions:this.versions,chainCode:o,depth:this.depth+1,parentFingerprint:this.fingerprint,index:e};try{if(this.privateKey){const e=mod(this.privKey+r,secp256k1.CURVE.n);if(!secp256k1.utils.isValidPrivateKey(e))throw new Error("The tweak was out of range or the resulted private key is invalid");s.privateKey=e}else{const e=Point.fromHex(this.pubKey).add(Point.fromPrivateKey(r));if(e.equals(Point.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");s.publicKey=e.toRawBytes(!0)}return new HDKey(s)}catch(t){return this.deriveChild(e+1)}}sign(e){if(!this.privateKey)throw new Error("No privateKey set!");return bytes$1(e,32),secp256k1.sign(e,this.privKey).toCompactRawBytes()}verify(e,t){if(bytes$1(e,32),bytes$1(t,64),!this.publicKey)throw new Error("No publicKey set!");let n;try{n=secp256k1.Signature.fromCompact(t)}catch(e){return!1}return secp256k1.verify(n,e,this.publicKey)}wipePrivateData(){return this.privKey=void 0,this.privKeyBytes&&(this.privKeyBytes.fill(0),this.privKeyBytes=void 0),this}toJSON(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}}serialize(e,t){if(!this.chainCode)throw new Error("No chainCode set");return bytes$1(t,33),concatBytes(toU32(e),new Uint8Array([this.depth]),toU32(this.parentFingerprint),toU32(this.index),this.chainCode,t)}}
15
+ /*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */const u8a=e=>e instanceof Uint8Array,u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!isLE)throw new Error("Non little-endian hardware is not supported");function utf8ToBytes(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function toBytes(e){if("string"==typeof e&&(e=utf8ToBytes(e)),!u8a(e))throw new Error("expected Uint8Array, got "+typeof e);return e}const isPlainObject=e=>"[object Object]"===Object.prototype.toString.call(e)&&e.constructor===Object;function checkOpts(e,t){if(void 0!==t&&("object"!=typeof t||!isPlainObject(t)))throw new Error("options must be object or undefined");return Object.assign(e,t)}function ensureBytes(e,t){if(!(e instanceof Uint8Array))throw new Error("Uint8Array expected");if(e.length!==t)throw new Error(`Uint8Array length ${t} expected`)}function equalBytes(e,t){if(e.length!==t.length)throw new Error("equalBytes: Different size of Uint8Arrays");let n=!0;for(let r=0;r<e.length;r++)n&&(n=e[r]===t[r]);return n}function number(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function bool(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)}function bytes(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function hash(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("hash must be wrapped by utils.wrapConstructor");number(e.outputLen),number(e.blockLen)}function exists(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output(e,t){bytes(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const assert={number:number,bool:bool,bytes:bytes,hash:hash,exists:exists,output:output},u8to16=(e,t)=>255&e[t++]|(255&e[t++])<<8;class Poly1305{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,ensureBytes(e=toBytes(e),32);const t=u8to16(e,0),n=u8to16(e,2),r=u8to16(e,4),o=u8to16(e,6),s=u8to16(e,8),i=u8to16(e,10),a=u8to16(e,12),l=u8to16(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|n<<3),this.r[2]=7939&(n>>>10|r<<6),this.r[3]=8191&(r>>>7|o<<9),this.r[4]=255&(o>>>4|s<<12),this.r[5]=s>>>1&8190,this.r[6]=8191&(s>>>14|i<<2),this.r[7]=8065&(i>>>11|a<<5),this.r[8]=8191&(a>>>8|l<<8),this.r[9]=l>>>5&127;for(let t=0;t<8;t++)this.pad[t]=u8to16(e,16+2*t)}process(e,t,n=!1){const r=n?0:2048,{h:o,r:s}=this,i=s[0],a=s[1],l=s[2],c=s[3],d=s[4],h=s[5],u=s[6],p=s[7],f=s[8],g=s[9],m=u8to16(e,t+0),b=u8to16(e,t+2),y=u8to16(e,t+4),w=u8to16(e,t+6),v=u8to16(e,t+8),k=u8to16(e,t+10),x=u8to16(e,t+12),E=u8to16(e,t+14);let C=o[0]+(8191&m),$=o[1]+(8191&(m>>>13|b<<3)),S=o[2]+(8191&(b>>>10|y<<6)),_=o[3]+(8191&(y>>>7|w<<9)),A=o[4]+(8191&(w>>>4|v<<12)),N=o[5]+(v>>>1&8191),L=o[6]+(8191&(v>>>14|k<<2)),R=o[7]+(8191&(k>>>11|x<<5)),T=o[8]+(8191&(x>>>8|E<<8)),U=o[9]+(E>>>5|r),B=0,I=B+C*i+$*(5*g)+S*(5*f)+_*(5*p)+A*(5*u);B=I>>>13,I&=8191,I+=N*(5*h)+L*(5*d)+R*(5*c)+T*(5*l)+U*(5*a),B+=I>>>13,I&=8191;let M=B+C*a+$*i+S*(5*g)+_*(5*f)+A*(5*p);B=M>>>13,M&=8191,M+=N*(5*u)+L*(5*h)+R*(5*d)+T*(5*c)+U*(5*l),B+=M>>>13,M&=8191;let O=B+C*l+$*a+S*i+_*(5*g)+A*(5*f);B=O>>>13,O&=8191,O+=N*(5*p)+L*(5*u)+R*(5*h)+T*(5*d)+U*(5*c),B+=O>>>13,O&=8191;let P=B+C*c+$*l+S*a+_*i+A*(5*g);B=P>>>13,P&=8191,P+=N*(5*f)+L*(5*p)+R*(5*u)+T*(5*h)+U*(5*d),B+=P>>>13,P&=8191;let D=B+C*d+$*c+S*l+_*a+A*i;B=D>>>13,D&=8191,D+=N*(5*g)+L*(5*f)+R*(5*p)+T*(5*u)+U*(5*h),B+=D>>>13,D&=8191;let H=B+C*h+$*d+S*c+_*l+A*a;B=H>>>13,H&=8191,H+=N*i+L*(5*g)+R*(5*f)+T*(5*p)+U*(5*u),B+=H>>>13,H&=8191;let F=B+C*u+$*h+S*d+_*c+A*l;B=F>>>13,F&=8191,F+=N*a+L*i+R*(5*g)+T*(5*f)+U*(5*p),B+=F>>>13,F&=8191;let K=B+C*p+$*u+S*h+_*d+A*c;B=K>>>13,K&=8191,K+=N*l+L*a+R*i+T*(5*g)+U*(5*f),B+=K>>>13,K&=8191;let j=B+C*f+$*p+S*u+_*h+A*d;B=j>>>13,j&=8191,j+=N*c+L*l+R*a+T*i+U*(5*g),B+=j>>>13,j&=8191;let z=B+C*g+$*f+S*p+_*u+A*h;B=z>>>13,z&=8191,z+=N*d+L*c+R*l+T*a+U*i,B+=z>>>13,z&=8191,B=(B<<2)+B|0,B=B+I|0,I=8191&B,B>>>=13,M+=B,o[0]=I,o[1]=M,o[2]=O,o[3]=P,o[4]=D,o[5]=H,o[6]=F,o[7]=K,o[8]=j,o[9]=z}finalize(){const{h:e,pad:t}=this,n=new Uint16Array(10);let r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=8191;e[0]+=5*r,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,n[0]=e[0]+5,r=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+r,r=n[t]>>>13,n[t]&=8191;n[9]-=8192;let o=(1^r)-1;for(let e=0;e<10;e++)n[e]&=o;o=~o;for(let t=0;t<10;t++)e[t]=e[t]&o|n[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let s=e[0]+t[0];e[0]=65535&s;for(let n=1;n<8;n++)s=(e[n]+t[n]|0)+(s>>>16)|0,e[n]=65535&s}update(e){assert.exists(this);const{buffer:t,blockLen:n}=this,r=(e=toBytes(e)).length;for(let o=0;o<r;){const s=Math.min(n-this.pos,r-o);if(s!==n)t.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(t,0,!1),this.pos=0);else for(;n<=r-o;o+=n)this.process(e,o)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(e){assert.exists(this),assert.output(e,this),this.finished=!0;const{buffer:t,h:n}=this;let{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let o=0;for(let t=0;t<8;t++)e[o++]=n[t]>>>0,e[o++]=n[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}}function wrapConstructorWithKey(e){const t=(t,n)=>e(n).update(toBytes(t)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}wrapConstructorWithKey((e=>new Poly1305(e)));const sigma16=utf8ToBytes("expand 16-byte k"),sigma32=utf8ToBytes("expand 32-byte k"),sigma16_32=u32(sigma16),sigma32_32=u32(sigma32),isAligned32=e=>!(e.byteOffset%4),salsaBasic=e=>{const{core:t,rounds:n,counterRight:r,counterLen:o,allow128bitKeys:s,extendNonceFn:i,blockLen:a}=checkOpts({rounds:20,counterRight:!1,counterLen:8,allow128bitKeys:!0,blockLen:64},e);assert.number(o),assert.number(n),assert.number(a),assert.bool(r),assert.bool(s);const l=a/4;if(a%4!=0)throw new Error("Salsa/ChaCha: blockLen must be aligned to 4 bytes");return(e,c,d,h,u=0)=>{if(assert.bytes(e),assert.bytes(c),assert.bytes(d),h||(h=new Uint8Array(d.length)),assert.bytes(h),assert.number(u),u<0||u>=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");if(h.length<d.length)throw new Error(`Salsa/ChaCha: output (${h.length}) is shorter than data (${d.length})`);const p=[];let f,g;if(32===e.length)f=e,g=sigma32_32;else{if(16!==e.length||!s)throw new Error(`Salsa/ChaCha: invalid 32-byte key, got length=${e.length}`);f=new Uint8Array(32),f.set(e),f.set(e,16),g=sigma16_32,p.push(f)}if(i){if(c.length<=16)throw new Error("Salsa/ChaCha: extended nonce must be bigger than 16 bytes");f=i(g,f,c.subarray(0,16),new Uint8Array(32)),p.push(f),c=c.subarray(16)}const m=16-o;if(c.length!==m)throw new Error(`Salsa/ChaCha: nonce must be ${m} or 16 bytes`);if(12!==m){const e=new Uint8Array(12);e.set(c,r?0:12-c.length),p.push(c=e)}const b=new Uint8Array(a),y=u32(b),w=u32(f),v=u32(c),k=isAligned32(d)&&u32(d),x=isAligned32(h)&&u32(h);p.push(y);const E=d.length;for(let e=0,r=u;e<E;r++){if(t(g,w,v,y,r,n),r>=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");const o=Math.min(a,E-e);if(o===a&&x&&k){const t=e/4;if(e%4!=0)throw new Error("Salsa/ChaCha: invalid block position");for(let e=0;e<l;e++)x[t+e]=k[t+e]^y[e];e+=a}else{for(let t=0;t<o;t++)h[e+t]=d[e+t]^b[t];e+=o}}for(let e=0;e<p.length;e++)p[e].fill(0);return h}},rotl=(e,t)=>e<<t|e>>>32-t;function chachaCore(e,t,n,r,o,s=20){let i=e[0],a=e[1],l=e[2],c=e[3],d=t[0],h=t[1],u=t[2],p=t[3],f=t[4],g=t[5],m=t[6],b=t[7],y=o,w=n[0],v=n[1],k=n[2],x=i,E=a,C=l,$=c,S=d,_=h,A=u,N=p,L=f,R=g,T=m,U=b,B=y,I=w,M=v,O=k;for(let e=0;e<s;e+=2)x=x+S|0,B=rotl(B^x,16),L=L+B|0,S=rotl(S^L,12),x=x+S|0,B=rotl(B^x,8),L=L+B|0,S=rotl(S^L,7),E=E+_|0,I=rotl(I^E,16),R=R+I|0,_=rotl(_^R,12),E=E+_|0,I=rotl(I^E,8),R=R+I|0,_=rotl(_^R,7),C=C+A|0,M=rotl(M^C,16),T=T+M|0,A=rotl(A^T,12),C=C+A|0,M=rotl(M^C,8),T=T+M|0,A=rotl(A^T,7),$=$+N|0,O=rotl(O^$,16),U=U+O|0,N=rotl(N^U,12),$=$+N|0,O=rotl(O^$,8),U=U+O|0,N=rotl(N^U,7),x=x+_|0,O=rotl(O^x,16),T=T+O|0,_=rotl(_^T,12),x=x+_|0,O=rotl(O^x,8),T=T+O|0,_=rotl(_^T,7),E=E+A|0,B=rotl(B^E,16),U=U+B|0,A=rotl(A^U,12),E=E+A|0,B=rotl(B^E,8),U=U+B|0,A=rotl(A^U,7),C=C+N|0,I=rotl(I^C,16),L=L+I|0,N=rotl(N^L,12),C=C+N|0,I=rotl(I^C,8),L=L+I|0,N=rotl(N^L,7),$=$+S|0,M=rotl(M^$,16),R=R+M|0,S=rotl(S^R,12),$=$+S|0,M=rotl(M^$,8),R=R+M|0,S=rotl(S^R,7);let P=0;r[P++]=i+x|0,r[P++]=a+E|0,r[P++]=l+C|0,r[P++]=c+$|0,r[P++]=d+S|0,r[P++]=h+_|0,r[P++]=u+A|0,r[P++]=p+N|0,r[P++]=f+L|0,r[P++]=g+R|0,r[P++]=m+T|0,r[P++]=b+U|0,r[P++]=y+B|0,r[P++]=w+I|0,r[P++]=v+M|0,r[P++]=k+O|0}const chacha20=salsaBasic({core:chachaCore,counterRight:!1,counterLen:4,allow128bitKeys:!1});class HMAC extends Hash$1{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,assert$2.hash(e);const n=toBytes$2(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<o.length;e++)o[e]^=54;this.iHash.update(o),this.oHash=e.create();for(let e=0;e<o.length;e++)o[e]^=106;this.oHash.update(o),o.fill(0)}update(e){return assert$2.exists(this),this.iHash.update(e),this}digestInto(e){assert$2.exists(this),assert$2.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:o,blockLen:s,outputLen:i}=this;return e.finished=r,e.destroyed=o,e.blockLen=s,e.outputLen=i,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const hmac=(e,t,n)=>new HMAC(e,t).update(n).digest();function extract$1(e,t,n){return assert$2.hash(e),void 0===n&&(n=new Uint8Array(e.outputLen)),hmac(e,toBytes$2(n),toBytes$2(t))}hmac.create=(e,t)=>new HMAC(e,t);const HKDF_COUNTER$1=new Uint8Array([0]),EMPTY_BUFFER$1=new Uint8Array;function expand$1(e,t,n,r=32){if(assert$2.hash(e),assert$2.number(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/e.outputLen),s=new Uint8Array(o*e.outputLen),i=hmac.create(e,t),a=i._cloneInto(),l=new Uint8Array(i.outputLen);for(let t=0;t<o;t++)HKDF_COUNTER$1[0]=t+1,a.update(0===t?EMPTY_BUFFER$1:l).update(n).update(HKDF_COUNTER$1).digestInto(l),s.set(l,e.outputLen*t),i._cloneInto(a);return i.destroy(),a.destroy(),l.fill(0),HKDF_COUNTER$1.fill(0),s.slice(0,r)}const hkdf=(e,t,n,r,o)=>expand$1(e,extract$1(e,t,n),r,o);var __defProp=Object.defineProperty,__export=(e,t)=>{for(var n in t)__defProp(e,n,{get:t[n],enumerable:!0})};function generatePrivateKey(){return bytesToHex$1(schnorr.utils.randomPrivateKey())}function getPublicKey(e){return bytesToHex$1(schnorr.getPublicKey(e))}var utils_exports={};__export(utils_exports,{MessageNode:()=>MessageNode,MessageQueue:()=>MessageQueue,insertEventIntoAscendingList:()=>insertEventIntoAscendingList,insertEventIntoDescendingList:()=>insertEventIntoDescendingList,normalizeURL:()=>normalizeURL,utf8Decoder:()=>utf8Decoder,utf8Encoder:()=>utf8Encoder});var utf8Decoder=new TextDecoder("utf-8"),utf8Encoder=new TextEncoder;function normalizeURL(e){let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),("80"===t.port&&"ws:"===t.protocol||"443"===t.port&&"wss:"===t.protocol)&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}function insertEventIntoDescendingList(e,t){let n,r=0,o=e.length-1,s=r;if(o<0)s=0;else if(t.created_at<e[o].created_at)s=o+1;else if(t.created_at>=e[r].created_at)s=r;else for(;;){if(o<=r+1){s=o;break}if(n=Math.floor(r+(o-r)/2),e[n].created_at>t.created_at)r=n;else{if(!(e[n].created_at<t.created_at)){s=n;break}o=n}}return e[s]?.id!==t.id?[...e.slice(0,s),t,...e.slice(s)]:e}function insertEventIntoAscendingList(e,t){let n,r=0,o=e.length-1,s=r;if(o<0)s=0;else if(t.created_at>e[o].created_at)s=o+1;else if(t.created_at<=e[r].created_at)s=r;else for(;;){if(o<=r+1){s=o;break}if(n=Math.floor(r+(o-r)/2),e[n].created_at<t.created_at)r=n;else{if(!(e[n].created_at>t.created_at)){s=n;break}o=n}}return e[s]?.id!==t.id?[...e.slice(0,s),t,...e.slice(s)]:e}var MessageNode=class{_value;_next;get value(){return this._value}set value(e){this._value=e}get next(){return this._next}set next(e){this._next=e}constructor(e){this._value=e,this._next=null}},MessageQueue=class{_first;_last;get first(){return this._first}set first(e){this._first=e}get last(){return this._last}set last(e){this._last=e}_size;get size(){return this._size}set size(e){this._size=e}constructor(){this._first=null,this._last=null,this._size=0}enqueue(e){const t=new MessageNode(e);return 0!==this._size&&this._last?(this._last.next=t,this._last=t):(this._first=t,this._last=t),this._size++,!0}dequeue(){if(0===this._size||!this._first)return null;let e=this._first;return this._first=e.next,e.next=null,this._size--,e.value}},verifiedSymbol=Symbol("verified");function getBlankEvent(e=255){return{kind:e,content:"",tags:[],created_at:0}}function finishEvent(e,t){const n=e;return n.pubkey=getPublicKey(t),n.id=getEventHash(n),n.sig=getSignature(n,t),n[verifiedSymbol]=!0,n}function serializeEvent(e){if(!validateEvent(e))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}function getEventHash(e){return bytesToHex$1(sha256$1(utf8Encoder.encode(serializeEvent(e))))}var isRecord=e=>e instanceof Object;function validateEvent(e){if(!isRecord(e))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let n=e.tags[t];if(!Array.isArray(n))return!1;for(let e=0;e<n.length;e++)if("object"==typeof n[e])return!1}return!0}function verifySignature(e){if("boolean"==typeof e[verifiedSymbol])return e[verifiedSymbol];const t=getEventHash(e);if(t!==e.id)return e[verifiedSymbol]=!1;try{return e[verifiedSymbol]=schnorr.verify(e.sig,t,e.pubkey)}catch(t){return e[verifiedSymbol]=!1}}function getSignature(e,t){return bytesToHex$1(schnorr.sign(getEventHash(e),t))}function matchFilter(e,t){if(e.ids&&-1===e.ids.indexOf(t.id)&&!e.ids.some((e=>t.id.startsWith(e))))return!1;if(e.kinds&&-1===e.kinds.indexOf(t.kind))return!1;if(e.authors&&-1===e.authors.indexOf(t.pubkey)&&!e.authors.some((e=>t.pubkey.startsWith(e))))return!1;for(let n in e)if("#"===n[0]){let r=e[`#${n.slice(1)}`];if(r&&!t.tags.find((([e,t])=>e===n.slice(1)&&-1!==r.indexOf(t))))return!1}return!(e.since&&t.created_at<e.since)&&!(e.until&&t.created_at>e.until)}function matchFilters(e,t){for(let n=0;n<e.length;n++)if(matchFilter(e[n],t))return!0;return!1}var fakejson_exports={};function getHex64(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,o=e.slice(r).indexOf('"')+r+1;return e.slice(o,o+64)}function getInt(e,t){let n=t.length,r=e.indexOf(`"${t}":`)+n+3,o=e.slice(r),s=Math.min(o.indexOf(","),o.indexOf("}"));return parseInt(o.slice(0,s),10)}function getSubscriptionId(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let r=t+7+1+n,o=e.slice(r+1,80).indexOf('"');if(-1===o)return null;let s=r+1+o;return e.slice(r+1,s)}function matchEventId(e,t){return t===getHex64(e,"id")}function matchEventPubkey(e,t){return t===getHex64(e,"pubkey")}function matchEventKind(e,t){return t===getInt(e,"kind")}__export(fakejson_exports,{getHex64:()=>getHex64,getInt:()=>getInt,getSubscriptionId:()=>getSubscriptionId,matchEventId:()=>matchEventId,matchEventKind:()=>matchEventKind,matchEventPubkey:()=>matchEventPubkey});var newListeners=()=>({connect:[],disconnect:[],error:[],notice:[],auth:[]});function relayInit(e,t={}){let{listTimeout:n=3e3,getTimeout:r=3e3,countTimeout:o=3e3}=t;var s,i,a={},l=newListeners(),c={},d={};function h(){return 1===s?.readyState}async function u(e){let t=JSON.stringify(e);if(h()||(await new Promise((e=>setTimeout(e,1e3))),h()))try{s.send(t)}catch(e){console.log(e)}}const p=(e,{verb:t="REQ",skipVerification:n=!1,alreadyHaveEvent:r=null,id:o=Math.random().toString().slice(2)}={})=>{let s=o;a[s]={id:s,filters:e,skipVerification:n,alreadyHaveEvent:r},u([t,s,...e]);let i={sub:(t,o={})=>p(t||e,{skipVerification:o.skipVerification||n,alreadyHaveEvent:o.alreadyHaveEvent||r,id:s}),unsub:()=>{delete a[s],delete c[s],u(["CLOSE",s])},on:(e,t)=>{c[s]=c[s]||{event:[],count:[],eose:[]},c[s][e].push(t)},off:(e,t)=>{let n=c[s],r=n[e].indexOf(t);r>=0&&n[e].splice(r,1)},get events(){return eventsGenerator(i)}};return i};function f(e,t){return new Promise(((n,r)=>{if(!e.id)return void r(new Error(`event ${e} has no id`));let o=e.id;u([t,e]),d[o]={resolve:n,reject:r}}))}return{url:e,sub:p,on:(e,t)=>{l[e].push(t),"connect"===e&&1===s?.readyState&&t()},off:(e,t)=>{let n=l[e].indexOf(t);-1!==n&&l[e].splice(n,1)},list:(e,t)=>new Promise((r=>{let o=p(e,t),s=[],i=setTimeout((()=>{o.unsub(),r(s)}),n);o.on("eose",(()=>{o.unsub(),clearTimeout(i),r(s)})),o.on("event",(e=>{s.push(e)}))})),get:(e,t)=>new Promise((n=>{let o=p([e],t),s=setTimeout((()=>{o.unsub(),n(null)}),r);o.on("event",(e=>{o.unsub(),clearTimeout(s),n(e)}))})),count:e=>new Promise((t=>{let n=p(e,{...p,verb:"COUNT"}),r=setTimeout((()=>{n.unsub(),t(null)}),o);n.on("count",(e=>{n.unsub(),clearTimeout(r),t(e)}))})),async publish(e){await f(e,"EVENT")},async auth(e){await f(e,"AUTH")},connect:async function(){h()||await async function(){return i||(i=new Promise(((t,n)=>{try{s=new WebSocket(e)}catch(e){n(e)}s.onopen=()=>{l.connect.forEach((e=>e())),t()},s.onerror=()=>{i=void 0,l.error.forEach((e=>e())),n()},s.onclose=async()=>{i=void 0,l.disconnect.forEach((e=>e()))};let r,o=new MessageQueue;function h(){if(0===o.size)return clearInterval(r),void(r=null);var t=o.dequeue();if(!t)return;let n=getSubscriptionId(t);if(n){let r=a[n];if(r&&r.alreadyHaveEvent&&r.alreadyHaveEvent(getHex64(t,"id"),e))return}try{let e=JSON.parse(t);switch(e[0]){case"EVENT":{let t=e[1],n=e[2];return void(validateEvent(n)&&a[t]&&(a[t].skipVerification||verifySignature(n))&&matchFilters(a[t].filters,n)&&(a[t],(c[t]?.event||[]).forEach((e=>e(n)))))}case"COUNT":let t=e[1],n=e[2];return void(a[t]&&(c[t]?.count||[]).forEach((e=>e(n))));case"EOSE":{let t=e[1];return void(t in c&&(c[t].eose.forEach((e=>e())),c[t].eose=[]))}case"OK":{let t=e[1],n=e[2],r=e[3]||"";if(t in d){let{resolve:e,reject:o}=d[t];n?e(null):o(new Error(r))}return}case"NOTICE":let r=e[1];return void l.notice.forEach((e=>e(r)));case"AUTH":{let t=e[1];return void l.auth?.forEach((e=>e(t)))}}}catch(e){return}}s.onmessage=e=>{o.enqueue(e.data),r||(r=setInterval(h,0))}})),i)}()},close(){l=newListeners(),c={},d={},s?.readyState===WebSocket.OPEN&&s.close()},get status(){return s?.readyState??3}}}async function*eventsGenerator(e){let t;const n=[],r=e=>{t?(t(e),t=void 0):n.push(e)};e.on("event",r);try{for(;;)if(n.length>0)yield n.shift();else{const e=await new Promise((e=>{t=e}));yield e}}finally{e.off("event",r)}}var nip19_exports={};__export(nip19_exports,{BECH32_REGEX:()=>BECH32_REGEX,decode:()=>decode,naddrEncode:()=>naddrEncode,neventEncode:()=>neventEncode,noteEncode:()=>noteEncode,nprofileEncode:()=>nprofileEncode,npubEncode:()=>npubEncode,nrelayEncode:()=>nrelayEncode,nsecEncode:()=>nsecEncode});var Bech32MaxSize=5e3,BECH32_REGEX=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function integerToUint8Array(e){const t=new Uint8Array(4);return t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t}function decode(e){let{prefix:t,words:n}=bech32$2.decode(e,Bech32MaxSize),r=new Uint8Array(bech32$2.fromWords(n));switch(t){case"nprofile":{let e=parseTLV(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:bytesToHex$1(e[0][0]),relays:e[1]?e[1].map((e=>utf8Decoder.decode(e))):[]}}}case"nevent":{let e=parseTLV(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(e[3]&&4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:bytesToHex$1(e[0][0]),relays:e[1]?e[1].map((e=>utf8Decoder.decode(e))):[],author:e[2]?.[0]?bytesToHex$1(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(bytesToHex$1(e[3][0]),16):void 0}}}case"naddr":{let e=parseTLV(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:utf8Decoder.decode(e[0][0]),pubkey:bytesToHex$1(e[2][0]),kind:parseInt(bytesToHex$1(e[3][0]),16),relays:e[1]?e[1].map((e=>utf8Decoder.decode(e))):[]}}}case"nrelay":{let e=parseTLV(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nrelay");return{type:"nrelay",data:utf8Decoder.decode(e[0][0])}}case"nsec":case"npub":case"note":return{type:t,data:bytesToHex$1(r)};default:throw new Error(`unknown prefix ${t}`)}}function parseTLV(e){let t={},n=e;for(;n.length>0;){let e=n[0],r=n[1];if(!r)throw new Error(`malformed TLV ${e}`);let o=n.slice(2,2+r);if(n=n.slice(2+r),o.length<r)throw new Error(`not enough data to read on TLV ${e}`);t[e]=t[e]||[],t[e].push(o)}return t}function nsecEncode(e){return encodeBytes("nsec",e)}function npubEncode(e){return encodeBytes("npub",e)}function noteEncode(e){return encodeBytes("note",e)}function encodeBech32(e,t){let n=bech32$2.toWords(t);return bech32$2.encode(e,n,Bech32MaxSize)}function encodeBytes(e,t){return encodeBech32(e,hexToBytes$1(t))}function nprofileEncode(e){return encodeBech32("nprofile",encodeTLV({0:[hexToBytes$1(e.pubkey)],1:(e.relays||[]).map((e=>utf8Encoder.encode(e)))}))}function neventEncode(e){let t;return null!=e.kind&&(t=integerToUint8Array(e.kind)),encodeBech32("nevent",encodeTLV({0:[hexToBytes$1(e.id)],1:(e.relays||[]).map((e=>utf8Encoder.encode(e))),2:e.author?[hexToBytes$1(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function naddrEncode(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),encodeBech32("naddr",encodeTLV({0:[utf8Encoder.encode(e.identifier)],1:(e.relays||[]).map((e=>utf8Encoder.encode(e))),2:[hexToBytes$1(e.pubkey)],3:[new Uint8Array(t)]}))}function nrelayEncode(e){return encodeBech32("nrelay",encodeTLV({0:[utf8Encoder.encode(e)]}))}function encodeTLV(e){let t=[];return Object.entries(e).forEach((([e,n])=>{n.forEach((n=>{let r=new Uint8Array(n.length+2);r.set([parseInt(e)],0),r.set([n.length],1),r.set(n,2),t.push(r)}))})),concatBytes$1(...t)}var nip04_exports={};async function encrypt$1(e,t,n){const r=getNormalizedX(secp256k1.getSharedSecret(e,"02"+t));let o=Uint8Array.from(randomBytes$1(16)),s=utf8Encoder.encode(n),i=await crypto.subtle.importKey("raw",r,{name:"AES-CBC"},!1,["encrypt"]),a=await crypto.subtle.encrypt({name:"AES-CBC",iv:o},i,s);return`${base64$1.encode(new Uint8Array(a))}?iv=${base64$1.encode(new Uint8Array(o.buffer))}`}async function decrypt$1(e,t,n){let[r,o]=n.split("?iv="),s=getNormalizedX(secp256k1.getSharedSecret(e,"02"+t)),i=await crypto.subtle.importKey("raw",s,{name:"AES-CBC"},!1,["decrypt"]),a=base64$1.decode(r),l=base64$1.decode(o),c=await crypto.subtle.decrypt({name:"AES-CBC",iv:l},i,a);return utf8Decoder.decode(c)}function getNormalizedX(e){return e.slice(1,33)}__export(nip04_exports,{decrypt:()=>decrypt$1,encrypt:()=>encrypt$1}),"undefined"!=typeof crypto&&!crypto.subtle&&crypto.webcrypto&&(crypto.subtle=crypto.webcrypto.subtle);var nip05_exports={};__export(nip05_exports,{NIP05_REGEX:()=>NIP05_REGEX$1,queryProfile:()=>queryProfile,searchDomain:()=>searchDomain,useFetchImplementation:()=>useFetchImplementation});var NIP05_REGEX$1=/^(?:([\w.+-]+)@)?([\w.-]+)$/,_fetch;try{_fetch=fetch}catch{}function useFetchImplementation(e){_fetch=e}async function searchDomain(e,t=""){try{return(await(await _fetch(`https://${e}/.well-known/nostr.json?name=${t}`)).json()).names}catch(e){return{}}}async function queryProfile(e){const t=e.match(NIP05_REGEX$1);if(!t)return null;const[n,r="_",o]=t;try{const e=await _fetch(`https://${o}/.well-known/nostr.json?name=${r}`),{names:t,relays:n}=parseNIP05Result$1(await e.json()),s=t[r];return s?{pubkey:s,relays:n?.[s]}:null}catch(e){return null}}function parseNIP05Result$1(e){const t={names:{}};for(const[n,r]of Object.entries(e.names))"string"==typeof n&&"string"==typeof r&&(t.names[n]=r);if(e.relays){t.relays={};for(const[n,r]of Object.entries(e.relays))"string"==typeof n&&Array.isArray(r)&&(t.relays[n]=r.filter((e=>"string"==typeof e)))}return t}var nip06_exports={};function privateKeyFromSeedWords(e,t){let n=HDKey.fromMasterSeed(mnemonicToSeedSync(e,t)).derive("m/44'/1237'/0'/0/0").privateKey;if(!n)throw new Error("could not derive private key");return bytesToHex$1(n)}function generateSeedWords(){return generateMnemonic(wordlist)}function validateWords(e){return validateMnemonic(e,wordlist)}__export(nip06_exports,{generateSeedWords:()=>generateSeedWords,privateKeyFromSeedWords:()=>privateKeyFromSeedWords,validateWords:()=>validateWords});var nip10_exports={};function parse(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[]},n=[];for(const r of e.tags)"e"===r[0]&&r[1]&&n.push(r),"p"===r[0]&&r[1]&&t.profiles.push({pubkey:r[1],relays:r[2]?[r[2]]:[]});for(let e=0;e<n.length;e++){const r=n[e],[o,s,i,a]=r,l={id:s,relays:i?[i]:[]},c=0===e,d=e===n.length-1;"root"!==a?"reply"!==a?"mention"!==a?c?t.root=l:d?t.reply=l:t.mentions.push(l):t.mentions.push(l):t.reply=l:t.root=l}return t}__export(nip10_exports,{parse:()=>parse});var nip13_exports={};function getPow(e){let t=0;for(let n=0;n<e.length;n++){const r=parseInt(e[n],16);if(0!==r){t+=Math.clz32(r)-28;break}t+=4}return t}function minePow(e,t){let n=0;const r=e,o=["nonce",n.toString(),t.toString()];for(r.tags.push(o);;){const e=Math.floor((new Date).getTime()/1e3);if(e!==r.created_at&&(n=0,r.created_at=e),o[1]=(++n).toString(),r.id=getEventHash(r),getPow(r.id)>=t)break}return r}__export(nip13_exports,{getPow:()=>getPow,minePow:()=>minePow});var nip18_exports={};function finishRepostEvent(e,t,n,r){return finishEvent({kind:6,tags:[...e.tags??[],["e",t.id,n],["p",t.pubkey]],content:""===e.content?"":JSON.stringify(t),created_at:e.created_at},r)}function getRepostedEventPointer(e){if(6!==e.kind)return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const o=e.tags[r];o.length>=2&&("e"===o[0]&&void 0===t?t=o:"p"===o[0]&&void 0===n&&(n=o))}return void 0!==t?{id:t[1],relays:[t[2],n?.[2]].filter((e=>"string"==typeof e)),author:n?.[1]}:void 0}function getRepostedEvent(e,{skipVerification:t}={}){const n=getRepostedEventPointer(e);if(void 0===n||""===e.content)return;let r;try{r=JSON.parse(e.content)}catch(e){return}return r.id===n.id&&(t||verifySignature(r))?r:void 0}__export(nip18_exports,{finishRepostEvent:()=>finishRepostEvent,getRepostedEvent:()=>getRepostedEvent,getRepostedEventPointer:()=>getRepostedEventPointer});var nip21_exports={};__export(nip21_exports,{NOSTR_URI_REGEX:()=>NOSTR_URI_REGEX,parse:()=>parse2,test:()=>test});var NOSTR_URI_REGEX=new RegExp(`nostr:(${BECH32_REGEX.source})`);function test(e){return"string"==typeof e&&new RegExp(`^${NOSTR_URI_REGEX.source}$`).test(e)}function parse2(e){const t=e.match(new RegExp(`^${NOSTR_URI_REGEX.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:decode(t[1])}}var nip25_exports={};function finishReactionEvent(e,t,n){const r=t.tags.filter((e=>e.length>=2&&("e"===e[0]||"p"===e[0])));return finishEvent({...e,kind:7,tags:[...e.tags??[],...r,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function getReactedEventPointer(e){if(7!==e.kind)return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const o=e.tags[r];o.length>=2&&("e"===o[0]&&void 0===t?t=o:"p"===o[0]&&void 0===n&&(n=o))}return void 0!==t&&void 0!==n?{id:t[1],relays:[t[2],n[2]].filter((e=>void 0!==e)),author:n[1]}:void 0}__export(nip25_exports,{finishReactionEvent:()=>finishReactionEvent,getReactedEventPointer:()=>getReactedEventPointer});var nip26_exports={};function createDelegation(e,t){let n=[];(t.kind||-1)>=0&&n.push(`kind=${t.kind}`),t.until&&n.push(`created_at<${t.until}`),t.since&&n.push(`created_at>${t.since}`);let r=n.join("&");if(""===r)throw new Error("refusing to create a delegation without any conditions");let o=sha256$1(utf8Encoder.encode(`nostr:delegation:${t.pubkey}:${r}`)),s=bytesToHex$1(schnorr.sign(o,e));return{from:getPublicKey(e),to:t.pubkey,cond:r,sig:s}}function getDelegator(e){let t=e.tags.find((e=>"delegation"===e[0]&&e.length>=4));if(!t)return null;let n=t[1],r=t[2],o=t[3],s=r.split("&");for(let t=0;t<s.length;t++){let[n,r,o]=s[t].split(/\b/);if(("kind"!==n||"="!==r||e.kind!==parseInt(o))&&!("created_at"===n&&"<"===r&&e.created_at<parseInt(o)||"created_at"===n&&">"===r&&e.created_at>parseInt(o)))return null}let i=sha256$1(utf8Encoder.encode(`nostr:delegation:${e.pubkey}:${r}`));return schnorr.verify(o,i,n)?n:null}__export(nip26_exports,{createDelegation:()=>createDelegation,getDelegator:()=>getDelegator});var nip27_exports={};__export(nip27_exports,{matchAll:()=>matchAll,regex:()=>regex,replaceAll:()=>replaceAll});var regex=()=>new RegExp(`\\b${NOSTR_URI_REGEX.source}\\b`,"g");function*matchAll(e){const t=e.matchAll(regex());for(const e of t)try{const[t,n]=e;yield{uri:t,value:n,decoded:decode(n),start:e.index,end:e.index+t.length}}catch(e){}}function replaceAll(e,t){return e.replaceAll(regex(),((e,n)=>t({uri:e,value:n,decoded:decode(n)})))}var nip28_exports={};__export(nip28_exports,{channelCreateEvent:()=>channelCreateEvent,channelHideMessageEvent:()=>channelHideMessageEvent,channelMessageEvent:()=>channelMessageEvent,channelMetadataEvent:()=>channelMetadataEvent,channelMuteUserEvent:()=>channelMuteUserEvent});var channelCreateEvent=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return finishEvent({kind:40,tags:[...e.tags??[]],content:n,created_at:e.created_at},t)},channelMetadataEvent=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return finishEvent({kind:41,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},channelMessageEvent=(e,t)=>{const n=[["e",e.channel_create_event_id,e.relay_url,"root"]];return e.reply_to_channel_message_event_id&&n.push(["e",e.reply_to_channel_message_event_id,e.relay_url,"reply"]),finishEvent({kind:42,tags:[...n,...e.tags??[]],content:e.content,created_at:e.created_at},t)},channelHideMessageEvent=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return finishEvent({kind:43,tags:[["e",e.channel_message_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},channelMuteUserEvent=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return finishEvent({kind:44,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)},nip39_exports={},_fetch2;__export(nip39_exports,{useFetchImplementation:()=>useFetchImplementation2,validateGithub:()=>validateGithub});try{_fetch2=fetch}catch{}function useFetchImplementation2(e){_fetch2=e}async function validateGithub(e,t,n){try{return await(await _fetch2(`https://gist.github.com/${t}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch(e){return!1}}var nip42_exports={};__export(nip42_exports,{authenticate:()=>authenticate});var authenticate=async({challenge:e,relay:t,sign:n})=>{const r={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t.url],["challenge",e]],content:""};return t.auth(await n(r))},nip44_exports={};__export(nip44_exports,{decrypt:()=>decrypt2,encrypt:()=>encrypt2,utils:()=>utils});var utils={v2:{maxPlaintextSize:65408,minCiphertextSize:100,maxCiphertextSize:102400,getConversationKey:(e,t)=>secp256k1.getSharedSecret(e,"02"+t).subarray(1,33),getMessageKeys(e,t){const n=hkdf(sha256$1,e,t,"nip44-v2",76);return{encryption:n.subarray(0,32),nonce:n.subarray(32,44),auth:n.subarray(44,76)}},calcPadding(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("expected positive integer");if(e<=32)return 32;const t=1<<Math.floor(Math.log2(e-1))+1,n=t<=256?32:t/8;return n*(Math.floor((e-1)/n)+1)},pad(e){const t=utf8Encoder.encode(e),n=t.length;if(n<1||n>=utils.v2.maxPlaintextSize)throw new Error("invalid plaintext length: must be between 1b and 64KB");const r=utils.v2.calcPadding(n),o=new Uint8Array(r-n),s=new Uint8Array(2);return new DataView(s.buffer).setUint16(0,n),concatBytes$1(s,t,o)},unpad(e){const t=new DataView(e.buffer).getUint16(0),n=e.subarray(2,2+t);if(0===t||n.length!==t||e.length!==2+utils.v2.calcPadding(t))throw new Error("invalid padding");return utf8Decoder.decode(n)}}};function encrypt2(e,t,n={}){const r=n.version??2;if(2!==r)throw new Error("unknown encryption version "+r);const o=n.salt??randomBytes$1(32);ensureBytes(o,32);const s=utils.v2.getMessageKeys(e,o),i=utils.v2.pad(t),a=chacha20(s.encryption,s.nonce,i),l=hmac(sha256$1,s.auth,a);return base64$1.encode(concatBytes$1(new Uint8Array([r]),o,a,l))}function decrypt2(e,t){const n=utils.v2;ensureBytes(e,32);const r=t.length;if(r<n.minCiphertextSize||r>=n.maxCiphertextSize)throw new Error("invalid ciphertext length: "+r);if("#"===t[0])throw new Error("unknown encryption version");let o;try{o=base64$1.decode(t)}catch(e){throw new Error("invalid base64: "+e.message)}const s=o.subarray(0,1)[0];if(2!==s)throw new Error("unknown encryption version "+s);const i=o.subarray(1,33),a=o.subarray(33,-32),l=o.subarray(-32),c=n.getMessageKeys(e,i);if(!equalBytes(hmac(sha256$1,c.auth,a),l))throw new Error("invalid MAC");const d=chacha20(c.encryption,c.nonce,a);return n.unpad(d)}var nip47_exports={};function parseConnectionString(e){const{pathname:t,searchParams:n}=new URL(e),r=t,o=n.get("relay"),s=n.get("secret");if(!r||!o||!s)throw new Error("invalid connection string");return{pubkey:r,relay:o,secret:s}}async function makeNwcRequestEvent({pubkey:e,secret:t,invoice:n}){const r={method:"pay_invoice",params:{invoice:n}},o=await encrypt$1(t,e,JSON.stringify(r));return finishEvent({kind:23194,created_at:Math.round(Date.now()/1e3),content:o,tags:[["p",e]]},t)}__export(nip47_exports,{makeNwcRequestEvent:()=>makeNwcRequestEvent,parseConnectionString:()=>parseConnectionString});var nip57_exports={},_fetch3;__export(nip57_exports,{getZapEndpoint:()=>getZapEndpoint,makeZapReceipt:()=>makeZapReceipt,makeZapRequest:()=>makeZapRequest,useFetchImplementation:()=>useFetchImplementation3,validateZapRequest:()=>validateZapRequest});try{_fetch3=fetch}catch{}function useFetchImplementation3(e){_fetch3=e}async function getZapEndpoint(e){try{let t="",{lud06:n,lud16:r}=JSON.parse(e.content);if(n){let{words:e}=bech32$2.decode(n,1e3),r=bech32$2.fromWords(e);t=utf8Decoder.decode(r)}else{if(!r)return null;{let[e,n]=r.split("@");t=`https://${n}/.well-known/lnurlp/${e}`}}let o=await _fetch3(t),s=await o.json();if(s.allowsNostr&&s.nostrPubkey)return s.callback}catch(e){}return null}function makeZapRequest({profile:e,event:t,amount:n,relays:r,comment:o=""}){if(!n)throw new Error("amount not given");if(!e)throw new Error("profile not given");let s={kind:9734,created_at:Math.round(Date.now()/1e3),content:o,tags:[["p",e],["amount",n.toString()],["relays",...r]]};return t&&s.tags.push(["e",t]),s}function validateZapRequest(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!validateEvent(t))return"Zap request is not a valid Nostr event.";if(!verifySignature(t))return"Invalid signature on zap request.";let n=t.tags.find((([e,t])=>"p"===e&&t));if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let r=t.tags.find((([e,t])=>"e"===e&&t));return r&&!r[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":t.tags.find((([e,t])=>"relays"===e&&t))?null:"Zap request doesn't have a 'relays' tag."}function makeZapReceipt({zapRequest:e,preimage:t,bolt11:n,paidAt:r}){let o=JSON.parse(e).tags.filter((([e])=>"e"===e||"p"===e||"a"===e)),s={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...o,["bolt11",n],["description",e]]};return t&&s.tags.push(["preimage",t]),s}var nip98_exports={};__export(nip98_exports,{getToken:()=>getToken,unpackEventFromToken:()=>unpackEventFromToken,validateEvent:()=>validateEvent2,validateToken:()=>validateToken});var _authorizationScheme="Nostr ";async function getToken(e,t,n,r=!1){if(!e||!t)throw new Error("Missing loginUrl or httpMethod");const o=getBlankEvent(27235);o.tags=[["u",e],["method",t]],o.created_at=Math.round((new Date).getTime()/1e3);const s=await n(o);return(r?_authorizationScheme:"")+base64$1.encode(utf8Encoder.encode(JSON.stringify(s)))}async function validateToken(e,t,n){const r=await unpackEventFromToken(e).catch((e=>{throw e}));return await validateEvent2(r,t,n).catch((e=>{throw e}))}async function unpackEventFromToken(e){if(!e)throw new Error("Missing token");e=e.replace(_authorizationScheme,"");const t=utf8Decoder.decode(base64$1.decode(e));if(!t||0===t.length||!t.startsWith("{"))throw new Error("Invalid token");return JSON.parse(t)}async function validateEvent2(e,t,n){if(!e)throw new Error("Invalid nostr event");if(!verifySignature(e))throw new Error("Invalid nostr event, signature invalid");if(27235!==e.kind)throw new Error("Invalid nostr event, kind invalid");if(!e.created_at)throw new Error("Invalid nostr event, created_at invalid");if(Math.round((new Date).getTime()/1e3)-e.created_at>60)throw new Error("Invalid nostr event, expired");const r=e.tags.find((e=>"u"===e[0]));if(1!==r?.length&&r?.[1]!==t)throw new Error("Invalid nostr event, url tag invalid");const o=e.tags.find((e=>"method"===e[0]));if(1!==o?.length&&o?.[1].toLowerCase()!==n.toLowerCase())throw new Error("Invalid nostr event, method tag invalid");return!0}var browser={exports:{}},ms,hasRequiredMs;function requireMs(){if(hasRequiredMs)return ms;hasRequiredMs=1;var e=1e3,t=60*e,n=60*t,r=24*n,o=7*r,s=365.25*r;function i(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}return ms=function(a,l){l=l||{};var c=typeof a;if("string"===c&&a.length>0)return function(i){if((i=String(i)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(!a)return;var l=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return l*s;case"weeks":case"week":case"w":return l*o;case"days":case"day":case"d":return l*r;case"hours":case"hour":case"hrs":case"hr":case"h":return l*n;case"minutes":case"minute":case"mins":case"min":case"m":return l*t;case"seconds":case"second":case"secs":case"sec":case"s":return l*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:return}}(a);if("number"===c&&isFinite(a))return l.long?function(o){var s=Math.abs(o);if(s>=r)return i(o,s,r,"day");if(s>=n)return i(o,s,n,"hour");if(s>=t)return i(o,s,t,"minute");if(s>=e)return i(o,s,e,"second");return o+" ms"}(a):function(o){var s=Math.abs(o);if(s>=r)return Math.round(o/r)+"d";if(s>=n)return Math.round(o/n)+"h";if(s>=t)return Math.round(o/t)+"m";if(s>=e)return Math.round(o/e)+"s";return o+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}function setup(e){function t(e){let r,o,s,i=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),s=o-(r||o);n.diff=s,n.prev=r,n.curr=o,r=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,o)=>{if("%%"===r)return"%";i++;const s=t.formatters[o];if("function"==typeof s){const t=e[i];r=s.call(n,t),e.splice(i,1),i--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(o!==t.namespaces&&(o=t.namespaces,s=t.enabled(e)),s),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=requireMs(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}var common=setup;!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=common(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(browser,browser.exports);var browserExports=browser.exports,debug3=getDefaultExportFromCjs(browserExports),dist={},LRUCache$1={},LRUCacheNode$1={};Object.defineProperty(LRUCacheNode$1,"__esModule",{value:!0}),LRUCacheNode$1.LRUCacheNode=void 0;class LRUCacheNode{constructor(e,t,n){const{entryExpirationTimeInMS:r=null,next:o=null,prev:s=null,onEntryEvicted:i,onEntryMarkedAsMostRecentlyUsed:a,clone:l,cloneFn:c}=null!=n?n:{};if("number"==typeof r&&(r<=0||Number.isNaN(r)))throw new Error("entryExpirationTimeInMS must either be null (no expiry) or greater than 0");this.clone=null!=l&&l,this.cloneFn=null!=c?c:this.defaultClone,this.key=e,this.internalValue=this.clone?this.cloneFn(t):t,this.created=Date.now(),this.entryExpirationTimeInMS=r,this.next=o,this.prev=s,this.onEntryEvicted=i,this.onEntryMarkedAsMostRecentlyUsed=a}get value(){return this.clone?this.cloneFn(this.internalValue):this.internalValue}get isExpired(){return"number"==typeof this.entryExpirationTimeInMS&&Date.now()-this.created>this.entryExpirationTimeInMS}invokeOnEvicted(){if(this.onEntryEvicted){const{key:e,value:t,isExpired:n}=this;this.onEntryEvicted({key:e,value:t,isExpired:n})}}invokeOnEntryMarkedAsMostRecentlyUsed(){if(this.onEntryMarkedAsMostRecentlyUsed){const{key:e,value:t}=this;this.onEntryMarkedAsMostRecentlyUsed({key:e,value:t})}}defaultClone(e){return"boolean"==typeof e||"string"==typeof e||"number"==typeof e?e:JSON.parse(JSON.stringify(e))}}LRUCacheNode$1.LRUCacheNode=LRUCacheNode,Object.defineProperty(LRUCache$1,"__esModule",{value:!0}),LRUCache$1.LRUCache=void 0;const LRUCacheNode_1=LRUCacheNode$1;class LRUCache{constructor(e){this.lookupTable=new Map,this.head=null,this.tail=null;const{maxSize:t=25,entryExpirationTimeInMS:n=null,onEntryEvicted:r,onEntryMarkedAsMostRecentlyUsed:o,cloneFn:s,clone:i}=null!=e?e:{};if(Number.isNaN(t)||t<=0)throw new Error("maxSize must be greater than 0.");if("number"==typeof n&&(n<=0||Number.isNaN(n)))throw new Error("entryExpirationTimeInMS must either be null (no expiry) or greater than 0");this.maxSizeInternal=t,this.entryExpirationTimeInMS=n,this.onEntryEvicted=r,this.onEntryMarkedAsMostRecentlyUsed=o,this.clone=i,this.cloneFn=s}get size(){return this.cleanCache(),this.lookupTable.size}get remainingSize(){return this.maxSizeInternal-this.size}get newest(){return this.head?this.head.isExpired?(this.removeNodeFromListAndLookupTable(this.head),this.newest):this.mapNodeToEntry(this.head):null}get oldest(){return this.tail?this.tail.isExpired?(this.removeNodeFromListAndLookupTable(this.tail),this.oldest):this.mapNodeToEntry(this.tail):null}get maxSize(){return this.maxSizeInternal}set maxSize(e){if(Number.isNaN(e)||e<=0)throw new Error("maxSize must be greater than 0.");this.maxSizeInternal=e,this.enforceSizeLimit()}set(e,t,n){const r=this.lookupTable.get(e);r&&this.removeNodeFromListAndLookupTable(r);const o=new LRUCacheNode_1.LRUCacheNode(e,t,{entryExpirationTimeInMS:this.entryExpirationTimeInMS,onEntryEvicted:this.onEntryEvicted,onEntryMarkedAsMostRecentlyUsed:this.onEntryMarkedAsMostRecentlyUsed,clone:this.clone,cloneFn:this.cloneFn,...n});return this.setNodeAsHead(o),this.lookupTable.set(e,o),this.enforceSizeLimit(),this}get(e){const t=this.lookupTable.get(e);return t?t.isExpired?(this.removeNodeFromListAndLookupTable(t),null):(this.setNodeAsHead(t),t.value):null}peek(e){const t=this.lookupTable.get(e);return t?t.isExpired?(this.removeNodeFromListAndLookupTable(t),null):t.value:null}delete(e){const t=this.lookupTable.get(e);return!!t&&this.removeNodeFromListAndLookupTable(t)}has(e){const t=this.lookupTable.get(e);return!!t&&(!t.isExpired||(this.removeNodeFromListAndLookupTable(t),!1))}clear(){this.head=null,this.tail=null,this.lookupTable.clear()}find(e){let t=this.head;for(;t;){if(t.isExpired){const e=t.next;this.removeNodeFromListAndLookupTable(t),t=e;continue}const n=this.mapNodeToEntry(t);if(e(n))return this.setNodeAsHead(t),n;t=t.next}return null}forEach(e){let t=this.head,n=0;for(;t;)if(t.isExpired){const e=t.next;this.removeNodeFromListAndLookupTable(t),t=e}else e(t.value,t.key,n),t=t.next,n++}*values(){let e=this.head;for(;e;)if(e.isExpired){const t=e.next;this.removeNodeFromListAndLookupTable(e),e=t}else yield e.value,e=e.next}*keys(){let e=this.head;for(;e;)if(e.isExpired){const t=e.next;this.removeNodeFromListAndLookupTable(e),e=t}else yield e.key,e=e.next}*entries(){let e=this.head;for(;e;)if(e.isExpired){const t=e.next;this.removeNodeFromListAndLookupTable(e),e=t}else yield this.mapNodeToEntry(e),e=e.next}*[Symbol.iterator](){let e=this.head;for(;e;)if(e.isExpired){const t=e.next;this.removeNodeFromListAndLookupTable(e),e=t}else yield this.mapNodeToEntry(e),e=e.next}enforceSizeLimit(){let e=this.tail;for(;null!==e&&this.size>this.maxSizeInternal;){const t=e.prev;this.removeNodeFromListAndLookupTable(e),e=t}}mapNodeToEntry({key:e,value:t}){return{key:e,value:t}}setNodeAsHead(e){this.removeNodeFromList(e),this.head?(e.next=this.head,this.head.prev=e,this.head=e):(this.head=e,this.tail=e),e.invokeOnEntryMarkedAsMostRecentlyUsed()}removeNodeFromList(e){null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.head===e&&(this.head=e.next),this.tail===e&&(this.tail=e.prev),e.next=null,e.prev=null}removeNodeFromListAndLookupTable(e){return e.invokeOnEvicted(),this.removeNodeFromList(e),this.lookupTable.delete(e.key)}cleanCache(){if(!this.entryExpirationTimeInMS)return;const e=[];for(const t of this.lookupTable.values())t.isExpired&&e.push(t);e.forEach((e=>this.removeNodeFromListAndLookupTable(e)))}}LRUCache$1.LRUCache=LRUCache,function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=commonjsGlobal&&commonjsGlobal.__exportStar||function(e,n){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(n,r)||t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(LRUCache$1,e)}(dist);var lib={};!function(e){function t(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function n(...e){const t=(e,t)=>n=>e(t(n));return{encode:Array.from(e).reverse().reduce(((e,n)=>e?t(e,n.encode):n.encode),void 0),decode:e.reduce(((e,n)=>e?t(e,n.decode):n.decode),void 0)}}function r(e){return{encode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("alphabet.encode input should be an array of numbers");return n.map((n=>{if(t(n),n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]}))},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map((t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}}function o(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function s(e,n="="){if(t(e),"string"!=typeof n)throw new Error("padding chr should be string");return{encode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;t.length*e%8;)t.push(n);return t},decode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let r=t.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&t[r-1]===n;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return t.slice(0,r)}}}function i(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function a(e,n,r){if(n<2)throw new Error(`convertRadix: wrong from=${n}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let o=0;const s=[],i=Array.from(e);for(i.forEach((e=>{if(t(e),e<0||e>=n)throw new Error(`Wrong integer: ${e}`)}));;){let e=0,t=!0;for(let s=o;s<i.length;s++){const a=i[s],l=n*e+a;if(!Number.isSafeInteger(l)||n*e/n!==e||l-a!=n*e)throw new Error("convertRadix: carry overflow");if(e=l%r,i[s]=Math.floor(l/r),!Number.isSafeInteger(i[s])||i[s]*r+e!==l)throw new Error("convertRadix: carry overflow");t&&(i[s]?t=!1:o=s)}if(s.push(e),t)break}for(let t=0;t<e.length-1&&0===e[t];t++)s.push(0);return s.reverse()}
44
16
  /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
45
- function isBytes(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function chain(...e){const t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}function alphabet(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map(t=>{if(t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]})},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map(t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})}}}function join(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function convertRadix(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const i=[],s=Array.from(e);for(s.forEach(e=>{if(e<0||e>=t)throw new Error(`Wrong integer: ${e}`)});;){let e=0,o=!0;for(let i=r;i<s.length;i++){const a=s[i],c=t*e+a;if(!Number.isSafeInteger(c)||t*e/t!==e||c-a!==t*e)throw new Error("convertRadix: carry overflow");e=c%n;const l=Math.floor(c/n);if(s[i]=l,!Number.isSafeInteger(l)||l*n+e!==c)throw new Error("convertRadix: carry overflow");o&&(l?o=!1:r=i)}if(i.push(e),o)break}for(let t=0;t<e.length-1&&0===e[t];t++)i.push(0);return i.reverse()}function radix(e){return{encode:t=>{if(!isBytes(t))throw new Error("radix.encode input should be Uint8Array");return convertRadix(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(convertRadix(t,e,256))}}}function checksum(e,t){if("function"!=typeof t)throw new Error("checksum fn should be function");return{encode(n){if(!isBytes(n))throw new Error("checksum.encode: input should be Uint8Array");const r=t(n).slice(0,e),i=new Uint8Array(n.length+e);return i.set(n),i.set(r,n.length),i},decode(n){if(!isBytes(n))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-e),i=t(r).slice(0,e),s=n.slice(-e);for(let t=0;t<e;t++)if(i[t]!==s[t])throw new Error("Invalid checksum");return r}}}BigInt(0),secp256k1.ProjectivePoint;const genBase58=e=>chain(radix(58),alphabet(e),join("")),base58=genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),createBase58check=e=>chain(checksum(4,t=>e(e(t))),base58),base58check$1=createBase58check,Point=secp256k1.ProjectivePoint,base58check=base58check$1(sha256$1);function bytesToNumber(e){return BigInt(`0x${bytesToHex$1(e)}`)}function numberToBytes(e){return hexToBytes$1(e.toString(16).padStart(64,"0"))}const MASTER_SECRET=utf8ToBytes$3("Bitcoin seed"),BITCOIN_VERSIONS={private:76066276,public:76067358},HARDENED_OFFSET=2147483648,hash160=e=>ripemd160(sha256$1(e)),fromU32=e=>createView$1(e).getUint32(0,!1),toU32=e=>{if(!Number.isSafeInteger(e)||e<0||e>2**32-1)throw new Error(`Invalid number=${e}. Should be from 0 to 2 ** 32 - 1`);const t=new Uint8Array(4);return createView$1(t).setUint32(0,e,!1),t};class HDKey{get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return fromU32(this.pubHash)}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this.privKeyBytes||null}get publicKey(){return this.pubKey||null}get privateExtendedKey(){const e=this.privateKey;if(!e)throw new Error("No private key");return base58check.encode(this.serialize(this.versions.private,concatBytes$2(new Uint8Array([0]),e)))}get publicExtendedKey(){if(!this.pubKey)throw new Error("No public key");return base58check.encode(this.serialize(this.versions.public,this.pubKey))}static fromMasterSeed(e,t=BITCOIN_VERSIONS){if(bytes$2(e),8*e.length<128||8*e.length>512)throw new Error(`HDKey: wrong seed length=${e.length}. Should be between 128 and 512 bits; 256 bits is advised)`);const n=hmac$1(sha512,MASTER_SECRET,e);return new HDKey({versions:t,chainCode:n.slice(32),privateKey:n.slice(0,32)})}static fromExtendedKey(e,t=BITCOIN_VERSIONS){const n=base58check.decode(e),r=createView$1(n),i=r.getUint32(0,!1),s={versions:t,depth:n[4],parentFingerprint:r.getUint32(5,!1),index:r.getUint32(9,!1),chainCode:n.slice(13,45)},o=n.slice(45),a=0===o[0];if(i!==t[a?"private":"public"])throw new Error("Version mismatch");return new HDKey(a?{...s,privateKey:o.slice(1)}:{...s,publicKey:o})}static fromJSON(e){return HDKey.fromExtendedKey(e.xpriv)}constructor(e){if(this.depth=0,this.index=0,this.chainCode=null,this.parentFingerprint=0,!e||"object"!=typeof e)throw new Error("HDKey.constructor must not be called directly");if(this.versions=e.versions||BITCOIN_VERSIONS,this.depth=e.depth||0,this.chainCode=e.chainCode,this.index=e.index||0,this.parentFingerprint=e.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(e.publicKey&&e.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(e.privateKey){if(!secp256k1.utils.isValidPrivateKey(e.privateKey))throw new Error("Invalid private key");this.privKey="bigint"==typeof e.privateKey?e.privateKey:bytesToNumber(e.privateKey),this.privKeyBytes=numberToBytes(this.privKey),this.pubKey=secp256k1.getPublicKey(e.privateKey,!0)}else{if(!e.publicKey)throw new Error("HDKey: no public or private key provided");this.pubKey=Point.fromHex(e.publicKey).toRawBytes(!0)}this.pubHash=hash160(this.pubKey)}derive(e){if(!/^[mM]'?/.test(e))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(e))return this;const t=e.replace(/^[mM]'?\//,"").split("/");let n=this;for(const e of t){const t=/^(\d+)('?)$/.exec(e);if(!t||3!==t.length)throw new Error(`Invalid child index: ${e}`);let r=+t[1];if(!Number.isSafeInteger(r)||r>=HARDENED_OFFSET)throw new Error("Invalid index");"'"===t[2]&&(r+=HARDENED_OFFSET),n=n.deriveChild(r)}return n}deriveChild(e){if(!this.pubKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let t=toU32(e);if(e>=HARDENED_OFFSET){const e=this.privateKey;if(!e)throw new Error("Could not derive hardened child key");t=concatBytes$2(new Uint8Array([0]),e,t)}else t=concatBytes$2(this.pubKey,t);const n=hmac$1(sha512,this.chainCode,t),r=bytesToNumber(n.slice(0,32)),i=n.slice(32);if(!secp256k1.utils.isValidPrivateKey(r))throw new Error("Tweak bigger than curve order");const s={versions:this.versions,chainCode:i,depth:this.depth+1,parentFingerprint:this.fingerprint,index:e};try{if(this.privateKey){const e=mod(this.privKey+r,secp256k1.CURVE.n);if(!secp256k1.utils.isValidPrivateKey(e))throw new Error("The tweak was out of range or the resulted private key is invalid");s.privateKey=e}else{const e=Point.fromHex(this.pubKey).add(Point.fromPrivateKey(r));if(e.equals(Point.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");s.publicKey=e.toRawBytes(!0)}return new HDKey(s)}catch(t){return this.deriveChild(e+1)}}sign(e){if(!this.privateKey)throw new Error("No privateKey set!");return bytes$2(e,32),secp256k1.sign(e,this.privKey).toCompactRawBytes()}verify(e,t){if(bytes$2(e,32),bytes$2(t,64),!this.publicKey)throw new Error("No publicKey set!");let n;try{n=secp256k1.Signature.fromCompact(t)}catch(e){return!1}return secp256k1.verify(n,e,this.publicKey)}wipePrivateData(){return this.privKey=void 0,this.privKeyBytes&&(this.privKeyBytes.fill(0),this.privKeyBytes=void 0),this}toJSON(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}}serialize(e,t){if(!this.chainCode)throw new Error("No chainCode set");return bytes$2(t,33),concatBytes$2(toU32(e),new Uint8Array([this.depth]),toU32(this.parentFingerprint),toU32(this.index),this.chainCode,t)}}
46
- /*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */const u8a=e=>e instanceof Uint8Array,u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!isLE)throw new Error("Non little-endian hardware is not supported");function utf8ToBytes(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function toBytes(e){if("string"==typeof e&&(e=utf8ToBytes(e)),!u8a(e))throw new Error("expected Uint8Array, got "+typeof e);return e}const isPlainObject=e=>"[object Object]"===Object.prototype.toString.call(e)&&e.constructor===Object;function checkOpts(e,t){if(void 0!==t&&("object"!=typeof t||!isPlainObject(t)))throw new Error("options must be object or undefined");return Object.assign(e,t)}function ensureBytes(e,t){if(!(e instanceof Uint8Array))throw new Error("Uint8Array expected");if(e.length!==t)throw new Error(`Uint8Array length ${t} expected`)}function equalBytes(e,t){if(e.length!==t.length)throw new Error("equalBytes: Different size of Uint8Arrays");let n=!0;for(let r=0;r<e.length;r++)n&&(n=e[r]===t[r]);return n}function number(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function bool(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)}function bytes(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function hash(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("hash must be wrapped by utils.wrapConstructor");number(e.outputLen),number(e.blockLen)}function exists(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function output(e,t){bytes(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const assert={number:number,bool:bool,bytes:bytes,hash:hash,exists:exists,output:output},u8to16=(e,t)=>255&e[t++]|(255&e[t++])<<8;class Poly1305{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,ensureBytes(e=toBytes(e),32);const t=u8to16(e,0),n=u8to16(e,2),r=u8to16(e,4),i=u8to16(e,6),s=u8to16(e,8),o=u8to16(e,10),a=u8to16(e,12),c=u8to16(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|n<<3),this.r[2]=7939&(n>>>10|r<<6),this.r[3]=8191&(r>>>7|i<<9),this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,this.r[6]=8191&(s>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=u8to16(e,16+2*t)}process(e,t,n=!1){const r=n?0:2048,{h:i,r:s}=this,o=s[0],a=s[1],c=s[2],l=s[3],h=s[4],d=s[5],u=s[6],f=s[7],p=s[8],g=s[9],y=u8to16(e,t+0),m=u8to16(e,t+2),b=u8to16(e,t+4),w=u8to16(e,t+6),v=u8to16(e,t+8),$=u8to16(e,t+10),E=u8to16(e,t+12),k=u8to16(e,t+14);let x=i[0]+(8191&y),_=i[1]+(8191&(y>>>13|m<<3)),S=i[2]+(8191&(m>>>10|b<<6)),C=i[3]+(8191&(b>>>7|w<<9)),A=i[4]+(8191&(w>>>4|v<<12)),N=i[5]+(v>>>1&8191),R=i[6]+(8191&(v>>>14|$<<2)),T=i[7]+(8191&($>>>11|E<<5)),B=i[8]+(8191&(E>>>8|k<<8)),L=i[9]+(k>>>5|r),I=0,U=I+x*o+_*(5*g)+S*(5*p)+C*(5*f)+A*(5*u);I=U>>>13,U&=8191,U+=N*(5*d)+R*(5*h)+T*(5*l)+B*(5*c)+L*(5*a),I+=U>>>13,U&=8191;let O=I+x*a+_*o+S*(5*g)+C*(5*p)+A*(5*f);I=O>>>13,O&=8191,O+=N*(5*u)+R*(5*d)+T*(5*h)+B*(5*l)+L*(5*c),I+=O>>>13,O&=8191;let P=I+x*c+_*a+S*o+C*(5*g)+A*(5*p);I=P>>>13,P&=8191,P+=N*(5*f)+R*(5*u)+T*(5*d)+B*(5*h)+L*(5*l),I+=P>>>13,P&=8191;let M=I+x*l+_*c+S*a+C*o+A*(5*g);I=M>>>13,M&=8191,M+=N*(5*p)+R*(5*f)+T*(5*u)+B*(5*d)+L*(5*h),I+=M>>>13,M&=8191;let D=I+x*h+_*l+S*c+C*a+A*o;I=D>>>13,D&=8191,D+=N*(5*g)+R*(5*p)+T*(5*f)+B*(5*u)+L*(5*d),I+=D>>>13,D&=8191;let H=I+x*d+_*h+S*l+C*c+A*a;I=H>>>13,H&=8191,H+=N*o+R*(5*g)+T*(5*p)+B*(5*f)+L*(5*u),I+=H>>>13,H&=8191;let F=I+x*u+_*d+S*h+C*l+A*c;I=F>>>13,F&=8191,F+=N*a+R*o+T*(5*g)+B*(5*p)+L*(5*f),I+=F>>>13,F&=8191;let K=I+x*f+_*u+S*d+C*h+A*l;I=K>>>13,K&=8191,K+=N*c+R*a+T*o+B*(5*g)+L*(5*p),I+=K>>>13,K&=8191;let V=I+x*p+_*f+S*u+C*d+A*h;I=V>>>13,V&=8191,V+=N*l+R*c+T*a+B*o+L*(5*g),I+=V>>>13,V&=8191;let j=I+x*g+_*p+S*f+C*u+A*d;I=j>>>13,j&=8191,j+=N*h+R*l+T*c+B*a+L*o,I+=j>>>13,j&=8191,I=(I<<2)+I|0,I=I+U|0,U=8191&I,I>>>=13,O+=I,i[0]=U,i[1]=O,i[2]=P,i[3]=M,i[4]=D,i[5]=H,i[6]=F,i[7]=K,i[8]=V,i[9]=j}finalize(){const{h:e,pad:t}=this,n=new Uint16Array(10);let r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=8191;e[0]+=5*r,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,n[0]=e[0]+5,r=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+r,r=n[t]>>>13,n[t]&=8191;n[9]-=8192;let i=(1^r)-1;for(let e=0;e<10;e++)n[e]&=i;i=~i;for(let t=0;t<10;t++)e[t]=e[t]&i|n[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let s=e[0]+t[0];e[0]=65535&s;for(let n=1;n<8;n++)s=(e[n]+t[n]|0)+(s>>>16)|0,e[n]=65535&s}update(e){assert.exists(this);const{buffer:t,blockLen:n}=this,r=(e=toBytes(e)).length;for(let i=0;i<r;){const s=Math.min(n-this.pos,r-i);if(s!==n)t.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===n&&(this.process(t,0,!1),this.pos=0);else for(;n<=r-i;i+=n)this.process(e,i)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(e){assert.exists(this),assert.output(e,this),this.finished=!0;const{buffer:t,h:n}=this;let{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let t=0;t<8;t++)e[i++]=n[t]>>>0,e[i++]=n[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}}function wrapConstructorWithKey(e){const t=(t,n)=>e(n).update(toBytes(t)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}wrapConstructorWithKey(e=>new Poly1305(e));const sigma16=utf8ToBytes("expand 16-byte k"),sigma32=utf8ToBytes("expand 32-byte k"),sigma16_32=u32(sigma16),sigma32_32=u32(sigma32),isAligned32=e=>!(e.byteOffset%4),salsaBasic=e=>{const{core:t,rounds:n,counterRight:r,counterLen:i,allow128bitKeys:s,extendNonceFn:o,blockLen:a}=checkOpts({rounds:20,counterRight:!1,counterLen:8,allow128bitKeys:!0,blockLen:64},e);assert.number(i),assert.number(n),assert.number(a),assert.bool(r),assert.bool(s);const c=a/4;if(a%4!=0)throw new Error("Salsa/ChaCha: blockLen must be aligned to 4 bytes");return(e,l,h,d,u=0)=>{if(assert.bytes(e),assert.bytes(l),assert.bytes(h),d||(d=new Uint8Array(h.length)),assert.bytes(d),assert.number(u),u<0||u>=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");if(d.length<h.length)throw new Error(`Salsa/ChaCha: output (${d.length}) is shorter than data (${h.length})`);const f=[];let p,g;if(32===e.length)p=e,g=sigma32_32;else{if(16!==e.length||!s)throw new Error(`Salsa/ChaCha: invalid 32-byte key, got length=${e.length}`);p=new Uint8Array(32),p.set(e),p.set(e,16),g=sigma16_32,f.push(p)}if(o){if(l.length<=16)throw new Error("Salsa/ChaCha: extended nonce must be bigger than 16 bytes");p=o(g,p,l.subarray(0,16),new Uint8Array(32)),f.push(p),l=l.subarray(16)}const y=16-i;if(l.length!==y)throw new Error(`Salsa/ChaCha: nonce must be ${y} or 16 bytes`);if(12!==y){const e=new Uint8Array(12);e.set(l,r?0:12-l.length),f.push(l=e)}const m=new Uint8Array(a),b=u32(m),w=u32(p),v=u32(l),$=isAligned32(h)&&u32(h),E=isAligned32(d)&&u32(d);f.push(b);const k=h.length;for(let e=0,r=u;e<k;r++){if(t(g,w,v,b,r,n),r>=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");const i=Math.min(a,k-e);if(i===a&&E&&$){const t=e/4;if(e%4!=0)throw new Error("Salsa/ChaCha: invalid block position");for(let e=0;e<c;e++)E[t+e]=$[t+e]^b[e];e+=a;continue}for(let t=0;t<i;t++)d[e+t]=h[e+t]^m[t];e+=i}for(let e=0;e<f.length;e++)f[e].fill(0);return d}},rotl=(e,t)=>e<<t|e>>>32-t;function chachaCore(e,t,n,r,i,s=20){let o=e[0],a=e[1],c=e[2],l=e[3],h=t[0],d=t[1],u=t[2],f=t[3],p=t[4],g=t[5],y=t[6],m=t[7],b=i,w=n[0],v=n[1],$=n[2],E=o,k=a,x=c,_=l,S=h,C=d,A=u,N=f,R=p,T=g,B=y,L=m,I=b,U=w,O=v,P=$;for(let e=0;e<s;e+=2)E=E+S|0,I=rotl(I^E,16),R=R+I|0,S=rotl(S^R,12),E=E+S|0,I=rotl(I^E,8),R=R+I|0,S=rotl(S^R,7),k=k+C|0,U=rotl(U^k,16),T=T+U|0,C=rotl(C^T,12),k=k+C|0,U=rotl(U^k,8),T=T+U|0,C=rotl(C^T,7),x=x+A|0,O=rotl(O^x,16),B=B+O|0,A=rotl(A^B,12),x=x+A|0,O=rotl(O^x,8),B=B+O|0,A=rotl(A^B,7),_=_+N|0,P=rotl(P^_,16),L=L+P|0,N=rotl(N^L,12),_=_+N|0,P=rotl(P^_,8),L=L+P|0,N=rotl(N^L,7),E=E+C|0,P=rotl(P^E,16),B=B+P|0,C=rotl(C^B,12),E=E+C|0,P=rotl(P^E,8),B=B+P|0,C=rotl(C^B,7),k=k+A|0,I=rotl(I^k,16),L=L+I|0,A=rotl(A^L,12),k=k+A|0,I=rotl(I^k,8),L=L+I|0,A=rotl(A^L,7),x=x+N|0,U=rotl(U^x,16),R=R+U|0,N=rotl(N^R,12),x=x+N|0,U=rotl(U^x,8),R=R+U|0,N=rotl(N^R,7),_=_+S|0,O=rotl(O^_,16),T=T+O|0,S=rotl(S^T,12),_=_+S|0,O=rotl(O^_,8),T=T+O|0,S=rotl(S^T,7);let M=0;r[M++]=o+E|0,r[M++]=a+k|0,r[M++]=c+x|0,r[M++]=l+_|0,r[M++]=h+S|0,r[M++]=d+C|0,r[M++]=u+A|0,r[M++]=f+N|0,r[M++]=p+R|0,r[M++]=g+T|0,r[M++]=y+B|0,r[M++]=m+L|0,r[M++]=b+I|0,r[M++]=w+U|0,r[M++]=v+O|0,r[M++]=$+P|0}const chacha20=salsaBasic({core:chachaCore,counterRight:!1,counterLen:4,allow128bitKeys:!1});function extract(e,t,n){return assert$3.hash(e),void 0===n&&(n=new Uint8Array(e.outputLen)),hmac$3(e,toBytes$4(n),toBytes$4(t))}const HKDF_COUNTER=new Uint8Array([0]),EMPTY_BUFFER=new Uint8Array;function expand(e,t,n,r=32){if(assert$3.hash(e),assert$3.number(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/e.outputLen);void 0===n&&(n=EMPTY_BUFFER);const s=new Uint8Array(i*e.outputLen),o=hmac$3.create(e,t),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let t=0;t<i;t++)HKDF_COUNTER[0]=t+1,a.update(0===t?EMPTY_BUFFER:c).update(n).update(HKDF_COUNTER).digestInto(c),s.set(c,e.outputLen*t),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),HKDF_COUNTER.fill(0),s.slice(0,r)}const hkdf=(e,t,n,r,i)=>expand(e,extract(e,t,n),r,i);var __defProp=Object.defineProperty,__export=(e,t)=>{for(var n in t)__defProp(e,n,{get:t[n],enumerable:!0})};function generatePrivateKey(){return bytesToHex$3(schnorr.utils.randomPrivateKey())}function getPublicKey(e){return bytesToHex$3(schnorr.getPublicKey(e))}var utils_exports={};__export(utils_exports,{MessageNode:()=>MessageNode,MessageQueue:()=>MessageQueue,insertEventIntoAscendingList:()=>insertEventIntoAscendingList,insertEventIntoDescendingList:()=>insertEventIntoDescendingList,normalizeURL:()=>normalizeURL,utf8Decoder:()=>utf8Decoder,utf8Encoder:()=>utf8Encoder});var utf8Decoder=new TextDecoder("utf-8"),utf8Encoder=new TextEncoder;function normalizeURL(e){let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),("80"===t.port&&"ws:"===t.protocol||"443"===t.port&&"wss:"===t.protocol)&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}function insertEventIntoDescendingList(e,t){let n,r=0,i=e.length-1,s=r;if(i<0)s=0;else if(t.created_at<e[i].created_at)s=i+1;else if(t.created_at>=e[r].created_at)s=r;else for(;;){if(i<=r+1){s=i;break}if(n=Math.floor(r+(i-r)/2),e[n].created_at>t.created_at)r=n;else{if(!(e[n].created_at<t.created_at)){s=n;break}i=n}}return e[s]?.id!==t.id?[...e.slice(0,s),t,...e.slice(s)]:e}function insertEventIntoAscendingList(e,t){let n,r=0,i=e.length-1,s=r;if(i<0)s=0;else if(t.created_at>e[i].created_at)s=i+1;else if(t.created_at<=e[r].created_at)s=r;else for(;;){if(i<=r+1){s=i;break}if(n=Math.floor(r+(i-r)/2),e[n].created_at<t.created_at)r=n;else{if(!(e[n].created_at>t.created_at)){s=n;break}i=n}}return e[s]?.id!==t.id?[...e.slice(0,s),t,...e.slice(s)]:e}var MessageNode=class{_value;_next;get value(){return this._value}set value(e){this._value=e}get next(){return this._next}set next(e){this._next=e}constructor(e){this._value=e,this._next=null}},MessageQueue=class{_first;_last;get first(){return this._first}set first(e){this._first=e}get last(){return this._last}set last(e){this._last=e}_size;get size(){return this._size}set size(e){this._size=e}constructor(){this._first=null,this._last=null,this._size=0}enqueue(e){const t=new MessageNode(e);return 0!==this._size&&this._last?(this._last.next=t,this._last=t):(this._first=t,this._last=t),this._size++,!0}dequeue(){if(0===this._size||!this._first)return null;let e=this._first;return this._first=e.next,e.next=null,this._size--,e.value}},verifiedSymbol=Symbol("verified");function getBlankEvent(e=255){return{kind:e,content:"",tags:[],created_at:0}}function finishEvent(e,t){const n=e;return n.pubkey=getPublicKey(t),n.id=getEventHash(n),n.sig=getSignature(n,t),n[verifiedSymbol]=!0,n}function serializeEvent(e){if(!validateEvent(e))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}function getEventHash(e){return bytesToHex$3(sha256$3(utf8Encoder.encode(serializeEvent(e))))}var isRecord=e=>e instanceof Object;function validateEvent(e){if(!isRecord(e))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let n=e.tags[t];if(!Array.isArray(n))return!1;for(let e=0;e<n.length;e++)if("object"==typeof n[e])return!1}return!0}function verifySignature(e){if("boolean"==typeof e[verifiedSymbol])return e[verifiedSymbol];const t=getEventHash(e);if(t!==e.id)return e[verifiedSymbol]=!1;try{return e[verifiedSymbol]=schnorr.verify(e.sig,t,e.pubkey)}catch(t){return e[verifiedSymbol]=!1}}function getSignature(e,t){return bytesToHex$3(schnorr.sign(getEventHash(e),t))}var fakejson_exports={};function getHex64(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,i=e.slice(r).indexOf('"')+r+1;return e.slice(i,i+64)}function getInt(e,t){let n=t.length,r=e.indexOf(`"${t}":`)+n+3,i=e.slice(r),s=Math.min(i.indexOf(","),i.indexOf("}"));return parseInt(i.slice(0,s),10)}function getSubscriptionId(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let r=t+7+1+n,i=e.slice(r+1,80).indexOf('"');if(-1===i)return null;let s=r+1+i;return e.slice(r+1,s)}function matchEventId(e,t){return t===getHex64(e,"id")}function matchEventPubkey(e,t){return t===getHex64(e,"pubkey")}function matchEventKind(e,t){return t===getInt(e,"kind")}__export(fakejson_exports,{getHex64:()=>getHex64,getInt:()=>getInt,getSubscriptionId:()=>getSubscriptionId,matchEventId:()=>matchEventId,matchEventKind:()=>matchEventKind,matchEventPubkey:()=>matchEventPubkey});var nip19_exports={};__export(nip19_exports,{BECH32_REGEX:()=>BECH32_REGEX,decode:()=>decode,naddrEncode:()=>naddrEncode,neventEncode:()=>neventEncode,noteEncode:()=>noteEncode,nprofileEncode:()=>nprofileEncode,npubEncode:()=>npubEncode,nrelayEncode:()=>nrelayEncode,nsecEncode:()=>nsecEncode});var Bech32MaxSize=5e3,BECH32_REGEX=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function integerToUint8Array(e){const t=new Uint8Array(4);return t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t}function decode(e){let{prefix:t,words:n}=bech32.decode(e,Bech32MaxSize),r=new Uint8Array(bech32.fromWords(n));switch(t){case"nprofile":{let e=parseTLV(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:bytesToHex$3(e[0][0]),relays:e[1]?e[1].map(e=>utf8Decoder.decode(e)):[]}}}case"nevent":{let e=parseTLV(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(e[3]&&4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:bytesToHex$3(e[0][0]),relays:e[1]?e[1].map(e=>utf8Decoder.decode(e)):[],author:e[2]?.[0]?bytesToHex$3(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(bytesToHex$3(e[3][0]),16):void 0}}}case"naddr":{let e=parseTLV(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:utf8Decoder.decode(e[0][0]),pubkey:bytesToHex$3(e[2][0]),kind:parseInt(bytesToHex$3(e[3][0]),16),relays:e[1]?e[1].map(e=>utf8Decoder.decode(e)):[]}}}case"nrelay":{let e=parseTLV(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nrelay");return{type:"nrelay",data:utf8Decoder.decode(e[0][0])}}case"nsec":case"npub":case"note":return{type:t,data:bytesToHex$3(r)};default:throw new Error(`unknown prefix ${t}`)}}function parseTLV(e){let t={},n=e;for(;n.length>0;){let e=n[0],r=n[1];if(!r)throw new Error(`malformed TLV ${e}`);let i=n.slice(2,2+r);if(n=n.slice(2+r),i.length<r)throw new Error(`not enough data to read on TLV ${e}`);t[e]=t[e]||[],t[e].push(i)}return t}function nsecEncode(e){return encodeBytes("nsec",e)}function npubEncode(e){return encodeBytes("npub",e)}function noteEncode(e){return encodeBytes("note",e)}function encodeBech32(e,t){let n=bech32.toWords(t);return bech32.encode(e,n,Bech32MaxSize)}function encodeBytes(e,t){return encodeBech32(e,hexToBytes$3(t))}function nprofileEncode(e){return encodeBech32("nprofile",encodeTLV({0:[hexToBytes$3(e.pubkey)],1:(e.relays||[]).map(e=>utf8Encoder.encode(e))}))}function neventEncode(e){let t;return null!=e.kind&&(t=integerToUint8Array(e.kind)),encodeBech32("nevent",encodeTLV({0:[hexToBytes$3(e.id)],1:(e.relays||[]).map(e=>utf8Encoder.encode(e)),2:e.author?[hexToBytes$3(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function naddrEncode(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),encodeBech32("naddr",encodeTLV({0:[utf8Encoder.encode(e.identifier)],1:(e.relays||[]).map(e=>utf8Encoder.encode(e)),2:[hexToBytes$3(e.pubkey)],3:[new Uint8Array(t)]}))}function nrelayEncode(e){return encodeBech32("nrelay",encodeTLV({0:[utf8Encoder.encode(e)]}))}function encodeTLV(e){let t=[];return Object.entries(e).forEach(([e,n])=>{n.forEach(n=>{let r=new Uint8Array(n.length+2);r.set([parseInt(e)],0),r.set([n.length],1),r.set(n,2),t.push(r)})}),concatBytes$4(...t)}var nip04_exports={};async function encrypt(e,t,n){const r=getNormalizedX(secp256k1$1.getSharedSecret(e,"02"+t));let i=Uint8Array.from(randomBytes$2(16)),s=utf8Encoder.encode(n),o=await crypto.subtle.importKey("raw",r,{name:"AES-CBC"},!1,["encrypt"]),a=await crypto.subtle.encrypt({name:"AES-CBC",iv:i},o,s);return`${base64.encode(new Uint8Array(a))}?iv=${base64.encode(new Uint8Array(i.buffer))}`}async function decrypt(e,t,n){let[r,i]=n.split("?iv="),s=getNormalizedX(secp256k1$1.getSharedSecret(e,"02"+t)),o=await crypto.subtle.importKey("raw",s,{name:"AES-CBC"},!1,["decrypt"]),a=base64.decode(r),c=base64.decode(i),l=await crypto.subtle.decrypt({name:"AES-CBC",iv:c},o,a);return utf8Decoder.decode(l)}function getNormalizedX(e){return e.slice(1,33)}__export(nip04_exports,{decrypt:()=>decrypt,encrypt:()=>encrypt}),"undefined"!=typeof crypto&&!crypto.subtle&&crypto.webcrypto&&(crypto.subtle=crypto.webcrypto.subtle);var nip05_exports={};__export(nip05_exports,{NIP05_REGEX:()=>NIP05_REGEX,queryProfile:()=>queryProfile,searchDomain:()=>searchDomain,useFetchImplementation:()=>useFetchImplementation});var NIP05_REGEX=/^(?:([\w.+-]+)@)?([\w.-]+)$/,_fetch;try{_fetch=fetch}catch{}function useFetchImplementation(e){_fetch=e}async function searchDomain(e,t=""){try{return(await(await _fetch(`https://${e}/.well-known/nostr.json?name=${t}`)).json()).names}catch(e){return{}}}async function queryProfile(e){const t=e.match(NIP05_REGEX);if(!t)return null;const[n,r="_",i]=t;try{const e=await _fetch(`https://${i}/.well-known/nostr.json?name=${r}`),{names:t,relays:n}=parseNIP05Result(await e.json()),s=t[r];return s?{pubkey:s,relays:n?.[s]}:null}catch(e){return null}}function parseNIP05Result(e){const t={names:{}};for(const[n,r]of Object.entries(e.names))"string"==typeof n&&"string"==typeof r&&(t.names[n]=r);if(e.relays){t.relays={};for(const[n,r]of Object.entries(e.relays))"string"==typeof n&&Array.isArray(r)&&(t.relays[n]=r.filter(e=>"string"==typeof e))}return t}var nip06_exports={};function privateKeyFromSeedWords(e,t){let n=HDKey.fromMasterSeed(mnemonicToSeedSync(e,t)).derive("m/44'/1237'/0'/0/0").privateKey;if(!n)throw new Error("could not derive private key");return bytesToHex$3(n)}function generateSeedWords(){return generateMnemonic(wordlist)}function validateWords(e){return validateMnemonic(e,wordlist)}__export(nip06_exports,{generateSeedWords:()=>generateSeedWords,privateKeyFromSeedWords:()=>privateKeyFromSeedWords,validateWords:()=>validateWords});var nip10_exports={};function parse(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[]},n=[];for(const r of e.tags)"e"===r[0]&&r[1]&&n.push(r),"p"===r[0]&&r[1]&&t.profiles.push({pubkey:r[1],relays:r[2]?[r[2]]:[]});for(let e=0;e<n.length;e++){const r=n[e],[i,s,o,a]=r,c={id:s,relays:o?[o]:[]},l=0===e,h=e===n.length-1;"root"!==a?"reply"!==a?"mention"!==a?l?t.root=c:h?t.reply=c:t.mentions.push(c):t.mentions.push(c):t.reply=c:t.root=c}return t}__export(nip10_exports,{parse:()=>parse});var nip13_exports={};function getPow(e){let t=0;for(let n=0;n<e.length;n++){const r=parseInt(e[n],16);if(0!==r){t+=Math.clz32(r)-28;break}t+=4}return t}function minePow(e,t){let n=0;const r=e,i=["nonce",n.toString(),t.toString()];for(r.tags.push(i);;){const e=Math.floor((new Date).getTime()/1e3);if(e!==r.created_at&&(n=0,r.created_at=e),i[1]=(++n).toString(),r.id=getEventHash(r),getPow(r.id)>=t)break}return r}__export(nip13_exports,{getPow:()=>getPow,minePow:()=>minePow});var nip18_exports={};function finishRepostEvent(e,t,n,r){return finishEvent({kind:6,tags:[...e.tags??[],["e",t.id,n],["p",t.pubkey]],content:""===e.content?"":JSON.stringify(t),created_at:e.created_at},r)}function getRepostedEventPointer(e){if(6!==e.kind)return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const i=e.tags[r];i.length>=2&&("e"===i[0]&&void 0===t?t=i:"p"===i[0]&&void 0===n&&(n=i))}return void 0!==t?{id:t[1],relays:[t[2],n?.[2]].filter(e=>"string"==typeof e),author:n?.[1]}:void 0}function getRepostedEvent(e,{skipVerification:t}={}){const n=getRepostedEventPointer(e);if(void 0===n||""===e.content)return;let r;try{r=JSON.parse(e.content)}catch(e){return}return r.id===n.id&&(t||verifySignature(r))?r:void 0}__export(nip18_exports,{finishRepostEvent:()=>finishRepostEvent,getRepostedEvent:()=>getRepostedEvent,getRepostedEventPointer:()=>getRepostedEventPointer});var nip21_exports={};__export(nip21_exports,{NOSTR_URI_REGEX:()=>NOSTR_URI_REGEX,parse:()=>parse2,test:()=>test});var NOSTR_URI_REGEX=new RegExp(`nostr:(${BECH32_REGEX.source})`);function test(e){return"string"==typeof e&&new RegExp(`^${NOSTR_URI_REGEX.source}$`).test(e)}function parse2(e){const t=e.match(new RegExp(`^${NOSTR_URI_REGEX.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:decode(t[1])}}var nip25_exports={};function finishReactionEvent(e,t,n){const r=t.tags.filter(e=>e.length>=2&&("e"===e[0]||"p"===e[0]));return finishEvent({...e,kind:7,tags:[...e.tags??[],...r,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function getReactedEventPointer(e){if(7!==e.kind)return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const i=e.tags[r];i.length>=2&&("e"===i[0]&&void 0===t?t=i:"p"===i[0]&&void 0===n&&(n=i))}return void 0!==t&&void 0!==n?{id:t[1],relays:[t[2],n[2]].filter(e=>void 0!==e),author:n[1]}:void 0}__export(nip25_exports,{finishReactionEvent:()=>finishReactionEvent,getReactedEventPointer:()=>getReactedEventPointer});var nip26_exports={};function createDelegation(e,t){let n=[];(t.kind||-1)>=0&&n.push(`kind=${t.kind}`),t.until&&n.push(`created_at<${t.until}`),t.since&&n.push(`created_at>${t.since}`);let r=n.join("&");if(""===r)throw new Error("refusing to create a delegation without any conditions");let i=sha256$3(utf8Encoder.encode(`nostr:delegation:${t.pubkey}:${r}`)),s=bytesToHex$3(schnorr.sign(i,e));return{from:getPublicKey(e),to:t.pubkey,cond:r,sig:s}}function getDelegator(e){let t=e.tags.find(e=>"delegation"===e[0]&&e.length>=4);if(!t)return null;let n=t[1],r=t[2],i=t[3],s=r.split("&");for(let t=0;t<s.length;t++){let[n,r,i]=s[t].split(/\b/);if(("kind"!==n||"="!==r||e.kind!==parseInt(i))&&!("created_at"===n&&"<"===r&&e.created_at<parseInt(i)||"created_at"===n&&">"===r&&e.created_at>parseInt(i)))return null}let o=sha256$3(utf8Encoder.encode(`nostr:delegation:${e.pubkey}:${r}`));return schnorr.verify(i,o,n)?n:null}__export(nip26_exports,{createDelegation:()=>createDelegation,getDelegator:()=>getDelegator});var nip27_exports={};__export(nip27_exports,{matchAll:()=>matchAll,regex:()=>regex,replaceAll:()=>replaceAll});var regex=()=>new RegExp(`\\b${NOSTR_URI_REGEX.source}\\b`,"g");function*matchAll(e){const t=e.matchAll(regex());for(const e of t)try{const[t,n]=e;yield{uri:t,value:n,decoded:decode(n),start:e.index,end:e.index+t.length}}catch(e){}}function replaceAll(e,t){return e.replaceAll(regex(),(e,n)=>t({uri:e,value:n,decoded:decode(n)}))}var nip28_exports={};__export(nip28_exports,{channelCreateEvent:()=>channelCreateEvent,channelHideMessageEvent:()=>channelHideMessageEvent,channelMessageEvent:()=>channelMessageEvent,channelMetadataEvent:()=>channelMetadataEvent,channelMuteUserEvent:()=>channelMuteUserEvent});var channelCreateEvent=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return finishEvent({kind:40,tags:[...e.tags??[]],content:n,created_at:e.created_at},t)},channelMetadataEvent=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return finishEvent({kind:41,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},channelMessageEvent=(e,t)=>{const n=[["e",e.channel_create_event_id,e.relay_url,"root"]];return e.reply_to_channel_message_event_id&&n.push(["e",e.reply_to_channel_message_event_id,e.relay_url,"reply"]),finishEvent({kind:42,tags:[...n,...e.tags??[]],content:e.content,created_at:e.created_at},t)},channelHideMessageEvent=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return finishEvent({kind:43,tags:[["e",e.channel_message_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},channelMuteUserEvent=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return finishEvent({kind:44,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)},nip39_exports={},_fetch2;__export(nip39_exports,{useFetchImplementation:()=>useFetchImplementation2,validateGithub:()=>validateGithub});try{_fetch2=fetch}catch{}function useFetchImplementation2(e){_fetch2=e}async function validateGithub(e,t,n){try{return await(await _fetch2(`https://gist.github.com/${t}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch(e){return!1}}var nip42_exports={};__export(nip42_exports,{authenticate:()=>authenticate});var authenticate=async({challenge:e,relay:t,sign:n})=>{const r={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t.url],["challenge",e]],content:""};return t.auth(await n(r))},nip44_exports={};__export(nip44_exports,{decrypt:()=>decrypt2,encrypt:()=>encrypt2,utils:()=>utils});var utils={v2:{maxPlaintextSize:65408,minCiphertextSize:100,maxCiphertextSize:102400,getConversationKey:(e,t)=>secp256k1$1.getSharedSecret(e,"02"+t).subarray(1,33),getMessageKeys(e,t){const n=hkdf(sha256$3,e,t,"nip44-v2",76);return{encryption:n.subarray(0,32),nonce:n.subarray(32,44),auth:n.subarray(44,76)}},calcPadding(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("expected positive integer");if(e<=32)return 32;const t=1<<Math.floor(Math.log2(e-1))+1,n=t<=256?32:t/8;return n*(Math.floor((e-1)/n)+1)},pad(e){const t=utf8Encoder.encode(e),n=t.length;if(n<1||n>=utils.v2.maxPlaintextSize)throw new Error("invalid plaintext length: must be between 1b and 64KB");const r=utils.v2.calcPadding(n),i=new Uint8Array(r-n),s=new Uint8Array(2);return new DataView(s.buffer).setUint16(0,n),concatBytes$4(s,t,i)},unpad(e){const t=new DataView(e.buffer).getUint16(0),n=e.subarray(2,2+t);if(0===t||n.length!==t||e.length!==2+utils.v2.calcPadding(t))throw new Error("invalid padding");return utf8Decoder.decode(n)}}};function encrypt2(e,t,n={}){const r=n.version??2;if(2!==r)throw new Error("unknown encryption version "+r);const i=n.salt??randomBytes$2(32);ensureBytes(i,32);const s=utils.v2.getMessageKeys(e,i),o=utils.v2.pad(t),a=chacha20(s.encryption,s.nonce,o),c=hmac$3(sha256$3,s.auth,a);return base64.encode(concatBytes$4(new Uint8Array([r]),i,a,c))}function decrypt2(e,t){const n=utils.v2;ensureBytes(e,32);const r=t.length;if(r<n.minCiphertextSize||r>=n.maxCiphertextSize)throw new Error("invalid ciphertext length: "+r);if("#"===t[0])throw new Error("unknown encryption version");let i;try{i=base64.decode(t)}catch(e){throw new Error("invalid base64: "+e.message)}const s=i.subarray(0,1)[0];if(2!==s)throw new Error("unknown encryption version "+s);const o=i.subarray(1,33),a=i.subarray(33,-32),c=i.subarray(-32),l=n.getMessageKeys(e,o);if(!equalBytes(hmac$3(sha256$3,l.auth,a),c))throw new Error("invalid MAC");const h=chacha20(l.encryption,l.nonce,a);return n.unpad(h)}var nip47_exports={};function parseConnectionString(e){const{pathname:t,searchParams:n}=new URL(e),r=t,i=n.get("relay"),s=n.get("secret");if(!r||!i||!s)throw new Error("invalid connection string");return{pubkey:r,relay:i,secret:s}}async function makeNwcRequestEvent({pubkey:e,secret:t,invoice:n}){const r={method:"pay_invoice",params:{invoice:n}},i=await encrypt(t,e,JSON.stringify(r));return finishEvent({kind:23194,created_at:Math.round(Date.now()/1e3),content:i,tags:[["p",e]]},t)}__export(nip47_exports,{makeNwcRequestEvent:()=>makeNwcRequestEvent,parseConnectionString:()=>parseConnectionString});var nip57_exports={},_fetch3;__export(nip57_exports,{getZapEndpoint:()=>getZapEndpoint,makeZapReceipt:()=>makeZapReceipt,makeZapRequest:()=>makeZapRequest,useFetchImplementation:()=>useFetchImplementation3,validateZapRequest:()=>validateZapRequest});try{_fetch3=fetch}catch{}function useFetchImplementation3(e){_fetch3=e}async function getZapEndpoint(e){try{let t="",{lud06:n,lud16:r}=JSON.parse(e.content);if(n){let{words:e}=bech32.decode(n,1e3),r=bech32.fromWords(e);t=utf8Decoder.decode(r)}else{if(!r)return null;{let[e,n]=r.split("@");t=`https://${n}/.well-known/lnurlp/${e}`}}let i=await _fetch3(t),s=await i.json();if(s.allowsNostr&&s.nostrPubkey)return s.callback}catch(e){}return null}function makeZapRequest({profile:e,event:t,amount:n,relays:r,comment:i=""}){if(!n)throw new Error("amount not given");if(!e)throw new Error("profile not given");let s={kind:9734,created_at:Math.round(Date.now()/1e3),content:i,tags:[["p",e],["amount",n.toString()],["relays",...r]]};return t&&s.tags.push(["e",t]),s}function validateZapRequest(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!validateEvent(t))return"Zap request is not a valid Nostr event.";if(!verifySignature(t))return"Invalid signature on zap request.";let n=t.tags.find(([e,t])=>"p"===e&&t);if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let r=t.tags.find(([e,t])=>"e"===e&&t);return r&&!r[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":t.tags.find(([e,t])=>"relays"===e&&t)?null:"Zap request doesn't have a 'relays' tag."}function makeZapReceipt({zapRequest:e,preimage:t,bolt11:n,paidAt:r}){let i=JSON.parse(e).tags.filter(([e])=>"e"===e||"p"===e||"a"===e),s={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...i,["bolt11",n],["description",e]]};return t&&s.tags.push(["preimage",t]),s}var nip98_exports={};__export(nip98_exports,{getToken:()=>getToken,unpackEventFromToken:()=>unpackEventFromToken,validateEvent:()=>validateEvent2,validateToken:()=>validateToken});var _authorizationScheme="Nostr ";async function getToken(e,t,n,r=!1){if(!e||!t)throw new Error("Missing loginUrl or httpMethod");const i=getBlankEvent(27235);i.tags=[["u",e],["method",t]],i.created_at=Math.round((new Date).getTime()/1e3);const s=await n(i);return(r?_authorizationScheme:"")+base64.encode(utf8Encoder.encode(JSON.stringify(s)))}async function validateToken(e,t,n){const r=await unpackEventFromToken(e).catch(e=>{throw e});return await validateEvent2(r,t,n).catch(e=>{throw e})}async function unpackEventFromToken(e){if(!e)throw new Error("Missing token");e=e.replace(_authorizationScheme,"");const t=utf8Decoder.decode(base64.decode(e));if(!t||0===t.length||!t.startsWith("{"))throw new Error("Invalid token");return JSON.parse(t)}async function validateEvent2(e,t,n){if(!e)throw new Error("Invalid nostr event");if(!verifySignature(e))throw new Error("Invalid nostr event, signature invalid");if(27235!==e.kind)throw new Error("Invalid nostr event, kind invalid");if(!e.created_at)throw new Error("Invalid nostr event, created_at invalid");if(Math.round((new Date).getTime()/1e3)-e.created_at>60)throw new Error("Invalid nostr event, expired");const r=e.tags.find(e=>"u"===e[0]);if(1!==r?.length&&r?.[1]!==t)throw new Error("Invalid nostr event, url tag invalid");const i=e.tags.find(e=>"method"===e[0]);if(1!==i?.length&&i?.[1].toLowerCase()!==n.toLowerCase())throw new Error("Invalid nostr event, method tag invalid");return!0}const LOCAL_STORE_KEY="__nostrlogin_nip46",LOGGED_IN_ACCOUNTS="__nostrlogin_accounts",RECENT_ACCOUNTS="__nostrlogin_recent",OUTBOX_RELAYS$1=["wss://purplepag.es","wss://relay.nos.social","wss://user.kindpag.es","wss://relay.damus.io","wss://nos.lol"],DEFAULT_SIGNUP_RELAYS=["wss://relay.damus.io/","wss://nos.lol/","wss://relay.primal.net/"],localStorageSetItem=(e,t)=>{localStorage.setItem(e,t)},localStorageGetItem=e=>{const t=window.localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch{}return null},localStorageRemoveItem=e=>{localStorage.removeItem(e)},fetchProfile=async(e,t)=>{const n=new NDKUser({pubkey:e.pubkey});return n.ndk=t,await n.fetchProfile()},prepareSignupRelays=e=>{const t=(e||"").split(",").map(e=>e.trim()).filter(e=>e.startsWith("ws"));return t.length||t.push(...DEFAULT_SIGNUP_RELAYS),t},createProfile=async(e,t,n,r,i)=>{const s={name:e.name},o=new NDKEvent(t,{kind:0,created_at:Math.floor(Date.now()/1e3),pubkey:e.pubkey,content:JSON.stringify(s),tags:[]});window.location.hostname&&o.tags.push(["client",window.location.hostname]);const a=new NDKEvent(t,{kind:10002,created_at:Math.floor(Date.now()/1e3),pubkey:e.pubkey,content:"",tags:[]}),c=prepareSignupRelays(r);for(const e of c)a.tags.push(["r",e]);await o.sign(n),console.log("signed profile",o),await a.sign(n),console.log("signed relays",a);const l=i&&i.length?i:OUTBOX_RELAYS$1;await o.publish(NDKRelaySet.fromRelayUrls(l,t)),console.log("published profile",o),await a.publish(NDKRelaySet.fromRelayUrls(l,t)),console.log("published relays",a)},bunkerUrlToInfo=(e,t="")=>{const n=new URL(e);return{pubkey:"",signerPubkey:n.hostname||n.pathname.split("//")[1],sk:t||generatePrivateKey(),relays:n.searchParams.getAll("relay"),token:n.searchParams.get("secret")||"",authMethod:"connect"}},isBunkerUrl=e=>e.startsWith("bunker://"),getBunkerUrl=async(e,t)=>{if(!e)return"";if(isBunkerUrl(e))return e;if(e.includes("@")){const[n,r]=e.toLocaleLowerCase().split("@"),i=t.devOverrideBunkerOrigin||`https://${r}`,s=`${i}/.well-known/nostr.json?name=_`,o=`${i}/.well-known/nostr.json?name=${n}`,a=await fetch(s),c=await a.json(),l=c.names._,h=c.nip46[l],d=await fetch(o),u=(await d.json()).names[n];if(!h.length)throw new Error("Bunker relay not provided");return`bunker://${u}?relay=${h[0]}`}throw new Error("Invalid user name or bunker url")},checkNip05=async e=>{let t=!1,n="",r="";return await(async()=>{if(!e||!e.includes("@"))return;const[i,s]=e.toLocaleLowerCase().split("@");if(!i)return;if(!new RegExp(/^[\w-.]+@([\w-]+\.)+[\w-]{2,8}$/g).test(e))return void(n="Invalid name");if(!s)return void(n="Select service");const o=`https://${s}/.well-known/nostr.json?name=${i.toLowerCase()}`;try{const e=await fetch(o),t=await e.json();if(t.names[i])return void(r=t.names[i])}catch{}t=!0})(),{available:t,taken:""!=r,error:n,pubkey:r}},upgradeInfo=e=>{"typeAuthMethod"in e&&delete e.typeAuthMethod,e.authMethod||("extension"in e&&e.extension?e.authMethod="extension":"readOnly"in e&&e.readOnly?e.authMethod="readOnly":e.authMethod="connect"),e.nip05&&isBunkerUrl(e.nip05)&&(e.bunkerUrl=e.nip05,e.nip05=""),"connect"!==e.authMethod||e.signerPubkey||(e.signerPubkey=e.pubkey)},localStorageAddAccount=e=>{localStorageSetItem(LOCAL_STORE_KEY,JSON.stringify(e));const t=localStorageGetItem(LOGGED_IN_ACCOUNTS)||[],n=localStorageGetItem(RECENT_ACCOUNTS)||[];t.forEach(e=>upgradeInfo(e)),n.forEach(e=>upgradeInfo(e));const r=t,i=t.findIndex(t=>t.pubkey===e.pubkey&&t.authMethod===e.authMethod);-1!==i?r[i]=e:r.push(e);const s=n.filter(t=>t.pubkey!==e.pubkey||t.authMethod!==e.authMethod);localStorageSetItem(RECENT_ACCOUNTS,JSON.stringify(s)),localStorageSetItem(LOGGED_IN_ACCOUNTS,JSON.stringify(r))},localStorageRemoveCurrentAccount=()=>{const e=localStorageGetItem(LOCAL_STORE_KEY);if(!e)return;upgradeInfo(e);const t={...e};delete t.sk,delete t.otpData;const n=localStorageGetItem(LOGGED_IN_ACCOUNTS)||[],r=localStorageGetItem(RECENT_ACCOUNTS)||[];n.forEach(e=>upgradeInfo(e)),r.forEach(e=>upgradeInfo(e));const i=r;if("connect"===t.authMethod&&t.bunkerUrl&&t.bunkerUrl.includes("secret="))console.log("nostr login bunker conn with a secret not saved to recent");else if("local"===t.authMethod)console.log("nostr login temporary local keys not save to recent");else{const e=r.findIndex(e=>e.pubkey===t.pubkey&&e.authMethod===t.authMethod);-1!==e?i[e]=t:i.push(t)}const s=n.filter(t=>t.pubkey!==e.pubkey||t.authMethod!==e.authMethod);localStorageSetItem(RECENT_ACCOUNTS,JSON.stringify(i)),localStorageSetItem(LOGGED_IN_ACCOUNTS,JSON.stringify(s)),localStorageRemoveItem(LOCAL_STORE_KEY)},localStorageRemoveRecent=e=>{const t=localStorageGetItem(RECENT_ACCOUNTS)||[];t.forEach(e=>upgradeInfo(e));const n=t.filter(t=>t.pubkey!==e.pubkey||t.authMethod!==e.authMethod);localStorageSetItem(RECENT_ACCOUNTS,JSON.stringify(n))},localStorageGetRecents=()=>{const e=localStorageGetItem(RECENT_ACCOUNTS)||[];return e.forEach(e=>upgradeInfo(e)),e},localStorageGetAccounts=()=>{const e=localStorageGetItem(LOGGED_IN_ACCOUNTS)||[];return e.forEach(e=>upgradeInfo(e)),e},localStorageGetCurrent=()=>{const e=localStorageGetItem(LOCAL_STORE_KEY);return e&&upgradeInfo(e),e},getDarkMode=e=>{const t=localStorage.getItem("nl-dark-mode");return t?Boolean(JSON.parse(t)):void 0!==e.darkMode?e.darkMode:!(!window.matchMedia||!window.matchMedia("(prefers-color-scheme: dark)").matches)},getIcon=async()=>document.location.origin+"/favicon.ico";class NostrRpc extends NDKNostrRpc{_ndk;_signer;requests=new Set;sub;_useNip44=!1;constructor(e,t){super(e,t,e.debug.extend("nip46:signer:rpc")),this._ndk=e,this._signer=t}async subscribe(e){return e.kinds=e.kinds?.filter(e=>24133===e),this.sub=await super.subscribe(e),this.sub}stop(){this.sub&&(this.sub.stop(),this.sub=void 0)}setUseNip44(e){this._useNip44=e}isNip04(e){const t=e.length;return!(t<28)&&("?"===e[t-28]&&"i"===e[t-27]&&"v"===e[t-26]&&"="===e[t-25])}async parseEvent(e){const t=this._ndk.getUser({pubkey:e.pubkey});t.ndk=this._ndk;const n=this.isNip04(e.content)?await this._signer.decrypt(t,e.content,"nip04"):await this._signer.decrypt(t,e.content,"nip44"),r=JSON.parse(n),{id:i,method:s,params:o,result:a,error:c}=r;return s?{id:i,pubkey:e.pubkey,method:s,params:o,event:e}:{id:i,result:a,error:c,event:e}}async parseNostrConnectReply(e,t){const n=new NDKEvent(this._ndk,e),r=await this.parseEvent(n);if(console.log("nostr connect parsedEvent",r),r.method)throw new Error("Bad nostr connect reply");{const e=r;if(e.result!==t)throw new Error(e.error);return n.pubkey}}async listen(e){const t=this._signer.pubkey;console.log("nostr-login listening for conn to",t);const n=await this.subscribe({kinds:[24133],"#p":[t]});return new Promise((t,r)=>{n.on("event",async n=>{try{const i=await this.parseEvent(n);if(!i.method){const s=i;if("auth_url"===s.result)return;"ack"===s.result||s.result===e?t(n.pubkey):r(s.error)}}catch(e){console.log("error parsing event",e,n.rawEvent())}this.stop()})})}async connect(e,t,n){return new Promise((r,i)=>{const s=[e,t||"",n||""];this.sendRequest(e,"connect",s,24133,e=>{"ack"===e.result?r():i(e.error)})})}getId(){return Math.random().toString(36).substring(7)}async sendRequest(e,t,n=[],r=24133,i){const s=this.getId(),o=this.setResponseHandler(s,i),a=await this.createRequestEvent(s,e,t,n,r);return await a.publish(),o}setResponseHandler(e,t){const n=Date.now();let r=!1;return new Promise(i=>{const s=o=>{console.log(`[NIP46] Received response for ID: ${o.id}`,o),"auth_url"===o.result?(this.once(`response-${e}`,s),r||(r=!0,this.emit("authUrl",o.error))):this.requests.has(e)?(this.requests.delete(e),console.log("nostr-login processed nip46 request in",Date.now()-n,"ms"),t&&t(o),i(o)):console.warn(`[NIP46] Received response for unknown ID: ${e}`)};this.once(`response-${e}`,s)})}async createRequestEvent(e,t,n,r=[],i=24133){this.requests.add(e);const s=await this._signer.user(),o=this._ndk.getUser({pubkey:t}),a={id:e,method:n,params:r},c=new NDKEvent(this._ndk,{kind:i,content:JSON.stringify(a),tags:[["p",t]],pubkey:s.pubkey}),l=this._useNip44&&"create_account"!==n;return c.content=l?await this._signer.encrypt(o,c.content,"nip44"):await this._signer.encrypt(o,c.content,"nip04"),await c.sign(this._signer),c}}class IframeNostrRpc extends NostrRpc{peerOrigin;iframePort;iframeRequests=new Map;constructor(e,t,n){super(e,t),this._ndk=e,this.peerOrigin=n}async subscribe(e){return this.peerOrigin?new NDKSubscription(this._ndk,{},{closeOnEose:!0,cacheUsage:NDKSubscriptionCacheUsage.ONLY_CACHE}):super.subscribe(e)}setWorkerIframePort(e){if(!this.peerOrigin)throw new Error("Unexpected iframe port");this.iframePort=e,setInterval(()=>{console.log("iframe-nip46 ping"),this.iframePort.postMessage("ping")},5e3),e.onmessage=async e=>{if(console.log("iframe-nip46 got response",e.data),"string"==typeof e.data&&e.data.startsWith("errorNoKey")){const t=e.data.split(":")[1],{id:n="",pubkey:r=""}=this.iframeRequests.get(t)||{};return void(n&&r&&this.requests.has(n)&&this.emit(`iframeRestart-${r}`))}try{const t=e.data;if(!validateEvent(t))throw new Error("Invalid event from iframe");if(!verifySignature(t))throw new Error("Invalid event signature from iframe");const n=new NDKEvent(this._ndk,t),r=await this.parseEvent(n);r.method||(console.log("parsed response",r),this.emit(`response-${r.id}`,r))}catch(t){console.log("error parsing event",t,e.data)}}}async sendRequest(e,t,n=[],r=24133,i){const s=this.getId(),o=await this.createRequestEvent(s,e,t,n,r);this.setResponseHandler(s,i),this.iframePort?(this.iframeRequests.set(o.id,{id:s,pubkey:e}),console.log("iframe-nip46 sending request to",this.peerOrigin,o.rawEvent()),this.iframePort.postMessage(o.rawEvent())):await o.publish()}}class ReadyListener{origin;messages;promise;constructor(e,t){this.origin=t,this.messages=e,this.promise=new Promise(e=>{console.log(new Date,"started listener for",this.messages);const n=async r=>{const i=new URL(t).hostname,s=new URL(r.origin).hostname;(s===i||s.endsWith("."+i))&&Array.isArray(r.data)&&r.data.length&&this.messages.includes(r.data[0])&&(console.log(new Date,"got ready message from",r.origin,r.data),window.removeEventListener("message",n),e(r.data))};window.addEventListener("message",n)})}async wait(){console.log(new Date,"waiting for",this.messages);const e=await this.promise;return console.log(new Date,"finished waiting for",this.messages,e),e}}class Nip46Signer extends NDKNip46Signer{_rpc;_remotePubkey="";constructor(e,t,n,r){super(e,n,t),this._remotePubkey=n,this._rpc=new IframeNostrRpc(e,t,r),this._rpc.setUseNip44(!0),this._rpc.on("authUrl",e=>{this.emit("authUrl",e)}),this.rpc=this._rpc}get remotePubkey(){return this._remotePubkey}set remotePubkey(e){this._remotePubkey=e}async setSignerPubkey(e,t=!1){console.log("setSignerPubkey",e),this.remotePubkey=e,this._rpc.on(`iframeRestart-${e}`,()=>{this.emit("iframeRestart")}),await this.initUserPubkey(t?e:"")}async initUserPubkey(e){if(this.userPubkey)throw new Error("Already called initUserPubkey");this.userPubkey=e||await new Promise((e,t)=>{if(!this.remotePubkey)throw new Error("Signer pubkey not set");console.log("get_public_key",this.remotePubkey),this._rpc.sendRequest(this.remotePubkey,"get_public_key",[],24133,t=>{e(t.result)})})}async listen(e){const t=await this.rpc.listen(e);await this.setSignerPubkey(t)}async connect(e,t){if(!this.remotePubkey)throw new Error("No signer pubkey");await this._rpc.connect(this.remotePubkey,e,t),await this.setSignerPubkey(this.remotePubkey)}async setListenReply(e,t){const n=await this._rpc.parseNostrConnectReply(e,t);await this.setSignerPubkey(n,!0)}async createAccount2({bunkerPubkey:e,name:t,domain:n,perms:r=""}){const i=[t,n,"",r],s=await new Promise(t=>{this.rpc.sendRequest(e,"create_account",i,void 0,t)});if(console.log("create_account pubkey",s),"error"===s.result)throw new Error(s.error);return s.result}}class BannerManager extends lib$1.EventEmitter{banner=null;iframeReady;params;constructor(e){super(),this.params=e}onAuthUrl(e,t){this.banner&&(this.banner.notify=e?{mode:t?"iframeAuthUrl":"authUrl",url:e}:{mode:""})}onIframeRestart(e){this.banner&&(this.iframeReady=new ReadyListener(["rebinderDone","rebinderError"],new URL(e).origin),this.banner.notify={mode:"rebind",url:e})}onUserInfo(e){this.banner&&(this.banner.userInfo=e)}onCallTimeout(){this.banner&&(this.banner.notify={mode:"timeout"})}onCallStart(){this.banner&&(this.banner.isLoading=!0)}async onCallEnd(){this.banner&&(this.iframeReady&&(await this.iframeReady.wait(),this.iframeReady=void 0),this.banner.isLoading=!1,this.banner.notify={mode:""})}onUpdateAccounts(e){this.banner&&(this.banner.accounts=e)}onDarkMode(e){this.banner&&(this.banner.darkMode=e)}launchAuthBanner(e){this.banner=document.createElement("nl-banner"),this.banner.setAttribute("dark-mode",String(getDarkMode(e))),e.theme&&this.banner.setAttribute("theme",e.theme),e.noBanner&&this.banner.setAttribute("hidden-mode","true"),this.banner.addEventListener("handleLoginBanner",e=>{this.emit("launch",e.detail)}),this.banner.addEventListener("handleConfirmLogout",()=>{this.emit("onConfirmLogout")}),this.banner.addEventListener("handleLogoutBanner",async()=>{this.emit("logout")}),this.banner.addEventListener("handleImportModal",e=>{this.emit("import")}),this.banner.addEventListener("handleNotifyConfirmBanner",e=>{this.emit("onAuthUrlClick",e.detail)}),this.banner.addEventListener("handleNotifyConfirmBannerIframe",e=>{this.emit("onIframeAuthUrlClick",e.detail)}),this.banner.addEventListener("handleSwitchAccount",e=>{this.emit("onSwitchAccount",e.detail)}),this.banner.addEventListener("handleOpenWelcomeModal",()=>{this.emit("launch"),this.banner&&(this.banner.isOpen=!1)}),document.body.appendChild(this.banner)}}const decoder=new TextDecoder,u={minPlaintextSize:1,maxPlaintextSize:65535,utf8Encode:utf8ToBytes$6,utf8Decode:e=>decoder.decode(e),getConversationKey(e,t){const n=secp256k1$1.getSharedSecret(e,"02"+t).subarray(1,33);return extract(sha256$3,n,"nip44-v2")},getMessageKeys(e,t){const n=expand(sha256$3,e,t,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}},calcPaddedLen(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("expected positive integer");if(e<=32)return 32;const t=1<<Math.floor(Math.log2(e-1))+1,n=t<=256?32:t/8;return n*(Math.floor((e-1)/n)+1)},writeU16BE(e){if(!Number.isSafeInteger(e)||e<u.minPlaintextSize||e>u.maxPlaintextSize)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e,!1),t},pad(e){const t=u.utf8Encode(e),n=t.length;return concatBytes$4(u.writeU16BE(n),t,new Uint8Array(u.calcPaddedLen(n)-n))},unpad(e){const t=new DataView(e.buffer).getUint16(0),n=e.subarray(2,2+t);if(t<u.minPlaintextSize||t>u.maxPlaintextSize||n.length!==t||e.length!==2+u.calcPaddedLen(t))throw new Error("invalid padding");return u.utf8Decode(n)},hmacAad(e,t,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const r=concatBytes$4(n,t);return hmac$3(sha256$3,e,r)},decodePayload(e){if("string"!=typeof e)throw new Error("payload must be a valid string");const t=e.length;if(t<132||t>87472)throw new Error("invalid payload length: "+t);if("#"===e[0])throw new Error("unknown encryption version");let n;try{n=base64.decode(e)}catch(e){throw new Error("invalid base64: "+e.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const i=n[0];if(2!==i)throw new Error("unknown encryption version "+i);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}};function encryptNip44(e,t,n=randomBytes$2(32)){const{chacha_key:r,chacha_nonce:i,hmac_key:s}=u.getMessageKeys(t,n),o=u.pad(e),a=chacha20(r,i,o),c=u.hmacAad(s,a,n);return base64.encode(concatBytes$4(new Uint8Array([2]),n,a,c))}function decryptNip44(e,t){const{nonce:n,ciphertext:r,mac:i}=u.decodePayload(e),{chacha_key:s,chacha_nonce:o,hmac_key:a}=u.getMessageKeys(t,n);if(!equalBytes(u.hmacAad(a,r,n),i))throw new Error("invalid MAC");const c=chacha20(s,o,r);return u.unpad(c)}class Nip44{cache=new Map;createKey(e,t){return u.getConversationKey(e,t)}getKey(e,t,n){const r=getPublicKey(e)+t;let i=this.cache.get(r);if(i)return i;const s=this.createKey(e,t);return this.cache.set(r,s),s}encrypt(e,t,n){return encryptNip44(n,this.getKey(e,t))}decrypt(e,t,n){return decryptNip44(n,this.getKey(e,t))}}const OUTBOX_RELAYS=["wss://user.kindpag.es","wss://purplepag.es","wss://relay.nos.social"],DEFAULT_NOSTRCONNECT_RELAYS=["wss://relay.nsec.app/","wss://ephemeral.snowflare.cc/"],CONNECT_TIMEOUT=2e4,NOSTRCONNECT_APPS=[{name:"Nsec.app",domain:"nsec.app",canImport:!0,img:"https://nsec.app/assets/favicon.ico",link:"https://use.nsec.app/<nostrconnect>",relays:DEFAULT_NOSTRCONNECT_RELAYS},{name:"Amber",img:"https://raw.githubusercontent.com/greenart7c3/Amber/refs/heads/master/assets/android-icon.svg",link:"<nostrconnect>",relays:DEFAULT_NOSTRCONNECT_RELAYS},{name:"Other key stores",img:"",link:"<nostrconnect>",relays:DEFAULT_NOSTRCONNECT_RELAYS}];class AuthNostrService extends lib$1.EventEmitter{ndk;profileNdk;signer=null;localSigner=null;params;signerPromise;signerErrCallback;readyPromise;readyCallback;nip44Codec=new Nip44;nostrConnectKey="";nostrConnectSecret="";iframe;starterReady;nip04;nip44;constructor(e){super(),this.params=e,this.ndk=new NDK({enableOutboxModel:!1}),this.profileNdk=new NDK({enableOutboxModel:!0,explicitRelayUrls:OUTBOX_RELAYS}),this.profileNdk.connect(CONNECT_TIMEOUT),this.nip04={encrypt:this.encrypt04.bind(this),decrypt:this.decrypt04.bind(this)},this.nip44={encrypt:this.encrypt44.bind(this),decrypt:this.decrypt44.bind(this)}}isIframe(){return!!this.iframe}async waitReady(){if(this.signerPromise)try{await this.signerPromise}catch{}if(this.readyPromise)try{await this.readyPromise}catch{}}cancelNostrConnect(){this.releaseSigner(),this.resetAuth()}async nostrConnect(e,{domain:t="",link:n="",iframeUrl:r="",importConnect:i=!1}={}){e=e&&e.length>0?e:DEFAULT_NOSTRCONNECT_RELAYS;const s={authMethod:"connect",pubkey:"",signerPubkey:"",sk:this.nostrConnectKey,domain:t,relays:e,iframeUrl:r};if(console.log("nostrconnect info",s,n),n&&!r&&window.open(n,"_blank","width=400,height=700"),await this.initSigner(s,{listen:!0}),!s.pubkey||!s.signerPubkey)throw new Error("Bad remote pubkey");return s.bunkerUrl=`bunker://${s.signerPubkey}?${e.map((e,t)=>`${0!==t?"&":""}relay=${e}`)}`,i||this.onAuth("login",s),s}async createNostrConnect(e){this.nostrConnectKey=generatePrivateKey(),this.nostrConnectSecret=Math.random().toString(36).substring(7);const t=getPublicKey(this.nostrConnectKey),n=encodeURIComponent(document.location.host),r=encodeURIComponent(document.location.origin),i=encodeURIComponent(await getIcon()),s=encodeURIComponent(this.params.optionsModal.perms||""),o=(e||[]).length>0?(e||[]).map(e=>`&relay=${encodeURIComponent(e)}`).join(""):"";return`nostrconnect://${t}?image=${i}&url=${r}&name=${n}&perms=${s}&secret=${this.nostrConnectSecret}${o}`}async getNostrConnectServices(){const e=await this.createNostrConnect(DEFAULT_NOSTRCONNECT_RELAYS),t=NOSTRCONNECT_APPS.map(e=>({...e}));for(const n of t){let t=[...DEFAULT_NOSTRCONNECT_RELAYS];if(n.link.startsWith("https://")){const e=n.domain||new URL(n.link).hostname;try{const r=await(await fetch(`https://${e}/.well-known/nostr.json`)).json(),i=r.names._,s=r.nip46?.[i];Array.isArray(s)&&s.length>0&&(t=s),n.iframeUrl=r.nip46?.iframe_url||""}catch(e){console.log("Bad app info",e,n)}}const r=e.split("&relay=")[0]+t.map(e=>`&relay=${encodeURIComponent(e)}`).join("");n.link=n.iframeUrl?r:n.link.replace("<nostrconnect>",r)}return[e,t]}async localSignup(e,t){const n=!t,r={pubkey:getPublicKey(t=t||generatePrivateKey()),sk:t,name:e,authMethod:"local"};console.log(`localSignup name: ${e}`),await this.setLocal(r,n)}async setLocal(e,t){this.releaseSigner(),this.localSigner=new NDKPrivateKeySigner(e.sk),t&&await createProfile(e,this.profileNdk,this.localSigner,this.params.optionsModal.signupRelays,this.params.optionsModal.outboxRelays),this.onAuth(t?"signup":"login",e)}prepareImportUrl(e){if("otp"===this.params.userInfo?.authMethod)return e+"&import=true";if(!this.localSigner||"local"!==this.params.userInfo?.authMethod)throw new Error("Most be local keys");return e+"#import="+nip19_exports.nsecEncode(this.localSigner.privateKey)}async importAndConnect(e){const{relays:t,domain:n,link:r,iframeUrl:i}=e;if(!n)throw new Error("Domain required");const s=await this.nostrConnect(t,{domain:n,link:r,importConnect:!0,iframeUrl:i});await this.logout(!0),this.localSigner=null,this.onAuth("login",s)}setReadOnly(e){const t={pubkey:e,authMethod:"readOnly"};this.onAuth("login",t)}setExtension(e){const t={pubkey:e,authMethod:"extension"};this.onAuth("login",t)}setOTP(e,t){const n={pubkey:e,authMethod:"otp",otpData:t};this.onAuth("login",n)}async setConnect(e){this.releaseSigner(),await this.startAuth(),await this.initSigner(e),this.onAuth("login",e),await this.endAuth()}async createAccount(e){const[t,n]=e.split("@"),r=await getBunkerUrl(`_@${n}`,this.params.optionsModal);console.log("create account bunker's url",r);const i=bunkerUrlToInfo(r);if(!i.signerPubkey)throw new Error("Bad bunker url");const s=Boolean(this.params.userInfo);await this.initSigner(i,{eventToAddAccount:s});return{bunkerUrl:`bunker://${await this.signer.createAccount2({bunkerPubkey:i.signerPubkey,name:t,domain:n,perms:this.params.optionsModal.perms})}?`+(i.relays??[]).map(e=>`relay=${encodeURIComponent(e)}`).join("&"),sk:i.sk}}releaseSigner(){this.signer=null,this.signerErrCallback?.("cancelled"),this.localSigner=null;for(const e of this.ndk.pool.relays.keys())this.ndk.pool.removeRelay(e)}async logout(e=!1){e||this.releaseSigner(),localStorageRemoveCurrentAccount(),this.onAuth("logout"),this.emit("updateAccounts")}setUserInfo(e){this.params.userInfo=e,this.emit("onUserInfo",e),e&&(localStorageAddAccount(e),this.emit("updateAccounts"))}exportKeys(){return this.params.userInfo?"local"!==this.params.userInfo.authMethod?"":nip19_exports.nsecEncode(this.params.userInfo.sk):""}onAuth(e,t=null){if("logout"!==e&&!t)throw new Error("No user info in onAuth");if(t&&this.params.userInfo&&(t.pubkey!==this.params.userInfo.pubkey||t.authMethod!==this.params.userInfo.authMethod)){const e=new CustomEvent("nlAuth",{detail:{type:"logout"}});console.log("nostr-login auth",e.detail),document.dispatchEvent(e)}this.setUserInfo(t),t&&fetchProfile(t,this.profileNdk).then(e=>{if(this.params.userInfo!==t)return;const n={...this.params.userInfo,picture:e?.image||e?.picture,name:e?.name||e?.displayName||e?.nip05||nip19_exports.npubEncode(t.pubkey)};this.setUserInfo(n)});try{const n=t?nip19_exports.npubEncode(t.pubkey):"",r={type:e};"logout"===e?(this.iframe&&this.iframe.remove(),this.iframe=void 0):(r.pubkey=t.pubkey,r.name=t.name,t.sk&&(r.localNsec=nip19_exports.nsecEncode(t.sk)),t.relays&&(r.relays=t.relays),t.otpData&&(r.otpData=t.otpData),r.method=t.authMethod||"connect");const i=new CustomEvent("nlAuth",{detail:r});console.log("nostr-login auth",r),document.dispatchEvent(i),this.params.optionsModal.onAuth&&this.params.optionsModal.onAuth(n,r)}catch(e){console.log("onAuth error",e)}}async createIframe(e){if(!e)return;const t=new URL(e);let n;const r="__nostr-login-worker-iframe-"+t.hostname.replaceAll(".","-");n=document.querySelector(`#${r}`),console.log("iframe",r,n),n||(n=document.createElement("iframe"),n.setAttribute("width","0"),n.setAttribute("height","0"),n.setAttribute("border","0"),n.style.display="none",n.id=r,document.body.append(n)),n.setAttribute("src",e);const i=new ReadyListener(["workerReady","workerError"],t.origin);await new Promise(e=>{n.addEventListener("load",e)});const s=await i.wait();return console.log("nostr-login iframe ready",e,s),{iframe:n,port:s[1]}}async sendNeedAuth(){const[e]=await this.getNostrConnectServices(),t=new CustomEvent("nlNeedAuth",{detail:{nostrconnect:e}});console.log("nostr-login need auth",e),document.dispatchEvent(t)}isAuthing(){return!!this.readyCallback}async startAuth(){if(console.log("startAuth"),this.readyCallback)throw new Error("Already started");this.readyPromise=new Promise(e=>this.readyCallback=e)}async endAuth(){if(console.log("endAuth",this.params.userInfo),this.params.userInfo&&this.params.userInfo.iframeUrl){const{iframe:e,port:t}=await this.createIframe(this.params.userInfo.iframeUrl)||{};if(this.iframe=e,!this.iframe||!t)return;this.signer.rpc.setWorkerIframePort(t)}this.readyCallback(),this.readyCallback=void 0}resetAuth(){this.readyCallback&&this.readyCallback(),this.readyCallback=void 0}async listen(e){if(!e.iframeUrl)return this.signer.listen(this.nostrConnectSecret);const t=await this.starterReady.wait();if("starterError"===t[0])throw new Error(t[1]);return this.signer.setListenReply(t[1],this.nostrConnectSecret)}async connect(e,t){return this.signer.connect(e.token,t)}async initSigner(e,{listen:t=!1,connect:n=!1,eventToAddAccount:r=!1}={}){if(this.signerPromise)try{await this.signerPromise}catch{}console.log("initSigner info",e);const i=e.iframeUrl?new URL(e.iframeUrl).origin:void 0;return i&&(this.starterReady=new ReadyListener(["starterDone","starterError"],i)),this.emit("onIframeUrl",e.iframeUrl),this.signerPromise=new Promise(async(s,o)=>{this.signerErrCallback=o;try{if(console.log("NDK relays before connect:",Array.from(this.ndk.pool.relays.keys())),e.relays&&!e.iframeUrl)for(const t of e.relays)this.ndk.addExplicitRelay(t,void 0),console.log("Added relay:",t);console.log("NDK relays after add:",Array.from(this.ndk.pool.relays.keys())),this.ndk.connect(CONNECT_TIMEOUT).then(e=>{console.log(e)}),await new Promise(e=>{const t=Date.now(),n=setInterval(()=>{if(this.ndk.pool.connectedRelays().length>0)return clearInterval(n),void e();Date.now()-t>CONNECT_TIMEOUT&&(clearInterval(n),e())},5e3)}),console.log("NDK connected relays:",this.ndk.pool.connectedRelays().map(e=>e.url));const o=new NDKPrivateKeySigner(e.sk);this.signer=new Nip46Signer(this.ndk,o,e.signerPubkey,i),this.signer.on("iframeRestart",async()=>{const t=e.iframeUrl+(e.iframeUrl.includes("?")?"&":"?")+"pubkey="+e.pubkey+"&rebind="+o.pubkey;this.emit("iframeRestart",{pubkey:e.pubkey,iframeUrl:t})}),this.signer.on("authUrl",t=>{console.log("nostr login auth url",t),this.emit("onAuthUrl",{url:t,iframeUrl:e.iframeUrl,eventToAddAccount:r})}),t?await this.listen(e):n?await this.connect(e,this.params.optionsModal.perms):await this.signer.initUserPubkey(e.pubkey),e.pubkey=this.signer.userPubkey,e.signerPubkey=this.signer.remotePubkey,s()}catch(e){console.log("initSigner failure",e),this.signer=null,o(e)}}),this.signerPromise}async authNip46(e,{name:t,bunkerUrl:n,sk:r="",domain:i="",iframeUrl:s=""}){try{const o=bunkerUrlToInfo(n,r);if(isBunkerUrl(t)?o.bunkerUrl=t:(o.nip05=t,o.domain=t.split("@")[1]),i&&(o.domain=i),s&&(o.iframeUrl=s),!o.signerPubkey||!o.sk||!o.relays||0===o.relays.length)throw new Error(`Bad bunker url ${n}`);const a=Boolean(this.params.userInfo);console.log("authNip46",e,o),await this.initSigner(o,{connect:!0,eventToAddAccount:a}),this.onAuth(e,o)}catch(e){throw console.log("nostr login auth failed",e),e}}async signEvent(e){const t=(async()=>(this.localSigner?(e.pubkey=getPublicKey(this.localSigner.privateKey),e.id=getEventHash(e),e.sig=await this.localSigner.sign(e)):(e.pubkey=this.signer?.remotePubkey,e.id=getEventHash(e),e.sig=await(this.signer?.sign(e))),e))(),n=new Promise((e,t)=>{setTimeout(()=>t(new Error("Sign timeout")),2e4)}),r=await Promise.race([t,n]);return console.log("signed",{event:r}),r}async codec_call(e,t,n){return new Promise((r,i)=>{this.signer.rpc.sendRequest(this.signer.remotePubkey,e,[t,n],24133,e=>{e.error?i(e.error):r(e.result)})})}async encrypt04(e,t){return this.localSigner?this.localSigner.encrypt(new NDKUser({pubkey:e}),t):this.signer.encrypt(new NDKUser({pubkey:e}),t)}async decrypt04(e,t){return this.localSigner?this.localSigner.decrypt(new NDKUser({pubkey:e}),t):this.codec_call("nip04_decrypt",e,t)}async encrypt44(e,t){return this.localSigner?this.nip44Codec.encrypt(this.localSigner.privateKey,e,t):this.codec_call("nip44_encrypt",e,t)}async decrypt44(e,t){return this.localSigner?this.nip44Codec.decrypt(this.localSigner.privateKey,e,t):this.codec_call("nip44_decrypt",e,t)}}class ModalManager extends lib$1.EventEmitter{modal=null;params;extensionService;authNostrService;launcherPromise;accounts=[];recents=[];opt;constructor(e,t,n){super(),this.params=e,this.extensionService=n,this.authNostrService=t}async waitReady(){if(this.launcherPromise){try{await this.launcherPromise}catch{}this.launcherPromise=void 0}}async launch(e){console.log("nostr-login launch",e),this.launcherPromise&&await this.waitReady(),this.authNostrService.isAuthing()&&this.authNostrService.resetAuth(),this.opt=e;const t=document.createElement("dialog");if(this.modal=document.createElement("nl-auth"),this.modal.accounts=this.accounts,this.modal.recents=this.recents,this.modal.setAttribute("dark-mode",String(getDarkMode(e))),e.theme&&this.modal.setAttribute("theme",e.theme),e.startScreen&&this.modal.setAttribute("start-screen",e.startScreen),e.bunkers)this.modal.setAttribute("bunkers",e.bunkers);else{let e="nsec.app,highlighter.com";this.modal.setAttribute("bunkers",e)}void 0!==e.methods&&(this.modal.authMethods=e.methods),void 0!==e.localSignup&&(this.modal.localSignup=e.localSignup),void 0!==e.signupNstart&&(this.modal.signupNjump=e.signupNstart),e.title&&(this.modal.welcomeTitle=e.title),e.description&&(this.modal.welcomeDescription=e.description),this.modal.hasExtension=this.extensionService.hasExtension(),this.modal.hasOTP=!!e.otpRequestUrl&&!!e.otpReplyUrl,this.modal.isLoadingExtension=!1,this.modal.isLoading=!1,[this.modal.connectionString,this.modal.connectionStringServices]=await this.authNostrService.getNostrConnectServices(),t.appendChild(this.modal),document.body.appendChild(t);let n="";return this.launcherPromise=new Promise((e,r)=>{t.addEventListener("close",()=>{r(new Error("Closed")),this.authNostrService.resetAuth(),this.modal&&(document.body.removeChild(this.modal.parentNode),this.modal=null)});const i=async e=>{this.modal&&(this.modal.isLoading=!1),await this.authNostrService.endAuth(),t.close(),this.modal=null,e()},s=async(t,n)=>{this.modal&&(this.modal.isLoading=!0);try{n&&!n.start||await this.authNostrService.startAuth(),await t(),n&&!n.end||await i(e)}catch(e){console.log("error",e),this.modal&&(this.modal.isLoading=!1,this.modal.authUrl="",this.modal.iframeUrl="","cancelled"!==e&&(this.modal.error=e.toString()))}},o=async(e,t)=>{await s(async()=>{const n=await getBunkerUrl(e,this.params.optionsModal);await this.authNostrService.authNip46("login",{name:e,bunkerUrl:n,domain:t})})},a=async e=>{await s(async()=>{const{bunkerUrl:t,sk:n}=await this.authNostrService.createAccount(e);await this.authNostrService.authNip46("signup",{name:e,bunkerUrl:t,sk:n})})},c=async()=>{try{await navigator.clipboard.writeText(this.authNostrService.exportKeys()),localStorageSetItem("backupKey","true")}catch(e){console.error("Failed to copy to clipboard: ",e)}},l=async e=>{await s(async()=>{const{iframeUrl:t}=e;e.link=this.authNostrService.prepareImportUrl(e.link),this.modal&&t&&(this.modal.authUrl=e.link,this.modal.iframeUrl=t,this.modal.isLoading=!1,console.log("nostrconnect authUrl",this.modal.authUrl,this.modal.iframeUrl)),await this.authNostrService.importAndConnect(e)})},h=async e=>{await s(async()=>{const{relays:t,domain:n,link:r,iframeUrl:i}=e||{};console.log("nostrConnect",e,t,n,r,i),this.modal&&(i&&(this.modal.authUrl=r,this.modal.iframeUrl=i,this.modal.isLoading=!1,console.log("nostrconnect authUrl",this.modal.authUrl,this.modal.iframeUrl)),e||(this.modal.isLoading=!1)),await this.authNostrService.nostrConnect(t,{domain:n,link:r,iframeUrl:i})})},d=async e=>{await s(async()=>{if(!e)throw new Error("Please enter some nickname");await this.authNostrService.localSignup(e)})},u=async()=>{await s(async()=>{const e=new URL(window.location.href),t=e.hostname.toLocaleLowerCase().replace(/^www\./i,"").charAt(0).toUpperCase()+e.hostname.slice(1),n=prepareSignupRelays(this.params.optionsModal.signupRelays);return this.modal.njumpIframe=`\n <html><body>\n <script src='https://start.njump.me/modal.js'><\/script>\n <script>\n new NstartModal({\n baseUrl: 'https://start.njump.me',\n // Required parameters\n an: '${t}',\n // Optional parameters\n s: [${this.opt.followNpubs?`'${this.opt.followNpubs}'`:""}],\n afb: false, // forceBunker\n asb: false, // skipBunker\n aan: false, // avoidNsec\n aac: true, // avoidNcryptsec\n ahc: true, // hide close button\n arr: ${JSON.stringify(n)}, //readRelays\n awr: ${JSON.stringify(n)}, //writeRelays\n // Callbacks\n onComplete: (result) => {\n console.log('Login token:', result.nostrLogin);\n window.parent.location.href='${window.location.href}#nostr-login='+result.nostrLogin;\n },\n onCancel: () => {\n window.parent.location.href='${window.location.href}#nostr-login=null';\n },\n }).open();\n <\/script>\n </body></html>\n `.replaceAll("&","&amp;"),new Promise((e,t)=>{const n=async n=>{if(console.log("nsecOrBunker",n),n.startsWith("nsec1")){let t;try{t=nip19_exports.decode(n)}catch(e){throw new Error("Bad nsec value")}if("nsec"!==t.type)throw new Error("Bad bech32 type");await this.authNostrService.localSignup("",t.data),e()}else n.startsWith("bunker:")?(await this.authNostrService.authNip46("login",{name:"",bunkerUrl:n}),e()):t("null"===n?"Cancelled":"Unknown return value")};window.addEventListener("hashchange",async()=>{if(window.location.hash.startsWith("#nostr-login=")){const e=window.location.hash.split("#nostr-login=")[1],t=new URL(window.location.toString());t.hash="",window.history.replaceState({},"",t.toString()),n(e)}})})})};if(!this.modal)throw new Error("WTH?");this.modal.addEventListener("handleContinue",()=>{this.modal&&(this.modal.isLoading=!0,this.emit("onAuthUrlClick",this.modal.authUrl))}),this.modal.addEventListener("nlLogin",e=>{o(e.detail)}),this.modal.addEventListener("nlSignup",e=>{a(e.detail)}),this.modal.addEventListener("nlLocalSignup",e=>{d(e.detail)}),this.modal.addEventListener("nlSignupNjump",e=>{u()}),this.modal.addEventListener("nlImportAccount",e=>{l(e.detail)}),this.modal.addEventListener("nlExportKeys",e=>{c()}),this.modal.addEventListener("handleLogoutBanner",()=>{this.emit("onLogoutBanner")}),this.modal.addEventListener("nlNostrConnect",e=>{h(e.detail)}),this.modal.addEventListener("nlNostrConnectDefault",()=>{this.authNostrService.isAuthing()||h()}),this.modal.addEventListener("nlNostrConnectDefaultCancel",()=>{console.log("nlNostrConnectDefaultCancel"),this.authNostrService.cancelNostrConnect()}),this.modal.addEventListener("nlSwitchAccount",e=>{const n=e.detail;this.emit("onSwitchAccount",n),setTimeout(()=>t.close(),300)}),this.modal.addEventListener("nlLoginRecentAccount",async e=>{const n=e.detail;if("readOnly"===n.authMethod)this.authNostrService.setReadOnly(n.pubkey),t.close();else if("otp"===n.authMethod)try{this.modal.dispatchEvent(new CustomEvent("nlLoginOTPUser",{detail:n.nip05||n.pubkey}))}catch(e){console.error(e)}else if("extension"===n.authMethod)await this.extensionService.trySetExtensionForPubkey(n.pubkey),t.close();else{const e=n.bunkerUrl||n.nip05;if(!e)throw new Error("Bad connect info");o(e,n.domain)}}),this.modal.addEventListener("nlRemoveRecent",e=>{localStorageRemoveRecent(e.detail),this.emit("updateAccounts")});const f=async e=>{let t="";if(e.includes("@")){const{error:n,pubkey:r}=await checkNip05(e);if(!r)throw new Error(n);t=r}else if(e.startsWith("npub")){const{type:n,data:r}=nip19_exports.decode(e);if("npub"!==n)throw new Error("Bad npub");t=r}else 64===e.trim().length&&(t=e.trim(),nip19_exports.npubEncode(t));return t};this.modal.addEventListener("nlLoginReadOnly",async e=>{await s(async()=>{const t=e.detail,n=await f(t);this.authNostrService.setReadOnly(n)})}),this.modal.addEventListener("nlLoginExtension",async()=>{if(!this.extensionService.hasExtension())throw new Error("No extension");await s(async()=>{this.modal&&(this.modal.isLoadingExtension=!0,await this.extensionService.setExtension(),this.modal.isLoadingExtension=!1)})}),this.modal.addEventListener("nlLoginOTPUser",async e=>{await s(async()=>{if(!this.modal)return;const t=e.detail,r=await f(t),i=this.opt.otpRequestUrl+(this.opt.otpRequestUrl.includes("?")?"&":"?")+"pubkey="+r,s=await fetch(i);if(200!==s.status)throw console.warn("nostr-login: bad otp reply",s),new Error("Failed to send DM");this.modal.isOTP=!0,n=r,this.modal.isLoading=!1},{start:!0})}),this.modal.addEventListener("nlLoginOTPCode",async e=>{await s(async()=>{if(!this.modal)return;const t=e.detail,r=this.opt.otpReplyUrl+(this.opt.otpRequestUrl.includes("?")?"&":"?")+"pubkey="+n+"&code="+t,i=await fetch(r);if(200!==i.status)throw console.warn("nostr-login: bad otp reply",i),new Error("Invalid code");const s=await i.text();this.authNostrService.setOTP(n,s),this.modal.isOTP=!1},{end:!0})}),this.modal.addEventListener("nlCheckSignup",async e=>{const{available:t,taken:n,error:r}=await checkNip05(e.detail);this.modal&&(this.modal.error=String(r),!r&&n&&(this.modal.error="Already taken"),this.modal.signupNameIsAvailable=t)}),this.modal.addEventListener("nlCheckLogin",async e=>{const{available:t,taken:n,error:r}=await checkNip05(e.detail);this.modal&&(this.modal.error=String(r),t&&(this.modal.error="Name not found"),this.modal.loginIsGood=n)});const p=()=>{this.modal&&(this.modal.isLoading=!1),t.close(),r(new Error("Cancelled"))};this.modal.addEventListener("stopFetchHandler",p),this.modal.addEventListener("nlCloseModal",p),this.modal.addEventListener("nlChangeDarkMode",e=>{setDarkMode(e.detail),document.dispatchEvent(new CustomEvent("nlDarkMode",{detail:e.detail}))}),this.on("onIframeAuthUrlCallEnd",()=>{t.close(),this.modal=null,e()}),t.showModal()}),this.launcherPromise}async showIframeUrl(e){await this.waitReady(),this.launch({startScreen:"iframe"}).catch(()=>console.log("closed auth iframe")),this.modal.authUrl=e}connectModals(e){const t=async e=>{await this.launch(e)},n=document.getElementsByTagName("nl-button");for(let r=0;r<n.length;r++){const i=n[r].getAttribute("nl-theme"),s=n[r].getAttribute("start-screen"),o={...e};switch(i&&(o.theme=i),s){case"login":case"login-bunker-url":case"login-read-only":case"signup":case"switch-account":case"welcome":o.startScreen=s}n[r].addEventListener("click",function(){t(o)})}}onAuthUrl(e){this.modal&&(this.modal.authUrl=e,this.modal.isLoading=!1)}onIframeUrl(e){this.modal&&(console.log("modal iframe url",e),this.modal.iframeUrl=e)}onCallEnd(){this.modal&&this.modal.authUrl&&this.params.userInfo?.iframeUrl&&this.emit("onIframeAuthUrlCallEnd")}onUpdateAccounts(e,t){this.accounts=e,this.recents=t,this.modal&&(this.modal.accounts=e,this.modal.recents=t)}onDarkMode(e){this.modal&&(this.modal.darkMode=e)}}class Nostr{#e;nip04;nip44;constructor(e){this.#e=e,this.getPublicKey=this.getPublicKey.bind(this),this.signEvent=this.signEvent.bind(this),this.getRelays=this.getRelays.bind(this),this.nip04={encrypt:this.encrypt04.bind(this),decrypt:this.decrypt04.bind(this)},this.nip44={encrypt:this.encrypt44.bind(this),decrypt:this.decrypt44.bind(this)}}async ensureAuth(){if(await this.#e.waitReady(),!this.#e.getUserInfo()&&(await this.#e.launch(),!this.#e.getUserInfo()))throw new Error("Rejected by user")}async getPublicKey(){await this.ensureAuth();const e=this.#e.getUserInfo();if(e)return e.pubkey;throw new Error("No user")}async signEvent(e){return await this.ensureAuth(),this.#e.wait(async()=>await this.#e.getSigner().signEvent(e))}async getRelays(){return{}}async encrypt04(e,t){return await this.ensureAuth(),this.#e.wait(async()=>await this.#e.getSigner().nip04.encrypt(e,t))}async decrypt04(e,t){return await this.ensureAuth(),this.#e.wait(async()=>await this.#e.getSigner().nip04.decrypt(e,t))}async encrypt44(e,t){return await this.ensureAuth(),this.#e.wait(async()=>await this.#e.getSigner().nip44.encrypt(e,t))}async decrypt44(e,t){return await this.ensureAuth(),this.#e.wait(async()=>await this.#e.getSigner().nip44.decrypt(e,t))}}class NostrExtensionService extends lib$1.EventEmitter{params;nostrExtension;constructor(e){super(),this.params=e}startCheckingExtension(e){if(this.checkExtension(e))return;const t=setInterval(()=>{this.checkExtension(e)&&clearTimeout(t)},100)}checkExtension(e){return!(this.nostrExtension||!window.nostr||window.nostr===e)&&(this.initExtension(e),!0)}async initExtension(e,t){this.nostrExtension=window.nostr,window.nostr=e,"extension"===this.params.userInfo?.authMethod&&await this.trySetExtensionForPubkey(this.params.userInfo.pubkey),t||setTimeout(()=>{window.nostr!==e&&this.nostrExtension!==window.nostr&&this.initExtension(e,!0)},300)}async setExtensionReadPubkey(e){window.nostr=this.nostrExtension;const t=await window.nostr.getPublicKey();e&&e!==t?this.emit("extensionLogout"):this.emit("extensionLogin",t)}async trySetExtensionForPubkey(e){if(this.nostrExtension)return this.setExtensionReadPubkey(e)}async setExtension(){return this.setExtensionReadPubkey()}unsetExtension(e){window.nostr===this.nostrExtension&&(window.nostr=e)}getExtension(){return this.nostrExtension}hasExtension(){return!!this.nostrExtension}}class NostrParams{userInfo;optionsModal;constructor(){this.userInfo=null,this.optionsModal={theme:"default",startScreen:"welcome",devOverrideBunkerOrigin:""}}}class Popup{popup=null;constructor(){}openPopup(e){if((!this.popup||this.popup.closed)&&(this.popup=window.open(e,"_blank","width=400,height=700"),console.log("popup",this.popup),!this.popup))throw new Error("Popup blocked. Try again, please!")}closePopup(){try{this.popup?.close(),this.popup=null}catch{}}}const CALL_TIMEOUT=5e3;class ProcessManager extends lib$1.EventEmitter{callCount=0;callTimer;constructor(){super()}onAuthUrl(){Boolean(this.callTimer)&&clearTimeout(this.callTimer)}onIframeUrl(){Boolean(this.callTimer)&&clearTimeout(this.callTimer)}async wait(e){let t,n;this.callTimer||(this.callTimer=setTimeout(()=>this.emit("onCallTimeout"),CALL_TIMEOUT)),this.callCount||this.emit("onCallStart"),this.callCount++;try{n=await e()}catch(e){t=e}if(this.callCount--,this.emit("onCallEnd"),this.callTimer&&clearTimeout(this.callTimer),this.callTimer=void 0,t)throw t;return n}}class NostrLoginInitializer{extensionService;params;authNostrService;nostr;processManager;popupManager;bannerManager;modalManager;customLaunchCallback;constructor(){this.params=new NostrParams,this.processManager=new ProcessManager,this.popupManager=new Popup,this.bannerManager=new BannerManager(this.params),this.authNostrService=new AuthNostrService(this.params),this.extensionService=new NostrExtensionService(this.params),this.modalManager=new ModalManager(this.params,this.authNostrService,this.extensionService);const e={waitReady:async()=>{await this.authNostrService.waitReady(),await this.modalManager.waitReady()},getUserInfo:()=>this.params.userInfo,getSigner:()=>{if("readOnly"===this.params.userInfo.authMethod)throw new Error("Read only");return"extension"===this.params.userInfo.authMethod?this.extensionService.getExtension():this.authNostrService},launch:()=>this.launch(),wait:e=>this.processManager.wait(e)};this.nostr=new Nostr(e),this.processManager.on("onCallTimeout",()=>{this.bannerManager.onCallTimeout()}),this.processManager.on("onCallEnd",()=>{this.bannerManager.onCallEnd(),this.modalManager.onCallEnd()}),this.processManager.on("onCallStart",()=>{this.bannerManager.onCallStart()}),this.authNostrService.on("onIframeUrl",e=>{this.modalManager.onIframeUrl(e)}),this.authNostrService.on("iframeRestart",({iframeUrl:e})=>{this.processManager.onIframeUrl(),this.bannerManager.onIframeRestart(e)}),this.authNostrService.on("onAuthUrl",({url:e,iframeUrl:t,eventToAddAccount:n})=>{this.processManager.onAuthUrl(),n?this.modalManager.onAuthUrl(e):this.params.userInfo?this.bannerManager.onAuthUrl(e,t):this.modalManager.onAuthUrl(e)}),this.authNostrService.on("updateAccounts",()=>{this.updateAccounts()}),this.authNostrService.on("onUserInfo",e=>{this.bannerManager.onUserInfo(e)}),this.modalManager.on("onAuthUrlClick",e=>{this.openPopup(e)}),this.bannerManager.on("onIframeAuthUrlClick",e=>{this.modalManager.showIframeUrl(e)}),this.modalManager.on("onSwitchAccount",async e=>{this.switchAccount(e)}),this.modalManager.on("onLogoutBanner",async e=>{logout()}),this.bannerManager.on("onConfirmLogout",async()=>{this.launch("confirm-logout")}),this.modalManager.on("updateAccounts",()=>{this.updateAccounts()}),this.bannerManager.on("logout",()=>{logout()}),this.bannerManager.on("onAuthUrlClick",e=>{this.openPopup(e)}),this.bannerManager.on("onSwitchAccount",async e=>{this.switchAccount(e)}),this.bannerManager.on("import",()=>{this.launch("import")}),this.extensionService.on("extensionLogin",e=>{this.authNostrService.setExtension(e)}),this.extensionService.on("extensionLogout",()=>{logout()}),this.bannerManager.on("launch",e=>{this.launch(e)})}openPopup(e){this.popupManager.openPopup(e)}async switchAccount(e,t=!1){if(console.log("nostr login switch to info",e),this.extensionService.unsetExtension(this.nostr),"readOnly"===e.authMethod)this.authNostrService.setReadOnly(e.pubkey);else if("otp"===e.authMethod)this.authNostrService.setOTP(e.pubkey,e.otpData||"");else if("local"===e.authMethod&&e.sk)this.authNostrService.setLocal(e,t);else if("extension"===e.authMethod)await this.extensionService.trySetExtensionForPubkey(e.pubkey);else{if(!("connect"===e.authMethod&&e.sk&&e.relays&&e.relays[0]))throw new Error("Bad auth info");this.authNostrService.setConnect(e)}}updateAccounts(){const e=localStorageGetAccounts(),t=localStorageGetRecents();this.bannerManager.onUpdateAccounts(e),this.modalManager.onUpdateAccounts(e,t)}async launchCustomNostrConnect(){try{this.authNostrService.isAuthing()&&this.authNostrService.cancelNostrConnect();const e=new Promise(e=>this.customLaunchCallback=e);await this.authNostrService.startAuth(),await this.authNostrService.sendNeedAuth();try{await this.authNostrService.nostrConnect(),await this.authNostrService.endAuth()}catch(t){"cancelled"===t&&await e}}catch(e){console.error("launchCustomNostrConnect",e)}}fulfillCustomLaunchPromise(){if(this.customLaunchCallback){const e=this.customLaunchCallback;this.customLaunchCallback=void 0,e()}}launch=async e=>{if(!e&&this.params.optionsModal.customNostrConnect)return this.launchCustomNostrConnect();const t=localStorageGetRecents(),n=localStorageGetAccounts(),r={...this.params.optionsModal};e&&"default"!==e?r.startScreen=e:(Boolean(t?.length)||Boolean(n?.length))&&(r.startScreen="switch-account"),this.customLaunchCallback&&this.authNostrService.cancelNostrConnect();try{await this.modalManager.launch(r),this.fulfillCustomLaunchPromise()}catch(e){console.log("nostr-login failed",e)}};init=async e=>{this.extensionService.startCheckingExtension(this.nostr),window.nostr=this.nostr,this.modalManager.connectModals(e),this.bannerManager.launchAuthBanner(e),e&&(this.params.optionsModal={...e});try{const e=localStorageGetCurrent();if(e){if(!e.pubkey)throw new Error("Bad stored info");await this.switchAccount(e)}}catch(e){console.log("nostr login init error",e),await logout()}this.updateAccounts()};logout=async()=>{this.extensionService.unsetExtension(this.nostr),await this.authNostrService.logout()};setDarkMode=e=>{localStorageSetItem("nl-dark-mode",`${e}`),this.bannerManager.onDarkMode(e),this.modalManager.onDarkMode(e)};setAuth=async e=>{if(!e.type)throw new Error("Invalid auth event");if("login"!==e.type&&"logout"!==e.type&&"signup"!==e.type)throw new Error("Invalid auth event");if(e.method&&"connect"!==e.method&&"extension"!==e.method&&"local"!==e.method&&"otp"!==e.method&&"readOnly"!==e.method)throw new Error("Invalid auth event");if("logout"===e.type)return this.logout();if(!e.method||!e.pubkey)throw new Error("Invalid pubkey");const t={authMethod:e.method,pubkey:e.pubkey,relays:e.relays,sk:e.localNsec,otpData:e.otpData,name:e.name};await this.switchAccount(t,"signup"===e.type)};cancelNeedAuth=()=>{console.log("cancelNeedAuth"),this.fulfillCustomLaunchPromise(),this.authNostrService.cancelNostrConnect()}}const initializer=new NostrLoginInitializer,{init:init,launch:launch,logout:logout,setDarkMode:setDarkMode,setAuth:setAuth,cancelNeedAuth:cancelNeedAuth}=initializer;document.addEventListener("nlLogout",logout),document.addEventListener("nlLaunch",e=>{launch(e.detail||"")}),document.addEventListener("nlNeedAuthCancel",()=>{cancelNeedAuth()}),document.addEventListener("nlDarkMode",e=>{setDarkMode(!!e.detail)}),document.addEventListener("nlSetAuth",e=>{setAuth(e.detail)});export{NostrLoginInitializer,cancelNeedAuth,init,launch,logout,setAuth,setDarkMode};
17
+ Object.defineProperty(e,"__esModule",{value:!0}),e.bytes=e.stringToBytes=e.str=e.bytesToString=e.hex=e.utf8=e.bech32m=e.bech32=e.base58check=e.base58xmr=e.base58xrp=e.base58flickr=e.base58=e.base64url=e.base64=e.base32crockford=e.base32hex=e.base32=e.base16=e.utils=e.assertNumber=void 0,e.assertNumber=t;const l=(e,t)=>t?l(t,e%t):e,c=(e,t)=>e+(t-l(e,t));function d(e,n,r,o){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(n<=0||n>32)throw new Error(`convertRadix2: wrong from=${n}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(c(n,r)>32)throw new Error(`convertRadix2: carry overflow from=${n} to=${r} carryBits=${c(n,r)}`);let s=0,i=0;const a=2**r-1,l=[];for(const o of e){if(t(o),o>=2**n)throw new Error(`convertRadix2: invalid data word=${o} from=${n}`);if(s=s<<n|o,i+n>32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${n}`);for(i+=n;i>=r;i-=r)l.push((s>>i-r&a)>>>0);s&=2**i-1}if(s=s<<r-i&a,!o&&i>=n)throw new Error("Excess padding");if(!o&&s)throw new Error(`Non-zero padding: ${s}`);return o&&i>0&&l.push(s>>>0),l}function h(e){return t(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return a(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(a(t,e,256))}}}function u(e,n=!1){if(t(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(c(8,e)>32||c(e,8)>32)throw new Error("radix2: carry overflow");return{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return d(Array.from(t),8,e,!n)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(d(t,e,8,n))}}}function p(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function f(e,n){if(t(e),"function"!=typeof n)throw new Error("checksum fn should be function");return{encode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const r=n(t).slice(0,e),o=new Uint8Array(t.length+e);return o.set(t),o.set(r,t.length),o},decode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const r=t.slice(0,-e),o=n(r).slice(0,e),s=t.slice(-e);for(let t=0;t<e;t++)if(o[t]!==s[t])throw new Error("Invalid checksum");return r}}}e.utils={alphabet:r,chain:n,checksum:f,radix:h,radix2:u,join:o,padding:s},e.base16=n(u(4),r("0123456789ABCDEF"),o("")),e.base32=n(u(5),r("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),s(5),o("")),e.base32hex=n(u(5),r("0123456789ABCDEFGHIJKLMNOPQRSTUV"),s(5),o("")),e.base32crockford=n(u(5),r("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),o(""),i((e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),e.base64=n(u(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),s(6),o("")),e.base64url=n(u(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),s(6),o(""));const g=e=>n(h(58),r(e),o(""));e.base58=g("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),e.base58flickr=g("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),e.base58xrp=g("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const m=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let n="";for(let r=0;r<t.length;r+=8){const o=t.subarray(r,r+8);n+=e.base58.encode(o).padStart(m[o.length],"1")}return n},decode(t){let n=[];for(let r=0;r<t.length;r+=11){const o=t.slice(r,r+11),s=m.indexOf(o.length),i=e.base58.decode(o);for(let e=0;e<i.length-s;e++)if(0!==i[e])throw new Error("base58xmr: wrong padding");n=n.concat(Array.from(i.slice(i.length-s)))}return Uint8Array.from(n)}};e.base58check=t=>n(f(4,(e=>t(t(e)))),e.base58);const b=n(r("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),o("")),y=[996825010,642813549,513874426,1027748829,705979059];function w(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e<y.length;e++)1==(t>>e&1)&&(n^=y[e]);return n}function v(e,t,n=1){const r=e.length;let o=1;for(let t=0;t<r;t++){const n=e.charCodeAt(t);if(n<33||n>126)throw new Error(`Invalid prefix (${e})`);o=w(o)^n>>5}o=w(o);for(let t=0;t<r;t++)o=w(o)^31&e.charCodeAt(t);for(let e of t)o=w(o)^e;for(let e=0;e<6;e++)o=w(o);return o^=n,b.encode(d([o%2**30],30,5,!1))}function k(e){const t="bech32"===e?1:734539939,n=u(5),r=n.decode,o=n.encode,s=p(r);function i(e,n=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==n&&e.length>n)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=(e=r).lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const s=e.slice(0,o),i=e.slice(o+1);if(i.length<6)throw new Error("Data must be at least 6 characters long");const a=b.decode(i).slice(0,-6),l=v(s,a,t);if(!i.endsWith(l))throw new Error(`Invalid checksum in ${e}: expected "${l}"`);return{prefix:s,words:a}}return{encode:function(e,n,r=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const o=e.length+7+n.length;if(!1!==r&&o>r)throw new TypeError(`Length ${o} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${b.encode(n)}${v(e,n,t)}`},decode:i,decodeToBytes:function(e){const{prefix:t,words:n}=i(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:p(i),fromWords:r,fromWordsUnsafe:s,toWords:o}}e.bech32=k("bech32"),e.bech32m=k("bech32m"),e.utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},e.hex=n(u(4),r("0123456789abcdef"),o(""),i((e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})));const x={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},E=`Invalid encoding type. Available types: ${Object.keys(x).join(", ")}`;e.bytesToString=(e,t)=>{if("string"!=typeof e||!x.hasOwnProperty(e))throw new TypeError(E);if(!(t instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return x[e].encode(t)},e.str=e.bytesToString;e.stringToBytes=(e,t)=>{if(!x.hasOwnProperty(e))throw new TypeError(E);if("string"!=typeof t)throw new TypeError("stringToBytes() expects string");return x[e].decode(t)},e.bytes=e.stringToBytes}(lib);const{bech32:bech32,hex:hex,utf8:utf8}=lib;BigInt(1e3),BigInt(1e6),BigInt(1e9),BigInt(1e12),BigInt("2100000000000000000"),BigInt(1e11);const TAGCODES={payment_hash:1,payment_secret:16,description:13,payee:19,description_hash:23,expiry:6,min_final_cltv_expiry:24,fallback_address:9,route_hint:3,feature_bits:5,metadata:27};for(let e=0,t=Object.keys(TAGCODES);e<t.length;e++)t[e],TAGCODES[t[e]].toString();var NDKRelayConnectivity=class{ndkRelay;_status;relay;connectedAt;_connectionStats={attempts:0,success:0,durations:[]};debug;constructor(e){this.ndkRelay=e,this._status=3,this.relay=relayInit(this.ndkRelay.url),this.debug=this.ndkRelay.debug.extend("connectivity"),this.relay.on("notice",(e=>this.handleNotice(e)))}async initiateAuth(e={limit:1}){this.debug("Initiating authentication");const t=this.relay.sub([e],{id:"auth-test"});t.on("eose",(()=>{t.unsub(),this._status=1,this.ndkRelay.emit("ready"),this.debug("Authentication not required"),t.unsub()})),this.debug("Authentication request started")}async connect(){const e=()=>{this.updateConnectionStats.connected(),this.ndkRelay.authRequired?(this._status=6,this.ndkRelay.emit("connect"),this.initiateAuth()):(this._status=1,this.ndkRelay.emit("connect"),this.ndkRelay.emit("ready"))},t=()=>{this.updateConnectionStats.disconnected(),1===this._status&&(this._status=3,this.handleReconnection()),this.ndkRelay.emit("disconnect")},n=async e=>{this.debug("Relay requested authentication",{havePolicy:!!this.ndkRelay.authPolicy}),this.ndkRelay.authPolicy?7!==this._status&&(this._status=7,await this.ndkRelay.authPolicy(this.ndkRelay,e),7===this._status&&(this.debug("Authentication policy finished"),this._status=1,this.ndkRelay.emit("ready"))):await this.ndkRelay.emit("auth",e)};try{this.updateConnectionStats.attempt(),this._status=0,this.relay.off("connect",e),this.relay.off("disconnect",t),this.relay.on("connect",e),this.relay.on("disconnect",t),this.relay.on("auth",n),await this.relay.connect()}catch(e){throw this.debug("Failed to connect",e),this._status=3,e}}disconnect(){this._status=2,this.relay.close()}get status(){return this._status}isAvailable(){return 1===this._status}isFlapping(){const e=this._connectionStats.durations;if(e.length%3!=0)return!1;const t=e.reduce(((e,t)=>e+t),0)/e.length,n=e.map((e=>Math.pow(e-t,2))).reduce(((e,t)=>e+t),0)/e.length;return Math.sqrt(n)<1e3}async handleNotice(e){(e.includes("oo many")||e.includes("aximum"))&&(this.disconnect(),setTimeout((()=>this.connect()),2e3),this.debug(this.relay.url,"Relay complaining?",e)),this.ndkRelay.emit("notice",this,e)}handleReconnection(e=0){if(this.isFlapping())return this.ndkRelay.emit("flapping",this,this._connectionStats),void(this._status=5);const t=this.connectedAt?Math.max(0,6e4-(Date.now()-this.connectedAt)):0;setTimeout((()=>{this._status=4,this.connect().then((()=>{this.debug("Reconnected")})).catch((t=>{this.debug("Reconnect failed",t),e<5?setTimeout((()=>{this.handleReconnection(e+1)}),6e4):this.debug("Reconnect failed after 5 attempts")}))}),t)}updateConnectionStats={connected:()=>{this._connectionStats.success++,this._connectionStats.connectedAt=Date.now()},disconnected:()=>{this._connectionStats.connectedAt&&(this._connectionStats.durations.push(Date.now()-this._connectionStats.connectedAt),this._connectionStats.durations.length>100&&this._connectionStats.durations.shift()),this._connectionStats.connectedAt=void 0},attempt:()=>{this._connectionStats.attempts++}};get connectionStats(){return this._connectionStats}},NDKRelayPublisher=class{ndkRelay;constructor(e){this.ndkRelay=e}async publish(e,t=2500){const n=()=>new Promise(((n,r)=>{try{this.publishEvent(e,t).then((e=>n(e))).catch((e=>r(e)))}catch(e){r(e)}})),r=new Promise(((e,n)=>{setTimeout((()=>n(new Error("Timeout"))),t)})),o=()=>{n().then((e=>s(e))).catch((e=>i(e)))};let s,i;return 1===this.ndkRelay.status?Promise.race([n(),r]):Promise.race([new Promise(((e,t)=>{s=e,i=t,this.ndkRelay.once("connect",o)})),r]).finally((()=>{this.ndkRelay.removeListener("connect",o)}))}async publishEvent(e,t){const n=await e.toNostrEvent(),r=this.ndkRelay.connectivity.relay.publish(n);let o;const s=new Promise(((t,n)=>{r.then((()=>{clearTimeout(o),this.ndkRelay.emit("published",e),t(!0)})).catch((t=>{clearTimeout(o),this.ndkRelay.debug("Publish failed",t,e.id),this.ndkRelay.emit("publish:failed",e,t),n(t)}))}));if(!t||e.isEphemeral())return s;const i=new Promise(((n,r)=>{o=setTimeout((()=>{this.ndkRelay.debug("Publish timed out",e.rawEvent()),this.ndkRelay.emit("publish:failed",e,"Timeout"),r(new Error("Publish operation timed out"))}),t)}));return Promise.race([s,i])}async auth(e){return this.ndkRelay.connectivity.relay.auth(e.rawEvent())}};function calculateGroupableId(e){const t=[];for(const n of e){if(n.since||n.until)return null;const e=Object.keys(n||{}).sort().join("-");t.push(e)}return t.join("|")}function mergeFilters(e){const t={};return e.forEach((e=>{Object.entries(e).forEach((([e,n])=>{Array.isArray(n)?void 0===t[e]?t[e]=[...n]:t[e]=Array.from(new Set([...t[e],...n])):t[e]=n}))})),t}var MAX_SUBID_LENGTH=20;function queryFullyFilled(e){return!(!filterIncludesIds(e.filter)||!resultHasAllRequestedIds(e))}function compareFilter(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const[n,r]of Object.entries(e)){const e=t[n];if(!e)return!1;if(Array.isArray(r)&&Array.isArray(e)){const t=r;for(const n of e){const e=n;if(!t.includes(e))return!1}}else if(e!==r)return!1}return!0}function filterIncludesIds(e){return!!e.ids}function resultHasAllRequestedIds(e){const t=e.filter.ids;return!!t&&t.length===e.eventFirstSeen.size}function generateSubId(e,t){const n=e.map((e=>e.subId)).filter(Boolean),r=[],o=new Set,s=new Set;if(n.length>0)r.push(Array.from(new Set(n)).join(","));else{for(const e of t)for(const t of Object.keys(e))"kinds"===t?e.kinds?.forEach((e=>s.add(e))):o.add(t);s.size>0&&r.push("kinds:"+Array.from(s).join(",")),o.size>0&&r.push(Array.from(o).join(","))}let i=r.join("-");return i.length>MAX_SUBID_LENGTH&&(i=i.substring(0,MAX_SUBID_LENGTH)),1!==n.length&&(i+="-"+Math.floor(999*Math.random()).toString()),i}function filterFromId(e){let t;if(e.match(NIP33_A_REGEX)){const[t,n,r]=e.split(":"),o={authors:[n],kinds:[parseInt(t)]};return r&&(o["#d"]=[r]),o}try{switch(t=nip19_exports.decode(e),t.type){case"nevent":return{ids:[t.data.id]};case"note":return{ids:[t.data]};case"naddr":return{authors:[t.data.pubkey],"#d":[t.data.identifier],kinds:[t.data.kind]}}}catch(e){}return{ids:[e]}}function isNip33AValue(e){return null!==e.match(NIP33_A_REGEX)}var NIP33_A_REGEX=/^(\d+):([0-9A-Fa-f]+)(?::(.*))?$/;function relaysFromBech32(e){try{const t=nip19_exports.decode(e);if(["naddr","nevent"].includes(t?.type)){const e=t.data;if(e?.relays)return e.relays.map((e=>new NDKRelay(e)))}}catch(e){}return[]}var NDKGroupedSubscriptions=class extends lib$1.EventEmitter{subscriptions;req;debug;constructor(e,t){super(),this.subscriptions=e,this.debug=t||this.subscriptions[0].subscription.debug.extend("grouped");for(const t of e)this.handleSubscriptionClosure(t)}addSubscription(e){this.subscriptions.push(e),this.handleSubscriptionClosure(e)}eventReceived(e){for(const t of this.subscriptions)t.eventReceived(e)}eoseReceived(e){Array.from(this.subscriptions).forEach((async t=>{t.subscription.eoseReceived(e)}))}handleSubscriptionClosure(e){e.subscription.on("close",(()=>{const t=this.subscriptions.findIndex((t=>t.subscription===e.subscription));this.subscriptions.splice(t,1),this.subscriptions.length<=0&&this.emit("close")}))}map(e){return this.subscriptions.map(e)}[Symbol.iterator](){let e=0;const t=this.subscriptions;return{next:()=>e<t.length?{value:t[e++],done:!1}:{value:null,done:!0}}}},NDKSubscriptionFilters=class{subscription;filters=[];ndkRelay;constructor(e,t,n){this.subscription=e,this.filters=t,this.ndkRelay=n}eventReceived(e){this.eventMatchesLocalFilter(e)&&this.subscription.eventReceived(e,this.ndkRelay,!1)}eventMatchesLocalFilter(e){const t=e.rawEvent();return this.filters.some((e=>matchFilter(e,t)))}};function findMatchingActiveSubscriptions(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length&&compareFilter(e[n],t[n]);n++)return e[n]}var NDKRelaySubscriptions=class{ndkRelay;delayedItems=new Map;delayedTimers=new Map;activeSubscriptions=new Map;activeSubscriptionsByGroupId=new Map;executionTimeoutsByGroupId=new Map;debug;groupingDebug;conn;constructor(e){this.ndkRelay=e,this.conn=e.connectivity,this.debug=e.debug.extend("subscriptions"),this.groupingDebug=e.debug.extend("grouping")}subscribe(e,t){const n=calculateGroupableId(t),r=new NDKSubscriptionFilters(e,t,this.ndkRelay);if(!n||!e.isGroupable())return void this.executeSubscriptions(n,new NDKGroupedSubscriptions([r]),t);const o=this.activeSubscriptionsByGroupId.get(n);if(o){if(findMatchingActiveSubscriptions(o.filters,t)){const n=this.activeSubscriptions.get(o.sub);return void n?.addSubscription(new NDKSubscriptionFilters(e,t,this.ndkRelay))}}let s=this.delayedItems.get(n);s?s.addSubscription(r):(s=new NDKGroupedSubscriptions([r]),this.delayedItems.set(n,s),s.once("close",(()=>{this.delayedItems.get(n)&&this.delayedItems.delete(n)})));let i=this.executionTimeoutsByGroupId.get(n);i&&"at-most"!==e.opts.groupableDelayType||(i=setTimeout((()=>{this.executeGroup(n,e)}),e.opts.groupableDelay),this.executionTimeoutsByGroupId.set(n,i)),this.delayedTimers.has(n)?this.delayedTimers.get(n).push(i):this.delayedTimers.set(n,[i])}executeGroup(e,t){const n=this.delayedItems.get(e);this.delayedItems.delete(e);const r=this.delayedTimers.get(e);if(this.delayedTimers.delete(e),r)for(const e of r)clearTimeout(e);if(n){const t=n.subscriptions[0].filters.length,r=[];for(let e=0;e<t;e++){const t=n.map((t=>t.filters[e]));r.push(mergeFilters(t))}this.executeSubscriptions(e,n,r)}}executeSubscriptionsWhenConnected(e,t,n){const r=()=>{this.debug("new relay coming online for active subscription",{relay:this.ndkRelay.url,mergeFilters:mergeFilters}),this.executeSubscriptionsConnected(e,t,n)};this.ndkRelay.once("ready",r),t.once("close",(()=>{this.ndkRelay.removeListener("ready",r)}))}executeSubscriptions(e,t,n){this.conn.isAvailable()?this.executeSubscriptionsConnected(e,t,n):this.executeSubscriptionsWhenConnected(e,t,n)}executeSubscriptionsConnected(e,t,n){const r=[];for(const{subscription:e}of t)r.push(e);const o=generateSubId(r,n);t.req=n;const s={id:o};(this.ndkRelay.trusted||r.every((e=>e.opts.skipVerification)))&&(s.skipVerification=!0);const i=this.conn.relay.sub(n,s);return this.activeSubscriptions.set(i,t),e&&this.activeSubscriptionsByGroupId.set(e,{filters:n,sub:i}),i.on("event",(e=>{const t=new NDKEvent(void 0,e);t.relay=this.ndkRelay;const n=this.activeSubscriptions.get(i);n?.eventReceived(t)})),i.on("eose",(()=>{const e=this.activeSubscriptions.get(i);e?.eoseReceived(this.ndkRelay)})),t.once("close",(()=>{i.unsub(),this.activeSubscriptions.delete(i),e&&this.activeSubscriptionsByGroupId.delete(e)})),this.executeSubscriptionsWhenConnected(e,t,n),i}executedFilters(){const e=new Map;for(const[,t]of this.activeSubscriptions)e.set(t.req,t.map((e=>e.subscription)));return e}},NDKRelay=class extends lib$1.EventEmitter{url;scores;connectivity;subs;publisher;authPolicy;authRequired=!1;trusted=!1;complaining=!1;debug;constructor(e,t){super(),this.url=e,this.scores=new Map,this.debug=debug3(`ndk:relay:${e}`),this.connectivity=new NDKRelayConnectivity(this),this.subs=new NDKRelaySubscriptions(this),this.publisher=new NDKRelayPublisher(this),this.authPolicy=t}get status(){return this.connectivity.status}get connectionStats(){return this.connectivity.connectionStats}async connect(){return this.connectivity.connect()}disconnect(){3!==this.status&&this.connectivity.disconnect()}subscribe(e,t){this.subs.subscribe(e,t)}async publish(e,t=2500){return this.publisher.publish(e,t)}async auth(e){return this.publisher.auth(e)}scoreSlowerEvent(e){}tagReference(e){const t=["r",this.url];return e&&t.push(e),t}referenceTags(){return[["r",this.url]]}activeSubscriptions(){return this.subs.executedFilters()}},PublishError=class extends Error{errors;constructor(e,t){super(e),this.errors=t}},NDKRelaySet=class e{relays;debug;ndk;constructor(e,t){this.relays=e,this.ndk=t,this.debug=t.debug.extend("relayset")}addRelay(e){this.relays.add(e)}static fromRelayUrls(t,n){const r=new Set;for(const e of t){const t=n.pool.relays.get(e);if(t)r.add(t);else{const t=new NDKRelay(e);n.pool.useTemporaryRelay(t),r.add(t)}}return new e(new Set(r),n)}async publish(e,t){const n=new Set,r=new Map,o=e.isEphemeral(),s=Array.from(this.relays).map((s=>new Promise((i=>{s.publish(e,t).then((()=>{n.add(s),i()})).catch((e=>{o||(r.set(s,e),this.debug("error publishing to relay",{relay:s.url,err:e})),i()}))}))));if(await Promise.all(s),0===n.size&&!o)throw new PublishError("No relay was able to receive the event",r);return n}size(){return this.relays.size}};function calculateRelaySetFromEvent(e,t){const n=new Set;return e.pool?.relays.forEach((e=>n.add(e))),new NDKRelaySet(n,e)}function getWriteRelaysFor(e,t){if(e.outboxTracker)return e.outboxTracker.data.get(t)?.writeRelays}function calculateRelaySetsFromFilter(e,t){const n=new Map,r=new Set;if(t.forEach((e=>{e.authors&&e.authors.forEach((e=>r.add(e)))})),r.size>0){const o=new Map;for(const t of r){const n=getWriteRelaysFor(e,t);n&&n.size>0?(e.debug(`Adding ${n.size} relays for ${t}`),n.forEach((e=>{const n=o.get(e)||[];n.push(t),o.set(e,n)}))):e.explicitRelayUrls?.forEach((e=>{const n=o.get(e)||[];n.push(t),o.set(e,n)}))}for(const e of o.keys())n.set(e,[]);for(const e of t)if(e.authors)for(const[t,r]of o.entries()){const o=e.authors.filter((e=>r.includes(e)));n.set(t,[...n.get(t),{...e,authors:o}])}else for(const t of o.keys())n.set(t,[...n.get(t),e])}else e.explicitRelayUrls?.forEach((e=>{n.set(e,t)}));return n}function calculateRelaySetsFromFilters(e,t){return calculateRelaySetsFromFilter(e,t)}var DEFAULT_RELAYS=["wss://nos.lol","wss://relay.nostr.band","wss://relay.f7z.io","wss://relay.damus.io","wss://nostr.mom","wss://no.str.cr"],Zap=class extends lib$1.EventEmitter{ndk;zappedEvent;zappedUser;constructor(e){super(),this.ndk=e.ndk,this.zappedEvent=e.zappedEvent,this.zappedUser=e.zappedUser||this.ndk.getUser({hexpubkey:this.zappedEvent?.pubkey})}async getZapEndpoint(){let e,t,n,r;if(this.zappedUser&&(this.zappedUser.profile||await this.zappedUser.fetchProfile({groupable:!1}),e=(this.zappedUser.profile||{}).lud06,t=(this.zappedUser.profile||{}).lud16),t&&!t.startsWith("LNURL")){const[e,r]=t.split("@");n=`https://${r}/.well-known/lnurlp/${e}`}else if(e){const{words:t}=bech32$1.decode(e,1e3),r=bech32$1.fromWords(t);n=new TextDecoder("utf-8").decode(r)}if(!n)throw new Error("No zap endpoint found");try{const e=this.ndk.httpFetch||fetch,t=await e(n);if(200!==t.status){const e=await t.text();throw new Error(`Unable to fetch zap endpoint ${n}: ${e}`)}const o=await t.json();return o?.allowsNostr&&(o?.nostrPubkey||o?.nostrPubKey)&&(r=o.callback),r}catch(e){throw new Error(`Unable to fetch zap endpoint ${n}: ${e}`)}}async createZapRequest(e,t,n,r,o){const s=await this.generateZapRequest(e,t,n,r);if(!s)return null;const{event:i,zapEndpoint:a}=s;if(!i)throw new Error("No zap request event found");let l;await i.sign(o);try{l=await this.getInvoice(i,e,a)}catch(e){throw new Error("Failed to get invoice: "+e)}return l}async getInvoice(e,t,n){const r=await fetch(`${n}?`+new URLSearchParams({amount:t.toString(),nostr:JSON.stringify(e.rawEvent())}));return(await r.json()).pr}async generateZapRequest(e,t,n,r,o){const s=await this.getZapEndpoint();if(!s)throw new Error("No zap endpoint found");if(!this.zappedEvent&&!this.zappedUser)throw new Error("No zapped event or user found");const i=nip57_exports.makeZapRequest({profile:this.zappedUser.pubkey,event:null,amount:e,comment:t||"",relays:r??this.relays()});if(this.zappedEvent){const e=this.zappedEvent.referenceTags();i.tags.push(...e)}i.tags.push(["lnurl",s]);const a=new NDKEvent(this.ndk,i);return n&&(a.tags=a.tags.concat(n)),{event:a,zapEndpoint:s}}relays(){let e=[];return this.ndk?.pool?.relays&&(e=this.ndk.pool.urls()),e.length||(e=DEFAULT_RELAYS),e}};function mergeTags(e,t){const n=new Map,r=(e,t)=>e.every(((e,n)=>e===t[n]));return e.concat(t).forEach((e=>{for(let[t,o]of n)if(r(o,e)||r(e,o))return void(e.length>=o.length&&n.set(t,e));n.set((e=>e.join(","))(e),e)})),Array.from(n.values())}async function generateContentTags(e,t=[]){let n=[];const r=e=>{t.find((t=>t[0]===e[0]&&t[1]===e[1]))||t.push(e)};return e=e.replace(/(@|nostr:)(npub|nprofile|note|nevent|naddr)[a-zA-Z0-9]+/g,(e=>{try{const t=e.split(/(@|nostr:)/)[2],{type:o,data:s}=nip19_exports.decode(t);let i;switch(o){case"npub":i=["p",s];break;case"nprofile":i=["p",s.pubkey];break;case"note":n.push(new Promise((async e=>{r(["e",s,await maybeGetEventRelayUrl(t),"mention"]),e()})));break;case"nevent":n.push(new Promise((async e=>{let{id:n,relays:o,author:i}=s;o&&0!==o.length||(o=[await maybeGetEventRelayUrl(t)]),r(["e",n,o[0],"mention"]),i&&r(["p",i]),e()})));break;case"naddr":n.push(new Promise((async e=>{const n=[s.kind,s.pubkey,s.identifier].join(":");let o=s.relays??[];0===o.length&&(o=[await maybeGetEventRelayUrl(t)]),r(["a",n,o[0],"mention"]),r(["p",s.pubkey]),e()})));break;default:return e}return i&&r(i),`nostr:${t}`}catch(t){return e}})),await Promise.all(n),{content:e=e.replace(/#(\w+)/g,((e,n)=>{const r=["t",n];return t.find((e=>e[0]===r[0]&&e[1]===r[1]))||t.push(r),e})),tags:t}}async function maybeGetEventRelayUrl(e){return""}function isReplaceable(){if(void 0===this.kind)throw new Error("Kind not set");return this.kind>=1e4&&this.kind<2e4}function isEphemeral(){if(void 0===this.kind)throw new Error("Kind not set");return this.kind>=2e4&&this.kind<3e4}function isParamReplaceable(){if(void 0===this.kind)throw new Error("Kind not set");return this.kind>=3e4&&this.kind<4e4}async function encrypt(e,t){if(!this.ndk)throw new Error("No NDK instance found!");if(t||(await this.ndk.assertSigner(),t=this.ndk.signer),!e){const t=this.getMatchingTags("p");if(1!==t.length)throw new Error("No recipient could be determined and no explicit recipient was provided");e=this.ndk.getUser({hexpubkey:t[0][1]})}this.content=await(t?.encrypt(e,this.content))}async function decrypt(e,t){if(!this.ndk)throw new Error("No NDK instance found!");t||(await this.ndk.assertSigner(),t=this.ndk.signer),e||(e=this.author),this.content=await(t?.decrypt(e,this.content))}function encode(){return this.isParamReplaceable()?nip19_exports.naddrEncode({kind:this.kind,pubkey:this.pubkey,identifier:this.replaceableDTag(),relays:this.relay?[this.relay.url]:[]}):this.relay?nip19_exports.neventEncode({id:this.tagId(),relays:[this.relay.url],author:this.pubkey}):nip19_exports.noteEncode(this.tagId())}async function repost(e=!0,t){if(!t&&e){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner(),t=this.ndk.signer}const n=new NDKEvent(this.ndk,{kind:getKind(this),content:""});return n.tag(this),16===n.kind&&n.tags.push(["k",`${this.kind}`]),t&&await n.sign(t),e&&await n.publish(),n}function getKind(e){return 1===e.kind?6:16}var NDKEvent=class e extends lib$1.EventEmitter{ndk;created_at;content="";tags=[];kind;id="";sig;pubkey="";_author=void 0;relay;constructor(e,t){super(),this.ndk=e,this.created_at=t?.created_at,this.content=t?.content||"",this.tags=t?.tags||[],this.id=t?.id||"",this.sig=t?.sig,this.pubkey=t?.pubkey||"",this.kind=t?.kind}rawEvent(){return{created_at:this.created_at,content:this.content,tags:this.tags,kind:this.kind,pubkey:this.pubkey,id:this.id,sig:this.sig}}set author(e){this.pubkey=e.hexpubkey,this._author=void 0}get author(){if(this._author)return this._author;if(!this.ndk)throw new Error("No NDK instance found");const e=this.ndk.getUser({hexpubkey:this.pubkey});return this._author=e,e}tag(t,n){let r=[];if(t instanceof NDKUser){const e=["p",t.pubkey];n&&e.push(n),r.push(e)}else if(t instanceof e){const e=t,o=e?.pubkey===this.pubkey;r=e.referenceTags(n,o);for(const t of e.getMatchingTags("p"))t[1]!==this.pubkey&&(this.tags.find((e=>"p"===e[0]&&e[1]===t[1]))||this.tags.push(["p",t[1]]))}else r=[t];this.tags=mergeTags(this.tags,r)}async toNostrEvent(e){if(!e&&""===this.pubkey){const e=await(this.ndk?.signer?.user());this.pubkey=e?.hexpubkey||""}this.created_at||(this.created_at=Math.floor(Date.now()/1e3));const t=this.rawEvent(),{content:n,tags:r}=await this.generateTags();t.content=n||"",t.tags=r;try{this.id=getEventHash(t)}catch(e){}return this.id&&(t.id=this.id),this.sig&&(t.sig=this.sig),t}isReplaceable=isReplaceable.bind(this);isEphemeral=isEphemeral.bind(this);isParamReplaceable=isParamReplaceable.bind(this);encode=encode.bind(this);encrypt=encrypt.bind(this);decrypt=decrypt.bind(this);getMatchingTags(e){return this.tags.filter((t=>t[0]===e))}tagValue(e){const t=this.getMatchingTags(e);if(0!==t.length)return t[0][1]}get alt(){return this.tagValue("alt")}set alt(e){this.removeTag("alt"),e&&this.tags.push(["alt",e])}removeTag(e){this.tags=this.tags.filter((t=>t[0]!==e))}async sign(e){e?this.author=await e.user():(this.ndk?.assertSigner(),e=this.ndk.signer),await this.generateTags(),this.isReplaceable()&&(this.created_at=Math.floor(Date.now()/1e3));const t=await this.toNostrEvent();return this.sig=await e.sign(t),this.sig}async publish(e,t){if(this.sig||await this.sign(),!this.ndk)throw new Error("NDKEvent must be associated with an NDK instance to publish");return e||(e=this.ndk.devWriteRelaySet||calculateRelaySetFromEvent(this.ndk)),e.publish(this,t)}async generateTags(){let e=[];const t=await generateContentTags(this.content,this.tags),n=t.content;if(e=t.tags,this.kind&&this.isParamReplaceable()){if(!this.getMatchingTags("d")[0]){const t=this.tagValue("title");let n=[...Array(t?6:16)].map((()=>Math.random().toString(36)[2])).join("");t&&t.length>0&&(n=t.replace(/[^a-z0-9]+/gi,"-").replace(/^-|-$/g,"")+"-"+n),e.push(["d",n])}}if((this.ndk?.clientName||this.ndk?.clientNip89)&&!this.tagValue("client")){const t=["client",this.ndk.clientName??""];this.ndk.clientNip89&&t.push(this.ndk.clientNip89),e.push(t)}return{content:n||"",tags:e}}muted(){const e=this.ndk?.mutedIds.get(this.pubkey);if(e&&"p"===e)return"author";const t=this.tagReference(),n=this.ndk?.mutedIds.get(t[1]);return n&&n===t[0]?"event":null}replaceableDTag(){if(this.kind&&this.kind>=3e4&&this.kind<=4e4){const e=this.getMatchingTags("d")[0];return e?e[1]:""}throw new Error("Event is not a parameterized replaceable event")}deduplicationKey(){return 0===this.kind||3===this.kind||this.kind&&this.kind>=1e4&&this.kind<2e4?`${this.kind}:${this.pubkey}`:this.tagId()}tagId(){return this.isParamReplaceable()?this.tagAddress():this.id}tagAddress(){if(!this.isParamReplaceable())throw new Error("This must only be called on replaceable events");const e=this.replaceableDTag();return`${this.kind}:${this.pubkey}:${e}`}tagReference(e){let t;return t=this.isParamReplaceable()?["a",this.tagAddress()]:["e",this.tagId()],this.relay?t.push(this.relay.url):t.push(""),e&&t.push(e),t}referenceTags(e,t){let n=[];return n=this.isParamReplaceable()?[["a",this.tagAddress()],["e",this.id]]:[["e",this.id]],this.relay?.url?n=n.map((e=>(e.push(this.relay?.url),e))):e&&(n=n.map((e=>(e.push(""),e)))),e&&n.forEach((t=>t.push(e))),t||n.push(...this.author.referenceTags()),n}filter(){return this.isParamReplaceable()?{"#a":[this.tagId()]}:{"#e":[this.tagId()]}}async zap(e,t,n,r,o){if(!this.ndk)throw new Error("No NDK instance found");o||this.ndk.assertSigner();const s=new Zap({ndk:this.ndk,zappedEvent:this,zappedUser:r}),i=Array.from(this.ndk.pool.relays.keys());return await s.createZapRequest(e,t,n,i,o)}async delete(t){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner();const n=new e(this.ndk,{kind:5,content:t||""});return n.tag(this),await n.publish(),n}repost=repost.bind(this);async react(t,n=!0){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner();const r=new e(this.ndk,{kind:7,content:t});return r.tag(this),n?await r.publish():await r.sign(),r}get isValid(){return!0}},READ_MARKER="read",WRITE_MARKER="write",NDKRelayList=class e extends NDKEvent{constructor(e,t){super(e,t),this.kind??=10002}static from(t){return new e(t.ndk,t.rawEvent())}get readRelayUrls(){return this.getMatchingTags("r").filter((e=>!e[2]||e[2]&&e[2]===READ_MARKER)).map((e=>e[1]))}set readRelayUrls(e){for(const t of e)this.tags.push(["r",t,READ_MARKER])}get writeRelayUrls(){return this.getMatchingTags("r").filter((e=>!e[2]||e[2]&&e[2]===WRITE_MARKER)).map((e=>e[1]))}set writeRelayUrls(e){for(const t of e)this.tags.push(["r",t,WRITE_MARKER])}get bothRelayUrls(){return this.getMatchingTags("r").filter((e=>!e[2])).map((e=>e[1]))}set bothRelayUrls(e){for(const t of e)this.tags.push(["r",t])}get relays(){return this.getMatchingTags("r").map((e=>e[1]))}},NDKSubscriptionCacheUsage=(e=>(e.ONLY_CACHE="ONLY_CACHE",e.CACHE_FIRST="CACHE_FIRST",e.PARALLEL="PARALLEL",e.ONLY_RELAY="ONLY_RELAY",e))(NDKSubscriptionCacheUsage||{}),defaultOpts={closeOnEose:!1,cacheUsage:"CACHE_FIRST",groupable:!0,groupableDelay:100,groupableDelayType:"at-most"},NDKSubscription=class extends lib$1.EventEmitter{subId;filters;opts;pool;skipVerification=!1;skipValidation=!1;relayFilters;relaySet;ndk;debug;eoseDebug;eventFirstSeen=new Map;eosesSeen=new Set;eventsPerRelay=new Map;lastEventReceivedAt;internalId;constructor(e,t,n,r,o){if(super(),this.ndk=e,this.pool=n?.pool||e.pool,this.opts={...defaultOpts,...n||{}},this.filters=t instanceof Array?t:[t],this.subId=o||n?.subId,this.internalId=Math.random().toString(36).substring(7),this.relaySet=r,this.debug=e.debug.extend(`subscription[${n?.subId??this.internalId}]`),this.eoseDebug=this.debug.extend("eose"),this.skipVerification=n?.skipVerification||!1,this.skipValidation=n?.skipValidation||!1,this.opts.closeOnEose||this.debug("Creating a permanent subscription",this.opts,JSON.stringify(this.filters)),"ONLY_CACHE"===this.opts.cacheUsage&&!this.opts.closeOnEose)throw new Error("Cannot use cache-only options with a persistent subscription")}get filter(){return this.filters[0]}isGroupable(){return this.opts?.groupable||!1}shouldQueryCache(){return"ONLY_RELAY"!==this.opts?.cacheUsage}shouldQueryRelays(){return"ONLY_CACHE"!==this.opts?.cacheUsage}shouldWaitForCache(){return this.opts.closeOnEose&&!!this.ndk.cacheAdapter?.locking&&"PARALLEL"!==this.opts.cacheUsage}async start(){let e;this.shouldQueryCache()&&(e=this.startWithCache(),this.shouldWaitForCache()&&(await e,queryFullyFilled(this)))?this.emit("eose",this):this.shouldQueryRelays()?this.startWithRelays():this.emit("eose",this)}stop(){this.emit("close",this),this.removeAllListeners()}hasAuthorsFilter(){return this.filters.some((e=>e.authors?.length))}async startWithCache(){if(this.ndk.cacheAdapter?.query){const e=this.ndk.cacheAdapter.query(this);this.ndk.cacheAdapter.locking&&await e}}startWithRelays(){if(this.relaySet){this.relayFilters=new Map;for(const e of this.relaySet.relays)this.relayFilters.set(e.url,this.filters)}else this.relayFilters=calculateRelaySetsFromFilters(this.ndk,this.filters);if(this.relayFilters&&0!==this.relayFilters.size)for(const[e,t]of this.relayFilters){this.pool.getRelay(e).subscribe(this,t)}else this.debug("No relays to subscribe to",this.ndk.explicitRelayUrls)}eventReceived(e,t,n=!1){if(t&&(e.relay=t),t||(t=e.relay),this.skipValidation||e.isValid){if(!n&&t){let n=this.eventsPerRelay.get(t);n||(n=new Set,this.eventsPerRelay.set(t,n)),n.add(e.id);if(this.eventFirstSeen.has(e.id)){const n=Date.now()-(this.eventFirstSeen.get(e.id)||0);return t.scoreSlowerEvent(n),void this.emit("event:dup",e,t,n,this)}this.ndk.cacheAdapter&&this.ndk.cacheAdapter.setEvent(e,this.filters,t),this.eventFirstSeen.set(e.id,Date.now())}else this.eventFirstSeen.set(e.id,0);e.ndk||(e.ndk=this.ndk),this.emit("event",e,t,this),this.lastEventReceivedAt=Date.now()}else this.debug("Event failed validation",e)}eoseTimeout;eoseReceived(e){this.eosesSeen.add(e),this.eoseDebug(`received from ${e.url}`);let t=this.lastEventReceivedAt?Date.now()-this.lastEventReceivedAt:void 0;const n=this.eosesSeen.size===this.relayFilters?.size;if(queryFullyFilled(this))this.emit("eose"),this.eoseDebug("Query fully filled"),this.opts?.closeOnEose&&this.stop();else if(n)this.emit("eose"),this.eoseDebug("All EOSEs seen"),this.opts?.closeOnEose&&this.stop();else{let e=1e3;const n=this.eosesSeen.size/this.relayFilters.size;if(this.eosesSeen.size>=2&&n>=.5){e*=1-n,this.eoseTimeout&&clearTimeout(this.eoseTimeout);const r=()=>{t=this.lastEventReceivedAt?Date.now()-this.lastEventReceivedAt:void 0,void 0!==t&&t<20?this.eoseTimeout=setTimeout(r,e):(this.emit("eose"),this.opts?.closeOnEose&&this.stop())};this.eoseTimeout=setTimeout(r,e)}}}};async function follows(e,t,n=3){if(!this.ndk)throw new Error("NDK not set");const r=Array.from(await this.ndk.fetchEvents({kinds:[n],authors:[this.pubkey]},e||{groupable:!1}))[0];if(r){const e=new Set;return r.tags.forEach((n=>{if("p"===n[0])try{e.add(n[1]),t&&this.ndk?.outboxTracker?.trackUsers([n[1]])}catch(e){}})),[...e].reduce(((e,t)=>{const n=new NDKUser({pubkey:t});return n.ndk=this.ndk,e.add(n),e}),new Set)}return new Set}function profileFromEvent(e){const t={};let n;try{n=JSON.parse(e.content)}catch(e){throw new Error(`Failed to parse profile event: ${e}`)}return Object.keys(n).forEach((e=>{switch(e){case"name":t.name=n.name;break;case"display_name":t.displayName=n.display_name;break;case"image":case"picture":t.image=n.image||n.picture;break;case"banner":t.banner=n.banner;break;case"bio":t.bio=n.bio;break;case"nip05":t.nip05=n.nip05;break;case"lud06":t.lud06=n.lud06;break;case"lud16":t.lud16=n.lud16;break;case"about":t.about=n.about;break;case"zapService":t.zapService=n.zapService;break;case"website":t.website=n.website;break;default:t[e]=n[e]}})),t}function serializeProfile(e){const t={};for(const[n,r]of Object.entries(e))switch(n){case"username":case"name":t.name=r;break;case"displayName":t.display_name=r;break;case"image":case"picture":t.picture=r;break;case"bio":case"about":t.about=r;break;default:t[n]=r}return JSON.stringify(t)}var NDKList=class e extends NDKEvent{_encryptedTags;encryptedTagsLength;constructor(e,t){super(e,t),this.kind??=30001}static from(t){return new e(t.ndk,t.rawEvent())}get title(){const e=this.tagValue("title")||this.tagValue("name");return 3!==this.kind||e?1e4!==this.kind||e?10001!==this.kind||e?10002!==this.kind||e?10003!==this.kind||e?10004!==this.kind||e?10005!==this.kind||e?10006!==this.kind||e?10007!==this.kind||e?10015!==this.kind||e?10030!==this.kind||e?e??this.tagValue("d"):"Emojis":"Interests":"Search Relays":"Blocked Relays":"Public Chats":"Communities":"Bookmarks":"Relay Metadata":"Pinned Notes":"Mute":"Contacts"}set title(e){if(this.removeTag("title"),this.removeTag("name"),!e)throw new Error("Title cannot be empty");this.tags.push(["title",e])}get name(){const e=this.tagValue("name");return 3!==this.kind||e?1e4!==this.kind||e?10001!==this.kind||e?10002!==this.kind||e?10003!==this.kind||e?10004!==this.kind||e?10005!==this.kind||e?10006!==this.kind||e?10007!==this.kind||e?10015!==this.kind||e?10030!==this.kind||e?e??this.tagValue("d"):"Emojis":"Interests":"Search Relays":"Blocked Relays":"Public Chats":"Communities":"Bookmarks":"Relay Metadata":"Pinned Notes":"Mute":"Contacts"}set name(e){if(this.removeTag("name"),!e)throw new Error("Name cannot be empty");this.tags.push(["title",e])}get description(){return this.tagValue("description")}set description(e){e?this.tags.push(["description",e]):this.removeTag("description")}isEncryptedTagsCacheValid(){return!(!this._encryptedTags||this.encryptedTagsLength!==this.content.length)}async encryptedTags(e=!0){if(e&&this.isEncryptedTagsCacheValid())return this._encryptedTags;if(!this.ndk)throw new Error("NDK instance not set");if(!this.ndk.signer)throw new Error("NDK signer not set");const t=await this.ndk.signer.user();try{if(this.content.length>0)try{const e=await this.ndk.signer.decrypt(t,this.content),n=JSON.parse(e);return n&&n[0]?(this.encryptedTagsLength=this.content.length,this._encryptedTags=n):(this.encryptedTagsLength=this.content.length,this._encryptedTags=[])}catch(e){console.log(`error decrypting ${this.content}`)}}catch(e){}return[]}validateTag(e){return!0}get items(){return this.tags.filter((e=>!["d","L","l","title","name","description","summary","image","thumb","alt","expiration","subject"].includes(e[0])))}async addItem(e,t=void 0,n=!1){if(!this.ndk)throw new Error("NDK instance not set");if(!this.ndk.signer)throw new Error("NDK signer not set");let r;if(e instanceof NDKEvent)r=e.referenceTags();else if(e instanceof NDKUser)r=e.referenceTags();else if(e instanceof NDKRelay)r=e.referenceTags();else{if(!Array.isArray(e))throw new Error("Invalid object type");r=[e]}if(t&&r[0].push(t),n){const e=await this.ndk.signer.user(),t=await this.encryptedTags();t.push(...r),this._encryptedTags=t,this.encryptedTagsLength=this.content.length,this.content=JSON.stringify(t),await this.encrypt(e)}else this.tags.push(...r);this.created_at=Math.floor(Date.now()/1e3),this.emit("change")}async removeItem(e,t){if(!this.ndk)throw new Error("NDK instance not set");if(!this.ndk.signer)throw new Error("NDK signer not set");if(t){const t=await this.ndk.signer.user(),n=await this.encryptedTags();n.splice(e,1),this._encryptedTags=n,this.encryptedTagsLength=this.content.length,this.content=JSON.stringify(n),await this.encrypt(t)}else this.tags.splice(e,1);return this.created_at=Math.floor(Date.now()/1e3),this.emit("change"),this}},lists_default=NDKList;async function pin(e,t,n){if(!this.ndk)throw new Error("No NDK instance found");if(this.ndk.assertSigner(),!t){const e=await this.ndk.fetchEvents({kinds:[10001],authors:[this.pubkey]},{cacheUsage:"ONLY_RELAY"});t=e.size>0?lists_default.from(Array.from(e)[0]):new NDKEvent(this.ndk,{kind:10001})}return t.tag(e),n&&await t.publish(),t}var NIP05_REGEX=/^(?:([\w.+-]+)@)?([\w.-]+)$/;async function getNip05For(e,t=fetch,n={}){const r=e.match(NIP05_REGEX);if(!r)return null;const[o,s="_",i]=r;try{const e=await t(`https://${i}/.well-known/nostr.json?name=${s}`,n),{names:r,relays:o,nip46:a}=parseNIP05Result(await e.json()),l=r[s];return l?{pubkey:l,relays:o?.[l],nip46:a?.[l]}:null}catch(e){return null}}function parseNIP05Result(e){const t={names:{}};for(const[n,r]of Object.entries(e.names))"string"==typeof n&&"string"==typeof r&&(t.names[n]=r);if(e.relays){t.relays={};for(const[n,r]of Object.entries(e.relays))"string"==typeof n&&Array.isArray(r)&&(t.relays[n]=r.filter((e=>"string"==typeof e)))}if(e.nip46){t.nip46={};for(const[n,r]of Object.entries(e.relays))"string"==typeof n&&Array.isArray(r)&&(t.nip46[n]=r.filter((e=>"string"==typeof e)))}return t}var NDKUser=class e{ndk;profile;_npub;_pubkey;relayUrls=[];nip46Urls=[];constructor(e){e.npub&&(this._npub=e.npub),e.hexpubkey&&(this._pubkey=e.hexpubkey),e.pubkey&&(this._pubkey=e.pubkey),e.relayUrls&&(this.relayUrls=e.relayUrls),e.nip46Urls&&(this.nip46Urls=e.nip46Urls)}get npub(){if(!this._npub){if(!this._pubkey)throw new Error("hexpubkey not set");this._npub=nip19_exports.npubEncode(this.pubkey)}return this._npub}set npub(e){this._npub=e}get hexpubkey(){return this.pubkey}set hexpubkey(e){this._pubkey=e}get pubkey(){if(!this._pubkey){if(!this._npub)throw new Error("npub not set");this._pubkey=nip19_exports.decode(this.npub).data}return this._pubkey}set pubkey(e){this._pubkey=e}static async fromNip05(t,n,r=!1){if(n?.cacheAdapter&&n.cacheAdapter.loadNip05){const r=await n.cacheAdapter.loadNip05(t);if(r){const t=new e({pubkey:r.pubkey,relayUrls:r.relays,nip46Urls:r.nip46});return t.ndk=n,t}}let o={};r&&(o.cache="no-cache");const s=await getNip05For(t,n?.httpFetch,o);if(s&&n?.cacheAdapter&&n.cacheAdapter.saveNip05&&n?.cacheAdapter.saveNip05(t,s),s){const t=new e({pubkey:s.pubkey,relayUrls:s.relays,nip46Urls:s.nip46});return t.ndk=n,t}}async fetchProfile(e){if(!this.ndk)throw new Error("NDK not set");this.profile||(this.profile={});let t=null;if(this.ndk.cacheAdapter&&this.ndk.cacheAdapter.fetchProfile&&"ONLY_RELAY"!==e?.cacheUsage){const e=await this.ndk.cacheAdapter.fetchProfile(this.pubkey);if(e)return this.profile=e,e}!e&&this.ndk.cacheAdapter&&this.ndk.cacheAdapter.locking&&(t=await this.ndk.fetchEvents({kinds:[0],authors:[this.pubkey]},{cacheUsage:"ONLY_CACHE",closeOnEose:!0,groupable:!1}),e={cacheUsage:"ONLY_RELAY",closeOnEose:!0,groupable:!0,groupableDelay:250}),t&&0!==t.size||(t=await this.ndk.fetchEvents({kinds:[0],authors:[this.pubkey]},e));const n=Array.from(t).sort(((e,t)=>e.created_at-t.created_at));return 0===n.length?null:(this.profile=profileFromEvent(n[0]),this.profile&&this.ndk.cacheAdapter&&this.ndk.cacheAdapter.saveProfile&&this.ndk.cacheAdapter.saveProfile(this.pubkey,this.profile),this.profile)}follows=follows.bind(this);pin=pin.bind(this);async relayList(){if(!this.ndk)throw new Error("NDK not set");const e=this.ndk.outboxPool||this.ndk.pool,t=new Set;for(const n of e.relays.values())t.add(n);const n=new NDKRelaySet(t,this.ndk),r=await this.ndk.fetchEvent({kinds:[10002],authors:[this.pubkey]},{closeOnEose:!0,pool:e,groupable:!0,subId:`relay-list-${this.pubkey.slice(0,6)}`},n);return r?NDKRelayList.from(r):await this.relayListFromKind3()}async relayListFromKind3(){if(!this.ndk)throw new Error("NDK not set");const e=await this.ndk.fetchEvent({kinds:[3],authors:[this.pubkey]});if(e)try{const t=JSON.parse(e.content),n=new NDKRelayList(this.ndk),r=new Set,o=new Set;for(const[e,n]of Object.entries(t))if(n){const t=n;t.write&&o.add(e),t.read&&r.add(e)}else r.add(e),o.add(e);return n.readRelayUrls=Array.from(r),n.writeRelayUrls=Array.from(o),n}catch(e){}}tagReference(){return["p",this.pubkey]}referenceTags(e){const t=[["p",this.pubkey]];return e?(t[0].push("",e),t):t}async publish(){if(!this.ndk)throw new Error("No NDK instance found");if(!this.profile)throw new Error("No profile available");this.ndk.assertSigner();const e=new NDKEvent(this.ndk,{kind:0,content:serializeProfile(this.profile)});await e.publish()}async follow(e,t,n=3){if(!this.ndk)throw new Error("No NDK instance found");if(this.ndk.assertSigner(),t||(t=await this.follows(void 0,void 0,n)),t.has(e))return!1;t.add(e);const r=new NDKEvent(this.ndk,{kind:n});for(const e of t)r.tag(e);return await r.publish(),!0}async validateNip05(e){if(!this.ndk)throw new Error("No NDK instance found");const t=await getNip05For(e);return null===t?null:t.pubkey===this.pubkey}async zap(e,t,n,r){if(!this.ndk)throw new Error("No NDK instance found");r||this.ndk.assertSigner();const o=new Zap({ndk:this.ndk,zappedUser:this}),s=Array.from(this.ndk.pool.relays.keys());return await o.createZapRequest(e,t,n,s,r)}},NDKPrivateKeySigner=class e{_user;privateKey;constructor(e){e&&(this.privateKey=e,this._user=new NDKUser({hexpubkey:getPublicKey(this.privateKey)}))}static generate(){const t=generatePrivateKey();return new e(t)}async blockUntilReady(){if(!this._user)throw new Error("NDKUser not initialized");return this._user}async user(){return await this.blockUntilReady(),this._user}async sign(e){if(!this.privateKey)throw Error("Attempted to sign without a private key");return getSignature(e,this.privateKey)}async encrypt(e,t){if(!this.privateKey)throw Error("Attempted to encrypt without a private key");const n=e.hexpubkey;return await nip04_exports.encrypt(this.privateKey,n,t)}async decrypt(e,t){if(!this.privateKey)throw Error("Attempted to decrypt without a private key");const n=e.hexpubkey;return await nip04_exports.decrypt(this.privateKey,n,t)}},NDKNostrRpc=class extends lib$1.EventEmitter{ndk;signer;debug;constructor(e,t,n){super(),this.ndk=e,this.signer=t,this.debug=n.extend("rpc")}subscribe(e){const t=this.ndk.subscribe(e,{closeOnEose:!1,groupable:!1});return t.on("event",(async e=>{try{const t=await this.parseEvent(e);t.method?this.emit("request",t):this.emit(`response-${t.id}`,t)}catch(t){this.debug("error parsing event",t,e.rawEvent())}})),new Promise(((e,n)=>{t.on("eose",(()=>e(t)))}))}async parseEvent(e){const t=this.ndk.getUser({hexpubkey:e.pubkey});t.ndk=this.ndk;const n=await this.signer.decrypt(t,e.content),r=JSON.parse(n),{id:o,method:s,params:i,result:a,error:l}=r;return s?{id:o,pubkey:e.pubkey,method:s,params:i,event:e}:{id:o,result:a,error:l,event:e}}async sendResponse(e,t,n,r=24133,o){const s={id:e,result:n};o&&(s.error=o);const i=await this.signer.user(),a=this.ndk.getUser({hexpubkey:t}),l=new NDKEvent(this.ndk,{kind:r,content:JSON.stringify(s),tags:[["p",t]],pubkey:i.hexpubkey});l.content=await this.signer.encrypt(a,l.content),await l.sign(this.signer),await l.publish()}async sendRequest(e,t,n=[],r=24133,o){const s=Math.random().toString(36).substring(7),i=await this.signer.user(),a=this.ndk.getUser({hexpubkey:e}),l={id:s,method:t,params:n},c=new Promise((e=>{const t=e=>{"auth_url"===e.result?(this.once(`response-${s}`,t),this.emit("authUrl",e.error)):o&&o(e)};this.once(`response-${s}`,t)})),d=new NDKEvent(this.ndk,{kind:r,content:JSON.stringify(l),tags:[["p",e]],pubkey:i.pubkey});return d.content=await this.signer.encrypt(a,d.content),await d.sign(this.signer),this.debug(`sending ${t} request to`,e),await d.publish(),c}},NDKNip46Signer=class extends lib$1.EventEmitter{ndk;remoteUser;remotePubkey;token;localSigner;nip05;rpc;debug;relayUrls=[];constructor(e,t,n){let r,o;if(super(),t.includes("#")){const e=t.split("#");r=new NDKUser({npub:e[0]}).pubkey,o=e[1]}else t.startsWith("npub")?r=new NDKUser({npub:t}).pubkey:t.match(/\./)?this.nip05=t:r=t;this.ndk=e,r&&(this.remotePubkey=r),this.token=o,this.debug=e.debug.extend("nip46:signer"),this.remoteUser=new NDKUser({pubkey:r}),this.localSigner=n||NDKPrivateKeySigner.generate(),this.rpc=new NDKNostrRpc(e,this.localSigner,this.debug),this.rpc.on("authUrl",((...e)=>{this.emit("authUrl",...e)})),this.localSigner.user().then((e=>{this.rpc.subscribe({kinds:[24133,24134],"#p":[e.pubkey]})}))}async user(){return this.remoteUser}async blockUntilReady(){const e=await this.localSigner.user(),t=this.ndk.getUser({pubkey:this.remotePubkey});if(this.nip05&&!this.remotePubkey&&NDKUser.fromNip05(this.nip05).then((e=>{e&&(this.remoteUser=e,this.remotePubkey=e.pubkey,this.relayUrls=e.nip46Urls)})),!this.remotePubkey)throw new Error("Remote pubkey not set");return new Promise(((n,r)=>{setTimeout((()=>{const o=[e.pubkey];this.token&&o.push(this.token),this.rpc.sendRequest(this.remotePubkey,"connect",o,24133,(e=>{"ack"===e.result?n(t):r(e.error)}))}),100)}))}async encrypt(e,t){this.debug("asking for encryption");return new Promise(((n,r)=>{this.rpc.sendRequest(this.remotePubkey,"nip04_encrypt",[e.pubkey,t],24133,(e=>{e.error?r(e.error):n(e.result)}))}))}async decrypt(e,t){this.debug("asking for decryption");return new Promise(((n,r)=>{this.rpc.sendRequest(this.remotePubkey,"nip04_decrypt",[e.pubkey,t],24133,(e=>{if(e.error)r(e.error);else{const t=JSON.parse(e.result);n(t[0])}}))}))}async sign(e){this.debug("asking for a signature");return new Promise(((t,n)=>{this.rpc.sendRequest(this.remotePubkey,"sign_event",[JSON.stringify(e)],24133,(e=>{if(this.debug("got a response",e),e.error)n(e.error);else{const n=JSON.parse(e.result);t(n.sig)}}))}))}async createAccount(e,t,n){this.debug("asking to create an account");const r=[];return e&&r.push(e),t&&r.push(t),n&&r.push(n),new Promise(((e,t)=>{this.rpc.sendRequest(this.remotePubkey,"create_account",r,24134,(n=>{if(this.debug("got a response",n),n.error)t(n.error);else{const t=n.result;e(t)}}))}))}};function dedup(e,t){return e.created_at>t.created_at?e:t}var OutboxItem=class{type;relayUrlScores;readRelays;writeRelays;constructor(e){this.type=e,this.relayUrlScores=new Map,this.readRelays=new Set,this.writeRelays=new Set}},OutboxTracker=class extends lib$1.EventEmitter{data;ndk;debug;constructor(e){super(),this.ndk=e,this.debug=e.debug.extend("outbox-tracker"),this.data=new dist.LRUCache({maxSize:1e5,entryExpirationTimeInMS:5e3})}trackUsers(e){for(const t of e){const e=getKeyFromItem(t);if(this.data.has(e))continue;const n=this.track(t,"user"),r=t instanceof NDKUser?t:new NDKUser({hexpubkey:t});r.ndk=this.ndk,r.relayList().then((t=>{if(t){n.readRelays=new Set(t.readRelayUrls),n.writeRelays=new Set(t.writeRelayUrls);for(const e of n.readRelays)this.ndk.pool.blacklistRelayUrls.has(e)&&(this.debug(`removing blacklisted relay ${e} from read relays`),n.readRelays.delete(e));for(const e of n.writeRelays)this.ndk.pool.blacklistRelayUrls.has(e)&&(this.debug(`removing blacklisted relay ${e} from write relays`),n.writeRelays.delete(e));this.data.set(e,n),this.debug(`Adding ${n.readRelays.size} read relays and ${n.writeRelays.size} write relays for ${r.hexpubkey}`)}}))}}track(e,t){const n=getKeyFromItem(e);t??=getTypeFromItem(e);let r=this.data.get(n);return r||(r=new OutboxItem(t)),this.data.set(n,r),r}};function getKeyFromItem(e){return e instanceof NDKUser?e.hexpubkey:e}function getTypeFromItem(e){return e instanceof NDKUser?"user":"kind"}var NDKPool=class extends lib$1.EventEmitter{relays=new Map;blacklistRelayUrls;debug;temporaryRelayTimers=new Map;flappingRelays=new Set;backoffTimes=new Map;constructor(e=[],t=[],n,r){super(),this.debug=r??n.debug.extend("pool");for(const t of e){const e=new NDKRelay(t);this.addRelay(e,!1)}this.blacklistRelayUrls=new Set(t)}useTemporaryRelay(e,t=6e5){const n=this.relays.has(e.url);n||this.addRelay(e);const r=this.temporaryRelayTimers.get(e.url);if(r&&clearTimeout(r),!n||r){const n=setTimeout((()=>{this.removeRelay(e.url)}),t);this.temporaryRelayTimers.set(e.url,n)}}addRelay(e,t=!0){const n=e.url;this.blacklistRelayUrls?.has(n)?this.debug(`Relay ${n} is blacklisted`):(e.on("notice",(async(e,t)=>this.emit("notice",e,t))),e.on("connect",(()=>this.handleRelayConnect(n))),e.on("ready",(()=>this.handleRelayReady(e))),e.on("disconnect",(async()=>this.emit("relay:disconnect",e))),e.on("flapping",(()=>this.handleFlapping(e))),e.on("auth",(async t=>this.emit("relay:auth",e,t))),this.relays.set(n,e),t&&e.connect().catch((e=>{this.debug(`Failed to connect to relay ${n}`,e)})))}removeRelay(e){const t=this.relays.get(e);if(t)return t.disconnect(),this.relays.delete(e),this.emit("relay:disconnect",t),!0;const n=this.temporaryRelayTimers.get(e);return n&&(clearTimeout(n),this.temporaryRelayTimers.delete(e)),!1}getRelay(e,t=!0){let n=this.relays.get(e);return n||(n=new NDKRelay(e),this.addRelay(n,t)),n}handleRelayConnect(e){this.debug(`Relay ${e} connected`),this.emit("relay:connect",this.relays.get(e)),this.stats().connected===this.relays.size&&this.emit("connect")}handleRelayReady(e){this.debug(`Relay ${e.url} ready`),this.emit("relay:ready",e)}async connect(e){const t=[];this.debug(`Connecting to ${this.relays.size} relays${e?`, timeout ${e}...`:""}`);for(const n of this.relays.values())if(e){const r=new Promise(((t,n)=>{setTimeout((()=>n(`Timed out after ${e}ms`)),e)}));t.push(Promise.race([n.connect(),r]).catch((e=>{this.debug(`Failed to connect to relay ${n.url}: ${e??"No reason specified"}`)})))}else t.push(n.connect());e&&setTimeout((()=>{const e=this.stats().connected===this.relays.size,t=this.stats().connected>0;!e&&t&&this.emit("connect")}),e),await Promise.all(t)}checkOnFlappingRelays(){if(this.flappingRelays.size/this.relays.size>=.8)for(const e of this.flappingRelays)this.backoffTimes.set(e,0)}handleFlapping(e){this.debug(`Relay ${e.url} is flapping`);let t=this.backoffTimes.get(e.url)||5e3;t*=2,this.backoffTimes.set(e.url,t),this.debug(`Backoff time for ${e.url} is ${t}ms`),setTimeout((()=>{this.debug(`Attempting to reconnect to ${e.url}`),e.connect(),this.checkOnFlappingRelays()}),t),e.disconnect(),this.emit("flapping",e)}size(){return this.relays.size}stats(){const e={total:0,connected:0,disconnected:0,connecting:0};for(const t of this.relays.values())e.total++,1===t.status?e.connected++:3===t.status?e.disconnected++:0===t.status&&e.connecting++;return e}connectedRelays(){return Array.from(this.relays.values()).filter((e=>1===e.status))}urls(){return Array.from(this.relays.keys())}};function correctRelaySet(e,t){const n=t.connectedRelays();if(!Array.from(e.relays).some((e=>n.map((e=>e.url)).includes(e.url))))for(const t of n)e.addRelay(t);if(0===n.length)for(const n of t.relays.values())e.addRelay(n);return e}var SPEC_PATH="/.well-known/nostr/nip96.json",Nip96=class{ndk;spec;url;nip98Required=!1;constructor(e,t){this.url=`https://${e}${SPEC_PATH}`,this.ndk=t}async prepareUpload(e,t="POST"){if(this.validateHttpFetch(),this.spec||await this.fetchSpec(),!this.spec)throw new Error("Failed to fetch NIP96 spec");let n={};if(this.nip98Required){n={Authorization:await this.generateNip98Header(this.spec.api_url,t,e)}}return{url:this.spec.api_url,headers:n}}async xhrUpload(e,t){const n="POST",{url:r,headers:o}=await this.prepareUpload(t,n);e.open(n,r,!0),o.Authorization&&e.setRequestHeader("Authorization",o.Authorization);const s=new FormData;return s.append("file",t),new Promise(((t,n)=>{e.onload=function(){e.status>=200&&e.status<300?t(JSON.parse(e.responseText)):n(new Error(e.statusText))},e.onerror=function(){n(new Error("Network Error"))},e.send(s)}))}async upload(e){const t="POST",{url:n,headers:r}=await this.prepareUpload(e,t),o=new FormData;o.append("file",e);const s=await this.ndk.httpFetch(this.spec.api_url,{method:t,headers:r,body:o});if(200!==s.status)throw new Error(`Failed to upload file to ${n}`);const i=await s.json();if("success"!==i.status)throw new Error(i.message);return i}validateHttpFetch(){if(!this.ndk)throw new Error("NDK is required to fetch NIP96 spec");if(!this.ndk.httpFetch)throw new Error("NDK must have an httpFetch method to fetch NIP96 spec")}async fetchSpec(){this.validateHttpFetch();const e=await this.ndk.httpFetch(this.url);if(200!==e.status)throw new Error(`Failed to fetch NIP96 spec from ${this.url}`);const t=await e.json();if(!t)throw new Error(`Failed to parse NIP96 spec from ${this.url}`);this.spec=t,this.nip98Required=this.spec.plans.free.is_nip98_required}async generateNip98Header(e,t,n){const r=new NDKEvent(this.ndk,{kind:27235,tags:[["u",e],["method",t]]});if(["POST","PUT","PATCH"].includes(t)){const e=await this.calculateSha256(n);r.tags.push(["payload",e])}await r.sign();return`Nostr ${btoa(JSON.stringify(r.rawEvent()))}`}async calculateSha256(e){const t=await e.arrayBuffer(),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map((e=>e.toString(16).padStart(2,"0"))).join("")}},DEFAULT_OUTBOX_RELAYS=["wss://purplepag.es","wss://relay.snort.social"],DEFAULT_BLACKLISTED_RELAYS=["wss://brb.io"],NDK=class extends lib$1.EventEmitter{explicitRelayUrls;pool;outboxPool;_signer;_activeUser;cacheAdapter;debug;devWriteRelaySet;outboxTracker;mutedIds;clientName;clientNip89;relayAuthDefaultPolicy;httpFetch;autoConnectUserRelays=!0;autoFetchUserMutelist=!0;constructor(e={}){super(),this.debug=e.debug||debug3("ndk"),this.explicitRelayUrls=e.explicitRelayUrls||[],this.pool=new NDKPool(e.explicitRelayUrls||[],e.blacklistRelayUrls,this),this.debug(`Starting with explicit relays: ${JSON.stringify(this.explicitRelayUrls)}`),this.pool.on("relay:auth",(async(e,t)=>{this.relayAuthDefaultPolicy&&await this.relayAuthDefaultPolicy(e,t)})),this.autoConnectUserRelays=e.autoConnectUserRelays??!0,this.autoFetchUserMutelist=e.autoFetchUserMutelist??!0,this.clientName=e.clientName,this.clientNip89=e.clientNip89,this.relayAuthDefaultPolicy=e.relayAuthDefaultPolicy,e.enableOutboxModel&&(this.outboxPool=new NDKPool(e.outboxRelayUrls||DEFAULT_OUTBOX_RELAYS,e.blacklistRelayUrls||DEFAULT_BLACKLISTED_RELAYS,this,this.debug.extend("outbox-pool")),this.outboxTracker=new OutboxTracker(this)),this.signer=e.signer,this.cacheAdapter=e.cacheAdapter,this.mutedIds=e.mutedIds||new Map,e.devWriteRelayUrls&&(this.devWriteRelaySet=NDKRelaySet.fromRelayUrls(e.devWriteRelayUrls,this));try{this.httpFetch=fetch}catch{}}addExplicitRelay(e,t,n=!0){let r;return r="string"==typeof e?new NDKRelay(e,t):e,this.pool.addRelay(r,n),this.explicitRelayUrls.push(r.url),r}toJSON(){return{relayCount:this.pool.relays.size}.toString()}get activeUser(){return this._activeUser}set activeUser(e){const t=this._activeUser?.pubkey!==e?.pubkey;if(this._activeUser=e,e&&t){const t=async e=>{const t=await e.relayList();if(t){this.debug("Connecting to user relays",{npub:e.npub,relays:t.relays});for(const e of t.relays){let t=this.pool.relays.get(e);t||(t=new NDKRelay(e),this.pool.addRelay(t))}}else this.debug("No relay list found for user",{npub:e.npub})},n=async e=>{const t=await this.fetchEvents([{kinds:[1e4],authors:[e.pubkey]},{kinds:[3e4],authors:[e.pubkey],"#d":["mute"],limit:1}]);if(t)for(const e of t){const t=lists_default.from(e);for(const e of t.items)this.mutedIds.set(e[1],e[0])}else this.debug("No mute list found for user",{npub:e.npub})},r=[];this.autoConnectUserRelays&&r.push(t),this.autoFetchUserMutelist&&r.push(n);const o=async e=>{for(const t of r)await t(e)},s=this.outboxPool||this.pool;s.connectedRelays.length>0?o(e):(this.debug("Waiting for connection to main relays"),s.once("relay:ready",(t=>{this.debug("New relay ready",t?.url),o(e)})))}else e||(this.mutedIds=new Map)}get signer(){return this._signer}set signer(e){this._signer=e,this.emit("signer:ready",e),e?.user().then((e=>{e.ndk=this,this.activeUser=e}))}async connect(e){if(this._signer&&this.autoConnectUserRelays&&(this.debug("Attempting to connect to user relays specified by signer"),this._signer.relays)){(await this._signer.relays()).forEach((e=>this.pool.addRelay(e)))}const t=[this.pool.connect(e)];return this.outboxPool&&t.push(this.outboxPool.connect(e)),this.debug("Connecting to relays",{timeoutMs:e}),Promise.allSettled(t).then((()=>{}))}getUser(e){const t=new NDKUser(e);return t.ndk=this,t}async getUserFromNip05(e,t=!1){return NDKUser.fromNip05(e,this,t)}subscribe(e,t,n,r=!0){const o=new NDKSubscription(this,e,t,n);if(n)for(const e of n.relays)this.pool.useTemporaryRelay(e);if(this.outboxPool&&o.hasAuthorsFilter()){const e=o.filters.filter((e=>e.authors&&e.authors?.length>0)).map((e=>e.authors)).flat();this.outboxTracker?.trackUsers(e)}return r&&o.start(),o}async publish(e,t,n){return this.debug("Deprecated: Use `event.publish()` instead"),e.publish(t,n)}async fetchEvent(e,t,n){let r,o;if(n instanceof NDKRelay?o=new NDKRelaySet(new Set([n]),this):n instanceof NDKRelaySet&&(o=n),!n&&"string"==typeof e&&!isNip33AValue(e)){const t=relaysFromBech32(e);t.length>0&&(o=new NDKRelaySet(new Set(t),this),o=correctRelaySet(o,this.pool))}if(r="string"==typeof e?filterFromId(e):e,!r)throw new Error(`Invalid filter: ${JSON.stringify(e)}`);return new Promise((e=>{const n=this.subscribe(r,{...t||{},closeOnEose:!0},o,!1);n.on("event",(t=>{t.ndk=this,e(t)})),n.on("eose",(()=>{e(null)})),n.start()}))}async fetchEvents(e,t,n){return new Promise((r=>{const o=new Map,s=this.subscribe(e,{...t||{},closeOnEose:!0},n,!1),i=e=>{const t=e.deduplicationKey(),n=o.get(t);n&&(e=dedup(n,e)),e.ndk=this,o.set(t,e)};s.on("event",i),s.on("event:dup",i),s.on("eose",(()=>{r(new Set(o.values()))})),s.start()}))}assertSigner(){if(!this.signer)throw this.emit("signerRequired"),new Error("Signer required")}getNip96(e){return new Nip96(e,this)}};const LOCAL_STORE_KEY="__nostrlogin_nip46",LOGGED_IN_ACCOUNTS="__nostrlogin_accounts",RECENT_ACCOUNTS="__nostrlogin_recent",OUTBOX_RELAYS$1=["wss://purplepag.es","wss://relay.nos.social","wss://user.kindpag.es","wss://relay.damus.io","wss://nos.lol"],DEFAULT_SIGNUP_RELAYS=["wss://relay.damus.io/","wss://nos.lol/","wss://relay.primal.net/"],localStorageSetItem=(e,t)=>{localStorage.setItem(e,t)},localStorageGetItem=e=>{const t=window.localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch{}return null},localStorageRemoveItem=e=>{localStorage.removeItem(e)},fetchProfile=async(e,t)=>{const n=new NDKUser({pubkey:e.pubkey});return n.ndk=t,await n.fetchProfile()},prepareSignupRelays=e=>{const t=(e||"").split(",").map((e=>e.trim())).filter((e=>e.startsWith("ws")));return t.length||t.push(...DEFAULT_SIGNUP_RELAYS),t},createProfile=async(e,t,n,r,o)=>{const s={name:e.name},i=new NDKEvent(t,{kind:0,created_at:Math.floor(Date.now()/1e3),pubkey:e.pubkey,content:JSON.stringify(s),tags:[]});window.location.hostname&&i.tags.push(["client",window.location.hostname]);const a=new NDKEvent(t,{kind:10002,created_at:Math.floor(Date.now()/1e3),pubkey:e.pubkey,content:"",tags:[]}),l=prepareSignupRelays(r);for(const e of l)a.tags.push(["r",e]);await i.sign(n),console.log("signed profile",i),await a.sign(n),console.log("signed relays",a);const c=o&&o.length?o:OUTBOX_RELAYS$1;await i.publish(NDKRelaySet.fromRelayUrls(c,t)),console.log("published profile",i),await a.publish(NDKRelaySet.fromRelayUrls(c,t)),console.log("published relays",a)},bunkerUrlToInfo=(e,t="")=>{const n=new URL(e);return{pubkey:"",signerPubkey:n.hostname||n.pathname.split("//")[1],sk:t||generatePrivateKey(),relays:n.searchParams.getAll("relay"),token:n.searchParams.get("secret")||"",authMethod:"connect"}},isBunkerUrl=e=>e.startsWith("bunker://"),getBunkerUrl=async(e,t)=>{if(!e)return"";if(isBunkerUrl(e))return e;if(e.includes("@")){const[n,r]=e.toLocaleLowerCase().split("@"),o=t.devOverrideBunkerOrigin||`https://${r}`,s=`${o}/.well-known/nostr.json?name=_`,i=`${o}/.well-known/nostr.json?name=${n}`,a=await fetch(s),l=await a.json(),c=l.names._,d=l.nip46[c],h=await fetch(i),u=(await h.json()).names[n];if(!d||0===d.length)throw new Error("Bunker relay not provided");return`bunker://${u}?${d.map((e=>`relay=${encodeURIComponent(e)}`)).join("&")}`}throw new Error("Invalid user name or bunker url")},checkNip05=async e=>{let t=!1,n="",r="";return await(async()=>{if(!e||!e.includes("@"))return;const[o,s]=e.toLocaleLowerCase().split("@");if(!o)return;if(!new RegExp(/^[\w-.]+@([\w-]+\.)+[\w-]{2,8}$/g).test(e))return void(n="Invalid name");if(!s)return void(n="Select service");const i=`https://${s}/.well-known/nostr.json?name=${o.toLowerCase()}`;try{const e=await fetch(i),t=await e.json();if(t.names[o])return void(r=t.names[o])}catch{}t=!0})(),{available:t,taken:""!=r,error:n,pubkey:r}},upgradeInfo=e=>{"typeAuthMethod"in e&&delete e.typeAuthMethod,e.authMethod||("extension"in e&&e.extension?e.authMethod="extension":"readOnly"in e&&e.readOnly?e.authMethod="readOnly":e.authMethod="connect"),e.nip05&&isBunkerUrl(e.nip05)&&(e.bunkerUrl=e.nip05,e.nip05=""),"connect"!==e.authMethod||e.signerPubkey||(e.signerPubkey=e.pubkey)},localStorageAddAccount=e=>{localStorageSetItem(LOCAL_STORE_KEY,JSON.stringify(e));const t=localStorageGetItem(LOGGED_IN_ACCOUNTS)||[],n=localStorageGetItem(RECENT_ACCOUNTS)||[];t.forEach((e=>upgradeInfo(e))),n.forEach((e=>upgradeInfo(e)));const r=t,o=t.findIndex((t=>t.pubkey===e.pubkey&&t.authMethod===e.authMethod));-1!==o?r[o]=e:r.push(e);const s=n.filter((t=>t.pubkey!==e.pubkey||t.authMethod!==e.authMethod));localStorageSetItem(RECENT_ACCOUNTS,JSON.stringify(s)),localStorageSetItem(LOGGED_IN_ACCOUNTS,JSON.stringify(r))},localStorageRemoveCurrentAccount=()=>{const e=localStorageGetItem(LOCAL_STORE_KEY);if(!e)return;upgradeInfo(e);const t={...e};delete t.sk,delete t.otpData;const n=localStorageGetItem(LOGGED_IN_ACCOUNTS)||[],r=localStorageGetItem(RECENT_ACCOUNTS)||[];n.forEach((e=>upgradeInfo(e))),r.forEach((e=>upgradeInfo(e)));const o=r;if("connect"===t.authMethod&&t.bunkerUrl&&t.bunkerUrl.includes("secret="))console.log("nostr login bunker conn with a secret not saved to recent");else if("local"===t.authMethod)console.log("nostr login temporary local keys not save to recent");else{const e=r.findIndex((e=>e.pubkey===t.pubkey&&e.authMethod===t.authMethod));-1!==e?o[e]=t:o.push(t)}const s=n.filter((t=>t.pubkey!==e.pubkey||t.authMethod!==e.authMethod));localStorageSetItem(RECENT_ACCOUNTS,JSON.stringify(o)),localStorageSetItem(LOGGED_IN_ACCOUNTS,JSON.stringify(s)),localStorageRemoveItem(LOCAL_STORE_KEY)},localStorageRemoveRecent=e=>{const t=localStorageGetItem(RECENT_ACCOUNTS)||[];t.forEach((e=>upgradeInfo(e)));const n=t.filter((t=>t.pubkey!==e.pubkey||t.authMethod!==e.authMethod));localStorageSetItem(RECENT_ACCOUNTS,JSON.stringify(n))},localStorageGetRecents=()=>{const e=localStorageGetItem(RECENT_ACCOUNTS)||[];return e.forEach((e=>upgradeInfo(e))),e},localStorageGetAccounts=()=>{const e=localStorageGetItem(LOGGED_IN_ACCOUNTS)||[];return e.forEach((e=>upgradeInfo(e))),e},localStorageGetCurrent=()=>{const e=localStorageGetItem(LOCAL_STORE_KEY);return e&&upgradeInfo(e),e},getDarkMode=e=>{const t=localStorage.getItem("nl-dark-mode");return t?Boolean(JSON.parse(t)):void 0!==e.darkMode?e.darkMode:!(!window.matchMedia||!window.matchMedia("(prefers-color-scheme: dark)").matches)},getIcon=async()=>document.location.origin+"/favicon.ico";class NostrRpc extends NDKNostrRpc{_ndk;_signer;requests=new Set;sub;_useNip44=!1;constructor(e,t){super(e,t,e.debug.extend("nip46:signer:rpc")),this._ndk=e,this._signer=t}async subscribe(e){return e.kinds=e.kinds?.filter((e=>24133===e)),this.sub=await super.subscribe(e),this.sub}stop(){this.sub&&(this.sub.stop(),this.sub=void 0)}setUseNip44(e){this._useNip44=e}isNip04(e){const t=e.length;return!(t<28)&&("?"===e[t-28]&&"i"===e[t-27]&&"v"===e[t-26]&&"="===e[t-25])}async parseEvent(e){const t=this._ndk.getUser({pubkey:e.pubkey});t.ndk=this._ndk;const n=this.isNip04(e.content)?this._signer.decrypt:this._signer.decryptNip44,r=await n.call(this._signer,t,e.content),o=JSON.parse(r),{id:s,method:i,params:a,result:l,error:c}=o;return i?{id:s,pubkey:e.pubkey,method:i,params:a,event:e}:{id:s,result:l,error:c,event:e}}async parseNostrConnectReply(e,t){const n=new NDKEvent(this._ndk,e),r=await this.parseEvent(n);if(console.log("nostr connect parsedEvent",r),r.method)throw new Error("Bad nostr connect reply");{const e=r;if(e.result!==t)throw new Error(e.error);return n.pubkey}}async listen(e){const t=this._signer.pubkey;console.log("nostr-login listening for conn to",t);const n=await this.subscribe({kinds:[24133],"#p":[t]});return new Promise(((t,r)=>{n.on("event",(async n=>{try{const o=await this.parseEvent(n);if(!o.method){const s=o;if("auth_url"===s.result)return;"ack"===s.result||s.result===e?t(n.pubkey):r(s.error)}}catch(e){console.log("error parsing event",e,n.rawEvent())}this.stop()}))}))}async connect(e,t,n){return new Promise(((r,o)=>{const s=[e,t||"",n||""];this.sendRequest(e,"connect",s,24133,(e=>{"ack"===e.result?r():o(e.error)}))}))}getId(){return Math.random().toString(36).substring(7)}async sendRequest(e,t,n=[],r=24133,o){const s=this.getId();this.setResponseHandler(s,o);const i=await this.createRequestEvent(s,e,t,n,r);console.log("sendRequest",{event:i,method:t,remotePubkey:e,params:n}),await i.publish()}setResponseHandler(e,t){let n=!1;const r=Date.now();return new Promise((()=>{const o=s=>{"auth_url"===s.result?(this.once(`response-${e}`,o),n||(n=!0,this.emit("authUrl",s.error))):t&&this.requests.has(e)&&(this.requests.delete(e),console.log("nostr-login processed nip46 request in",Date.now()-r,"ms"),t(s))};this.once(`response-${e}`,o)}))}async createRequestEvent(e,t,n,r=[],o=24133){this.requests.add(e);const s=await this._signer.user(),i=this._ndk.getUser({pubkey:t}),a={id:e,method:n,params:r},l=new NDKEvent(this._ndk,{kind:o,content:JSON.stringify(a),tags:[["p",t]],pubkey:s.pubkey}),c=this._useNip44&&"create_account"!==n?this._signer.encryptNip44:this._signer.encrypt;return l.content=await c.call(this._signer,i,l.content),await l.sign(this._signer),l}}class IframeNostrRpc extends NostrRpc{peerOrigin;iframePort;iframeRequests=new Map;constructor(e,t,n){super(e,t),this._ndk=e,this.peerOrigin=n}async subscribe(e){return this.peerOrigin?new NDKSubscription(this._ndk,{},{closeOnEose:!0,cacheUsage:NDKSubscriptionCacheUsage.ONLY_CACHE}):super.subscribe(e)}setWorkerIframePort(e){if(!this.peerOrigin)throw new Error("Unexpected iframe port");this.iframePort=e,setInterval((()=>{console.log("iframe-nip46 ping"),this.iframePort.postMessage("ping")}),5e3),e.onmessage=async e=>{if(console.log("iframe-nip46 got response",e.data),"string"==typeof e.data&&e.data.startsWith("errorNoKey")){const t=e.data.split(":")[1],{id:n="",pubkey:r=""}=this.iframeRequests.get(t)||{};n&&r&&this.requests.has(n)&&this.emit(`iframeRestart-${r}`)}else try{const t=e.data;if(!validateEvent(t))throw new Error("Invalid event from iframe");if(!verifySignature(t))throw new Error("Invalid event signature from iframe");const n=new NDKEvent(this._ndk,t),r=await this.parseEvent(n);r.method||(console.log("parsed response",r),this.emit(`response-${r.id}`,r))}catch(t){console.log("error parsing event",t,e.data)}}}async sendRequest(e,t,n=[],r=24133,o){const s=this.getId(),i=await this.createRequestEvent(s,e,t,n,r);this.setResponseHandler(s,o),this.iframePort?(this.iframeRequests.set(i.id,{id:s,pubkey:e}),console.log("iframe-nip46 sending request to",this.peerOrigin,i.rawEvent()),this.iframePort.postMessage(i.rawEvent())):await i.publish()}}class ReadyListener{origin;messages;promise;constructor(e,t){this.origin=t,this.messages=e,this.promise=new Promise((e=>{console.log(new Date,"started listener for",this.messages);const n=async r=>{const o=new URL(t).hostname,s=new URL(r.origin).hostname;(s===o||s.endsWith("."+o))&&Array.isArray(r.data)&&r.data.length&&this.messages.includes(r.data[0])&&(console.log(new Date,"got ready message from",r.origin,r.data),window.removeEventListener("message",n),e(r.data))};window.addEventListener("message",n)}))}async wait(){console.log(new Date,"waiting for",this.messages);const e=await this.promise;return console.log(new Date,"finished waiting for",this.messages,e),e}}class Nip46Signer extends NDKNip46Signer{_userPubkey="";_rpc;constructor(e,t,n,r){super(e,n,t),this._rpc=new IframeNostrRpc(e,t,r),this._rpc.setUseNip44(!0),this._rpc.on("authUrl",(e=>{this.emit("authUrl",e)})),this.rpc=this._rpc}get userPubkey(){return this._userPubkey}async setSignerPubkey(e,t=!1){console.log("setSignerPubkey",e),this.remotePubkey=e,this._rpc.on(`iframeRestart-${e}`,(()=>{this.emit("iframeRestart")})),await this.initUserPubkey(t?e:"")}async initUserPubkey(e){if(this._userPubkey)throw new Error("Already called initUserPubkey");this._userPubkey=e||await new Promise(((e,t)=>{if(!this.remotePubkey)throw new Error("Signer pubkey not set");console.log("get_public_key",this.remotePubkey),this._rpc.sendRequest(this.remotePubkey,"get_public_key",[],24133,(t=>{e(t.result)}))}))}async listen(e){const t=await this.rpc.listen(e);await this.setSignerPubkey(t)}async connect(e,t){if(!this.remotePubkey)throw new Error("No signer pubkey");await this._rpc.connect(this.remotePubkey,e,t),await this.setSignerPubkey(this.remotePubkey)}async setListenReply(e,t){const n=await this._rpc.parseNostrConnectReply(e,t);await this.setSignerPubkey(n,!0)}async createAccount2({bunkerPubkey:e,name:t,domain:n,perms:r=""}){const o=[t,n,"",r],s=await new Promise((t=>{this.rpc.sendRequest(e,"create_account",o,void 0,t)}));if(console.log("create_account pubkey",s),"error"===s.result)throw new Error(s.error);return s.result}}class BannerManager extends lib$1.EventEmitter{banner=null;iframeReady;params;constructor(e){super(),this.params=e}onAuthUrl(e,t){this.banner&&(this.banner.notify=e?{mode:t?"iframeAuthUrl":"authUrl",url:e}:{mode:""})}onIframeRestart(e){this.banner&&(this.iframeReady=new ReadyListener(["rebinderDone","rebinderError"],new URL(e).origin),this.banner.notify={mode:"rebind",url:e})}onUserInfo(e){this.banner&&(this.banner.userInfo=e)}onCallTimeout(){this.banner&&(this.banner.notify={mode:"timeout"})}onCallStart(){this.banner&&(this.banner.isLoading=!0)}async onCallEnd(){this.banner&&(this.iframeReady&&(await this.iframeReady.wait(),this.iframeReady=void 0),this.banner.isLoading=!1,this.banner.notify={mode:""})}onUpdateAccounts(e){this.banner&&(this.banner.accounts=e)}onDarkMode(e){this.banner&&(this.banner.darkMode=e)}launchAuthBanner(e){this.banner=document.createElement("nl-banner"),this.banner.setAttribute("dark-mode",String(getDarkMode(e))),e.theme&&this.banner.setAttribute("theme",e.theme),e.noBanner&&this.banner.setAttribute("hidden-mode","true"),this.banner.addEventListener("handleLoginBanner",(e=>{this.emit("launch",e.detail)})),this.banner.addEventListener("handleConfirmLogout",(()=>{this.emit("onConfirmLogout")})),this.banner.addEventListener("handleLogoutBanner",(async()=>{this.emit("logout")})),this.banner.addEventListener("handleImportModal",(e=>{this.emit("import")})),this.banner.addEventListener("handleNotifyConfirmBanner",(e=>{this.emit("onAuthUrlClick",e.detail)})),this.banner.addEventListener("handleNotifyConfirmBannerIframe",(e=>{this.emit("onIframeAuthUrlClick",e.detail)})),this.banner.addEventListener("handleSwitchAccount",(e=>{this.emit("onSwitchAccount",e.detail)})),this.banner.addEventListener("handleOpenWelcomeModal",(()=>{this.emit("launch"),this.banner&&(this.banner.isOpen=!1)})),document.body.appendChild(this.banner)}}function extract(e,t,n){return hash$1(e),hmac$1(e,toBytes$1(n),toBytes$1(t))}const HKDF_COUNTER=new Uint8Array([0]),EMPTY_BUFFER=new Uint8Array;function expand(e,t,n,r=32){if(hash$1(e),number$1(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/e.outputLen);void 0===n&&(n=EMPTY_BUFFER);const s=new Uint8Array(o*e.outputLen),i=hmac$1.create(e,t),a=i._cloneInto(),l=new Uint8Array(i.outputLen);for(let t=0;t<o;t++)HKDF_COUNTER[0]=t+1,a.update(0===t?EMPTY_BUFFER:l).update(n).update(HKDF_COUNTER).digestInto(l),s.set(l,e.outputLen*t),i._cloneInto(a);return i.destroy(),a.destroy(),l.fill(0),HKDF_COUNTER.fill(0),s.slice(0,r)}const decoder=new TextDecoder,u={minPlaintextSize:1,maxPlaintextSize:65535,utf8Encode:utf8ToBytes$1,utf8Decode:e=>decoder.decode(e),getConversationKey(e,t){const n=secp256k1.getSharedSecret(e,"02"+t).subarray(1,33);return extract(sha256,n,"nip44-v2")},getMessageKeys(e,t){const n=expand(sha256,e,t,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}},calcPaddedLen(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("expected positive integer");if(e<=32)return 32;const t=1<<Math.floor(Math.log2(e-1))+1,n=t<=256?32:t/8;return n*(Math.floor((e-1)/n)+1)},writeU16BE(e){if(!Number.isSafeInteger(e)||e<u.minPlaintextSize||e>u.maxPlaintextSize)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e,!1),t},pad(e){const t=u.utf8Encode(e),n=t.length;return concatBytes(u.writeU16BE(n),t,new Uint8Array(u.calcPaddedLen(n)-n))},unpad(e){const t=new DataView(e.buffer).getUint16(0),n=e.subarray(2,2+t);if(t<u.minPlaintextSize||t>u.maxPlaintextSize||n.length!==t||e.length!==2+u.calcPaddedLen(t))throw new Error("invalid padding");return u.utf8Decode(n)},hmacAad(e,t,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const r=concatBytes(n,t);return hmac$1(sha256,e,r)},decodePayload(e){if("string"!=typeof e)throw new Error("payload must be a valid string");const t=e.length;if(t<132||t>87472)throw new Error("invalid payload length: "+t);if("#"===e[0])throw new Error("unknown encryption version");let n;try{n=base64.decode(e)}catch(e){throw new Error("invalid base64: "+e.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const o=n[0];if(2!==o)throw new Error("unknown encryption version "+o);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}};function encryptNip44(e,t,n=randomBytes(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:s}=u.getMessageKeys(t,n),i=u.pad(e),a=chacha20(r,o,i),l=u.hmacAad(s,a,n);return base64.encode(concatBytes(new Uint8Array([2]),n,a,l))}function decryptNip44(e,t){const{nonce:n,ciphertext:r,mac:o}=u.decodePayload(e),{chacha_key:s,chacha_nonce:i,hmac_key:a}=u.getMessageKeys(t,n);if(!equalBytes(u.hmacAad(a,r,n),o))throw new Error("invalid MAC");const l=chacha20(s,i,r);return u.unpad(l)}class Nip44{cache=new Map;createKey(e,t){return u.getConversationKey(e,t)}getKey(e,t,n){const r=getPublicKey(e)+t;let o=this.cache.get(r);if(o)return o;const s=this.createKey(e,t);return this.cache.set(r,s),s}encrypt(e,t,n){return encryptNip44(n,this.getKey(e,t))}decrypt(e,t,n){return decryptNip44(n,this.getKey(e,t))}}class PrivateKeySigner extends NDKPrivateKeySigner{nip44=new Nip44;_pubkey;constructor(e){super(e),this._pubkey=getPublicKey(e)}get pubkey(){return this._pubkey}encryptNip44(e,t){return Promise.resolve(this.nip44.encrypt(this.privateKey,e.pubkey,t))}decryptNip44(e,t){return Promise.resolve(this.nip44.decrypt(this.privateKey,e.pubkey,t))}}const OUTBOX_RELAYS=["wss://user.kindpag.es","wss://purplepag.es","wss://relay.nos.social"],DEFAULT_NOSTRCONNECT_RELAYS=["wss://relay.nsec.app/","wss://ephemeral.snowflare.cc/"],CONNECT_TIMEOUT=5e3,NOSTRCONNECT_APPS=[{name:"Nsec.app",domain:"nsec.app",canImport:!0,img:"https://nsec.app/assets/favicon.ico",link:"https://use.nsec.app/<nostrconnect>",relays:DEFAULT_NOSTRCONNECT_RELAYS},{name:"Amber",img:"https://raw.githubusercontent.com/greenart7c3/Amber/refs/heads/master/assets/android-icon.svg",link:"<nostrconnect>",relays:DEFAULT_NOSTRCONNECT_RELAYS},{name:"Other key stores",img:"",link:"<nostrconnect>",relays:DEFAULT_NOSTRCONNECT_RELAYS}];class AuthNostrService extends lib$1.EventEmitter{ndk;profileNdk;signer=null;localSigner=null;params;signerPromise;signerErrCallback;readyPromise;readyCallback;nip44Codec=new Nip44;nostrConnectKey="";nostrConnectSecret="";iframe;starterReady;nip04;nip44;constructor(e){super(),this.params=e,this.ndk=new NDK({enableOutboxModel:!1}),this.profileNdk=new NDK({enableOutboxModel:!0,explicitRelayUrls:OUTBOX_RELAYS}),this.profileNdk.connect(CONNECT_TIMEOUT),this.nip04={encrypt:this.encrypt04.bind(this),decrypt:this.decrypt04.bind(this)},this.nip44={encrypt:this.encrypt44.bind(this),decrypt:this.decrypt44.bind(this)}}isIframe(){return!!this.iframe}async waitReady(){if(this.signerPromise)try{await this.signerPromise}catch{}if(this.readyPromise)try{await this.readyPromise}catch{}}cancelNostrConnect(){this.releaseSigner(),this.resetAuth()}async nostrConnect(e,{domain:t="",link:n="",iframeUrl:r="",importConnect:o=!1}={}){e=e&&e.length>0?e:DEFAULT_NOSTRCONNECT_RELAYS;const s={authMethod:"connect",pubkey:"",signerPubkey:"",sk:this.nostrConnectKey,domain:t,relays:e,iframeUrl:r};if(console.log("nostrconnect info",s,n),n&&!r&&window.open(n,"_blank","width=400,height=700"),await this.initSigner(s,{listen:!0}),!s.pubkey||!s.signerPubkey)throw new Error("Bad remote pubkey");return s.bunkerUrl=`bunker://${s.signerPubkey}?${e.map(((e,t)=>`${0!==t?"&":""}relay=${e}`))}`,o||this.onAuth("login",s),s}async createNostrConnect(e){this.nostrConnectKey=generatePrivateKey(),this.nostrConnectSecret=Math.random().toString(36).substring(7);const t=getPublicKey(this.nostrConnectKey),n=encodeURIComponent(document.location.host),r=encodeURIComponent(document.location.origin);return`nostrconnect://${t}?image=${encodeURIComponent(await getIcon())}&url=${r}&name=${n}&perms=${encodeURIComponent(this.params.optionsModal.perms||"")}&secret=${this.nostrConnectSecret}${(e||[]).length>0?(e||[]).map(((e,t)=>`&relay=${e}`)):""}`}async getNostrConnectServices(){const e=await this.createNostrConnect(),t=NOSTRCONNECT_APPS.map((e=>({...e})));for(const n of t){let t=[...DEFAULT_NOSTRCONNECT_RELAYS];if(n.link.startsWith("https://")){const e=n.domain||new URL(n.link).hostname;try{const r=await(await fetch(`https://${e}/.well-known/nostr.json`)).json(),o=r.names._,s=r.nip46?.[o];Array.isArray(s)&&s.length>0&&(t=s),n.iframeUrl=r.nip46?.iframe_url||""}catch(e){console.log("Bad app info",e,n)}}const r=e+t.map((e=>e.replace(/['"]/g,""))).map((e=>`&relay=${encodeURIComponent(e)}`)).join("");n.iframeUrl?n.link=r:n.link=n.link.replace("<nostrconnect>",r)}return[e,t]}async localSignup(e,t){const n=!t,r={pubkey:getPublicKey(t=t||generatePrivateKey()),sk:t,name:e,authMethod:"local"};console.log(`localSignup name: ${e}`),await this.setLocal(r,n)}async setLocal(e,t){this.releaseSigner(),this.localSigner=new PrivateKeySigner(e.sk),t&&await createProfile(e,this.profileNdk,this.localSigner,this.params.optionsModal.signupRelays,this.params.optionsModal.outboxRelays),this.onAuth(t?"signup":"login",e)}prepareImportUrl(e){if("otp"===this.params.userInfo?.authMethod)return e+"&import=true";if(!this.localSigner||"local"!==this.params.userInfo?.authMethod)throw new Error("Most be local keys");return e+"#import="+nip19_exports.nsecEncode(this.localSigner.privateKey)}async importAndConnect(e){const{relays:t,domain:n,link:r,iframeUrl:o}=e;if(!n)throw new Error("Domain required");const s=await this.nostrConnect(t,{domain:n,link:r,importConnect:!0,iframeUrl:o});await this.logout(!0),this.localSigner=null,this.onAuth("login",s)}setReadOnly(e){const t={pubkey:e,authMethod:"readOnly"};this.onAuth("login",t)}setExtension(e){const t={pubkey:e,authMethod:"extension"};this.onAuth("login",t)}setOTP(e,t){const n={pubkey:e,authMethod:"otp",otpData:t};this.onAuth("login",n)}async setConnect(e){this.releaseSigner(),await this.startAuth(),await this.initSigner(e),this.onAuth("login",e),await this.endAuth()}async createAccount(e){const[t,n]=e.split("@"),r=await getBunkerUrl(`_@${n}`,this.params.optionsModal);console.log("create account bunker's url",r);const o=bunkerUrlToInfo(r);if(!o.signerPubkey)throw new Error("Bad bunker url");const s=Boolean(this.params.userInfo);await this.initSigner(o,{eventToAddAccount:s});return{bunkerUrl:`bunker://${await this.signer.createAccount2({bunkerPubkey:o.signerPubkey,name:t,domain:n,perms:this.params.optionsModal.perms})}?`+(o.relays??[]).map((e=>`relay=${encodeURIComponent(e)}`)).join("&"),sk:o.sk}}releaseSigner(){this.signer=null,this.signerErrCallback?.("cancelled"),this.localSigner=null;for(const e of this.ndk.pool.relays.keys())this.ndk.pool.removeRelay(e)}async logout(e=!1){e||this.releaseSigner(),localStorageRemoveCurrentAccount(),this.onAuth("logout"),this.emit("updateAccounts")}setUserInfo(e){this.params.userInfo=e,this.emit("onUserInfo",e),e&&(localStorageAddAccount(e),this.emit("updateAccounts"))}exportKeys(){return this.params.userInfo?"local"!==this.params.userInfo.authMethod?"":nip19_exports.nsecEncode(this.params.userInfo.sk):""}onAuth(e,t=null){if("logout"!==e&&!t)throw new Error("No user info in onAuth");if(t&&this.params.userInfo&&(t.pubkey!==this.params.userInfo.pubkey||t.authMethod!==this.params.userInfo.authMethod)){const e=new CustomEvent("nlAuth",{detail:{type:"logout"}});console.log("nostr-login auth",e.detail),document.dispatchEvent(e)}this.setUserInfo(t),t&&fetchProfile(t,this.profileNdk).then((e=>{if(this.params.userInfo!==t)return;const n={...this.params.userInfo,picture:e?.image||e?.picture,name:e?.name||e?.displayName||e?.nip05||nip19_exports.npubEncode(t.pubkey)};this.setUserInfo(n)}));try{const n=t?nip19_exports.npubEncode(t.pubkey):"",r={type:e};"logout"===e?(this.iframe&&this.iframe.remove(),this.iframe=void 0):(r.pubkey=t.pubkey,r.name=t.name,t.sk&&(r.localNsec=nip19_exports.nsecEncode(t.sk)),t.relays&&(r.relays=t.relays),t.otpData&&(r.otpData=t.otpData),r.method=t.authMethod||"connect");const o=new CustomEvent("nlAuth",{detail:r});console.log("nostr-login auth",r),document.dispatchEvent(o),this.params.optionsModal.onAuth&&this.params.optionsModal.onAuth(n,r)}catch(e){console.log("onAuth error",e)}}async createIframe(e){if(!e)return;const t=new URL(e);let n;const r="__nostr-login-worker-iframe-"+t.hostname.replaceAll(".","-");n=document.querySelector(`#${r}`),console.log("iframe",r,n),n||(n=document.createElement("iframe"),n.setAttribute("width","0"),n.setAttribute("height","0"),n.setAttribute("border","0"),n.style.display="none",n.id=r,document.body.append(n)),n.setAttribute("src",e);const o=new ReadyListener(["workerReady","workerError"],t.origin);await new Promise((e=>{n.addEventListener("load",e)}));const s=await o.wait();return console.log("nostr-login iframe ready",e,s),{iframe:n,port:s[1]}}async sendNeedAuth(){const[e]=await this.getNostrConnectServices(),t=new CustomEvent("nlNeedAuth",{detail:{nostrconnect:e}});console.log("nostr-login need auth",e),document.dispatchEvent(t)}isAuthing(){return!!this.readyCallback}async startAuth(){if(console.log("startAuth"),this.readyCallback)throw new Error("Already started");this.readyPromise=new Promise((e=>this.readyCallback=e))}async endAuth(){if(console.log("endAuth",this.params.userInfo),this.params.userInfo&&this.params.userInfo.iframeUrl){const{iframe:e,port:t}=await this.createIframe(this.params.userInfo.iframeUrl)||{};if(this.iframe=e,!this.iframe||!t)return;this.signer.rpc.setWorkerIframePort(t)}this.readyCallback(),this.readyCallback=void 0}resetAuth(){this.readyCallback&&this.readyCallback(),this.readyCallback=void 0}async listen(e){if(!e.iframeUrl)return this.signer.listen(this.nostrConnectSecret);const t=await this.starterReady.wait();if("starterError"===t[0])throw new Error(t[1]);return this.signer.setListenReply(t[1],this.nostrConnectSecret)}async connect(e,t){return this.signer.connect(e.token,t)}async initSigner(e,{listen:t=!1,connect:n=!1,eventToAddAccount:r=!1}={}){if(this.signerPromise)try{await this.signerPromise}catch{}console.log("initSigner info",e);const o=e.iframeUrl?new URL(e.iframeUrl).origin:void 0;return o&&(this.starterReady=new ReadyListener(["starterDone","starterError"],o)),this.emit("onIframeUrl",e.iframeUrl),this.signerPromise=new Promise((async(s,i)=>{this.signerErrCallback=i;try{if(e.relays&&!e.iframeUrl)for(const t of e.relays)this.ndk.addExplicitRelay(t,void 0);await this.ndk.connect(CONNECT_TIMEOUT);const i=new PrivateKeySigner(e.sk);this.signer=new Nip46Signer(this.ndk,i,e.signerPubkey,o),this.signer.on("iframeRestart",(async()=>{const t=e.iframeUrl+(e.iframeUrl.includes("?")?"&":"?")+"pubkey="+e.pubkey+"&rebind="+i.pubkey;this.emit("iframeRestart",{pubkey:e.pubkey,iframeUrl:t})})),this.signer.on("authUrl",(t=>{console.log("nostr login auth url",t),this.emit("onAuthUrl",{url:t,iframeUrl:e.iframeUrl,eventToAddAccount:r})})),t?await this.listen(e):n?await this.connect(e,this.params.optionsModal.perms):await this.signer.initUserPubkey(e.pubkey),e.pubkey=this.signer.userPubkey,e.signerPubkey=this.signer.remotePubkey,s()}catch(e){console.log("initSigner failure",e),this.signer=null,i(e)}})),this.signerPromise}async authNip46(e,{name:t,bunkerUrl:n,sk:r="",domain:o="",iframeUrl:s=""}){try{const i=bunkerUrlToInfo(n,r);if(isBunkerUrl(t)?i.bunkerUrl=t:(i.nip05=t,i.domain=t.split("@")[1]),o&&(i.domain=o),s&&(i.iframeUrl=s),!i.signerPubkey||!i.sk||!i.relays||0===i.relays.length)throw new Error(`Bad bunker url ${n}`);const a=Boolean(this.params.userInfo);console.log("authNip46",e,i),await this.initSigner(i,{connect:!0,eventToAddAccount:a}),this.onAuth(e,i)}catch(e){throw console.log("nostr login auth failed",e),e}}async signEvent(e){const t=(async()=>(this.localSigner?(e.pubkey=getPublicKey(this.localSigner.privateKey),e.id=getEventHash(e),e.sig=await this.localSigner.sign(e)):(e.pubkey=this.signer?.remotePubkey,e.id=getEventHash(e),e.sig=await(this.signer?.sign(e))),e))(),n=new Promise(((e,t)=>{setTimeout((()=>t(new Error("Sign timeout"))),2e4)})),r=await Promise.race([t,n]);return console.log("signed",{event:r}),r}async codec_call(e,t,n){return new Promise(((r,o)=>{this.signer.rpc.sendRequest(this.signer.remotePubkey,e,[t,n],24133,(e=>{e.error?o(e.error):r(e.result)}))}))}async encrypt04(e,t){return this.localSigner?this.localSigner.encrypt(new NDKUser({pubkey:e}),t):this.signer.encrypt(new NDKUser({pubkey:e}),t)}async decrypt04(e,t){return this.localSigner?this.localSigner.decrypt(new NDKUser({pubkey:e}),t):this.codec_call("nip04_decrypt",e,t)}async encrypt44(e,t){return this.localSigner?this.nip44Codec.encrypt(this.localSigner.privateKey,e,t):this.codec_call("nip44_encrypt",e,t)}async decrypt44(e,t){return this.localSigner?this.nip44Codec.decrypt(this.localSigner.privateKey,e,t):this.codec_call("nip44_decrypt",e,t)}}class ModalManager extends lib$1.EventEmitter{modal=null;params;extensionService;authNostrService;launcherPromise;accounts=[];recents=[];opt;constructor(e,t,n){super(),this.params=e,this.extensionService=n,this.authNostrService=t}async waitReady(){if(this.launcherPromise){try{await this.launcherPromise}catch{}this.launcherPromise=void 0}}async launch(e){console.log("nostr-login launch",e),this.launcherPromise&&await this.waitReady(),this.authNostrService.isAuthing()&&this.authNostrService.resetAuth(),this.opt=e;const t=document.createElement("dialog");if(this.modal=document.createElement("nl-auth"),this.modal.accounts=this.accounts,this.modal.recents=this.recents,this.modal.setAttribute("dark-mode",String(getDarkMode(e))),e.theme&&this.modal.setAttribute("theme",e.theme),e.startScreen&&this.modal.setAttribute("start-screen",e.startScreen),e.bunkers)this.modal.setAttribute("bunkers",e.bunkers);else{let e="nsec.app,highlighter.com";this.modal.setAttribute("bunkers",e)}void 0!==e.methods&&(this.modal.authMethods=e.methods),void 0!==e.localSignup&&(this.modal.localSignup=e.localSignup),void 0!==e.signupNstart&&(this.modal.signupNjump=e.signupNstart),e.title&&(this.modal.welcomeTitle=e.title),e.description&&(this.modal.welcomeDescription=e.description),this.modal.hasExtension=this.extensionService.hasExtension(),this.modal.hasOTP=!!e.otpRequestUrl&&!!e.otpReplyUrl,this.modal.isLoadingExtension=!1,this.modal.isLoading=!1,[this.modal.connectionString,this.modal.connectionStringServices]=await this.authNostrService.getNostrConnectServices(),t.appendChild(this.modal),document.body.appendChild(t);let n="";return this.launcherPromise=new Promise(((e,r)=>{t.addEventListener("close",(()=>{r(new Error("Closed")),this.authNostrService.resetAuth(),this.modal&&(document.body.removeChild(this.modal.parentNode),this.modal=null)}));const o=async e=>{this.modal&&(this.modal.isLoading=!1),await this.authNostrService.endAuth(),t.close(),this.modal=null,e()},s=async(t,n)=>{this.modal&&(this.modal.isLoading=!0);try{n&&!n.start||await this.authNostrService.startAuth(),await t(),n&&!n.end||await o(e)}catch(e){console.log("error",e),this.modal&&(this.modal.isLoading=!1,this.modal.authUrl="",this.modal.iframeUrl="","cancelled"!==e&&(this.modal.error=e.toString()))}},i=async(e,t)=>{await s((async()=>{const n=await getBunkerUrl(e,this.params.optionsModal);await this.authNostrService.authNip46("login",{name:e,bunkerUrl:n,domain:t})}))},a=async e=>{await s((async()=>{const{bunkerUrl:t,sk:n}=await this.authNostrService.createAccount(e);await this.authNostrService.authNip46("signup",{name:e,bunkerUrl:t,sk:n})}))},l=async()=>{try{await navigator.clipboard.writeText(this.authNostrService.exportKeys()),localStorageSetItem("backupKey","true")}catch(e){console.error("Failed to copy to clipboard: ",e)}},c=async e=>{await s((async()=>{const{iframeUrl:t}=e;e.link=this.authNostrService.prepareImportUrl(e.link),this.modal&&t&&(this.modal.authUrl=e.link,this.modal.iframeUrl=t,this.modal.isLoading=!1,console.log("nostrconnect authUrl",this.modal.authUrl,this.modal.iframeUrl)),await this.authNostrService.importAndConnect(e)}))},d=async e=>{await s((async()=>{const{relays:t,domain:n,link:r,iframeUrl:o}=e||{};console.log("nostrConnect",e,t,n,r,o),this.modal&&(o&&(this.modal.authUrl=r,this.modal.iframeUrl=o,this.modal.isLoading=!1,console.log("nostrconnect authUrl",this.modal.authUrl,this.modal.iframeUrl)),e||(this.modal.isLoading=!1)),await this.authNostrService.nostrConnect(t,{domain:n,link:r,iframeUrl:o})}))},h=async e=>{await s((async()=>{if(!e)throw new Error("Please enter some nickname");await this.authNostrService.localSignup(e)}))},u=async()=>{await s((async()=>{const e=new URL(window.location.href),t=e.hostname.toLocaleLowerCase().replace(/^www\./i,"").charAt(0).toUpperCase()+e.hostname.slice(1),n=prepareSignupRelays(this.params.optionsModal.signupRelays);return this.modal.njumpIframe=`\n <html><body>\n <script src='https://start.njump.me/modal.js'><\/script>\n <script>\n new NstartModal({\n baseUrl: 'https://start.njump.me',\n // Required parameters\n an: '${t}',\n // Optional parameters\n s: [${this.opt.followNpubs?`'${this.opt.followNpubs}'`:""}],\n afb: false, // forceBunker\n asb: false, // skipBunker\n aan: false, // avoidNsec\n aac: true, // avoidNcryptsec\n ahc: true, // hide close button\n arr: ${JSON.stringify(n)}, //readRelays\n awr: ${JSON.stringify(n)}, //writeRelays\n // Callbacks\n onComplete: (result) => {\n console.log('Login token:', result.nostrLogin);\n window.parent.location.href='${window.location.href}#nostr-login='+result.nostrLogin;\n },\n onCancel: () => {\n window.parent.location.href='${window.location.href}#nostr-login=null';\n },\n }).open();\n <\/script>\n </body></html>\n `.replaceAll("&","&amp;"),new Promise(((e,t)=>{const n=async n=>{if(console.log("nsecOrBunker",n),n.startsWith("nsec1")){let t;try{t=nip19_exports.decode(n)}catch(e){throw new Error("Bad nsec value")}if("nsec"!==t.type)throw new Error("Bad bech32 type");await this.authNostrService.localSignup("",t.data),e()}else n.startsWith("bunker:")?(await this.authNostrService.authNip46("login",{name:"",bunkerUrl:n}),e()):t("null"===n?"Cancelled":"Unknown return value")};window.addEventListener("hashchange",(async()=>{if(window.location.hash.startsWith("#nostr-login=")){const e=window.location.hash.split("#nostr-login=")[1],t=new URL(window.location.toString());t.hash="",window.history.replaceState({},"",t.toString()),n(e)}}))}))}))};if(!this.modal)throw new Error("WTH?");this.modal.addEventListener("handleContinue",(()=>{this.modal&&(this.modal.isLoading=!0,this.emit("onAuthUrlClick",this.modal.authUrl))})),this.modal.addEventListener("nlLogin",(e=>{i(e.detail)})),this.modal.addEventListener("nlSignup",(e=>{a(e.detail)})),this.modal.addEventListener("nlLocalSignup",(e=>{h(e.detail)})),this.modal.addEventListener("nlSignupNjump",(e=>{u()})),this.modal.addEventListener("nlImportAccount",(e=>{c(e.detail)})),this.modal.addEventListener("nlExportKeys",(e=>{l()})),this.modal.addEventListener("handleLogoutBanner",(()=>{this.emit("onLogoutBanner")})),this.modal.addEventListener("nlNostrConnect",(e=>{d(e.detail)})),this.modal.addEventListener("nlNostrConnectDefault",(()=>{this.authNostrService.isAuthing()||d()})),this.modal.addEventListener("nlNostrConnectDefaultCancel",(()=>{console.log("nlNostrConnectDefaultCancel"),this.authNostrService.cancelNostrConnect()})),this.modal.addEventListener("nlSwitchAccount",(e=>{const n=e.detail;this.emit("onSwitchAccount",n),setTimeout((()=>t.close()),300)})),this.modal.addEventListener("nlLoginRecentAccount",(async e=>{const n=e.detail;if("readOnly"===n.authMethod)this.authNostrService.setReadOnly(n.pubkey),t.close();else if("otp"===n.authMethod)try{this.modal.dispatchEvent(new CustomEvent("nlLoginOTPUser",{detail:n.nip05||n.pubkey}))}catch(e){console.error(e)}else if("extension"===n.authMethod)await this.extensionService.trySetExtensionForPubkey(n.pubkey),t.close();else{const e=n.bunkerUrl||n.nip05;if(!e)throw new Error("Bad connect info");i(e,n.domain)}})),this.modal.addEventListener("nlRemoveRecent",(e=>{localStorageRemoveRecent(e.detail),this.emit("updateAccounts")}));const p=async e=>{let t="";if(e.includes("@")){const{error:n,pubkey:r}=await checkNip05(e);if(!r)throw new Error(n);t=r}else if(e.startsWith("npub")){const{type:n,data:r}=nip19_exports.decode(e);if("npub"!==n)throw new Error("Bad npub");t=r}else 64===e.trim().length&&(t=e.trim(),nip19_exports.npubEncode(t));return t};this.modal.addEventListener("nlLoginReadOnly",(async e=>{await s((async()=>{const t=e.detail,n=await p(t);this.authNostrService.setReadOnly(n)}))})),this.modal.addEventListener("nlLoginExtension",(async()=>{if(!this.extensionService.hasExtension())throw new Error("No extension");await s((async()=>{this.modal&&(this.modal.isLoadingExtension=!0,await this.extensionService.setExtension(),this.modal.isLoadingExtension=!1)}))})),this.modal.addEventListener("nlLoginOTPUser",(async e=>{await s((async()=>{if(!this.modal)return;const t=e.detail,r=await p(t),o=this.opt.otpRequestUrl+(this.opt.otpRequestUrl.includes("?")?"&":"?")+"pubkey="+r,s=await fetch(o);if(200!==s.status)throw console.warn("nostr-login: bad otp reply",s),new Error("Failed to send DM");this.modal.isOTP=!0,n=r,this.modal.isLoading=!1}),{start:!0})})),this.modal.addEventListener("nlLoginOTPCode",(async e=>{await s((async()=>{if(!this.modal)return;const t=e.detail,r=this.opt.otpReplyUrl+(this.opt.otpRequestUrl.includes("?")?"&":"?")+"pubkey="+n+"&code="+t,o=await fetch(r);if(200!==o.status)throw console.warn("nostr-login: bad otp reply",o),new Error("Invalid code");const s=await o.text();this.authNostrService.setOTP(n,s),this.modal.isOTP=!1}),{end:!0})})),this.modal.addEventListener("nlCheckSignup",(async e=>{const{available:t,taken:n,error:r}=await checkNip05(e.detail);this.modal&&(this.modal.error=String(r),!r&&n&&(this.modal.error="Already taken"),this.modal.signupNameIsAvailable=t)})),this.modal.addEventListener("nlCheckLogin",(async e=>{const{available:t,taken:n,error:r}=await checkNip05(e.detail);this.modal&&(this.modal.error=String(r),t&&(this.modal.error="Name not found"),this.modal.loginIsGood=n)}));const f=()=>{this.modal&&(this.modal.isLoading=!1),t.close(),r(new Error("Cancelled"))};this.modal.addEventListener("stopFetchHandler",f),this.modal.addEventListener("nlCloseModal",f),this.modal.addEventListener("nlChangeDarkMode",(e=>{setDarkMode(e.detail),document.dispatchEvent(new CustomEvent("nlDarkMode",{detail:e.detail}))})),this.on("onIframeAuthUrlCallEnd",(()=>{t.close(),this.modal=null,e()})),t.showModal()})),this.launcherPromise}async showIframeUrl(e){await this.waitReady(),this.launch({startScreen:"iframe"}).catch((()=>console.log("closed auth iframe"))),this.modal.authUrl=e}connectModals(e){const t=async e=>{await this.launch(e)},n=document.getElementsByTagName("nl-button");for(let r=0;r<n.length;r++){const o=n[r].getAttribute("nl-theme"),s=n[r].getAttribute("start-screen"),i={...e};switch(o&&(i.theme=o),s){case"login":case"login-bunker-url":case"login-read-only":case"signup":case"switch-account":case"welcome":i.startScreen=s}n[r].addEventListener("click",(function(){t(i)}))}}onAuthUrl(e){this.modal&&(this.modal.authUrl=e,this.modal.isLoading=!1)}onIframeUrl(e){this.modal&&(console.log("modal iframe url",e),this.modal.iframeUrl=e)}onCallEnd(){this.modal&&this.modal.authUrl&&this.params.userInfo?.iframeUrl&&this.emit("onIframeAuthUrlCallEnd")}onUpdateAccounts(e,t){this.accounts=e,this.recents=t,this.modal&&(this.modal.accounts=e,this.modal.recents=t)}onDarkMode(e){this.modal&&(this.modal.darkMode=e)}}class Nostr{#e;nip04;nip44;constructor(e){this.#e=e,this.getPublicKey=this.getPublicKey.bind(this),this.signEvent=this.signEvent.bind(this),this.getRelays=this.getRelays.bind(this),this.nip04={encrypt:this.encrypt04.bind(this),decrypt:this.decrypt04.bind(this)},this.nip44={encrypt:this.encrypt44.bind(this),decrypt:this.decrypt44.bind(this)}}async ensureAuth(){if(await this.#e.waitReady(),!this.#e.getUserInfo()&&(await this.#e.launch(),!this.#e.getUserInfo()))throw new Error("Rejected by user")}async getPublicKey(){await this.ensureAuth();const e=this.#e.getUserInfo();if(e)return e.pubkey;throw new Error("No user")}async signEvent(e){return await this.ensureAuth(),this.#e.wait((async()=>await this.#e.getSigner().signEvent(e)))}async getRelays(){return{}}async encrypt04(e,t){return await this.ensureAuth(),this.#e.wait((async()=>await this.#e.getSigner().nip04.encrypt(e,t)))}async decrypt04(e,t){return await this.ensureAuth(),this.#e.wait((async()=>await this.#e.getSigner().nip04.decrypt(e,t)))}async encrypt44(e,t){return await this.ensureAuth(),this.#e.wait((async()=>await this.#e.getSigner().nip44.encrypt(e,t)))}async decrypt44(e,t){return await this.ensureAuth(),this.#e.wait((async()=>await this.#e.getSigner().nip44.decrypt(e,t)))}}class NostrExtensionService extends lib$1.EventEmitter{params;nostrExtension;constructor(e){super(),this.params=e}startCheckingExtension(e){if(this.checkExtension(e))return;const t=setInterval((()=>{this.checkExtension(e)&&clearTimeout(t)}),100)}checkExtension(e){return!(this.nostrExtension||!window.nostr||window.nostr===e)&&(this.initExtension(e),!0)}async initExtension(e,t){this.nostrExtension=window.nostr,window.nostr=e,"extension"===this.params.userInfo?.authMethod&&await this.trySetExtensionForPubkey(this.params.userInfo.pubkey),t||setTimeout((()=>{window.nostr!==e&&this.nostrExtension!==window.nostr&&this.initExtension(e,!0)}),300)}async setExtensionReadPubkey(e){window.nostr=this.nostrExtension;const t=await window.nostr.getPublicKey();e&&e!==t?this.emit("extensionLogout"):this.emit("extensionLogin",t)}async trySetExtensionForPubkey(e){if(this.nostrExtension)return this.setExtensionReadPubkey(e)}async setExtension(){return this.setExtensionReadPubkey()}unsetExtension(e){window.nostr===this.nostrExtension&&(window.nostr=e)}getExtension(){return this.nostrExtension}hasExtension(){return!!this.nostrExtension}}class NostrParams{userInfo;optionsModal;constructor(){this.userInfo=null,this.optionsModal={theme:"default",startScreen:"welcome",devOverrideBunkerOrigin:""}}}class Popup{popup=null;constructor(){}openPopup(e){if((!this.popup||this.popup.closed)&&(this.popup=window.open(e,"_blank","width=400,height=700"),console.log("popup",this.popup),!this.popup))throw new Error("Popup blocked. Try again, please!")}closePopup(){try{this.popup?.close(),this.popup=null}catch{}}}const CALL_TIMEOUT=5e3;class ProcessManager extends lib$1.EventEmitter{callCount=0;callTimer;constructor(){super()}onAuthUrl(){Boolean(this.callTimer)&&clearTimeout(this.callTimer)}onIframeUrl(){Boolean(this.callTimer)&&clearTimeout(this.callTimer)}async wait(e){let t,n;this.callTimer||(this.callTimer=setTimeout((()=>this.emit("onCallTimeout")),CALL_TIMEOUT)),this.callCount||this.emit("onCallStart"),this.callCount++;try{n=await e()}catch(e){t=e}if(this.callCount--,this.emit("onCallEnd"),this.callTimer&&clearTimeout(this.callTimer),this.callTimer=void 0,t)throw t;return n}}class NostrLoginInitializer{extensionService;params;authNostrService;nostr;processManager;popupManager;bannerManager;modalManager;customLaunchCallback;constructor(){this.params=new NostrParams,this.processManager=new ProcessManager,this.popupManager=new Popup,this.bannerManager=new BannerManager(this.params),this.authNostrService=new AuthNostrService(this.params),this.extensionService=new NostrExtensionService(this.params),this.modalManager=new ModalManager(this.params,this.authNostrService,this.extensionService);const e={waitReady:async()=>{await this.authNostrService.waitReady(),await this.modalManager.waitReady()},getUserInfo:()=>this.params.userInfo,getSigner:()=>{if("readOnly"===this.params.userInfo.authMethod)throw new Error("Read only");return"extension"===this.params.userInfo.authMethod?this.extensionService.getExtension():this.authNostrService},launch:()=>this.launch(),wait:e=>this.processManager.wait(e)};this.nostr=new Nostr(e),this.processManager.on("onCallTimeout",(()=>{this.bannerManager.onCallTimeout()})),this.processManager.on("onCallEnd",(()=>{this.bannerManager.onCallEnd(),this.modalManager.onCallEnd()})),this.processManager.on("onCallStart",(()=>{this.bannerManager.onCallStart()})),this.authNostrService.on("onIframeUrl",(e=>{this.modalManager.onIframeUrl(e)})),this.authNostrService.on("iframeRestart",(({iframeUrl:e})=>{this.processManager.onIframeUrl(),this.bannerManager.onIframeRestart(e)})),this.authNostrService.on("onAuthUrl",(({url:e,iframeUrl:t,eventToAddAccount:n})=>{this.processManager.onAuthUrl(),n?this.modalManager.onAuthUrl(e):this.params.userInfo?this.bannerManager.onAuthUrl(e,t):this.modalManager.onAuthUrl(e)})),this.authNostrService.on("updateAccounts",(()=>{this.updateAccounts()})),this.authNostrService.on("onUserInfo",(e=>{this.bannerManager.onUserInfo(e)})),this.modalManager.on("onAuthUrlClick",(e=>{this.openPopup(e)})),this.bannerManager.on("onIframeAuthUrlClick",(e=>{this.modalManager.showIframeUrl(e)})),this.modalManager.on("onSwitchAccount",(async e=>{this.switchAccount(e)})),this.modalManager.on("onLogoutBanner",(async e=>{logout()})),this.bannerManager.on("onConfirmLogout",(async()=>{this.launch("confirm-logout")})),this.modalManager.on("updateAccounts",(()=>{this.updateAccounts()})),this.bannerManager.on("logout",(()=>{logout()})),this.bannerManager.on("onAuthUrlClick",(e=>{this.openPopup(e)})),this.bannerManager.on("onSwitchAccount",(async e=>{this.switchAccount(e)})),this.bannerManager.on("import",(()=>{this.launch("import")})),this.extensionService.on("extensionLogin",(e=>{this.authNostrService.setExtension(e)})),this.extensionService.on("extensionLogout",(()=>{logout()})),this.bannerManager.on("launch",(e=>{this.launch(e)}))}openPopup(e){this.popupManager.openPopup(e)}async switchAccount(e,t=!1){if(console.log("nostr login switch to info",e),this.extensionService.unsetExtension(this.nostr),"readOnly"===e.authMethod)this.authNostrService.setReadOnly(e.pubkey);else if("otp"===e.authMethod)this.authNostrService.setOTP(e.pubkey,e.otpData||"");else if("local"===e.authMethod&&e.sk)this.authNostrService.setLocal(e,t);else if("extension"===e.authMethod)await this.extensionService.trySetExtensionForPubkey(e.pubkey);else{if(!("connect"===e.authMethod&&e.sk&&e.relays&&e.relays[0]))throw new Error("Bad auth info");this.authNostrService.setConnect(e)}}updateAccounts(){const e=localStorageGetAccounts(),t=localStorageGetRecents();this.bannerManager.onUpdateAccounts(e),this.modalManager.onUpdateAccounts(e,t)}async launchCustomNostrConnect(){try{this.authNostrService.isAuthing()&&this.authNostrService.cancelNostrConnect();const e=new Promise((e=>this.customLaunchCallback=e));await this.authNostrService.startAuth(),await this.authNostrService.sendNeedAuth();try{await this.authNostrService.nostrConnect(),await this.authNostrService.endAuth()}catch(t){"cancelled"===t&&await e}}catch(e){console.error("launchCustomNostrConnect",e)}}fulfillCustomLaunchPromise(){if(this.customLaunchCallback){const e=this.customLaunchCallback;this.customLaunchCallback=void 0,e()}}launch=async e=>{if(!e&&this.params.optionsModal.customNostrConnect)return this.launchCustomNostrConnect();const t=localStorageGetRecents(),n=localStorageGetAccounts(),r={...this.params.optionsModal};e&&"default"!==e?r.startScreen=e:(Boolean(t?.length)||Boolean(n?.length))&&(r.startScreen="switch-account"),this.customLaunchCallback&&this.authNostrService.cancelNostrConnect();try{await this.modalManager.launch(r),this.fulfillCustomLaunchPromise()}catch(e){console.log("nostr-login failed",e)}};init=async e=>{this.extensionService.startCheckingExtension(this.nostr),window.nostr=this.nostr,this.modalManager.connectModals(e),this.bannerManager.launchAuthBanner(e),e&&(this.params.optionsModal={...e});try{const e=localStorageGetCurrent();if(e){if(!e.pubkey)throw new Error("Bad stored info");await this.switchAccount(e)}}catch(e){console.log("nostr login init error",e),await logout()}this.updateAccounts()};logout=async()=>{this.extensionService.unsetExtension(this.nostr),await this.authNostrService.logout()};setDarkMode=e=>{localStorageSetItem("nl-dark-mode",`${e}`),this.bannerManager.onDarkMode(e),this.modalManager.onDarkMode(e)};setAuth=async e=>{if(!e.type)throw new Error("Invalid auth event");if("login"!==e.type&&"logout"!==e.type&&"signup"!==e.type)throw new Error("Invalid auth event");if(e.method&&"connect"!==e.method&&"extension"!==e.method&&"local"!==e.method&&"otp"!==e.method&&"readOnly"!==e.method)throw new Error("Invalid auth event");if("logout"===e.type)return this.logout();if(!e.method||!e.pubkey)throw new Error("Invalid pubkey");const t={authMethod:e.method,pubkey:e.pubkey,relays:e.relays,sk:e.localNsec,otpData:e.otpData,name:e.name};await this.switchAccount(t,"signup"===e.type)};cancelNeedAuth=()=>{console.log("cancelNeedAuth"),this.fulfillCustomLaunchPromise(),this.authNostrService.cancelNostrConnect()}}const initializer=new NostrLoginInitializer,{init:init,launch:launch,logout:logout,setDarkMode:setDarkMode,setAuth:setAuth,cancelNeedAuth:cancelNeedAuth}=initializer;document.addEventListener("nlLogout",logout),document.addEventListener("nlLaunch",(e=>{launch(e.detail||"")})),document.addEventListener("nlNeedAuthCancel",(()=>{cancelNeedAuth()})),document.addEventListener("nlDarkMode",(e=>{setDarkMode(!!e.detail)})),document.addEventListener("nlSetAuth",(e=>{setAuth(e.detail)}));export{NostrLoginInitializer,cancelNeedAuth,init,launch,logout,setAuth,setDarkMode};
47
18
  //# sourceMappingURL=index.esm.js.map