@konemono/nostr-login 1.13.7 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +26 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/modules/AuthNostrService.d.ts +1 -4
- package/dist/modules/Nip46.d.ts +43 -6
- package/dist/modules/Signer.d.ts +2 -0
- package/dist/unpkg.js +26 -16
- package/package.json +4 -3
- package/src/modules/AuthNostrService.ts +24 -27
- package/src/modules/Nip46.ts +170 -75
- package/src/modules/Signer.ts +7 -2
- package/src/utils/index.ts +28 -55
- package/src/utils/nip44.ts +2 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
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,o)=>e.addEventListener(t,n,o),rel:(e,t,n,o)=>e.removeEventListener(t,n,o),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,o;return null!=(o=null==(n=null==(t=e.head)?void 0:t.querySelector('meta[name="csp-nonce"]'))?void 0:n.getAttribute("content"))?o: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 o=null,r=null,s=null,i=!1,a=!1;const c=[],l=t=>{for(let n=0;n<t.length;n++)o=t[n],Array.isArray(o)?l(o):null!=o&&"boolean"!=typeof o&&((i="function"!=typeof e&&!isComplexType(o))&&(o=String(o)),i&&a?c[c.length-1].$text$+=o:c.push(i?newVNode(null,o):o),a=i)};if(l(n),t){t.key&&(r=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 d=newVNode(e,null);return d.$attrs$=t,c.length>0&&(d.$children$=c),d.$key$=r,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$1=(e,t,n)=>{const o=getElement(e);return{emit:e=>emitEvent(o,t,{bubbles:!0,composed:!0,cancelable:!0,detail:e})}},emitEvent=(e,t,n)=>{const o=plt.ce(t,n);return e.dispatchEvent(o),o},rootAppliedStyles=new WeakMap,registerStyle=(e,t,n)=>{let o=styles.get(e);supportsConstructableStylesheets&&n?(o=o||new CSSStyleSheet,"string"==typeof o?o=t:o.replaceSync(t)):o=t,styles.set(e,o)},addStyle=(e,t,n)=>{var o;const r=getScopeId(t,n),s=styles.get(r);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(r)){{n=doc.createElement("style"),n.innerHTML=s;const r=null!=(o=plt.$nonce$)?o:queryNonceMetaTagContent(doc);null!=r&&n.setAttribute("nonce",r);(!(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(r)}}else e.adoptedStyleSheets.includes(s)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,s]);return r},attachStyles=e=>{const t=e.$cmpMeta$,n=e.$hostElement$,o=t.$flags$,r=createTime("attachStyles",t.$tagName$),s=addStyle(n.shadowRoot?n.shadowRoot:n.getRootNode(),t,e.$modeName$);10&o&&2&o&&(n["s-sc"]=s,n.classList.add(s+"-h"),2&o&&n.classList.add(s+"-s")),r()},getScopeId=(e,t)=>"sc-"+(t&&32&e.$flags$?e.$tagName$+"-"+t:e.$tagName$),setAccessor=(e,t,n,o,r,s)=>{if(n!==o){let i=isMemberInElement(e,t),a=t.toLowerCase();if("class"===t){const t=e.classList,r=parseClassList(n),s=parseClassList(o);t.remove(...r.filter((e=>e&&!s.includes(e)))),t.add(...s.filter((e=>e&&!r.includes(e))))}else if("style"===t){for(const t in n)o&&null!=o[t]||(t.includes("-")?e.style.removeProperty(t):e.style[t]="");for(const t in o)n&&o[t]===n[t]||(t.includes("-")?e.style.setProperty(t,o[t]):e.style[t]=o[t])}else if("key"===t);else if("ref"===t)o&&o(e);else if(e.__lookupSetter__(t)||"o"!==t[0]||"n"!==t[1]){const c=isComplexType(o);if((i||c&&null!==o)&&!r)try{if(e.tagName.includes("-"))e[t]=o;else{const r=null==o?"":o;"list"===t?i=!1:null!=n&&e[t]==r||(e[t]=r)}}catch(e){}let l=!1;a!==(a=a.replace(/^xlink\:?/,""))&&(t=a,l=!0),null==o||!1===o?!1===o&&""!==e.getAttribute(t)||(l?e.removeAttributeNS(XLINK_NS,t):e.removeAttribute(t)):(!i||4&s||r)&&!c&&(o=!0===o?"":o,l?e.setAttributeNS(XLINK_NS,t,o):e.setAttribute(t,o))}else if(t="-"===t[2]?t.slice(3):isMemberInElement(win,a)?a.slice(2):a[2]+t.slice(3),n||o){const r=t.endsWith(CAPTURE_EVENT_SUFFIX);t=t.replace(CAPTURE_EVENT_REGEX,""),n&&plt.rel(e,t,n,r),o&&plt.ael(e,t,o,r)}}},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 o=11===t.$elm$.nodeType&&t.$elm$.host?t.$elm$.host:t.$elm$,r=e&&e.$attrs$||EMPTY_OBJ,s=t.$attrs$||EMPTY_OBJ;for(const e of sortedAttrNames(Object.keys(r)))e in s||setAccessor(o,e,r[e],void 0,n,t.$flags$);for(const e of sortedAttrNames(Object.keys(s)))setAccessor(o,e,r[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,o)=>{var r;const s=t.$children$[n];let i,a,c,l=0;if(useNativeShadowDom||(checkSlotRelocate=!0,"slot"===s.$tag$&&(scopeId&&o.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,o),s.$children$)for(l=0;l<s.$children$.length;++l)a=createElm(e,s,l,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==(r=s.$attrs$)?void 0:r.ref,c=e&&e.$children$&&e.$children$[n],c&&c.$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 o=n[e];o["s-hn"]!==hostTagName&&o["s-ol"]&&(insertBefore(parentReferenceNode(o),o,referenceNode(o)),o["s-ol"].remove(),o["s-ol"]=void 0,o["s-sh"]=void 0,checkSlotRelocate=!0),t&&putBackInOriginalLocation(o,t)}plt.$flags$&=-2},addVnodes=(e,t,n,o,r,s)=>{let i,a=e["s-cr"]&&e["s-cr"].parentNode||e;for(a.shadowRoot&&a.tagName===hostTagName&&(a=a.shadowRoot);r<=s;++r)o[r]&&(i=createElm(null,n,r,e),i&&(o[r].$elm$=i,insertBefore(a,i,referenceNode(t))))},removeVnodes=(e,t,n)=>{for(let o=t;o<=n;++o){const t=e[o];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,o,r=!1)=>{let s,i,a=0,c=0,l=0,d=0,h=t.length-1,u=t[0],f=t[h],p=o.length-1,g=o[0],m=o[p];for(;a<=h&&c<=p;)if(null==u)u=t[++a];else if(null==f)f=t[--h];else if(null==g)g=o[++c];else if(null==m)m=o[--p];else if(isSameVnode(u,g,r))patch(u,g,r),u=t[++a],g=o[++c];else if(isSameVnode(f,m,r))patch(f,m,r),f=t[--h],m=o[--p];else if(isSameVnode(u,m,r))"slot"!==u.$tag$&&"slot"!==m.$tag$||putBackInOriginalLocation(u.$elm$.parentNode,!1),patch(u,m,r),insertBefore(e,u.$elm$,f.$elm$.nextSibling),u=t[++a],m=o[--p];else if(isSameVnode(f,g,r))"slot"!==u.$tag$&&"slot"!==m.$tag$||putBackInOriginalLocation(f.$elm$.parentNode,!1),patch(f,g,r),insertBefore(e,f.$elm$,u.$elm$),f=t[--h],g=o[++c];else{for(l=-1,d=a;d<=h;++d)if(t[d]&&null!==t[d].$key$&&t[d].$key$===g.$key$){l=d;break}l>=0?(i=t[l],i.$tag$!==g.$tag$?s=createElm(t&&t[c],n,l,e):(patch(i,g,r),t[l]=void 0,s=i.$elm$),g=o[++c]):(s=createElm(t&&t[c],n,c,e),g=o[++c]),s&&insertBefore(parentReferenceNode(u.$elm$),s,referenceNode(u.$elm$))}a>h?addVnodes(e,null==o[p+1]?null:o[p+1].$elm$,n,o,c,p):c>p&&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 o=t.$elm$=e.$elm$,r=e.$children$,s=t.$children$,i=t.$tag$,a=t.$text$;let c;null===a?(isSvgMode="svg"===i||"foreignObject"!==i&&isSvgMode,("slot"!==i||useNativeShadowDom)&&updateElement(e,t,isSvgMode),null!==r&&null!==s?updateChildren(o,r,t,s,n):null!==s?(null!==e.$text$&&(o.textContent=""),addVnodes(o,null,t,s,0,s.length-1)):!n&&BUILD.updatable&&null!==r&&removeVnodes(r,0,r.length-1),isSvgMode&&"svg"===i&&(isSvgMode=!1)):(c=o["s-cr"])?c.parentNode.textContent=a:e.$text$!==a&&(o.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 o of t)if(o!==e)if(o["s-hn"]!==e["s-hn"]||""!==n){if(1===o.nodeType&&(n===o.getAttribute("slot")||n===o["s-sn"])||3===o.nodeType&&n===o["s-sn"]){e.hidden=!0;break}}else if(1===o.nodeType||3===o.nodeType&&""!==o.textContent.trim()){e.hidden=!0;break}}updateFallbackSlotVisibility(e)}},relocateNodes=[],markSlotContentForRelocation=e=>{let t,n,o;for(const r of e.childNodes){if(r["s-sr"]&&(t=r["s-cr"])&&t.parentNode){n=t.parentNode.childNodes;const e=r["s-sn"];for(o=n.length-1;o>=0;o--)if(t=n[o],!t["s-cn"]&&!t["s-nr"]&&t["s-hn"]!==r["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"]=r["s-hn"],n.$slotRefNode$=r):(t["s-sh"]=r["s-hn"],relocateNodes.push({$slotRefNode$:r,$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===r.nodeType&&markSlotContentForRelocation(r)}},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 o=null==e?void 0:e.insertBefore(t,n);return updateElementScopeIds(t,e),o},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 o;if(e&&t&&1===e.nodeType){const r=new Set(findScopeIds(t).filter(Boolean));if(r.size&&(null==(o=e.classList)||o.add(...e["s-scs"]=[...r]),e["s-ol"]||n))for(const t of Array.from(e.childNodes))updateElementScopeIds(t,e,!0)}},renderVdom=(e,t,n=!1)=>{var o,r,s,i,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$.map((([e,t])=>u.$attrs$[t]=c[e]))),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$),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"]){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==(o=t["s-ol"])?void 0:o.previousSibling;for(;s;){let o=null!=(r=s["s-nr"])?r:null;if(o&&o["s-sn"]===t["s-sn"]&&e===o.parentNode){for(o=o.nextSibling;o===t||(null==o?void 0:o["s-sr"]);)o=null==o?void 0:o.nextSibling;if(!o||!o["s-nr"]){n=o;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&l.$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$,o=createTime("scheduleUpdate",e.$cmpMeta$.$tagName$),r=n;if(!r)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(r,t?"componentWillLoad":"componentWillUpdate"),s=enqueue(s,(()=>safeCall(r,"componentWillRender"))),o(),enqueue(s,(()=>updateComponent(e,r,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 o=e.$hostElement$,r=createTime("update",e.$cmpMeta$.$tagName$);o["s-rc"],n&&attachStyles(e);const s=createTime("render",e.$cmpMeta$.$tagName$);callRender(e,t,o,n),s(),r(),postUpdateComponent(e)},renderingRef=null,callRender=(e,t,n,o)=>{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,o))}catch(t){consoleError(t,e.$hostElement$)}return renderingRef=null,null},getRenderingRef=()=>renderingRef,postUpdateComponent=e=>{const t=e.$cmpMeta$.$tagName$,n=e.$hostElement$,o=createTime("postUpdate",t),r=n;e.$ancestorComponent$,safeCall(r,"componentDidRender"),64&e.$flags$?(safeCall(r,"componentDidUpdate"),o()):(e.$flags$|=64,safeCall(r,"componentDidLoad"),o())},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,o)=>{const r=getHostRef(e),s=e,i=r.$instanceValues$.get(t),a=r.$flags$,c=s;n=parsePropertyValue(n,o.$members$[t][0]);const l=Number.isNaN(i)&&Number.isNaN(n);if(n!==i&&!l){if(r.$instanceValues$.set(t,n),o.$watchers$&&128&a){const e=o.$watchers$[t];e&&e.map((e=>{try{c[e](n,i,t)}catch(e){consoleError(e,s)}}))}if(2==(18&a)){if(c.componentShouldUpdate&&!1===c.componentShouldUpdate(n,i,t))return;scheduleUpdate(r,!1)}}},proxyComponent=(e,t,n)=>{var o,r;const s=e.prototype;if(t.$members$||t.$watchers$||e.watchers){e.watchers&&!t.$watchers$&&(t.$watchers$=e.watchers);const n=Object.entries(null!=(o=t.$members$)?o:{});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 o=new Map;s.attributeChangedCallback=function(e,n,r){plt.jmp((()=>{var i;const a=o.get(e);if(this.hasOwnProperty(a))r=this[a],delete this[a];else{if(s.hasOwnProperty(a)&&"number"==typeof this[a]&&this[a]==r)return;if(null==a){const o=getHostRef(this),s=null==o?void 0:o.$flags$;if(s&&!(8&s)&&128&s&&r!==n){const o=this,s=null==(i=t.$watchers$)?void 0:i[e];null==s||s.forEach((t=>{null!=o[t]&&o[t].call(o,r,n,e)}))}return}}this[a]=(null!==r||"boolean"!=typeof this[a])&&r}))},e.observedAttributes=Array.from(new Set([...Object.keys(null!=(r=t.$watchers$)?r:{}),...n.filter((([e,t])=>15&t[0])).map((([e,n])=>{var r;const s=n[1]||e;return o.set(s,e),512&n[0]&&(null==(r=t.$attrsToReflect$)||r.push([e,s])),s}))]))}}return e},initializeComponent=async(e,t,n,o)=>{let r;if(!(32&t.$flags$)){t.$flags$|=32,n.$lazyBundleId$;{r=e.constructor;const n=e.localName;customElements.whenDefined(n).then((()=>t.$flags$|=128))}if(r&&r.style){let o;"string"==typeof r.style?o=r.style:"string"!=typeof r.style&&(t.$modeName$=computeMode(e),t.$modeName$&&(o=r.style[t.$modeName$]));const s=getScopeId(n,t.$modeName$);if(!styles.has(s)){const e=createTime("registerStyles",n.$tagName$);registerStyle(s,o,!!(1&n.$flags$)),e()}}}t.$ancestorComponent$;scheduleUpdate(t,!0)},fireConnectedCallback=e=>{},connectedCallback=e=>{if(!(1&plt.$flags$)){const t=getHostRef(e),n=t.$cmpMeta$,o=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)),o()}},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 o=e.prototype.connectedCallback,r=e.prototype.disconnectedCallback;return Object.assign(e.prototype,{__registerHost(){registerHost(this,n)},connectedCallback(){const e=getHostRef(this);addHostEventListeners(this,e,n.$listeners$),connectedCallback(this),o&&o.call(this)},disconnectedCallback(){disconnectedCallback(this),r&&r.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,o)=>{n&&n.map((([n,o,r])=>{const s=getHostListenerTarget(e,n),i=hostListenerProxy(t,r),a=hostListenerOpts(n);plt.ael(s,o,i,a),(t.$rmListeners$=t.$rmListeners$||[]).push((()=>plt.rel(s,o,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.LOGIN_NSEC="login-nsec",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 o=e.get(t);o?o.includes(n)||o.push(n):e.set(t,[n])},debounce=(e,t)=>{let n;return(...o)=>{n&&clearTimeout(n),n=setTimeout((()=>{n=0,e(...o)}),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 o=new Map(Object.entries(null!=n?n:{}));const r={dispose:[],get:[],set:[],reset:[]},s=()=>{var t;o=new Map(Object.entries(null!==(t=unwrap(e))&&void 0!==t?t:{})),r.reset.forEach((e=>e()))},i=e=>(r.get.forEach((t=>t(e))),o.get(e)),a=(e,n)=>{const s=o.get(e);t(n,s,e)&&(o.set(e,n),r.set.forEach((t=>t(e,n,s))))},c="undefined"==typeof Proxy?{}:new Proxy(n,{get:(e,t)=>i(t),ownKeys:e=>Array.from(o.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(e,t)=>o.has(t),set:(e,t,n)=>(a(t,n),!0)}),l=(e,t)=>(r[e].push(t),()=>{removeFromArray(r[e],t)});return{state:c,get:i,set:a,on:l,onChange:(t,n)=>{const o=l("set",((e,o)=>{e===t&&n(o)})),r=l("reset",(()=>n(unwrap(e)[t])));return()=>{o(),r()}},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:()=>{r.dispose.forEach((e=>e())),s()},reset:s,forceUpdate:e=>{const t=o.get(e);r.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},loadCustomRelays=()=>{try{const e=localStorage.getItem("customNip46Relays");if(e){const t=JSON.parse(e);if(Array.isArray(t)&&t.length>0)return t}}catch(e){console.error("Failed to load custom relays from localStorage",e)}return["wss://relay.nsec.app/","wss://ephemeral.snowflare.cc/"]},{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:"",customNip46Relays:loadCustomRelays(),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:""},nlSigninNsec:{nsecValue:""},nlImport:null});onChange("customNip46Relays",(e=>{try{localStorage.setItem("customNip46Relays",JSON.stringify(e))}catch(e){console.error("Failed to save custom relays to localStorage",e)}})),onChange("screen",(()=>{state.error="",state.nlSignin.loginName="",state.nlSignup.signupName="",state.nlSignup.domain="",state.nlSigninNsec.nsecValue=""}));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-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))}.left-0{left:0}.start-0{inset-inline-start:0}.top-0{top:0}.z-\\[80\\]{z-index:80}.z-\\[81\\]{z-index:81}.h-full{height:100%}.max-w-96{max-width:384px}.flex-col{flex-direction:column}.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}.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-base{font-size:16px;line-height:24px}.font-light{font-weight:300}.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}}.pointer-events-none{pointer-events:none}.inset-y-0{bottom:0;top:0}.max-w-72{max-width:288px}.border-\\[3px\\]{border-width:3px}.pe-4{padding-inline-end:16px}.ps-11{padding-inline-start:44px}.ps-4{padding-inline-start:16px}.pt-2{padding-top:8px}.text-2xl{font-size:24px;line-height:32px}.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}.mb-3{margin-bottom:12px}.mb-4{margin-bottom:16px}.ml-2{margin-left:8px}.flex-1{flex:1 1 0%}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(4px*var(--tw-space-y-reverse));margin-top:calc(4px*(1 - var(--tw-space-y-reverse)))}.rounded{border-radius:.25rem}.bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity))}.bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity))}.py-1{padding-bottom:4px;padding-top:4px}.py-1\\.5{padding-bottom:6px;padding-top:6px}.text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity))}.text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity))}.text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity))}.text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.underline{text-decoration-line:underline}.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)}.hover\\:bg-blue-600:hover{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity))}.hover\\:text-blue-700:hover{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity))}.hover\\:text-gray-700:hover{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity))}.hover\\:text-red-700:hover{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity))}.dark\\:border-gray-600:is(.dark *){--tw-border-opacity:1;border-color:rgb(75 85 99/var(--tw-border-opacity))}.dark\\:bg-gray-700:is(.dark *){--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity))}.dark\\:bg-gray-800:is(.dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity))}.dark\\:text-blue-400:is(.dark *){--tw-text-opacity:1;color:rgb(96 165 250/var(--tw-text-opacity))}.dark\\:text-gray-100:is(.dark *){--tw-text-opacity:1;color:rgb(243 244 246/var(--tw-text-opacity))}.dark\\:text-gray-400:is(.dark *){--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.dark\\:text-red-400:is(.dark *){--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity))}.dark\\:hover\\:text-blue-300:hover:is(.dark *){--tw-text-opacity:1;color:rgb(147 197 253/var(--tw-text-opacity))}.dark\\:hover\\:text-gray-300:hover:is(.dark *){--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity))}.dark\\:hover\\:text-red-300:hover:is(.dark *){--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity))}.max-w-52{max-width:208px}.gap-3{gap:12px}.pb-5{padding-bottom:20px}.text-3xl{font-size:30px;line-height:36px}.text-lg{font-size:18px;line-height:28px}.mt-3{margin-top:12px}.mb-0\\.5{margin-bottom:2px}.mb-5{margin-bottom:20px}.ml-auto{margin-left:auto}.mr-auto{margin-right:auto}.w-72{width:288px}.pb-2{padding-bottom:8px}.mb-10{margin-bottom:40px}.mt-10{margin-top:40px}.h-20{height:80px}.w-20{width:80px}.border-\\[4px\\]{border-width:4px}.text-4xl{font-size:36px;line-height:40px}.mt-0{margin-top:0}.max-h-0{max-height:0}.max-h-\\[500px\\]{max-height:500px}.max-w-7{max-width:28px}.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}.cursor-default{cursor:default}.gap-0\\.5{gap:2px}.gap-x-3\\.5{column-gap:14px}.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-400{--tw-border-opacity:1;border-color:rgb(156 163 175/var(--tw-border-opacity))}.p-2{padding:8px}.py-2{padding-bottom:8px;padding-top:8px}.pb-1{padding-bottom:4px}.pb-1\\.5{padding-bottom:6px}.pt-5{padding-top:20px}.decoration-dashed{text-decoration-style:dashed}.opacity-50{opacity:.5}.grayscale{--tw-grayscale:grayscale(100%);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)}.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))}.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))}.ml-auto,.mx-auto{margin-left:auto}.w-60{width:240px}.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}.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))}.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%}.end-0{inset-inline-end:0}.h-\\[20px\\]{height:20px}.w-\\[20px\\]{width:20px}.pe-11{padding-inline-end:44px}.mt-0\\.5{margin-top:2px}.items-start{align-items:flex-start}.border-yellow-400{--tw-border-opacity:1;border-color:rgb(250 204 21/var(--tw-border-opacity))}.bg-yellow-50{--tw-bg-opacity:1;background-color:rgb(254 252 232/var(--tw-bg-opacity))}.dark\\:border-yellow-600:is(.dark *){--tw-border-opacity:1;border-color:rgb(202 138 4/var(--tw-border-opacity))}.dark\\:bg-yellow-900\\/20:is(.dark *){background-color:rgba(113,63,18,.2)}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity))}",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$s(){if("undefined"==typeof customElements)return;["button-base"].forEach((e=>{if("button-base"===e)customElements.get(e)||customElements.define(e,ButtonBase)}))}defineCustomElement$s();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$r(){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$s()}}))}defineCustomElement$r();const nlNip46RelaySettingsCss=baseCss,NlNip46RelaySettingsStyle0=nlNip46RelaySettingsCss,FACTORY_DEFAULT_RELAYS=["wss://relay.nsec.app/","wss://ephemeral.snowflare.cc/"],NlNip46RelaySettings=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlRelaysChanged=createEvent$1(this,"nlRelaysChanged"),this.defaultRelays=[...FACTORY_DEFAULT_RELAYS],this.relays=[],this.newRelay="",this.showSettings=!1}componentWillLoad(){this.relays=[...this.defaultRelays]}addRelay(){const e=this.newRelay.trim();e&&(e.startsWith("wss://")||e.startsWith("ws://"))&&(this.relays.includes(e)||(this.relays=[...this.relays,e],this.newRelay="",this.nlRelaysChanged.emit(this.relays)))}removeRelay(e){this.relays=this.relays.filter(((t,n)=>n!==e)),this.nlRelaysChanged.emit(this.relays)}resetToDefaults(){this.relays=[...FACTORY_DEFAULT_RELAYS],this.nlRelaysChanged.emit(this.relays)}render(){return h("div",{key:"b21c3d9935218ccd1d552b9f635bd2a5577f50c0",class:"nip46-relay-settings mb-4"},h("button",{key:"aa9bd7bb3bd4310b1a02edfc1c010a7907dc79ce",type:"button",class:"text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 underline cursor-pointer",onClick:()=>this.showSettings=!this.showSettings},this.showSettings?"▼":"▶"," Advanced: Relay Settings"),this.showSettings&&h("div",{key:"bfafd2a8bfae6b9829c553f286d5d80f16011b2e",class:"mt-2 p-3 border border-gray-300 dark:border-gray-600 rounded bg-gray-50 dark:bg-gray-800"},h("div",{key:"6bcfc31c24f3eb074e0101cdb319b19806550db9",class:"flex justify-between items-center mb-2"},h("div",{key:"32d87ef74ecfd3f330ce88ab1802878bed40d680",class:"text-xs font-semibold text-gray-700 dark:text-gray-300"},"Nip46 Relays:"),h("button",{key:"26c7843cff229b73d33e86238eadbbdbde33955e",type:"button",class:"text-xs text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 underline cursor-pointer",onClick:()=>this.resetToDefaults()},"Reset to defaults")),h("ul",{key:"d6419de90eb296e91df6e6ede131d41c22d9e0e8",class:"text-xs mb-3 space-y-1"},this.relays.map(((e,t)=>h("li",{class:"flex justify-between items-center py-1 px-2 bg-white dark:bg-gray-700 rounded"},h("span",{class:"truncate text-gray-700 dark:text-gray-300 flex-1"},e),h("button",{type:"button",class:"ml-2 text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 font-bold cursor-pointer",onClick:()=>this.removeRelay(t),title:"Remove relay"},"✕"))))),h("div",{key:"0544da279bb32591f78dff61ecb5372e3a069b06",class:"flex gap-2"},h("input",{key:"eaf3009c8d711dbbf6bc0a3f954e042d5865a669",type:"text",class:"flex-1 text-xs px-2 py-1.5 border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100",placeholder:"wss://relay.example.com",value:this.newRelay,onInput:e=>this.newRelay=e.target.value,onKeyPress:e=>{"Enter"===e.key&&(e.preventDefault(),this.addRelay())}}),h("button",{key:"1223d35e9155b6716715f0685777370e8afa32d1",type:"button",class:"text-xs px-3 py-1.5 bg-blue-500 hover:bg-blue-600 text-white rounded cursor-pointer",onClick:()=>this.addRelay()},"Add"))))}static get style(){return NlNip46RelaySettingsStyle0}},[0,"nl-nip46-relay-settings",{defaultRelays:[16],relays:[32],newRelay:[32],showSettings:[32]}]);function defineCustomElement$q(){if("undefined"==typeof customElements)return;["nl-nip46-relay-settings"].forEach((e=>{if("nl-nip46-relay-settings"===e)customElements.get(e)||customElements.define(e,NlNip46RelaySettings)}))}defineCustomElement$q();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:"7361ac64cb9b8b02f85a97bc8dc01e2c9ab8b01c"},h("div",{key:"6e9a8335ae521f6e9a67ed433cb9ca9501f2e062",class:"p-4 overflow-y-auto"},h("h1",{key:"3ba01b15367e43824fea55967fa949da53bd956c",class:"nl-title font-bold text-center text-3xl"},this.titleWelcome)),h("div",{key:"0a7995f42d602d73f3ad23bff7d8a6995763acbc",class:"p-4"},Boolean(this.connectionStringServices.length)&&h("div",{key:"dd90d4a123c1940aa4cace1291262811d21352a8",class:"max-w-96 mx-auto pt-5"},h("p",{key:"2e122c0d1274fe996f37aadb54e2b1135084b906",class:"nl-description font-medium text-sm pb-1.5"},"Select key store:"),h("ul",{key:"54c38861f6bbb2eb1198ad8a7aeddd38104b33e4",class:"p-2 rounded-lg border border-gray-200 flex flex-col w-full gap-0.5"},this.connectionStringServices.map((e=>{const t="loading"===e.available,n=!1===e.available,o=t||n;return h("li",{class:o?"opacity-50 pointer-events-none":""},h("a",{href:o?void 0:e.link,target:"_blank",onClick:t=>{o?t.preventDefault():this.handleOpenLink(t,e)},class:"flex items-center gap-x-3.5 w-full py-2 px-3 rounded-lg text-sm justify-between "+(o?"cursor-default":"hover:bg-gray-300 cursor-pointer")},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 "+(n?"grayscale":""),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,t&&h("span",{class:"nl-description text-xs ml-2"},"checking..."),n&&h("span",{class:"nl-description text-xs ml-2"},"offline")))))}))))),h("div",{key:"c372f1e8bd0cceb7b9660612eb6158d5ec625d3e",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"0b6c50602854cf06554c92505cfce1ef215e8f7d",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("div",{key:"a67dd79c1f13bdc0636a34e4f0c6c0df80293aa6",class:"max-w-72 mx-auto"},h("nl-nip46-relay-settings",{key:"0f358c327060445e14313331ca5e1ee8175d1493",defaultRelays:state.customNip46Relays,onNlRelaysChanged:e=>{state.customNip46Relays=e.detail}})),h("div",{key:"beccc66491904a50dc44c720fa5e32208e1ff61e",class:"max-w-52 mx-auto pb-5"},(this.allowAuthMethod("connect")||this.allowAuthMethod("readOnly"))&&h("div",{key:"7e670e898fd405c82cb749699a73d087525f4475",class:"flex justify-center"},h("div",{key:"634509b97941ceeda9338cc29d431dcafab17b04",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:"3e14d6c45fb72b1ad47beea455b36001ecb6c394",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:"0ebce63b4caffd049c6e5a110792ca138e2e914b",d:"m6 9 6 6 6-6"})))),h("div",{key:"7d22deba5c378a53056eae0884e0d051504d7c5b",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:"c4bbb92fcbf14048429099e26ab6e886a87e62f6",titleBtn:"User name",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN)},h("svg",{key:"8482dadd22930b1c17b328441a15609d41bc6c8d",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:"ce5b427cba70a646c07ce61ea738765322e6c4ff","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:"2859b956807892b0fcbbd88433733c7a905ad4f1",titleBtn:"Connection string",onClick:()=>this.handleConnectionString()},h("svg",{key:"8e2f155b9c5bfbec2f88a97013111739065c9914",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:"3071eb6d992c31d5fb11a03ec5c3c9dabde9eff1","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:"fa667a1e898b232c1db217d10458c926b559568f","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:"5c66ae1e86bae7a9c3fbc975a92eefae2d4253ec",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN_BUNKER_URL),titleBtn:"Bunker URL"},h("svg",{key:"04d85bf0ac2f66b44a9ddd95815dd20d81935bad",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:"763ef4a4f3f6f7807187e4d6aef8eecb7b858a44","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$p(){if("undefined"==typeof customElements)return;["nl-connect","button-base","nl-nip46-relay-settings"].forEach((e=>{switch(e){case"nl-connect":customElements.get(e)||customElements.define(e,NlConnect);break;case"button-base":customElements.get(e)||defineCustomElement$s();break;case"nl-nip46-relay-settings":customElements.get(e)||defineCustomElement$q()}}))}defineCustomElement$p();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:"954ed56c0b6069cbcaae788121d82733c772e5d6",class:"p-4 overflow-y-auto"},h("div",{key:"4f62e37fc1d19d9da953eef1d5e7df66256c2e50",class:"mt-3 flex flex-col gap-2"},this.iframeUrl&&h("iframe",{key:"26aee24e31d903e2207b6664b29904fd5b94deac",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$o(){if("undefined"==typeof customElements)return;["nl-iframe"].forEach((e=>{if("nl-iframe"===e)customElements.get(e)||customElements.define(e,NlConfirmLogout)}))}defineCustomElement$o();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$n(){if("undefined"==typeof customElements)return;["nl-select"].forEach((e=>{if("nl-select"===e)customElements.get(e)||customElements.define(e,NlSelect)}))}defineCustomElement$n();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$m(){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$s();break;case"nl-select":customElements.get(e)||defineCustomElement$n()}}))}defineCustomElement$m();const nlInfoCss=baseCss,NlInfoStyle0=nlInfoCss,NlInfo=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost()}render(){return h("div",{key:"ff51154f6dd944fd5de65bc2e8835c6b4b1cfa57",class:"p-4 overflow-y-auto"},h("svg",{key:"c04db0af7e108551b3b9de37dfe5c2175b6439f4",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:"6a4d8f9847e857973d4e089a74fec6f8e50fc09d",width:"224.047",height:"224",rx:"64",fill:"#6951FA"}),h("path",{key:"a5bddb82b767722286b2165bc03e6d7aec7fee98",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:"b3264a68c05a73a83c01c2e54c7088bb234ca40d",class:"nl-title font-bold text-center text-4xl"},"Nostr ",h("span",{key:"ace01503f2160f1589229fbc732c7b5cf5aeedcc",class:"font-light"},"Login")),h("p",{key:"204c3ce4a21857081eb6e65c4b4a8d5356ab2722",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:"88790a07beaad70f1d6e77ce77b30b87c7a73f3c",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},"Learn more about Nostr"," ",h("a",{key:"129c8383ab18b01fba2b13c5b805435b24056e18",target:"_blank",href:"https://nostr.how"},"here"),".",h("br",{key:"8c1cca37a0992068c94a22ec8dea3e859db97e4a"}),"This is an"," ",h("a",{key:"eb270824dba82f0a707715724b165af90f86d25b",target:"_blank",href:"https://github.com/nostrband/nostr-login"},"open-source")," ","tool by"," ",h("a",{key:"d64434bf56e2083bf82ad90a2daf003a3c368ddc",target:"_blank",href:"https://nostr.band"},"Nostr.Band"),"."))}static get style(){return NlInfoStyle0}},[0,"nl-info"]);function defineCustomElement$l(){if("undefined"==typeof customElements)return;["nl-info"].forEach((e=>{if("nl-info"===e)customElements.get(e)||customElements.define(e,NlInfo)}))}defineCustomElement$l();const nlInfoExtensionCss=baseCss,NlInfoExtensionStyle0=nlInfoExtensionCss,NlInfoExtension=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost()}render(){return h("div",{key:"1d919493f0e640d5394470dd77ad586c8ad949d4",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$k(){if("undefined"==typeof customElements)return;["nl-info-extension"].forEach((e=>{if("nl-info-extension"===e)customElements.get(e)||customElements.define(e,NlInfoExtension)}))}defineCustomElement$k();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,o=!state.isLoading&&state.iframeUrl&&state.authUrl,r=state.iframeUrl?`${state.iframeUrl}?connect=${encodeURIComponent(state.authUrl)}`:"";return h("div",{key:"db647721e5ca60eed1502bf784f11973106938ff",class:"p-4 overflow-y-auto"},e&&h("h1",{key:"605d32178383840ea53a3fc16c2d760dccea0812",class:"nl-title font-bold text-center text-4xl"},e),t&&h("p",{key:"8dc819ba9544242ef05256a12f866cd88b3603cf",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:"f392c2a856018c4d35b01a76b77f0eec8342fb86",class:"mt-10 mb-10 ml-auto mr-auto w-20"},h("span",{key:"90541216f412c9c8d77be8988c6f9e5b654ce115",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:"a870a4e31048a13f400970aad850e7eab418ef06",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"5bf2c4a5b94a4dfe1331a2fa5fb11ea4d414f353",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),r&&h("div",{key:"854f1920def8e2354801a819f9e564ae1658e34b",class:"mt-3 ml-auto mr-auto w-72 flex justify-center"},h("iframe",{key:"a5056dbe483013c20515b8c6576af60f612e132b",src:r,width:"180px",height:"80px",style:{display:o?"block":"none",border:"0"}})),state.njumpIframe&&h("div",{key:"848d0c6cf74610b8793ade84a5c1f32fd5944b62",class:"mt-3 ml-auto mr-auto flex justify-center"},h("iframe",{key:"456702bd5c9e9b290d532aef0ec245e1212ea79f",srcdoc:state.njumpIframe,width:"600px",style:{border:"0",height:"80vh",borderRadius:"8px"}})),n&&h("div",{key:"d7b82c1fd76a8cf4edf38d2cbe2386e2ce698a81",class:"mt-3 ml-auto mr-auto w-72"},h("button-base",{key:"8465e32b53c4b86e3b1b488fddcc5937a018768f",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$j(){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$s()}}))}defineCustomElement$j();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:"4e2e1cb4e43c985fbcc79af1b085389a38c2805d"},h("div",{key:"ed3e90f3eeef7d1354b6e36d8f29c7348176b989",class:"p-4 overflow-y-auto"},h("h1",{key:"8b47eb2e2221b61d8b75e297ae9b954cd2a0ef89",class:"nl-title font-bold text-center text-2xl"},this.titleSignup),h("p",{key:"af517d0c92652d1e4fd14f57bf593eb1510865e7",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:"54dd6ee361785bf45b760333104dc946a5a8f941",class:"max-w-72 mx-auto"},!this.signupNjump&&h("div",{key:"af4d8a26c1da84d2a07f1086c69b9776b361d484",class:"relative mb-2"},h("input",{key:"dc30806eefb1b2210e4960401de95578256becbd",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:"64cfe0fe240b2e04216485915b3e6f034c5d0229",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:"434077af1de7ee510325e84b64bc02981b039792",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:"5f9aae2d279fd8807b1798518f33da878e30f8ff","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:"39115be409b0cc01e098e05fdeb370e15673f8e1",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"cd7556b84e69f372b6aa9c834794e5bded78c228",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"d29de7bb01cf5fb0b3ba76b9cf52aa846e3db638",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$i(){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$s()}}))}defineCustomElement$i();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:"8b5236e4bc47388d9e55ff92b3c5837bd77833d6"},h("span",{key:"066cb55933afc54e17831a3fe4c6fbc4b66aec15",class:`${t} rounded-xl border w-auto text-[10px] px-1 `},e))}},[0,"nl-login-status",{info:[16]}]);function defineCustomElement$h(){if("undefined"==typeof customElements)return;["nl-login-status"].forEach((e=>{if("nl-login-status"===e)customElements.get(e)||customElements.define(e,NlLoginStatus)}))}defineCustomElement$h();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:"12693d07250ca52865a5a04d454e11e43b651e13"},h("div",{key:"1fa49c196cfb54cc7da20925dc61490d3cea4f1d",class:"p-4 overflow-y-auto"},h("h1",{key:"ff29ef7de0954e75bf17ee260eea556ba364ecdd",class:"nl-title font-bold text-center text-2xl"},this.titleImport),h("p",{key:"626e164f92be79d655384e631c982bc4e06fdbfc",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.textImport)),h("div",{key:"7d3b75101d0531c41a7bfcbb5ece1ffa67821810",class:"max-w-72 mx-auto mb-5"},h("div",{key:"7a11b1c4668f0172ce4535fe0c4931221b147509",class:"mb-0.5"},h("nl-select",{key:"1c7dbbd077d06f19745f2c53d1100b74e5498a17",onSelectDomain:e=>this.handleDomainSelect(e),selected:0,options:e})),h("p",{key:"da6a4528697951de8b31b4697ba9b19d71b33b4f",class:"nl-title font-light text-sm mb-2"},"Default provider is a fine choice to start with."),h("div",{key:"a57b965e8ad521ab36d81d8962a723ddfa735757",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"cb748be936c8204d67b1fa49fe2f2f8ed11cb604",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"dd31a190750a945c5a4f71830e8177bd7172a7bc",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$g(){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$s();break;case"nl-select":customElements.get(e)||defineCustomElement$n()}}))}defineCustomElement$g();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:"433be12e7eb9f18f10afa828a53920c85410940c"},h("div",{key:"080f439a9910e8fe8217a914d04e2a2cc8ca97ad",class:"p-4 pt-0 overflow-y-auto"},h("h1",{key:"332f960bc2b1727277dade6d5236f41f9a81116c",class:"nl-title font-bold text-center text-4xl"},this.titlePage),h("p",{key:"2a1fb42c969f6266eb782d3f4f01a935ff88d779",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"679d3e53e352631f704c997c8ec206d122e4f8a6",class:"p-4"},Boolean(this.accounts.length)&&h("div",{key:"4f2d266c86cc05c5030c432eeb8611f12ccfe52b",class:"max-w-96 mx-auto"},h("p",{key:"94baf6a179142c0f3d6e0f15d2d98be35ee4cbcc",class:"nl-description font-medium text-sm pb-1.5"},"Active profiles"),h("ul",{key:"5d7971661fbb7e6cc992df82f73639d9d1b5c69d",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,o=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"}):o?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:"c66d7eda3b667f736052dc27709a343ddb74b54a",class:"max-w-96 mx-auto pt-5"},h("p",{key:"d31c7a93df4b7583cb00b4e0d55c1118adae0b32",class:"nl-description font-medium text-sm pb-1.5"},"Recent profiles"),h("ul",{key:"c03f0135c7e3dc4fe5db91aeff7cb8e1ccd436b6",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,o=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"}):o?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:"bf85231e1b0cd2a3490564507ec9f41e9277a64f",class:"p-4 overflow-y-auto"},h("p",{key:"c88a893c3833de4ad97637abd10507b76921c0c5",class:"nl-footer font-light text-center text-sm max-w-96 mx-auto"},"You can also"," ",h("span",{key:"767425be179794ec16efe01c66f11d01954c70df",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$f(){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$h()}}))}defineCustomElement$f();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:"a498d75f074f6df3cda28a845c783cbd8568747a"},h("div",{key:"32c20383fd595cd977c5163f14806fd1dcdab210",class:"p-4 overflow-y-auto"},h("h1",{key:"4a0d7b438e34497072df509f8b7196342f30964c",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h("p",{key:"1a48de557c4544eb38c9c826848171cdcebead9f",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"9c74d29c7f007f2dd3e795cfb3fbc3bccd03549a",class:"max-w-72 mx-auto"},h("div",{key:"97d4c6367bfa6bf581a3bb4283ee6d8958cbc7c6",class:"relative mb-2"},h("input",{key:"5b5ba0b7268576680f40508cfd2f6fa771cd1acd",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:"971b0e66f94f20fa3406786e8f6fc66e858b82aa",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:"e267ffa5f7a5cf560732da01645f771c24555927",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:"c694ee22fe4198b58f0d750cea98a34cf2a9bc14","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:"41828dc382da40b4a7b11dc094d20f4913480a8a",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"b619b41116fc3d6ae33363dd1be6ac67f3521f14",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"81797cde8acbaf0aeeb204aa07885ba27f27c08d",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$e(){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$s()}}))}defineCustomElement$e();class e{constructor(t,n,o,r,s){this._legacyCanvasSize=e.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),o&&"object"==typeof o?this._onDecode=n:(o||r||s?console.warn("You're using a deprecated version of the QrScanner constructor which will be removed in the future"):console.warn("Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=n),n="object"==typeof o?o:{},this._onDecodeError=n.onDecodeError||("function"==typeof o?o:this._onDecodeError),this._calculateScanRegion=n.calculateScanRegion||("function"==typeof r?r:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||s||this._preferredCamera,this._legacyCanvasSize="number"==typeof o?o:"number"==typeof r?r:this._legacyCanvasSize,this._maxScansPerSecond=n.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let i=!1;if(t.hidden&&(t.hidden=!1,i=!0),document.body.contains(t)||(document.body.appendChild(t),i=!0),o=t.parentElement,n.highlightScanRegion||n.highlightCodeOutline){if(r=!!n.overlay,this.$overlay=n.overlay||document.createElement("div"),(s=this.$overlay.style).position="absolute",s.display="none",s.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!r&&n.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch(e){}o.insertBefore(this.$overlay,this.$video.nextSibling)}n.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame((()=>{let e=window.getComputedStyle(t);"none"===e.display&&(t.style.setProperty("display","block","important"),i=!0),"visible"!==e.visibility&&(t.style.setProperty("visibility","visible","important"),i=!0),i&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),t.style.opacity="0",t.style.width="0",t.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()})),t.addEventListener("play",this._onPlay),t.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=e.createQrEngine()}static set WORKER_PATH(e){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await e.listCameras(!1)).length}catch(e){return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let n,o=async()=>(await navigator.mediaDevices.enumerateDevices()).filter((e=>"videoinput"===e.kind));try{t&&(await o()).every((e=>!e.label))&&(n=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch(e){}try{return(await o()).map(((e,t)=>({id:e.deviceId,label:e.label||(0===t?"Default Camera":`Camera ${t+1}`)})))}finally{n&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),e._stopVideoStream(n))}}async hasFlash(){let t;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;t=this.$video.srcObject}else t=(await this._getCameraStream()).stream;return"torch"in t.getVideoTracks()[0].getSettings()}catch(e){return!1}finally{t&&t!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),e._stopVideoStream(t))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!await this.hasFlash())throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(e){throw this._flashOn=!1,e}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),e._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&("https:"!==window.location.protocol&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:n}=await this._getCameraStream();!this._active||this._paused?e._stopVideoStream(t):(this._setVideoMirror(n),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch((()=>{}))))}catch(e){if(!this._paused)throw this._active=!1,e}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let n=()=>{this.$video.srcObject instanceof MediaStream&&(e._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(n(),!0):(await new Promise((e=>setTimeout(e,300))),!!this._paused&&(n(),!0))}async setCamera(e){e!==this._preferredCamera&&(this._preferredCamera=e,await this._restartVideoStream())}static async scanImage(t,n,o,r,s=!1,i=!1){let a,c=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(a=n.scanRegion,o=n.qrEngine,r=n.canvas,s=n.disallowCanvasResizing||!1,i=n.alsoTryWithoutScanRegion||!1,c=!0):n||o||r||s||i?console.warn("You're using a deprecated api for scanImage which will be removed in the future."):console.warn("Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),n=!!o;try{let l,d,h;if([o,l]=await Promise.all([o||e.createQrEngine(),e._loadImage(t)]),[r,d]=e._drawToCanvas(l,a,r,s),o instanceof Worker){let t=o;n||e._postWorkerMessageSync(t,"inversionMode","both"),h=await new Promise(((n,o)=>{let s,i,c,l=-1;i=r=>{r.data.id===l&&(t.removeEventListener("message",i),t.removeEventListener("error",c),clearTimeout(s),null!==r.data.data?n({data:r.data.data,cornerPoints:e._convertPoints(r.data.cornerPoints,a)}):o(e.NO_QR_CODE_FOUND))},c=e=>{t.removeEventListener("message",i),t.removeEventListener("error",c),clearTimeout(s),o("Scanner error: "+(e?e.message||e:"Unknown Error"))},t.addEventListener("message",i),t.addEventListener("error",c),s=setTimeout((()=>c("timeout")),1e4);let h=d.getImageData(0,0,r.width,r.height);l=e._postWorkerMessageSync(t,"decode",h,[h.data.buffer])}))}else h=await Promise.race([new Promise(((e,t)=>window.setTimeout((()=>t("Scanner error: timeout")),1e4))),(async()=>{try{var[n]=await o.detect(r);if(!n)throw e.NO_QR_CODE_FOUND;return{data:n.rawValue,cornerPoints:e._convertPoints(n.cornerPoints,a)}}catch(o){if(n=o.message||o,/not implemented|service unavailable/.test(n))return e._disableBarcodeDetector=!0,e.scanImage(t,{scanRegion:a,canvas:r,disallowCanvasResizing:s,alsoTryWithoutScanRegion:i});throw`Scanner error: ${n}`}})()]);return c?h:h.data}catch(n){if(!a||!i)throw n;let l=await e.scanImage(t,{qrEngine:o,canvas:r,disallowCanvasResizing:s});return c?l:l.data}finally{n||e._postWorkerMessage(o,"close")}}setGrayscaleWeights(t,n,o,r=!0){e._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:n,blue:o,useIntegerApproximation:r})}setInversionMode(t){e._postWorkerMessage(this._qrEnginePromise,"inversionMode",t)}static async createQrEngine(t){if(t&&console.warn("Specifying a worker path is not required and not supported anymore."),t=()=>Promise.resolve().then((function(){return qrScannerWorker_min})).then((e=>e.createWorker())),e._disableBarcodeDetector||!("BarcodeDetector"in window)||!BarcodeDetector.getSupportedFormats||!(await BarcodeDetector.getSupportedFormats()).includes("qr_code"))return t();let n=navigator.userAgentData;return n&&n.brands.some((({brand:e})=>/Chromium/i.test(e)))&&/mac ?OS/i.test(n.platform)&&await n.getHighEntropyValues(["architecture","platformVersion"]).then((({architecture:e,platformVersion:t})=>/arm/i.test(e||"arm")&&13<=parseInt(t||"13"))).catch((()=>!0))?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(e){let t=Math.round(2/3*Math.min(e.videoWidth,e.videoHeight));return{x:Math.round((e.videoWidth-t)/2),y:Math.round((e.videoHeight-t)/2),width:t,height:t,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame((()=>{if(this.$overlay){var e=this.$video,t=e.videoWidth,n=e.videoHeight,o=e.offsetWidth,r=e.offsetHeight,s=e.offsetLeft,i=e.offsetTop,a=window.getComputedStyle(e),c=a.objectFit,l=t/n,d=o/r;switch(c){case"none":var h=t,u=n;break;case"fill":h=o,u=r;break;default:("cover"===c?l>d:l<d)?h=(u=r)*l:u=(h=o)/l,"scale-down"===c&&(h=Math.min(h,t),u=Math.min(u,n))}var[f,p]=a.objectPosition.split(" ").map(((e,t)=>{const n=parseFloat(e);return e.endsWith("%")?(t?r-u:o-h)*n/100:n}));a=this._scanRegion.width||t,d=this._scanRegion.height||n,c=this._scanRegion.x||0;var g=this._scanRegion.y||0;(l=this.$overlay.style).width=a/t*h+"px",l.height=d/n*u+"px",l.top=`${i+p+g/n*u}px`,n=/scaleX\(-1\)/.test(e.style.transform),l.left=`${s+(n?o-f-h:f)+(n?t-c-a:c)/t*h}px`,l.transform=e.style.transform}}))}static _convertPoints(e,t){if(!t)return e;let n=t.x||0,o=t.y||0,r=t.width&&t.downScaledWidth?t.width/t.downScaledWidth:1;t=t.height&&t.downScaledHeight?t.height/t.downScaledHeight:1;for(let s of e)s.x=s.x*r+n,s.y=s.y*t+o;return e}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)((async()=>{if(!(1>=this.$video.readyState)){var t=Date.now()-this._lastScanTimestamp,n=1e3/this._maxScansPerSecond;t<n&&await new Promise((e=>setTimeout(e,n-t))),this._lastScanTimestamp=Date.now();try{var o=await e.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(e){if(!this._active)return;this._onDecodeError(e)}!e._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=e.createQrEngine()),o?(this._onDecode?this._onDecode(o):this._legacyOnDecode&&this._legacyOnDecode(o.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",o.cornerPoints.map((({x:e,y:t})=>`${e},${t}`)).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout((()=>this.$codeOutlineHighlight.style.display="none"),100))}this._scanFrame()}))}_onDecodeError(t){t!==e.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let e=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",t=[{width:{min:1024}},{width:{min:768}},{}],n=t.map((t=>Object.assign({},t,{[e]:{exact:this._preferredCamera}})));for(let e of[...n,...t])try{let t=await navigator.mediaDevices.getUserMedia({video:e,audio:!1});return{stream:t,facingMode:this._getFacingMode(t)||(e.facingMode?this._preferredCamera:"environment"===this._preferredCamera?"user":"environment")}}catch(e){}throw"Camera not found."}async _restartVideoStream(){let e=this._paused;await this.pause(!0)&&!e&&this._active&&await this.start()}static _stopVideoStream(e){for(let t of e.getTracks())t.stop(),e.removeTrack(t)}_setVideoMirror(e){this.$video.style.transform="scaleX("+("user"===e?-1:1)+")"}_getFacingMode(e){return(e=e.getVideoTracks()[0])?/rear|back|environment/i.test(e.label)?"environment":/front|user|face/i.test(e.label)?"user":null:null}static _drawToCanvas(e,t,n,o=!1){n=n||document.createElement("canvas");let r=t&&t.x?t.x:0,s=t&&t.y?t.y:0,i=t&&t.width?t.width:e.videoWidth||e.width,a=t&&t.height?t.height:e.videoHeight||e.height;return o||(o=t&&t.downScaledWidth?t.downScaledWidth:i,t=t&&t.downScaledHeight?t.downScaledHeight:a,n.width!==o&&(n.width=o),n.height!==t&&(n.height=t)),(t=n.getContext("2d",{alpha:!1})).imageSmoothingEnabled=!1,t.drawImage(e,r,s,i,a,0,0,n.width,n.height),[n,t]}static async _loadImage(t){if(t instanceof Image)return await e._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(!(t instanceof File||t instanceof Blob||t instanceof URL||"string"==typeof t))throw"Unsupported image type.";{let n=new Image;n.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await e._awaitImageLoad(n),n}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(n.src)}}}static async _awaitImageLoad(e){e.complete&&0!==e.naturalWidth||await new Promise(((t,n)=>{let o=r=>{e.removeEventListener("load",o),e.removeEventListener("error",o),r instanceof ErrorEvent?n("Image load error"):t()};e.addEventListener("load",o),e.addEventListener("error",o)}))}static async _postWorkerMessage(t,n,o,r){return e._postWorkerMessageSync(await t,n,o,r)}static _postWorkerMessageSync(t,n,o,r){if(!(t instanceof Worker))return-1;let s=e._workerMessageId++;return t.postMessage({id:s,type:n,data:o},r),s}}e.DEFAULT_CANVAS_SIZE=400,e.NO_QR_CODE_FOUND="No QR code found",e._disableBarcodeDetector=!1,e._workerMessageId=0;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.videoEl=null,this.stream=null,this.scanInterval=null,this.titleLogin="Connect with bunker url",this.description="Please enter a bunker url provided by key store.",this.isGood=!1,this.isScanning=!1,this.scanError=""}handleInputChange(e){state.nlSigninBunkerUrl.loginName=e.target.value,this.nlCheckLogin.emit(e.target.value)}handleLogin(e){e.preventDefault(),this.nlLogin.emit(state.nlSigninBunkerUrl.loginName)}async startScan(){if(this.scanError="",this.isScanning=!0,await new Promise((e=>requestAnimationFrame((()=>requestAnimationFrame(e))))),!this.scannerContainer)return this.scanError="Camera not available",void(this.isScanning=!1);try{this.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"},audio:!1}),this.videoEl=document.createElement("video"),this.videoEl.setAttribute("playsinline",""),this.videoEl.setAttribute("autoplay",""),this.videoEl.muted=!0,this.videoEl.style.width="100%",this.videoEl.style.height="100%",this.videoEl.style.objectFit="cover",this.videoEl.style.display="block",this.videoEl.srcObject=this.stream,this.scannerContainer.appendChild(this.videoEl),await this.videoEl.play(),this.scanInterval=setInterval((async()=>{if(this.videoEl&&!(this.videoEl.readyState<2))try{const t=(await e.scanImage(this.videoEl,{returnDetailedScanResult:!0})).data;t&&(t.startsWith("bunker://")||t.startsWith("nostrconnect://"))&&(state.nlSigninBunkerUrl.loginName=t,this.nlCheckLogin.emit(t),this.stopScan())}catch(e){}}),250)}catch(e){console.error("QR Scanner error:",e),this.scanError=e instanceof Error?e.message:"Failed to access camera",this.isScanning=!1}}stopScan(){this.scanInterval&&(clearInterval(this.scanInterval),this.scanInterval=null),this.stream&&(this.stream.getTracks().forEach((e=>e.stop())),this.stream=null),this.videoEl&&(this.videoEl.srcObject=null,this.videoEl.remove(),this.videoEl=null),this.isScanning=!1}disconnectedCallback(){this.stopScan()}render(){return h(Fragment,{key:"1ee10a09c7f6782b5f89530c9331a3144f73a8ba"},h("div",{key:"68b5bef4961ddc8cf24ef98f7452d8ae5b0f6aae",class:"p-4 overflow-y-auto"},h("h1",{key:"be4da63776a4fc4f2228b22e95a1f31380e6d0f6",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h("p",{key:"d2e9c469206c4e71544416760090751dbe33cb4b",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"f2219e9bfc0262b5e1bfcfb3761515a26332c3d6",class:"max-w-72 mx-auto"},h("div",{key:"bd25646ec291c36aa20088108056bd6ae80f851a",class:"relative mb-2"},h("input",{key:"659665fa5c9b1247c5e81afc86a11b61e236b67a",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:"4e0fe1bfaa82a05256a716c329ae9f8e6696b1d3",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:"795ba20efa3fc317ccb0e91489ee7d96dc36b0e7",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:"0d856bf29de693b6424256da7491993692edde1b","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"})))),this.isScanning?h("div",{class:"mb-3"},h("div",{ref:e=>this.scannerContainer=e,class:"relative rounded-lg overflow-hidden bg-black",style:{aspectRatio:"1",width:"100%"}}),h("button",{type:"button",onClick:()=>this.stopScan(),class:"nl-action-button mt-2 w-full py-2 px-4 text-sm font-medium rounded-lg border border-transparent"},"Cancel")):h("div",{class:"mb-3"},h("button",{type:"button",onClick:()=>this.startScan(),class:"nl-action-button w-full py-2 px-4 inline-flex justify-center items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent"},h("svg",{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",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6.827 6.175A2.31 2.31 0 0 1 5.186 7.23c-.38.054-.757.112-1.134.175C2.999 7.58 2.25 8.507 2.25 9.574V18a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 18V9.574c0-1.067-.75-1.994-1.802-2.169a47.865 47.865 0 0 0-1.134-.175 2.31 2.31 0 0 1-1.64-1.055l-.822-1.316a2.192 2.192 0 0 0-1.736-1.039 48.774 48.774 0 0 0-5.232 0 2.192 2.192 0 0 0-1.736 1.039l-.821 1.316Z"}),h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M16.5 12.75a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0ZM18.75 10.5h.008v.008h-.008V10.5Z"})),"Scan QR Code")),this.scanError&&h("div",{key:"dfc914e494b41c2381fe9f4d699632ecb4fd33c9",class:"mb-2"},h("p",{key:"043fa75931e800a25afa0d6d02de0aab7718ed4c",class:"nl-error font-light text-center text-sm"},this.scanError)),h("div",{key:"d908c3d8c8a8054ce944a47a27e3b18c8dc40ce5",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"8293556d3e2a1f714e2a776ab69d1e1609806bbb",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"305e5badc3dd35dcbadc0e1ff123eee5bb1580a6",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],isScanning:[32],scanError:[32]}]);function defineCustomElement$d(){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$s()}}))}defineCustomElement$d();var browser={},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,o){const r=e*this.size+t;this.data[r]=n,o&&(this.reservedBit[r]=!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,o=t(e),r=145===o?26:2*Math.ceil((o-13)/(2*n-2)),s=[o-7];for(let e=1;e<n-1;e++)s[e]=s[e-1]-r;return s.push(6),s.reverse()},e.getPositions=function(t){const n=[],o=e.getRowColCoords(t),r=o.length;for(let e=0;e<r;e++)for(let t=0;t<r;t++)0===e&&0===t||0===e&&t===r-1||e===r-1&&0===t||n.push([o[e],o[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,o=40,r=10;function s(t,n,o){switch(t){case e.Patterns.PATTERN000:return(n+o)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return o%3==0;case e.Patterns.PATTERN011:return(n+o)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(o/3))%2==0;case e.Patterns.PATTERN101:return n*o%2+n*o%3==0;case e.Patterns.PATTERN110:return(n*o%2+n*o%3)%2==0;case e.Patterns.PATTERN111:return(n*o%3+(n+o)%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 o=0,r=0,s=0,i=null,a=null;for(let c=0;c<n;c++){r=s=0,i=a=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===i?r++:(r>=5&&(o+=t+(r-5)),i=n,r=1),n=e.get(l,c),n===a?s++:(s>=5&&(o+=t+(s-5)),a=n,s=1)}r>=5&&(o+=t+(r-5)),s>=5&&(o+=t+(s-5))}return o},e.getPenaltyN2=function(e){const t=e.size;let o=0;for(let n=0;n<t-1;n++)for(let r=0;r<t-1;r++){const t=e.get(n,r)+e.get(n,r+1)+e.get(n+1,r)+e.get(n+1,r+1);4!==t&&0!==t||o++}return o*n},e.getPenaltyN3=function(e){const t=e.size;let n=0,r=0,s=0;for(let o=0;o<t;o++){r=s=0;for(let i=0;i<t;i++)r=r<<1&2047|e.get(o,i),i>=10&&(1488===r||93===r)&&n++,s=s<<1&2047|e.get(i,o),i>=10&&(1488===s||93===s)&&n++}return n*o},e.getPenaltyN4=function(e){let t=0;const n=e.data.length;for(let o=0;o<n;o++)t+=e.data[o];return Math.abs(Math.ceil(100*t/n/5)-10)*r},e.applyMask=function(e,t){const n=t.size;for(let o=0;o<n;o++)for(let r=0;r<n;r++)t.isReserved(r,o)||t.xor(r,o,s(e,r,o))},e.getBestMask=function(t,n){const o=Object.keys(e.Patterns).length;let r=0,s=1/0;for(let i=0;i<o;i++){n(i),e.applyMask(i,t);const o=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(i,t),o<s&&(s=o,r=i)}return r}}(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 o=new Uint8Array(e.length+n.length-1);for(let r=0;r<e.length;r++)for(let s=0;s<n.length;s++)o[r+s]^=t.mul(e[r],n[s]);return o},e.mod=function(e,n){let o=new Uint8Array(e);for(;o.length-n.length>=0;){const e=o[0];for(let r=0;r<n.length;r++)o[r]^=t.mul(n[r],e);let r=0;for(;r<o.length&&0===o[r];)r++;o=o.slice(r)}return o},e.generateECPolynomial=function(n){let o=new Uint8Array([1]);for(let r=0;r<n;r++)o=e.mul(o,new Uint8Array([1,t.exp(r)]));return o}}(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),o=this.degree-n.length;if(o>0){const e=new Uint8Array(this.degree);return e.set(n,o),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,o=errorCorrectionLevel,r=mode,s=versionCheck,i=t.getBCHDigit(7973);function a(e,t){return r.getCharCountIndicator(e,t)+4}function c(e,t){let n=0;return e.forEach((function(e){const o=a(e.mode,t);n+=o+e.getBitsLength()})),n}e.from=function(e,t){return s.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,o,i){if(!s.isValid(e))throw new Error("Invalid QR Code version");void 0===i&&(i=r.BYTE);const c=8*(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,o));if(i===r.MIXED)return c;const l=c-a(i,e);switch(i){case r.NUMERIC:return Math.floor(l/10*3);case r.ALPHANUMERIC:return Math.floor(l/11*2);case r.KANJI:return Math.floor(l/13);case r.BYTE:default:return Math.floor(l/8)}},e.getBestVersionForData=function(t,n){let s;const i=o.from(n,o.M);if(Array.isArray(t)){if(t.length>1)return function(t,n){for(let o=1;o<=40;o++)if(c(t,o)<=e.getCapacity(o,n,r.MIXED))return o}(t,i);if(0===t.length)return 1;s=t[0]}else s=t;return function(t,n,o){for(let r=1;r<=40;r++)if(n<=e.getCapacity(r,o,t))return r}(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 o=n<<10;for(;Utils$3.getBCHDigit(o)-G15_BCH>=0;)o^=G15<<Utils$3.getBCHDigit(o)-G15_BCH;return(n<<10|o)^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,o;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),o=parseInt(n,10),e.put(o,10);const r=this.data.length-t;r>0&&(n=this.data.substr(t),o=parseInt(n,10),e.put(o,3*r+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,o){var r={},s={};s[n]=0;var i,a,c,l,d,h,u,f=t.PriorityQueue.make();for(f.push(n,0);!f.empty();)for(c in a=(i=f.pop()).value,l=i.cost,d=e[a]||{})d.hasOwnProperty(c)&&(h=l+d[c],u=s[c],(void 0===s[c]||u>h)&&(s[c]=h,f.push(c,h),r[c]=a));if(void 0!==o&&void 0===s[o]){var p=["Could not find a path from ",n," to ",o,"."].join("");throw new Error(p)}return r},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],o=t;o;)n.push(o),o=e[o];return n.reverse(),n},find_path:function(e,n,o){var r=t.single_source_shortest_paths(e,n,o);return t.extract_shortest_path_from_predecessor_list(r,o)},PriorityQueue:{make:function(e){var n,o=t.PriorityQueue,r={};for(n in e=e||{},o)o.hasOwnProperty(n)&&(r[n]=o[n]);return r.queue=[],r.sorter=e.sorter||o.default_sorter,r},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,o=alphanumericData,r=byteData,s=kanjiData,i=regex$1,a=utils$1$1,c=dijkstra.exports;function l(e){return unescape(encodeURIComponent(e)).length}function d(e,t,n){const o=[];let r;for(;null!==(r=e.exec(n));)o.push({data:r[0],index:r.index,mode:t,length:r[0].length});return o}function h(e){const n=d(i.NUMERIC,t.NUMERIC,e),o=d(i.ALPHANUMERIC,t.ALPHANUMERIC,e);let r,s;a.isKanjiModeEnabled()?(r=d(i.BYTE,t.BYTE,e),s=d(i.KANJI,t.KANJI,e)):(r=d(i.BYTE_KANJI,t.BYTE,e),s=[]);return n.concat(o,r,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 o.getBitsLength(e);case t.KANJI:return s.getBitsLength(e);case t.BYTE:return r.getBitsLength(e)}}function f(e,i){let c;const l=t.getBestModeForData(e);if(c=t.from(i,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 o(e);case t.KANJI:return new s(e);case t.BYTE:return new r(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,o){const r=function(e){const n=[];for(let o=0;o<e.length;o++){const r=e[o];switch(r.mode){case t.NUMERIC:n.push([r,{data:r.data,mode:t.ALPHANUMERIC,length:r.length},{data:r.data,mode:t.BYTE,length:r.length}]);break;case t.ALPHANUMERIC:n.push([r,{data:r.data,mode:t.BYTE,length:r.length}]);break;case t.KANJI:n.push([r,{data:r.data,mode:t.BYTE,length:l(r.data)}]);break;case t.BYTE:n.push([{data:r.data,mode:t.BYTE,length:l(r.data)}])}}return n}(h(n,a.isKanjiModeEnabled())),s=function(e,n){const o={},r={start:{}};let s=["start"];for(let i=0;i<e.length;i++){const a=e[i],c=[];for(let e=0;e<a.length;e++){const l=a[e],d=""+i+e;c.push(d),o[d]={node:l,lastCount:0},r[d]={};for(let e=0;e<s.length;e++){const i=s[e];o[i]&&o[i].node.mode===l.mode?(r[i][d]=u(o[i].lastCount+l.length,l.mode)-u(o[i].lastCount,l.mode),o[i].lastCount+=l.length):(o[i]&&(o[i].lastCount=l.length),r[i][d]=u(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}s=c}for(let e=0;e<s.length;e++)r[s[e]].end=0;return{map:r,table:o}}(r,o),i=c.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$5=mode,Segments=segments;function setupFinderPattern(e,t){const n=e.size,o=FinderPattern.getPositions(t);for(let t=0;t<o.length;t++){const r=o[t][0],s=o[t][1];for(let t=-1;t<=7;t++)if(!(r+t<=-1||n<=r+t))for(let o=-1;o<=7;o++)s+o<=-1||n<=s+o||(t>=0&&t<=6&&(0===o||6===o)||o>=0&&o<=6&&(0===t||6===t)||t>=2&&t<=4&&o>=2&&o<=4?e.set(r+t,s+o,!0,!0):e.set(r+t,s+o,!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 o=n[t][0],r=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(o+t,r+n,!0,!0):e.set(o+t,r+n,!1,!0)}}function setupVersionInfo(e,t){const n=e.size,o=Version.getEncodedBits(t);let r,s,i;for(let t=0;t<18;t++)r=Math.floor(t/3),s=t%3+n-8-3,i=1==(o>>t&1),e.set(r,s,i,!0),e.set(s,r,i,!0)}function setupFormatInfo(e,t,n){const o=e.size,r=FormatInfo.getEncodedBits(t,n);let s,i;for(s=0;s<15;s++)i=1==(r>>s&1),s<6?e.set(s,8,i,!0):s<8?e.set(s+1,8,i,!0):e.set(o-15+s,8,i,!0),s<8?e.set(8,o-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(o-8,8,1,!0)}function setupData(e,t){const n=e.size;let o=-1,r=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(r,a-n)){let o=!1;i<t.length&&(o=1==(t[i]>>>s&1)),e.set(r,a-n,o),s--,-1===s&&(i++,s=7)}if(r+=o,r<0||n<=r){r-=o,o=-o;break}}}function createData(e,t,n){const o=new BitBuffer;n.forEach((function(t){o.put(t.mode.bit,4),o.put(t.getLength(),Mode$5.getCharCountIndicator(t.mode,e)),t.write(o)}));const r=8*(Utils$1.getSymbolTotalCodewords(e)-ECCode.getTotalCodewordsCount(e,t));for(o.getLengthInBits()+4<=r&&o.put(0,4);o.getLengthInBits()%8!=0;)o.putBit(0);const s=(r-o.getLengthInBits())/8;for(let e=0;e<s;e++)o.put(e%2?17:236,8);return createCodewords(o,e,t)}function createCodewords(e,t,n){const o=Utils$1.getSymbolTotalCodewords(t),r=o-ECCode.getTotalCodewordsCount(t,n),s=ECCode.getBlocksCount(t,n),i=s-o%s,a=Math.floor(o/s),c=Math.floor(r/s),l=c+1,d=a-c,h=new ReedSolomonEncoder(d);let u=0;const f=new Array(s),p=new Array(s);let g=0;const m=new Uint8Array(e.buffer);for(let e=0;e<s;e++){const t=e<i?c:l;f[e]=m.slice(u,u+t),p[e]=h.encode(f[e]),u+=t,g=Math.max(g,t)}const b=new Uint8Array(o);let y,w,v=0;for(y=0;y<g;y++)for(w=0;w<s;w++)y<f[w].length&&(b[v++]=f[w][y]);for(y=0;y<d;y++)for(w=0;w<s;w++)b[v++]=p[w][y];return b}function createSymbol(e,t,n,o){let r;if(Array.isArray(e))r=Segments.fromArray(e);else{if("string"!=typeof e)throw new Error("Invalid data");{let o=t;if(!o){const t=Segments.rawSplit(e);o=Version.getBestVersionForData(t,n)}r=Segments.fromString(e,o||40)}}const s=Version.getBestVersionForData(r,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,r),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,i),isNaN(o)&&(o=MaskPattern.getBestMask(c,setupFormatInfo.bind(null,c,n))),MaskPattern.applyMask(o,c),setupFormatInfo(c,n,o),{modules:c,version:t,errorCorrectionLevel:n,maskPattern:o,segments:r}}qrcode.create=function(e,t){if(void 0===e||""===e)throw new Error("No input text");let n,o,r=ECLevel.M;return void 0!==t&&(r=ECLevel.from(t.errorCorrectionLevel,ECLevel.M),n=Version.from(t.version),o=MaskPattern.from(t.maskPattern),t.toSJISFunc&&Utils$1.setToSJISFunction(t.toSJISFunc)),createSymbol(e,n,r,o)};var canvas={},utils$2={};!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,o=e.width&&e.width>=21?e.width:void 0,r=e.scale||4;return{width:o,scale:o?4:r,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 o=e.getScale(t,n);return Math.floor((t+2*n.margin)*o)},e.qrToImageData=function(t,n,o){const r=n.modules.size,s=n.modules.data,i=e.getScale(r,o),a=Math.floor((r+2*o.margin)*i),c=o.margin*i,l=[o.color.light,o.color.dark];for(let e=0;e<a;e++)for(let n=0;n<a;n++){let d=4*(e*a+n),h=o.color.light;if(e>=c&&n>=c&&e<a-c&&n<a-c){h=l[s[Math.floor((e-c)/i)*r+Math.floor((n-c)/i)]?1:0]}t[d++]=h.r,t[d++]=h.g,t[d++]=h.b,t[d]=h.a}}}(utils$2),function(e){const t=utils$2;e.render=function(e,n,o){let r=o,s=n;void 0!==r||n&&n.getContext||(r=n,n=void 0),n||(s=function(){try{return document.createElement("canvas")}catch(e){throw new Error("You need to specify a canvas element")}}()),r=t.getOptions(r);const i=t.getImageWidth(e.modules.size,r),a=s.getContext("2d"),c=a.createImageData(i,i);return t.qrToImageData(c.data,e,r),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(c,0,0),s},e.renderToDataURL=function(t,n,o){let r=o;void 0!==r||n&&n.getContext||(r=n,n=void 0),r||(r={});const s=e.render(t,n,r),i=r.type||"image/png",a=r.rendererOpts||{};return s.toDataURL(i,a.quality)}}(canvas);var svgTag={};const Utils=utils$2;function getColorAttrib(e,t){const n=e.a/255,o=t+'="'+e.hex+'"';return n<1?o+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':o}function svgCmd(e,t,n){let o=e+t;return void 0!==n&&(o+=" "+n),o}function qrToPath(e,t,n){let o="",r=0,s=!1,i=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]?(i++,a>0&&c>0&&e[a-1]||(o+=s?svgCmd("M",c+n,.5+l+n):svgCmd("m",r,0),r=0,s=!1),c+1<t&&e[a+1]||(o+=svgCmd("h",i),i=0)):r++}return o}svgTag.render=function(e,t,n){const o=Utils.getOptions(t),r=e.modules.size,s=e.modules.data,i=r+2*o.margin,a=o.color.light.a?"<path "+getColorAttrib(o.color.light,"fill")+' d="M0 0h'+i+"v"+i+'H0z"/>':"",c="<path "+getColorAttrib(o.color.dark,"stroke")+' d="'+qrToPath(s,r,o.margin)+'"/>',l='viewBox="0 0 '+i+" "+i+'"',d='<svg xmlns="http://www.w3.org/2000/svg" '+(o.width?'width="'+o.width+'" height="'+o.width+'" ':"")+l+' shape-rendering="crispEdges">'+a+c+"</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,o,r){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=o=void 0):2!==i||t.getContext||(o=n,n=t,t=void 0),new Promise((function(r,s){try{const s=QRCode.create(n,o);r(e(s,t,o))}catch(e){s(e)}}))}if(i<2)throw new Error("Too few arguments provided");2===i?(r=n,n=t,t=o=void 0):3===i&&(t.getContext&&void 0===r?(r=o,o=void 0):(r=o,o=n,n=t,t=void 0));try{const s=QRCode.create(n,o);r(null,e(s,t,o))}catch(e){r(e)}}browser.create=QRCode.create,browser.toCanvas=renderCanvas.bind(null,CanvasRenderer.render),browser.toDataURL=renderCanvas.bind(null,CanvasRenderer.renderToDataURL),browser.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.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:"739ccc5ccbb2d95dd79e61bca0734603c071fa0c"},h("div",{key:"e0e55217f18f113364c874a7a749eeb4e7747da2",class:"p-4 overflow-y-auto"},h("h1",{key:"536646c9e2f14b5a26eb7cf537a2aba27108480f",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h("p",{key:"319cce0772500eb08061d62542e09e7dc31886fc",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h("canvas",{key:"acbb64df286dadd9cfc209df904bcdae06781fd7",class:"mx-auto mb-2",ref:e=>this.canvasElement=e}),h("div",{key:"5d6569013d81f1235a2e0fce79d63a358662e19b",class:"px-4"},h("div",{key:"4d6651551f297ba8065b6a8a28d00edc804ff597",class:"max-w-72 mx-auto"},h("div",{key:"32d3e176ea2b5f9aaee1a68c85a36a5f4c560414",class:"relative mb-2"},h("input",{key:"e4a0c9bcb80ec84ba545c427616e16d77f4c8581",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:"e1af97f16bf9dbedef178ea4c8e6f1b656ad10b2",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:"e53e6e030b0173fde047dabbb5d5a84a37c36562",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:"ad082553497803daeb16eb3a1b1acd4afbf173d3","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:"25438a495668108eeca317c69ed60ef830c7b76d","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:"557a946f96cf2e1d9e16d7d0b617ceae63a20ba4",class:"mt-10 justify-center items-center flex gap-2"},h("span",{key:"223239887aa24dfc350605137a18857c2944bb8a",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:"919c6ab74a39b4d8e124de850be72f4c30817b6a",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$c(){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$c();const nlSigninNsecCss=baseCss,NlSigninNsecStyle0=nlSigninNsecCss,NlSigninNsec=proxyCustomElement(class extends H{constructor(){super(),this.__registerHost(),this.nlLoginNsec=createEvent$1(this,"nlLoginNsec"),this.titleLogin="Login with nsec",this.description="Enter your private key (nsec) to log in."}handleInputChange(e){state.nlSigninNsec.nsecValue=e.target.value}handleLogin(e){e.preventDefault(),this.nlLoginNsec.emit(state.nlSigninNsec.nsecValue)}render(){return h(Fragment,{key:"96b364ced9e063e319692f6796856eb88ece7dc7"},h("div",{key:"6eb8a90f07aa52abe93af9f1cb1f98df67925c90",class:"p-4 overflow-y-auto"},h("h1",{key:"395ea33533887d43be9663e671a381614af32ec8",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h("p",{key:"775bfeedda38d2a52d439f85e6fc1c471a14df06",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"335af1f09ccdeac29cb17e9e671edbc06f251de7",class:"max-w-72 mx-auto"},h("div",{key:"e7949c50411f44ddc2e666e4a6efd4c1ced0bc51",class:"p-3 mb-3 rounded-lg border border-yellow-400 bg-yellow-50 dark:bg-yellow-900/20 dark:border-yellow-600"},h("div",{key:"3bbb8da9a9a66ba779af864b18726f367fa39b37",class:"flex items-start gap-2"},h("svg",{key:"e78c62977f057b46df3af6e6aa6d34bca86bedf1",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"#ca8a04",class:"flex-shrink-0 w-5 h-5 mt-0.5"},h("path",{key:"38fa5ad1e1e09b768a1fc17a6354f67ef6182e5f","stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z"})),h("div",{key:"e4df5e35b96ac61ce48f151988167d70c44478f4"},h("p",{key:"04d1b231d1fc9b5773bde43f7d48f7654442a8e3",class:"nl-title text-xs font-semibold",style:{color:"#ca8a04"}},"Use at your own risk"),h("p",{key:"57d626346430f8f0a09a38b10ba699252da3fe2e",class:"nl-description text-xs mt-1",style:{color:"#a16207"}},"Entering your private key directly is not recommended. We suggest migrating to a key store service for better security.")))),h("div",{key:"a00f417138ef4abf1ca2e22800a3d2a11d7fde10",class:"relative mb-2"},h("input",{key:"17d2f098263f3744de65361e09e18a0c8e1b0868",onInput:e=>this.handleInputChange(e),type:"password",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:"nsec1...",value:state.nlSigninNsec.nsecValue}),h("div",{key:"7ee9540e35b72d2678c51528f7f0302cbdbc271a",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:"0a85157080fd2363d30f002c181c32b497b6dd60",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:"819466744f8729a1ba2c6f14f3e6eb96ef6a09af","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",{key:"3773ee73ac8f9bc7eb115dbd7120d3b0d3f6d9aa",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"10325d69b4fbc0cdde6dd0fd0a0b940d82636fa7",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"f31975f0fd11bef77ebf1282fa4505c2f70dfcba",titleBtn:"Log in",disabled:state.isLoading,onClick:e=>this.handleLogin(e)},state.isLoading&&h("span",{key:"37f2a1a4e24c508511549515754b452398cd83d6",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 NlSigninNsecStyle0}},[0,"nl-signin-nsec",{titleLogin:[1,"title-login"],description:[1]}]);function defineCustomElement$b(){if("undefined"==typeof customElements)return;["nl-signin-nsec","button-base"].forEach((e=>{switch(e){case"nl-signin-nsec":customElements.get(e)||customElements.define(e,NlSigninNsec);break;case"button-base":customElements.get(e)||defineCustomElement$s()}}))}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:"709d350659757afd0ab48e36c71d8c4383bfefe0"},h("div",{key:"b0f5f62a5f154bfcc2f7a7af58cfc05614110c34",class:"p-4 overflow-y-auto"},h("h1",{key:"b846587dd89240232ae5e80812073b88e8885ebf",class:"nl-title font-bold text-center text-2xl"},state.isOTP?this.titleLoginOTP:this.titleLogin),h("p",{key:"41e3ffb50a451af98c5864e53cf9b29b6f9954eb",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:"ef89992613d828c4522af37be614e03c00ca181f",class:"max-w-72 mx-auto"},h("div",{key:"bea6fbf173fdc9a248d96318547a3e4d72df1b21",class:"relative mb-2"},h("input",{key:"2c5dce83b126cfc0c10c5609da99c124944a3050",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:"ca758a6f68f12dbd6913378de1f167cc59df86f2",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:"c6d6fd56d5ea9b01983578e6a182c71e80156088",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:"89553d48fa3519fe42ea3ad3f6a8d4de90db9c66","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:"4a4ae482c3095537b30be245c4aabc9d5c65902d","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:"94ccf98dadf388302f8269a822accac872c1a1bb",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"dc167d95b9aa12f1a8034af58d652671d345c07e",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"98b1b8d1b2cc4547be2862db89f684a7278184b2",titleBtn:"Log in",disabled:state.isLoading,onClick:e=>this.handleLogin(e)},state.isLoading&&h("span",{key:"2edccf4b93a7daf6bb33b0ff373248ee1ff84970",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$s()}}))}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:"ab72934e6f777bd62e5065cee268b2dff4209a05"},h("div",{key:"c8b77eac4c36dc67d1e550dbef1969aefa0db3b9",class:"p-4 overflow-y-auto"},h("h1",{key:"711b4d81bc446a4e1925ea6772d8724492410492",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h("p",{key:"1bd45ccdcf760a0428e979bea6cd5d4946efa440",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"1c086de3f2d458c9f3163314e17ee056bd30b89e",class:"max-w-72 mx-auto"},h("div",{key:"29baadba904448aff56f5b490e4684b4f5669817",class:"relative mb-2"},h("input",{key:"85a2266a004e7832f3a8bf6586fdab68364441ed",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:"d563c7cdd5c7dd560d7a3c6c5e5b7a36798d2fe3",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:"57bf5e498bb4ce520de1665555618be2a191660a",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:"354d1a2b42d1590430b13b63fa8b54d365743d17","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:"3fd555ef4b8ef4d6d38fa8d417c0c8745412b70a","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:"47991d46b02ede704b99e3958e81871cc733a874",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"9bf3a572a89d85d5da61c6665060b5f5b2e8f46c",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"bee14c47813853dcdcba90ae29a10cded60e902a",titleBtn:"Log in",disabled:state.isLoading,onClick:e=>this.handleLogin(e)},state.isLoading&&h("span",{key:"acf228ea98993476107e394f6a74f27a5b6efa84",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$s()}}))}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:"100d9330a518e02431bd21dce3247225d2e148a6"},h("div",{key:"f6ca0cc88094790a2ec0dd7ee8e03073b5aed315",class:"p-4 overflow-y-auto"},h("h1",{key:"341daf884a33b81946265dd688910e411b87f90a",class:"nl-title font-bold text-center text-2xl"},this.titleSignup),h("p",{key:"9e8a890c91b026739a71b00a06ba0dd6c52a0a94",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"0d1cae8ceea504f40f49fff35d3a3e2162801c48",class:"max-w-72 mx-auto"},h("div",{key:"0aa970acebd3392d3c2b91a57bf18982397cbfd2",class:"relative mb-2"},h("input",{key:"861f95f3dfe8cbedaeabe5e80d310cee8ec6b3ef",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:"687cd576c83a67e4ad946da7d675153eb1c249cd",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:"d870596edf59c8d747c08d887af7d3b33060f9f4",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:"2669def09130b54c40ab3fb9ac044490c6465e32","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:"b2dbdd050024352b399a7fb1925dd530680d1b3a",class:"mb-2"},h("nl-select",{key:"c6f4c4a5c5854a1980ab67dd43958dc5120ba0aa",onSelectDomain:e=>this.handleDomainSelect(e),selected:0,options:state.nlSignup.servers})),h("div",{key:"e92991946bcf756880fb607365e8415943af393e",class:"ps-4 pe-4 overflow-y-auto"},h("p",{key:"8e5d4f08c0996a5b80364ab2abfcbf869a45a066",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h("button-base",{key:"04a486b8a81f3750d048362689365b3a975ef0d1",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$s();break;case"nl-select":customElements.get(e)||defineCustomElement$n()}}))}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:"6f0a48d82976e4148caf8ff8c4a000355696de48"},h("div",{key:"ceaf09713ee4cdd7fba07db76aa64b3e7aabef52",class:"p-4 overflow-y-auto"},h("h1",{key:"dee6b8c58bed8216c8929550231860b7fab9600f",class:"nl-title font-bold text-center text-4xl"},this.titleWelcome),h("p",{key:"d63d6c7f040b32886f4a2c165640cbff5bae525f",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"bdfd30799af7e1c0d003cbce2e1c97f0c4d8345e",class:"max-w-52 mx-auto pb-5"},h("div",{key:"c1845b8823b5992647eedc8d0de4106adad2905f",class:"flex gap-3 flex-col mb-2"},h("button-base",{key:"92a35fd59f02a3f1b35757f36a111e6978dccd4e",titleBtn:"Log in",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.WELCOME_LOGIN)},h("svg",{key:"1fbcbe9b48913334b7cb96571d527de2ede1083f",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:"0cebc8b3d0747c9598d08b6b81f95e5dd1a325c1","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:"1d94662ed04041cf8246ba75792c88288694769d",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.WELCOME_SIGNUP),titleBtn:"Sign up"},h("svg",{key:"4b610e3752bc18c40f2afb2385d3ec64ee71f656",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:"23f217c6d17f81aa55bdc153bc8fb26dcebae9dc","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$s()}}))}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:"037b8d2ba99338efd13be6a1ec49accace64218b"},h("div",{key:"cedab2e7f1a4b8df177d5b6fd4c609aa45ff5965",class:"p-4 overflow-y-auto"},h("h1",{key:"0bbae7bd31433baa6f8572cd7fdcd60b64cb3abb",class:"nl-title font-bold text-center text-3xl"},this.titleWelcome)),h("div",{key:"d1cd467c79e0034e93522045990f7d1f10e95f42",class:"max-w-52 mx-auto pb-5"},h("div",{key:"f89c6551de4b27d04f07051049093c43bd77dd9b",class:"flex gap-3 flex-col"},this.allowAuthMethod("connect")&&h("button-base",{key:"a86482667df33e31dff35544364576cd0fbeec0b",titleBtn:"Connect",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.CONNECT)},h("svg",{key:"b0b8f37580302000950c4a89a0239132b1aca88a",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:"feef73e7c96f9f494abc9f3946c2c96446c117fb","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:"75cb54d6ba1961239c89f2e2e0699a0f7a3b3841",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN_READ_ONLY),titleBtn:"Read only"},h("svg",{key:"4d3741e46c24963e3373d308916e04f1b9cdddad",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:"109481732e23a555dabb8bd2aaf072984ac2642c","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:"7c571b8540f5d4f89c3f10c05d1f029cb2184e84","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:"b3f78d5917f4efef7551e093d6cb5ef3d906eaa6",titleBtn:"One-time code",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN_OTP)},h("svg",{key:"f4dac958561ba1710d262cb07886f9dc15ebeb9e",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:"da957eadb59492f7c907b35dd20a4eb5bdabe559","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(),h("button-base",{key:"fa26358ebee467e4926b3a820c38a34b6f2ea1b4",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN_NSEC),titleBtn:"With nsec"},h("svg",{key:"b3a248c229e2571c038a88c8d93c802927ec2b43",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:"ac007bbc3bf0e6e8654fdcaa57cfbdecf1f67fb9","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"}))),!this.allowAuthMethod("connect")&&!this.hasExtension&&h("p",{key:"fa06ff007947dee35315b6311097fc03cc55da78",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:"0080e835c7024ed6f867f96399b604651ea74483",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$s()}}))}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:"164e5da760f1609d604bbc85867bd3ae788ce924"},h("div",{key:"03691d670c29b844cae9a771c12c37b1e9540e95",class:"p-4 overflow-y-auto"},h("h1",{key:"0b60f6cf4c8a9cd9ecf3161c64761c7d7c9fb57e",class:"nl-title font-bold text-center text-3xl"},this.titleWelcome),h("p",{key:"91a2e92660873d45f2e92d60a0a7adc3114a0d8d",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},this.description)),h("div",{key:"a14d1a9ac594806be23679b59d9081e2ec1ef92d",class:"max-w-52 mx-auto pb-5"},h("div",{key:"6c8c856efe85e19a3a432c856ddd658aea7e2bd2",class:"flex gap-3 flex-col"},h("button-base",{key:"50c470453b16b552a4070c451f57baa4e366eb7d",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOCAL_SIGNUP),titleBtn:"Create keys"},h("svg",{key:"da1d5889dbbc208bafed0d460a65cae6523b2269",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:"ccae3b5c13c1953fe47f5fe416d35b031cf84c3d","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:"6a557e8d6f926fd0f185c280ae4a372139f8aa5b",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.SIGNUP),titleBtn:"With key store"},h("svg",{key:"08ea855bea4186d1f73a6fde7264585930fe6f91",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:"4cc3dc620843a3a970f558b8702ad109411eaf0c","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$s()}}))}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,o=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.LOGIN_NSEC:return h("nl-signin-nsec",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"),".")):o&&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-nip46-relay-settings","nl-otp-migrate","nl-previously-logged","nl-select","nl-signin","nl-signin-bunker-url","nl-signin-connection-string","nl-signin-nsec","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$s();break;case"nl-confirm-logout":customElements.get(e)||defineCustomElement$r();break;case"nl-connect":customElements.get(e)||defineCustomElement$p();break;case"nl-iframe":customElements.get(e)||defineCustomElement$o();break;case"nl-import-flow":customElements.get(e)||defineCustomElement$m();break;case"nl-info":customElements.get(e)||defineCustomElement$l();break;case"nl-info-extension":customElements.get(e)||defineCustomElement$k();break;case"nl-loading":customElements.get(e)||defineCustomElement$j();break;case"nl-local-signup":customElements.get(e)||defineCustomElement$i();break;case"nl-login-status":customElements.get(e)||defineCustomElement$h();break;case"nl-nip46-relay-settings":customElements.get(e)||defineCustomElement$q();break;case"nl-otp-migrate":customElements.get(e)||defineCustomElement$g();break;case"nl-previously-logged":customElements.get(e)||defineCustomElement$f();break;case"nl-select":customElements.get(e)||defineCustomElement$n();break;case"nl-signin":customElements.get(e)||defineCustomElement$e();break;case"nl-signin-bunker-url":customElements.get(e)||defineCustomElement$d();break;case"nl-signin-connection-string":customElements.get(e)||defineCustomElement$c();break;case"nl-signin-nsec":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$s()}}))}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,o=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"}):o?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$h()}}))}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:"236049861cbba1f18e4bccfed48d3211aaefabec",ref:e=>this.dialogElement=e,class:"m-auto nl-banner-dialog",style:{border:"0",backgroundColor:"transparent"}},h("slot",{key:"b0396bb61e95d6ea66ad520e68c84f917de9db8a"}))}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.handleCancelTimeout=createEvent$1(this,"handleCancelTimeout"),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,o,r;this.isOpen=!0,this.isOpenConfirm=!0,this.domain=(null===(t=this.userInfo)||void 0===t?void 0:t.domain)||(null===(r=null===(o=null===(n=this.userInfo)||void 0===n?void 0:n.nip05)||void 0===o?void 0:o.split("@"))||void 0===r?void 0:r[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,o,r,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===(r=null===(o=null===(n=this.userInfo)||void 0===n?void 0:n.nip05)||void 0===o?void 0:o.split("@"))||void 0===r?void 0:r[0])||(null===(s=this.userInfo)||void 0===s?void 0:s.pubkey)||"",c=Boolean(a),l=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"})),d=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?l:h("img",{class:"w-full rounded-full",src:this.userInfo.picture,alt:"Logo",onError:()=>this.isUserImgError=!0}):c?a[0]:l):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("div",null,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 mb-2"},"Go to ",this.domain),h("button-base",{onClick:()=>{this.handleCancelTimeout.emit(),this.handleClose()},titleBtn:"Cancel"})):"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),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 u=function e(t,n){n=n||document.body;const o=Array.from(n.querySelectorAll(t)),r=function(n){e(t,n).forEach((e=>{o.includes(e)||o.push(e)}))};n.shadowRoot&&r(n.shadowRoot);for(const e of Array.from(n.querySelectorAll("*")))e.shadowRoot&&r(e.shadowRoot);return o}("dialog"),f=!!u.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&&f?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`},d)):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`},d)))}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$s();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$h()}}))}defineCustomElement();var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},lib={},types={};Object.defineProperty(types,"__esModule",{value:!0});var ee={},taskCollection$1={},taskCollection={},utils$1={};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$1,"__esModule",{value:!0}),utils$1._fast_remove_single=void 0,utils$1._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="",o="",r=0;r<t;++r)n+="var f".concat(r," = collection[").concat(r,"];\n"),o+="f".concat(r,"(").concat(e,")\n");return{funcDefCode:n,funcCallCode:o}}function generateBodyPartsVariadicCode(e){for(var t="",n="",o=0;o<e;++o)t+="var f".concat(o," = collection[").concat(o,"];\n"),n+="f".concat(o,".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 o,r=0,s=t.length;r<s;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))};Object.defineProperty(taskCollection,"__esModule",{value:!0}),taskCollection.TaskCollection=void 0;var utils_1$1=utils$1,bake_collection_1=bakeCollection;function push_norebuild(e,t){var n,o=this.length;if(o>1)t?((n=this._tasks).push.apply(n,arguments),this.length+=arguments.length):(this._tasks.push(e),this.length++);else if(t){var r;if(1===o)(r=Array(1+arguments.length)).push(r),r.push.apply(r,arguments),this._tasks=r;else(r=Array(arguments.length)).push.apply(r,arguments),this._tasks=r;this.length+=arguments.length}else this._tasks=1===o?[this._tasks,e]:e,this.length++}function push_rebuild(e,t){var n,o=this.length;if(o>1)t?((n=this._tasks).push.apply(n,arguments),this.length+=arguments.length):(this._tasks.push(e),this.length++);else if(t){var r;if(1===o)(r=Array(1+arguments.length)).push(r),r.push.apply(r,arguments),this._tasks=r;else(r=Array(arguments.length)).push.apply(r,arguments),this._tasks=r;this.length+=arguments.length}else this._tasks=1===o?[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=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];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=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];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,o){void 0===t&&(t=!0),void 0===n&&(n=null),void 0===o&&(o=!1),this.awaitTasks=o,this.call=bake_collection_1.BAKED_EMPTY_FUNC,this.argsNum=e,this.firstEmitBuildStrategy=!0,this.rebuild=o?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,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),n=commonjsGlobal&&commonjsGlobal.__exportStar||function(e,n){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(n,o)||t(n,e,o)};Object.defineProperty(e,"__esModule",{value:!0}),n(taskCollection,e)}(taskCollection$1);var utils={};function nullObj(){var e={__proto__:null};return e}Object.defineProperty(utils,"__esModule",{value:!0}),utils.nullObj=void 0,utils.nullObj=nullObj;var __spreadArray=commonjsGlobal&&commonjsGlobal.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var o,r=0,s=t.length;r<s;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))};Object.defineProperty(ee,"__esModule",{value:!0}),ee.EventEmitter=void 0;var task_collection_1=taskCollection$1,utils_1=utils$1,utils_2=utils;function emit(e,t,n,o,r,s){var i=this.events[e];if(i){if(0===i.length)return!1;if(i.argsNum<6)i.call(t,n,o,r,s);else{for(var a=new Array(i.argsNum),c=0,l=a.length;c<l;++c)a[c]=arguments[c+1];i.call.apply(void 0,a)}return!0}return!1}function emitHasOnce(e,t,n,o,r,s){var i,a=this.events[e];if(void 0!==a){if(0===a.length)return!1;if(a.argsNum<6)a.call(t,n,o,r,s);else{for(var c=0,l=(i=new Array(a.argsNum)).length;c<l;++c)i[c]=arguments[c+1];a.call.apply(void 0,i)}}var d=this.onceEvents[e];if(d){if("function"==typeof d)if(this.onceEvents[e]=void 0,arguments.length<6)d(t,n,o,r,s);else{if(void 0===i)for(c=0,l=(i=new Array(arguments.length-1)).length;c<l;++c)i[c]=arguments[c+1];d.apply(void 0,i)}else{var h=d;if(this.onceEvents[e]=void 0,arguments.length<6)for(c=0;c<h.length;++c)h[c](t,n,o,r,s);else{if(void 0===i)for(c=0,l=(i=new Array(arguments.length-1)).length;c<l;++c)i[c]=arguments[c+1];for(c=0;c<h.length;++c)h[c].apply(void 0,i)}}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 o=this.events[e];return o?(o.push(t),o.growArgsNum(n),this.maxListeners!==1/0&&this.maxListeners<=o.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 o=this.onceEvents[e];return o&&("function"==typeof o?this.onceEvents[e]=void 0:"object"==typeof o&&(1===o.length&&o[0]===t?this.onceEvents[e]=void 0:(0,utils_1._fast_remove_single)(o,o.lastIndexOf(t)))),this}function addListenerBound(e,t,n,o){void 0===n&&(n=this),void 0===o&&(o=t.length),this.boundFuncs||(this.boundFuncs=new Map);var r=t.bind(n);return this.boundFuncs.set(t,r),this.addListener(e,r,o)}function removeListenerBound(e,t){var n,o,r=null===(n=this.boundFuncs)||void 0===n?void 0:n.get(t);return null===(o=this.boundFuncs)||void 0===o||o.delete(t),this.removeListener(e,r)}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 o=this.events[e];return o&&o instanceof task_collection_1.TaskCollection?(o.insert(0,t),o.growArgsNum(n),this.maxListeners!==1/0&&this.maxListeners<=o.length&&console.warn('Maximum event listeners for "'.concat(String(e),'" event!'))):(o=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)}
|
|
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$2=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$1,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$1(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$1=(e,t,...n)=>{let r=null,o=null,s=null,i=!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&&((i="function"!=typeof e&&!isComplexType(r))&&(r=String(r)),i&&a?c[c.length-1].$text$+=r:c.push(i?newVNode(null,r):r),a=i)};if(l(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,c,vdomFnUtils);const d=newVNode(e,null);return d.$attrs$=t,c.length>0&&(d.$children$=c),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$1(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$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},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 c=isComplexType(r);if((i||c&&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 l=!1;a!==(a=a.replace(/^xlink\:?/,""))&&(t=a,l=!0),null==r||!1===r?!1===r&&""!==e.getAttribute(t)||(l?e.removeAttributeNS(XLINK_NS,t):e.removeAttribute(t)):(!i||4&s||o)&&!c&&(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,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,c,l=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(l=0;l<s.$children$.length;++l)a=createElm(e,s,l,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,c=e&&e.$children$&&e.$children$[n],c&&c.$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,c=0,l=0,d=0,u=t.length-1,h=t[0],f=t[u],p=r.length-1,g=r[0],m=r[p];for(;a<=u&&c<=p;)if(null==h)h=t[++a];else if(null==f)f=t[--u];else if(null==g)g=r[++c];else if(null==m)m=r[--p];else if(isSameVnode(h,g,o))patch(h,g,o),h=t[++a],g=r[++c];else if(isSameVnode(f,m,o))patch(f,m,o),f=t[--u],m=r[--p];else if(isSameVnode(h,m,o))"slot"!==h.$tag$&&"slot"!==m.$tag$||putBackInOriginalLocation(h.$elm$.parentNode,!1),patch(h,m,o),insertBefore(e,h.$elm$,f.$elm$.nextSibling),h=t[++a],m=r[--p];else if(isSameVnode(f,g,o))"slot"!==h.$tag$&&"slot"!==m.$tag$||putBackInOriginalLocation(f.$elm$.parentNode,!1),patch(f,g,o),insertBefore(e,f.$elm$,h.$elm$),f=t[--u],g=r[++c];else{for(l=-1,d=a;d<=u;++d)if(t[d]&&null!==t[d].$key$&&t[d].$key$===g.$key$){l=d;break}l>=0?(i=t[l],i.$tag$!==g.$tag$?s=createElm(t&&t[c],n,l,e):(patch(i,g,o),t[l]=void 0,s=i.$elm$),g=r[++c]):(s=createElm(t&&t[c],n,c,e),g=r[++c]),s&&insertBefore(parentReferenceNode(h.$elm$),s,referenceNode(h.$elm$))}a>u?addVnodes(e,null==r[p+1]?null:r[p+1].$elm$,n,r,c,p):c>p&&removeVnodes(t,a,u)},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 c;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)):(c=r["s-cr"])?c.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 c=e.$hostElement$,l=e.$cmpMeta$,d=e.$vnode$||newVNode(null,null),u=isHost(t)?t:h$1(null,null,t);if(hostTagName=c.tagName,l.$attrsToReflect$&&(u.$attrs$=u.$attrs$||{},l.$attrsToReflect$.map((([e,t])=>u.$attrs$[t]=c[e]))),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$),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"]){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&l.$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$,c=s;n=parsePropertyValue(n,r.$members$[t][0]);const l=Number.isNaN(i)&&Number.isNaN(n);if(n!==i&&!l){if(o.$instanceValues$.set(t,n),r.$watchers$&&128&a){const e=r.$watchers$[t];e&&e.map((e=>{try{c[e](n,i,t)}catch(e){consoleError(e,s)}}))}if(2==(18&a)){if(c.componentShouldUpdate&&!1===c.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.LOGIN_NSEC="login-nsec",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))))},c="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)}),l=(e,t)=>(o[e].push(t),()=>{removeFromArray(o[e],t)});return{state:c,get:i,set:a,on:l,onChange:(t,n)=>{const r=l("set",((e,r)=>{e===t&&n(r)})),o=l("reset",(()=>n(unwrap(e)[t])));return()=>{r(),o()}},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:()=>{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},loadCustomRelays=()=>{try{const e=localStorage.getItem("customNip46Relays");if(e){const t=JSON.parse(e);if(Array.isArray(t)&&t.length>0)return t}}catch(e){console.error("Failed to load custom relays from localStorage",e)}return["wss://relay.nsec.app/","wss://ephemeral.snowflare.cc/"]},{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:"",customNip46Relays:loadCustomRelays(),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:""},nlSigninNsec:{nsecValue:""},nlImport:null});onChange("customNip46Relays",(e=>{try{localStorage.setItem("customNip46Relays",JSON.stringify(e))}catch(e){console.error("Failed to save custom relays to localStorage",e)}})),onChange("screen",(()=>{state.error="",state.nlSignin.loginName="",state.nlSignup.signupName="",state.nlSignup.domain="",state.nlSigninNsec.nsecValue=""}));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-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))}.left-0{left:0}.start-0{inset-inline-start:0}.top-0{top:0}.z-\\[80\\]{z-index:80}.z-\\[81\\]{z-index:81}.h-full{height:100%}.max-w-96{max-width:384px}.flex-col{flex-direction:column}.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}.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-base{font-size:16px;line-height:24px}.font-light{font-weight:300}.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}}.mb-10{margin-bottom:40px}.ml-auto{margin-left:auto}.mr-auto{margin-right:auto}.mt-10{margin-top:40px}.h-20{height:80px}.w-20{width:80px}.border-\\[4px\\]{border-width:4px}.pe-4{padding-inline-end:16px}.ps-4{padding-inline-start:16px}.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}.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)}.mt-3{margin-top:12px}.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}.mb-3{margin-bottom:12px}.mb-4{margin-bottom:16px}.ml-2{margin-left:8px}.flex-1{flex:1 1 0%}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(4px*var(--tw-space-y-reverse));margin-top:calc(4px*(1 - var(--tw-space-y-reverse)))}.rounded{border-radius:.25rem}.bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity))}.bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity))}.py-1{padding-bottom:4px;padding-top:4px}.py-1\\.5{padding-bottom:6px;padding-top:6px}.text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity))}.text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity))}.text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity))}.text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.underline{text-decoration-line:underline}.hover\\:bg-blue-600:hover{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity))}.hover\\:text-blue-700:hover{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity))}.hover\\:text-gray-700:hover{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity))}.hover\\:text-red-700:hover{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity))}.dark\\:border-gray-600:is(.dark *){--tw-border-opacity:1;border-color:rgb(75 85 99/var(--tw-border-opacity))}.dark\\:bg-gray-700:is(.dark *){--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity))}.dark\\:bg-gray-800:is(.dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity))}.dark\\:text-blue-400:is(.dark *){--tw-text-opacity:1;color:rgb(96 165 250/var(--tw-text-opacity))}.dark\\:text-gray-100:is(.dark *){--tw-text-opacity:1;color:rgb(243 244 246/var(--tw-text-opacity))}.dark\\:text-gray-400:is(.dark *){--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.dark\\:text-red-400:is(.dark *){--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity))}.dark\\:hover\\:text-blue-300:hover:is(.dark *){--tw-text-opacity:1;color:rgb(147 197 253/var(--tw-text-opacity))}.dark\\:hover\\:text-gray-300:hover:is(.dark *){--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity))}.dark\\:hover\\:text-red-300:hover:is(.dark *){--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity))}.mt-1{margin-top:4px}.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}.p-2{padding:8px}.py-2{padding-bottom:8px;padding-top:8px}.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}.ml-auto,.mx-auto{margin-left:auto}.h-1\\.5{height:6px}.h-3{height:12px}.w-1\\.5{width:6px}.w-3{width:12px}.max-w-6{max-width:24px}.max-w-7{max-width:28px}.gap-0\\.5{gap:2px}.overflow-hidden{overflow:hidden}.border-2{border-width:2px}.border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity))}.border-gray-400{--tw-border-opacity:1;border-color:rgb(156 163 175/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-1\\.5{padding-bottom:6px}.pb-3{padding-bottom:12px}.pt-0{padding-top:0}.pt-5{padding-top:20px}.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))}.max-w-52{max-width:208px}.gap-3{gap:12px}.pb-5{padding-bottom:20px}.text-3xl{font-size:30px;line-height:36px}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity))}.end-0{inset-inline-end:0}.h-\\[20px\\]{height:20px}.w-\\[20px\\]{width:20px}.pe-11{padding-inline-end:44px}.mt-0\\.5{margin-top:2px}.items-start{align-items:flex-start}.border-yellow-400{--tw-border-opacity:1;border-color:rgb(250 204 21/var(--tw-border-opacity))}.bg-yellow-50{--tw-bg-opacity:1;background-color:rgb(254 252 232/var(--tw-bg-opacity))}.dark\\:border-yellow-600:is(.dark *){--tw-border-opacity:1;border-color:rgb(202 138 4/var(--tw-border-opacity))}.dark\\:bg-yellow-900\\/20:is(.dark *){background-color:rgba(113,63,18,.2)}.w-60{width:240px}.mt-0{margin-top:0}.max-h-0{max-height:0}.max-h-\\[500px\\]{max-height:500px}.cursor-default{cursor:default}.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))}.pb-1{padding-bottom:4px}.decoration-dashed{text-decoration-style:dashed}.opacity-50{opacity:.5}.grayscale{--tw-grayscale:grayscale(100%);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)}.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))}",buttonBaseCss=baseCss,ButtonBaseStyle0=buttonBaseCss,ButtonBase=proxyCustomElement(class extends H$2{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$1("div",{key:"1048576f0a9839c56cac030b1de7899b25b5f39e",class:`theme-${this.theme}`},h$1("div",{key:"ea29f74a1f7e4268802c6e4aaca5867dfd2e4c9b",class:"animate-spin-loading active"}),h$1("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$1("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$s(){if("undefined"==typeof customElements)return;["button-base"].forEach((e=>{if("button-base"===e)customElements.get(e)||customElements.define(e,ButtonBase)}))}defineCustomElement$s();const nlConfirmLogoutCss=baseCss,NlConfirmLogoutStyle0=nlConfirmLogoutCss,NlConfirmLogout$1=proxyCustomElement(class extends H$2{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$1("div",{key:"fe605f38f9d0a440fe53e21f19288c41e4762c22",class:"p-4 overflow-y-auto"},h$1("h1",{key:"84d14a59035515b2fd612d262400a038887a10d7",class:"nl-title font-bold text-center text-4xl"},this.titleModal),h$1("p",{key:"83ef73271c76309561be95e0207f8130d75a161c",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},this.description),h$1("div",{key:"fce0f132846beb95dd9e41357f5ab87be7229a56",class:"mt-3 ml-auto mr-auto w-60 flex flex-col gap-2"},h$1("button-base",{key:"c4fc722a7c98d84e797963ed7fe928164411b701",onClick:()=>this.handleBackUp(),titleBtn:"Backup keys",theme:"lemonade"}),h$1("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$r(){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$s()}}))}defineCustomElement$r();const nlNip46RelaySettingsCss=baseCss,NlNip46RelaySettingsStyle0=nlNip46RelaySettingsCss,FACTORY_DEFAULT_RELAYS=["wss://relay.nsec.app/","wss://ephemeral.snowflare.cc/"],NlNip46RelaySettings=proxyCustomElement(class extends H$2{constructor(){super(),this.__registerHost(),this.nlRelaysChanged=createEvent$1(this,"nlRelaysChanged"),this.defaultRelays=[...FACTORY_DEFAULT_RELAYS],this.relays=[],this.newRelay="",this.showSettings=!1}componentWillLoad(){this.relays=[...this.defaultRelays]}addRelay(){const e=this.newRelay.trim();e&&(e.startsWith("wss://")||e.startsWith("ws://"))&&(this.relays.includes(e)||(this.relays=[...this.relays,e],this.newRelay="",this.nlRelaysChanged.emit(this.relays)))}removeRelay(e){this.relays=this.relays.filter(((t,n)=>n!==e)),this.nlRelaysChanged.emit(this.relays)}resetToDefaults(){this.relays=[...FACTORY_DEFAULT_RELAYS],this.nlRelaysChanged.emit(this.relays)}render(){return h$1("div",{key:"b21c3d9935218ccd1d552b9f635bd2a5577f50c0",class:"nip46-relay-settings mb-4"},h$1("button",{key:"aa9bd7bb3bd4310b1a02edfc1c010a7907dc79ce",type:"button",class:"text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 underline cursor-pointer",onClick:()=>this.showSettings=!this.showSettings},this.showSettings?"▼":"▶"," Advanced: Relay Settings"),this.showSettings&&h$1("div",{key:"bfafd2a8bfae6b9829c553f286d5d80f16011b2e",class:"mt-2 p-3 border border-gray-300 dark:border-gray-600 rounded bg-gray-50 dark:bg-gray-800"},h$1("div",{key:"6bcfc31c24f3eb074e0101cdb319b19806550db9",class:"flex justify-between items-center mb-2"},h$1("div",{key:"32d87ef74ecfd3f330ce88ab1802878bed40d680",class:"text-xs font-semibold text-gray-700 dark:text-gray-300"},"Nip46 Relays:"),h$1("button",{key:"26c7843cff229b73d33e86238eadbbdbde33955e",type:"button",class:"text-xs text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 underline cursor-pointer",onClick:()=>this.resetToDefaults()},"Reset to defaults")),h$1("ul",{key:"d6419de90eb296e91df6e6ede131d41c22d9e0e8",class:"text-xs mb-3 space-y-1"},this.relays.map(((e,t)=>h$1("li",{class:"flex justify-between items-center py-1 px-2 bg-white dark:bg-gray-700 rounded"},h$1("span",{class:"truncate text-gray-700 dark:text-gray-300 flex-1"},e),h$1("button",{type:"button",class:"ml-2 text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 font-bold cursor-pointer",onClick:()=>this.removeRelay(t),title:"Remove relay"},"✕"))))),h$1("div",{key:"0544da279bb32591f78dff61ecb5372e3a069b06",class:"flex gap-2"},h$1("input",{key:"eaf3009c8d711dbbf6bc0a3f954e042d5865a669",type:"text",class:"flex-1 text-xs px-2 py-1.5 border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100",placeholder:"wss://relay.example.com",value:this.newRelay,onInput:e=>this.newRelay=e.target.value,onKeyPress:e=>{"Enter"===e.key&&(e.preventDefault(),this.addRelay())}}),h$1("button",{key:"1223d35e9155b6716715f0685777370e8afa32d1",type:"button",class:"text-xs px-3 py-1.5 bg-blue-500 hover:bg-blue-600 text-white rounded cursor-pointer",onClick:()=>this.addRelay()},"Add"))))}static get style(){return NlNip46RelaySettingsStyle0}},[0,"nl-nip46-relay-settings",{defaultRelays:[16],relays:[32],newRelay:[32],showSettings:[32]}]);function defineCustomElement$q(){if("undefined"==typeof customElements)return;["nl-nip46-relay-settings"].forEach((e=>{if("nl-nip46-relay-settings"===e)customElements.get(e)||customElements.define(e,NlNip46RelaySettings)}))}defineCustomElement$q();const nlConnectCss=baseCss,NlConnectStyle0=nlConnectCss,NlConnect=proxyCustomElement(class extends H$2{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$1(Fragment,{key:"7361ac64cb9b8b02f85a97bc8dc01e2c9ab8b01c"},h$1("div",{key:"6e9a8335ae521f6e9a67ed433cb9ca9501f2e062",class:"p-4 overflow-y-auto"},h$1("h1",{key:"3ba01b15367e43824fea55967fa949da53bd956c",class:"nl-title font-bold text-center text-3xl"},this.titleWelcome)),h$1("div",{key:"0a7995f42d602d73f3ad23bff7d8a6995763acbc",class:"p-4"},Boolean(this.connectionStringServices.length)&&h$1("div",{key:"dd90d4a123c1940aa4cace1291262811d21352a8",class:"max-w-96 mx-auto pt-5"},h$1("p",{key:"2e122c0d1274fe996f37aadb54e2b1135084b906",class:"nl-description font-medium text-sm pb-1.5"},"Select key store:"),h$1("ul",{key:"54c38861f6bbb2eb1198ad8a7aeddd38104b33e4",class:"p-2 rounded-lg border border-gray-200 flex flex-col w-full gap-0.5"},this.connectionStringServices.map((e=>{const t="loading"===e.available,n=!1===e.available,r=t||n;return h$1("li",{class:r?"opacity-50 pointer-events-none":""},h$1("a",{href:r?void 0:e.link,target:"_blank",onClick:t=>{r?t.preventDefault():this.handleOpenLink(t,e)},class:"flex items-center gap-x-3.5 w-full py-2 px-3 rounded-lg text-sm justify-between "+(r?"cursor-default":"hover:bg-gray-300 cursor-pointer")},h$1("div",{class:"w-full max-w-7 h-7 flex relative"},h$1("div",{class:"uppercase font-bold w-full h-full rounded-full border border-gray-400 flex justify-center items-center"},Boolean(e.img)?h$1("img",{class:"w-full rounded-full "+(n?"grayscale":""),src:e.img,alt:e.name}):h$1("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$1("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$1("div",{class:"overflow-hidden flex flex-col w-full"},h$1("div",{class:"nl-title truncate overflow-hidden"},e.name,t&&h$1("span",{class:"nl-description text-xs ml-2"},"checking..."),n&&h$1("span",{class:"nl-description text-xs ml-2"},"offline")))))}))))),h$1("div",{key:"c372f1e8bd0cceb7b9660612eb6158d5ec625d3e",class:"ps-4 pe-4 overflow-y-auto"},h$1("p",{key:"0b6c50602854cf06554c92505cfce1ef215e8f7d",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h$1("div",{key:"a67dd79c1f13bdc0636a34e4f0c6c0df80293aa6",class:"max-w-72 mx-auto"},h$1("nl-nip46-relay-settings",{key:"0f358c327060445e14313331ca5e1ee8175d1493",defaultRelays:state.customNip46Relays,onNlRelaysChanged:e=>{state.customNip46Relays=e.detail}})),h$1("div",{key:"beccc66491904a50dc44c720fa5e32208e1ff61e",class:"max-w-52 mx-auto pb-5"},(this.allowAuthMethod("connect")||this.allowAuthMethod("readOnly"))&&h$1("div",{key:"7e670e898fd405c82cb749699a73d087525f4475",class:"flex justify-center"},h$1("div",{key:"634509b97941ceeda9338cc29d431dcafab17b04",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$1("svg",{key:"3e14d6c45fb72b1ad47beea455b36001ecb6c394",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$1("path",{key:"0ebce63b4caffd049c6e5a110792ca138e2e914b",d:"m6 9 6 6 6-6"})))),h$1("div",{key:"7d22deba5c378a53056eae0884e0d051504d7c5b",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$1("button-base",{key:"c4bbb92fcbf14048429099e26ab6e886a87e62f6",titleBtn:"User name",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN)},h$1("svg",{key:"8482dadd22930b1c17b328441a15609d41bc6c8d",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$1("path",{key:"ce5b427cba70a646c07ce61ea738765322e6c4ff","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$1("button-base",{key:"2859b956807892b0fcbbd88433733c7a905ad4f1",titleBtn:"Connection string",onClick:()=>this.handleConnectionString()},h$1("svg",{key:"8e2f155b9c5bfbec2f88a97013111739065c9914",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$1("path",{key:"3071eb6d992c31d5fb11a03ec5c3c9dabde9eff1","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$1("path",{key:"fa667a1e898b232c1db217d10458c926b559568f","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$1("button-base",{key:"5c66ae1e86bae7a9c3fbc975a92eefae2d4253ec",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN_BUNKER_URL),titleBtn:"Bunker URL"},h$1("svg",{key:"04d85bf0ac2f66b44a9ddd95815dd20d81935bad",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$1("path",{key:"763ef4a4f3f6f7807187e4d6aef8eecb7b858a44","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$p(){if("undefined"==typeof customElements)return;["nl-connect","button-base","nl-nip46-relay-settings"].forEach((e=>{switch(e){case"nl-connect":customElements.get(e)||customElements.define(e,NlConnect);break;case"button-base":customElements.get(e)||defineCustomElement$s();break;case"nl-nip46-relay-settings":customElements.get(e)||defineCustomElement$q()}}))}defineCustomElement$p();const nlIframeCss=baseCss,NlIframeStyle0=nlIframeCss,NlConfirmLogout=proxyCustomElement(class extends H$2{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$1("div",{key:"954ed56c0b6069cbcaae788121d82733c772e5d6",class:"p-4 overflow-y-auto"},h$1("div",{key:"4f62e37fc1d19d9da953eef1d5e7df66256c2e50",class:"mt-3 flex flex-col gap-2"},this.iframeUrl&&h$1("iframe",{key:"26aee24e31d903e2207b6664b29904fd5b94deac",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$o(){if("undefined"==typeof customElements)return;["nl-iframe"].forEach((e=>{if("nl-iframe"===e)customElements.get(e)||customElements.define(e,NlConfirmLogout)}))}defineCustomElement$o();const nlSelectCss=baseCss,NlSelectStyle0=nlSelectCss,NlSelect=proxyCustomElement(class extends H$2{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$1("div",{key:"c86084c50712455e04682a4392e490bc0e20eb1d",class:`theme-${this.themeState}`},h$1("div",{key:"a90d9b4af52845a9971c39cec69c13493d511381",class:"relative",ref:e=>this.wrapperRef=e},h$1("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$1("span",{key:"224425ab92ba3599595924972e98a0fc9cb1a189",class:"truncate overflow-hidden"},this.value.name),h$1("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$1("path",{key:"feea1a7f54f4a111b7bf01e3945445311b97ab82",d:"m6 9 6 6 6-6"}))),h$1("ul",{key:"fca4982f04f4133d5c2a2f613a7e7d977dd5c241",ref:e=>this.ulRef=e,class:e},this.options.map((e=>h$1("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$n(){if("undefined"==typeof customElements)return;["nl-select"].forEach((e=>{if("nl-select"===e)customElements.get(e)||customElements.define(e,NlSelect)}))}defineCustomElement$n();const nlImportFlowCss=baseCss,NlImportFlowStyle0=nlImportFlowCss,NlImportFlow$1=proxyCustomElement(class extends H$2{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$1("div",{class:"p-4 overflow-y-auto"},h$1("h1",{class:"nl-title font-bold text-center text-2xl"},this.titleInfo),h$1("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$1("br",null),h$1("br",null),"Your keys are currently only stored in this browser tab, and may be lost if you close it.",h$1("br",null),h$1("br",null),"You should backup your keys.",h$1("br",null),h$1("br",null),"We recommend to import your keys into a key store service, to protect them and to use with other apps."),h$1("div",{class:"ml-auto mr-auto mb-2 w-72"},h$1("button-base",{onClick:()=>this.handleContinue(),titleBtn:"Import to key store"})),h$1("div",{class:"ml-auto mr-auto w-72"},h$1("button-base",{onClick:()=>this.handleContinueKeyBackup(),titleBtn:"Export keys"})));if(this.isKeyBackup)return h$1("div",{class:"p-4 overflow-y-auto"},h$1("h1",{class:"nl-title font-bold text-center text-2xl"},"Key export"),h$1("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$1("br",null),h$1("br",null),"You can sign into other Nostr apps by pasting your keys into them.",h$1("br",null),h$1("br",null),"Your keys must be kept secret, never share them with anyone."),h$1("div",{class:"max-w-72 mx-auto"},h$1("div",{class:"ml-auto mr-auto mb-2 w-72"},h$1("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$1(Fragment,null,h$1("div",{class:"p-4 overflow-y-auto"},h$1("h1",{class:"nl-title font-bold text-center text-2xl"},this.titleImport),h$1("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$1("div",{class:"max-w-72 mx-auto mb-5"},h$1("div",{class:"mb-0.5"},h$1("nl-select",{onSelectDomain:e=>this.handleDomainSelect(e),selected:0,options:e})),h$1("p",{class:"nl-title font-light text-sm mb-2"},"Default provider is a fine choice to start with."),h$1("div",{class:"ps-4 pe-4 overflow-y-auto"},h$1("p",{class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h$1("button-base",{disabled:state.isLoading,onClick:e=>this.handleCreateAccount(e),titleBtn:"Start importing"},state.isLoading?h$1("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$1("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$1("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$m(){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$s();break;case"nl-select":customElements.get(e)||defineCustomElement$n()}}))}defineCustomElement$m();const nlInfoCss=baseCss,NlInfoStyle0=nlInfoCss,NlInfo=proxyCustomElement(class extends H$2{constructor(){super(),this.__registerHost()}render(){return h$1("div",{key:"ff51154f6dd944fd5de65bc2e8835c6b4b1cfa57",class:"p-4 overflow-y-auto"},h$1("svg",{key:"c04db0af7e108551b3b9de37dfe5c2175b6439f4",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$1("rect",{key:"6a4d8f9847e857973d4e089a74fec6f8e50fc09d",width:"224.047",height:"224",rx:"64",fill:"#6951FA"}),h$1("path",{key:"a5bddb82b767722286b2165bc03e6d7aec7fee98",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$1("h1",{key:"b3264a68c05a73a83c01c2e54c7088bb234ca40d",class:"nl-title font-bold text-center text-4xl"},"Nostr ",h$1("span",{key:"ace01503f2160f1589229fbc732c7b5cf5aeedcc",class:"font-light"},"Login")),h$1("p",{key:"204c3ce4a21857081eb6e65c4b4a8d5356ab2722",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$1("p",{key:"88790a07beaad70f1d6e77ce77b30b87c7a73f3c",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},"Learn more about Nostr"," ",h$1("a",{key:"129c8383ab18b01fba2b13c5b805435b24056e18",target:"_blank",href:"https://nostr.how"},"here"),".",h$1("br",{key:"8c1cca37a0992068c94a22ec8dea3e859db97e4a"}),"This is an"," ",h$1("a",{key:"eb270824dba82f0a707715724b165af90f86d25b",target:"_blank",href:"https://github.com/nostrband/nostr-login"},"open-source")," ","tool by"," ",h$1("a",{key:"d64434bf56e2083bf82ad90a2daf003a3c368ddc",target:"_blank",href:"https://nostr.band"},"Nostr.Band"),"."))}static get style(){return NlInfoStyle0}},[0,"nl-info"]);function defineCustomElement$l(){if("undefined"==typeof customElements)return;["nl-info"].forEach((e=>{if("nl-info"===e)customElements.get(e)||customElements.define(e,NlInfo)}))}defineCustomElement$l();const nlInfoExtensionCss=baseCss,NlInfoExtensionStyle0=nlInfoExtensionCss,NlInfoExtension=proxyCustomElement(class extends H$2{constructor(){super(),this.__registerHost()}render(){return h$1("div",{key:"1d919493f0e640d5394470dd77ad586c8ad949d4",class:"p-4 overflow-y-auto"},state.isLoadingExtension?h$1("div",null,h$1("h1",{class:"nl-title font-bold text-center text-4xl"},"Signing in..."),h$1("div",{class:"mt-10 mb-10 ml-auto mr-auto w-20"},h$1("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$1("div",{class:"ps-4 pe-4 overflow-y-auto"},h$1("p",{class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error))):h$1("div",null,h$1("h1",{class:"nl-title font-bold text-center text-4xl"},"Install browser extension!"),h$1("p",{class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},"Try"," ",h$1("a",{href:"https://getalby.com",target:"_blank"},"Alby"),","," ",h$1("a",{href:"https://chromewebstore.google.com/detail/nos2x/kpgefcfmnafjgpblomihpgmejjdanjjp",target:"_blank"},"nos2x")," ","or"," ",h$1("a",{href:"https://apps.apple.com/us/app/nostore/id1666553677",target:"_blank"},"Nostore"))))}static get style(){return NlInfoExtensionStyle0}},[0,"nl-info-extension"]);function defineCustomElement$k(){if("undefined"==typeof customElements)return;["nl-info-extension"].forEach((e=>{if("nl-info-extension"===e)customElements.get(e)||customElements.define(e,NlInfoExtension)}))}defineCustomElement$k();const nlLoadingCss=baseCss,NlLoadingStyle0=nlLoadingCss,NlLoading=proxyCustomElement(class extends H$2{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,o=state.iframeUrl?`${state.iframeUrl}?connect=${encodeURIComponent(state.authUrl)}`:"";return h$1("div",{key:"db647721e5ca60eed1502bf784f11973106938ff",class:"p-4 overflow-y-auto"},e&&h$1("h1",{key:"605d32178383840ea53a3fc16c2d760dccea0812",class:"nl-title font-bold text-center text-4xl"},e),t&&h$1("p",{key:"8dc819ba9544242ef05256a12f866cd88b3603cf",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},t),!state.njumpIframe&&!state.authUrl&&state.isLoading&&h$1("div",{key:"f392c2a856018c4d35b01a76b77f0eec8342fb86",class:"mt-10 mb-10 ml-auto mr-auto w-20"},h$1("span",{key:"90541216f412c9c8d77be8988c6f9e5b654ce115",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$1("div",{key:"a870a4e31048a13f400970aad850e7eab418ef06",class:"ps-4 pe-4 overflow-y-auto"},h$1("p",{key:"5bf2c4a5b94a4dfe1331a2fa5fb11ea4d414f353",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),o&&h$1("div",{key:"854f1920def8e2354801a819f9e564ae1658e34b",class:"mt-3 ml-auto mr-auto w-72 flex justify-center"},h$1("iframe",{key:"a5056dbe483013c20515b8c6576af60f612e132b",src:o,width:"180px",height:"80px",style:{display:r?"block":"none",border:"0"}})),state.njumpIframe&&h$1("div",{key:"848d0c6cf74610b8793ade84a5c1f32fd5944b62",class:"mt-3 ml-auto mr-auto flex justify-center"},h$1("iframe",{key:"456702bd5c9e9b290d532aef0ec245e1212ea79f",srcdoc:state.njumpIframe,width:"600px",style:{border:"0",height:"80vh",borderRadius:"8px"}})),n&&h$1("div",{key:"d7b82c1fd76a8cf4edf38d2cbe2386e2ce698a81",class:"mt-3 ml-auto mr-auto w-72"},h$1("button-base",{key:"8465e32b53c4b86e3b1b488fddcc5937a018768f",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$j(){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$s()}}))}defineCustomElement$j();const nlLocalSignupCss=baseCss,NlLocalSignupStyle0=nlLocalSignupCss,NlLocalSignup=proxyCustomElement(class extends H$2{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$1(Fragment,{key:"4e2e1cb4e43c985fbcc79af1b085389a38c2805d"},h$1("div",{key:"ed3e90f3eeef7d1354b6e36d8f29c7348176b989",class:"p-4 overflow-y-auto"},h$1("h1",{key:"8b47eb2e2221b61d8b75e297ae9b954cd2a0ef89",class:"nl-title font-bold text-center text-2xl"},this.titleSignup),h$1("p",{key:"af517d0c92652d1e4fd14f57bf593eb1510865e7",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.signupNjump?this.descriptionNjump:this.description)),h$1("div",{key:"54dd6ee361785bf45b760333104dc946a5a8f941",class:"max-w-72 mx-auto"},!this.signupNjump&&h$1("div",{key:"af4d8a26c1da84d2a07f1086c69b9776b361d484",class:"relative mb-2"},h$1("input",{key:"dc30806eefb1b2210e4960401de95578256becbd",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$1("div",{key:"64cfe0fe240b2e04216485915b3e6f034c5d0229",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$1("svg",{key:"434077af1de7ee510325e84b64bc02981b039792",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$1("path",{key:"5f9aae2d279fd8807b1798518f33da878e30f8ff","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$1("div",{key:"39115be409b0cc01e098e05fdeb370e15673f8e1",class:"ps-4 pe-4 overflow-y-auto"},h$1("p",{key:"cd7556b84e69f372b6aa9c834794e5bded78c228",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h$1("button-base",{key:"d29de7bb01cf5fb0b3ba76b9cf52aa846e3db638",disabled:state.isLoading,onClick:e=>this.handleCreateAccount(e),titleBtn:this.signupNjump?"Get started":"Create profile"},state.isLoading?h$1("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$1("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$1("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$i(){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$s()}}))}defineCustomElement$i();const NlLoginStatus=proxyCustomElement(class extends H$2{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$1("div",{key:"8b5236e4bc47388d9e55ff92b3c5837bd77833d6"},h$1("span",{key:"066cb55933afc54e17831a3fe4c6fbc4b66aec15",class:`${t} rounded-xl border w-auto text-[10px] px-1 `},e))}},[0,"nl-login-status",{info:[16]}]);function defineCustomElement$h(){if("undefined"==typeof customElements)return;["nl-login-status"].forEach((e=>{if("nl-login-status"===e)customElements.get(e)||customElements.define(e,NlLoginStatus)}))}defineCustomElement$h();const nlOtpMigrateCss=baseCss,NlOtpMigrateStyle0=nlOtpMigrateCss,NlImportFlow=proxyCustomElement(class extends H$2{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$1(Fragment,{key:"12693d07250ca52865a5a04d454e11e43b651e13"},h$1("div",{key:"1fa49c196cfb54cc7da20925dc61490d3cea4f1d",class:"p-4 overflow-y-auto"},h$1("h1",{key:"ff29ef7de0954e75bf17ee260eea556ba364ecdd",class:"nl-title font-bold text-center text-2xl"},this.titleImport),h$1("p",{key:"626e164f92be79d655384e631c982bc4e06fdbfc",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.textImport)),h$1("div",{key:"7d3b75101d0531c41a7bfcbb5ece1ffa67821810",class:"max-w-72 mx-auto mb-5"},h$1("div",{key:"7a11b1c4668f0172ce4535fe0c4931221b147509",class:"mb-0.5"},h$1("nl-select",{key:"1c7dbbd077d06f19745f2c53d1100b74e5498a17",onSelectDomain:e=>this.handleDomainSelect(e),selected:0,options:e})),h$1("p",{key:"da6a4528697951de8b31b4697ba9b19d71b33b4f",class:"nl-title font-light text-sm mb-2"},"Default provider is a fine choice to start with."),h$1("div",{key:"a57b965e8ad521ab36d81d8962a723ddfa735757",class:"ps-4 pe-4 overflow-y-auto"},h$1("p",{key:"cb748be936c8204d67b1fa49fe2f2f8ed11cb604",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h$1("button-base",{key:"dd31a190750a945c5a4f71830e8177bd7172a7bc",disabled:state.isLoading,onClick:e=>this.handleCreateAccount(e),titleBtn:"Start importing"},state.isLoading?h$1("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$1("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$1("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$g(){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$s();break;case"nl-select":customElements.get(e)||defineCustomElement$n()}}))}defineCustomElement$g();const nlPreviouslyLoggedCss=baseCss,NlPreviouslyLoggedStyle0=nlPreviouslyLoggedCss,NlPreviouslyLogged=proxyCustomElement(class extends H$2{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$1(Fragment,{key:"433be12e7eb9f18f10afa828a53920c85410940c"},h$1("div",{key:"080f439a9910e8fe8217a914d04e2a2cc8ca97ad",class:"p-4 pt-0 overflow-y-auto"},h$1("h1",{key:"332f960bc2b1727277dade6d5236f41f9a81116c",class:"nl-title font-bold text-center text-4xl"},this.titlePage),h$1("p",{key:"2a1fb42c969f6266eb782d3f4f01a935ff88d779",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},this.description)),h$1("div",{key:"679d3e53e352631f704c997c8ec206d122e4f8a6",class:"p-4"},Boolean(this.accounts.length)&&h$1("div",{key:"4f2d266c86cc05c5030c432eeb8611f12ccfe52b",class:"max-w-96 mx-auto"},h$1("p",{key:"94baf6a179142c0f3d6e0f15d2d98be35ee4cbcc",class:"nl-description font-medium text-sm pb-1.5"},"Active profiles"),h$1("ul",{key:"5d7971661fbb7e6cc992df82f73639d9d1b5c69d",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$1("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$1("div",{class:"flex items-center gap-x-3.5 w-full"},h$1("div",{class:"w-full max-w-7 h-7 flex relative"},h$1("div",{class:"absolute top-[-2px] right-[-2px] bg-white border-2 border-white rounded-xl"},h$1("div",{class:"active h-1.5 w-1.5 bg-green-500 rounded-xl"})),h$1("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$1("img",{class:"w-full rounded-full",src:e.picture,alt:"Logo"}):r?n[0]:h$1("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$1("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$1("div",{class:"overflow-hidden flex flex-col w-full"},h$1("div",{class:"nl-title truncate overflow-hidden"},n),h$1("nl-login-status",{info:e}))))})))),Boolean(this.recents.length)&&h$1("div",{key:"c66d7eda3b667f736052dc27709a343ddb74b54a",class:"max-w-96 mx-auto pt-5"},h$1("p",{key:"d31c7a93df4b7583cb00b4e0d55c1118adae0b32",class:"nl-description font-medium text-sm pb-1.5"},"Recent profiles"),h$1("ul",{key:"c03f0135c7e3dc4fe5db91aeff7cb8e1ccd436b6",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$1("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$1("div",{class:"w-full max-w-7 h-7 flex relative"},h$1("div",{class:"absolute top-[-3px] right-[-3px] bg-white border border-white rounded-xl"},h$1("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$1("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$1("div",{class:"uppercase font-bold w-full h-full rounded-full border border-gray-400 flex justify-center items-center"},t?h$1("img",{class:"w-full rounded-full",src:e.picture,alt:"Logo"}):r?n[0]:h$1("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$1("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$1("div",{class:"overflow-hidden flex flex-col w-full"},h$1("div",{class:"nl-title truncate overflow-hidden"},n),h$1("nl-login-status",{info:e})),h$1("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$1("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$1("div",{key:"bf85231e1b0cd2a3490564507ec9f41e9277a64f",class:"p-4 overflow-y-auto"},h$1("p",{key:"c88a893c3833de4ad97637abd10507b76921c0c5",class:"nl-footer font-light text-center text-sm max-w-96 mx-auto"},"You can also"," ",h$1("span",{key:"767425be179794ec16efe01c66f11d01954c70df",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$f(){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$h()}}))}defineCustomElement$f();const nlSigninCss=baseCss,NlSigninStyle0=nlSigninCss,NlSignin=proxyCustomElement(class extends H$2{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$1(Fragment,{key:"a498d75f074f6df3cda28a845c783cbd8568747a"},h$1("div",{key:"32c20383fd595cd977c5163f14806fd1dcdab210",class:"p-4 overflow-y-auto"},h$1("h1",{key:"4a0d7b438e34497072df509f8b7196342f30964c",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h$1("p",{key:"1a48de557c4544eb38c9c826848171cdcebead9f",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h$1("div",{key:"9c74d29c7f007f2dd3e795cfb3fbc3bccd03549a",class:"max-w-72 mx-auto"},h$1("div",{key:"97d4c6367bfa6bf581a3bb4283ee6d8958cbc7c6",class:"relative mb-2"},h$1("input",{key:"5b5ba0b7268576680f40508cfd2f6fa771cd1acd",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$1("div",{key:"971b0e66f94f20fa3406786e8f6fc66e858b82aa",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$1("svg",{key:"e267ffa5f7a5cf560732da01645f771c24555927",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$1("path",{key:"c694ee22fe4198b58f0d750cea98a34cf2a9bc14","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$1("div",{key:"41828dc382da40b4a7b11dc094d20f4913480a8a",class:"ps-4 pe-4 overflow-y-auto"},h$1("p",{key:"b619b41116fc3d6ae33363dd1be6ac67f3521f14",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h$1("button-base",{key:"81797cde8acbaf0aeeb204aa07885ba27f27c08d",titleBtn:"Connect",disabled:state.isLoading,onClick:e=>this.handleLogin(e)},state.isLoading?h$1("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$1("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$1("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$e(){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$s()}}))}defineCustomElement$e();class e{constructor(t,n,r,o,s){this._legacyCanvasSize=e.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),r&&"object"==typeof r?this._onDecode=n:(r||o||s?console.warn("You're using a deprecated version of the QrScanner constructor which will be removed in the future"):console.warn("Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=n),n="object"==typeof r?r:{},this._onDecodeError=n.onDecodeError||("function"==typeof r?r:this._onDecodeError),this._calculateScanRegion=n.calculateScanRegion||("function"==typeof o?o:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||s||this._preferredCamera,this._legacyCanvasSize="number"==typeof r?r:"number"==typeof o?o:this._legacyCanvasSize,this._maxScansPerSecond=n.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let i=!1;if(t.hidden&&(t.hidden=!1,i=!0),document.body.contains(t)||(document.body.appendChild(t),i=!0),r=t.parentElement,n.highlightScanRegion||n.highlightCodeOutline){if(o=!!n.overlay,this.$overlay=n.overlay||document.createElement("div"),(s=this.$overlay.style).position="absolute",s.display="none",s.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!o&&n.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch(e){}r.insertBefore(this.$overlay,this.$video.nextSibling)}n.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame((()=>{let e=window.getComputedStyle(t);"none"===e.display&&(t.style.setProperty("display","block","important"),i=!0),"visible"!==e.visibility&&(t.style.setProperty("visibility","visible","important"),i=!0),i&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),t.style.opacity="0",t.style.width="0",t.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()})),t.addEventListener("play",this._onPlay),t.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=e.createQrEngine()}static set WORKER_PATH(e){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await e.listCameras(!1)).length}catch(e){return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let n,r=async()=>(await navigator.mediaDevices.enumerateDevices()).filter((e=>"videoinput"===e.kind));try{t&&(await r()).every((e=>!e.label))&&(n=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch(e){}try{return(await r()).map(((e,t)=>({id:e.deviceId,label:e.label||(0===t?"Default Camera":`Camera ${t+1}`)})))}finally{n&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),e._stopVideoStream(n))}}async hasFlash(){let t;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;t=this.$video.srcObject}else t=(await this._getCameraStream()).stream;return"torch"in t.getVideoTracks()[0].getSettings()}catch(e){return!1}finally{t&&t!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),e._stopVideoStream(t))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!await this.hasFlash())throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(e){throw this._flashOn=!1,e}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),e._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&("https:"!==window.location.protocol&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:n}=await this._getCameraStream();!this._active||this._paused?e._stopVideoStream(t):(this._setVideoMirror(n),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch((()=>{}))))}catch(e){if(!this._paused)throw this._active=!1,e}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let n=()=>{this.$video.srcObject instanceof MediaStream&&(e._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(n(),!0):(await new Promise((e=>setTimeout(e,300))),!!this._paused&&(n(),!0))}async setCamera(e){e!==this._preferredCamera&&(this._preferredCamera=e,await this._restartVideoStream())}static async scanImage(t,n,r,o,s=!1,i=!1){let a,c=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(a=n.scanRegion,r=n.qrEngine,o=n.canvas,s=n.disallowCanvasResizing||!1,i=n.alsoTryWithoutScanRegion||!1,c=!0):n||r||o||s||i?console.warn("You're using a deprecated api for scanImage which will be removed in the future."):console.warn("Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),n=!!r;try{let l,d,u;if([r,l]=await Promise.all([r||e.createQrEngine(),e._loadImage(t)]),[o,d]=e._drawToCanvas(l,a,o,s),r instanceof Worker){let t=r;n||e._postWorkerMessageSync(t,"inversionMode","both"),u=await new Promise(((n,r)=>{let s,i,c,l=-1;i=o=>{o.data.id===l&&(t.removeEventListener("message",i),t.removeEventListener("error",c),clearTimeout(s),null!==o.data.data?n({data:o.data.data,cornerPoints:e._convertPoints(o.data.cornerPoints,a)}):r(e.NO_QR_CODE_FOUND))},c=e=>{t.removeEventListener("message",i),t.removeEventListener("error",c),clearTimeout(s),r("Scanner error: "+(e?e.message||e:"Unknown Error"))},t.addEventListener("message",i),t.addEventListener("error",c),s=setTimeout((()=>c("timeout")),1e4);let u=d.getImageData(0,0,o.width,o.height);l=e._postWorkerMessageSync(t,"decode",u,[u.data.buffer])}))}else u=await Promise.race([new Promise(((e,t)=>window.setTimeout((()=>t("Scanner error: timeout")),1e4))),(async()=>{try{var[n]=await r.detect(o);if(!n)throw e.NO_QR_CODE_FOUND;return{data:n.rawValue,cornerPoints:e._convertPoints(n.cornerPoints,a)}}catch(r){if(n=r.message||r,/not implemented|service unavailable/.test(n))return e._disableBarcodeDetector=!0,e.scanImage(t,{scanRegion:a,canvas:o,disallowCanvasResizing:s,alsoTryWithoutScanRegion:i});throw`Scanner error: ${n}`}})()]);return c?u:u.data}catch(n){if(!a||!i)throw n;let l=await e.scanImage(t,{qrEngine:r,canvas:o,disallowCanvasResizing:s});return c?l:l.data}finally{n||e._postWorkerMessage(r,"close")}}setGrayscaleWeights(t,n,r,o=!0){e._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:n,blue:r,useIntegerApproximation:o})}setInversionMode(t){e._postWorkerMessage(this._qrEnginePromise,"inversionMode",t)}static async createQrEngine(t){if(t&&console.warn("Specifying a worker path is not required and not supported anymore."),t=()=>Promise.resolve().then((function(){return qrScannerWorker_min})).then((e=>e.createWorker())),e._disableBarcodeDetector||!("BarcodeDetector"in window)||!BarcodeDetector.getSupportedFormats||!(await BarcodeDetector.getSupportedFormats()).includes("qr_code"))return t();let n=navigator.userAgentData;return n&&n.brands.some((({brand:e})=>/Chromium/i.test(e)))&&/mac ?OS/i.test(n.platform)&&await n.getHighEntropyValues(["architecture","platformVersion"]).then((({architecture:e,platformVersion:t})=>/arm/i.test(e||"arm")&&13<=parseInt(t||"13"))).catch((()=>!0))?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(e){let t=Math.round(2/3*Math.min(e.videoWidth,e.videoHeight));return{x:Math.round((e.videoWidth-t)/2),y:Math.round((e.videoHeight-t)/2),width:t,height:t,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame((()=>{if(this.$overlay){var e=this.$video,t=e.videoWidth,n=e.videoHeight,r=e.offsetWidth,o=e.offsetHeight,s=e.offsetLeft,i=e.offsetTop,a=window.getComputedStyle(e),c=a.objectFit,l=t/n,d=r/o;switch(c){case"none":var u=t,h=n;break;case"fill":u=r,h=o;break;default:("cover"===c?l>d:l<d)?u=(h=o)*l:h=(u=r)/l,"scale-down"===c&&(u=Math.min(u,t),h=Math.min(h,n))}var[f,p]=a.objectPosition.split(" ").map(((e,t)=>{const n=parseFloat(e);return e.endsWith("%")?(t?o-h:r-u)*n/100:n}));a=this._scanRegion.width||t,d=this._scanRegion.height||n,c=this._scanRegion.x||0;var g=this._scanRegion.y||0;(l=this.$overlay.style).width=a/t*u+"px",l.height=d/n*h+"px",l.top=`${i+p+g/n*h}px`,n=/scaleX\(-1\)/.test(e.style.transform),l.left=`${s+(n?r-f-u:f)+(n?t-c-a:c)/t*u}px`,l.transform=e.style.transform}}))}static _convertPoints(e,t){if(!t)return e;let n=t.x||0,r=t.y||0,o=t.width&&t.downScaledWidth?t.width/t.downScaledWidth:1;t=t.height&&t.downScaledHeight?t.height/t.downScaledHeight:1;for(let s of e)s.x=s.x*o+n,s.y=s.y*t+r;return e}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)((async()=>{if(!(1>=this.$video.readyState)){var t=Date.now()-this._lastScanTimestamp,n=1e3/this._maxScansPerSecond;t<n&&await new Promise((e=>setTimeout(e,n-t))),this._lastScanTimestamp=Date.now();try{var r=await e.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(e){if(!this._active)return;this._onDecodeError(e)}!e._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=e.createQrEngine()),r?(this._onDecode?this._onDecode(r):this._legacyOnDecode&&this._legacyOnDecode(r.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",r.cornerPoints.map((({x:e,y:t})=>`${e},${t}`)).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout((()=>this.$codeOutlineHighlight.style.display="none"),100))}this._scanFrame()}))}_onDecodeError(t){t!==e.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let e=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",t=[{width:{min:1024}},{width:{min:768}},{}],n=t.map((t=>Object.assign({},t,{[e]:{exact:this._preferredCamera}})));for(let e of[...n,...t])try{let t=await navigator.mediaDevices.getUserMedia({video:e,audio:!1});return{stream:t,facingMode:this._getFacingMode(t)||(e.facingMode?this._preferredCamera:"environment"===this._preferredCamera?"user":"environment")}}catch(e){}throw"Camera not found."}async _restartVideoStream(){let e=this._paused;await this.pause(!0)&&!e&&this._active&&await this.start()}static _stopVideoStream(e){for(let t of e.getTracks())t.stop(),e.removeTrack(t)}_setVideoMirror(e){this.$video.style.transform="scaleX("+("user"===e?-1:1)+")"}_getFacingMode(e){return(e=e.getVideoTracks()[0])?/rear|back|environment/i.test(e.label)?"environment":/front|user|face/i.test(e.label)?"user":null:null}static _drawToCanvas(e,t,n,r=!1){n=n||document.createElement("canvas");let o=t&&t.x?t.x:0,s=t&&t.y?t.y:0,i=t&&t.width?t.width:e.videoWidth||e.width,a=t&&t.height?t.height:e.videoHeight||e.height;return r||(r=t&&t.downScaledWidth?t.downScaledWidth:i,t=t&&t.downScaledHeight?t.downScaledHeight:a,n.width!==r&&(n.width=r),n.height!==t&&(n.height=t)),(t=n.getContext("2d",{alpha:!1})).imageSmoothingEnabled=!1,t.drawImage(e,o,s,i,a,0,0,n.width,n.height),[n,t]}static async _loadImage(t){if(t instanceof Image)return await e._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(!(t instanceof File||t instanceof Blob||t instanceof URL||"string"==typeof t))throw"Unsupported image type.";{let n=new Image;n.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await e._awaitImageLoad(n),n}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(n.src)}}}static async _awaitImageLoad(e){e.complete&&0!==e.naturalWidth||await new Promise(((t,n)=>{let r=o=>{e.removeEventListener("load",r),e.removeEventListener("error",r),o instanceof ErrorEvent?n("Image load error"):t()};e.addEventListener("load",r),e.addEventListener("error",r)}))}static async _postWorkerMessage(t,n,r,o){return e._postWorkerMessageSync(await t,n,r,o)}static _postWorkerMessageSync(t,n,r,o){if(!(t instanceof Worker))return-1;let s=e._workerMessageId++;return t.postMessage({id:s,type:n,data:r},o),s}}e.DEFAULT_CANVAS_SIZE=400,e.NO_QR_CODE_FOUND="No QR code found",e._disableBarcodeDetector=!1,e._workerMessageId=0;const nlSigninBunkerUrlCss=baseCss,NlSigninBunkerUrlStyle0=nlSigninBunkerUrlCss,NlSigninBunkerUrl=proxyCustomElement(class extends H$2{constructor(){super(),this.__registerHost(),this.nlLogin=createEvent$1(this,"nlLogin"),this.nlCheckLogin=createEvent$1(this,"nlCheckLogin"),this.videoEl=null,this.stream=null,this.scanInterval=null,this.titleLogin="Connect with bunker url",this.description="Please enter a bunker url provided by key store.",this.isGood=!1,this.isScanning=!1,this.scanError=""}handleInputChange(e){state.nlSigninBunkerUrl.loginName=e.target.value,this.nlCheckLogin.emit(e.target.value)}handleLogin(e){e.preventDefault(),this.nlLogin.emit(state.nlSigninBunkerUrl.loginName)}async startScan(){if(this.scanError="",this.isScanning=!0,await new Promise((e=>requestAnimationFrame((()=>requestAnimationFrame(e))))),!this.scannerContainer)return this.scanError="Camera not available",void(this.isScanning=!1);try{this.stream=await navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"},audio:!1}),this.videoEl=document.createElement("video"),this.videoEl.setAttribute("playsinline",""),this.videoEl.setAttribute("autoplay",""),this.videoEl.muted=!0,this.videoEl.style.width="100%",this.videoEl.style.height="100%",this.videoEl.style.objectFit="cover",this.videoEl.style.display="block",this.videoEl.srcObject=this.stream,this.scannerContainer.appendChild(this.videoEl),await this.videoEl.play(),this.scanInterval=setInterval((async()=>{if(this.videoEl&&!(this.videoEl.readyState<2))try{const t=(await e.scanImage(this.videoEl,{returnDetailedScanResult:!0})).data;t&&(t.startsWith("bunker://")||t.startsWith("nostrconnect://"))&&(state.nlSigninBunkerUrl.loginName=t,this.nlCheckLogin.emit(t),this.stopScan())}catch(e){}}),250)}catch(e){console.error("QR Scanner error:",e),this.scanError=e instanceof Error?e.message:"Failed to access camera",this.isScanning=!1}}stopScan(){this.scanInterval&&(clearInterval(this.scanInterval),this.scanInterval=null),this.stream&&(this.stream.getTracks().forEach((e=>e.stop())),this.stream=null),this.videoEl&&(this.videoEl.srcObject=null,this.videoEl.remove(),this.videoEl=null),this.isScanning=!1}disconnectedCallback(){this.stopScan()}render(){return h$1(Fragment,{key:"1ee10a09c7f6782b5f89530c9331a3144f73a8ba"},h$1("div",{key:"68b5bef4961ddc8cf24ef98f7452d8ae5b0f6aae",class:"p-4 overflow-y-auto"},h$1("h1",{key:"be4da63776a4fc4f2228b22e95a1f31380e6d0f6",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h$1("p",{key:"d2e9c469206c4e71544416760090751dbe33cb4b",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h$1("div",{key:"f2219e9bfc0262b5e1bfcfb3761515a26332c3d6",class:"max-w-72 mx-auto"},h$1("div",{key:"bd25646ec291c36aa20088108056bd6ae80f851a",class:"relative mb-2"},h$1("input",{key:"659665fa5c9b1247c5e81afc86a11b61e236b67a",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$1("div",{key:"4e0fe1bfaa82a05256a716c329ae9f8e6696b1d3",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$1("svg",{key:"795ba20efa3fc317ccb0e91489ee7d96dc36b0e7",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$1("path",{key:"0d856bf29de693b6424256da7491993692edde1b","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"})))),this.isScanning?h$1("div",{class:"mb-3"},h$1("div",{ref:e=>this.scannerContainer=e,class:"relative rounded-lg overflow-hidden bg-black",style:{aspectRatio:"1",width:"100%"}}),h$1("button",{type:"button",onClick:()=>this.stopScan(),class:"nl-action-button mt-2 w-full py-2 px-4 text-sm font-medium rounded-lg border border-transparent"},"Cancel")):h$1("div",{class:"mb-3"},h$1("button",{type:"button",onClick:()=>this.startScan(),class:"nl-action-button w-full py-2 px-4 inline-flex justify-center items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent"},h$1("svg",{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$1("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6.827 6.175A2.31 2.31 0 0 1 5.186 7.23c-.38.054-.757.112-1.134.175C2.999 7.58 2.25 8.507 2.25 9.574V18a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 18V9.574c0-1.067-.75-1.994-1.802-2.169a47.865 47.865 0 0 0-1.134-.175 2.31 2.31 0 0 1-1.64-1.055l-.822-1.316a2.192 2.192 0 0 0-1.736-1.039 48.774 48.774 0 0 0-5.232 0 2.192 2.192 0 0 0-1.736 1.039l-.821 1.316Z"}),h$1("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M16.5 12.75a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0ZM18.75 10.5h.008v.008h-.008V10.5Z"})),"Scan QR Code")),this.scanError&&h$1("div",{key:"dfc914e494b41c2381fe9f4d699632ecb4fd33c9",class:"mb-2"},h$1("p",{key:"043fa75931e800a25afa0d6d02de0aab7718ed4c",class:"nl-error font-light text-center text-sm"},this.scanError)),h$1("div",{key:"d908c3d8c8a8054ce944a47a27e3b18c8dc40ce5",class:"ps-4 pe-4 overflow-y-auto"},h$1("p",{key:"8293556d3e2a1f714e2a776ab69d1e1609806bbb",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h$1("button-base",{key:"305e5badc3dd35dcbadc0e1ff123eee5bb1580a6",titleBtn:"Connect",disabled:state.isLoading,onClick:e=>this.handleLogin(e)},state.isLoading?h$1("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$1("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$1("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],isScanning:[32],scanError:[32]}]);function defineCustomElement$d(){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$s()}}))}defineCustomElement$d();var browser={},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 c=0;c<n;c++){o=s=0,i=a=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===i?o++:(o>=5&&(r+=t+(o-5)),i=n,o=1),n=e.get(l,c),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 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,i){if(!s.isValid(e))throw new Error("Invalid QR Code version");void 0===i&&(i=o.BYTE);const c=8*(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r));if(i===o.MIXED)return c;const l=c-a(i,e);switch(i){case o.NUMERIC:return Math.floor(l/10*3);case o.ALPHANUMERIC:return Math.floor(l/11*2);case o.KANJI:return Math.floor(l/13);case o.BYTE:default:return Math.floor(l/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(c(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,c,l,d,u,h,f=t.PriorityQueue.make();for(f.push(n,0);!f.empty();)for(c in a=(i=f.pop()).value,l=i.cost,d=e[a]||{})d.hasOwnProperty(c)&&(u=l+d[c],h=s[c],(void 0===s[c]||h>u)&&(s[c]=u,f.push(c,u),o[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 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,c=dijkstra.exports;function l(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 u(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 h(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 f(e,i){let c;const l=t.getBestModeForData(e);if(c=t.from(i,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 o(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 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:l(o.data)}]);break;case t.BYTE:n.push([{data:o.data,mode:t.BYTE,length:l(o.data)}])}}return n}(u(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],c=[];for(let e=0;e<a.length;e++){const l=a[e],d=""+i+e;c.push(d),r[d]={node:l,lastCount:0},o[d]={};for(let e=0;e<s.length;e++){const i=s[e];r[i]&&r[i].node.mode===l.mode?(o[i][d]=h(r[i].lastCount+l.length,l.mode)-h(r[i].lastCount,l.mode),r[i].lastCount+=l.length):(r[i]&&(r[i].lastCount=l.length),o[i][d]=h(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}s=c}for(let e=0;e<s.length;e++)o[s[e]].end=0;return{map:o,table:r}}(o,r),i=c.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(u(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 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$5.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),c=Math.floor(o/s),l=c+1,d=a-c,u=new ReedSolomonEncoder(d);let h=0;const f=new Array(s),p=new Array(s);let g=0;const m=new Uint8Array(e.buffer);for(let e=0;e<s;e++){const t=e<i?c:l;f[e]=m.slice(h,h+t),p[e]=u.encode(f[e]),h+=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<f[w].length&&(b[v++]=f[w][y]);for(y=0;y<d;y++)for(w=0;w<s;w++)b[v++]=p[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),c=new BitMatrix(a);return setupFinderPattern(c,t),setupTimingPattern(c),setupAlignmentPattern(c,t),setupFormatInfo(c,n,0),t>=7&&setupVersionInfo(c,t),setupData(c,i),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: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$2={};!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),c=r.margin*i,l=[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),u=r.color.light;if(e>=c&&n>=c&&e<a-c&&n<a-c){u=l[s[Math.floor((e-c)/i)*o+Math.floor((n-c)/i)]?1:0]}t[d++]=u.r,t[d++]=u.g,t[d++]=u.b,t[d]=u.a}}}(utils$2),function(e){const t=utils$2;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"),c=a.createImageData(i,i);return t.qrToImageData(c.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(c,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$2;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 c=Math.floor(a%t),l=Math.floor(a/t);c||s||(s=!0),e[a]?(i++,a>0&&c>0&&e[a-1]||(r+=s?svgCmd("M",c+n,.5+l+n):svgCmd("m",o,0),o=0,s=!1),c+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"/>':"",c="<path "+getColorAttrib(r.color.dark,"stroke")+' d="'+qrToPath(s,o,r.margin)+'"/>',l='viewBox="0 0 '+i+" "+i+'"',d='<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,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.create=QRCode.create,browser.toCanvas=renderCanvas.bind(null,CanvasRenderer.render),browser.toDataURL=renderCanvas.bind(null,CanvasRenderer.renderToDataURL),browser.toString=renderCanvas.bind(null,(function(e,t,n){return SvgRenderer.render(e,n)}));const nlSigninConnectionStringCss=baseCss,NlSigninConnectionStringStyle0=nlSigninConnectionStringCss,NlSigninConnectionString=proxyCustomElement(class extends H$2{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.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$1(Fragment,{key:"739ccc5ccbb2d95dd79e61bca0734603c071fa0c"},h$1("div",{key:"e0e55217f18f113364c874a7a749eeb4e7747da2",class:"p-4 overflow-y-auto"},h$1("h1",{key:"536646c9e2f14b5a26eb7cf537a2aba27108480f",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h$1("p",{key:"319cce0772500eb08061d62542e09e7dc31886fc",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h$1("canvas",{key:"acbb64df286dadd9cfc209df904bcdae06781fd7",class:"mx-auto mb-2",ref:e=>this.canvasElement=e}),h$1("div",{key:"5d6569013d81f1235a2e0fce79d63a358662e19b",class:"px-4"},h$1("div",{key:"4d6651551f297ba8065b6a8a28d00edc804ff597",class:"max-w-72 mx-auto"},h$1("div",{key:"32d3e176ea2b5f9aaee1a68c85a36a5f4c560414",class:"relative mb-2"},h$1("input",{key:"e4a0c9bcb80ec84ba545c427616e16d77f4c8581",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$1("div",{key:"e1af97f16bf9dbedef178ea4c8e6f1b656ad10b2",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$1("svg",{key:"e53e6e030b0173fde047dabbb5d5a84a37c36562",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$1("path",{key:"ad082553497803daeb16eb3a1b1acd4afbf173d3","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$1("path",{key:"25438a495668108eeca317c69ed60ef830c7b76d","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$1("div",{class:"absolute inset-y-0 end-0 flex items-center p-2 rounded-lg"},h$1("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$1("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$1("div",{class:"absolute inset-y-0 end-0 flex items-center cursor-pointer p-2 rounded-lg",onClick:()=>this.copyToClipboard()},h$1("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$1("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$1("div",{key:"557a946f96cf2e1d9e16d7d0b617ceae63a20ba4",class:"mt-10 justify-center items-center flex gap-2"},h$1("span",{key:"223239887aa24dfc350605137a18857c2944bb8a",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$1("span",{key:"919c6ab74a39b4d8e124de850be72f4c30817b6a",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$c(){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$c();const nlSigninNsecCss=baseCss,NlSigninNsecStyle0=nlSigninNsecCss,NlSigninNsec=proxyCustomElement(class extends H$2{constructor(){super(),this.__registerHost(),this.nlLoginNsec=createEvent$1(this,"nlLoginNsec"),this.titleLogin="Login with nsec",this.description="Enter your private key (nsec) to log in."}handleInputChange(e){state.nlSigninNsec.nsecValue=e.target.value}handleLogin(e){e.preventDefault(),this.nlLoginNsec.emit(state.nlSigninNsec.nsecValue)}render(){return h$1(Fragment,{key:"96b364ced9e063e319692f6796856eb88ece7dc7"},h$1("div",{key:"6eb8a90f07aa52abe93af9f1cb1f98df67925c90",class:"p-4 overflow-y-auto"},h$1("h1",{key:"395ea33533887d43be9663e671a381614af32ec8",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h$1("p",{key:"775bfeedda38d2a52d439f85e6fc1c471a14df06",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h$1("div",{key:"335af1f09ccdeac29cb17e9e671edbc06f251de7",class:"max-w-72 mx-auto"},h$1("div",{key:"e7949c50411f44ddc2e666e4a6efd4c1ced0bc51",class:"p-3 mb-3 rounded-lg border border-yellow-400 bg-yellow-50 dark:bg-yellow-900/20 dark:border-yellow-600"},h$1("div",{key:"3bbb8da9a9a66ba779af864b18726f367fa39b37",class:"flex items-start gap-2"},h$1("svg",{key:"e78c62977f057b46df3af6e6aa6d34bca86bedf1",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"#ca8a04",class:"flex-shrink-0 w-5 h-5 mt-0.5"},h$1("path",{key:"38fa5ad1e1e09b768a1fc17a6354f67ef6182e5f","stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z"})),h$1("div",{key:"e4df5e35b96ac61ce48f151988167d70c44478f4"},h$1("p",{key:"04d1b231d1fc9b5773bde43f7d48f7654442a8e3",class:"nl-title text-xs font-semibold",style:{color:"#ca8a04"}},"Use at your own risk"),h$1("p",{key:"57d626346430f8f0a09a38b10ba699252da3fe2e",class:"nl-description text-xs mt-1",style:{color:"#a16207"}},"Entering your private key directly is not recommended. We suggest migrating to a key store service for better security.")))),h$1("div",{key:"a00f417138ef4abf1ca2e22800a3d2a11d7fde10",class:"relative mb-2"},h$1("input",{key:"17d2f098263f3744de65361e09e18a0c8e1b0868",onInput:e=>this.handleInputChange(e),type:"password",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:"nsec1...",value:state.nlSigninNsec.nsecValue}),h$1("div",{key:"7ee9540e35b72d2678c51528f7f0302cbdbc271a",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$1("svg",{key:"0a85157080fd2363d30f002c181c32b497b6dd60",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$1("path",{key:"819466744f8729a1ba2c6f14f3e6eb96ef6a09af","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$1("div",{key:"3773ee73ac8f9bc7eb115dbd7120d3b0d3f6d9aa",class:"ps-4 pe-4 overflow-y-auto"},h$1("p",{key:"10325d69b4fbc0cdde6dd0fd0a0b940d82636fa7",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h$1("button-base",{key:"f31975f0fd11bef77ebf1282fa4505c2f70dfcba",titleBtn:"Log in",disabled:state.isLoading,onClick:e=>this.handleLogin(e)},state.isLoading&&h$1("span",{key:"37f2a1a4e24c508511549515754b452398cd83d6",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 NlSigninNsecStyle0}},[0,"nl-signin-nsec",{titleLogin:[1,"title-login"],description:[1]}]);function defineCustomElement$b(){if("undefined"==typeof customElements)return;["nl-signin-nsec","button-base"].forEach((e=>{switch(e){case"nl-signin-nsec":customElements.get(e)||customElements.define(e,NlSigninNsec);break;case"button-base":customElements.get(e)||defineCustomElement$s()}}))}defineCustomElement$b();const nlSigninOtpCss=baseCss,NlSigninOtpStyle0=nlSigninOtpCss,NlSigninOtp=proxyCustomElement(class extends H$2{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$1(Fragment,{key:"709d350659757afd0ab48e36c71d8c4383bfefe0"},h$1("div",{key:"b0f5f62a5f154bfcc2f7a7af58cfc05614110c34",class:"p-4 overflow-y-auto"},h$1("h1",{key:"b846587dd89240232ae5e80812073b88e8885ebf",class:"nl-title font-bold text-center text-2xl"},state.isOTP?this.titleLoginOTP:this.titleLogin),h$1("p",{key:"41e3ffb50a451af98c5864e53cf9b29b6f9954eb",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},state.isOTP?this.descriptionOTP:this.description)),h$1("div",{key:"ef89992613d828c4522af37be614e03c00ca181f",class:"max-w-72 mx-auto"},h$1("div",{key:"bea6fbf173fdc9a248d96318547a3e4d72df1b21",class:"relative mb-2"},h$1("input",{key:"2c5dce83b126cfc0c10c5609da99c124944a3050",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$1("div",{key:"ca758a6f68f12dbd6913378de1f167cc59df86f2",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$1("svg",{key:"c6d6fd56d5ea9b01983578e6a182c71e80156088",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$1("path",{key:"89553d48fa3519fe42ea3ad3f6a8d4de90db9c66","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$1("path",{key:"4a4ae482c3095537b30be245c4aabc9d5c65902d","stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})))),h$1("div",{key:"94ccf98dadf388302f8269a822accac872c1a1bb",class:"ps-4 pe-4 overflow-y-auto"},h$1("p",{key:"dc167d95b9aa12f1a8034af58d652671d345c07e",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h$1("button-base",{key:"98b1b8d1b2cc4547be2862db89f684a7278184b2",titleBtn:"Log in",disabled:state.isLoading,onClick:e=>this.handleLogin(e)},state.isLoading&&h$1("span",{key:"2edccf4b93a7daf6bb33b0ff373248ee1ff84970",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$s()}}))}defineCustomElement$a();const nlSigninReadOnlyCss=baseCss,NlSigninReadOnlyStyle0=nlSigninReadOnlyCss,NlSigninReadOnly=proxyCustomElement(class extends H$2{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$1(Fragment,{key:"ab72934e6f777bd62e5065cee268b2dff4209a05"},h$1("div",{key:"c8b77eac4c36dc67d1e550dbef1969aefa0db3b9",class:"p-4 overflow-y-auto"},h$1("h1",{key:"711b4d81bc446a4e1925ea6772d8724492410492",class:"nl-title font-bold text-center text-2xl"},this.titleLogin),h$1("p",{key:"1bd45ccdcf760a0428e979bea6cd5d4946efa440",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h$1("div",{key:"1c086de3f2d458c9f3163314e17ee056bd30b89e",class:"max-w-72 mx-auto"},h$1("div",{key:"29baadba904448aff56f5b490e4684b4f5669817",class:"relative mb-2"},h$1("input",{key:"85a2266a004e7832f3a8bf6586fdab68364441ed",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$1("div",{key:"d563c7cdd5c7dd560d7a3c6c5e5b7a36798d2fe3",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$1("svg",{key:"57bf5e498bb4ce520de1665555618be2a191660a",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$1("path",{key:"354d1a2b42d1590430b13b63fa8b54d365743d17","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$1("path",{key:"3fd555ef4b8ef4d6d38fa8d417c0c8745412b70a","stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})))),h$1("div",{key:"47991d46b02ede704b99e3958e81871cc733a874",class:"ps-4 pe-4 overflow-y-auto"},h$1("p",{key:"9bf3a572a89d85d5da61c6665060b5f5b2e8f46c",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h$1("button-base",{key:"bee14c47813853dcdcba90ae29a10cded60e902a",titleBtn:"Log in",disabled:state.isLoading,onClick:e=>this.handleLogin(e)},state.isLoading&&h$1("span",{key:"acf228ea98993476107e394f6a74f27a5b6efa84",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$s()}}))}defineCustomElement$9();const nlSignupCss=baseCss,NlSignupStyle0=nlSignupCss,NlSignup=proxyCustomElement(class extends H$2{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$1(Fragment,{key:"100d9330a518e02431bd21dce3247225d2e148a6"},h$1("div",{key:"f6ca0cc88094790a2ec0dd7ee8e03073b5aed315",class:"p-4 overflow-y-auto"},h$1("h1",{key:"341daf884a33b81946265dd688910e411b87f90a",class:"nl-title font-bold text-center text-2xl"},this.titleSignup),h$1("p",{key:"9e8a890c91b026739a71b00a06ba0dd6c52a0a94",class:"nl-description font-light text-center text-sm pt-2 max-w-96 mx-auto"},this.description)),h$1("div",{key:"0d1cae8ceea504f40f49fff35d3a3e2162801c48",class:"max-w-72 mx-auto"},h$1("div",{key:"0aa970acebd3392d3c2b91a57bf18982397cbfd2",class:"relative mb-2"},h$1("input",{key:"861f95f3dfe8cbedaeabe5e80d310cee8ec6b3ef",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$1("div",{key:"687cd576c83a67e4ad946da7d675153eb1c249cd",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$1("svg",{key:"d870596edf59c8d747c08d887af7d3b33060f9f4",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$1("path",{key:"2669def09130b54c40ab3fb9ac044490c6465e32","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$1("div",{key:"b2dbdd050024352b399a7fb1925dd530680d1b3a",class:"mb-2"},h$1("nl-select",{key:"c6f4c4a5c5854a1980ab67dd43958dc5120ba0aa",onSelectDomain:e=>this.handleDomainSelect(e),selected:0,options:state.nlSignup.servers})),h$1("div",{key:"e92991946bcf756880fb607365e8415943af393e",class:"ps-4 pe-4 overflow-y-auto"},h$1("p",{key:"8e5d4f08c0996a5b80364ab2abfcbf869a45a066",class:"nl-error font-light text-center text-sm max-w-96 mx-auto"},state.error)),h$1("button-base",{key:"04a486b8a81f3750d048362689365b3a975ef0d1",disabled:state.isLoading,onClick:e=>this.handleCreateAccount(e),titleBtn:"Create profile"},state.isLoading?h$1("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$1("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$1("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$s();break;case"nl-select":customElements.get(e)||defineCustomElement$n()}}))}defineCustomElement$8();const nlWelcomeCss=baseCss,NlWelcomeStyle0=nlWelcomeCss,NlWelcome=proxyCustomElement(class extends H$2{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$1(Fragment,{key:"6f0a48d82976e4148caf8ff8c4a000355696de48"},h$1("div",{key:"ceaf09713ee4cdd7fba07db76aa64b3e7aabef52",class:"p-4 overflow-y-auto"},h$1("h1",{key:"dee6b8c58bed8216c8929550231860b7fab9600f",class:"nl-title font-bold text-center text-4xl"},this.titleWelcome),h$1("p",{key:"d63d6c7f040b32886f4a2c165640cbff5bae525f",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},this.description)),h$1("div",{key:"bdfd30799af7e1c0d003cbce2e1c97f0c4d8345e",class:"max-w-52 mx-auto pb-5"},h$1("div",{key:"c1845b8823b5992647eedc8d0de4106adad2905f",class:"flex gap-3 flex-col mb-2"},h$1("button-base",{key:"92a35fd59f02a3f1b35757f36a111e6978dccd4e",titleBtn:"Log in",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.WELCOME_LOGIN)},h$1("svg",{key:"1fbcbe9b48913334b7cb96571d527de2ede1083f",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$1("path",{key:"0cebc8b3d0747c9598d08b6b81f95e5dd1a325c1","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$1("button-base",{key:"1d94662ed04041cf8246ba75792c88288694769d",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.WELCOME_SIGNUP),titleBtn:"Sign up"},h$1("svg",{key:"4b610e3752bc18c40f2afb2385d3ec64ee71f656",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$1("path",{key:"23f217c6d17f81aa55bdc153bc8fb26dcebae9dc","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$s()}}))}defineCustomElement$7();const nlWelcomeSigninCss=baseCss,NlWelcomeSigninStyle0=nlWelcomeSigninCss,NlWelcomeSignIn=proxyCustomElement(class extends H$2{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$1("button-base",{onClick:()=>this.handleChangeScreen(CURRENT_MODULE.EXTENSION),titleBtn:"With extension"},h$1("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$1("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$1(Fragment,{key:"037b8d2ba99338efd13be6a1ec49accace64218b"},h$1("div",{key:"cedab2e7f1a4b8df177d5b6fd4c609aa45ff5965",class:"p-4 overflow-y-auto"},h$1("h1",{key:"0bbae7bd31433baa6f8572cd7fdcd60b64cb3abb",class:"nl-title font-bold text-center text-3xl"},this.titleWelcome)),h$1("div",{key:"d1cd467c79e0034e93522045990f7d1f10e95f42",class:"max-w-52 mx-auto pb-5"},h$1("div",{key:"f89c6551de4b27d04f07051049093c43bd77dd9b",class:"flex gap-3 flex-col"},this.allowAuthMethod("connect")&&h$1("button-base",{key:"a86482667df33e31dff35544364576cd0fbeec0b",titleBtn:"Connect",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.CONNECT)},h$1("svg",{key:"b0b8f37580302000950c4a89a0239132b1aca88a",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$1("path",{key:"feef73e7c96f9f494abc9f3946c2c96446c117fb","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$1("button-base",{key:"75cb54d6ba1961239c89f2e2e0699a0f7a3b3841",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN_READ_ONLY),titleBtn:"Read only"},h$1("svg",{key:"4d3741e46c24963e3373d308916e04f1b9cdddad",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$1("path",{key:"109481732e23a555dabb8bd2aaf072984ac2642c","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$1("path",{key:"7c571b8540f5d4f89c3f10c05d1f029cb2184e84","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$1("button-base",{key:"b3f78d5917f4efef7551e093d6cb5ef3d906eaa6",titleBtn:"One-time code",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN_OTP)},h$1("svg",{key:"f4dac958561ba1710d262cb07886f9dc15ebeb9e",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$1("path",{key:"da957eadb59492f7c907b35dd20a4eb5bdabe559","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(),h$1("button-base",{key:"fa26358ebee467e4926b3a820c38a34b6f2ea1b4",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOGIN_NSEC),titleBtn:"With nsec"},h$1("svg",{key:"b3a248c229e2571c038a88c8d93c802927ec2b43",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$1("path",{key:"ac007bbc3bf0e6e8654fdcaa57cfbdecf1f67fb9","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"}))),!this.allowAuthMethod("connect")&&!this.hasExtension&&h$1("p",{key:"fa06ff007947dee35315b6311097fc03cc55da78",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$1("p",{key:"0080e835c7024ed6f867f96399b604651ea74483",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$s()}}))}defineCustomElement$6();const nlWelcomeSignupCss=baseCss,NlWelcomeSignupStyle0=nlWelcomeSignupCss,NlWelcomeSignUp=proxyCustomElement(class extends H$2{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$1(Fragment,{key:"164e5da760f1609d604bbc85867bd3ae788ce924"},h$1("div",{key:"03691d670c29b844cae9a771c12c37b1e9540e95",class:"p-4 overflow-y-auto"},h$1("h1",{key:"0b60f6cf4c8a9cd9ecf3161c64761c7d7c9fb57e",class:"nl-title font-bold text-center text-3xl"},this.titleWelcome),h$1("p",{key:"91a2e92660873d45f2e92d60a0a7adc3114a0d8d",class:"nl-description font-light text-center text-lg pt-2 max-w-96 mx-auto"},this.description)),h$1("div",{key:"a14d1a9ac594806be23679b59d9081e2ec1ef92d",class:"max-w-52 mx-auto pb-5"},h$1("div",{key:"6c8c856efe85e19a3a432c856ddd658aea7e2bd2",class:"flex gap-3 flex-col"},h$1("button-base",{key:"50c470453b16b552a4070c451f57baa4e366eb7d",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.LOCAL_SIGNUP),titleBtn:"Create keys"},h$1("svg",{key:"da1d5889dbbc208bafed0d460a65cae6523b2269",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$1("path",{key:"ccae3b5c13c1953fe47f5fe416d35b031cf84c3d","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$1("button-base",{key:"6a557e8d6f926fd0f185c280ae4a372139f8aa5b",onClick:()=>this.handleChangeScreen(CURRENT_MODULE.SIGNUP),titleBtn:"With key store"},h$1("svg",{key:"08ea855bea4186d1f73a6fde7264585930fe6f91",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$1("path",{key:"4cc3dc620843a3a970f558b8702ad109411eaf0c","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$s()}}))}defineCustomElement$5();const nlAuthCss=baseCss,NlAuthStyle0=nlAuthCss,NlAuth=proxyCustomElement(class extends H$2{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$1("div",{class:`theme-${this.theme}`,dir:"ltr"},h$1("div",{class:e},h$1("div",{onClick:()=>this.handleClose(),class:"absolute top-0 left-0 w-full h-full bg-gray-500 bg-opacity-75 z-[80]"}),h$1("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$1("div",{class:"flex justify-between items-center py-3 px-4"},h$1("div",{class:"flex gap-2 items-center"},h$1("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$1("rect",{width:"224.047",height:"224",rx:"64",fill:"#6951FA"}),h$1("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$1("p",{class:"font-bold nl-logo text-base"},"Nostr ",h$1("span",{class:"font-light"},"Login"))),h$1("div",{class:"flex gap-1"},h$1("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$1("span",{class:"sr-only"},"Change theme"),this.darkMode?h$1("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$1("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$1("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$1("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$1("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$1("span",{class:"sr-only"},"Info"),h$1("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$1("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$1("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$1("span",{class:"sr-only"},"Close"),h$1("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$1("path",{d:"M18 6 6 18"}),h$1("path",{d:"m6 6 12 12"}))))),state.path.length>1&&!state.isLoading&&h$1("div",{class:"p-4"},h$1("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$1("span",{class:"sr-only"},"Back"),h$1("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$1("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$1("nl-loading",{path:t}):h$1(Fragment,null,(()=>{if(state.isOTP)return h$1("nl-signin-otp",null);switch(t){case CURRENT_MODULE.WELCOME:return h$1("nl-welcome",{titleWelcome:this.welcomeTitle||void 0,description:this.welcomeDescription||void 0});case CURRENT_MODULE.LOGIN:return h$1("nl-signin",null);case CURRENT_MODULE.SIGNUP:return h$1("nl-signup",{bunkers:this.bunkers});case CURRENT_MODULE.LOCAL_SIGNUP:return h$1("nl-local-signup",{signupNjump:this.signupNjump});case CURRENT_MODULE.CONFIRM_LOGOUT:return h$1("nl-confirm-logout",null);case CURRENT_MODULE.IMPORT_FLOW:return h$1("nl-import-flow",{services:this.connectionStringServices});case CURRENT_MODULE.IMPORT_OTP:return h$1("nl-otp-migrate",{services:this.connectionStringServices});case CURRENT_MODULE.INFO:return h$1("nl-info",null);case CURRENT_MODULE.EXTENSION:return h$1("nl-info-extension",null);case CURRENT_MODULE.LOGIN_READ_ONLY:return h$1("nl-signin-read-only",null);case CURRENT_MODULE.LOGIN_BUNKER_URL:return h$1("nl-signin-bunker-url",null);case CURRENT_MODULE.LOGIN_OTP:return h$1("nl-signin-otp",null);case CURRENT_MODULE.LOGIN_NSEC:return h$1("nl-signin-nsec",null);case CURRENT_MODULE.WELCOME_LOGIN:return h$1("nl-welcome-signin",{hasOTP:this.hasOTP,authMethods:this.authMethods,hasExtension:this.hasExtension});case CURRENT_MODULE.WELCOME_SIGNUP:return h$1("nl-welcome-signup",null);case CURRENT_MODULE.CONNECTION_STRING:return h$1("nl-signin-connection-string",{connectionString:this.connectionString});case CURRENT_MODULE.CONNECT:return h$1("nl-connect",{connectionStringServices:this.connectionStringServices,authMethods:this.authMethods});case CURRENT_MODULE.PREVIOUSLY_LOGGED:return h$1("nl-previously-logged",{accounts:this.accounts,recents:this.recents});case CURRENT_MODULE.IFRAME:return h$1("nl-iframe",{iframeUrl:this.authUrl});default:return h$1("nl-welcome",null)}})(),n&&h$1(Fragment,null,t===CURRENT_MODULE.WELCOME_SIGNUP||t===CURRENT_MODULE.SIGNUP||t===CURRENT_MODULE.LOCAL_SIGNUP?h$1("div",{class:"p-4 overflow-y-auto"},h$1("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$1("span",{onClick:()=>this.switchSignSignUpStrategy(CURRENT_MODULE.WELCOME_LOGIN),class:"cursor-pointer text-blue-400"},"log in"),".")):r&&h$1("div",{class:"p-4 overflow-y-auto"},h$1("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$1("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-nip46-relay-settings","nl-otp-migrate","nl-previously-logged","nl-select","nl-signin","nl-signin-bunker-url","nl-signin-connection-string","nl-signin-nsec","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$s();break;case"nl-confirm-logout":customElements.get(e)||defineCustomElement$r();break;case"nl-connect":customElements.get(e)||defineCustomElement$p();break;case"nl-iframe":customElements.get(e)||defineCustomElement$o();break;case"nl-import-flow":customElements.get(e)||defineCustomElement$m();break;case"nl-info":customElements.get(e)||defineCustomElement$l();break;case"nl-info-extension":customElements.get(e)||defineCustomElement$k();break;case"nl-loading":customElements.get(e)||defineCustomElement$j();break;case"nl-local-signup":customElements.get(e)||defineCustomElement$i();break;case"nl-login-status":customElements.get(e)||defineCustomElement$h();break;case"nl-nip46-relay-settings":customElements.get(e)||defineCustomElement$q();break;case"nl-otp-migrate":customElements.get(e)||defineCustomElement$g();break;case"nl-previously-logged":customElements.get(e)||defineCustomElement$f();break;case"nl-select":customElements.get(e)||defineCustomElement$n();break;case"nl-signin":customElements.get(e)||defineCustomElement$e();break;case"nl-signin-bunker-url":customElements.get(e)||defineCustomElement$d();break;case"nl-signin-connection-string":customElements.get(e)||defineCustomElement$c();break;case"nl-signin-nsec":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$2{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.theme="default",this.darkMode=!1,this.titleBtn="Open modal",this.disabled=!1}render(){return h$1("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$s()}}))}defineCustomElement$3();const nlChangeAccountCss=baseCss,NlChangeAccountStyle0=nlChangeAccountCss,NLChangeAccount=proxyCustomElement(class extends H$2{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$1("div",{key:"4e15e39f7ac6a552bfc772396e3e9ef8eeca95cc",class:`theme-${this.themeState}`},h$1("div",{key:"eae10769ce35dc4cc072d2361c1ee1390c79c822",class:"relative",ref:e=>this.wrapperRef=e},h$1("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$1("span",{key:"006ed9a67b57227d4dab51f0b6bcb8290cd9d3ac",class:"text-gray-500"},"Switch profile"),h$1("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$1("path",{key:"600914907723c9f8d01a15da357ccb825c1d1e6a",d:"m6 9 6 6 6-6"}))),h$1("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$1("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$1("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$1("img",{class:"w-full rounded-full",src:e.picture,alt:"Logo"}):r?n[0]:h$1("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$1("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$1("div",{class:"overflow-hidden flex flex-col w-full"},h$1("div",{class:"truncate overflow-hidden"},n),h$1("nl-login-status",{info:e})))})),h$1("li",{key:"936f2b75ca2dfca3483650d5d62fc50182cfc8f2",class:"first:pt-0 pt-2 border-t-[1px] first:border-none border-gray-300"},h$1("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$1("div",{key:"bdd2a67e5763726666fcea91b0e7de67fe855994",class:"uppercase font-bold w-6 h-6 rounded-full border border-gray-400 flex justify-center items-center"},h$1("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$1("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$h()}}))}defineCustomElement$2();const nlDialogCss=baseCss,NlDialogStyle0=nlDialogCss,NlDialog=proxyCustomElement(class extends H$2{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$1("dialog",{key:"236049861cbba1f18e4bccfed48d3211aaefabec",ref:e=>this.dialogElement=e,class:"m-auto nl-banner-dialog",style:{border:"0",backgroundColor:"transparent"}},h$1("slot",{key:"b0396bb61e95d6ea66ad520e68c84f917de9db8a"}))}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$2{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.handleCancelTimeout=createEvent$1(this,"handleCancelTimeout"),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)||"",c=Boolean(a),l=h$1("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$1("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"})),d=h$1(Fragment,null,h$1("div",{class:"block w-[48px] h-[46px] relative z-10"},h$1("div",{onClick:()=>this.handleOpen(),class:"flex w-52 h-[46px] items-center pl-[11px]"},h$1("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$1("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?l:h$1("img",{class:"w-full rounded-full",src:this.userInfo.picture,alt:"Logo",onError:()=>this.isUserImgError=!0}):c?a[0]:l):h$1("div",{class:"flex justify-center items-center"},h$1("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$1("rect",{width:"224.047",height:"224",rx:"64",fill:"#6951FA"}),h$1("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$1("span",{class:"px-2"},h$1("b",null,"Nostr")," Login")),this.isOpen&&c&&h$1("div",{class:"show-slow truncate w-16 text-xs"},a),this.isOpen&&c&&h$1("nl-login-status",{info:this.userInfo}))),h$1("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$1("span",{class:"sr-only"},"Close"),h$1("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$1("path",{d:"M18 6 6 18"}),h$1("path",{d:"m6 6 12 12"}))),h$1("div",{class:"p-3 show-slow"},this.isOpenConfirm?h$1("div",null,h$1("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$1("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$1("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$1("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$1("div",null,h$1("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 mb-2"},"Go to ",this.domain),h$1("button-base",{onClick:()=>{this.handleCancelTimeout.emit(),this.handleClose()},titleBtn:"Cancel"})):"rebind"===this.mode?h$1("iframe",{src:this.url,width:"180",height:"80",frameBorder:"0"}):h$1("button-base",{onClick:()=>this.handleConfirm(),titleBtn:"Confirm"})):h$1("div",null,h$1("div",null,this.titleBanner&&h$1("p",{class:"mb-2 text-center show-slow max-w-40 min-w-40 mx-auto"},this.titleBanner),h$1("div",{class:"mb-2"},h$1("nl-change-account",{currentAccount:this.userInfo,accounts:this.accounts})),this.userInfo?h$1("button-base",{onClick:()=>this.handleLogout(),titleBtn:"Log out"}):h$1("div",null,h$1("button-base",{onClick:()=>this.handleLogin(),titleBtn:"Log in"},h$1("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$1("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$1("button-base",{onClick:()=>this.handleSignup(),titleBtn:"Sign up"},h$1("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$1("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 u=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"),h=!!u.find((e=>e.open&&!e.classList.contains("nl-banner-dialog")));return h$1("div",{class:`theme-${this.theme} ${!this.isOpen&&this.hiddenMode?"hidden":""}`},h$1("div",{class:this.darkMode&&"dark",dir:"ltr"},this.isOpenConfirm&&h?h$1("nl-dialog",null,h$1("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`},d)):h$1("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`},d)))}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$s();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$h()}}))}defineCustomElement();var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},lib={},types={};Object.defineProperty(types,"__esModule",{value:!0});var ee$1={},taskCollection$1={},taskCollection={},utils$1={};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$1,"__esModule",{value:!0}),utils$1._fast_remove_single=void 0,utils$1._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="",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$2=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=void 0;var utils_1$1=utils$1,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 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$2([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$2([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 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={};function nullObj(){var e={__proto__:null};return e}Object.defineProperty(utils,"__esModule",{value:!0}),utils.nullObj=void 0,utils.nullObj=nullObj;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(ee$1,"__esModule",{value:!0}),ee$1.EventEmitter=void 0;var task_collection_1=taskCollection$1,utils_1=utils$1,utils_2=utils;function emit(e,t,n,r,o,s){var i=this.events[e];if(i){if(0===i.length)return!1;if(i.argsNum<6)i.call(t,n,r,o,s);else{for(var a=new Array(i.argsNum),c=0,l=a.length;c<l;++c)a[c]=arguments[c+1];i.call.apply(void 0,a)}return!0}return!1}function emitHasOnce(e,t,n,r,o,s){var i,a=this.events[e];if(void 0!==a){if(0===a.length)return!1;if(a.argsNum<6)a.call(t,n,r,o,s);else{for(var c=0,l=(i=new Array(a.argsNum)).length;c<l;++c)i[c]=arguments[c+1];a.call.apply(void 0,i)}}var d=this.onceEvents[e];if(d){if("function"==typeof d)if(this.onceEvents[e]=void 0,arguments.length<6)d(t,n,r,o,s);else{if(void 0===i)for(c=0,l=(i=new Array(arguments.length-1)).length;c<l;++c)i[c]=arguments[c+1];d.apply(void 0,i)}else{var u=d;if(this.onceEvents[e]=void 0,arguments.length<6)for(c=0;c<u.length;++c)u[c](t,n,r,o,s);else{if(void 0===i)for(c=0,l=(i=new Array(arguments.length-1)).length;c<l;++c)i[c]=arguments[c+1];for(c=0;c<u.length;++c)u[c].apply(void 0,i)}}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 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_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$1(__spreadArray$1([],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$1(__spreadArray$1([],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$1(__spreadArray$1(__spreadArray$1([],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)}
|
|
2
2
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3
|
-
function isBytes$4(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function anumber$4(e,t=""){if(!Number.isSafeInteger(e)||e<0){throw new Error(`${t&&`"${t}" `}expected integer >= 0, got ${e}`)}}function abytes$4(e,t,n=""){const
|
|
4
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function abool$1(e,t=""){if("boolean"!=typeof e){throw new Error((t&&`"${t}" `)+"expected boolean, got type="+typeof e)}return e}function abignumber(e){if("bigint"==typeof e){if(!isPosBig$1(e))throw new Error("positive bigint expected, got "+e)}else anumber$4(e);return e}function numberToHexUnpadded$1(e){const t=abignumber(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""===e?_0n$8:BigInt("0x"+e)}function bytesToNumberBE$1(e){return hexToNumber$1(bytesToHex$1(e))}function bytesToNumberLE$1(e){return hexToNumber$1(bytesToHex$1(copyBytes$1(abytes$4(e)).reverse()))}function numberToBytesBE$1(e,t){anumber$4(t);const n=hexToBytes$1((e=abignumber(e)).toString(16).padStart(2*t,"0"));if(n.length!==t)throw new Error("number too large");return n}function numberToBytesLE$1(e,t){return numberToBytesBE$1(e,t).reverse()}function copyBytes$1(e){return Uint8Array.from(e)}function asciiToBytes(e){return Uint8Array.from(e,((t,n)=>{const
|
|
5
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$7=BigInt(0),_1n$6=BigInt(1),_2n$5=BigInt(2),_3n$3=BigInt(3),_4n$3=BigInt(4),_5n$1=BigInt(5),_7n$1=BigInt(7),_8n$1=BigInt(8),_9n$1=BigInt(9),_16n$1=BigInt(16);function mod$1(e,t){const n=e%t;return n>=_0n$7?n:t+n}function pow2$1(e,t,n){let
|
|
6
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$6=BigInt(0),_1n$5=BigInt(1);function negateCt$1(e,t){const n=t.negate();return e?n:t}function normalizeZ$1(e,t){const n=FpInvertBatch$1(e.Fp,t.map((e=>e.Z)));return t.map(((t,
|
|
7
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */;const divNearest$1=(e,t)=>(e+(e>=0?t:-t)/_2n$4)/t;function _splitEndoScalar$1(e,t,n){const[[o,r],[s,i]]=t,a=divNearest$1(i*e,n),c=divNearest$1(-r*e,n);let l=e-a*o-c*s,d=-a*r-c*i;const h=l<_0n$5,u=d<_0n$5;h&&(l=-l),u&&(d=-d);const f=bitMask$1(Math.ceil(bitLen$1(n)/2))+_1n$4;if(l<_0n$5||l>=f||d<_0n$5||d>=f)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:h,k1:l,k2neg:u,k2:d}}function validateSigFormat$1(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function validateSigOpts$1(e,t){const n={};for(let o of Object.keys(t))n[o]=void 0===e[o]?t[o]:e[o];return abool$1(n.lowS,"lowS"),abool$1(n.prehash,"prehash"),void 0!==n.format&&validateSigFormat$1(n.format),n}let DERErr$1=class extends Error{constructor(e=""){super(e)}};const DER$1={Err:DERErr$1,_tlv:{encode:(e,t)=>{const{Err:n}=DER$1;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const o=t.length/2,r=numberToHexUnpadded$1(o);if(r.length/2&128)throw new n("tlv.encode: long form length too big");const s=o>127?numberToHexUnpadded$1(r.length/2|128):"";return numberToHexUnpadded$1(e)+s+r+t},decode(e,t){const{Err:n}=DER$1;let o=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new n("tlv.decode: wrong tlv");const r=t[o++];let s=0;if(!!(128&r)){const e=127&r;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 i=t.subarray(o,o+e);if(i.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===i[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of i)s=s<<8|e;if(o+=e,s<128)throw new n("tlv.decode(long): not minimal encoding")}else s=r;const i=t.subarray(o,o+s);if(i.length!==s)throw new n("tlv.decode: wrong value length");return{v:i,l:t.subarray(o+s)}}},_int:{encode(e){const{Err:t}=DER$1;if(e<_0n$5)throw new t("integer: negative integers are not allowed");let n=numberToHexUnpadded$1(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$1;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$1(e)}},toSig(e){const{Err:t,_int:n,_tlv:o}=DER$1,r=abytes$4(e,void 0,"signature"),{v:s,l:i}=o.decode(48,r);if(i.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=o.decode(2,s),{v:l,l:d}=o.decode(2,c);if(d.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$1,o=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,o)}},_0n$5=BigInt(0),_1n$4=BigInt(1),_2n$4=BigInt(2),_3n$2=BigInt(3),_4n$2=BigInt(4);function weierstrass$1(e,t={}){const n=createCurveFields("weierstrass",e,t),{Fp:o,Fn:r}=n;let s=n.CURVE;const{h:i,n:a}=s;validateObject(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});const{endo:c}=t;if(c&&(!o.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$1(o,r);function d(){if(!o.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const h=t.toBytes||function(e,t,n){const{x:r,y:s}=t.toAffine(),i=o.toBytes(r);if(abool$1(n,"isCompressed"),n){d();return concatBytes$1(pprefix$1(!o.isOdd(s)),i)}return concatBytes$1(Uint8Array.of(4),i,o.toBytes(s))},u=t.fromBytes||function(e){abytes$4(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=l,r=e.length,s=e[0],i=e.subarray(1);if(r!==t||2!==s&&3!==s){if(r===n&&4===s){const e=o.BYTES,t=o.fromBytes(i.subarray(0,e)),n=o.fromBytes(i.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 ${r}, expected compressed=${t} or uncompressed=${n}`)}{const e=o.fromBytes(i);if(!o.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=f(e);let n;try{n=o.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}d();return!(1&~s)!==o.isOdd(n)&&(n=o.neg(n)),{x:e,y:n}}};function f(e){const t=o.sqr(e),n=o.mul(t,e);return o.add(o.add(n,o.mul(e,s.a)),s.b)}function p(e,t){const n=o.sqr(t),r=f(e);return o.eql(n,r)}if(!p(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const g=o.mul(o.pow(s.a,_3n$2),_4n$2),m=o.mul(o.sqr(s.b),BigInt(27));if(o.is0(o.add(g,m)))throw new Error("bad curve params: a or b");function b(e,t,n=!1){if(!o.isValid(t)||n&&o.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function y(e){if(!(e instanceof x))throw new Error("Weierstrass Point expected")}function w(e){if(!c||!c.basises)throw new Error("no endo");return _splitEndoScalar$1(e,c.basises,r.ORDER)}const v=memoized$1(((e,t)=>{const{X:n,Y:r,Z:s}=e;if(o.eql(s,o.ONE))return{x:n,y:r};const i=e.is0();null==t&&(t=i?o.ONE:o.inv(s));const a=o.mul(n,t),c=o.mul(r,t),l=o.mul(s,t);if(i)return{x:o.ZERO,y:o.ZERO};if(!o.eql(l,o.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),k=memoized$1((e=>{if(e.is0()){if(t.allowInfinityPoint&&!o.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:n,y:r}=e.toAffine();if(!o.isValid(n)||!o.isValid(r))throw new Error("bad point: x or y not field elements");if(!p(n,r))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,r,s){return n=new x(o.mul(n.X,e),n.Y,n.Z),t=negateCt$1(r,t),n=negateCt$1(s,n),t.add(n)}class x{static BASE=new x(s.Gx,s.Gy,o.ONE);static ZERO=new x(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=r;X;Y;Z;constructor(e,t,n){this.X=b("x",e),this.Y=b("y",t,!0),this.Z=b("z",n),Object.freeze(this)}static CURVE(){return s}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!o.isValid(t)||!o.isValid(n))throw new Error("invalid affine point");if(e instanceof x)throw new Error("projective point not allowed");return o.is0(t)&&o.is0(n)?x.ZERO:new x(t,n,o.ONE)}static fromBytes(e){const t=x.fromAffine(u(abytes$4(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return x.fromBytes(hexToBytes$1(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return B.createCache(this,e),t||this.multiply(_3n$2),this}assertValidity(){k(this)}hasEvenY(){const{y:e}=this.toAffine();if(!o.isOdd)throw new Error("Field doesn't support isOdd");return!o.isOdd(e)}equals(e){y(e);const{X:t,Y:n,Z:r}=this,{X:s,Y:i,Z:a}=e,c=o.eql(o.mul(t,a),o.mul(s,r)),l=o.eql(o.mul(n,a),o.mul(i,r));return c&&l}negate(){return new x(this.X,o.neg(this.Y),this.Z)}double(){const{a:e,b:t}=s,n=o.mul(t,_3n$2),{X:r,Y:i,Z:a}=this;let c=o.ZERO,l=o.ZERO,d=o.ZERO,h=o.mul(r,r),u=o.mul(i,i),f=o.mul(a,a),p=o.mul(r,i);return p=o.add(p,p),d=o.mul(r,a),d=o.add(d,d),c=o.mul(e,d),l=o.mul(n,f),l=o.add(c,l),c=o.sub(u,l),l=o.add(u,l),l=o.mul(c,l),c=o.mul(p,c),d=o.mul(n,d),f=o.mul(e,f),p=o.sub(h,f),p=o.mul(e,p),p=o.add(p,d),d=o.add(h,h),h=o.add(d,h),h=o.add(h,f),h=o.mul(h,p),l=o.add(l,h),f=o.mul(i,a),f=o.add(f,f),h=o.mul(f,p),c=o.sub(c,h),d=o.mul(f,u),d=o.add(d,d),d=o.add(d,d),new x(c,l,d)}add(e){y(e);const{X:t,Y:n,Z:r}=this,{X:i,Y:a,Z:c}=e;let l=o.ZERO,d=o.ZERO,h=o.ZERO;const u=s.a,f=o.mul(s.b,_3n$2);let p=o.mul(t,i),g=o.mul(n,a),m=o.mul(r,c),b=o.add(t,n),w=o.add(i,a);b=o.mul(b,w),w=o.add(p,g),b=o.sub(b,w),w=o.add(t,r);let v=o.add(i,c);return w=o.mul(w,v),v=o.add(p,m),w=o.sub(w,v),v=o.add(n,r),l=o.add(a,c),v=o.mul(v,l),l=o.add(g,m),v=o.sub(v,l),h=o.mul(u,w),l=o.mul(f,m),h=o.add(l,h),l=o.sub(g,h),h=o.add(g,h),d=o.mul(l,h),g=o.add(p,p),g=o.add(g,p),m=o.mul(u,m),w=o.mul(f,w),g=o.add(g,m),m=o.sub(p,m),m=o.mul(u,m),w=o.add(w,m),p=o.mul(g,w),d=o.add(d,p),p=o.mul(v,w),l=o.mul(b,l),l=o.sub(l,p),p=o.mul(b,g),h=o.mul(v,h),h=o.add(h,p),new x(l,d,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(x.ZERO)}multiply(e){const{endo:n}=t;if(!r.isValidNot0(e))throw new Error("invalid scalar: out of range");let o,s;const i=e=>B.cached(this,e,(e=>normalizeZ$1(x,e)));if(n){const{k1neg:t,k1:r,k2neg:a,k2:c}=w(e),{p:l,f:d}=i(r),{p:h,f:u}=i(c);s=d.add(u),o=E(n.beta,l,h,t,a)}else{const{p:t,f:n}=i(e);o=t,s=n}return normalizeZ$1(x,[o,s])[0]}multiplyUnsafe(e){const{endo:n}=t,o=this;if(!r.isValid(e))throw new Error("invalid scalar: out of range");if(e===_0n$5||o.is0())return x.ZERO;if(e===_1n$4)return o;if(B.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:r,k2neg:s,k2:i}=w(e),{p1:a,p2:c}=mulEndoUnsafe$1(x,o,r,i);return E(n.beta,a,c,t,s)}return B.unsafe(o,e)}toAffine(e){return v(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return i===_1n$4||(e?e(x,this):B.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return i===_1n$4?this:e?e(x,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(e=!0){return abool$1(e,"isCompressed"),this.assertValidity(),h(x,this,e)}toHex(e=!0){return bytesToHex$1(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const C=r.BITS,B=new wNAF$1(x,t.endo?Math.ceil(C/2):C);return x.BASE.precompute(8),x}function pprefix$1(e){return Uint8Array.of(e?2:3)}function getWLengths$1(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function ecdh$1(e,t={}){const{Fn:n}=e,o=t.randomBytes||randomBytes$1,r=Object.assign(getWLengths$1(e.Fp,n),{seed:getMinHashLength$1(n.ORDER)});function s(e=o(r.seed)){return mapHashToField$1(abytes$4(e,r.seed,"seed"),n.ORDER)}function i(t,o=!0){return e.BASE.multiply(n.fromBytes(t)).toBytes(o)}function a(e){const{secretKey:t,publicKey:o,publicKeyUncompressed:s}=r;if(!isBytes$4(e))return;if("_lengths"in n&&n._lengths||t===o)return;const i=abytes$4(e,void 0,"key").length;return i===o||i===s}const c={isValidSecretKey:function(e){try{const t=n.fromBytes(e);return n.isValidNot0(t)}catch(e){return!1}},isValidPublicKey:function(t,n){const{publicKey:o,publicKeyUncompressed:s}=r;try{const r=t.length;return(!0!==n||r===o)&&((!1!==n||r===s)&&!!e.fromBytes(t))}catch(e){return!1}},randomSecretKey:s},l=createKeygen(s,i);return Object.freeze({getPublicKey:i,getSharedSecret:function(t,o,r=!0){if(!0===a(t))throw new Error("first arg must be private key");if(!1===a(o))throw new Error("second arg must be public key");const s=n.fromBytes(t);return e.fromBytes(o).multiply(s).toBytes(r)},keygen:l,Point:e,utils:c,lengths:r})}function ecdsa$1(e,t,n={}){ahash$1(t),validateObject(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const o=(n=Object.assign({},n)).randomBytes||randomBytes$1,r=n.hmac||((e,n)=>hmac$1(t,e,n)),{Fp:s,Fn:i}=e,{ORDER:a,BITS:c}=i,{keygen:l,getPublicKey:d,getSharedSecret:h,utils:u,lengths:f}=ecdh$1(e,n),p={prehash:!0,lowS:"boolean"!=typeof n.lowS||n.lowS,format:"compact",extraEntropy:!1},g=a*_2n$4<s.ORDER;function m(e){return e>a>>_1n$4}function b(e,t){if(!i.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function y(){if(g)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function w(e,t){validateSigFormat$1(t);const n=f.signature;return abytes$4(e,"compact"===t?n:"recovered"===t?n+1:void 0)}class v{r;s;recovery;constructor(e,t,n){if(this.r=b("r",e),this.s=b("s",t),null!=n){if(y(),![0,1,2,3].includes(n))throw new Error("invalid recovery id");this.recovery=n}Object.freeze(this)}static fromBytes(e,t=p.format){let n;if(w(e,t),"der"===t){const{r:t,s:n}=DER$1.toSig(abytes$4(e));return new v(t,n)}"recovered"===t&&(n=e[0],t="compact",e=e.subarray(1));const o=f.signature/2,r=e.subarray(0,o),s=e.subarray(o,2*o);return new v(i.fromBytes(r),i.fromBytes(s),n)}static fromHex(e,t){return this.fromBytes(hexToBytes$1(e),t)}assertRecovery(){const{recovery:e}=this;if(null==e)throw new Error("invalid recovery id: must be present");return e}addRecoveryBit(e){return new v(this.r,this.s,e)}recoverPublicKey(t){const{r:n,s:o}=this,r=this.assertRecovery(),c=2===r||3===r?n+a:n;if(!s.isValid(c))throw new Error("invalid recovery id: sig.r+curve.n != R.x");const l=s.toBytes(c),d=e.fromBytes(concatBytes$1(pprefix$1(!(1&r)),l)),h=i.inv(c),u=E(abytes$4(t,void 0,"msgHash")),f=i.create(-u*h),p=i.create(o*h),g=e.BASE.multiplyUnsafe(f).add(d.multiplyUnsafe(p));if(g.is0())throw new Error("invalid recovery: point at infinify");return g.assertValidity(),g}hasHighS(){return m(this.s)}toBytes(e=p.format){if(validateSigFormat$1(e),"der"===e)return hexToBytes$1(DER$1.hexFromSig(this));const{r:t,s:n}=this,o=i.toBytes(t),r=i.toBytes(n);return"recovered"===e?(y(),concatBytes$1(Uint8Array.of(this.assertRecovery()),o,r)):concatBytes$1(o,r)}toHex(e){return bytesToHex$1(this.toBytes(e))}}const k=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=bytesToNumberBE$1(e),n=8*e.length-c;return n>0?t>>BigInt(n):t},E=n.bits2int_modN||function(e){return i.create(k(e))},x=bitMask$1(c);function C(e){return aInRange$1("num < 2^"+c,e,_0n$5,x),i.toBytes(e)}function B(e,n){return abytes$4(e,void 0,"message"),n?abytes$4(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:l,getPublicKey:d,getSharedSecret:h,utils:u,lengths:f,Point:e,sign:function(n,s,a={}){const{seed:c,k2sig:l}=function(t,n,r){const{lowS:s,prehash:a,extraEntropy:c}=validateSigOpts$1(r,p);t=B(t,a);const l=E(t),d=i.fromBytes(n);if(!i.isValidNot0(d))throw new Error("invalid private key");const h=[C(d),C(l)];if(null!=c&&!1!==c){const e=!0===c?o(f.secretKey):c;h.push(abytes$4(e,void 0,"extraEntropy"))}const u=concatBytes$1(...h),b=l;return{seed:u,k2sig:function(t){const n=k(t);if(!i.isValidNot0(n))return;const o=i.inv(n),r=e.BASE.multiply(n).toAffine(),a=i.create(r.x);if(a===_0n$5)return;const c=i.create(o*i.create(b+a*d));if(c===_0n$5)return;let l=(r.x===a?0:2)|Number(r.y&_1n$4),h=c;return s&&m(c)&&(h=i.neg(c),l^=1),new v(a,h,g?void 0:l)}}}(n,s,a);return createHmacDrbg$1(t.outputLen,i.BYTES,r)(c,l).toBytes(a.format)},verify:function(t,n,o,r={}){const{lowS:s,prehash:a,format:c}=validateSigOpts$1(r,p);if(o=abytes$4(o,void 0,"publicKey"),n=B(n,a),!isBytes$4(t)){throw new Error("verify expects Uint8Array signature"+(t instanceof v?", use sig.toBytes()":""))}w(t,c);try{const r=v.fromBytes(t,c),a=e.fromBytes(o);if(s&&r.hasHighS())return!1;const{r:l,s:d}=r,h=E(n),u=i.inv(d),f=i.create(h*u),p=i.create(l*u),g=e.BASE.multiplyUnsafe(f).add(a.multiplyUnsafe(p));if(g.is0())return!1;return i.create(g.x)===l}catch(e){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:o}=validateSigOpts$1(n,p);return t=B(t,o),v.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:v,hash:t})}
|
|
8
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1_CURVE$1={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},secp256k1_ENDO$1={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},_0n$4=BigInt(0),_2n$3=BigInt(2);function sqrtMod$1(e){const t=secp256k1_CURVE$1.p,n=BigInt(3),
|
|
9
|
-
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function isBytes$3(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function abytes$3(e){if(!isBytes$3(e))throw new Error("Uint8Array expected")}function isArrayOf$1(e,t){return!!Array.isArray(t)&&(0===t.length||(e?t.every((e=>"string"==typeof e)):t.every((e=>Number.isSafeInteger(e)))))}function afn(e){if("function"!=typeof e)throw new Error("function expected");return!0}function astr$1(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function anumber$3(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function aArr$1(e){if(!Array.isArray(e))throw new Error("array expected")}function astrArr$1(e,t){if(!isArrayOf$1(!0,t))throw new Error(`${e}: array of strings expected`)}function anumArr$1(e,t){if(!isArrayOf$1(!1,t))throw new Error(`${e}: array of numbers expected`)}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){const t="string"==typeof e?e.split(""):e,n=t.length;astrArr$1("alphabet",t);const
|
|
10
|
-
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function isBytes$2(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function abool(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function anumber$2(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function abytes$2(e,t,n=""){const o=isBytes$2(e),r=e?.length,s=void 0!==t;if(!o||s&&r!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${t}`:"")+", got "+(o?`length=${r}`:"type="+typeof e))}return e}function u32(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function clean$1(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const isLE=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function overlapBytes(e,t){return e.buffer===t.buffer&&e.byteOffset<t.byteOffset+t.byteLength&&t.byteOffset<e.byteOffset+e.byteLength}function complexOverlapBytes(e,t){if(overlapBytes(e,t)&&e.byteOffset<t.byteOffset)throw new Error("complex overlap of input and output is not supported")}function checkOpts(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)}function equalBytes(e,t){if(e.length!==t.length)return!1;let n=0;for(let o=0;o<e.length;o++)n|=e[o]^t[o];return 0===n}const wrapCipher=(e,t)=>{function n(n,...o){if(abytes$2(n,void 0,"key"),!isLE)throw new Error("Non little-endian hardware is not yet supported");if(void 0!==e.nonceLength){abytes$2(o[0],e.varSizeNonce?void 0:e.nonceLength,"nonce")}const r=e.tagLength;r&&void 0!==o[1]&&abytes$2(o[1],void 0,"AAD");const s=t(n,...o),i=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");abytes$2(t,void 0,"output")}};let a=!1;return{encrypt(e,t){if(a)throw new Error("cannot encrypt() twice with same key + nonce");return a=!0,abytes$2(e),i(s.encrypt.length,t),s.encrypt(e,t)},decrypt(e,t){if(abytes$2(e),r&&e.length<r)throw new Error('"ciphertext" expected length bigger than tagLength='+r);return i(s.decrypt.length,t),s.decrypt(e,t)}}}return Object.assign(n,e),n};function getOutput(e,t,n=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(n&&!isAligned32$1(t))throw new Error("invalid output, must be aligned");return t}function isAligned32$1(e){return e.byteOffset%4==0}function copyBytes(e){return Uint8Array.from(e)}const BLOCK_SIZE=16,POLY=283;function validateKeyLength(e){if(![16,24,32].includes(e.length))throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length='+e.length)}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=(()=>{const 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 o=e[255-n];o|=o<<8,t[e[n]]=255&(o^o>>4^o>>5^o>>6^o>>7^99)}return clean$1(e),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,o)=>t(e[o]))),o=n.map(rotl32_8),r=o.map(rotl32_8),s=r.map(rotl32_8),i=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 d=256*t+l;i[d]=n[t]^o[l],a[d]=r[t]^s[l],c[d]=e[t]<<8|e[l]}return{sbox:e,sbox2:c,T0:n,T1:o,T2:r,T3:s,T01:i,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){abytes$2(e);const t=e.length;validateKeyLength(e);const{sbox2:n}=tableEncoding,o=[];isAligned32$1(e)||o.push(e=copyBytes(e));const r=u32(e),s=r.length,i=e=>applySbox(n,e,e,e,e),a=new Uint32Array(t+28);a.set(r);for(let e=s;e<a.length;e++){let t=a[e-1];e%s==0?t=i(rotr32_8(t))^xPowers[e/s-1]:s>6&&e%s==4&&(t=i(t)),a[e]=a[e-s]^t}return clean$1(...o),a}function expandKeyDecLE(e){const t=expandKeyLE(e),n=t.slice(),o=t.length,{sbox2:r}=tableEncoding,{T0:s,T1:i,T2:a,T3:c}=tableDecoding;for(let e=0;e<o;e+=4)for(let r=0;r<4;r++)n[e+r]=t[o-e-4+r];clean$1(t);for(let e=4;e<o-4;e++){const t=n[e],o=applySbox(r,t,t,t,t);n[e]=s[255&o]^i[o>>>8&255]^a[o>>>16&255]^c[o>>>24]}return n}function apply0123(e,t,n,o,r,s){return e[n<<8&65280|o>>>8&255]^t[r>>>8&65280|s>>>24&255]}function applySbox(e,t,n,o,r){return e[255&t|65280&n]|e[o>>>16&255|r>>>16&65280]<<16}function encrypt$1(e,t,n,o,r){const{sbox2:s,T01:i,T23:a}=tableEncoding;let c=0;t^=e[c++],n^=e[c++],o^=e[c++],r^=e[c++];const l=e.length/4-2;for(let s=0;s<l;s++){const s=e[c++]^apply0123(i,a,t,n,o,r),l=e[c++]^apply0123(i,a,n,o,r,t),d=e[c++]^apply0123(i,a,o,r,t,n),h=e[c++]^apply0123(i,a,r,t,n,o);t=s,n=l,o=d,r=h}return{s0:e[c++]^applySbox(s,t,n,o,r),s1:e[c++]^applySbox(s,n,o,r,t),s2:e[c++]^applySbox(s,o,r,t,n),s3:e[c++]^applySbox(s,r,t,n,o)}}function decrypt$1(e,t,n,o,r){const{sbox2:s,T01:i,T23:a}=tableDecoding;let c=0;t^=e[c++],n^=e[c++],o^=e[c++],r^=e[c++];const l=e.length/4-2;for(let s=0;s<l;s++){const s=e[c++]^apply0123(i,a,t,r,o,n),l=e[c++]^apply0123(i,a,n,t,r,o),d=e[c++]^apply0123(i,a,o,n,t,r),h=e[c++]^apply0123(i,a,r,o,n,t);t=s,n=l,o=d,r=h}return{s0:e[c++]^applySbox(s,t,r,o,n),s1:e[c++]^applySbox(s,n,t,r,o),s2:e[c++]^applySbox(s,o,n,t,r),s3:e[c++]^applySbox(s,r,o,n,t)}}function validateBlockDecrypt(e){if(abytes$2(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){abytes$2(e);let o=e.length;const r=o%BLOCK_SIZE;if(!t&&0!==r)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");isAligned32$1(e)||(e=copyBytes(e));const s=u32(e);if(t){let e=BLOCK_SIZE-r;e||(e=BLOCK_SIZE),o+=e}complexOverlapBytes(e,n=getOutput(o,n));return{b:s,o:u32(n),out:n}}function validatePCKS(e,t){if(!t)return e;const n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const o=e[n-1];if(o<=0||o>16)throw new Error("aes/pcks5: wrong padding");const r=e.subarray(0,-o);for(let t=0;t<o;t++)if(e[n-t-1]!==o)throw new Error("aes/pcks5: wrong padding");return r}function padPCKS(e){const t=new Uint8Array(16),n=u32(t);t.set(e);const o=BLOCK_SIZE-e.length;for(let e=BLOCK_SIZE-o;e<BLOCK_SIZE;e++)t[e]=o;return n}const cbc=wrapCipher({blockSize:16,nonceLength:16},(function(e,t,n={}){const o=!n.disablePadding;return{encrypt(n,r){const s=expandKeyLE(e),{b:i,o:a,out:c}=validateBlockEncrypt(n,o,r);let l=t;const d=[s];isAligned32$1(l)||d.push(l=copyBytes(l));const h=u32(l);let u=h[0],f=h[1],p=h[2],g=h[3],m=0;for(;m+4<=i.length;)u^=i[m+0],f^=i[m+1],p^=i[m+2],g^=i[m+3],({s0:u,s1:f,s2:p,s3:g}=encrypt$1(s,u,f,p,g)),a[m++]=u,a[m++]=f,a[m++]=p,a[m++]=g;if(o){const e=padPCKS(n.subarray(4*m));u^=e[0],f^=e[1],p^=e[2],g^=e[3],({s0:u,s1:f,s2:p,s3:g}=encrypt$1(s,u,f,p,g)),a[m++]=u,a[m++]=f,a[m++]=p,a[m++]=g}return clean$1(...d),c},decrypt(n,r){validateBlockDecrypt(n);const s=expandKeyDecLE(e);let i=t;const a=[s];isAligned32$1(i)||a.push(i=copyBytes(i));const c=u32(i);r=getOutput(n.length,r),isAligned32$1(n)||a.push(n=copyBytes(n)),complexOverlapBytes(n,r);const l=u32(n),d=u32(r);let h=c[0],u=c[1],f=c[2],p=c[3];for(let e=0;e+4<=l.length;){const t=h,n=u,o=f,r=p;h=l[e+0],u=l[e+1],f=l[e+2],p=l[e+3];const{s0:i,s1:a,s2:c,s3:g}=decrypt$1(s,h,u,f,p);d[e++]=i^t,d[e++]=a^n,d[e++]=c^o,d[e++]=g^r}return clean$1(...a),validatePCKS(r,o)}}})),encodeStr=e=>Uint8Array.from(e.split(""),(e=>e.charCodeAt(0))),sigma16=encodeStr("expand 16-byte k"),sigma32=encodeStr("expand 32-byte k"),sigma16_32=u32(sigma16),sigma32_32=u32(sigma32);function rotl(e,t){return e<<t|e>>>32-t}function isAligned32(e){return e.byteOffset%4==0}const BLOCK_LEN=64,BLOCK_LEN32=16,MAX_COUNTER=2**32-1,U32_EMPTY=Uint32Array.of();function runCipher(e,t,n,o,r,s,i,a){const c=r.length,l=new Uint8Array(BLOCK_LEN),d=u32(l),h=isAligned32(r)&&isAligned32(s),u=h?u32(r):U32_EMPTY,f=h?u32(s):U32_EMPTY;for(let p=0;p<c;i++){if(e(t,n,o,d,i,a),i>=MAX_COUNTER)throw new Error("arx: counter overflow");const g=Math.min(BLOCK_LEN,c-p);if(h&&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]^d[n];p+=BLOCK_LEN}else{for(let e,t=0;t<g;t++)e=p+t,s[e]=r[e]^l[t];p+=g}}}function createCipher(e,t){const{allowShortKeys:n,extendNonceFn:o,counterLength:r,counterRight:s,rounds:i}=checkOpts({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return anumber$2(r),anumber$2(i),abool(s),abool(n),(t,a,c,l,d=0)=>{abytes$2(t,void 0,"key"),abytes$2(a,void 0,"nonce"),abytes$2(c,void 0,"data");const h=c.length;if(void 0===l&&(l=new Uint8Array(h)),abytes$2(l,void 0,"output"),anumber$2(d),d<0||d>=MAX_COUNTER)throw new Error("arx: counter overflow");if(l.length<h)throw new Error(`arx: output (${l.length}) is shorter than data (${h})`);const u=[];let f,p,g=t.length;if(32===g)u.push(f=copyBytes(t)),p=sigma32_32;else{if(16!==g||!n)throw abytes$2(t,32,"arx key"),new Error("invalid key size");f=new Uint8Array(32),f.set(t),f.set(t,16),p=sigma16_32,u.push(f)}isAligned32(a)||u.push(a=copyBytes(a));const m=u32(f);if(o){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");o(p,m,u32(a.subarray(0,16)),m),a=a.subarray(16)}const b=16-r;if(b!==a.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(12!==b){const e=new Uint8Array(12);e.set(a,s?0:12-a.length),a=e,u.push(a)}const y=u32(a);return runCipher(e,p,m,y,c,l,d,i),clean$1(...u),l}}function chachaCore(e,t,n,o,r,s=20){let i=e[0],a=e[1],c=e[2],l=e[3],d=t[0],h=t[1],u=t[2],f=t[3],p=t[4],g=t[5],m=t[6],b=t[7],y=r,w=n[0],v=n[1],k=n[2],E=i,x=a,C=c,B=l,$=d,_=h,S=u,P=f,L=p,N=g,R=m,A=b,O=y,T=w,M=v,I=k;for(let e=0;e<s;e+=2)E=E+$|0,O=rotl(O^E,16),L=L+O|0,$=rotl($^L,12),E=E+$|0,O=rotl(O^E,8),L=L+O|0,$=rotl($^L,7),x=x+_|0,T=rotl(T^x,16),N=N+T|0,_=rotl(_^N,12),x=x+_|0,T=rotl(T^x,8),N=N+T|0,_=rotl(_^N,7),C=C+S|0,M=rotl(M^C,16),R=R+M|0,S=rotl(S^R,12),C=C+S|0,M=rotl(M^C,8),R=R+M|0,S=rotl(S^R,7),B=B+P|0,I=rotl(I^B,16),A=A+I|0,P=rotl(P^A,12),B=B+P|0,I=rotl(I^B,8),A=A+I|0,P=rotl(P^A,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),x=x+S|0,O=rotl(O^x,16),A=A+O|0,S=rotl(S^A,12),x=x+S|0,O=rotl(O^x,8),A=A+O|0,S=rotl(S^A,7),C=C+P|0,T=rotl(T^C,16),L=L+T|0,P=rotl(P^L,12),C=C+P|0,T=rotl(T^C,8),L=L+T|0,P=rotl(P^L,7),B=B+$|0,M=rotl(M^B,16),N=N+M|0,$=rotl($^N,12),B=B+$|0,M=rotl(M^B,8),N=N+M|0,$=rotl($^N,7);let U=0;o[U++]=i+E|0,o[U++]=a+x|0,o[U++]=c+C|0,o[U++]=l+B|0,o[U++]=d+$|0,o[U++]=h+_|0,o[U++]=u+S|0,o[U++]=f+P|0,o[U++]=p+L|0,o[U++]=g+N|0,o[U++]=m+R|0,o[U++]=b+A|0,o[U++]=y+O|0,o[U++]=w+T|0,o[U++]=v+M|0,o[U++]=k+I|0}const chacha20=createCipher(chachaCore,{counterRight:!1,counterLength:4,allowShortKeys:!1});function extract$1(e,t,n){return ahash$1(e),void 0===n&&(n=new Uint8Array(e.outputLen)),hmac$1(e,n,t)}const HKDF_COUNTER$1=Uint8Array.of(0),EMPTY_BUFFER$1=Uint8Array.of();function expand$1(e,t,n,o=32){ahash$1(e),anumber$4(o,"length");const r=e.outputLen;if(o>255*r)throw new Error("Length must be <= 255*HashLen");const s=Math.ceil(o/r);void 0===n?n=EMPTY_BUFFER$1:abytes$4(n,void 0,"info");const i=new Uint8Array(s*r),a=hmac$1.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let e=0;e<s;e++)HKDF_COUNTER$1[0]=e+1,c.update(0===e?EMPTY_BUFFER$1:l).update(n).update(HKDF_COUNTER$1).digestInto(l),i.set(l,r*e),a._cloneInto(c);return a.destroy(),c.destroy(),clean$2(l,HKDF_COUNTER$1),i.slice(0,o)}var __defProp=Object.defineProperty,__export=(e,t)=>{for(var n in t)__defProp(e,n,{get:t[n],enumerable:!0})},verifiedSymbol=Symbol("verified"),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("string"!=typeof n[e])return!1}return!0}var utils_exports={};__export(utils_exports,{binarySearch:()=>binarySearch,bytesToHex:()=>bytesToHex$1,hexToBytes:()=>hexToBytes$1,insertEventIntoAscendingList:()=>insertEventIntoAscendingList,insertEventIntoDescendingList:()=>insertEventIntoDescendingList,mergeReverseSortedLists:()=>mergeReverseSortedLists,normalizeURL:()=>normalizeURL,utf8Decoder:()=>utf8Decoder,utf8Encoder:()=>utf8Encoder});var utf8Decoder=new TextDecoder("utf-8"),utf8Encoder=new TextEncoder;function normalizeURL(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(e,t){const[n,o]=binarySearch(e,(e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at));return o||e.splice(n,0,t),e}function insertEventIntoAscendingList(e,t){const[n,o]=binarySearch(e,(e=>t.id===e.id?0:t.created_at===e.created_at?-1:t.created_at-e.created_at));return o||e.splice(n,0,t),e}function binarySearch(e,t){let n=0,o=e.length-1;for(;n<=o;){const r=Math.floor((n+o)/2),s=t(e[r]);if(0===s)return[r,!0];s<0?o=r-1:n=r+1}return[n,!1]}function mergeReverseSortedLists(e,t){const n=new Array(e.length+t.length);n.length=0;let o=0,r=0,s=[];for(;o<e.length&&r<t.length;){let i;if(e[o]?.created_at>t[r]?.created_at?(i=e[o],o++):(i=t[r],r++),n.length>0&&n[n.length-1].created_at===i.created_at){if(s.includes(i.id))continue}else s.length=0;n.push(i),s.push(i.id)}for(;o<e.length;){const t=e[o];if(o++,n.length>0&&n[n.length-1].created_at===t.created_at){if(s.includes(t.id))continue}else s.length=0;n.push(t),s.push(t.id)}for(;r<t.length;){const e=t[r];if(r++,n.length>0&&n[n.length-1].created_at===e.created_at){if(s.includes(e.id))continue}else s.length=0;n.push(e),s.push(e.id)}return n}var JS=class{generateSecretKey(){return schnorr.utils.randomSecretKey()}getPublicKey(e){return bytesToHex$1(schnorr.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=bytesToHex$1(schnorr.getPublicKey(t)),n.id=getEventHash(n),n.sig=bytesToHex$1(schnorr.sign(hexToBytes$1(getEventHash(n)),t)),n[verifiedSymbol]=!0,n}verifyEvent(e){if("boolean"==typeof e[verifiedSymbol])return e[verifiedSymbol];try{const t=getEventHash(e);if(t!==e.id)return e[verifiedSymbol]=!1,!1;const n=schnorr.verify(hexToBytes$1(e.sig),hexToBytes$1(t),hexToBytes$1(e.pubkey));return e[verifiedSymbol]=n,n}catch(t){return e[verifiedSymbol]=!1,!1}}};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$2(utf8Encoder.encode(serializeEvent(e))))}var i=new JS,generateSecretKey=i.generateSecretKey,getPublicKey=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(e)&&n.includes(e.kind)||!1}__export(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 o=e[`#${n.slice(1)}`];if(o&&!t.tags.find((([e,t])=>e===n.slice(1)&&-1!==o.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,o=e.indexOf(`"${t}":`)+n,r=e.slice(o).indexOf('"')+o+1;return e.slice(r,r+64)}function getInt(e,t){let n=t.length,o=e.indexOf(`"${t}":`)+n+3,r=e.slice(o),s=Math.min(r.indexOf(","),r.indexOf("}"));return parseInt(r.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 o=t+7+1+n,r=e.slice(o+1,80).indexOf('"');if(-1===r)return null;let s=o+1+r;return e.slice(o+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 nip42_exports={};function makeAuthEvent(e,t){return{kind:ClientAuth,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}__export(nip42_exports,{makeAuthEvent:()=>makeAuthEvent});var SendingOnClosedConnection=class extends Error{constructor(e,t){super(`Tried to send message '${e} on a closed connection to ${t}.`),this.name="SendingOnClosedConnection"}},AbstractRelay=class{url;_connected=!1;onclose=null;onnotice=e=>console.debug(`NOTICE from ${this.url}: ${e}`);onauth;baseEoseTimeout=4400;publishTimeout=4400;pingFrequency=29e3;pingTimeout=2e4;resubscribeBackoff=[1e4,1e4,1e4,2e4,2e4,3e4,6e4];openSubs=new Map;enablePing;enableReconnect;idleSince=Date.now();ongoingOperations=0;reconnectTimeoutHandle;pingIntervalHandle;reconnectAttempts=0;skipReconnection=!1;connectionPromise;openCountRequests=new Map;openEventPublishes=new Map;ws;challenge;authPromise;serial=0;verifyEvent;_WebSocket;constructor(e,t){this.url=normalizeURL(e),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation||WebSocket,this.enablePing=t.enablePing,this.enableReconnect=t.enableReconnect||!1}static async connect(e,t){const n=new AbstractRelay(e,t);return await n.connect(t),n}closeAllSubscriptions(e){for(let[t,n]of this.openSubs)n.close(e);this.openSubs.clear();for(let[t,n]of this.openEventPublishes)n.reject(new Error(e));this.openEventPublishes.clear();for(let[t,n]of this.openCountRequests)n.reject(new Error(e));this.openCountRequests.clear()}get connected(){return this._connected}async reconnect(){const e=this.resubscribeBackoff[Math.min(this.reconnectAttempts,this.resubscribeBackoff.length-1)];this.reconnectAttempts++,this.reconnectTimeoutHandle=setTimeout((async()=>{try{await this.connect()}catch(e){}}),e)}handleHardClose(e){this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this._connected=!1,this.connectionPromise=void 0,this.idleSince=void 0,this.enableReconnect&&!this.skipReconnection?this.reconnect():(this.onclose?.(),this.closeAllSubscriptions(e))}async connect(e){let t;return this.connectionPromise||(this.challenge=void 0,this.authPromise=void 0,this.skipReconnection=!1,this.connectionPromise=new Promise(((n,o)=>{e?.timeout&&(t=setTimeout((()=>{o("connection timed out"),this.connectionPromise=void 0,this.skipReconnection=!0,this.onclose?.(),this.handleHardClose("relay connection timed out")}),e.timeout)),e?.abort&&(e.abort.onabort=o);try{this.ws=new this._WebSocket(this.url)}catch(e){return clearTimeout(t),void o(e)}this.ws.onopen=()=>{this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),clearTimeout(t),this._connected=!0;const e=this.reconnectAttempts>0;this.reconnectAttempts=0;for(const t of this.openSubs.values()){if(t.eosed=!1,e)for(let e=0;e<t.filters.length;e++)t.lastEmitted&&(t.filters[e].since=t.lastEmitted+1);t.fire()}this.enablePing&&(this.pingIntervalHandle=setInterval((()=>this.pingpong()),this.pingFrequency)),n()},this.ws.onerror=()=>{clearTimeout(t),o("connection failed"),this.connectionPromise=void 0,this.skipReconnection=!0,this.onclose?.(),this.handleHardClose("relay connection failed")},this.ws.onclose=e=>{clearTimeout(t),o(e.message||"websocket closed"),this.handleHardClose("relay connection closed")},this.ws.onmessage=this._onmessage.bind(this)}))),this.connectionPromise}waitForPingPong(){return new Promise((e=>{this.ws.once("pong",(()=>e(!0))),this.ws.ping()}))}waitForDummyReq(){return new Promise(((e,t)=>{if(!this.connectionPromise)return t(new Error(`no connection to ${this.url}, can't ping`));try{const t=this.subscribe([{ids:["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],limit:0}],{label:"<forced-ping>",oneose:()=>{e(!0),t.close()},onclose(){e(!0)},eoseTimeout:this.pingTimeout+1e3})}catch(e){t(e)}}))}async pingpong(){if(1===this.ws?.readyState){await Promise.any([this.ws&&this.ws.ping&&this.ws.once?this.waitForPingPong():this.waitForDummyReq(),new Promise((e=>setTimeout((()=>e(!1)),this.pingTimeout)))])||this.ws?.readyState===this._WebSocket.OPEN&&this.ws?.close()}}async send(e){if(!this.connectionPromise)throw new SendingOnClosedConnection(e,this.url);this.connectionPromise.then((()=>{this.ws?.send(e)}))}async auth(e){const t=this.challenge;if(!t)throw new Error("can't perform auth, no challenge was received");return this.authPromise||(this.authPromise=new Promise((async(n,o)=>{try{let r=await e(makeAuthEvent(this.url,t)),s=setTimeout((()=>{let e=this.openEventPublishes.get(r.id);e&&(e.reject(new Error("auth timed out")),this.openEventPublishes.delete(r.id))}),this.publishTimeout);this.openEventPublishes.set(r.id,{resolve:n,reject:o,timeout:s}),this.send('["AUTH",'+JSON.stringify(r)+"]")}catch(e){console.warn("subscribe auth function failed:",e)}}))),this.authPromise}async publish(e){this.idleSince=void 0,this.ongoingOperations++;const t=new Promise(((t,n)=>{const o=setTimeout((()=>{const t=this.openEventPublishes.get(e.id);t&&(t.reject(new Error("publish timed out")),this.openEventPublishes.delete(e.id))}),this.publishTimeout);this.openEventPublishes.set(e.id,{resolve:t,reject:n,timeout:o})}));return this.send('["EVENT",'+JSON.stringify(e)+"]"),this.ongoingOperations--,0===this.ongoingOperations&&(this.idleSince=Date.now()),t}async count(e,t){this.serial++;const n=t?.id||"count:"+this.serial,o=new Promise(((e,t)=>{this.openCountRequests.set(n,{resolve:e,reject:t})}));return this.send('["COUNT","'+n+'",'+JSON.stringify(e).substring(1)),o}subscribe(e,t){"<forced-ping>"!==t.label&&(this.idleSince=void 0,this.ongoingOperations++);const n=this.prepareSubscription(e,t);return n.fire(),t.abort&&(t.abort.onabort=()=>n.close(String(t.abort.reason||"<aborted>"))),n}prepareSubscription(e,t){this.serial++;const n=t.id||(t.label?t.label+":":"sub:")+this.serial,o=new Subscription(this,n,e,t);return this.openSubs.set(n,o),o}close(){this.skipReconnection=!0,this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,this.idleSince=void 0,this.onclose?.(),this.ws?.readyState===this._WebSocket.OPEN&&this.ws?.close()}_onmessage(e){const t=e.data;if(!t)return;const n=getSubscriptionId(t);if(n){const e=this.openSubs.get(n);if(!e)return;const o=getHex64(t,"id"),r=e.alreadyHaveEvent?.(o);if(e.receivedEvent?.(this,o),r)return}try{let e=JSON.parse(t);switch(e[0]){case"EVENT":{const t=this.openSubs.get(e[1]),n=e[2];return this.verifyEvent(n)&&matchFilters(t.filters,n)?t.onevent(n):t.oninvalidevent?.(n),void((!t.lastEmitted||t.lastEmitted<n.created_at)&&(t.lastEmitted=n.created_at))}case"COUNT":{const t=e[1],n=e[2],o=this.openCountRequests.get(t);return void(o&&(o.resolve(n.count),this.openCountRequests.delete(t)))}case"EOSE":{const t=this.openSubs.get(e[1]);if(!t)return;return void t.receivedEose()}case"OK":{const t=e[1],n=e[2],o=e[3],r=this.openEventPublishes.get(t);return void(r&&(clearTimeout(r.timeout),n?r.resolve(o):r.reject(new Error(o)),this.openEventPublishes.delete(t)))}case"CLOSED":{const t=e[1],n=this.openSubs.get(t);if(!n)return;return n.closed=!0,void n.close(e[2])}case"NOTICE":return void this.onnotice(e[1]);case"AUTH":return this.challenge=e[1],void(this.onauth&&this.auth(this.onauth));default:{const t=this.openSubs.get(e[1]);return void t?.oncustom?.(e)}}}catch(e){try{const[n,o,r]=JSON.parse(t);console.warn(`[nostr] relay ${this.url} error processing message:`,e,r)}catch(t){console.warn(`[nostr] relay ${this.url} error processing message:`,e)}return}}},Subscription=class{relay;id;lastEmitted;closed=!1;eosed=!1;filters;alreadyHaveEvent;receivedEvent;onevent;oninvalidevent;oneose;onclose;oncustom;eoseTimeout;eoseTimeoutHandle;constructor(e,t,n,o){if(0===n.length)throw new Error("subscription can't be created with zero filters");this.relay=e,this.filters=n,this.id=t,this.alreadyHaveEvent=o.alreadyHaveEvent,this.receivedEvent=o.receivedEvent,this.eoseTimeout=o.eoseTimeout||e.baseEoseTimeout,this.oneose=o.oneose,this.onclose=o.onclose,this.oninvalidevent=o.oninvalidevent,this.onevent=o.onevent||(e=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,e)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,this.oneose?.())}close(e="closed by caller"){if(!this.closed&&this.relay.connected){try{this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]")}catch(e){if(!(e instanceof SendingOnClosedConnection))throw e}this.closed=!0}this.relay.openSubs.delete(this.id),this.relay.ongoingOperations--,0===this.relay.ongoingOperations&&(this.relay.idleSince=Date.now()),this.onclose?.(e)}},_WebSocket;try{_WebSocket=WebSocket}catch{}var Relay=class extends AbstractRelay{constructor(e,t){super(e,{verifyEvent:verifyEvent,websocketImplementation:_WebSocket,...t})}static async connect(e,t){const n=new Relay(e,t);return await n.connect(),n}},_WebSocket2;try{_WebSocket2=WebSocket}catch{}var nip19_exports={};__export(nip19_exports,{BECH32_REGEX:()=>BECH32_REGEX,Bech32MaxSize:()=>Bech32MaxSize,NostrTypeGuard:()=>NostrTypeGuard,decode:()=>decode,decodeNostrURI:()=>decodeNostrURI,encodeBytes:()=>encodeBytes,naddrEncode:()=>naddrEncode,neventEncode:()=>neventEncode,noteEncode:()=>noteEncode,nprofileEncode:()=>nprofileEncode,npubEncode:()=>npubEncode,nsecEncode:()=>nsecEncode});var 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=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 decodeNostrURI(e){try{return e.startsWith("nostr:")&&(e=e.substring(6)),decode(e)}catch(e){return{type:"invalid",data:null}}}function decode(e){let{prefix:t,words:n}=bech32.decode(e,Bech32MaxSize),o=new Uint8Array(bech32.fromWords(n));switch(t){case"nprofile":{let e=parseTLV(o);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(o);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(o);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"nsec":return{type:t,data:o};case"npub":case"note":return{type:t,data:bytesToHex$1(o)};default:throw new Error(`unknown prefix ${t}`)}}function parseTLV(e){let t={},n=e;for(;n.length>0;){let e=n[0],o=n[1],r=n.slice(2,2+o);if(n=n.slice(2+o),r.length<o)throw new Error(`not enough data to read on TLV ${e}`);t[e]=t[e]||[],t[e].push(r)}return t}function nsecEncode(e){return encodeBytes("nsec",e)}function npubEncode(e){return encodeBytes("npub",hexToBytes$1(e))}function noteEncode(e){return encodeBytes("note",hexToBytes$1(e))}function encodeBech32(e,t){let n=bech32.toWords(t);return bech32.encode(e,n,Bech32MaxSize)}function encodeBytes(e,t){return encodeBech32(e,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 void 0!==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 encodeTLV(e){let t=[];return Object.entries(e).reverse().forEach((([e,n])=>{n.forEach((n=>{let o=new Uint8Array(n.length+2);o.set([parseInt(e)],0),o.set([n.length],1),o.set(n,2),t.push(o)}))})),concatBytes$1(...t)}var nip04_exports={};function encrypt(e,t,n){const o=e instanceof Uint8Array?e:hexToBytes$1(e),r=getNormalizedX(secp256k1$1.getSharedSecret(o,hexToBytes$1("02"+t)));let s=Uint8Array.from(randomBytes$1(16)),i=utf8Encoder.encode(n),a=cbc(r,s).encrypt(i);return`${base64$1.encode(new Uint8Array(a))}?iv=${base64$1.encode(new Uint8Array(s.buffer))}`}function decrypt(e,t,n){const o=e instanceof Uint8Array?e:hexToBytes$1(e);let[r,s]=n.split("?iv="),i=getNormalizedX(secp256k1$1.getSharedSecret(o,hexToBytes$1("02"+t))),a=base64$1.decode(s),c=base64$1.decode(r),l=cbc(i,a).decrypt(c);return utf8Decoder.decode(l)}function getNormalizedX(e){return e.slice(1,33)}__export(nip04_exports,{decrypt:()=>decrypt,encrypt:()=>encrypt});var nip05_exports={};__export(nip05_exports,{NIP05_REGEX:()=>NIP05_REGEX,isNip05:()=>isNip05,isValid:()=>isValid,queryProfile:()=>queryProfile,searchDomain:()=>searchDomain,useFetchImplementation:()=>useFetchImplementation});var NIP05_REGEX=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,isNip05=e=>NIP05_REGEX.test(e||""),_fetch;try{_fetch=fetch}catch(e){}function useFetchImplementation(e){_fetch=e}async function searchDomain(e,t=""){try{const n=`https://${e}/.well-known/nostr.json?name=${t}`,o=await _fetch(n,{redirect:"manual"});if(200!==o.status)throw Error("Wrong response code");return(await o.json()).names}catch(e){return{}}}async function queryProfile(e){const t=e.match(NIP05_REGEX);if(!t)return null;const[,n="_",o]=t;try{const e=`https://${o}/.well-known/nostr.json?name=${n}`,t=await _fetch(e,{redirect:"manual"});if(200!==t.status)throw Error("Wrong response code");const r=await t.json(),s=r.names[n];return s?{pubkey:s,relays:r.relays?.[s]}:null}catch(e){return null}}async function isValid(e,t){const n=await queryProfile(t);return!!n&&n.pubkey===e}var nip10_exports={};function parse(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,o;for(let r=e.tags.length-1;r>=0;r--){const s=e.tags[r];if("e"===s[0]&&s[1]){const[e,r,i,a,c]=s,l={id:r,relays:i?[i]:[],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?o=l:n=l,t.mentions.push(l)}else{if("q"===s[0]&&s[1]){const[e,n,o]=s;t.quotes.push({id:n,relays:o?[o]:[]})}"p"===s[0]&&s[1]&&t.profiles.push({pubkey:s[1],relays:s[2]?[s[2]]:[]})}}return t.root||(t.root=o||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(nip10_exports,{parse:()=>parse});var nip11_exports={},_fetch2;__export(nip11_exports,{fetchRelayInformation:()=>fetchRelayInformation,useFetchImplementation:()=>useFetchImplementation2});try{_fetch2=fetch}catch{}function useFetchImplementation2(e){_fetch2=e}async function fetchRelayInformation(e){return await(await fetch(e.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}var nip13_exports={};function getPow(e){let t=0;for(let n=0;n<64;n+=8){const o=parseInt(e.substring(n,n+8),16);if(0!==o){t+=Math.clz32(o);break}t+=32}return t}function getPowFromBytes(e){let t=0;for(let n=0;n<e.length;n++){const o=e[n];if(0!==o){t+=Math.clz32(o)-24;break}t+=8}return t}function minePow(e,t){let n=0;const o=e,r=["nonce",n.toString(),t.toString()];for(o.tags.push(r);;){const e=Math.floor((new Date).getTime()/1e3);e!==o.created_at&&(n=0,o.created_at=e),r[1]=(++n).toString();const s=sha256$2(utf8Encoder.encode(JSON.stringify([0,o.pubkey,o.created_at,o.kind,o.tags,o.content])));if(getPowFromBytes(s)>=t){o.id=bytesToHex$1(s);break}}return o}__export(nip13_exports,{getPow:()=>getPow,minePow:()=>minePow});var nip17_exports={};__export(nip17_exports,{unwrapEvent:()=>unwrapEvent2,unwrapManyEvents:()=>unwrapManyEvents2,wrapEvent:()=>wrapEvent2,wrapManyEvents:()=>wrapManyEvents2});var nip59_exports={};__export(nip59_exports,{createRumor:()=>createRumor,createSeal:()=>createSeal,createWrap:()=>createWrap,unwrapEvent:()=>unwrapEvent,unwrapManyEvents:()=>unwrapManyEvents,wrapEvent:()=>wrapEvent,wrapManyEvents:()=>wrapManyEvents});var nip44_exports={};__export(nip44_exports,{decrypt:()=>decrypt2,encrypt:()=>encrypt2,getConversationKey:()=>getConversationKey,v2:()=>v2});var minPlaintextSize=1,maxPlaintextSize=65535;function getConversationKey(e,t){const n=secp256k1$1.getSharedSecret(e,hexToBytes$1("02"+t)).subarray(1,33);return extract$1(sha256$2,n,utf8Encoder.encode("nip44-v2"))}function getMessageKeys(e,t){const n=expand$1(sha256$2,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.encode(e),n=t.length;return concatBytes$1(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.decode(n)}function hmacAad(e,t,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const o=concatBytes$1(n,t);return hmac$1(sha256$2,e,o)}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 o=n.length;if(o<99||o>65603)throw new Error("invalid data length: "+o);const r=n[0];if(2!==r)throw new Error("unknown encryption version "+r);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}function encrypt2(e,t,n=randomBytes$1(32)){const{chacha_key:o,chacha_nonce:r,hmac_key:s}=getMessageKeys(t,n),i=pad(e),a=chacha20(o,r,i),c=hmacAad(s,a,n);return base64$1.encode(concatBytes$1(new Uint8Array([2]),n,a,c))}function decrypt2(e,t){const{nonce:n,ciphertext:o,mac:r}=decodePayload(e),{chacha_key:s,chacha_nonce:i,hmac_key:a}=getMessageKeys(t,n);if(!equalBytes(hmacAad(a,o,n),r))throw new Error("invalid MAC");return unpad(chacha20(s,i,o))}var v2={utils:{getConversationKey:getConversationKey,calcPaddedLen:calcPaddedLen},encrypt:encrypt2,decrypt:decrypt2},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(JSON.stringify(e),nip44ConversationKey(t,n)),nip44Decrypt=(e,t)=>JSON.parse(decrypt2(e.content,nip44ConversationKey(t,e.pubkey)));function createRumor(e,t){const n={created_at:now(),content:"",tags:[],...e,pubkey:getPublicKey(t)};return n.id=getEventHash(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(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 o=getPublicKey(t),r=[wrapEvent(e,t,o)];return n.forEach((n=>{r.push(wrapEvent(e,t,n))})),r}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,o){const r={created_at:Math.ceil(Date.now()/1e3),kind:PrivateDirectMessage,tags:[],content:t};return(Array.isArray(e)?e:[e]).forEach((({publicKey:e,relayUrl:t})=>{r.tags.push(t?["p",e,t]:["p",e])})),o&&r.tags.push(["e",o.eventId,o.relayUrl||"","reply"]),n&&r.tags.push(["subject",n]),r}function wrapEvent2(e,t,n,o,r){return wrapEvent(createEvent(t,n,o,r),e,t.publicKey)}function wrapManyEvents2(e,t,n,o,r){if(!t||0===t.length)throw new Error("At least one recipient is required.");return[{publicKey:getPublicKey(e)},...t].map((t=>wrapEvent2(e,t,n,o,r)))}var unwrapEvent2=unwrapEvent,unwrapManyEvents2=unwrapManyEvents,nip18_exports={};function finishRepostEvent(e,t,n,o){let r;const s=[...e.tags??[],["e",t.id,n],["p",t.pubkey]];return t.kind===ShortTextNote?r=Repost:(r=GenericRepost,s.push(["k",String(t.kind)])),finalizeEvent({kind:r,tags:s,content:""===e.content||t.tags?.find((e=>"-"===e[0]))?"":JSON.stringify(t),created_at:e.created_at},o)}function getRepostedEventPointer(e){if(![Repost,GenericRepost].includes(e.kind))return;let t,n;for(let o=e.tags.length-1;o>=0&&(void 0===t||void 0===n);o--){const r=e.tags[o];r.length>=2&&("e"===r[0]&&void 0===t?t=r:"p"===r[0]&&void 0===n&&(n=r))}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 o;try{o=JSON.parse(e.content)}catch(e){return}return o.id===n.id&&(t||verifyEvent(o))?o: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 o=t.tags.filter((e=>e.length>=2&&("e"===e[0]||"p"===e[0])));return finalizeEvent({...e,kind:Reaction,tags:[...e.tags??[],...o,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function getReactedEventPointer(e){if(e.kind!==Reaction)return;let t,n;for(let o=e.tags.length-1;o>=0&&(void 0===t||void 0===n);o--){const r=e.tags[o];r.length>=2&&("e"===r[0]&&void 0===t?t=r:"p"===r[0]&&void 0===n&&(n=r))}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 nip27_exports={};__export(nip27_exports,{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 o=e.tags[n];"emoji"===o[0]&&o.length>=3&&t.push({type:"emoji",shortcode:o[1],url:o[2]})}e=e.content}const n=e.length;let o=0,r=0;e:for(;r<n;){const s=e.indexOf(":",r),i=e.indexOf("#",r);if(-1===s&&-1===i)break e;if(-1===s||i>=0&&i<s){if(0===i||e[i-1].match(noCharacter)){const t=e.slice(i+1,i+MAX_HASHTAG_LENGTH).match(noCharacter),s=t?i+1+t.index:n;yield{type:"text",text:e.slice(o,i)},yield{type:"hashtag",value:e.slice(i+1,s)},r=s,o=r;continue e}r=i+1}else if("nostr"===e.slice(s-5,s)){const t=e.slice(s+60).match(noCharacter),i=t?s+60+t.index:n;try{let t,{data:n,type:a}=decode(e.slice(s+1,i));switch(a){case"npub":t={pubkey:n};break;case"note":t={id:n};break;case"nsec":r=i+1;continue;default:t=n}o!==s-5&&(yield{type:"text",text:e.slice(o,s-5)}),yield{type:"reference",pointer:t},r=i,o=r;continue e}catch(e){r=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),i=t?s+4+t.index:n,a="s"===e[s-1]?5:4;try{let t=new URL(e.slice(s-a,i));if(-1===t.hostname.indexOf("."))throw new Error("invalid url");if(o!==s-a&&(yield{type:"text",text:e.slice(o,s-a)}),/\.(png|jpe?g|gif|webp|heic|svg)$/i.test(t.pathname)){yield{type:"image",url:t.toString()},r=i,o=r;continue e}if(/\.(mp4|avi|webm|mkv|mov)$/i.test(t.pathname)){yield{type:"video",url:t.toString()},r=i,o=r;continue e}if(/\.(mp3|aac|ogg|opus|wav|flac)$/i.test(t.pathname)){yield{type:"audio",url:t.toString()},r=i,o=r;continue e}yield{type:"url",url:t.toString()},r=i,o=r;continue e}catch(e){r=i+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 i=t[n];if(":"===e[s+i.shortcode.length+1]&&e.slice(s+1,s+i.shortcode.length+1)===i.shortcode){o!==s&&(yield{type:"text",text:e.slice(o,s)}),yield i,r=s+i.shortcode.length+2,o=r;continue e}}r=s+1;continue e}{const t=e.slice(s+4).match(noURLCharacter),i=t?s+4+t.index:n,a="s"===e[s-1]?3:2;try{let t=new URL(e.slice(s-a,i));if(-1===t.hostname.indexOf("."))throw new Error("invalid ws url");o!==s-a&&(yield{type:"text",text:e.slice(o,s-a)}),yield{type:"relay",url:t.toString()},r=i,o=r;continue e}catch(e){r=i+1;continue e}}}}o!==n&&(yield{type:"text",text:e.slice(o)})}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 finalizeEvent({kind:ChannelCreation,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 finalizeEvent({kind:ChannelMetadata,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"]),finalizeEvent({kind:ChannelMessage,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 finalizeEvent({kind:ChannelHideMessage,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 finalizeEvent({kind:ChannelMuteUser,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)},nip30_exports={};__export(nip30_exports,{EMOJI_SHORTCODE_REGEX:()=>EMOJI_SHORTCODE_REGEX,matchAll:()=>matchAll,regex:()=>regex,replaceAll:()=>replaceAll});var EMOJI_SHORTCODE_REGEX=/:(\w+):/,regex=()=>new RegExp(`\\B${EMOJI_SHORTCODE_REGEX.source}\\B`,"g");function*matchAll(e){const t=e.matchAll(regex());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(e,t){return e.replaceAll(regex(),((e,n)=>t({shortcode:e,name:n})))}var nip39_exports={},_fetch3;__export(nip39_exports,{useFetchImplementation:()=>useFetchImplementation3,validateGithub:()=>validateGithub});try{_fetch3=fetch}catch{}function useFetchImplementation3(e){_fetch3=e}async function validateGithub(e,t,n){try{return await(await _fetch3(`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={};function parseConnectionString(e){const{host:t,pathname:n,searchParams:o}=new URL(e),r=n||t,s=o.get("relay"),i=o.get("secret");if(!r||!s||!i)throw new Error("invalid connection string");return{pubkey:r,relay:s,secret:i}}async function makeNwcRequestEvent(e,t,n){const o={method:"pay_invoice",params:{invoice:n}},r=encrypt(t,e,JSON.stringify(o)),s={kind:NWCWalletRequest,created_at:Math.round(Date.now()/1e3),content:r,tags:[["p",e]]};return finalizeEvent(s,t)}__export(nip47_exports,{makeNwcRequestEvent:()=>makeNwcRequestEvent,parseConnectionString:()=>parseConnectionString});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(nip54_exports,{normalizeIdentifier:()=>normalizeIdentifier});var nip57_exports={},_fetch4;__export(nip57_exports,{getSatoshisAmountFromBolt11:()=>getSatoshisAmountFromBolt11,getZapEndpoint:()=>getZapEndpoint,makeZapReceipt:()=>makeZapReceipt,makeZapRequest:()=>makeZapRequest,useFetchImplementation:()=>useFetchImplementation4,validateZapRequest:()=>validateZapRequest});try{_fetch4=fetch}catch{}function useFetchImplementation4(e){_fetch4=e}async function getZapEndpoint(e){try{let t="",{lud06:n,lud16:o}=JSON.parse(e.content);if(o){let[e,n]=o.split("@");t=new URL(`/.well-known/lnurlp/${e}`,`https://${n}`).toString()}else{if(!n)return null;{let{words:e}=bech32.decode(n,1e3),o=bech32.fromWords(e);t=utf8Decoder.decode(o)}}let r=await _fetch4(t),s=await r.json();if(s.allowsNostr&&s.nostrPubkey)return s.callback}catch(e){}return null}function makeZapRequest(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 o=["a",`${e.event.kind}:${e.event.pubkey}:${n[1]}`];t.tags.push(o)}t.tags.push(["k",e.event.kind.toString()])}return t}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(!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 o=t.tags.find((([e,t])=>"e"===e&&t));return o&&!o[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:o}){let r=JSON.parse(e),s=r.tags.filter((([e])=>"e"===e||"p"===e||"a"===e)),i={kind:9735,created_at:Math.round(o.getTime()/1e3),content:"",tags:[...s,["P",r.pubkey],["bolt11",n],["description",e]]};return t&&i.tags.push(["preimage",t]),i}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 o=n.substring(4);if(o.length<1)return 0;const r=o[o.length-1],s=r.charCodeAt(0)-"0".charCodeAt(0),i=s>=0&&s<=9;let a=o.length-1;if(i&&a++,a<1)return 0;const c=parseInt(o.substring(0,a));switch(r){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(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,o=new DataView(this.buf.buffer),r=new DataView(e.buffer);for(let e=0;e<8;e++){let s=4*e,i=o.getUint32(s,!0);i+=t,i+=r.getUint32(s,!0),i>4294967295&&(n=1),o.setUint32(s,4294967295&i,!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$2(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$1(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 o=e;o<t&&n(this.items[o],o);++o);}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,o){let r=n-t;for(;r>0;){let n=t,s=Math.floor(r/2);n+=s,o(e[n])?(t=++n,r-=s+1):r=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$1(e.unwrap())}reconcile(e,t,n){const o=new WrappedBuffer(hexToBytes$1(e));this.lastTimestampIn=this.lastTimestampOut=0;let r=new WrappedBuffer;r.extend(new Uint8Array([PROTOCOL_VERSION]));let s=getByte(o);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 i=this.storage.size(),a=this._bound(0),c=0,l=!1;for(;0!==o.length;){let e=new WrappedBuffer,s=()=>{l&&(l=!1,e.extend(this.encodeBound(a)),e.extend(encodeVarInt(Mode.Skip)))},d=this.decodeBound(o),h=decodeVarInt(o),u=c,f=this.storage.findLowerBound(c,i,d);if(h===Mode.Skip)l=!0;else if(h===Mode.Fingerprint){0!==compareUint8Array(getBytes(o,FINGERPRINT_SIZE),this.storage.fingerprint(u,f))?(s(),this.splitRange(u,f,d,e)):l=!0}else{if(h!==Mode.IdList)throw Error("unexpected mode");{let e=decodeVarInt(o),r={};for(let t=0;t<e;t++){let e=getBytes(o,ID_SIZE);r[bytesToHex$1(e)]=e}if(l=!0,this.storage.iterate(u,f,(e=>{let n=e.id;const o=bytesToHex$1(n);return r[o]?delete r[bytesToHex$1(n)]:t?.(o),!0})),n)for(let e of Object.values(r))n(bytesToHex$1(e))}}if(this.exceededFrameSizeLimit(r.length+e.length)){let e=this.storage.fingerprint(f,i);r.extend(this.encodeBound(this._bound(Number.MAX_VALUE))),r.extend(encodeVarInt(Mode.Fingerprint)),r.extend(e);break}r.extend(e),c=f,a=d}return 1===r.length?null:bytesToHex$1(r.unwrap())}splitRange(e,t,n,o){let r=t-e;if(r<32)o.extend(this.encodeBound(n)),o.extend(encodeVarInt(Mode.IdList)),o.extend(encodeVarInt(r)),this.storage.iterate(e,t,(e=>(o.extend(e.id),!0)));else{let s=Math.floor(r/16),i=r%16,a=e;for(let e=0;e<16;e++){let r,c=s+(e<i?1:0),l=this.storage.fingerprint(a,a+c);if(a+=c,a===t)r=n;else{let e,t;this.storage.iterate(a-1,a+1,((n,o)=>(o===a-1?e=n:t=n,!0))),r=this.getMinimalBound(e,t)}o.extend(this.encodeBound(r)),o.extend(encodeVarInt(Mode.Fingerprint)),o.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,o=t.id,r=e.id;for(let e=0;e<ID_SIZE&&o[e]===r[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,o={}){this.relay=e,this.storage=t,this.neg=new Negentropy(t),this.onhave=o.onhave,this.onneed=o.onneed,this.filter=n,this.subscription=this.relay.prepareSubscription([{}],{label:o.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(),o.onclose?.())}catch(e){console.error("negentropy reconcile error:",e),o?.onclose?.(`reconcile error: ${e}`)}break;case"NEG-CLOSE":{const t=e[2];console.warn("negentropy error:",t),o.onclose?.(t);break}case"NEG-ERR":o.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={};__export(nip98_exports,{getToken:()=>getToken,hashPayload:()=>hashPayload,unpackEventFromToken:()=>unpackEventFromToken,validateEvent:()=>validateEvent2,validateEventKind:()=>validateEventKind,validateEventMethodTag:()=>validateEventMethodTag,validateEventPayloadTag:()=>validateEventPayloadTag,validateEventTimestamp:()=>validateEventTimestamp,validateEventUrlTag:()=>validateEventUrlTag,validateToken:()=>validateToken});var _authorizationScheme="Nostr ";async function getToken(e,t,n,o=!1,r){const s={kind:HTTPAuth,tags:[["u",e],["method",t]],created_at:Math.round((new Date).getTime()/1e3),content:""};r&&s.tags.push(["payload",hashPayload(r)]);const i=await n(s);return(o?_authorizationScheme:"")+base64$1.encode(utf8Encoder.encode(JSON.stringify(i)))}async function validateToken(e,t,n){const o=await unpackEventFromToken(e).catch((e=>{throw e}));return await validateEvent2(o,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)}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$1(sha256$2(utf8Encoder.encode(JSON.stringify(e))))}function validateEventPayloadTag(e,t){const n=e.tags.find((e=>"payload"===e[0]));if(!n)return!1;const o=hashPayload(t);return n.length>0&&n[1]===o}async function validateEvent2(e,t,n,o){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(o)&&"object"==typeof o&&Object.keys(o).length>0&&!validateEventPayloadTag(e,o))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}const crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;
|
|
11
|
-
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function isBytes$1(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function anumber$1(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function abytes$1(e,...t){if(!isBytes$1(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$1(e.outputLen),anumber$1(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$1(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(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function rotr(e,t){return e<<32-t|e>>>t}const hasHexBuiltin=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),hexes=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function bytesToHex(e){if(abytes$1(e),hasHexBuiltin)return e.toHex();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);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 o=new Uint8Array(n);for(let t=0,r=0;t<n;t++,r+=2){const n=asciiToBase16(e.charCodeAt(r)),s=asciiToBase16(e.charCodeAt(r+1));if(void 0===n||void 0===s){const t=e[r]+e[r+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+r)}o[t]=16*n+s}return o}function utf8ToBytes(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function toBytes(e){return"string"==typeof e&&(e=utf8ToBytes(e)),abytes$1(e),e}function concatBytes(...e){let t=0;for(let n=0;n<e.length;n++){const o=e[n];abytes$1(o),t+=o.length}const n=new Uint8Array(t);for(let t=0,o=0;t<e.length;t++){const r=e[t];n.set(r,o),o+=r.length}return n}class Hash{}function createHasher(e){const t=t=>e().update(toBytes(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function randomBytes(e=32){if(crypto&&"function"==typeof crypto.getRandomValues)return crypto.getRandomValues(new Uint8Array(e));if(crypto&&"function"==typeof crypto.randomBytes)return Uint8Array.from(crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}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=e.pubkey;return n?new Promise((e=>{let o=!1;const r=setTimeout((()=>{o||e(null)}),8e3),s=[];for(const i of t.relays.values())if(i.connected)try{const t=i.subscribe([{kinds:[0],authors:[n],limit:1}],{onevent:t=>{if(!o){o=!0,clearTimeout(r);for(const e of s)try{e()}catch(e){}try{const n=JSON.parse(t.content);e(n)}catch{e(null)}}},oneose:()=>{}});s.push((()=>t.close()))}catch(e){console.warn("fetchProfile: subscribe failed on",i.url,e)}0===s.length&&(clearTimeout(r),e(null))})):null},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,o,r)=>{const s={name:e.name},i=[];window.location.hostname&&i.push(["client",window.location.hostname]);const a=finalizeEvent({kind:0,created_at:Math.floor(Date.now()/1e3),tags:i,content:JSON.stringify(s)},hexToBytes(n.privateKey)),c=prepareSignupRelays(o).map((e=>["r",e])),l=finalizeEvent({kind:10002,created_at:Math.floor(Date.now()/1e3),tags:c,content:""},hexToBytes(n.privateKey));console.log("signed profile",a),console.log("signed relays",l);const d=r&&r.length?r:OUTBOX_RELAYS$1,h=[];for(const e of d)h.push((async()=>{try{const t=await Relay.connect(e);await t.publish(a),console.log("published profile to",e),await t.publish(l),console.log("published relays to",e),t.close()}catch(t){console.warn("createProfile: failed to publish to",e,t)}})());await Promise.allSettled(h)},bunkerUrlToInfo=(e,t="")=>{const n=new URL(e);return{pubkey:"",signerPubkey:n.hostname||n.pathname.split("//")[1],sk:t||bytesToHex(generateSecretKey()),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,o]=e.toLocaleLowerCase().split("@"),r=t.devOverrideBunkerOrigin||`https://${o}`,s=`${r}/.well-known/nostr.json?name=_`,i=`${r}/.well-known/nostr.json?name=${n}`,a=await fetch(s),c=await a.json(),l=c.names._,d=c.nip46[l],h=await fetch(i),u=(await h.json()).names[n];if(!d.length)throw new Error("Bunker relay not provided");return`bunker://${u}?relay=${d[0]}`}throw new Error("Invalid user name or bunker url")},checkNip05=async e=>{let t=!1,n="",o="";return await(async()=>{if(!e||!e.includes("@"))return;const[r,s]=e.toLocaleLowerCase().split("@");if(!r)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=${r.toLowerCase()}`;try{const e=await fetch(i),t=await e.json();if(t.names[r])return void(o=t.names[r])}catch{}t=!0})(),{available:t,taken:""!=o,error:n,pubkey:o}},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 o=t,r=t.findIndex((t=>t.pubkey===e.pubkey&&t.authMethod===e.authMethod));-1!==r?o[r]=e:o.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(o))},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)||[],o=localStorageGetItem(RECENT_ACCOUNTS)||[];n.forEach((e=>upgradeInfo(e))),o.forEach((e=>upgradeInfo(e)));const r=o;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=o.findIndex((e=>e.pubkey===t.pubkey&&e.authMethod===t.authMethod));-1!==e?r[e]=t:r.push(t)}const s=n.filter((t=>t.pubkey!==e.pubkey||t.authMethod!==e.authMethod));localStorageSetItem(RECENT_ACCOUNTS,JSON.stringify(r)),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",CALL_TIMEOUT=5e3,AUTH_URL_CALL_TIMEOUT=12e4,DEFAULT_NIP46_RELAYS=["wss://relay.nsec.app/","wss://ephemeral.snowflare.cc/"],NIP46_REQUEST_TIMEOUT=3e4;class Nip46Error extends Error{code;constructor(e,t){super(e),this.name="Nip46Error",this.code=t}get retryable(){return"TIMEOUT"===this.code||"RELAY_DISCONNECTED"===this.code}}class RelayPool{relays=new Map;_relayUrls=[];addRelay(e){this._relayUrls.includes(e)||this._relayUrls.push(e)}removeRelay(e){const t=this.relays.get(e);if(t){try{t.close()}catch(e){}this.relays.delete(e)}this._relayUrls=this._relayUrls.filter((t=>t!==e))}removeAllRelays(){for(const e of[...this.relays.keys()])this.removeRelay(e);this._relayUrls=[]}async connect(e=1e4){const t=this._relayUrls.map((async e=>{if(!this.relays.has(e)||!this.relays.get(e).connected)try{const t=await Relay.connect(e);this.relays.set(e,t)}catch(t){console.warn("RelayPool: failed to connect to "+e,t)}}));await Promise.race([Promise.allSettled(t),new Promise((t=>setTimeout(t,e)))]),this.isAnyConnected()||await new Promise((e=>setTimeout(e,500)))}disconnectAll(){for(const e of this.relays.values())try{e.close()}catch(e){}this.relays.clear()}isAnyConnected(){return Array.from(this.relays.values()).some((e=>e.connected))}get relayUrls(){return[...this._relayUrls]}async publish(e){const t=[];for(const n of this.relays.values())n.connected&&t.push(n.publish(e).then((()=>{})).catch((e=>{console.warn("RelayPool: publish failed on",n.url,e)})));if(0===t.length)throw new Nip46Error("No connected relays to publish to","RELAY_DISCONNECTED");await Promise.allSettled(t)}subscribe(e,t){const n=[];for(const o of this.relays.values())if(o.connected)try{const r=o.subscribe([e],{onevent:e=>t(e)});n.push(r)}catch(e){console.warn("RelayPool: subscribe failed on",o.url,e)}return()=>{for(const e of n)try{e.close()}catch(e){}}}}class NostrRpc extends lib.EventEmitter{pool;_signer;requests=new Set;unsub;lastSubscribeFilter;requestTimers=new Map;_useNip44=!1;constructor(e,t){super(),this.pool=e,this._signer=t}subscribe(e){e.kinds=e.kinds?.filter((e=>24133===e)),this.lastSubscribeFilter={...e},this.unsub=this.pool.subscribe(e,(async e=>{try{const t=await this.parseEvent(e);t.method?this.emit("request",t):this.emit("response-"+t.id,t)}catch(e){console.error("error parsing event in subscription",e)}}))}ensureSubscription(){if(this.unsub)return;const e=this._signer.pubkey;console.log("ensureSubscription: subscribing for",e),this.subscribe({kinds:[24133],"#p":[e]})}stop(){this.unsub&&(this.unsub(),this.unsub=void 0)}resubscribe(){this.lastSubscribeFilter?(console.log("resubscribe: re-subscribing with filter",this.lastSubscribeFilter),this.stop(),this.subscribe(this.lastSubscribeFilter)):console.warn("resubscribe: no previous filter to resubscribe with")}isSubscriptionActive(){return!this.lastSubscribeFilter||!!this.unsub}clearPendingRequests(){for(const[e,t]of this.requestTimers.entries())clearTimeout(t),this.requestTimers.delete(e);this.requests.clear(),console.log("clearPendingRequests: all pending requests cleared")}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=e.pubkey,n=this.isNip04(e.content)?this._signer.decrypt:this._signer.decryptNip44,o=await n.call(this._signer,{pubkey:t},e.content),r=JSON.parse(o),{id:s,method:i,params:a,result:c,error:l}=r;return i?{id:s,pubkey:e.pubkey,method:i,params:a,event:e}:{id:s,result:c,error:l,event:e}}async parseNostrConnectReply(e,t){const n=e,o=await this.parseEvent(n);if(console.log("nostr connect parsedEvent",o),o.method)throw new Error("Bad nostr connect reply");{const e=o;if(e.result!==t)throw new Error(e.error||"Invalid secret in reply");return n.pubkey}}async listen(e){const t=this._signer.pubkey;return console.log("nostr-login listening for conn to",t,"expecting secret:",e),this.ensureSubscription(),new Promise(((n,o)=>{const r=setTimeout((()=>{o(new Error("Connection timeout: no response from signer"))}),6e4),s={kinds:[24133],"#p":[t]};this.stop(),this.lastSubscribeFilter=s,this.unsub=this.pool.subscribe(s,(async t=>{try{const s=await this.parseEvent(t);if(s.method?this.emit("request",s):this.emit("response-"+s.id,s),!s.method){const i=s;if("auth_url"===i.result)return void console.log("Ignoring auth_url response in listen");i.result===e?(clearTimeout(r),console.log("Connection established with signer:",t.pubkey),n(t.pubkey)):"ack"===i.result?(console.warn('Received "ack" instead of secret.'),clearTimeout(r),n(t.pubkey)):(console.error("Invalid response:",i),clearTimeout(r),o(new Error(i.error||"Invalid connection response")))}}catch(e){console.error("Error parsing event in listen",e)}}))}))}async connect(e,t,n){return console.log("Sending connect request to",e,"with perms:",n),this.ensureSubscription(),new Promise(((o,r)=>{const s=setTimeout((()=>{r(new Error("Connect timeout: no response from signer"))}),3e4),i=[e,t||"",n||""];this.sendRequest(e,"connect",i,24133,(e=>{clearTimeout(s),"ack"===e.result?(console.log("Connect acknowledged by signer"),o()):(console.error("Connect failed:",e.error),r(new Error(e.error||"Connection rejected by signer")))}))}))}getId(){return Math.random().toString(36).substring(7)}async sendRequest(e,t,n=[],o=24133,r){const s=this.getId();this.setResponseHandler(s,r);const i=await this.createRequestEvent(s,e,t,n,o);console.log("sendRequest",{event:i,method:t,remotePubkey:e,params:n}),await this.pool.publish(i)}setResponseHandler(e,t){let n=!1,o=!1;const r=Date.now(),s=()=>{const t=this.requestTimers.get(e);t&&(clearTimeout(t),this.requestTimers.delete(e)),this.requests.delete(e)},i=()=>{const n=this.requestTimers.get(e);n&&clearTimeout(n);const i=setTimeout((()=>{console.warn("nip46 request "+e+" timed out after "+(Date.now()-r)+"ms (authUrl="+o+")"),s(),t&&t({id:e,result:"",error:"Request timeout",event:void 0})}),o?4*NIP46_REQUEST_TIMEOUT:NIP46_REQUEST_TIMEOUT);this.requestTimers.set(e,i)};return i(),new Promise((()=>{const a=c=>{"auth_url"===c.result?(this.once("response-"+e,a),n||(n=!0,o=!0,this.emit("authUrl",c.error),i())):t&&this.requests.has(e)&&(s(),console.log("nostr-login processed nip46 request in",Date.now()-r,"ms"),t(c))};this.once("response-"+e,a)}))}async createRequestEvent(e,t,n,o=[],r=24133){this.requests.add(e);const s={id:e,method:n,params:o},i=JSON.stringify(s),a=this._useNip44&&"create_account"!==n?this._signer.encryptNip44:this._signer.encrypt,c=await a.call(this._signer,{pubkey:t},i),l={kind:r,created_at:Math.floor(Date.now()/1e3),tags:[["p",t]],content:c};return finalizeEvent(l,hexToBytes(this._signer.privateKey))}}class IframeNostrRpc extends NostrRpc{peerOrigin;iframePort;iframeRequests=new Map;constructor(e,t,n){super(e,t),this.peerOrigin=n}subscribe(e){this.peerOrigin||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:o=""}=this.iframeRequests.get(t)||{};n&&o&&this.requests.has(n)&&this.emit("iframeRestart-"+o)}else try{const t=e.data;if(!validateEvent(t))throw new Error("Invalid event from iframe");if(!verifyEvent(t))throw new Error("Invalid event signature from iframe");const n=await this.parseEvent(t);n.method||(console.log("parsed response",n),this.emit("response-"+n.id,n))}catch(t){console.log("error parsing event",t,e.data)}}}async sendRequest(e,t,n=[],o=24133,r){const s=this.getId(),i=await this.createRequestEvent(s,e,t,n,o);this.setResponseHandler(s,r),this.iframePort?(this.iframeRequests.set(i.id||"",{id:s,pubkey:e}),console.log("iframe-nip46 sending request to",this.peerOrigin,i),this.iframePort.postMessage(i)):await this.pool.publish(i)}}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 o=>{const r=new URL(t).hostname,s=new URL(o.origin).hostname;(s===r||s.endsWith("."+r))&&Array.isArray(o.data)&&o.data.length&&this.messages.includes(o.data[0])&&(console.log(new Date,"got ready message from",o.origin,o.data),window.removeEventListener("message",n),e(o.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 lib.EventEmitter{rpc;bunkerPubkey;userPubkey="";constructor(e,t,n,o){super(),this.bunkerPubkey=n,this.rpc=new IframeNostrRpc(e,t,o),this.rpc.setUseNip44(!0),this.rpc.on("authUrl",(e=>{this.emit("authUrl",e)}))}async setSignerPubkey(e,t=!1){console.log("setSignerPubkey",e),this.bunkerPubkey=e,this.rpc.on("iframeRestart-"+e,(()=>{this.emit("iframeRestart")})),await this.initUserPubkey(t?e:"")}async initUserPubkey(e){if(this.userPubkey)console.warn("initUserPubkey already called, pubkey:",this.userPubkey);else{if(e)return this.userPubkey=e,void console.log("User pubkey set from hint:",this.userPubkey);console.log("Requesting user pubkey from signer:",this.bunkerPubkey),this.userPubkey=await new Promise(((e,t)=>{if(!this.bunkerPubkey)throw new Error("Signer pubkey not set");const n=setTimeout((()=>{t(new Error("Timeout getting user pubkey"))}),3e4);console.log("get_public_key",this.bunkerPubkey),this.rpc.sendRequest(this.bunkerPubkey,"get_public_key",[],24133,(o=>{clearTimeout(n),o.error?t(new Error(o.error)):(console.log("User pubkey received:",o.result),e(o.result))}))}))}}async listen(e){const t=await this.rpc.listen(e);await this.setSignerPubkey(t)}async connect(e,t){if(!this.bunkerPubkey)throw new Error("No signer pubkey");await this.rpc.connect(this.bunkerPubkey,e,t),await this.setSignerPubkey(this.bunkerPubkey)}async setListenReply(e,t){const n=await this.rpc.parseNostrConnectReply(e,t);await this.setSignerPubkey(n,!0)}async sign(e){return new Promise(((t,n)=>{const o=JSON.stringify(e);this.rpc.sendRequest(this.bunkerPubkey,"sign_event",[o],24133,(e=>{if(e.error)e.error.includes("timeout")||"Request timeout"===e.error?n(new Nip46Error(e.error,"TIMEOUT")):n(new Nip46Error(e.error,"SIGNER_REJECTED"));else try{const n=JSON.parse(e.result);n.sig&&n.pubkey&&n.id?t(n):n.sig?t(n.sig):t(e.result)}catch{t(e.result)}}))}))}async encrypt(e,t){return new Promise(((n,o)=>{this.rpc.sendRequest(this.bunkerPubkey,"nip04_encrypt",[e,t],24133,(e=>{e.error?o(new Nip46Error(e.error,"SIGNER_REJECTED")):n(e.result)}))}))}async decrypt(e,t){return new Promise(((n,o)=>{this.rpc.sendRequest(this.bunkerPubkey,"nip04_decrypt",[e,t],24133,(e=>{e.error?o(new Nip46Error(e.error,"SIGNER_REJECTED")):n(e.result)}))}))}async createAccount2({bunkerPubkey:e,name:t,domain:n,perms:o=""}){const r=[t,n,"",o],s=await new Promise(((t,n)=>{const o=setTimeout((()=>{n(new Error("Timeout creating account"))}),6e4);this.rpc.sendRequest(e,"create_account",r,void 0,(e=>{clearTimeout(o),t(e)}))}));if(console.log("create_account response",s),"error"===s.result||s.error)throw new Error(s.error||"Failed to create account");return s.result}}class BannerManager extends lib.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)})),this.banner.addEventListener("handleCancelTimeout",(()=>{this.emit("cancelTimeout")})),document.body.appendChild(this.banner)}}function setBigUint64(e,t,n,o){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,o);const r=BigInt(32),s=BigInt(4294967295),i=Number(n>>r&s),a=Number(n&s),c=o?4:0,l=o?0:4;e.setUint32(t+c,i,o),e.setUint32(t+l,a,o)}function Chi(e,t,n){return e&t^~e&n}function Maj(e,t,n){return e&t^e&n^t&n}class HashMD extends Hash{constructor(e,t,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=createView(this.buffer)}update(e){aexists(this),abytes$1(e=toBytes(e));const{view:t,buffer:n,blockLen:o}=this,r=e.length;for(let s=0;s<r;){const i=Math.min(o-this.pos,r-s);if(i!==o)n.set(e.subarray(s,s+i),this.pos),this.pos+=i,s+=i,this.pos===o&&(this.process(t,0),this.pos=0);else{const t=createView(e);for(;o<=r-s;s+=o)this.process(t,s)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){aexists(this),aoutput(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:o,isLE:r}=this;let{pos:s}=this;t[s++]=128,clean(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let e=s;e<o;e++)t[e]=0;setBigUint64(n,o-8,BigInt(8*this.length),r),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 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++)i.setUint32(4*e,l[e],r)}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:o,finished:r,destroyed:s,pos:i}=this;return e.destroyed=s,e.finished=r,e.length=o,e.pos=i,o%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=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=new Uint32Array(64);class SHA256 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:o,E:r,F:s,G:i,H:a}=this;return[e,t,n,o,r,s,i,a]}set(e,t,n,o,r,s,i,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|o,this.E=0|r,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],o=rotr(t,7)^rotr(t,18)^t>>>3,r=rotr(n,17)^rotr(n,19)^n>>>10;SHA256_W[e]=r+SHA256_W[e-7]+o+SHA256_W[e-16]|0}let{A:n,B:o,C:r,D:s,E:i,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(rotr(i,6)^rotr(i,11)^rotr(i,25))+Chi(i,a,c)+SHA256_K[e]+SHA256_W[e]|0,d=(rotr(n,2)^rotr(n,13)^rotr(n,22))+Maj(n,o,r)|0;l=c,c=a,a=i,i=s+t|0,s=r,r=o,o=n,n=t+d|0}n=n+this.A|0,o=o+this.B|0,r=r+this.C|0,s=s+this.D|0,i=i+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,o,r,s,i,a,c,l)}roundClean(){clean(SHA256_W)}destroy(){this.set(0,0,0,0,0,0,0,0),clean(this.buffer)}}const sha256$1=createHasher((()=>new SHA256));class HMAC extends Hash{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ahash(e);const n=toBytes(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 o=this.blockLen,r=new Uint8Array(o);r.set(n.length>o?e.create().update(n).digest():n);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),clean(r)}update(e){return aexists(this),this.iHash.update(e),this}digestInto(e){aexists(this),abytes$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:o,destroyed:r,blockLen:s,outputLen:i}=this;return e.finished=o,e.destroyed=r,e.blockLen=s,e.outputLen=i,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=(e,t,n)=>new HMAC(e,t).update(n).digest();hmac.create=(e,t)=>new HMAC(e,t)
|
|
12
|
-
/*! noble-
|
|
13
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$2=BigInt(0),_1n$2=BigInt(1),_2n$2=BigInt(2),_3n$1=BigInt(3),_4n$1=BigInt(4),_5n=BigInt(5),_7n=BigInt(7),_8n=BigInt(8),_9n=BigInt(9),_16n=BigInt(16);function mod(e,t){const n=e%t;return n>=_0n$2?n:t+n}function pow2(e,t,n){let o=e;for(;t-- >_0n$2;)o*=o,o%=n;return o}function invert(e,t){if(e===_0n$2)throw new Error("invert: expected non-zero number");if(t<=_0n$2)throw new Error("invert: expected positive modulus, got "+t);let n=mod(e,t),o=t,r=_0n$2,s=_1n$2;for(;n!==_0n$2;){const e=o%n,t=r-s*(o/n);o=n,n=e,r=s,s=t}if(o!==_1n$2)throw new Error("invert: does not exist");return mod(r,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$2)/_4n$1,o=e.pow(t,n);return assertIsSquare(e,o,t),o}function sqrt5mod8(e,t){const n=(e.ORDER-_5n)/_8n,o=e.mul(t,_2n$2),r=e.pow(o,n),s=e.mul(t,r),i=e.mul(e.mul(s,_2n$2),r),a=e.mul(s,e.sub(i,e.ONE));return assertIsSquare(e,a,t),a}function sqrt9mod16(e){const t=Field(e),n=tonelliShanks(e),o=n(t,t.neg(t.ONE)),r=n(t,o),s=n(t,t.neg(o)),i=(e+_7n)/_16n;return(e,t)=>{let n=e.pow(t,i),a=e.mul(n,o);const c=e.mul(n,r),l=e.mul(n,s),d=e.eql(e.sqr(a),t),h=e.eql(e.sqr(c),t);n=e.cmov(n,a,d),a=e.cmov(l,c,h);const u=e.eql(e.sqr(a),t),f=e.cmov(n,a,u);return assertIsSquare(e,f,t),f}}function tonelliShanks(e){if(e<_3n$1)throw new Error("sqrt is not defined for small field");let t=e-_1n$2,n=0;for(;t%_2n$2===_0n$2;)t/=_2n$2,n++;let o=_2n$2;const r=Field(e);for(;1===FpLegendre(r,o);)if(o++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return sqrt3mod4;let s=r.pow(o,t);const i=(t+_1n$2)/_2n$2;return function(e,o){if(e.is0(o))return o;if(1!==FpLegendre(e,o))throw new Error("Cannot find square root");let r=n,a=e.mul(e.ONE,s),c=e.pow(o,t),l=e.pow(o,i);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===r)throw new Error("Cannot find square root");const o=_1n$2<<BigInt(r-t-1),s=e.pow(a,o);r=t,a=e.sqr(s),c=e.mul(c,a),l=e.mul(l,s)}return l}}function FpSqrt(e){return e%_4n$1===_3n$1?sqrt3mod4:e%_8n===_5n?sqrt5mod8:e%_16n===_9n?sqrt9mod16(e):tonelliShanks(e)}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:"number",BITS:"number"});return _validateObject(e,t),e}function FpPow(e,t,n){if(n<_0n$2)throw new Error("invalid exponent, negatives unsupported");if(n===_0n$2)return e.ONE;if(n===_1n$2)return t;let o=e.ONE,r=t;for(;n>_0n$2;)n&_1n$2&&(o=e.mul(o,r)),r=e.sqr(r),n>>=_1n$2;return o}function FpInvertBatch(e,t,n=!1){const o=new Array(t.length).fill(n?e.ZERO:void 0),r=t.reduce(((t,n,r)=>e.is0(n)?t:(o[r]=t,e.mul(t,n))),e.ONE),s=e.inv(r);return t.reduceRight(((t,n,r)=>e.is0(n)?t:(o[r]=e.mul(t,o[r]),e.mul(t,n))),s),o}function FpLegendre(e,t){const n=(e.ORDER-_1n$2)/_2n$2,o=e.pow(t,n),r=e.eql(o,e.ONE),s=e.eql(o,e.ZERO),i=e.eql(o,e.neg(e.ONE));if(!r&&!s&&!i)throw new Error("invalid Legendre symbol result");return r?1:s?0:-1}function nLength(e,t){void 0!==t&&anumber$1(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,o={}){if(e<=_0n$2)throw new Error("invalid field: expected ORDER > 0, got "+e);let r,s,i,a=!1;if("object"==typeof t&&null!=t){if(o.sqrt||n)throw new Error("cannot specify opts in two arguments");const e=t;e.BITS&&(r=e.BITS),e.sqrt&&(s=e.sqrt),"boolean"==typeof e.isLE&&(n=e.isLE),"boolean"==typeof e.modFromBytes&&(a=e.modFromBytes),i=e.allowedLengths}else"number"==typeof t&&(r=t),o.sqrt&&(s=o.sqrt);const{nBitLength:c,nByteLength:l}=nLength(e,r);if(l>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let d;const h=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:l,MASK:bitMask(c),ZERO:_0n$2,ONE:_1n$2,allowedLengths:i,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,isValidNot0:e=>!h.is0(e)&&h.isValid(e),isOdd:e=>(e&_1n$2)===_1n$2,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(h,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:s||(t=>(d||(d=FpSqrt(e)),d(h,t))),toBytes:e=>n?numberToBytesLE(e,l):numberToBytesBE(e,l),fromBytes:(t,o=!0)=>{if(i){if(!i.includes(t.length)||t.length>l)throw new Error("Field.fromBytes: expected "+i+" 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 r=n?bytesToNumberLE(t):bytesToNumberBE(t);if(a&&(r=mod(r,e)),!o&&!h.isValid(r))throw new Error("invalid field element: outside of range 0..ORDER");return r},invertBatch:e=>FpInvertBatch(h,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(h)}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 o=e.length,r=getFieldBytesLength(t),s=getMinHashLength(t);if(o<16||o<s||o>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+o);const i=mod(n?bytesToNumberLE(e):bytesToNumberBE(e),t-_1n$2)+_1n$2;return n?numberToBytesLE(i,r):numberToBytesBE(i,r)}
|
|
14
|
-
/*! noble-
|
|
15
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const divNearest=(e,t)=>(e+(e>=0?t:-t)/_2n$1)/t;function _splitEndoScalar(e,t,n){const[[o,r],[s,i]]=t,a=divNearest(i*e,n),c=divNearest(-r*e,n);let l=e-a*o-c*s,d=-a*r-c*i;const h=l<_0n,u=d<_0n;h&&(l=-l),u&&(d=-d);const f=bitMask(Math.ceil(bitLen(n)/2))+_1n;if(l<_0n||l>=f||d<_0n||d>=f)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:h,k1:l,k2neg:u,k2:d}}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 o of Object.keys(t))n[o]=void 0===e[o]?t[o]:e[o];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={Err:DERErr,_tlv:{encode:(e,t)=>{const{Err:n}=DER;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const o=t.length/2,r=numberToHexUnpadded(o);if(r.length/2&128)throw new n("tlv.encode: long form length too big");const s=o>127?numberToHexUnpadded(r.length/2|128):"";return numberToHexUnpadded(e)+s+r+t},decode(e,t){const{Err:n}=DER;let o=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new n("tlv.decode: wrong tlv");const r=t[o++];let s=0;if(!!(128&r)){const e=127&r;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 i=t.subarray(o,o+e);if(i.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===i[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of i)s=s<<8|e;if(o+=e,s<128)throw new n("tlv.decode(long): not minimal encoding")}else s=r;const i=t.subarray(o,o+s);if(i.length!==s)throw new n("tlv.decode: wrong value length");return{v:i,l:t.subarray(o+s)}}},_int:{encode(e){const{Err:t}=DER;if(e<_0n)throw new t("integer: negative integers are not allowed");let n=numberToHexUnpadded(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;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(e)}},toSig(e){const{Err:t,_int:n,_tlv:o}=DER,r=ensureBytes("signature",e),{v:s,l:i}=o.decode(48,r);if(i.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=o.decode(2,s),{v:l,l:d}=o.decode(2,c);if(d.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,o=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,o)}},_0n=BigInt(0),_1n=BigInt(1),_2n$1=BigInt(2),_3n=BigInt(3),_4n=BigInt(4);function _normFnElement(e,t){const{BYTES:n}=e;let o;if("bigint"==typeof t)o=t;else{let r=ensureBytes("private key",t);try{o=e.fromBytes(r)}catch(e){throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(o))throw new Error("invalid private key: out of range [1..N-1]");return o}function weierstrassN(e,t={}){const n=_createCurveFields("weierstrass",e,t),{Fp:o,Fn:r}=n;let s=n.CURVE;const{h:i,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&&(!o.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(o,r);function d(){if(!o.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const h=t.toBytes||function(e,t,n){const{x:r,y:s}=t.toAffine(),i=o.toBytes(r);if(_abool2(n,"isCompressed"),n){d();return concatBytes(pprefix(!o.isOdd(s)),i)}return concatBytes(Uint8Array.of(4),i,o.toBytes(s))},u=t.fromBytes||function(e){_abytes2(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=l,r=e.length,s=e[0],i=e.subarray(1);if(r!==t||2!==s&&3!==s){if(r===n&&4===s){const e=o.BYTES,t=o.fromBytes(i.subarray(0,e)),n=o.fromBytes(i.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 ${r}, expected compressed=${t} or uncompressed=${n}`)}{const e=o.fromBytes(i);if(!o.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=f(e);let n;try{n=o.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}d();return!(1&~s)!==o.isOdd(n)&&(n=o.neg(n)),{x:e,y:n}}};function f(e){const t=o.sqr(e),n=o.mul(t,e);return o.add(o.add(n,o.mul(e,s.a)),s.b)}function p(e,t){const n=o.sqr(t),r=f(e);return o.eql(n,r)}if(!p(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const g=o.mul(o.pow(s.a,_3n),_4n),m=o.mul(o.sqr(s.b),BigInt(27));if(o.is0(o.add(g,m)))throw new Error("bad curve params: a or b");function b(e,t,n=!1){if(!o.isValid(t)||n&&o.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function y(e){if(!(e instanceof x))throw new Error("ProjectivePoint expected")}function w(e){if(!c||!c.basises)throw new Error("no endo");return _splitEndoScalar(e,c.basises,r.ORDER)}const v=memoized(((e,t)=>{const{X:n,Y:r,Z:s}=e;if(o.eql(s,o.ONE))return{x:n,y:r};const i=e.is0();null==t&&(t=i?o.ONE:o.inv(s));const a=o.mul(n,t),c=o.mul(r,t),l=o.mul(s,t);if(i)return{x:o.ZERO,y:o.ZERO};if(!o.eql(l,o.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),k=memoized((e=>{if(e.is0()){if(t.allowInfinityPoint&&!o.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:n,y:r}=e.toAffine();if(!o.isValid(n)||!o.isValid(r))throw new Error("bad point: x or y not field elements");if(!p(n,r))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,r,s){return n=new x(o.mul(n.X,e),n.Y,n.Z),t=negateCt(r,t),n=negateCt(s,n),t.add(n)}class x{constructor(e,t,n){this.X=b("x",e),this.Y=b("y",t,!0),this.Z=b("z",n),Object.freeze(this)}static CURVE(){return s}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!o.isValid(t)||!o.isValid(n))throw new Error("invalid affine point");if(e instanceof x)throw new Error("projective point not allowed");return o.is0(t)&&o.is0(n)?x.ZERO:new x(t,n,o.ONE)}static fromBytes(e){const t=x.fromAffine(u(_abytes2(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return x.fromBytes(ensureBytes("pointHex",e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return B.createCache(this,e),t||this.multiply(_3n),this}assertValidity(){k(this)}hasEvenY(){const{y:e}=this.toAffine();if(!o.isOdd)throw new Error("Field doesn't support isOdd");return!o.isOdd(e)}equals(e){y(e);const{X:t,Y:n,Z:r}=this,{X:s,Y:i,Z:a}=e,c=o.eql(o.mul(t,a),o.mul(s,r)),l=o.eql(o.mul(n,a),o.mul(i,r));return c&&l}negate(){return new x(this.X,o.neg(this.Y),this.Z)}double(){const{a:e,b:t}=s,n=o.mul(t,_3n),{X:r,Y:i,Z:a}=this;let c=o.ZERO,l=o.ZERO,d=o.ZERO,h=o.mul(r,r),u=o.mul(i,i),f=o.mul(a,a),p=o.mul(r,i);return p=o.add(p,p),d=o.mul(r,a),d=o.add(d,d),c=o.mul(e,d),l=o.mul(n,f),l=o.add(c,l),c=o.sub(u,l),l=o.add(u,l),l=o.mul(c,l),c=o.mul(p,c),d=o.mul(n,d),f=o.mul(e,f),p=o.sub(h,f),p=o.mul(e,p),p=o.add(p,d),d=o.add(h,h),h=o.add(d,h),h=o.add(h,f),h=o.mul(h,p),l=o.add(l,h),f=o.mul(i,a),f=o.add(f,f),h=o.mul(f,p),c=o.sub(c,h),d=o.mul(f,u),d=o.add(d,d),d=o.add(d,d),new x(c,l,d)}add(e){y(e);const{X:t,Y:n,Z:r}=this,{X:i,Y:a,Z:c}=e;let l=o.ZERO,d=o.ZERO,h=o.ZERO;const u=s.a,f=o.mul(s.b,_3n);let p=o.mul(t,i),g=o.mul(n,a),m=o.mul(r,c),b=o.add(t,n),w=o.add(i,a);b=o.mul(b,w),w=o.add(p,g),b=o.sub(b,w),w=o.add(t,r);let v=o.add(i,c);return w=o.mul(w,v),v=o.add(p,m),w=o.sub(w,v),v=o.add(n,r),l=o.add(a,c),v=o.mul(v,l),l=o.add(g,m),v=o.sub(v,l),h=o.mul(u,w),l=o.mul(f,m),h=o.add(l,h),l=o.sub(g,h),h=o.add(g,h),d=o.mul(l,h),g=o.add(p,p),g=o.add(g,p),m=o.mul(u,m),w=o.mul(f,w),g=o.add(g,m),m=o.sub(p,m),m=o.mul(u,m),w=o.add(w,m),p=o.mul(g,w),d=o.add(d,p),p=o.mul(v,w),l=o.mul(b,l),l=o.sub(l,p),p=o.mul(b,g),h=o.mul(v,h),h=o.add(h,p),new x(l,d,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(x.ZERO)}multiply(e){const{endo:n}=t;if(!r.isValidNot0(e))throw new Error("invalid scalar: out of range");let o,s;const i=e=>B.cached(this,e,(e=>normalizeZ(x,e)));if(n){const{k1neg:t,k1:r,k2neg:a,k2:c}=w(e),{p:l,f:d}=i(r),{p:h,f:u}=i(c);s=d.add(u),o=E(n.beta,l,h,t,a)}else{const{p:t,f:n}=i(e);o=t,s=n}return normalizeZ(x,[o,s])[0]}multiplyUnsafe(e){const{endo:n}=t,o=this;if(!r.isValid(e))throw new Error("invalid scalar: out of range");if(e===_0n||o.is0())return x.ZERO;if(e===_1n)return o;if(B.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:r,k2neg:s,k2:i}=w(e),{p1:a,p2:c}=mulEndoUnsafe(x,o,r,i);return E(n.beta,a,c,t,s)}return B.unsafe(o,e)}multiplyAndAddUnsafe(e,t,n){const o=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return o.is0()?void 0:o}toAffine(e){return v(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return i===_1n||(e?e(x,this):B.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return i===_1n?this:e?e(x,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(e=!0){return _abool2(e,"isCompressed"),this.assertValidity(),h(x,this,e)}toHex(e=!0){return bytesToHex(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(x,e)}static msm(e,t){return pippenger(x,r,e,t)}static fromPrivateKey(e){return x.BASE.multiply(_normFnElement(r,e))}}x.BASE=new x(s.Gx,s.Gy,o.ONE),x.ZERO=new x(o.ZERO,o.ONE,o.ZERO),x.Fp=o,x.Fn=r;const C=r.BITS,B=new wNAF(x,t.endo?Math.ceil(C/2):C);return x.BASE.precompute(8),x}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,o=t.randomBytes||randomBytes,r=Object.assign(getWLengths(e.Fp,n),{seed:getMinHashLength(n.ORDER)});function s(e){try{return!!_normFnElement(n,e)}catch(e){return!1}}function i(e=o(r.seed)){return mapHashToField(_abytes2(e,r.seed,"seed"),n.ORDER)}function a(t,o=!0){return e.BASE.multiply(_normFnElement(n,t)).toBytes(o)}function c(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;const{secretKey:o,publicKey:s,publicKeyUncompressed:i}=r;if(n.allowedLengths||o===s)return;const a=ensureBytes("key",t).length;return a===s||a===i}const l={isValidSecretKey:s,isValidPublicKey:function(t,n){const{publicKey:o,publicKeyUncompressed:s}=r;try{const r=t.length;return(!0!==n||r===o)&&((!1!==n||r===s)&&!!e.fromBytes(t))}catch(e){return!1}},randomSecretKey:i,isValidPrivateKey:s,randomPrivateKey:i,normPrivateKeyToScalar:e=>_normFnElement(n,e),precompute:(t=8,n=e.BASE)=>n.precompute(t,!1)};return Object.freeze({getPublicKey:a,getSharedSecret:function(t,o,r=!0){if(!0===c(t))throw new Error("first arg must be private key");if(!1===c(o))throw new Error("second arg must be public key");const s=_normFnElement(n,t);return e.fromHex(o).multiply(s).toBytes(r)},keygen:function(e){const t=i(e);return{secretKey:t,publicKey:a(t)}},Point:e,utils:l,lengths:r})}function ecdsa(e,t,n={}){ahash(t),_validateObject(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const o=n.randomBytes||randomBytes,r=n.hmac||((e,...n)=>hmac(t,e,concatBytes(...n))),{Fp:s,Fn:i}=e,{ORDER:a,BITS:c}=i,{keygen:l,getPublicKey:d,getSharedSecret:h,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 m(e){return e>a>>_1n}function b(e,t){if(!i.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class y{constructor(e,t,n){this.r=b("r",e),this.s=b("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.toSig(_abytes2(e));return new y(t,n)}"recovered"===t&&(n=e[0],t="compact",e=e.subarray(1));const o=i.BYTES,r=e.subarray(0,o),s=e.subarray(o,2*o);return new y(i.fromBytes(r),i.fromBytes(s),n)}static fromHex(e,t){return this.fromBytes(hexToBytes(e),t)}addRecoveryBit(e){return new y(this.r,this.s,e)}recoverPublicKey(t){const n=s.ORDER,{r:o,s:r,recovery:c}=this;if(null==c||![0,1,2,3].includes(c))throw new Error("recovery id invalid");if(a*_2n$1<n&&c>1)throw new Error("recovery id is ambiguous for h>1 curve");const l=2===c||3===c?o+a:o;if(!s.isValid(l))throw new Error("recovery id 2 or 3 invalid");const d=s.toBytes(l),h=e.fromBytes(concatBytes(pprefix(!(1&c)),d)),u=i.inv(l),f=v(ensureBytes("msgHash",t)),p=i.create(-f*u),g=i.create(r*u),m=e.BASE.multiplyUnsafe(p).add(h.multiplyUnsafe(g));if(m.is0())throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return m(this.s)}toBytes(e=g){if(validateSigFormat(e),"der"===e)return hexToBytes(DER.hexFromSig(this));const t=i.toBytes(this.r),n=i.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return concatBytes(Uint8Array.of(this.recovery),t,n)}return concatBytes(t,n)}toHex(e){return bytesToHex(this.toBytes(e))}assertValidity(){}static fromCompact(e){return y.fromBytes(ensureBytes("sig",e),"compact")}static fromDER(e){return y.fromBytes(ensureBytes("sig",e),"der")}normalizeS(){return this.hasHighS()?new y(this.r,i.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return bytesToHex(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return bytesToHex(this.toBytes("compact"))}}const w=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=bytesToNumberBE(e),n=8*e.length-c;return n>0?t>>BigInt(n):t},v=n.bits2int_modN||function(e){return i.create(w(e))},k=bitMask(c);function E(e){return aInRange("num < 2^"+c,e,_0n,k),i.toBytes(e)}function x(e,n){return _abytes2(e,void 0,"message"),n?_abytes2(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:l,getPublicKey:d,getSharedSecret:h,utils:u,lengths:f,Point:e,sign:function(n,s,a={}){n=ensureBytes("message",n);const{seed:c,k2sig:l}=function(t,n,r){if(["recovered","canonical"].some((e=>e in r)))throw new Error("sign() legacy options not supported");const{lowS:s,prehash:a,extraEntropy:c}=validateSigOpts(r,p);t=x(t,a);const l=v(t),d=_normFnElement(i,n),h=[E(d),E(l)];if(null!=c&&!1!==c){const e=!0===c?o(f.secretKey):c;h.push(ensureBytes("extraEntropy",e))}const u=concatBytes(...h),g=l;return{seed:u,k2sig:function(t){const n=w(t);if(!i.isValidNot0(n))return;const o=i.inv(n),r=e.BASE.multiply(n).toAffine(),a=i.create(r.x);if(a===_0n)return;const c=i.create(o*i.create(g+a*d));if(c===_0n)return;let l=(r.x===a?0:2)|Number(r.y&_1n),h=c;return s&&m(c)&&(h=i.neg(c),l^=1),new y(a,h,l)}}}(n,s,a);return createHmacDrbg(t.outputLen,i.BYTES,r)(c,l)},verify:function(t,n,o,r={}){const{lowS:s,prehash:a,format:c}=validateSigOpts(r,p);if(o=ensureBytes("publicKey",o),n=x(ensureBytes("message",n),a),"strict"in r)throw new Error("options.strict was renamed to lowS");const l=void 0===c?function(e){let t;const n="string"==typeof e||isBytes$1(e),o=!n&&null!==e&&"object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!n&&!o)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(o)t=new y(e.r,e.s);else if(n){try{t=y.fromBytes(ensureBytes("sig",e),"der")}catch(e){if(!(e instanceof DER.Err))throw e}if(!t)try{t=y.fromBytes(ensureBytes("sig",e),"compact")}catch(e){return!1}}return t||!1}(t):y.fromBytes(ensureBytes("sig",t),c);if(!1===l)return!1;try{const t=e.fromBytes(o);if(s&&l.hasHighS())return!1;const{r:r,s:a}=l,c=v(n),d=i.inv(a),h=i.create(c*d),u=i.create(r*d),f=e.BASE.multiplyUnsafe(h).add(t.multiplyUnsafe(u));if(f.is0())return!1;return i.create(f.x)===r}catch(e){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:o}=validateSigOpts(n,p);return t=x(t,o),y.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:y,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 o=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map((e=>Math.ceil(e/2))))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:Field(t.n,{BITS:e.nBitLength,allowedLengths:o,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),o={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:o}}function _ecdsa_new_output_to_legacy(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,nLength(n.Fn.ORDER,n.Fn.BITS))})}function weierstrass(e){const{CURVE:t,curveOpts:n,hash:o,ecdsaOpts:r}=_ecdsa_legacy_opts_to_new(e);return _ecdsa_new_output_to_legacy(e,ecdsa(weierstrassN(t,n),o,r))}
|
|
3
|
+
function isBytes$4(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function anumber$4(e,t=""){if(!Number.isSafeInteger(e)||e<0){throw new Error(`${t&&`"${t}" `}expected integer >= 0, got ${e}`)}}function abytes$4(e,t,n=""){const r=isBytes$4(e),o=e?.length,s=void 0!==t;if(!r||s&&o!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${t}`:"")+", got "+(r?`length=${o}`:"type="+typeof e))}return e}function ahash$1(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash must wrapped by utils.createHasher");anumber$4(e.outputLen),anumber$4(e.blockLen)}function aexists$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 aoutput$1(e,t){abytes$4(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function clean$2(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function createView$1(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function rotr$1(e,t){return e<<32-t|e>>>t}ee$1.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$1,e)}(lib);const hasHexBuiltin$1=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),hexes$1=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function bytesToHex$1(e){if(abytes$4(e),hasHexBuiltin$1)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=hexes$1[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$1(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(hasHexBuiltin$1)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,o=0;t<n;t++,o+=2){const n=asciiToBase16$1(e.charCodeAt(o)),s=asciiToBase16$1(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 concatBytes$1(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];abytes$4(r),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}function createHasher$1(e,t={}){const n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function randomBytes$1(e=32){const t="object"==typeof globalThis?globalThis.crypto:null;if("function"!=typeof t?.getRandomValues)throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}const oidNist=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Chi$1(e,t,n){return e&t^~e&n}function Maj$1(e,t,n){return e&t^e&n^t&n}let HashMD$1=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=createView$1(this.buffer)}update(e){aexists$1(this),abytes$4(e);const{view:t,buffer:n,blockLen:r}=this,o=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){aexists$1(this),aoutput$1(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:s}=this;t[s++]=128,clean$2(this.buffer.subarray(s)),this.padOffset>r-s&&(this.process(n,0),s=0);for(let e=s;e<r;e++)t[e]=0;n.setBigUint64(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 must 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++)i.setUint32(4*e,l[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||=new this.constructor,e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:o,destroyed:s,pos:i}=this;return e.destroyed=s,e.finished=o,e.length=r,e.pos=i,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}};const SHA256_IV$1=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_K$1=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$1=new Uint32Array(64);class SHA2_32B extends HashMD$1{constructor(e){super(64,e,8,!1)}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:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(rotr$1(i,6)^rotr$1(i,11)^rotr$1(i,25))+Chi$1(i,a,c)+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;l=c,c=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,c=c+this.G|0,l=l+this.H|0,this.set(n,r,o,s,i,a,c,l)}roundClean(){clean$2(SHA256_W$1)}destroy(){this.set(0,0,0,0,0,0,0,0),clean$2(this.buffer)}}class _SHA256 extends SHA2_32B{A=0|SHA256_IV$1[0];B=0|SHA256_IV$1[1];C=0|SHA256_IV$1[2];D=0|SHA256_IV$1[3];E=0|SHA256_IV$1[4];F=0|SHA256_IV$1[5];G=0|SHA256_IV$1[6];H=0|SHA256_IV$1[7];constructor(){super(32)}}const sha256$2=createHasher$1((()=>new _SHA256),oidNist(1)),_0n$8=BigInt(0),_1n$7=BigInt(1);
|
|
4
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function abool$1(e,t=""){if("boolean"!=typeof e){throw new Error((t&&`"${t}" `)+"expected boolean, got type="+typeof e)}return e}function abignumber(e){if("bigint"==typeof e){if(!isPosBig$1(e))throw new Error("positive bigint expected, got "+e)}else anumber$4(e);return e}function numberToHexUnpadded$1(e){const t=abignumber(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""===e?_0n$8:BigInt("0x"+e)}function bytesToNumberBE$1(e){return hexToNumber$1(bytesToHex$1(e))}function bytesToNumberLE$1(e){return hexToNumber$1(bytesToHex$1(copyBytes$1(abytes$4(e)).reverse()))}function numberToBytesBE$1(e,t){anumber$4(t);const n=hexToBytes$1((e=abignumber(e)).toString(16).padStart(2*t,"0"));if(n.length!==t)throw new Error("number too large");return n}function numberToBytesLE$1(e,t){return numberToBytesBE$1(e,t).reverse()}function copyBytes$1(e){return Uint8Array.from(e)}function asciiToBytes(e){return Uint8Array.from(e,((t,n)=>{const r=t.charCodeAt(0);if(1!==t.length||r>127)throw new Error(`string contains non-ASCII character "${e[n]}" with code ${r} at position ${n}`);return r}))}const isPosBig$1=e=>"bigint"==typeof e&&_0n$8<=e;function inRange$1(e,t,n){return isPosBig$1(e)&&isPosBig$1(t)&&isPosBig$1(n)&&t<=e&&e<n}function aInRange$1(e,t,n,r){if(!inRange$1(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function bitLen$1(e){let t;for(t=0;e>_0n$8;e>>=_1n$7,t+=1);return t}const bitMask$1=e=>(_1n$7<<BigInt(e))-_1n$7;function createHmacDrbg$1(e,t,n){if(anumber$4(e,"hashLen"),anumber$4(t,"qByteLen"),"function"!=typeof n)throw new Error("hmacFn must be a function");const r=e=>new Uint8Array(e),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1);let a=r(e),c=r(e),l=0;const d=()=>{a.fill(1),c.fill(0),l=0},u=(...e)=>n(c,concatBytes$1(a,...e)),h=(e=o)=>{c=u(s,e),a=u(),0!==e.length&&(c=u(i,e),a=u())},f=()=>{if(l++>=1e3)throw new Error("drbg: tried max amount of iterations");let e=0;const n=[];for(;e<t;){a=u();const t=a.slice();n.push(t),e+=a.length}return concatBytes$1(...n)};return(e,t)=>{let n;for(d(),h(e);!(n=t(f()));)h();return d(),n}}function validateObject(e,t={},n={}){if(!e||"object"!=typeof e)throw new Error("expected valid options object");const r=(t,n)=>Object.entries(t).forEach((([t,r])=>function(t,n,r){const o=e[t];if(r&&void 0===o)return;const s=typeof o;if(s!==n||null===o)throw new Error(`param "${t}" is invalid: expected ${n}, got ${s}`)}(t,r,n)));r(t,!1),r(n,!0)}function memoized$1(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(void 0!==o)return o;const s=e(n,...r);return t.set(n,s),s}}
|
|
5
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$7=BigInt(0),_1n$6=BigInt(1),_2n$5=BigInt(2),_3n$3=BigInt(3),_4n$3=BigInt(4),_5n$1=BigInt(5),_7n$1=BigInt(7),_8n$1=BigInt(8),_9n$1=BigInt(9),_16n$1=BigInt(16);function mod$1(e,t){const n=e%t;return n>=_0n$7?n:t+n}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)throw new Error("invert: expected non-zero number");if(t<=_0n$7)throw new Error("invert: expected positive modulus, got "+t);let n=mod$1(e,t),r=t,o=_0n$7,s=_1n$6;for(;n!==_0n$7;){const e=r%n,t=o-s*(r/n);r=n,n=e,o=s,s=t}if(r!==_1n$6)throw new Error("invert: does not exist");return mod$1(o,t)}function assertIsSquare$1(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function sqrt3mod4$1(e,t){const n=(e.ORDER+_1n$6)/_4n$3,r=e.pow(t,n);return assertIsSquare$1(e,r,t),r}function sqrt5mod8$1(e,t){const n=(e.ORDER-_5n$1)/_8n$1,r=e.mul(t,_2n$5),o=e.pow(r,n),s=e.mul(t,o),i=e.mul(e.mul(s,_2n$5),o),a=e.mul(s,e.sub(i,e.ONE));return assertIsSquare$1(e,a,t),a}function sqrt9mod16$1(e){const t=Field$1(e),n=tonelliShanks$1(e),r=n(t,t.neg(t.ONE)),o=n(t,r),s=n(t,t.neg(r)),i=(e+_7n$1)/_16n$1;return(e,t)=>{let n=e.pow(t,i),a=e.mul(n,r);const c=e.mul(n,o),l=e.mul(n,s),d=e.eql(e.sqr(a),t),u=e.eql(e.sqr(c),t);n=e.cmov(n,a,d),a=e.cmov(l,c,u);const h=e.eql(e.sqr(a),t),f=e.cmov(n,a,h);return assertIsSquare$1(e,f,t),f}}function tonelliShanks$1(e){if(e<_3n$3)throw new Error("sqrt is not defined for small field");let t=e-_1n$6,n=0;for(;t%_2n$5===_0n$7;)t/=_2n$5,n++;let r=_2n$5;const o=Field$1(e);for(;1===FpLegendre$1(o,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return sqrt3mod4$1;let s=o.pow(r,t);const i=(t+_1n$6)/_2n$5;return function(e,r){if(e.is0(r))return r;if(1!==FpLegendre$1(e,r))throw new Error("Cannot find square root");let o=n,a=e.mul(e.ONE,s),c=e.pow(r,t),l=e.pow(r,i);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===o)throw new Error("Cannot find square root");const r=_1n$6<<BigInt(o-t-1),s=e.pow(a,r);o=t,a=e.sqr(s),c=e.mul(c,a),l=e.mul(l,s)}return l}}function FpSqrt$1(e){return e%_4n$3===_3n$3?sqrt3mod4$1:e%_8n$1===_5n$1?sqrt5mod8$1:e%_16n$1===_9n$1?sqrt9mod16$1(e):tonelliShanks$1(e)}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",BYTES:"number",BITS:"number"});return validateObject(e,t),e}function FpPow$1(e,t,n){if(n<_0n$7)throw new Error("invalid exponent, negatives unsupported");if(n===_0n$7)return e.ONE;if(n===_1n$6)return t;let r=e.ONE,o=t;for(;n>_0n$7;)n&_1n$6&&(r=e.mul(r,o)),o=e.sqr(o),n>>=_1n$6;return r}function FpInvertBatch$1(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce(((t,n,o)=>e.is0(n)?t:(r[o]=t,e.mul(t,n))),e.ONE),s=e.inv(o);return t.reduceRight(((t,n,o)=>e.is0(n)?t:(r[o]=e.mul(t,r[o]),e.mul(t,n))),s),r}function FpLegendre$1(e,t){const n=(e.ORDER-_1n$6)/_2n$5,r=e.pow(t,n),o=e.eql(r,e.ONE),s=e.eql(r,e.ZERO),i=e.eql(r,e.neg(e.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function nLength$1(e,t){void 0!==t&&anumber$4(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}class _Field{ORDER;BITS;BYTES;isLE;ZERO=_0n$7;ONE=_1n$6;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=_0n$7)throw new Error("invalid field: expected ORDER > 0, got "+e);let n;this.isLE=!1,null!=t&&"object"==typeof t&&("number"==typeof t.BITS&&(n=t.BITS),"function"==typeof t.sqrt&&(this.sqrt=t.sqrt),"boolean"==typeof t.isLE&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=t.allowedLengths?.slice()),"boolean"==typeof t.modFromBytes&&(this._mod=t.modFromBytes));const{nBitLength:r,nByteLength:o}=nLength$1(e,n);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=r,this.BYTES=o,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return mod$1(e,this.ORDER)}isValid(e){if("bigint"!=typeof e)throw new Error("invalid field element: expected bigint, got "+typeof e);return _0n$7<=e&&e<this.ORDER}is0(e){return e===_0n$7}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&_1n$6)===_1n$6}neg(e){return mod$1(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return mod$1(e*e,this.ORDER)}add(e,t){return mod$1(e+t,this.ORDER)}sub(e,t){return mod$1(e-t,this.ORDER)}mul(e,t){return mod$1(e*t,this.ORDER)}pow(e,t){return FpPow$1(this,e,t)}div(e,t){return mod$1(e*invert$1(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return invert$1(e,this.ORDER)}sqrt(e){return this._sqrt||(this._sqrt=FpSqrt$1(this.ORDER)),this._sqrt(this,e)}toBytes(e){return this.isLE?numberToBytesLE$1(e,this.BYTES):numberToBytesBE$1(e,this.BYTES)}fromBytes(e,t=!1){abytes$4(e);const{_lengths:n,BYTES:r,isLE:o,ORDER:s,_mod:i}=this;if(n){if(!n.includes(e.length)||e.length>r)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);const t=new Uint8Array(r);t.set(e,o?0:t.length-e.length),e=t}if(e.length!==r)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let a=o?bytesToNumberLE$1(e):bytesToNumberBE$1(e);if(i&&(a=mod$1(a,s)),!t&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(e){return FpInvertBatch$1(this,e)}cmov(e,t,n){return n?t:e}}function Field$1(e,t={}){return new _Field(e,t)}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){abytes$4(e);const r=e.length,o=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 i=mod$1(n?bytesToNumberLE$1(e):bytesToNumberBE$1(e),t-_1n$6)+_1n$6;return n?numberToBytesLE$1(i,o):numberToBytesBE$1(i,o)}
|
|
6
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$6=BigInt(0),_1n$5=BigInt(1);function negateCt$1(e,t){const n=t.negate();return e?n:t}function normalizeZ$1(e,t){const n=FpInvertBatch$1(e.Fp,t.map((e=>e.Z)));return t.map(((t,r)=>e.fromAffine(t.toAffine(n[r]))))}function validateW$1(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function calcWOpts$1(e,t){validateW$1(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:bitMask$1(e),maxNumber:n,shiftBy:BigInt(e)}}function calcOffsets$1(e,t,n){const{windowSize:r,mask:o,maxNumber:s,shiftBy:i}=n;let a=Number(e&o),c=e>>i;a>r&&(a-=s,c+=_1n$5);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}}const pointPrecomputes$1=new WeakMap,pointWindowSizes$1=new WeakMap;function getW$1(e){return pointWindowSizes$1.get(e)||1}function assert0$1(e){if(e!==_0n$6)throw new Error("invalid wNAF")}let wNAF$1=class{BASE;ZERO;Fn;bits;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$6;)t&_1n$5&&(n=n.add(r)),r=r.double(),t>>=_1n$5;return n}precomputeWindow(e,t){const{windows:n,windowSize:r}=calcWOpts$1(t,this.bits),o=[];let s=e,i=s;for(let e=0;e<n;e++){i=s,o.push(i);for(let e=1;e<r;e++)i=i.add(s),o.push(i);s=i.double()}return o}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let r=this.ZERO,o=this.BASE;const s=calcWOpts$1(e,this.bits);for(let e=0;e<s.windows;e++){const{nextN:i,offset:a,isZero:c,isNeg:l,isNegF:d,offsetF:u}=calcOffsets$1(n,e,s);n=i,c?o=o.add(negateCt$1(d,t[u])):r=r.add(negateCt$1(l,t[a]))}return assert0$1(n),{p:r,f:o}}wNAFUnsafe(e,t,n,r=this.ZERO){const o=calcWOpts$1(e,this.bits);for(let e=0;e<o.windows&&n!==_0n$6;e++){const{nextN:s,offset:i,isZero:a,isNeg:c}=calcOffsets$1(n,e,o);if(n=s,!a){const e=t[i];r=r.add(c?e.negate():e)}}return assert0$1(n),r}getPrecomputes(e,t,n){let r=pointPrecomputes$1.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&("function"==typeof n&&(r=n(r)),pointPrecomputes$1.set(t,r))),r}cached(e,t,n){const r=getW$1(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){const o=getW$1(e);return 1===o?this._unsafeLadder(e,t,r):this.wNAFUnsafe(o,this.getPrecomputes(o,e,n),t,r)}createCache(e,t){validateW$1(t,this.bits),pointWindowSizes$1.set(e,t),pointPrecomputes$1.delete(e)}hasCache(e){return 1!==getW$1(e)}};function mulEndoUnsafe$1(e,t,n,r){let o=t,s=e.ZERO,i=e.ZERO;for(;n>_0n$6||r>_0n$6;)n&_1n$5&&(s=s.add(o)),r&_1n$5&&(i=i.add(o)),o=o.double(),n>>=_1n$5,r>>=_1n$5;return{p1:s,p2:i}}function createField$1(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return validateField$1(t),t}return Field$1(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$6))throw new Error(`CURVE.${e} must be positive bigint`)}const o=createField$1(t.p,n.Fp,r),s=createField$1(t.n,n.Fn,r),i=["Gx","Gy","a","b"];for(const e of i)if(!o.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:o,Fn:s}}function createKeygen(e,t){return function(n){const r=e(n);return{secretKey:r,publicKey:t(r)}}}class _HMAC{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(ahash$1(e),abytes$4(t,void 0,"key"),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 n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),clean$2(r)}update(e){return aexists$1(this),this.iHash.update(e),this}digestInto(e){aexists$1(this),abytes$4(e,this.outputLen,"output"),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||=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}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const hmac$1=(e,t,n)=>new _HMAC(e,t).update(n).digest();hmac$1.create=(e,t)=>new _HMAC(e,t)
|
|
7
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */;const divNearest$1=(e,t)=>(e+(e>=0?t:-t)/_2n$4)/t;function _splitEndoScalar$1(e,t,n){const[[r,o],[s,i]]=t,a=divNearest$1(i*e,n),c=divNearest$1(-o*e,n);let l=e-a*r-c*s,d=-a*o-c*i;const u=l<_0n$5,h=d<_0n$5;u&&(l=-l),h&&(d=-d);const f=bitMask$1(Math.ceil(bitLen$1(n)/2))+_1n$4;if(l<_0n$5||l>=f||d<_0n$5||d>=f)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:u,k1:l,k2neg:h,k2:d}}function validateSigFormat$1(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function validateSigOpts$1(e,t){const n={};for(let r of Object.keys(t))n[r]=void 0===e[r]?t[r]:e[r];return abool$1(n.lowS,"lowS"),abool$1(n.prehash,"prehash"),void 0!==n.format&&validateSigFormat$1(n.format),n}let DERErr$1=class extends Error{constructor(e=""){super(e)}};const DER$1={Err:DERErr$1,_tlv:{encode:(e,t)=>{const{Err:n}=DER$1;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,o=numberToHexUnpadded$1(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const s=r>127?numberToHexUnpadded$1(o.length/2|128):"";return numberToHexUnpadded$1(e)+s+o+t},decode(e,t){const{Err:n}=DER$1;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const o=t[r++];let s=0;if(!!(128&o)){const e=127&o;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 i=t.subarray(r,r+e);if(i.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===i[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of i)s=s<<8|e;if(r+=e,s<128)throw new n("tlv.decode(long): not minimal encoding")}else s=o;const i=t.subarray(r,r+s);if(i.length!==s)throw new n("tlv.decode: wrong value length");return{v:i,l:t.subarray(r+s)}}},_int:{encode(e){const{Err:t}=DER$1;if(e<_0n$5)throw new t("integer: negative integers are not allowed");let n=numberToHexUnpadded$1(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$1;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$1(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=DER$1,o=abytes$4(e,void 0,"signature"),{v:s,l:i}=r.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,s),{v:l,l:d}=r.decode(2,c);if(d.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$1,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},_0n$5=BigInt(0),_1n$4=BigInt(1),_2n$4=BigInt(2),_3n$2=BigInt(3),_4n$2=BigInt(4);function weierstrass$1(e,t={}){const n=createCurveFields("weierstrass",e,t),{Fp:r,Fn:o}=n;let s=n.CURVE;const{h:i,n:a}=s;validateObject(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});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$1(r,o);function d(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const u=t.toBytes||function(e,t,n){const{x:o,y:s}=t.toAffine(),i=r.toBytes(o);if(abool$1(n,"isCompressed"),n){d();return concatBytes$1(pprefix$1(!r.isOdd(s)),i)}return concatBytes$1(Uint8Array.of(4),i,r.toBytes(s))},h=t.fromBytes||function(e){abytes$4(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=l,o=e.length,s=e[0],i=e.subarray(1);if(o!==t||2!==s&&3!==s){if(o===n&&4===s){const e=r.BYTES,t=r.fromBytes(i.subarray(0,e)),n=r.fromBytes(i.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 ${o}, expected compressed=${t} or uncompressed=${n}`)}{const e=r.fromBytes(i);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)}d();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),o=f(e);return r.eql(n,o)}if(!p(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const g=r.mul(r.pow(s.a,_3n$2),_4n$2),m=r.mul(r.sqr(s.b),BigInt(27));if(r.is0(r.add(g,m)))throw new Error("bad curve params: a or b");function b(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function y(e){if(!(e instanceof x))throw new Error("Weierstrass Point expected")}function w(e){if(!c||!c.basises)throw new Error("no endo");return _splitEndoScalar$1(e,c.basises,o.ORDER)}const v=memoized$1(((e,t)=>{const{X:n,Y:o,Z:s}=e;if(r.eql(s,r.ONE))return{x:n,y:o};const i=e.is0();null==t&&(t=i?r.ONE:r.inv(s));const a=r.mul(n,t),c=r.mul(o,t),l=r.mul(s,t);if(i)return{x:r.ZERO,y:r.ZERO};if(!r.eql(l,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),k=memoized$1((e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:n,y:o}=e.toAffine();if(!r.isValid(n)||!r.isValid(o))throw new Error("bad point: x or y not field elements");if(!p(n,o))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,o,s){return n=new x(r.mul(n.X,e),n.Y,n.Z),t=negateCt$1(o,t),n=negateCt$1(s,n),t.add(n)}class x{static BASE=new x(s.Gx,s.Gy,r.ONE);static ZERO=new x(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=o;X;Y;Z;constructor(e,t,n){this.X=b("x",e),this.Y=b("y",t,!0),this.Z=b("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 x)throw new Error("projective point not allowed");return r.is0(t)&&r.is0(n)?x.ZERO:new x(t,n,r.ONE)}static fromBytes(e){const t=x.fromAffine(h(abytes$4(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return x.fromBytes(hexToBytes$1(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return C.createCache(this,e),t||this.multiply(_3n$2),this}assertValidity(){k(this)}hasEvenY(){const{y:e}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(e)}equals(e){y(e);const{X:t,Y:n,Z:o}=this,{X:s,Y:i,Z:a}=e,c=r.eql(r.mul(t,a),r.mul(s,o)),l=r.eql(r.mul(n,a),r.mul(i,o));return c&&l}negate(){return new x(this.X,r.neg(this.Y),this.Z)}double(){const{a:e,b:t}=s,n=r.mul(t,_3n$2),{X:o,Y:i,Z:a}=this;let c=r.ZERO,l=r.ZERO,d=r.ZERO,u=r.mul(o,o),h=r.mul(i,i),f=r.mul(a,a),p=r.mul(o,i);return p=r.add(p,p),d=r.mul(o,a),d=r.add(d,d),c=r.mul(e,d),l=r.mul(n,f),l=r.add(c,l),c=r.sub(h,l),l=r.add(h,l),l=r.mul(c,l),c=r.mul(p,c),d=r.mul(n,d),f=r.mul(e,f),p=r.sub(u,f),p=r.mul(e,p),p=r.add(p,d),d=r.add(u,u),u=r.add(d,u),u=r.add(u,f),u=r.mul(u,p),l=r.add(l,u),f=r.mul(i,a),f=r.add(f,f),u=r.mul(f,p),c=r.sub(c,u),d=r.mul(f,h),d=r.add(d,d),d=r.add(d,d),new x(c,l,d)}add(e){y(e);const{X:t,Y:n,Z:o}=this,{X:i,Y:a,Z:c}=e;let l=r.ZERO,d=r.ZERO,u=r.ZERO;const h=s.a,f=r.mul(s.b,_3n$2);let p=r.mul(t,i),g=r.mul(n,a),m=r.mul(o,c),b=r.add(t,n),w=r.add(i,a);b=r.mul(b,w),w=r.add(p,g),b=r.sub(b,w),w=r.add(t,o);let v=r.add(i,c);return w=r.mul(w,v),v=r.add(p,m),w=r.sub(w,v),v=r.add(n,o),l=r.add(a,c),v=r.mul(v,l),l=r.add(g,m),v=r.sub(v,l),u=r.mul(h,w),l=r.mul(f,m),u=r.add(l,u),l=r.sub(g,u),u=r.add(g,u),d=r.mul(l,u),g=r.add(p,p),g=r.add(g,p),m=r.mul(h,m),w=r.mul(f,w),g=r.add(g,m),m=r.sub(p,m),m=r.mul(h,m),w=r.add(w,m),p=r.mul(g,w),d=r.add(d,p),p=r.mul(v,w),l=r.mul(b,l),l=r.sub(l,p),p=r.mul(b,g),u=r.mul(v,u),u=r.add(u,p),new x(l,d,u)}subtract(e){return this.add(e.negate())}is0(){return this.equals(x.ZERO)}multiply(e){const{endo:n}=t;if(!o.isValidNot0(e))throw new Error("invalid scalar: out of range");let r,s;const i=e=>C.cached(this,e,(e=>normalizeZ$1(x,e)));if(n){const{k1neg:t,k1:o,k2neg:a,k2:c}=w(e),{p:l,f:d}=i(o),{p:u,f:h}=i(c);s=d.add(h),r=E(n.beta,l,u,t,a)}else{const{p:t,f:n}=i(e);r=t,s=n}return normalizeZ$1(x,[r,s])[0]}multiplyUnsafe(e){const{endo:n}=t,r=this;if(!o.isValid(e))throw new Error("invalid scalar: out of range");if(e===_0n$5||r.is0())return x.ZERO;if(e===_1n$4)return r;if(C.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:o,k2neg:s,k2:i}=w(e),{p1:a,p2:c}=mulEndoUnsafe$1(x,r,o,i);return E(n.beta,a,c,t,s)}return C.unsafe(r,e)}toAffine(e){return v(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return i===_1n$4||(e?e(x,this):C.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return i===_1n$4?this:e?e(x,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(e=!0){return abool$1(e,"isCompressed"),this.assertValidity(),u(x,this,e)}toHex(e=!0){return bytesToHex$1(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const $=o.BITS,C=new wNAF$1(x,t.endo?Math.ceil($/2):$);return x.BASE.precompute(8),x}function pprefix$1(e){return Uint8Array.of(e?2:3)}function getWLengths$1(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function ecdh$1(e,t={}){const{Fn:n}=e,r=t.randomBytes||randomBytes$1,o=Object.assign(getWLengths$1(e.Fp,n),{seed:getMinHashLength$1(n.ORDER)});function s(e=r(o.seed)){return mapHashToField$1(abytes$4(e,o.seed,"seed"),n.ORDER)}function i(t,r=!0){return e.BASE.multiply(n.fromBytes(t)).toBytes(r)}function a(e){const{secretKey:t,publicKey:r,publicKeyUncompressed:s}=o;if(!isBytes$4(e))return;if("_lengths"in n&&n._lengths||t===r)return;const i=abytes$4(e,void 0,"key").length;return i===r||i===s}const c={isValidSecretKey:function(e){try{const t=n.fromBytes(e);return n.isValidNot0(t)}catch(e){return!1}},isValidPublicKey:function(t,n){const{publicKey:r,publicKeyUncompressed:s}=o;try{const o=t.length;return(!0!==n||o===r)&&((!1!==n||o===s)&&!!e.fromBytes(t))}catch(e){return!1}},randomSecretKey:s},l=createKeygen(s,i);return Object.freeze({getPublicKey:i,getSharedSecret:function(t,r,o=!0){if(!0===a(t))throw new Error("first arg must be private key");if(!1===a(r))throw new Error("second arg must be public key");const s=n.fromBytes(t);return e.fromBytes(r).multiply(s).toBytes(o)},keygen:l,Point:e,utils:c,lengths:o})}function ecdsa$1(e,t,n={}){ahash$1(t),validateObject(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=(n=Object.assign({},n)).randomBytes||randomBytes$1,o=n.hmac||((e,n)=>hmac$1(t,e,n)),{Fp:s,Fn:i}=e,{ORDER:a,BITS:c}=i,{keygen:l,getPublicKey:d,getSharedSecret:u,utils:h,lengths:f}=ecdh$1(e,n),p={prehash:!0,lowS:"boolean"!=typeof n.lowS||n.lowS,format:"compact",extraEntropy:!1},g=a*_2n$4<s.ORDER;function m(e){return e>a>>_1n$4}function b(e,t){if(!i.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function y(){if(g)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function w(e,t){validateSigFormat$1(t);const n=f.signature;return abytes$4(e,"compact"===t?n:"recovered"===t?n+1:void 0)}class v{r;s;recovery;constructor(e,t,n){if(this.r=b("r",e),this.s=b("s",t),null!=n){if(y(),![0,1,2,3].includes(n))throw new Error("invalid recovery id");this.recovery=n}Object.freeze(this)}static fromBytes(e,t=p.format){let n;if(w(e,t),"der"===t){const{r:t,s:n}=DER$1.toSig(abytes$4(e));return new v(t,n)}"recovered"===t&&(n=e[0],t="compact",e=e.subarray(1));const r=f.signature/2,o=e.subarray(0,r),s=e.subarray(r,2*r);return new v(i.fromBytes(o),i.fromBytes(s),n)}static fromHex(e,t){return this.fromBytes(hexToBytes$1(e),t)}assertRecovery(){const{recovery:e}=this;if(null==e)throw new Error("invalid recovery id: must be present");return e}addRecoveryBit(e){return new v(this.r,this.s,e)}recoverPublicKey(t){const{r:n,s:r}=this,o=this.assertRecovery(),c=2===o||3===o?n+a:n;if(!s.isValid(c))throw new Error("invalid recovery id: sig.r+curve.n != R.x");const l=s.toBytes(c),d=e.fromBytes(concatBytes$1(pprefix$1(!(1&o)),l)),u=i.inv(c),h=E(abytes$4(t,void 0,"msgHash")),f=i.create(-h*u),p=i.create(r*u),g=e.BASE.multiplyUnsafe(f).add(d.multiplyUnsafe(p));if(g.is0())throw new Error("invalid recovery: point at infinify");return g.assertValidity(),g}hasHighS(){return m(this.s)}toBytes(e=p.format){if(validateSigFormat$1(e),"der"===e)return hexToBytes$1(DER$1.hexFromSig(this));const{r:t,s:n}=this,r=i.toBytes(t),o=i.toBytes(n);return"recovered"===e?(y(),concatBytes$1(Uint8Array.of(this.assertRecovery()),r,o)):concatBytes$1(r,o)}toHex(e){return bytesToHex$1(this.toBytes(e))}}const k=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=bytesToNumberBE$1(e),n=8*e.length-c;return n>0?t>>BigInt(n):t},E=n.bits2int_modN||function(e){return i.create(k(e))},x=bitMask$1(c);function $(e){return aInRange$1("num < 2^"+c,e,_0n$5,x),i.toBytes(e)}function C(e,n){return abytes$4(e,void 0,"message"),n?abytes$4(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:l,getPublicKey:d,getSharedSecret:u,utils:h,lengths:f,Point:e,sign:function(n,s,a={}){const{seed:c,k2sig:l}=function(t,n,o){const{lowS:s,prehash:a,extraEntropy:c}=validateSigOpts$1(o,p);t=C(t,a);const l=E(t),d=i.fromBytes(n);if(!i.isValidNot0(d))throw new Error("invalid private key");const u=[$(d),$(l)];if(null!=c&&!1!==c){const e=!0===c?r(f.secretKey):c;u.push(abytes$4(e,void 0,"extraEntropy"))}const h=concatBytes$1(...u),b=l;return{seed:h,k2sig:function(t){const n=k(t);if(!i.isValidNot0(n))return;const r=i.inv(n),o=e.BASE.multiply(n).toAffine(),a=i.create(o.x);if(a===_0n$5)return;const c=i.create(r*i.create(b+a*d));if(c===_0n$5)return;let l=(o.x===a?0:2)|Number(o.y&_1n$4),u=c;return s&&m(c)&&(u=i.neg(c),l^=1),new v(a,u,g?void 0:l)}}}(n,s,a);return createHmacDrbg$1(t.outputLen,i.BYTES,o)(c,l).toBytes(a.format)},verify:function(t,n,r,o={}){const{lowS:s,prehash:a,format:c}=validateSigOpts$1(o,p);if(r=abytes$4(r,void 0,"publicKey"),n=C(n,a),!isBytes$4(t)){throw new Error("verify expects Uint8Array signature"+(t instanceof v?", use sig.toBytes()":""))}w(t,c);try{const o=v.fromBytes(t,c),a=e.fromBytes(r);if(s&&o.hasHighS())return!1;const{r:l,s:d}=o,u=E(n),h=i.inv(d),f=i.create(u*h),p=i.create(l*h),g=e.BASE.multiplyUnsafe(f).add(a.multiplyUnsafe(p));if(g.is0())return!1;return i.create(g.x)===l}catch(e){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:r}=validateSigOpts$1(n,p);return t=C(t,r),v.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:v,hash:t})}
|
|
8
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1_CURVE$1={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},secp256k1_ENDO$1={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},_0n$4=BigInt(0),_2n$3=BigInt(2);function sqrtMod$1(e){const t=secp256k1_CURVE$1.p,n=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,d=l*l*e%t,u=pow2$1(d,n,t)*d%t,h=pow2$1(u,n,t)*d%t,f=pow2$1(h,_2n$3,t)*l%t,p=pow2$1(f,o,t)*f%t,g=pow2$1(p,s,t)*p%t,m=pow2$1(g,a,t)*g%t,b=pow2$1(m,c,t)*m%t,y=pow2$1(b,a,t)*g%t,w=pow2$1(y,n,t)*d%t,v=pow2$1(w,i,t)*p%t,k=pow2$1(v,r,t)*l%t,E=pow2$1(k,_2n$3,t);if(!Fpk1$1.eql(Fpk1$1.sqr(E),e))throw new Error("Cannot find square root");return E}const Fpk1$1=Field$1(secp256k1_CURVE$1.p,{sqrt:sqrtMod$1}),Pointk1=weierstrass$1(secp256k1_CURVE$1,{Fp:Fpk1$1,endo:secp256k1_ENDO$1}),secp256k1$1=ecdsa$1(Pointk1,sha256$2),TAGGED_HASH_PREFIXES={};function taggedHash(e,...t){let n=TAGGED_HASH_PREFIXES[e];if(void 0===n){const t=sha256$2(asciiToBytes(e));n=concatBytes$1(t,t),TAGGED_HASH_PREFIXES[e]=n}return sha256$2(concatBytes$1(n,...t))}const pointToBytes=e=>e.toBytes(!0).slice(1),hasEven=e=>e%_2n$3===_0n$4;function schnorrGetExtPubKey(e){const{Fn:t,BASE:n}=Pointk1,r=t.fromBytes(e),o=n.multiply(r);return{scalar:hasEven(o.y)?r:t.neg(r),bytes:pointToBytes(o)}}function lift_x(e){const t=Fpk1$1;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 o=t.sqrt(r);hasEven(o)||(o=t.neg(o));const s=Pointk1.fromAffine({x:e,y:o});return s.assertValidity(),s}const num=bytesToNumberBE$1;function challenge(...e){return Pointk1.Fn.create(num(taggedHash("BIP0340/challenge",...e)))}function schnorrGetPublicKey(e){return schnorrGetExtPubKey(e).bytes}function schnorrSign(e,t,n=randomBytes$1(32)){const{Fn:r}=Pointk1,o=abytes$4(e,void 0,"message"),{bytes:s,scalar:i}=schnorrGetExtPubKey(t),a=abytes$4(n,32,"auxRand"),c=r.toBytes(i^num(taggedHash("BIP0340/aux",a))),l=taggedHash("BIP0340/nonce",c,s,o),{bytes:d,scalar:u}=schnorrGetExtPubKey(l),h=challenge(d,s,o),f=new Uint8Array(64);if(f.set(d,0),f.set(r.toBytes(r.create(u+h*i)),32),!schnorrVerify(f,o,s))throw new Error("sign: Invalid signature produced");return f}function schnorrVerify(e,t,n){const{Fp:r,Fn:o,BASE:s}=Pointk1,i=abytes$4(e,64,"signature"),a=abytes$4(t,void 0,"message"),c=abytes$4(n,32,"publicKey");try{const e=lift_x(num(c)),t=num(i.subarray(0,32));if(!r.isValidNot0(t))return!1;const n=num(i.subarray(32,64));if(!o.isValidNot0(n))return!1;const l=challenge(o.toBytes(t),pointToBytes(e),a),d=s.multiplyUnsafe(n).add(e.multiplyUnsafe(o.neg(l))),{x:u,y:h}=d.toAffine();return!(d.is0()||!hasEven(h)||u!==t)}catch(e){return!1}}const schnorr=(()=>{const e=(e=randomBytes$1(48))=>mapHashToField$1(e,secp256k1_CURVE$1.n);return{keygen:createKeygen(e,schnorrGetPublicKey),getPublicKey:schnorrGetPublicKey,sign:schnorrSign,verify:schnorrVerify,Point:Pointk1,utils:{randomSecretKey:e,taggedHash:taggedHash,lift_x:lift_x,pointToBytes:pointToBytes},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})();
|
|
9
|
+
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function isBytes$3(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function abytes$3(e){if(!isBytes$3(e))throw new Error("Uint8Array expected")}function isArrayOf$1(e,t){return!!Array.isArray(t)&&(0===t.length||(e?t.every((e=>"string"==typeof e)):t.every((e=>Number.isSafeInteger(e)))))}function afn(e){if("function"!=typeof e)throw new Error("function expected");return!0}function astr$1(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function anumber$3(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function aArr$1(e){if(!Array.isArray(e))throw new Error("array expected")}function astrArr$1(e,t){if(!isArrayOf$1(!0,t))throw new Error(`${e}: array of strings expected`)}function anumArr$1(e,t){if(!isArrayOf$1(!1,t))throw new Error(`${e}: array of numbers expected`)}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){const t="string"==typeof e?e.split(""):e,n=t.length;astrArr$1("alphabet",t);const r=new Map(t.map(((e,t)=>[e,t])));return{encode:r=>(aArr$1(r),r.map((r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${e}`);return t[r]}))),decode:t=>(aArr$1(t),t.map((t=>{astr$1("alphabet.decode",t);const n=r.get(t);if(void 0===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})))}}function join$1(e=""){return astr$1("join",e),{encode:t=>(astrArr$1("join.decode",t),t.join(e)),decode:t=>(astr$1("join.decode",t),t.split(e))}}function padding$1(e,t="="){return anumber$3(e),astr$1("padding",t),{encode(n){for(astrArr$1("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){astrArr$1("padding.decode",n);let r=n.length;if(r*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--){if((r-1)*e%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,r)}}}const gcd$1=(e,t)=>0===t?e:gcd$1(t,e%t),radix2carry$1=(e,t)=>e+(t-gcd$1(e,t)),powers$1=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function convertRadix2$1(e,t,n,r){if(aArr$1(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(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=powers$1[t],a=powers$1[n]-1,c=[];for(const r of e){if(anumber$3(r),r>=i)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)c.push((o>>s-n&a)>>>0);const e=powers$1[s];if(void 0===e)throw new Error("invalid carry");o&=e-1}if(o=o<<n-s&a,!r&&s>=t)throw new Error("Excess padding");if(!r&&o>0)throw new Error(`Non-zero padding: ${o}`);return r&&s>0&&c.push(o>>>0),c}function radix2$1(e,t=!1){if(anumber$3(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(!isBytes$3(n))throw new Error("radix2.encode input should be Uint8Array");return convertRadix2$1(Array.from(n),8,e,!t)},decode:n=>(anumArr$1("radix2.decode",n),Uint8Array.from(convertRadix2$1(n,e,8,t)))}}function unsafeWrapper(e){return afn(e),function(...t){try{return e.apply(null,t)}catch(e){}}}const hasBase64Builtin$1=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)(),decodeBase64Builtin$1=(e,t)=>{astr$1("base64",e);if(e.length>0&&!/^[A-Za-z0-9=+/]+$/.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:"base64",lastChunkHandling:"strict"})},base64$1=hasBase64Builtin$1?{encode:e=>(abytes$3(e),e.toBase64()),decode:e=>decodeBase64Builtin$1(e)}:chain$1(radix2$1(6),alphabet$1("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),padding$1(6),join$1("")),BECH_ALPHABET=chain$1(alphabet$1("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),join$1("")),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$1([o%powers$1[30]],30,5,!1))}function genBech32(e){const t="bech32"===e?1:734539939,n=radix2$1(5),r=n.decode,o=n.encode,s=unsafeWrapper(r);function i(e,n,r=90){astr$1("bech32.encode prefix",e),isBytes$3(n)&&(n=Array.from(n)),anumArr$1("bech32.encode",n);const o=e.length;if(0===o)throw new TypeError(`Invalid prefix length ${o}`);const s=o+7+n.length;if(!1!==r&&s>r)throw new TypeError(`Length ${s} exceeds limit ${r}`);const i=e.toLowerCase(),a=bechChecksum(i,n,t);return`${i}1${BECH_ALPHABET.encode(n)}${a}`}function a(e,n=90){astr$1("bech32.decode input",e);const r=e.length;if(r<8||!1!==n&&r>n)throw new TypeError(`invalid string length: ${r} (${e}). Expected (8..${n})`);const o=e.toLowerCase();if(e!==o&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const s=o.lastIndexOf("1");if(0===s||-1===s)throw new Error('Letter "1" must be present between prefix and data only');const i=o.slice(0,s),a=o.slice(s+1);if(a.length<6)throw new Error("Data must be at least 6 characters long");const c=BECH_ALPHABET.decode(a).slice(0,-6),l=bechChecksum(i,c,t);if(!a.endsWith(l))throw new Error(`Invalid checksum in ${e}: expected "${l}"`);return{prefix:i,words:c}}return{encode:i,decode:a,encodeFromBytes:function(e,t){return i(e,o(t))},decodeToBytes:function(e){const{prefix:t,words:n}=a(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:unsafeWrapper(a),fromWords:r,fromWordsUnsafe:s,toWords:o}}const bech32=genBech32("bech32");
|
|
10
|
+
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function isBytes$2(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function abool(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function anumber$2(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function abytes$2(e,t,n=""){const r=isBytes$2(e),o=e?.length,s=void 0!==t;if(!r||s&&o!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${t}`:"")+", got "+(r?`length=${o}`:"type="+typeof e))}return e}function u32(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function clean$1(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const isLE=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function overlapBytes(e,t){return e.buffer===t.buffer&&e.byteOffset<t.byteOffset+t.byteLength&&t.byteOffset<e.byteOffset+e.byteLength}function complexOverlapBytes(e,t){if(overlapBytes(e,t)&&e.byteOffset<t.byteOffset)throw new Error("complex overlap of input and output is not supported")}function checkOpts(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)}function equalBytes(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)=>{function n(n,...r){if(abytes$2(n,void 0,"key"),!isLE)throw new Error("Non little-endian hardware is not yet supported");if(void 0!==e.nonceLength){abytes$2(r[0],e.varSizeNonce?void 0:e.nonceLength,"nonce")}const o=e.tagLength;o&&void 0!==r[1]&&abytes$2(r[1],void 0,"AAD");const s=t(n,...r),i=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");abytes$2(t,void 0,"output")}};let a=!1;return{encrypt(e,t){if(a)throw new Error("cannot encrypt() twice with same key + nonce");return a=!0,abytes$2(e),i(s.encrypt.length,t),s.encrypt(e,t)},decrypt(e,t){if(abytes$2(e),o&&e.length<o)throw new Error('"ciphertext" expected length bigger than tagLength='+o);return i(s.decrypt.length,t),s.decrypt(e,t)}}}return Object.assign(n,e),n};function getOutput(e,t,n=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(n&&!isAligned32$1(t))throw new Error("invalid output, must be aligned");return t}function isAligned32$1(e){return e.byteOffset%4==0}function copyBytes(e){return Uint8Array.from(e)}const BLOCK_SIZE=16,POLY=283;function validateKeyLength(e){if(![16,24,32].includes(e.length))throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length='+e.length)}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=(()=>{const 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 clean$1(e),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),o=r.map(rotl32_8),s=o.map(rotl32_8),i=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 d=256*t+l;i[d]=n[t]^r[l],a[d]=o[t]^s[l],c[d]=e[t]<<8|e[l]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:o,T3:s,T01:i,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){abytes$2(e);const t=e.length;validateKeyLength(e);const{sbox2:n}=tableEncoding,r=[];isAligned32$1(e)||r.push(e=copyBytes(e));const o=u32(e),s=o.length,i=e=>applySbox(n,e,e,e,e),a=new Uint32Array(t+28);a.set(o);for(let e=s;e<a.length;e++){let t=a[e-1];e%s==0?t=i(rotr32_8(t))^xPowers[e/s-1]:s>6&&e%s==4&&(t=i(t)),a[e]=a[e-s]^t}return clean$1(...r),a}function expandKeyDecLE(e){const t=expandKeyLE(e),n=t.slice(),r=t.length,{sbox2:o}=tableEncoding,{T0:s,T1:i,T2:a,T3:c}=tableDecoding;for(let e=0;e<r;e+=4)for(let o=0;o<4;o++)n[e+o]=t[r-e-4+o];clean$1(t);for(let e=4;e<r-4;e++){const t=n[e],r=applySbox(o,t,t,t,t);n[e]=s[255&r]^i[r>>>8&255]^a[r>>>16&255]^c[r>>>24]}return n}function apply0123(e,t,n,r,o,s){return e[n<<8&65280|r>>>8&255]^t[o>>>8&65280|s>>>24&255]}function applySbox(e,t,n,r,o){return e[255&t|65280&n]|e[r>>>16&255|o>>>16&65280]<<16}function encrypt$1(e,t,n,r,o){const{sbox2:s,T01:i,T23:a}=tableEncoding;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],o^=e[c++];const l=e.length/4-2;for(let s=0;s<l;s++){const s=e[c++]^apply0123(i,a,t,n,r,o),l=e[c++]^apply0123(i,a,n,r,o,t),d=e[c++]^apply0123(i,a,r,o,t,n),u=e[c++]^apply0123(i,a,o,t,n,r);t=s,n=l,r=d,o=u}return{s0:e[c++]^applySbox(s,t,n,r,o),s1:e[c++]^applySbox(s,n,r,o,t),s2:e[c++]^applySbox(s,r,o,t,n),s3:e[c++]^applySbox(s,o,t,n,r)}}function decrypt$1(e,t,n,r,o){const{sbox2:s,T01:i,T23:a}=tableDecoding;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],o^=e[c++];const l=e.length/4-2;for(let s=0;s<l;s++){const s=e[c++]^apply0123(i,a,t,o,r,n),l=e[c++]^apply0123(i,a,n,t,o,r),d=e[c++]^apply0123(i,a,r,n,t,o),u=e[c++]^apply0123(i,a,o,r,n,t);t=s,n=l,r=d,o=u}return{s0:e[c++]^applySbox(s,t,o,r,n),s1:e[c++]^applySbox(s,n,t,o,r),s2:e[c++]^applySbox(s,r,n,t,o),s3:e[c++]^applySbox(s,o,r,n,t)}}function validateBlockDecrypt(e){if(abytes$2(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){abytes$2(e);let r=e.length;const o=r%BLOCK_SIZE;if(!t&&0!==o)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");isAligned32$1(e)||(e=copyBytes(e));const s=u32(e);if(t){let e=BLOCK_SIZE-o;e||(e=BLOCK_SIZE),r+=e}complexOverlapBytes(e,n=getOutput(r,n));return{b:s,o:u32(n),out:n}}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");const o=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 o}function padPCKS(e){const t=new Uint8Array(16),n=u32(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={}){const r=!n.disablePadding;return{encrypt(n,o){const s=expandKeyLE(e),{b:i,o:a,out:c}=validateBlockEncrypt(n,r,o);let l=t;const d=[s];isAligned32$1(l)||d.push(l=copyBytes(l));const u=u32(l);let h=u[0],f=u[1],p=u[2],g=u[3],m=0;for(;m+4<=i.length;)h^=i[m+0],f^=i[m+1],p^=i[m+2],g^=i[m+3],({s0:h,s1:f,s2:p,s3:g}=encrypt$1(s,h,f,p,g)),a[m++]=h,a[m++]=f,a[m++]=p,a[m++]=g;if(r){const e=padPCKS(n.subarray(4*m));h^=e[0],f^=e[1],p^=e[2],g^=e[3],({s0:h,s1:f,s2:p,s3:g}=encrypt$1(s,h,f,p,g)),a[m++]=h,a[m++]=f,a[m++]=p,a[m++]=g}return clean$1(...d),c},decrypt(n,o){validateBlockDecrypt(n);const s=expandKeyDecLE(e);let i=t;const a=[s];isAligned32$1(i)||a.push(i=copyBytes(i));const c=u32(i);o=getOutput(n.length,o),isAligned32$1(n)||a.push(n=copyBytes(n)),complexOverlapBytes(n,o);const l=u32(n),d=u32(o);let u=c[0],h=c[1],f=c[2],p=c[3];for(let e=0;e+4<=l.length;){const t=u,n=h,r=f,o=p;u=l[e+0],h=l[e+1],f=l[e+2],p=l[e+3];const{s0:i,s1:a,s2:c,s3:g}=decrypt$1(s,u,h,f,p);d[e++]=i^t,d[e++]=a^n,d[e++]=c^r,d[e++]=g^o}return clean$1(...a),validatePCKS(o,r)}}})),encodeStr=e=>Uint8Array.from(e.split(""),(e=>e.charCodeAt(0))),sigma16=encodeStr("expand 16-byte k"),sigma32=encodeStr("expand 32-byte k"),sigma16_32=u32(sigma16),sigma32_32=u32(sigma32);function rotl(e,t){return e<<t|e>>>32-t}function isAligned32(e){return e.byteOffset%4==0}const BLOCK_LEN=64,BLOCK_LEN32=16,MAX_COUNTER=2**32-1,U32_EMPTY=Uint32Array.of();function runCipher(e,t,n,r,o,s,i,a){const c=o.length,l=new Uint8Array(BLOCK_LEN),d=u32(l),u=isAligned32(o)&&isAligned32(s),h=u?u32(o):U32_EMPTY,f=u?u32(s):U32_EMPTY;for(let p=0;p<c;i++){if(e(t,n,r,d,i,a),i>=MAX_COUNTER)throw new Error("arx: counter overflow");const g=Math.min(BLOCK_LEN,c-p);if(u&&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]=h[t]^d[n];p+=BLOCK_LEN}else{for(let e,t=0;t<g;t++)e=p+t,s[e]=o[e]^l[t];p+=g}}}function createCipher(e,t){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:s,rounds:i}=checkOpts({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return anumber$2(o),anumber$2(i),abool(s),abool(n),(t,a,c,l,d=0)=>{abytes$2(t,void 0,"key"),abytes$2(a,void 0,"nonce"),abytes$2(c,void 0,"data");const u=c.length;if(void 0===l&&(l=new Uint8Array(u)),abytes$2(l,void 0,"output"),anumber$2(d),d<0||d>=MAX_COUNTER)throw new Error("arx: counter overflow");if(l.length<u)throw new Error(`arx: output (${l.length}) is shorter than data (${u})`);const h=[];let f,p,g=t.length;if(32===g)h.push(f=copyBytes(t)),p=sigma32_32;else{if(16!==g||!n)throw abytes$2(t,32,"arx key"),new Error("invalid key size");f=new Uint8Array(32),f.set(t),f.set(t,16),p=sigma16_32,h.push(f)}isAligned32(a)||h.push(a=copyBytes(a));const m=u32(f);if(r){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");r(p,m,u32(a.subarray(0,16)),m),a=a.subarray(16)}const b=16-o;if(b!==a.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(12!==b){const e=new Uint8Array(12);e.set(a,s?0:12-a.length),a=e,h.push(a)}const y=u32(a);return runCipher(e,p,m,y,c,l,d,i),clean$1(...h),l}}function chachaCore(e,t,n,r,o,s=20){let i=e[0],a=e[1],c=e[2],l=e[3],d=t[0],u=t[1],h=t[2],f=t[3],p=t[4],g=t[5],m=t[6],b=t[7],y=o,w=n[0],v=n[1],k=n[2],E=i,x=a,$=c,C=l,B=d,_=u,S=h,P=f,R=p,A=g,N=m,L=b,O=y,I=w,T=v,M=k;for(let e=0;e<s;e+=2)E=E+B|0,O=rotl(O^E,16),R=R+O|0,B=rotl(B^R,12),E=E+B|0,O=rotl(O^E,8),R=R+O|0,B=rotl(B^R,7),x=x+_|0,I=rotl(I^x,16),A=A+I|0,_=rotl(_^A,12),x=x+_|0,I=rotl(I^x,8),A=A+I|0,_=rotl(_^A,7),$=$+S|0,T=rotl(T^$,16),N=N+T|0,S=rotl(S^N,12),$=$+S|0,T=rotl(T^$,8),N=N+T|0,S=rotl(S^N,7),C=C+P|0,M=rotl(M^C,16),L=L+M|0,P=rotl(P^L,12),C=C+P|0,M=rotl(M^C,8),L=L+M|0,P=rotl(P^L,7),E=E+_|0,M=rotl(M^E,16),N=N+M|0,_=rotl(_^N,12),E=E+_|0,M=rotl(M^E,8),N=N+M|0,_=rotl(_^N,7),x=x+S|0,O=rotl(O^x,16),L=L+O|0,S=rotl(S^L,12),x=x+S|0,O=rotl(O^x,8),L=L+O|0,S=rotl(S^L,7),$=$+P|0,I=rotl(I^$,16),R=R+I|0,P=rotl(P^R,12),$=$+P|0,I=rotl(I^$,8),R=R+I|0,P=rotl(P^R,7),C=C+B|0,T=rotl(T^C,16),A=A+T|0,B=rotl(B^A,12),C=C+B|0,T=rotl(T^C,8),A=A+T|0,B=rotl(B^A,7);let U=0;r[U++]=i+E|0,r[U++]=a+x|0,r[U++]=c+$|0,r[U++]=l+C|0,r[U++]=d+B|0,r[U++]=u+_|0,r[U++]=h+S|0,r[U++]=f+P|0,r[U++]=p+R|0,r[U++]=g+A|0,r[U++]=m+N|0,r[U++]=b+L|0,r[U++]=y+O|0,r[U++]=w+I|0,r[U++]=v+T|0,r[U++]=k+M|0}const chacha20=createCipher(chachaCore,{counterRight:!1,counterLength:4,allowShortKeys:!1});function extract$1(e,t,n){return ahash$1(e),void 0===n&&(n=new Uint8Array(e.outputLen)),hmac$1(e,n,t)}const HKDF_COUNTER$1=Uint8Array.of(0),EMPTY_BUFFER$1=Uint8Array.of();function expand$1(e,t,n,r=32){ahash$1(e),anumber$4(r,"length");const o=e.outputLen;if(r>255*o)throw new Error("Length must be <= 255*HashLen");const s=Math.ceil(r/o);void 0===n?n=EMPTY_BUFFER$1:abytes$4(n,void 0,"info");const i=new Uint8Array(s*o),a=hmac$1.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let e=0;e<s;e++)HKDF_COUNTER$1[0]=e+1,c.update(0===e?EMPTY_BUFFER$1:l).update(n).update(HKDF_COUNTER$1).digestInto(l),i.set(l,o*e),a._cloneInto(c);return a.destroy(),c.destroy(),clean$2(l,HKDF_COUNTER$1),i.slice(0,r)}var __defProp=Object.defineProperty,__export=(e,t)=>{for(var n in t)__defProp(e,n,{get:t[n],enumerable:!0})},verifiedSymbol=Symbol("verified"),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("string"!=typeof n[e])return!1}return!0}var utils_exports={};__export(utils_exports,{binarySearch:()=>binarySearch,bytesToHex:()=>bytesToHex$1,hexToBytes:()=>hexToBytes$1,insertEventIntoAscendingList:()=>insertEventIntoAscendingList,insertEventIntoDescendingList:()=>insertEventIntoDescendingList,mergeReverseSortedLists:()=>mergeReverseSortedLists,normalizeURL:()=>normalizeURL,utf8Decoder:()=>utf8Decoder,utf8Encoder:()=>utf8Encoder});var utf8Decoder=new TextDecoder("utf-8"),utf8Encoder=new TextEncoder;function normalizeURL(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(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(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 o=Math.floor((n+r)/2),s=t(e[o]);if(0===s)return[o,!0];s<0?r=o-1:n=o+1}return[n,!1]}function mergeReverseSortedLists(e,t){const n=new Array(e.length+t.length);n.length=0;let r=0,o=0,s=[];for(;r<e.length&&o<t.length;){let i;if(e[r]?.created_at>t[o]?.created_at?(i=e[r],r++):(i=t[o],o++),n.length>0&&n[n.length-1].created_at===i.created_at){if(s.includes(i.id))continue}else s.length=0;n.push(i),s.push(i.id)}for(;r<e.length;){const t=e[r];if(r++,n.length>0&&n[n.length-1].created_at===t.created_at){if(s.includes(t.id))continue}else s.length=0;n.push(t),s.push(t.id)}for(;o<t.length;){const e=t[o];if(o++,n.length>0&&n[n.length-1].created_at===e.created_at){if(s.includes(e.id))continue}else s.length=0;n.push(e),s.push(e.id)}return n}var JS=class{generateSecretKey(){return schnorr.utils.randomSecretKey()}getPublicKey(e){return bytesToHex$1(schnorr.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=bytesToHex$1(schnorr.getPublicKey(t)),n.id=getEventHash(n),n.sig=bytesToHex$1(schnorr.sign(hexToBytes$1(getEventHash(n)),t)),n[verifiedSymbol]=!0,n}verifyEvent(e){if("boolean"==typeof e[verifiedSymbol])return e[verifiedSymbol];try{const t=getEventHash(e);if(t!==e.id)return e[verifiedSymbol]=!1,!1;const n=schnorr.verify(hexToBytes$1(e.sig),hexToBytes$1(t),hexToBytes$1(e.pubkey));return e[verifiedSymbol]=n,n}catch(t){return e[verifiedSymbol]=!1,!1}}};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$2(utf8Encoder.encode(serializeEvent(e))))}var i=new JS,generateSecretKey=i.generateSecretKey,getPublicKey=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(e)&&n.includes(e.kind)||!1}__export(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,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 nip42_exports={},_WebSocket,_WebSocket2;function makeAuthEvent(e,t){return{kind:ClientAuth,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}__export(nip42_exports,{makeAuthEvent:()=>makeAuthEvent});try{_WebSocket=WebSocket}catch{}try{_WebSocket2=WebSocket}catch{}var nip19_exports={};__export(nip19_exports,{BECH32_REGEX:()=>BECH32_REGEX,Bech32MaxSize:()=>Bech32MaxSize,NostrTypeGuard:()=>NostrTypeGuard,decode:()=>decode,decodeNostrURI:()=>decodeNostrURI,encodeBytes:()=>encodeBytes,naddrEncode:()=>naddrEncode,neventEncode:()=>neventEncode,noteEncode:()=>noteEncode,nprofileEncode:()=>nprofileEncode,npubEncode:()=>npubEncode,nsecEncode:()=>nsecEncode});var 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=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 decodeNostrURI(e){try{return e.startsWith("nostr:")&&(e=e.substring(6)),decode(e)}catch(e){return{type:"invalid",data:null}}}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$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"nsec":return{type:t,data:r};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],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",hexToBytes$1(e))}function noteEncode(e){return encodeBytes("note",hexToBytes$1(e))}function encodeBech32(e,t){let n=bech32.toWords(t);return bech32.encode(e,n,Bech32MaxSize)}function encodeBytes(e,t){return encodeBech32(e,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 void 0!==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 encodeTLV(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$1(...t)}var nip04_exports={};function encrypt(e,t,n){const r=e instanceof Uint8Array?e:hexToBytes$1(e),o=getNormalizedX(secp256k1$1.getSharedSecret(r,hexToBytes$1("02"+t)));let s=Uint8Array.from(randomBytes$1(16)),i=utf8Encoder.encode(n),a=cbc(o,s).encrypt(i);return`${base64$1.encode(new Uint8Array(a))}?iv=${base64$1.encode(new Uint8Array(s.buffer))}`}function decrypt(e,t,n){const r=e instanceof Uint8Array?e:hexToBytes$1(e);let[o,s]=n.split("?iv="),i=getNormalizedX(secp256k1$1.getSharedSecret(r,hexToBytes$1("02"+t))),a=base64$1.decode(s),c=base64$1.decode(o),l=cbc(i,a).decrypt(c);return utf8Decoder.decode(l)}function getNormalizedX(e){return e.slice(1,33)}__export(nip04_exports,{decrypt:()=>decrypt,encrypt:()=>encrypt});var nip05_exports={};__export(nip05_exports,{NIP05_REGEX:()=>NIP05_REGEX,isNip05:()=>isNip05,isValid:()=>isValid,queryProfile:()=>queryProfile,searchDomain:()=>searchDomain,useFetchImplementation:()=>useFetchImplementation});var NIP05_REGEX=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,isNip05=e=>NIP05_REGEX.test(e||""),_fetch;try{_fetch=fetch}catch(_){}function useFetchImplementation(e){_fetch=e}async function searchDomain(e,t=""){try{const n=`https://${e}/.well-known/nostr.json?name=${t}`,r=await _fetch(n,{redirect:"manual"});if(200!==r.status)throw Error("Wrong response code");return(await r.json()).names}catch(e){return{}}}async function queryProfile(e){const t=e.match(NIP05_REGEX);if(!t)return null;const[,n="_",r]=t;try{const e=`https://${r}/.well-known/nostr.json?name=${n}`,t=await _fetch(e,{redirect:"manual"});if(200!==t.status)throw Error("Wrong response code");const o=await t.json(),s=o.names[n];return s?{pubkey:s,relays:o.relays?.[s]}:null}catch(e){return null}}async function isValid(e,t){const n=await queryProfile(t);return!!n&&n.pubkey===e}var nip10_exports={};function parse(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,r;for(let o=e.tags.length-1;o>=0;o--){const s=e.tags[o];if("e"===s[0]&&s[1]){const[e,o,i,a,c]=s,l={id:o,relays:i?[i]:[],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)}else{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(nip10_exports,{parse:()=>parse});var nip11_exports={},_fetch2;__export(nip11_exports,{fetchRelayInformation:()=>fetchRelayInformation,useFetchImplementation:()=>useFetchImplementation2});try{_fetch2=fetch}catch{}function useFetchImplementation2(e){_fetch2=e}async function fetchRelayInformation(e){return await(await fetch(e.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}var nip13_exports={};function getPow(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 getPowFromBytes(e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];if(0!==r){t+=Math.clz32(r)-24;break}t+=8}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);e!==r.created_at&&(n=0,r.created_at=e),o[1]=(++n).toString();const s=sha256$2(utf8Encoder.encode(JSON.stringify([0,r.pubkey,r.created_at,r.kind,r.tags,r.content])));if(getPowFromBytes(s)>=t){r.id=bytesToHex$1(s);break}}return r}__export(nip13_exports,{getPow:()=>getPow,minePow:()=>minePow});var nip17_exports={};__export(nip17_exports,{unwrapEvent:()=>unwrapEvent2,unwrapManyEvents:()=>unwrapManyEvents2,wrapEvent:()=>wrapEvent2,wrapManyEvents:()=>wrapManyEvents2});var nip59_exports={};__export(nip59_exports,{createRumor:()=>createRumor,createSeal:()=>createSeal,createWrap:()=>createWrap,unwrapEvent:()=>unwrapEvent,unwrapManyEvents:()=>unwrapManyEvents,wrapEvent:()=>wrapEvent,wrapManyEvents:()=>wrapManyEvents});var nip44_exports={};__export(nip44_exports,{decrypt:()=>decrypt2,encrypt:()=>encrypt2,getConversationKey:()=>getConversationKey,v2:()=>v2});var minPlaintextSize=1,maxPlaintextSize=65535;function getConversationKey(e,t){const n=secp256k1$1.getSharedSecret(e,hexToBytes$1("02"+t)).subarray(1,33);return extract$1(sha256$2,n,utf8Encoder.encode("nip44-v2"))}function getMessageKeys(e,t){const n=expand$1(sha256$2,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.encode(e),n=t.length;return concatBytes$1(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.decode(n)}function hmacAad(e,t,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const r=concatBytes$1(n,t);return hmac$1(sha256$2,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 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 encrypt2(e,t,n=randomBytes$1(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:s}=getMessageKeys(t,n),i=pad(e),a=chacha20(r,o,i),c=hmacAad(s,a,n);return base64$1.encode(concatBytes$1(new Uint8Array([2]),n,a,c))}function decrypt2(e,t){const{nonce:n,ciphertext:r,mac:o}=decodePayload(e),{chacha_key:s,chacha_nonce:i,hmac_key:a}=getMessageKeys(t,n);if(!equalBytes(hmacAad(a,r,n),o))throw new Error("invalid MAC");return unpad(chacha20(s,i,r))}var v2={utils:{getConversationKey:getConversationKey,calcPaddedLen:calcPaddedLen},encrypt:encrypt2,decrypt:decrypt2},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(JSON.stringify(e),nip44ConversationKey(t,n)),nip44Decrypt=(e,t)=>JSON.parse(decrypt2(e.content,nip44ConversationKey(t,e.pubkey)));function createRumor(e,t){const n={created_at:now(),content:"",tags:[],...e,pubkey:getPublicKey(t)};return n.id=getEventHash(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(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(t),o=[wrapEvent(e,t,r)];return n.forEach((n=>{o.push(wrapEvent(e,t,n))})),o}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 o={created_at:Math.ceil(Date.now()/1e3),kind:PrivateDirectMessage,tags:[],content:t};return(Array.isArray(e)?e:[e]).forEach((({publicKey:e,relayUrl:t})=>{o.tags.push(t?["p",e,t]:["p",e])})),r&&o.tags.push(["e",r.eventId,r.relayUrl||"","reply"]),n&&o.tags.push(["subject",n]),o}function wrapEvent2(e,t,n,r,o){return wrapEvent(createEvent(t,n,r,o),e,t.publicKey)}function wrapManyEvents2(e,t,n,r,o){if(!t||0===t.length)throw new Error("At least one recipient is required.");return[{publicKey:getPublicKey(e)},...t].map((t=>wrapEvent2(e,t,n,r,o)))}var unwrapEvent2=unwrapEvent,unwrapManyEvents2=unwrapManyEvents,nip18_exports={};function finishRepostEvent(e,t,n,r){let o;const s=[...e.tags??[],["e",t.id,n],["p",t.pubkey]];return t.kind===ShortTextNote?o=Repost:(o=GenericRepost,s.push(["k",String(t.kind)])),finalizeEvent({kind:o,tags:s,content:""===e.content||t.tags?.find((e=>"-"===e[0]))?"":JSON.stringify(t),created_at:e.created_at},r)}function getRepostedEventPointer(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 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||verifyEvent(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 finalizeEvent({...e,kind:Reaction,tags:[...e.tags??[],...r,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function getReactedEventPointer(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 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 nip27_exports={};__export(nip27_exports,{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,o=0;e:for(;o<n;){const s=e.indexOf(":",o),i=e.indexOf("#",o);if(-1===s&&-1===i)break e;if(-1===s||i>=0&&i<s){if(0===i||e[i-1].match(noCharacter)){const t=e.slice(i+1,i+MAX_HASHTAG_LENGTH).match(noCharacter),s=t?i+1+t.index:n;yield{type:"text",text:e.slice(r,i)},yield{type:"hashtag",value:e.slice(i+1,s)},o=s,r=o;continue e}o=i+1}else if("nostr"===e.slice(s-5,s)){const t=e.slice(s+60).match(noCharacter),i=t?s+60+t.index:n;try{let t,{data:n,type:a}=decode(e.slice(s+1,i));switch(a){case"npub":t={pubkey:n};break;case"note":t={id:n};break;case"nsec":o=i+1;continue;default:t=n}r!==s-5&&(yield{type:"text",text:e.slice(r,s-5)}),yield{type:"reference",pointer:t},o=i,r=o;continue e}catch(e){o=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),i=t?s+4+t.index:n,a="s"===e[s-1]?5:4;try{let t=new URL(e.slice(s-a,i));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()},o=i,r=o;continue e}if(/\.(mp4|avi|webm|mkv|mov)$/i.test(t.pathname)){yield{type:"video",url:t.toString()},o=i,r=o;continue e}if(/\.(mp3|aac|ogg|opus|wav|flac)$/i.test(t.pathname)){yield{type:"audio",url:t.toString()},o=i,r=o;continue e}yield{type:"url",url:t.toString()},o=i,r=o;continue e}catch(e){o=i+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 i=t[n];if(":"===e[s+i.shortcode.length+1]&&e.slice(s+1,s+i.shortcode.length+1)===i.shortcode){r!==s&&(yield{type:"text",text:e.slice(r,s)}),yield i,o=s+i.shortcode.length+2,r=o;continue e}}o=s+1;continue e}{const t=e.slice(s+4).match(noURLCharacter),i=t?s+4+t.index:n,a="s"===e[s-1]?3:2;try{let t=new URL(e.slice(s-a,i));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()},o=i,r=o;continue e}catch(e){o=i+1;continue e}}}}r!==n&&(yield{type:"text",text:e.slice(r)})}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 finalizeEvent({kind:ChannelCreation,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 finalizeEvent({kind:ChannelMetadata,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"]),finalizeEvent({kind:ChannelMessage,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 finalizeEvent({kind:ChannelHideMessage,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 finalizeEvent({kind:ChannelMuteUser,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)},nip30_exports={};__export(nip30_exports,{EMOJI_SHORTCODE_REGEX:()=>EMOJI_SHORTCODE_REGEX,matchAll:()=>matchAll,regex:()=>regex,replaceAll:()=>replaceAll});var EMOJI_SHORTCODE_REGEX=/:(\w+):/,regex=()=>new RegExp(`\\B${EMOJI_SHORTCODE_REGEX.source}\\B`,"g");function*matchAll(e){const t=e.matchAll(regex());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(e,t){return e.replaceAll(regex(),((e,n)=>t({shortcode:e,name:n})))}var nip39_exports={},_fetch3;__export(nip39_exports,{useFetchImplementation:()=>useFetchImplementation3,validateGithub:()=>validateGithub});try{_fetch3=fetch}catch{}function useFetchImplementation3(e){_fetch3=e}async function validateGithub(e,t,n){try{return await(await _fetch3(`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={};function parseConnectionString(e){const{host:t,pathname:n,searchParams:r}=new URL(e),o=n||t,s=r.get("relay"),i=r.get("secret");if(!o||!s||!i)throw new Error("invalid connection string");return{pubkey:o,relay:s,secret:i}}async function makeNwcRequestEvent(e,t,n){const r={method:"pay_invoice",params:{invoice:n}},o=encrypt(t,e,JSON.stringify(r)),s={kind:NWCWalletRequest,created_at:Math.round(Date.now()/1e3),content:o,tags:[["p",e]]};return finalizeEvent(s,t)}__export(nip47_exports,{makeNwcRequestEvent:()=>makeNwcRequestEvent,parseConnectionString:()=>parseConnectionString});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(nip54_exports,{normalizeIdentifier:()=>normalizeIdentifier});var nip57_exports={},_fetch4;__export(nip57_exports,{getSatoshisAmountFromBolt11:()=>getSatoshisAmountFromBolt11,getZapEndpoint:()=>getZapEndpoint,makeZapReceipt:()=>makeZapReceipt,makeZapRequest:()=>makeZapRequest,useFetchImplementation:()=>useFetchImplementation4,validateZapRequest:()=>validateZapRequest});try{_fetch4=fetch}catch{}function useFetchImplementation4(e){_fetch4=e}async function getZapEndpoint(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.decode(n,1e3),r=bech32.fromWords(e);t=utf8Decoder.decode(r)}}let o=await _fetch4(t),s=await o.json();if(s.allowsNostr&&s.nostrPubkey)return s.callback}catch(e){}return null}function makeZapRequest(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(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(!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));if(r&&!r[1].match(/^[a-f0-9]{64}$/))return"Zap request 'e' tag is not valid hex.";let o=t.tags.find((([e,t])=>"relays"===e&&t));return o?null:"Zap request doesn't have a 'relays' tag."}function makeZapReceipt({zapRequest:e,preimage:t,bolt11:n,paidAt:r}){let o=JSON.parse(e),s=o.tags.filter((([e])=>"e"===e||"p"===e||"a"===e)),i={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...s,["P",o.pubkey],["bolt11",n],["description",e]]};return t&&i.tags.push(["preimage",t]),i}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 o=r[r.length-1],s=o.charCodeAt(0)-"0".charCodeAt(0),i=s>=0&&s<=9;let a=r.length-1;if(i&&a++,a<1)return 0;const c=parseInt(r.substring(0,a));switch(o){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(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),o=new DataView(e.buffer);for(let e=0;e<8;e++){let s=4*e,i=r.getUint32(s,!0);i+=t,i+=o.getUint32(s,!0),i>4294967295&&(n=1),r.setUint32(s,4294967295&i,!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$2(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$1(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 o=n-t;for(;o>0;){let n=t,s=Math.floor(o/2);n+=s,r(e[n])?(t=++n,o-=s+1):o=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$1(e.unwrap())}reconcile(e,t,n){const r=new WrappedBuffer(hexToBytes$1(e));this.lastTimestampIn=this.lastTimestampOut=0;let o=new WrappedBuffer;o.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 i=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)))},d=this.decodeBound(r),u=decodeVarInt(r),h=c,f=this.storage.findLowerBound(c,i,d);if(u===Mode.Skip)l=!0;else if(u===Mode.Fingerprint){0!==compareUint8Array(getBytes(r,FINGERPRINT_SIZE),this.storage.fingerprint(h,f))?(s(),this.splitRange(h,f,d,e)):l=!0}else{if(u!==Mode.IdList)throw Error("unexpected mode");{let e=decodeVarInt(r),o={};for(let t=0;t<e;t++){let e=getBytes(r,ID_SIZE);o[bytesToHex$1(e)]=e}if(l=!0,this.storage.iterate(h,f,(e=>{let n=e.id;const r=bytesToHex$1(n);return o[r]?delete o[bytesToHex$1(n)]:t?.(r),!0})),n)for(let e of Object.values(o))n(bytesToHex$1(e))}}if(this.exceededFrameSizeLimit(o.length+e.length)){let e=this.storage.fingerprint(f,i);o.extend(this.encodeBound(this._bound(Number.MAX_VALUE))),o.extend(encodeVarInt(Mode.Fingerprint)),o.extend(e);break}o.extend(e),c=f,a=d}return 1===o.length?null:bytesToHex$1(o.unwrap())}splitRange(e,t,n,r){let o=t-e;if(o<32)r.extend(this.encodeBound(n)),r.extend(encodeVarInt(Mode.IdList)),r.extend(encodeVarInt(o)),this.storage.iterate(e,t,(e=>(r.extend(e.id),!0)));else{let s=Math.floor(o/16),i=o%16,a=e;for(let e=0;e<16;e++){let o,c=s+(e<i?1:0),l=this.storage.fingerprint(a,a+c);if(a+=c,a===t)o=n;else{let e,t;this.storage.iterate(a-1,a+1,((n,r)=>(r===a-1?e=n:t=n,!0))),o=this.getMinimalBound(e,t)}r.extend(this.encodeBound(o)),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,o=e.id;for(let e=0;e<ID_SIZE&&r[e]===o[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={};__export(nip98_exports,{getToken:()=>getToken,hashPayload:()=>hashPayload,unpackEventFromToken:()=>unpackEventFromToken,validateEvent:()=>validateEvent2,validateEventKind:()=>validateEventKind,validateEventMethodTag:()=>validateEventMethodTag,validateEventPayloadTag:()=>validateEventPayloadTag,validateEventTimestamp:()=>validateEventTimestamp,validateEventUrlTag:()=>validateEventUrlTag,validateToken:()=>validateToken});var _authorizationScheme="Nostr ";async function getToken(e,t,n,r=!1,o){const s={kind:HTTPAuth,tags:[["u",e],["method",t]],created_at:Math.round((new Date).getTime()/1e3),content:""};o&&s.tags.push(["payload",hashPayload(o)]);const i=await n(s);return(r?_authorizationScheme:"")+base64$1.encode(utf8Encoder.encode(JSON.stringify(i)))}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)}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$1(sha256$2(utf8Encoder.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(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="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;
|
|
11
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function isBytes$1(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function anumber$1(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function abytes$1(e,...t){if(!isBytes$1(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$1(e.outputLen),anumber$1(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$1(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(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function rotr(e,t){return e<<32-t|e>>>t}const hasHexBuiltin=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),hexes=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function bytesToHex(e){if(abytes$1(e),hasHexBuiltin)return e.toHex();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);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,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(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function toBytes(e){return"string"==typeof e&&(e=utf8ToBytes(e)),abytes$1(e),e}function concatBytes(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];abytes$1(r),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{}function createHasher(e){const t=t=>e().update(toBytes(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function randomBytes(e=32){if(crypto&&"function"==typeof crypto.getRandomValues)return crypto.getRandomValues(new Uint8Array(e));if(crypto&&"function"==typeof crypto.randomBytes)return Uint8Array.from(crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}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=e.pubkey;return n?new Promise((e=>{let r=!1;const o=setTimeout((()=>{r||(s(),e(null))}),8e3),s=t.subscribeOnce({kinds:[0],authors:[n],limit:1},(t=>{if(!r){r=!0,clearTimeout(o),s();try{const n=JSON.parse(t.content);e(n)}catch{e(null)}}}))})):null},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=[];window.location.hostname&&i.push(["client",window.location.hostname]);const a=finalizeEvent({kind:0,created_at:Math.floor(Date.now()/1e3),tags:i,content:JSON.stringify(s)},hexToBytes(n.privateKey)),c=prepareSignupRelays(r).map((e=>["r",e])),l=finalizeEvent({kind:10002,created_at:Math.floor(Date.now()/1e3),tags:c,content:""},hexToBytes(n.privateKey));console.log("signed profile",a),console.log("signed relays",l);const d=o&&o.length?o:OUTBOX_RELAYS$1;try{await t.publishToRelays(a,d),console.log("published profile to outbox relays")}catch(e){console.warn("createProfile: failed to publish profile",e)}try{await t.publishToRelays(l,d),console.log("published relays to outbox relays")}catch(e){console.warn("createProfile: failed to publish relays event",e)}},bunkerUrlToInfo=(e,t="")=>{const n=new URL(e);return{pubkey:"",signerPubkey:n.hostname||n.pathname.split("//")[1],sk:t||bytesToHex(generateSecretKey()),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),c=await a.json(),l=c.names._,d=c.nip46[l],u=await fetch(i),h=(await u.json()).names[n];if(!d.length)throw new Error("Bunker relay not provided");return`bunker://${h}?relay=${d[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[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";var Ct$1=Object.defineProperty,jt$1=(e,t,n)=>t in e?Ct$1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t,n)=>(jt$1(e,"symbol"!=typeof t?t+"":t,n),n);class G extends Error{}let Pe$1=class extends G{constructor(e){super(`RxNostrWebSocketError: WebSocket was closed with code ${e} by relay.`),this.code=e,this.name="RxNostrWebSocketError"}};class B extends G{constructor(e){super(`RxNostrInvalidUsageError: ${e}`),this.name="RxNostrInvalidUsageError"}}let fe$1=class extends G{constructor(e){super(`RxNostrEnvironmentError: ${e}`),this.name="RxNostrEnvironmentError"}};class Oe extends G{constructor(){super("RxNostrLogicError: This is rx-nostr's internal bug. Please report to the author of the library."),this.name="RxNostrLogicError"}}let T$1=class extends G{constructor(){super("RxNostrAlreadyDisposedError: Attempted to access a disposed resource."),this.name="RxNostrAlreadyDisposedError"}};const P=(e,t)=>({...t,...e});function Dt$1(e){if("string"!=typeof e.id||"string"!=typeof e.sig||"number"!=typeof e.kind||"string"!=typeof e.pubkey||"string"!=typeof e.content||"number"!=typeof e.created_at||!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){const 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 he(e){throw e}function Nt$1(e){return{async signEvent(e){var t,n;const r={...e,pubkey:e.pubkey??await(null==(t=null==window?void 0:window.nostr)?void 0:t.getPublicKey())??he(new fe$1("window.nostr.getPublicKey() is not found")),tags:[...e.tags??[]],created_at:e.created_at??Math.floor(Date.now()/1e3)};return Dt$1(r)?r:await(null==(n=null==window?void 0:window.nostr)?void 0:n.signEvent(r))??he(new fe$1("window.nostr.signEvent() is not found"))},getPublicKey(){var e;return(null==(e=null==window?void 0:window.nostr)?void 0:e.getPublicKey())??he(new fe$1("window.nostr.getPublicKey() is not found"))}}}const qt$1=e=>P(e,{signer:Nt$1(),connectionStrategy:"lazy",retry:{strategy:"exponential",maxCount:5,initialDelay:1e3},disconnectTimeout:1e4,eoseTimeout:3e4,okTimeout:3e4,authTimeout:3e4,skipVerify:!1,skipValidateFilterMatching:!1,skipExpirationCheck:!1,skipFetchNip11:!1});function Ye$1(e){return"length"in e?e.map(_e$1):[_e$1(e)]}function _e$1(e){return{...e,since:e.since?Ce$1(e.since):void 0,until:e.until?Ce$1(e.until):void 0}}function Ce$1(e){return"number"==typeof e?e:e()}async function Lt(e){try{const t=new URL(e);return t.protocol=t.protocol.replace(/^ws(s?):/,"http$1:"),await(await fetch(t.toString(),{headers:{Accept:"application/nostr+json"}})).json()}catch{return{}}}function je$1(e,t){try{return e()}catch(e){return t instanceof Function?t(e):t}}function k(e){let t="";try{t=e.trim();const n=new URL(t);n.hash="",n.pathname=je$1((()=>decodeURI(n.pathname)),n.pathname),n.pathname=n.pathname.replace(/\/$/,""),n.hostname=n.hostname.replace(/\.$/,""),n.searchParams.sort(),n.search=je$1((()=>decodeURIComponent(n.search)),n.search);let r=n.toString();return n.search||(r=r.replace(/\/$/,"")),r}catch{return t}}class U extends Map{constructor(e){if(super(),e)for(const[t,n]of Object.entries(e))this.set(k(t),n)}get(e){return super.get(k(e))}getMany(e){const t=[];for(const n of new Set(e.map(k))){const e=this.get(n);void 0!==e&&t.push(e)}return t}set(e,t){return super.set(k(e),t)}has(e){return super.has(k(e))}delete(e){return super.delete(k(e))}toObject(){const e={};for(const[t,n]of this.entries())e[t]=n;return e}toKeys(){return[...super.keys()]}toValues(){return[...super.values()]}copy(){return new U(this.toObject())}}class te{static async getValue(e,t,n){if(null==n||!n.skipCache){const n=await this.cache.get(e);if(n)return t(n)}if(null==n||!n.skipFetch){const n=await this.fetch(e);if(n)return t(n)}return t(this.default)}static get(e){const t=this.cache.get(e);if(t&&!(t instanceof Promise))return t}static async fetch(e){const t=Lt(e);return this.cache.set(e,t),t.then((t=>{this.cache.set(e,t)})),t}static async getOrFetch(e){return this.cache.get(e)??this.fetch(e)}static set(e,t){this.cache.set(e,t)}static getDefault(){return this.default}static setDefault(e){this.default=e}static forget(e){this.cache.delete(e)}static forgetAll(){this.cache.clear()}}function Xe$1(e,t,n){return Array.isArray(t)?t.some((t=>Ue$1(e,t))):Ue$1(e,t)}function Ue$1(e,t,n){const{sinceInclusive:r,untilInclusive:o}=P({},{sinceInclusive:!0,untilInclusive:!0});if(t.ids&&t.ids.every((t=>!e.id.startsWith(t)))||t.kinds&&!t.kinds.includes(e.kind)||t.authors&&t.authors.every((t=>!e.pubkey.startsWith(t)))||t.since&&(r&&!(t.since<=e.created_at)||!r&&!(t.since<e.created_at))||t.until&&(o&&!(e.created_at<=t.until)||!o&&!(e.created_at<t.until)))return!1;for(const[n,r]of Object.entries(t)){if(!n.startsWith("#")||!Array.isArray(r))continue;const t=n.slice(1);if(!e.tags.find((([e,n])=>t===e&&r.includes(n))))return!1}return!0}function Je$1(e,t){const n=e.tags.find((e=>"expiration"===e[0]));if(!n)return!1;try{const e=Number(n[1]);return!!Number.isInteger(e)&&e<=(t??Math.floor(Date.now()/1e3))}catch{return!1}}h(te,"cache",new U),h(te,"default",{}),
|
|
12
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
13
|
+
new Uint8Array(new Uint32Array([287454020]).buffer)[0];var me$1=function(e,t){return me$1=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},me$1(e,t)};function _(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}me$1(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function Yt$1(e,t,n,r){return new(n||(n=Promise))((function(t,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function i(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){e.done?t(e.value):function(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(s,i)}a((r=r.apply(e,[])).next())}))}function Ze$1(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function F(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function D$1(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,s=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return i}function N(e,t,n){if(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))}function M(e){return this instanceof M?(this.v=e,this):new M(e)}function Qt$1(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),s=[];return r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r;function i(e){o[e]&&(r[e]=function(t){return new Promise((function(n,r){s.push([e,t,n,r])>1||a(e,t)}))})}function a(e,t){try{!function(e){e.value instanceof M?Promise.resolve(e.value.v).then(c,l):d(s[0][2],e)}(o[e](t))}catch(e){d(s[0][3],e)}}function c(e){a("next",e)}function l(e){a("throw",e)}function d(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Xt$1(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof F?F(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}}function w(e){return"function"==typeof e}function oe$1(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var de=oe$1((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function re$1(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var Q=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,n,r,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var i=F(s),a=i.next();!a.done;a=i.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}else s.remove(this);var c=this.initialTeardown;if(w(c))try{c()}catch(e){o=e instanceof de?e.errors:[e]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var d=F(l),u=d.next();!u.done;u=d.next()){var h=u.value;try{Me$1(h)}catch(e){o=o??[],e instanceof de?o=N(N([],D$1(o)),D$1(e.errors)):o.push(e)}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}}if(o)throw new de(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)Me$1(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&re$1(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&re$1(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),et$1=Q.EMPTY;function tt$1(e){return e instanceof Q||e&&"closed"in e&&w(e.remove)&&w(e.add)&&w(e.unsubscribe)}function Me$1(e){w(e)?e():e.unsubscribe()}var nt$1={Promise:void 0},we$1={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,N([e,t],D$1(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function rt(e){we$1.setTimeout((function(){throw e}))}function H$1(){}function ee(e){e()}var Re$1=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,tt$1(t)&&t.add(n)):n.destination=tn$1,n}return _(t,e),t.create=function(e,t,n){return new ie$1(e,t,n)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(Q),Zt=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){Z(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){Z(e)}else Z(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){Z(e)}},e}(),ie$1=function(e){function t(t,n,r){var o,s=e.call(this)||this;return o=w(t)||!t?{next:t??void 0,error:n??void 0,complete:r??void 0}:t,s.destination=new Zt(o),s}return _(t,e),t}(Re$1);function Z(e){rt(e)}function en$1(e){throw e}var tn$1={closed:!0,next:H$1,error:en$1,complete:H$1},$e$1="function"==typeof Symbol&&Symbol.observable||"@@observable";function C$1(e){return e}function V$1(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return it$1(e)}function it$1(e){return 0===e.length?C$1:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var R=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r=this,o=rn$1(e)?e:new ie$1(e,t,n);return ee((function(){var e=r,t=e.operator,n=e.source;o.add(t?t.call(o,n):n?r._subscribe(o):r._trySubscribe(o))})),o},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=Fe$1(t))((function(t,r){var o=new ie$1({next:function(t){try{e(t)}catch(e){r(e),o.unsubscribe()}},error:r,complete:t});n.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[$e$1]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return it$1(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=Fe$1(e))((function(e,n){var r;t.subscribe((function(e){return r=e}),(function(e){return n(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function Fe$1(e){var t;return null!==(t=e??nt$1.Promise)&&void 0!==t?t:Promise}function nn$1(e){return e&&w(e.next)&&w(e.error)&&w(e.complete)}function rn$1(e){return e&&e instanceof Re$1||nn$1(e)&&tt$1(e)}function sn$1(e){return w(null==e?void 0:e.lift)}function E(e){return function(t){if(sn$1(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}function m(e,t,n,r,o){return new st$1(e,t,n,r,o)}var st$1=function(e){function t(t,n,r,o,s,i){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=i,a._next=n?function(e){try{n(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return _(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(Re$1),on$1=oe$1((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),v=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return _(t,e),t.prototype.lift=function(e){var t=new Ve$1(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new on$1},t.prototype.next=function(e){var t=this;ee((function(){var n,r;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=F(t.currentObservers),s=o.next();!s.done;s=o.next()){s.value.next(e)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}}))},t.prototype.error=function(e){var t=this;ee((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}}))},t.prototype.complete=function(){var e=this;ee((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,o=n.isStopped,s=n.observers;return r||o?et$1:(this.currentObservers=null,s.push(e),new Q((function(){t.currentObservers=null,re$1(s,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,o=t.isStopped;n?e.error(r):o&&e.complete()},t.prototype.asObservable=function(){var e=new R;return e.source=this,e},t.create=function(e,t){return new Ve$1(e,t)},t}(R),Ve$1=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return _(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:et$1},t}(v),un$1=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return _(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){var e=this,t=e.hasError,n=e.thrownError,r=e._value;if(t)throw n;return this._throwIfClosed(),r},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(v),ot$1={now:function(){return Date.now()}},cn$1=function(e){function t(t,n){return e.call(this)||this}return _(t,e),t.prototype.schedule=function(e,t){return this},t}(Q),se$1={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=se$1.delegate;return null!=o&&o.setInterval?o.setInterval.apply(o,N([e,t],D$1(n))):setInterval.apply(void 0,N([e,t],D$1(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},an$1=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r.pending=!1,r}return _(t,e),t.prototype.schedule=function(e,t){var n;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var r=this.id,o=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(o,r,t)),this.pending=!0,this.delay=t,this.id=null!==(n=this.id)&&void 0!==n?n:this.requestAsyncId(o,this.id,t),this},t.prototype.requestAsyncId=function(e,t,n){return void 0===n&&(n=0),se$1.setInterval(e.flush.bind(e,this),n)},t.prototype.recycleAsyncId=function(e,t,n){if(void 0===n&&(n=0),null!=n&&this.delay===n&&!1===this.pending)return t;null!=t&&se$1.clearInterval(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(e,t);if(n)return n;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var n,r=!1;try{this.work(e)}catch(e){r=!0,n=e||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),n},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,n=this.scheduler,r=n.actions;this.work=this.state=this.scheduler=null,this.pending=!1,re$1(r,this),null!=t&&(this.id=this.recycleAsyncId(n,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(cn$1),We$1=function(){function e(t,n){void 0===n&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(e,t,n){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},e.now=ot$1.now,e}(),ln$1=function(e){function t(t,n){void 0===n&&(n=We$1.now);var r=e.call(this,t,n)||this;return r.actions=[],r._active=!1,r}return _(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var n;this._active=!0;do{if(n=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,n){for(;e=t.shift();)e.unsubscribe();throw n}}},t}(We$1),Ae$1=new ln$1(an$1),fn$1=Ae$1,X=new R((function(e){return e.complete()}));function ut(e){return e&&w(e.schedule)}function Ie$1(e){return e[e.length-1]}function hn$1(e){return w(Ie$1(e))?e.pop():void 0}function ue(e){return ut(Ie$1(e))?e.pop():void 0}function dn$1(e,t){return"number"==typeof Ie$1(e)?e.pop():t}var ct$1=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function at(e){return w(null==e?void 0:e.then)}function lt$1(e){return w(e[$e$1])}function ft(e){return Symbol.asyncIterator&&w(null==e?void 0:e[Symbol.asyncIterator])}function ht(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function yn$1(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}var dt$1=yn$1();function yt$1(e){return w(null==e?void 0:e[dt$1])}function bt$1(e){return Qt$1(this,arguments,(function(){var t,n,r;return Ze$1(this,(function(o){switch(o.label){case 0:t=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,M(t.read())];case 3:return n=o.sent(),r=n.value,n.done?[4,M(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,M(r)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}function pt$1(e){return w(null==e?void 0:e.getReader)}function $(e){if(e instanceof R)return e;if(null!=e){if(lt$1(e))return bn$1(e);if(ct$1(e))return pn$1(e);if(at(e))return vn$1(e);if(ft(e))return vt$1(e);if(yt$1(e))return gn$1(e);if(pt$1(e))return mn$1(e)}throw ht(e)}function bn$1(e){return new R((function(t){var n=e[$e$1]();if(w(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")}))}function pn$1(e){return new R((function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()}))}function vn$1(e){return new R((function(t){e.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,rt)}))}function gn$1(e){return new R((function(t){var n,r;try{for(var o=F(e),s=o.next();!s.done;s=o.next()){var i=s.value;if(t.next(i),t.closed)return}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}t.complete()}))}function vt$1(e){return new R((function(t){wn$1(e,t).catch((function(e){return t.error(e)}))}))}function mn$1(e){return vt$1(bt$1(e))}function wn$1(e,t){var n,r,o,s;return Yt$1(this,void 0,void 0,(function(){var i,a;return Ze$1(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),n=Xt$1(e),c.label=1;case 1:return[4,n.next()];case 2:if((r=c.sent()).done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),o={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))}))}function I(e,t,n,r,o){void 0===r&&(r=0),void 0===o&&(o=!1);var s=t.schedule((function(){n(),o?e.add(this.schedule(null,r)):this.unsubscribe()}),r);if(e.add(s),!o)return s}function gt(e,t){return void 0===t&&(t=0),E((function(n,r){n.subscribe(m(r,(function(n){return I(r,e,(function(){return r.next(n)}),t)}),(function(){return I(r,e,(function(){return r.complete()}),t)}),(function(n){return I(r,e,(function(){return r.error(n)}),t)})))}))}function mt$1(e,t){return void 0===t&&(t=0),E((function(n,r){r.add(e.schedule((function(){return n.subscribe(r)}),t))}))}function Sn$1(e,t){return $(e).pipe(mt$1(t),gt(t))}function En$1(e,t){return $(e).pipe(mt$1(t),gt(t))}function xn$1(e,t){return new R((function(n){var r=0;return t.schedule((function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())}))}))}function On(e,t){return new R((function(n){var r;return I(n,t,(function(){r=e[dt$1](),I(n,t,(function(){var e,t,o;try{t=(e=r.next()).value,o=e.done}catch(e){return void n.error(e)}o?n.complete():n.next(t)}),0,!0)})),function(){return w(null==r?void 0:r.return)&&r.return()}}))}function wt$1(e,t){if(!e)throw new Error("Iterable cannot be null");return new R((function(n){I(n,t,(function(){var r=e[Symbol.asyncIterator]();I(n,t,(function(){r.next().then((function(e){e.done?n.complete():n.next(e.value)}))}),0,!0)}))}))}function Rn(e,t){return wt$1(bt$1(e),t)}function $n$1(e,t){if(null!=e){if(lt$1(e))return Sn$1(e,t);if(ct$1(e))return xn$1(e,t);if(at(e))return En$1(e,t);if(ft(e))return wt$1(e,t);if(yt$1(e))return On(e,t);if(pt$1(e))return Rn(e,t)}throw ht(e)}function j(e,t){return t?$n$1(e,t):$(e)}function ce$1(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return j(e,ue(e))}var Te=oe$1((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function St(e,t){return new Promise((function(t,n){var r=new ie$1({next:function(e){t(e),r.unsubscribe()},error:n,complete:function(){n(new Te)}});e.subscribe(r)}))}function Et(e){return e instanceof Date&&!isNaN(e)}var xt$1=oe$1((function(e){return function(t){void 0===t&&(t=null),e(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=t}}));function Ot$1(e,t){var n=Et(e)?{first:e}:"number"==typeof e?{each:e}:e,r=n.first,o=n.each,s=n.with,i=void 0===s?An$1:s,a=n.scheduler,c=void 0===a?Ae$1:a,l=n.meta,d=void 0===l?null:l;if(null==r&&null==o)throw new TypeError("No timeout provided.");return E((function(e,t){var n,s,a=null,l=0,u=function(e){s=I(t,c,(function(){try{n.unsubscribe(),$(i({meta:d,lastValue:a,seen:l})).subscribe(t)}catch(e){t.error(e)}}),e)};n=e.subscribe(m(t,(function(e){null==s||s.unsubscribe(),l++,t.next(a=e),o>0&&u(o)}),void 0,void 0,(function(){null!=s&&s.closed||null==s||s.unsubscribe(),a=null}))),!l&&u(null!=r?"number"==typeof r?r:+r-c.now():o)}))}function An$1(e){throw new xt$1(e)}function A(e,t){return E((function(n,r){var o=0;n.subscribe(m(r,(function(n){r.next(e.call(t,n,o++))})))}))}var In$1=Array.isArray;function Tn(e,t){return In$1(t)?e.apply(void 0,N([],D$1(t))):e(t)}function kn$1(e){return A((function(t){return Tn(e,t)}))}var Pn$1=Array.isArray,_n$1=Object.getPrototypeOf,Cn$1=Object.prototype,jn=Object.keys;function Dn(e){if(1===e.length){var t=e[0];if(Pn$1(t))return{args:t,keys:null};if(Nn$1(t)){var n=jn(t);return{args:n.map((function(e){return t[e]})),keys:n}}}return{args:e,keys:null}}function Nn$1(e){return e&&"object"==typeof e&&_n$1(e)===Cn$1}function qn(e,t){return e.reduce((function(e,n,r){return e[n]=t[r],e}),{})}function Ln(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=ue(e),r=hn$1(e),o=Dn(e),s=o.args,i=o.keys;if(0===s.length)return j([],n);var a=new R(Un(s,n,i?function(e){return qn(i,e)}:C$1));return r?a.pipe(kn$1(r)):a}function Un(e,t,n){return void 0===n&&(n=C$1),function(r){ze$1(t,(function(){for(var o=e.length,s=new Array(o),i=o,a=o,c=function(o){ze$1(t,(function(){var c=j(e[o],t),l=!1;c.subscribe(m(r,(function(e){s[o]=e,l||(l=!0,a--),a||r.next(n(s.slice()))}),(function(){--i||r.complete()})))}),r)},l=0;l<o;l++)c(l)}),r)}}function ze$1(e,t,n){e?I(n,e,t):t()}function Mn(e,t,n,r,o,s,i,a){var c=[],l=0,d=0,u=!1,h=function(){u&&!c.length&&!l&&t.complete()},f=function(e){l++;var o=!1;$(n(e,d++)).subscribe(m(t,(function(e){t.next(e)}),(function(){o=!0}),void 0,(function(){if(o)try{l--;for(var e=function(){var e=c.shift();i?I(t,i,(function(){return f(e)})):f(e)};c.length&&l<r;)e();h()}catch(e){t.error(e)}})))};return e.subscribe(m(t,(function(e){return l<r?f(e):c.push(e)}),(function(){u=!0,h()}))),function(){}}function q$1(e,t,n){return void 0===n&&(n=1/0),w(t)?q$1((function(n,r){return A((function(e,o){return t(n,e,r,o)}))($(e(n,r)))}),n):("number"==typeof t&&(n=t),E((function(t,r){return Mn(t,r,e,n)})))}function ae$1(e){return void 0===e&&(e=1/0),q$1(C$1,e)}function Se$1(e,t,n){return void 0===e&&(e=0),void 0===n&&(n=fn$1),new R((function(t){var r=Et(e)?+e-n.now():e;r<0&&(r=0);var o=0;return n.schedule((function(){t.closed||(t.next(o++),t.complete())}),r)}))}function Wn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=ue(e),r=dn$1(e,1/0),o=e;return o.length?1===o.length?$(o[0]):ae$1(r)(j(o,n)):X}function S(e,t){return E((function(n,r){var o=0;n.subscribe(m(r,(function(n){return e.call(t,n,o++)&&r.next(n)})))}))}function Rt$1(e){return E((function(t,n){var r,o=null,s=!1;o=t.subscribe(m(n,void 0,void 0,(function(i){r=$(e(i,Rt$1(e)(t))),o?(o.unsubscribe(),o=null,r.subscribe(n)):s=!0}))),s&&(o.unsubscribe(),o=null,r.subscribe(n))}))}function Kn(e){return E((function(t,n){var r=!1;t.subscribe(m(n,(function(e){r=!0,n.next(e)}),(function(){r||n.next(e),n.complete()})))}))}function Ee$1(e){return e<=0?function(){return X}:E((function(t,n){var r=0;t.subscribe(m(n,(function(t){++r<=e&&(n.next(t),e<=r&&n.complete())})))}))}function At$1(e,t){return void 0===t&&(t=C$1),e=e??Qn,E((function(n,r){var o,s=!0;n.subscribe(m(r,(function(n){var i=t(n);(s||!e(o,i))&&(s=!1,o=i,r.next(n))})))}))}function Qn(e,t){return e===t}function Xn(e){return void 0===e&&(e=Jn),E((function(t,n){var r=!1;t.subscribe(m(n,(function(e){r=!0,n.next(e)}),(function(){return r?n.complete():n.error(e())})))}))}function Jn(){return new Te}function be$1(e){return E((function(t,n){try{t.subscribe(n)}finally{n.add(e)}}))}function xe$1(e,t){var n=arguments.length>=2;return function(r){return r.pipe(e?S((function(t,n){return e(t,n,r)})):C$1,Ee$1(1),n?Kn(t):Xn((function(){return new Te})))}}function er(e,t){return E((function(n,r){var o=null,s=0,i=!1,a=function(){return i&&!o&&r.complete()};n.subscribe(m(r,(function(n){null==o||o.unsubscribe();var i=0,c=s++;$(e(n,c)).subscribe(o=m(r,(function(e){return r.next(t?t(n,e,c,i++):e)}),(function(){o=null,a()})))}),(function(){i=!0,a()})))}))}function tr(){return er(C$1)}function z$1(e){return E((function(t,n){$(e).subscribe(m(n,(function(){return n.complete()}),H$1)),!n.closed&&t.subscribe(n)}))}function nr(e,t){return E((function(n,r){var o=0;n.subscribe(m(r,(function(n){var s=e(n,o++);(s||t)&&r.next(n),!s&&r.complete()})))}))}function K$1(e,t,n){var r=w(e)||t||n?{next:e,error:t,complete:n}:e;return r?E((function(e,t){var n;null===(n=r.subscribe)||void 0===n||n.call(r);var o=!0;e.subscribe(m(t,(function(e){var n;null===(n=r.next)||void 0===n||n.call(r,e),t.next(e)}),(function(){var e;o=!1,null===(e=r.complete)||void 0===e||e.call(r),t.complete()}),(function(e){var n;o=!1,null===(n=r.error)||void 0===n||n.call(r,e),t.error(e)}),(function(){var e,t;o&&(null===(e=r.unsubscribe)||void 0===e||e.call(r)),null===(t=r.finalize)||void 0===t||t.call(r)})))})):C$1}function Tt$1(e){return q$1(((t,n)=>j(e(t,n)).pipe(q$1((e=>e?ce$1(t):X)))))}function Ke$1(e){return V$1(Ot$1(e),Rt$1((e=>{if(e instanceof xt$1)return X;throw e})))}function pe$1(e,t){const{not:n}=P(t,{not:!1});return S((t=>J(t.subId===e,n)))}function J(e,t){return!e&&t||e&&!t}class cr{constructor(e){h(this,"relay"),h(this,"config"),h(this,"authenticator"),h(this,"ongoings",new Set),h(this,"authResult$",new v),h(this,"disposed",!1),this.relay=e.relay,this.config=e.config,this.authenticator=e.authenticator;const t=this.relay.getOKObservable().subscribe((e=>{const{eventId:r,ok:o}=e;this.ongoings.has(r)&&(this.ongoings.delete(r),this.authResult$.next(o),o||(t.unsubscribe(),n.unsubscribe()))})),n=this.relay.getAUTHObservable().subscribe((({challenge:e})=>{this.challenge(e)}))}getAuthResultObservable(){return this.authResult$.asObservable()}async challenge(e){try{const t=await this.signer.signEvent({kind:22242,content:"",tags:[["relay",this.relay.url],["challenge",e]]});this.ongoings.add(t.id),this.relay.send(["AUTH",t])}catch{this.authResult$.next(!1)}}get signer(){return this.authenticator.signer??this.config.signer}dispose(){this[Symbol.dispose]()}[Symbol.dispose](){if(this.disposed)return;this.disposed=!0;const e=[this.authResult$];for(const t of e)t.complete()}}let kt$1=class extends un$1{constructor(e){super(e??0)}increment(){this.next(this.getValue()+1)}decrement(){this.next(this.getValue()-1)}next(e){"number"==typeof e?super.next(e):super.next(e(this.getValue()))}};class ar extends v{waitNext(){return St(this.pipe(xe$1(null,void 0)))}}class lr{constructor(e){var t;h(this,"relay"),h(this,"authProxy"),h(this,"pubs",new Map),h(this,"authRequiredPubs",new Set),h(this,"count$",new kt$1(0)),h(this,"ok$",new v),h(this,"disposed",!1),this.relay=e.relay,this.authProxy=e.authProxy,this.relay.getReconnectedObservable().subscribe((e=>{for(const[t,n]of e)"EVENT"===t&&this.pubs.has(n.id)&&this.sendEVENT(n)})),this.relay.getOKObservable().subscribe((async e=>{const{eventId:t,notice:n}=e;this.pubs.get(t)&&(this.authProxy&&null!=n&&n.startsWith("auth-required:")?(this.authRequiredPubs.add(t),this.ok$.next({...e,done:!1})):(this.ok$.next({...e,done:!0}),this.confirmOK(t)))})),null==(t=this.authProxy)||t.getAuthResultObservable().subscribe((e=>{if(e)for(const e of this.authRequiredPubs){const t=this.pubs.get(e);t&&this.sendEVENT(t)}else for(const e of this.authRequiredPubs)this.confirmOK(e);this.authRequiredPubs.clear()}))}async publish(e){if(!this.disposed)return this.pubs.has(e.id)||(this.pubs.set(e.id,e),this.count$.increment()),this.sendEVENT(e)}confirmOK(e){this.disposed||this.pubs.has(e)||(this.pubs.delete(e),this.count$.decrement())}getOkAgainstEventObservable(){return this.ok$.asObservable()}getLogicalConnectionSizeObservable(){return this.count$.asObservable()}dispose(){this[Symbol.dispose]()}[Symbol.dispose](){if(this.disposed)return;this.disposed=!0;const e=[this.count$,this.ok$];for(const t of e)t.complete()}sendEVENT(e){return this.relay.send(["EVENT",e])}}const Be$1={OPEN:1};class fr{constructor(e,t){h(this,"socket",null),h(this,"buffer",[]),h(this,"unsent",[]),h(this,"reconnected$",new v),h(this,"outgoing$",new v),h(this,"message$",new v),h(this,"error$",new v),h(this,"retryTimer",null),h(this,"sendAttempted$",new ar),h(this,"isFirstTry",!0),h(this,"maybeDown",!1),h(this,"disposed",!1),h(this,"state$",new v),h(this,"_state","initialized"),this.url=e,this.config=t,t.skipFetchNip11||te.getOrFetch(e),this.setState("initialized")}get state(){return this._state}setState(e){this._state=e,this.state$.next(e)}connectManually(){this.connect()}connect(e){if("terminated"===this.state)return;const t="number"==typeof e;("initialized"===this.state||"dormant"===this.state||"error"===this.state||"rejected"===this.state||t)&&(this.socket=this.createSocket(e??0))}createSocket(e){const t=this.isFirstTry;this.isFirstTry=!1;let n=!1;const r=e>0,o=!r&&("error"===this.state||"rejected"===this.state);r?this.setState("retrying"):this.setState("connecting");const s=async()=>{if("terminated"!==this.state){this.setState("connected"),n=!0,e=0,(r||o)&&(this.reconnected$.next(this.unsent),this.unsent=[]);try{for(const e of this.buffer)this.send(e)}catch(e){this.error$.next(e)}finally{this.buffer=[]}}else null==l||l.close(L.RX_NOSTR_DISPOSED)},i=({data:e})=>{if("terminated"!==this.state)try{this.message$.next(this.pack(JSON.parse(e)))}catch(e){this.error$.next(e)}},a=({code:r})=>{var o;if(null==l||l.removeEventListener("open",s),null==l||l.removeEventListener("message",i),null==l||l.removeEventListener("close",a),this.socket===l&&(this.socket=null),"terminated"===this.state||r===L.RX_NOSTR_DISPOSED)return this.unsent=[],void(this.buffer=[]);if(r===L.RX_NOSTR_IDLE)this.setState("dormant"),this.buffer.length>0&&this.connect();else if(r===L.DONT_RETRY)this.unsent=[],this.buffer=[],this.error$.next(new Pe$1(r)),this.setState("rejected");else{t&&!n&&(this.maybeDown=!0),this.unsent.push(...this.buffer),this.buffer=[],this.error$.next(new Pe$1(r));const s=e+1;"off"===this.config.retry.strategy||this.config.retry.polite&&this.maybeDown||!(s<=this.config.retry.maxCount)?this.setState("error"):(this.setState("waiting-for-retrying"),null==(o=this.retryTimer)||o.unsubscribe(),this.retryTimer=hr(this.config.retry,s).subscribe((()=>{this.disposed||this.connect(s)})))}},c=this.config.websocketCtor??globalThis.WebSocket;if(!c)throw new B("WebSocket constructor is missing");const l=(()=>{try{return new c(this.url)}catch(e){return a({code:0}),null}})();return null==l||l.addEventListener("open",s),null==l||l.addEventListener("message",i),null==l||l.addEventListener("close",a),l}pack(e){const t=e[0],n=this.url;switch(t){case"EVENT":return{from:n,type:t,message:e,subId:e[1],event:e[2]};case"EOSE":return{from:n,type:t,message:e,subId:e[1]};case"OK":return{from:n,type:t,message:e,eventId:e[1],ok:e[2],notice:e[3]};case"CLOSED":return{from:n,type:t,message:e,subId:e[1],notice:e[2]};case"NOTICE":return{from:n,type:t,message:e,notice:e[1]};case"AUTH":return{from:n,type:t,message:e,challenge:e[1]};case"COUNT":return{from:n,type:t,message:e,subId:e[1],count:e[2]};default:return{from:n,type:"unknown",message:e}}}disconnect(e){var t;(null==(t=this.socket)?void 0:t.readyState)===Be$1.OPEN&&this.socket.close(e)}send(e){const t=this.sendAttempted$.waitNext();switch(this.state){case"terminated":case"rejected":return this.sendAttempted$.next(),t;case"initialized":case"connecting":case"dormant":return this.buffer.push(e),this.connect(),t;case"connected":if(!this.socket)throw new Oe;return this.socket.readyState===Be$1.OPEN?(this.outgoing$.next({to:this.url,message:e}),this.socket.send(JSON.stringify(e)),this.sendAttempted$.next(),t):(this.buffer.push(e),t);case"waiting-for-retrying":case"retrying":case"error":return this.sendAttempted$.next(),this.unsent.push(e),t}}getEVENTObservable(){return this.message$.pipe(S((e=>"EVENT"===e.type)))}getEOSEObservable(){return this.message$.pipe(S((e=>"EOSE"===e.type)))}getCLOSEDObservable(){return this.message$.pipe(S((e=>"CLOSED"===e.type)))}getOKObservable(){return this.message$.pipe(S((e=>"OK"===e.type)))}getAUTHObservable(){return this.message$.pipe(S((e=>"AUTH"===e.type)))}getAllMessageObservable(){return this.message$.asObservable()}getOutgoingMessageObservable(){return this.outgoing$.asObservable()}getReconnectedObservable(){return this.reconnected$.asObservable()}getConnectionStateObservable(){return this.state$.pipe(At$1(),A((e=>({from:this.url,state:e}))))}getErrorObservable(){return this.error$.asObservable()}dispose(){this[Symbol.dispose]()}[Symbol.dispose](){var e,t;if(this.disposed)return;this.disposed=!0,this.setState("terminated"),null==(e=this.retryTimer)||e.unsubscribe(),null==(t=this.socket)||t.close(L.RX_NOSTR_DISPOSED),this.socket=null;const n=[this.state$,this.outgoing$,this.message$,this.error$,this.reconnected$,this.sendAttempted$];for(const e of n)e.complete()}}function hr(e,t){switch(e.strategy){case"exponential":return Se$1(Math.max(e.initialDelay*2**(t-1)+1e3*(Math.random()-.5),1e3));case"immediately":return ce$1(0);case"linear":return Se$1(e.interval);case"off":return X}}const L={DONT_RETRY:4e3,RX_NOSTR_IDLE:4537,RX_NOSTR_DISPOSED:4538};class dr{constructor(e){var t;h(this,"relay"),h(this,"authProxy"),h(this,"config"),h(this,"subs",new Map),h(this,"authRequiredSubs",new Set),h(this,"fin$",new v),h(this,"disposed",!1),h(this,"queue"),this.relay=e.relay,this.authProxy=e.authProxy,this.config=e.config,this.queue=new yr(this.relay.url,this.config),this.queue.getActivationObservable().subscribe((e=>{for(const{req:t}of e)this.sendREQ(t)})),this.relay.getReconnectedObservable().subscribe((()=>{for(const{req:e}of this.queue.ongoings)this.sendREQ(e)})),this.relay.getEOSEObservable().subscribe((({subId:e})=>{var t;null!=(t=this.subs.get(e))&&t.autoclose&&this.unsubscribe(e)})),this.relay.getCLOSEDObservable().subscribe((async({subId:e,notice:t})=>{this.subs.get(e)&&(this.authProxy&&null!=t&&t.startsWith("auth-required:")?this.authRequiredSubs.add(e):this.fin(e))})),null==(t=this.authProxy)||t.getAuthResultObservable().subscribe((e=>{var t;if(e)for(const e of this.authRequiredSubs){const n=null==(t=this.subs.get(e))?void 0:t.req;n&&this.sendREQ(n)}else for(const e of this.authRequiredSubs)this.fin(e);this.authRequiredSubs.clear()}))}subscribe(e,t){if(this.disposed)return;const n=e[1],r={subId:n,req:e,autoclose:t};this.subs.set(n,r),this.queue.enqueue(r)}unsubscribe(e){this.disposed||(this.subs.has(e)&&this.sendCLOSE(e),this.fin(e))}isOngoingOrQueued(e){return this.subs.has(e)}getEventObservable(){return this.relay.getEVENTObservable().pipe(S((({subId:e,event:t})=>{var n;const r=null==(n=this.subs.get(e))?void 0:n.filters;return!!r&&(this.config.skipValidateFilterMatching||Xe$1(t,r))})))}getFinObservable(){return this.fin$.asObservable()}getLogicalConnectionSizeObservable(){return this.queue.getSizeObservable()}dispose(){this[Symbol.dispose]()}[Symbol.dispose](){if(this.disposed)return;this.disposed=!0;const e=[this.fin$];for(const t of e)t.complete();this.queue.dispose()}sendREQ([,e,...t]){const n=Ye$1(t),r=this.subs.get(e);r&&(r.filters=n,this.relay.send(["REQ",e,...n]))}sendCLOSE(e){this.relay.send(["CLOSE",e])}fin(e){this.subs.delete(e),this.queue.drop(e),this.fin$.next({from:this.relay.url,subId:e})}}class yr{constructor(e,t){h(this,"_queuings",[]),h(this,"_ongoings",[]),h(this,"activated$",new v),h(this,"count$",new kt$1),this.url=e,this.config=t}get queuings(){return this._queuings}set queuings(e){this._queuings=e}get ongoings(){return this._ongoings}set ongoings(e){this._ongoings=e}enqueue(e){this.queuings=[...this.queuings,e],this.count$.increment(),this.shift()}drop(e){const t=(e,t)=>{const n=e.length,r=e.filter((e=>e.subId!==t));return[r,n-r.length]},[n,r]=t(this.queuings,e),[o,s]=t(this.ongoings,e);this.queuings=n,this.ongoings=o,this.count$.next((e=>e-(r+s))),this.shift()}getActivationObservable(){return this.activated$.asObservable()}getSizeObservable(){return this.count$.asObservable()}dispose(){const e=[this.activated$,this.count$];for(const t of e)t.complete()}async shift(){const e=await this.capacity(),t=[...this.ongoings,...this.queuings],n=t.slice(0,e),r=t.slice(e),o=this.queuings.slice(0,e-this.ongoings.length);this.ongoings=n,this.queuings=r,o.length>0&&this.activated$.next(o)}async capacity(){return await te.getValue(this.url,(e=>{var t;return null==(t=e.limitation)?void 0:t.max_subscriptions}),{skipFetch:this.config.skipFetchNip11})??1/0}}class br{constructor(e,t){h(this,"relay"),h(this,"pubProxy"),h(this,"subProxy"),h(this,"defaultSubscriptionIds",new Set),h(this,"communicating",!1),h(this,"strategy","lazy"),h(this,"disconnectTimeout"),h(this,"disconnectTimer"),h(this,"isDefaultRelay",!1),h(this,"disposed",!1),h(this,"_url"),this._url=k(e);const n=pr(e,t),r=new fr(this.url,t),o=n?new cr({relay:r,config:t,authenticator:n}):null,s=new lr({relay:r,authProxy:o}),i=new dr({relay:r,authProxy:o,config:t});this.relay=r,this.pubProxy=s,this.subProxy=i,this.disconnectTimeout=t.disconnectTimeout,Ln([this.pubProxy.getLogicalConnectionSizeObservable(),this.subProxy.getLogicalConnectionSizeObservable()]).pipe(A((([e,t])=>e+t))).subscribe((e=>{this.communicating=e>0,this.resetConnection()}))}get url(){return this._url}setConnectionStrategy(e){this.disposed||(this.strategy=e,this.resetConnection())}resetConnection(){let e=this.strategy;switch(this.isDefaultRelay||(e="lazy"),e){case"lazy":{const e=()=>{this.communicating||this.relay.disconnect(L.RX_NOSTR_IDLE)};this.disconnectTimeout>0?(this.disconnectTimeout&&(clearTimeout(this.disconnectTimer),this.disconnectTimer=void 0),this.disconnectTimer=setTimeout(e,this.disconnectTimeout)):e();break}case"lazy-keep":break;case"aggressive":("initialized"===this.connectionState||"dormant"===this.connectionState)&&this.relay.connectManually()}}markAsDefault(e){if(!this.disposed){if(this.isDefaultRelay=e,!this.isDefaultRelay){for(const e of this.defaultSubscriptionIds)this.subProxy.unsubscribe(e);this.defaultSubscriptionIds.clear()}this.resetConnection()}}async publish(e){if(!this.disposed)return this.pubProxy.publish(e)}confirmOK(e){this.disposed||this.pubProxy.confirmOK(e)}subscribe(e,t){if(this.disposed)return;const{mode:n,overwrite:r,autoclose:o}=P(t??{},{overwrite:!1,autoclose:!1,mode:"default"}),[,s]=e;"default"===n&&!this.isDefaultRelay||!r&&this.subProxy.isOngoingOrQueued(s)||("default"===n&&this.defaultSubscriptionIds.add(s),this.subProxy.subscribe(e,o))}unsubscribe(e){this.disposed||(this.defaultSubscriptionIds.delete(e),this.subProxy.unsubscribe(e))}getEventObservable(){if(this.disposed)throw new T$1;return this.subProxy.getEventObservable()}getFinObservable(){if(this.disposed)throw new T$1;return this.subProxy.getFinObservable()}getOkAgainstEventObservable(){if(this.disposed)throw new T$1;return this.pubProxy.getOkAgainstEventObservable()}getAllMessageObservable(){if(this.disposed)throw new T$1;return this.relay.getAllMessageObservable()}getOutgoingMessageObservable(){if(this.disposed)throw new T$1;return this.relay.getOutgoingMessageObservable()}getConnectionStateObservable(){if(this.disposed)throw new T$1;return this.relay.getConnectionStateObservable()}get connectionState(){return this.relay.state}getErrorObservable(){if(this.disposed)throw new T$1;return this.relay.getErrorObservable().pipe(A((e=>({from:this.url,reason:e}))))}connectManually(){this.relay.connectManually()}dispose(){this[Symbol.dispose]()}[Symbol.dispose](){this.disposed||(this.disposed=!0,this.disconnectTimer&&clearTimeout(this.disconnectTimer),this.disconnectTimer=void 0,this.relay.dispose(),this.pubProxy.dispose(),this.subProxy.dispose())}}function pr(e,t){const n=t.authenticator;if(!n)return;const r=n instanceof Function?n(e):n;return"auto"===r?{}:r}function vr(e,t){return e.filter((e=>!t.includes(e)))}function gr(e){const{rxReq:t,index:n}=e,{rxReqId:r,strategy:o}=t;return`${r}:${"backward"===o?n:0}`}function mr(e){const{rxReq:t,filters:n,index:r}=e;return["REQ",gr({rxReq:t,index:r}),...n]}function He$1(e){if(Array.isArray(e)){const t=e.map((e=>{let t="",n=!1,r=!1;if("string"==typeof e)t=e,n=!0,r=!0;else if(Array.isArray(e)){const o=e[2];t=e[1],n=!o||"read"===o,r=!o||"write"===o}else t=e.url,n=e.read,r=e.write;return{url:t,read:n,write:r}}));return Object.fromEntries(t.map((e=>[e.url,e])))}{const t=Object.entries(e).map((([e,t])=>({url:e,...t})));return Object.fromEntries(t.map((e=>[e.url,e])))}}function Ge$1(e,t){const n=new Set;if(null!=t&&t.on){const r=t.on;if(!r.defaultReadRelays&&!r.defaultWriteRelays&&!r.relays)return;const o=e.getDefaultRelays();if(r.defaultReadRelays)for(const{url:e}of Object.values(o).filter((e=>e.read)))n.add(e);if(r.defaultWriteRelays)for(const{url:e}of Object.values(o).filter((e=>e.write)))n.add(e);if(r.relays)for(const e of r.relays)n.add(k(e));return[...n]}if(null!=t&&t.relays){for(const e of t.relays)n.add(k(e));return[...n]}}function Wr(e){return new wr(qt$1(e??{}))}class wr{constructor(e){h(this,"connections",new U),h(this,"defaultRelays",new U),h(this,"defaultSubscriptions",new Map),h(this,"event$",new v),h(this,"fin$",new v),h(this,"ok$",new v),h(this,"all$",new v),h(this,"error$",new v),h(this,"connectionState$",new v),h(this,"outgoing$",new v),h(this,"dispose$",new v),h(this,"disposed",!1),this.config=e}get defaultReadableConnections(){const e=[];for(const{url:t,read:n}of this.defaultRelays.values()){const r=this.connections.get(t);n&&r&&e.push(r)}return e}get defaultWritableConnections(){const e=[];for(const{url:t,write:n}of this.defaultRelays.values()){const r=this.connections.get(t);n&&r&&e.push(r)}return e}getDefaultRelays(){if(this.disposed)throw new T$1;return this.defaultRelays.toObject()}getDefaultRelay(e){return this.defaultRelays.get(e)}setDefaultRelays(e){if(this.disposed)throw new T$1;const t=new U(He$1(e)),n=[];for(const{read:e,url:r}of t.values()){const t=this.ensureNostrConnection(r);t.setConnectionStrategy(this.config.connectionStrategy),e&&n.push(t)}this.updateDefaultSubscriptions(n),this.defaultRelays=t}ensureNostrConnection(e){let t=this.connections.get(e);return t||(t=new br(e,this.config),this.attachNostrConnection(t),this.connections.set(e,t),t)}attachNostrConnection(e){e.getEventObservable().subscribe(this.event$),e.getFinObservable().subscribe(this.fin$),e.getOkAgainstEventObservable().subscribe(this.ok$),e.getAllMessageObservable().subscribe(this.all$),e.getConnectionStateObservable().subscribe(this.connectionState$),e.getErrorObservable().subscribe(this.error$),e.getOutgoingMessageObservable().subscribe(this.outgoing$)}updateDefaultSubscriptions(e){const t=vr(this.defaultReadableConnections,e);for(const e of t)e.markAsDefault(!1);for(const t of e){t.markAsDefault(!0);for(const{req:e,autoclose:n}of this.defaultSubscriptions.values())null==t||t.subscribe(e,{mode:"default",overwrite:!1,autoclose:n})}}addDefaultRelays(e){const t=He$1(e);this.setDefaultRelays({...this.defaultRelays.toObject(),...t})}removeDefaultRelays(e){const t=this.defaultRelays.copy(),n=Array.isArray(e)?e:[e];for(const e of n)t.delete(e);this.setDefaultRelays(t.toObject())}getAllRelayStatus(){return Object.fromEntries(Array.from(this.connections.values()).map((e=>[e.url,{connection:e.connectionState}])))}getRelayStatus(e){const t=this.connections.get(e);if(t)return{connection:t.connectionState}}reconnect(e){const t=this.getDefaultRelay(e);if(!t)throw new B(`The relay (${e}) is not a default relay. \`reconnect()\` can be used only for a readable default relay.`);if(!t.read)throw new B(`The relay (${e}) is not readable. \`reconnect()\` can be used only for a readable default relay.`);const n=this.connections.get(e);if(!n)throw new Oe;("error"===n.connectionState||"rejected"===n.connectionState)&&n.connectManually()}use(e,t){const n=Ge$1(this,t),r=({req:t,targetConnections:n,mode:r})=>{this.startSubscription({req:t,targetConnections:n,mode:r,overwrite:"forward"===e.strategy,autoclose:"backward"===e.strategy})},o=({subId:e,targetConnections:t,mode:n})=>{this.teardownSubscription({subId:e,targetConnections:t,mode:n})},s=({req:t,targetConnections:n})=>"forward"===e.strategy?this.createForwardEventObservable({req:t}).pipe(z$1(this.dispose$)):this.createBackwardEventObservable({req:t,targetConnections:n}).pipe(z$1(this.dispose$)),i=e.getReqPacketObservable().pipe(S((({filters:e})=>e.length>0)),A((({filters:t,relays:r},o)=>{var s;const i="backward"===e.strategy?r:void 0,a=mr({rxReq:e,filters:t,index:o});return{subId:a[1],req:a,targetConnections:(null==(s=i??n)?void 0:s.map((e=>this.ensureNostrConnection(e))))??this.defaultReadableConnections,mode:void 0===i&&void 0===n?"default":"temporary"}})),z$1(this.dispose$)),a=()=>Tt$1((async({event:e})=>(this.config.skipVerify||await this.config.verifier(e))&&(this.config.skipExpirationCheck||!Je$1(e))));if("forward"===e.strategy){let e;return i.pipe(K$1((t=>{e=t})),K$1(r),A(s),be$1((()=>{e&&o(e)})),tr(),a())}return i.pipe(K$1(r),A((e=>s(e).pipe(be$1((()=>{o(e)}))))),ae$1(),a())}createForwardEventObservable(e){const{req:t}=e,n=t[1];return this.event$.pipe(pe$1(n))}createBackwardEventObservable(e){const{req:t,targetConnections:n}=e,r=t[1],o=new Set,s=Wn(this.fin$.pipe(pe$1(r),K$1((({from:e})=>{o.add(e)}))),this.connectionState$.asObservable()).pipe(S((()=>n.every((({connectionState:e,url:t})=>(e=>"error"===e||"rejected"===e||"terminated"===e)(e)||o.has(t))))),xe$1(null,void 0));return this.event$.pipe(z$1(s),Ke$1(this.config.eoseTimeout),pe$1(r),S((e=>!o.has(e.from))))}startSubscription(e){const{req:t,targetConnections:n,mode:r,overwrite:o,autoclose:s}=e,i=t[1];"default"===r&&this.defaultSubscriptions.set(i,{req:t,autoclose:s});for(const e of n)e.subscribe(t,{mode:r,overwrite:o,autoclose:s})}teardownSubscription(e){const{subId:t,targetConnections:n,mode:r}=e;"default"===r&&this.defaultSubscriptions.delete(t);for(const e of n)e.unsubscribe(t)}createAllEventObservable(){return this.event$.asObservable()}createAllErrorObservable(){return this.error$.asObservable()}createAllMessageObservable(){return this.all$.asObservable()}createConnectionStateObservable(){return this.connectionState$.asObservable()}createOutgoingMessageObservable(){return this.outgoing$.asObservable()}send(e,t){const{signer:n,errorOnTimeout:r,completeOn:o}=P(t??{},{signer:this.config.signer,errorOnTimeout:!1,completeOn:"all-ok"}),s=Ge$1(this,t),i=void 0===s?this.defaultWritableConnections:s.map((e=>this.ensureNostrConnection(e))),a=new v,c=new Set;let l="";const d=()=>{a.closed||a.complete();for(const e of i)e.confirmOK(l)};n.signEvent(e).then((async e=>{a.closed||(l=e.id,this.ok$.pipe(S((({eventId:t})=>t===e.id))).subscribe(a),await Promise.all(i.map((t=>t.publish(e)))),"sent"===o&&a.complete())})).catch((e=>{throw d(),new B(e instanceof Error?e.message:"Failed to sign the given event")}));const u=(()=>{switch(o){case"sent":return C$1;case"all-ok":return nr((({from:e,done:t})=>(t&&c.add(e),c.size<i.length)),!0);case"any-ok":return xe$1((e=>e.ok))}})();return a.pipe(u,z$1(this.dispose$),r?Ot$1(this.config.okTimeout):Ke$1(this.config.okTimeout),be$1(d))}async cast(e,t){await St(this.send(e,{...t,completeOn:"sent"}))}dispose(){this[Symbol.dispose]()}[Symbol.dispose](){if(this.disposed)return;this.disposed=!0;for(const e of this.connections.values())e.dispose();this.connections.clear();const e=[this.event$,this.ok$,this.fin$,this.all$,this.connectionState$,this.error$,this.outgoing$];for(const t of e)t.complete();this.dispose$.next(),this.dispose$.complete()}}const ke$1=e=>{const{strategy:t}=e,n=e.operators??[],r=e.rxReqId??Pt$1(),o=e.subject??new v;return{strategy:t,rxReqId:r,getReqPacketObservable:()=>o.pipe(...n),pipe:(...e)=>ke$1({strategy:t,rxReqId:r,operators:[...n,...e],subject:o}),emit(e,t){o.next({filters:_t$1(e),...t??{}})},over(){o.complete()}}};function zr(e){return ke$1({strategy:"backward",rxReqId:e})}function Kr(e){return ke$1({strategy:"forward",rxReqId:e})}function Pt$1(){return`${Math.floor(1e6*Math.random())}`}function Sr(e){var t,n;const r={},o=e=>/^#[a-zA-Z]$/.test(e);for(const s of Object.keys(e))if("limit"===s&&(e[s]??-1)>=0)r[s]=e[s];else{if("since"===s||"until"===s){const t=e[s];if("number"!=typeof t||(t??-1)>=0){r[s]=t;continue}}(o(s)||"ids"===s||"authors"===s)&&void 0!==e[s]&&((null==(t=e[s])?void 0:t.length)??-1)>0||"kinds"===s&&void 0!==e[s]&&((null==(n=e[s])?void 0:n.length)??-1)>0?r[s]=e[s]:"search"!==s||void 0===e[s]||(r[s]=e[s])}return"number"!=typeof r.since||"number"!=typeof r.until||r.since<=r.until?r:null}function _t$1(e){return(Array.isArray(e)?e:[e]).map((e=>Sr(e))).filter((e=>null!==e))}function ne(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Ce(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function yt(e,...t){if(!Ce(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 ke(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");ne(e.outputLen),ne(e.blockLen)}function mt(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 Re(e,t){yt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Ot="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,Ht=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),W=(e,t)=>e<<32-t|e>>>t;
|
|
14
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */new Uint8Array(new Uint32Array([287454020]).buffer)[0];const Ve=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function xt(e){yt(e);let t="";for(let n=0;n<e.length;n++)t+=Ve[e[n]];return t}function Pe(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function Kt(e){return"string"==typeof e&&(e=Pe(e)),yt(e),e}function je(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];yt(r),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 ge{clone(){return this._cloneInto()}}function Ze(e){const t=t=>e().update(Kt(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function we(e=32){if(Ot&&"function"==typeof Ot.getRandomValues)return Ot.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function ze(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),c=r?4:0,l=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+l,a,r)}const Ke=(e,t,n)=>e&t^~e&n,Me=(e,t,n)=>e&t^e&n^t&n;class Ge extends ge{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=Ht(this.buffer)}update(e){mt(this);const{view:t,buffer:n,blockLen:r}=this,o=(e=Kt(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=Ht(e);for(;r<=o-s;s+=r)this.process(t,s)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){mt(this),Re(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;ze(n,r-8,BigInt(8*this.length),o),this.process(n,0);const i=Ht(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++)i.setUint32(4*e,l[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 We=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]),tt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),et=new Uint32Array(64);class Ye extends Ge{constructor(){super(64,32,8,!1),this.A=0|tt[0],this.B=0|tt[1],this.C=0|tt[2],this.D=0|tt[3],this.E=0|tt[4],this.F=0|tt[5],this.G=0|tt[6],this.H=0|tt[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)et[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=et[e-15],n=et[e-2],r=W(t,7)^W(t,18)^t>>>3,o=W(n,17)^W(n,19)^n>>>10;et[e]=o+et[e-7]+r+et[e-16]|0}let{A:n,B:r,C:o,D:s,E:i,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(W(i,6)^W(i,11)^W(i,25))+Ke(i,a,c)+We[e]+et[e]|0,d=(W(n,2)^W(n,13)^W(n,22))+Me(n,r,o)|0;l=c,c=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,c=c+this.G|0,l=l+this.H|0,this.set(n,r,o,s,i,a,c,l)}roundClean(){et.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Bt=Ze((()=>new Ye)),ye=BigInt(0),$t=BigInt(1),De=BigInt(2);
|
|
15
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function it(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function pt(e){if(!it(e))throw new Error("Uint8Array expected")}const Fe=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function lt(e){pt(e);let t="";for(let n=0;n<e.length;n++)t+=Fe[e[n]];return t}function pe(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function Mt(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}const Y={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function re(e){return e>=Y._0&&e<=Y._9?e-Y._0:e>=Y._A&&e<=Y._F?e-(Y._A-10):e>=Y._a&&e<=Y._f?e-(Y._a-10):void 0}function dt(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=re(e.charCodeAt(o)),s=re(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 V(e){return Mt(lt(e))}function Gt(e){return pt(e),Mt(lt(Uint8Array.from(e).reverse()))}function nt(e,t){return dt(e.toString(16).padStart(2*t,"0"))}function Wt(e,t){return nt(e,t).reverse()}function Xe(e){return dt(pe(e))}function C(e,t,n){let r;if("string"==typeof t)try{r=dt(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!it(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 ct(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];pt(r),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}function Qe(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}function Je(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function tn(e){let t;for(t=0;e>ye;e>>=$t,t+=1);return t}function en(e,t){return e>>BigInt(t)&$t}function nn(e,t,n){return e|(n?$t:ye)<<BigInt(t)}const Yt=e=>(De<<BigInt(e-1))-$t,Ut=e=>new Uint8Array(e),oe=e=>Uint8Array.from(e);function be(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=Ut(e),o=Ut(e),s=0;const i=()=>{r.fill(1),o.fill(0),s=0},a=(...e)=>n(o,r,...e),c=(e=Ut())=>{o=a(oe([0]),e),r=a(),0!==e.length&&(o=a(oe([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 ct(...n)};return(e,t)=>{let n;for(i(),c(e);!(n=t(l()));)c();return i(),n}}const rn={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||it(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 bt(e,t,n={}){const r=(t,n,r)=>{const o=rn[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}const on=Object.freeze(Object.defineProperty({__proto__:null,abytes:pt,bitGet:en,bitLen:tn,bitMask:Yt,bitSet:nn,bytesToHex:lt,bytesToNumberBE:V,bytesToNumberLE:Gt,concatBytes:ct,createHmacDrbg:be,ensureBytes:C,equalBytes:Qe,hexToBytes:dt,hexToNumber:Mt,isBytes:it,numberToBytesBE:nt,numberToBytesLE:Wt,numberToHexUnpadded:pe,numberToVarBytesBE:Xe,utf8ToBytes:Je,validateObject:bt},Symbol.toStringTag,{value:"Module"})),q=BigInt(0),H=BigInt(1),ot=BigInt(2),sn=BigInt(3),kt=BigInt(4),se=BigInt(5),ie=BigInt(8);
|
|
16
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function T(e,t){const n=e%t;return n>=q?n:t+n}function cn(e,t,n){if(n<=q||t<q)throw new Error("Expected power/modulo > 0");if(n===H)return q;let r=H;for(;t>q;)t&H&&(r=r*e%n),e=e*e%n,t>>=H;return r}function z(e,t,n){let r=e;for(;t-- >q;)r*=r,r%=n;return r}function Rt(e,t){if(e===q||t<=q)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=T(e,t),r=t,o=q,s=H;for(;n!==q;){const e=r%n,t=o-s*(r/n);r=n,n=e,o=s,s=t}if(r!==H)throw new Error("invert: does not exist");return T(o,t)}function fn(e){const t=(e-H)/ot;let n,r,o;for(n=e-H,r=0;n%ot===q;n/=ot,r++);for(o=ot;o<e&&cn(o,t,e)!==e-H;o++);if(1===r){const t=(e+H)/kt;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+H)/ot;return function(e,i){if(e.pow(i,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=r,c=e.pow(e.mul(e.ONE,o),n),l=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(c,H<<BigInt(a-t-1));c=e.sqr(n),l=e.mul(l,n),d=e.mul(d,c),a=t}return l}}function an(e){if(e%kt===sn){const t=(e+H)/kt;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%ie===se){const t=(e-se)/ie;return function(e,n){const r=e.mul(n,ot),o=e.pow(r,t),s=e.mul(n,o),i=e.mul(e.mul(s,ot),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 fn(e)}BigInt(9),BigInt(16);const un=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ln(e){return bt(e,un.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"}))}function dn(e,t,n){if(n<q)throw new Error("Expected power > 0");if(n===q)return e.ONE;if(n===H)return t;let r=e.ONE,o=t;for(;n>q;)n&H&&(r=e.mul(r,o)),o=e.sqr(o),n>>=H;return r}function hn(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 Ee(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function gn(e,t,n=!1,r={}){if(e<=q)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:s}=Ee(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const i=an(e),a=Object.freeze({ORDER:e,BITS:o,BYTES:s,MASK:Yt(o),ZERO:q,ONE:H,create:t=>T(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return q<=t&&t<e},is0:e=>e===q,isOdd:e=>(e&H)===H,neg:t=>T(-t,e),eql:(e,t)=>e===t,sqr:t=>T(t*t,e),add:(t,n)=>T(t+n,e),sub:(t,n)=>T(t-n,e),mul:(t,n)=>T(t*n,e),pow:(e,t)=>dn(a,e,t),div:(t,n)=>T(t*Rt(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Rt(t,e),sqrt:r.sqrt||(e=>i(a,e)),invertBatch:e=>hn(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?Wt(e,s):nt(e,s),fromBytes:e=>{if(e.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${e.length}`);return n?Gt(e):V(e)}});return Object.freeze(a)}function me(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 xe(e){const t=me(e);return t+Math.ceil(t/2)}function wn(e,t,n=!1){const r=e.length,o=me(t),s=xe(t);if(r<16||r<s||r>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);const i=T(n?V(e):Gt(e),t-H)+H;return n?Wt(i,o):nt(i,o)}
|
|
17
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const yn=BigInt(0),qt=BigInt(1);function pn(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>yn;)n&qt&&(r=r.add(o)),o=o.double(),n>>=qt;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 c=e.ZERO,l=e.BASE;const d=BigInt(2**t-1),u=2**t,h=BigInt(t);for(let e=0;e<i;e++){const t=e*a;let r=Number(s&d);s>>=h,r>a&&(r-=u,s+=qt);const i=t,f=t+Math.abs(r)-1,p=e%2!=0,g=r<0;0===r?l=l.add(n(p,o[i])):c=c.add(n(g,o[f]))}return{p:c,f:l}},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 Be(e){return ln(e.Fp),bt(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ee(e.n,e.nBitLength),...e,p:e.Fp.ORDER})
|
|
18
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */}function bn(e){const t=Be(e);bt(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:En,hexToBytes:mn}=on,st={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=st;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:En(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=st,n="string"==typeof e?mn(e):e;pt(n);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}=st._parseInt(n.subarray(2)),{d:i,l:a}=st._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),c=n(i);return`30${n(i+s+4)}02${c}${o}02${a}${r}`}},D=BigInt(0),K=BigInt(1);BigInt(2);const ce=BigInt(3);function xn(e){const t=bn(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{const o=t.toAffine();return ct(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&&D<e&&e<t.n}function a(e){if(!i(e))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:o,n:s}=t;if(n&&"bigint"!=typeof e){if(it(e)&&(e=lt(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:V(C("private key",e,r))}catch{throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return o&&(i=T(i,s)),a(i),i}const l=new Map;function d(e){if(!(e instanceof u))throw new Error("ProjectivePoint expected")}class u{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 u)throw new Error("projective point not allowed");const o=e=>n.eql(e,n.ZERO);return o(t)&&o(r)?u.ZERO:new u(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(u.fromAffine)}static fromHex(e){const t=u.fromAffine(o(C("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return u.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 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,c=n.eql(n.mul(t,a),n.mul(s,o)),l=n.eql(n.mul(r,a),n.mul(i,o));return c&&l}negate(){return new u(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,o=n.mul(r,ce),{px:s,py:i,pz:a}=this;let c=n.ZERO,l=n.ZERO,d=n.ZERO,h=n.mul(s,s),f=n.mul(i,i),p=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),c=n.mul(e,d),l=n.mul(o,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),d=n.mul(o,d),p=n.mul(e,p),g=n.sub(h,p),g=n.mul(e,g),g=n.add(g,d),d=n.add(h,h),h=n.add(d,h),h=n.add(h,p),h=n.mul(h,g),l=n.add(l,h),p=n.mul(i,a),p=n.add(p,p),h=n.mul(p,g),c=n.sub(c,h),d=n.mul(p,f),d=n.add(d,d),d=n.add(d,d),new u(c,l,d)}add(e){d(e);const{px:r,py:o,pz:s}=this,{px:i,py:a,pz:c}=e;let l=n.ZERO,h=n.ZERO,f=n.ZERO;const p=t.a,g=n.mul(t.b,ce);let m=n.mul(r,i),b=n.mul(o,a),y=n.mul(s,c),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,c);return v=n.mul(v,k),k=n.add(m,y),v=n.sub(v,k),k=n.add(o,s),l=n.add(a,c),k=n.mul(k,l),l=n.add(b,y),k=n.sub(k,l),f=n.mul(p,v),l=n.mul(g,y),f=n.add(l,f),l=n.sub(b,f),f=n.add(b,f),h=n.mul(l,f),b=n.add(m,m),b=n.add(b,m),y=n.mul(p,y),v=n.mul(g,v),b=n.add(b,y),y=n.sub(m,y),y=n.mul(p,y),v=n.add(v,y),m=n.mul(b,v),h=n.add(h,m),m=n.mul(k,v),l=n.mul(w,l),l=n.sub(l,m),m=n.mul(w,b),f=n.mul(k,f),f=n.add(f,m),new u(l,h,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(u.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(u.fromAffine)}))}multiplyUnsafe(e){const r=u.ZERO;if(e===D)return r;if(a(e),e===K)return this;const{endo:o}=t;if(!o)return f.unsafeLadder(this,e);let{k1neg:s,k1:i,k2neg:c,k2:l}=o.splitScalar(e),d=r,h=r,p=this;for(;i>D||l>D;)i&K&&(d=d.add(p)),l&K&&(h=h.add(p)),p=p.double(),i>>=K,l>>=K;return s&&(d=d.negate()),c&&(h=h.negate()),h=new u(n.mul(h.px,o.beta),h.py,h.pz),d.add(h)}multiply(e){a(e);let r,o,s=e;const{endo:i}=t;if(i){const{k1neg:e,k1:t,k2neg:a,k2:c}=i.splitScalar(s);let{p:l,f:d}=this.wNAF(t),{p:h,f:p}=this.wNAF(c);l=f.constTimeNegate(e,l),h=f.constTimeNegate(a,h),h=new u(n.mul(h.px,i.beta),h.py,h.pz),r=l.add(h),o=d.add(p)}else{const{p:e,f:t}=this.wNAF(s);r=e,o=t}return u.normalizeZ([r,o])[0]}multiplyAndAddUnsafe(e,t,n){const r=u.BASE,o=(e,t)=>t!==D&&t!==K&&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),c=n.mul(o,e);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw new Error("invZ was invalid");return{x:i,y:a}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===K)return!0;if(n)return n(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===K?this:n?n(u,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(u,this,e)}toHex(e=!0){return lt(this.toRawBytes(e))}}u.BASE=new u(t.Gx,t.Gy,n.ONE),u.ZERO=new u(n.ZERO,n.ONE,n.ZERO);const h=t.nBitLength,f=pn(u,t.endo?Math.ceil(h/2):h);return{CURVE:t,ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:i}}function Bn(e){const t=Be(e);return bt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function An(e){const t=Bn(e),{Fp:n,n:r}=t,o=n.BYTES+1,s=2*n.BYTES+1;function i(e){return T(e,r)}function a(e){return Rt(e,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:d,isWithinCurveOrder:u}=xn({...t,toBytes(e,t,r){const o=t.toAffine(),s=n.toBytes(o.x),i=ct;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=V(i);if(!function(e){return D<e&&e<n.ORDER}(e))throw new Error("Point is not on curve");const t=d(e);let o;try{o=n.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return!(1&~r)!==((o&K)===K)&&(o=n.neg(o)),{x:e,y:o}}}}),h=e=>lt(nt(e,t.nByteLength));function f(e){return e>r>>K}const p=(e,t,n)=>V(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=C("compactSignature",e,2*n),new g(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=st.toSig(C("DER",e));return new g(t,n)}assertValidity(){if(!u(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!u(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,l=w(C("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 u=1&s?"03":"02",f=c.fromHex(u+h(d)),p=a(d),g=i(-l*p),m=i(o*p),b=c.BASE.multiplyAndAddUnsafe(f,g,m);if(!b)throw new Error("point at infinify");return b.assertValidity(),b}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return dt(this.toDERHex())}toDERHex(){return st.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return dt(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const m={isValidPrivateKey(e){try{return l(e),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const e=xe(t.n);return wn(t.randomBytes(e),t.n)},precompute:(e=8,t=c.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function b(e){const t=it(e),n="string"==typeof e,r=(t||n)&&e.length;return t?r===o||r===s:n?r===2*o||r===2*s:e instanceof c}const y=t.bits2int||function(e){const n=V(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=Yt(t.nBitLength);function k(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(D<=e&&e<v))throw new Error(`bigint expected < 2^${t.nBitLength}`);return nt(e,t.nByteLength)}function E(e,r,o=x){if(["recovered","canonical"].some((e=>e in o)))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:d}=t;let{lowS:h,prehash:p,extraEntropy:m}=o;null==h&&(h=!0),e=C("msgHash",e),p&&(e=C("prehashed msgHash",s(e)));const b=w(e),v=l(r),E=[k(v),k(b)];if(null!=m&&!1!==m){const e=!0===m?d(n.BYTES):m;E.push(C("extraEntropy",e))}const $=ct(...E),B=b;return{seed:$,k2sig:function(e){const t=y(e);if(!u(t))return;const n=a(t),r=c.BASE.multiply(t).toAffine(),o=i(r.x);if(o===D)return;const s=i(n*i(B+o*v));if(s===D)return;let l=(r.x===o?0:2)|Number(r.y&K),d=s;return h&&f(s)&&(d=function(e){return f(e)?i(-e):e}(s),l^=1),new g(o,d,l)}}}const x={lowS:t.lowS,prehash:!1},$={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(b(e))throw new Error("first arg must be private key");if(!b(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(l(e)).toRawBytes(n)},sign:function(e,n,r=x){const{seed:o,k2sig:s}=E(e,n,r),i=t;return be(i.hash.outputLen,i.nByteLength,i.hmac)(o,s)},verify:function(e,n,r,o=$){var s;const l=e;if(n=C("msgHash",n),r=C("publicKey",r),"strict"in o)throw new Error("options.strict was renamed to lowS");const{lowS:d,prehash:u}=o;let h,f;try{if("string"==typeof l||it(l))try{h=g.fromDER(l)}catch(e){if(!(e instanceof st.Err))throw e;h=g.fromCompact(l)}else{if("object"!=typeof l||"bigint"!=typeof l.r||"bigint"!=typeof l.s)throw new Error("PARSE");{const{r:e,s:t}=l;h=new g(e,t)}}f=c.fromHex(r)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(d&&h.hasHighS())return!1;u&&(n=t.hash(n));const{r:p,s:m}=h,b=w(n),y=a(m),v=i(b*y),k=i(p*y),E=null==(s=c.BASE.multiplyAndAddUnsafe(f,v,k))?void 0:s.toAffine();return!!E&&i(E.x)===p},ProjectivePoint:c,Signature:g,utils:m}}BigInt(4);class Ae extends ge{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ke(e);const n=Kt(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 mt(this),this.iHash.update(e),this}digestInto(e){mt(this),yt(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 ve=(e,t,n)=>new Ae(e,t).update(n).digest();
|
|
19
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
20
|
+
function vn(e){return{hash:e,hmac:(t,...n)=>ve(e,t,je(...n)),randomBytes:we}}function In(e,t){const n=t=>An({...e,...vn(t)});return Object.freeze({...n(t),create:n})}
|
|
21
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ve.create=(e,t)=>new Ae(e,t);const Nt=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),At=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ie=BigInt(1),vt=BigInt(2),fe=(e,t)=>(e+t/vt)/t;function Se(e){const t=Nt,n=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,d=l*l*e%t,u=z(d,n,t)*d%t,h=z(u,n,t)*d%t,f=z(h,vt,t)*l%t,p=z(f,o,t)*f%t,g=z(p,s,t)*p%t,m=z(g,a,t)*g%t,b=z(m,c,t)*m%t,y=z(b,a,t)*g%t,w=z(y,n,t)*d%t,v=z(w,i,t)*p%t,k=z(v,r,t)*l%t,E=z(k,vt,t);if(!Vt.eql(Vt.sqr(E),e))throw new Error("Cannot find square root");return E}const Vt=gn(Nt,void 0,void 0,{sqrt:Se}),Dt=In({a:BigInt(0),b:BigInt(7),Fp:Vt,n:At,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=At,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Ie*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,i=BigInt("0x100000000000000000000000000000000"),a=fe(s*e,t),c=fe(-r*e,t);let l=T(e-a*n-c*o,t),d=T(-a*r-c*s,t);const u=l>i,h=d>i;if(u&&(l=t-l),h&&(d=t-d),l>i||d>i)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:u,k1:l,k2neg:h,k2:d}}}},Bt),_t=BigInt(0),$e=e=>"bigint"==typeof e&&_t<e&&e<Nt,Sn=e=>"bigint"==typeof e&&_t<e&&e<At,ae={};function It(e,...t){let n=ae[e];if(void 0===n){const t=Bt(Uint8Array.from(e,(e=>e.charCodeAt(0))));n=ct(t,t),ae[e]=n}return Bt(ct(n,...t))}const Ft=e=>e.toRawBytes(!0).slice(1),Pt=e=>nt(e,32),Tt=e=>T(e,Nt),wt=e=>T(e,At),Xt=Dt.ProjectivePoint,$n=(e,t,n)=>Xt.BASE.multiplyAndAddUnsafe(e,t,n);function jt(e){let t=Dt.utils.normPrivateKeyToScalar(e),n=Xt.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:wt(-t),bytes:Ft(n)}}function Ne(e){if(!$e(e))throw new Error("bad x: need 0 < x < p");const t=Tt(e*e);let n=Se(Tt(t*e+BigInt(7)));n%vt!==_t&&(n=Tt(-n));const r=new Xt(e,n,Ie);return r.assertValidity(),r}function _e(...e){return wt(V(It("BIP0340/challenge",...e)))}function Nn(e){return jt(e).bytes}function _n(e,t,n=we(32)){const r=C("message",e),{bytes:o,scalar:s}=jt(t),i=C("auxRand",n,32),a=Pt(s^V(It("BIP0340/aux",i))),c=It("BIP0340/nonce",a,o,r),l=wt(V(c));if(l===_t)throw new Error("sign failed: k is zero");const{bytes:d,scalar:u}=jt(l),h=_e(d,o,r),f=new Uint8Array(64);if(f.set(d,0),f.set(Pt(wt(u+h*s)),32),!Le(f,r,o))throw new Error("sign: Invalid signature produced");return f}function Le(e,t,n){const r=C("signature",e,64),o=C("message",t),s=C("publicKey",n,32);try{const e=Ne(V(s)),t=V(r.subarray(0,32));if(!$e(t))return!1;const n=V(r.subarray(32,64));if(!Sn(n))return!1;const i=_e(Pt(t),Ft(e),o),a=$n(e,n,wt(-i));return!(!a||!a.hasEvenY()||a.toAffine().x!==t)}catch{return!1}}const Ct={getPublicKey:Nn,sign:_n,verify:Le,utils:{randomPrivateKey:Dt.utils.randomPrivateKey,lift_x:Ne,pointToBytes:Ft,numberToBytesBE:nt,bytesToNumberBE:V,taggedHash:It,mod:T}},Cn=new TextEncoder;function kn(e){return xt(Bt(Cn.encode(e)))}const Qt={sign:(e,t)=>xt(Ct.sign(e,t)),verify:Ct.verify,getPublicKey:e=>xt(Ct.getPublicKey(e))};function He(e){return kn(JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content]))}function Pn(e){try{return Qt.verify(e.sig,He(e),e.pubkey)}catch(e){return console.warn("The following error occurred during verify():",e),!1}}const Ue=async e=>Pn(e);var extendStatics=function(e,t){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},extendStatics(e,t)};function __extends(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function __awaiter(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}function __generator(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function __values(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function __read(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,s=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return i}function __spreadArray(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))}function __await(e){return this instanceof __await?(this.v=e,this):new __await(e)}function __asyncGenerator(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),s=[];return r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r;function i(e){o[e]&&(r[e]=function(t){return new Promise((function(n,r){s.push([e,t,n,r])>1||a(e,t)}))})}function a(e,t){try{(n=o[e](t)).value instanceof __await?Promise.resolve(n.value.v).then(c,l):d(s[0][2],n)}catch(e){d(s[0][3],e)}var n}function c(e){a("next",e)}function l(e){a("throw",e)}function d(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function __asyncValues(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}}function isFunction(e){return"function"==typeof e}function createErrorClass(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var UnsubscriptionError=createErrorClass((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function arrRemove(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var Subscription=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,n,r,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var i=__values(s),a=i.next();!a.done;a=i.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}else s.remove(this);var c=this.initialTeardown;if(isFunction(c))try{c()}catch(e){o=e instanceof UnsubscriptionError?e.errors:[e]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var d=__values(l),u=d.next();!u.done;u=d.next()){var h=u.value;try{execFinalizer(h)}catch(e){o=null!=o?o:[],e instanceof UnsubscriptionError?o=__spreadArray(__spreadArray([],__read(o)),__read(e.errors)):o.push(e)}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}}if(o)throw new UnsubscriptionError(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)execFinalizer(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&arrRemove(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&arrRemove(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function isSubscription(e){return e instanceof Subscription||e&&"closed"in e&&isFunction(e.remove)&&isFunction(e.add)&&isFunction(e.unsubscribe)}function execFinalizer(e){isFunction(e)?e():e.unsubscribe()}Subscription.EMPTY;var config={Promise:void 0},timeoutProvider={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,__spreadArray([e,t],__read(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function reportUnhandledError(e){timeoutProvider.setTimeout((function(){throw e}))}function noop(){}function errorContext(e){e()}var Subscriber=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,isSubscription(t)&&t.add(n)):n.destination=EMPTY_OBSERVER,n}return __extends(t,e),t.create=function(e,t,n){return new SafeSubscriber(e,t,n)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(Subscription),ConsumerObserver=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){handleUnhandledError(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){handleUnhandledError(e)}else handleUnhandledError(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){handleUnhandledError(e)}},e}(),SafeSubscriber=function(e){function t(t,n,r){var o,s=e.call(this)||this;return o=isFunction(t)||!t?{next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=r?r:void 0}:t,s.destination=new ConsumerObserver(o),s}return __extends(t,e),t}(Subscriber);function handleUnhandledError(e){reportUnhandledError(e)}function defaultErrorHandler(e){throw e}var EMPTY_OBSERVER={closed:!0,next:noop,error:defaultErrorHandler,complete:noop},observable="function"==typeof Symbol&&Symbol.observable||"@@observable";function identity(e){return e}function pipeFromArray(e){return 0===e.length?identity:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var Observable=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r=this,o=isSubscriber(e)?e:new SafeSubscriber(e,t,n);return errorContext((function(){var e=r,t=e.operator,n=e.source;o.add(t?t.call(o,n):n?r._subscribe(o):r._trySubscribe(o))})),o},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=getPromiseCtor(t))((function(t,r){var o=new SafeSubscriber({next:function(t){try{e(t)}catch(e){r(e),o.unsubscribe()}},error:r,complete:t});n.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[observable]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return pipeFromArray(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=getPromiseCtor(e))((function(e,n){var r;t.subscribe((function(e){return r=e}),(function(e){return n(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function getPromiseCtor(e){var t;return null!==(t=null!=e?e:config.Promise)&&void 0!==t?t:Promise}function isObserver(e){return e&&isFunction(e.next)&&isFunction(e.error)&&isFunction(e.complete)}function isSubscriber(e){return e&&e instanceof Subscriber||isObserver(e)&&isSubscription(e)}function hasLift(e){return isFunction(null==e?void 0:e.lift)}function operate(e){return function(t){if(hasLift(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}function createOperatorSubscriber(e,t,n,r,o){return new OperatorSubscriber(e,t,n,r,o)}var OperatorSubscriber=function(e){function t(t,n,r,o,s,i){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=i,a._next=n?function(e){try{n(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return __extends(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(Subscriber),dateTimestampProvider={now:function(){return Date.now()}},Action=function(e){function t(t,n){return e.call(this)||this}return __extends(t,e),t.prototype.schedule=function(e,t){return this},t}(Subscription),intervalProvider={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,__spreadArray([e,t],__read(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},AsyncAction=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r.pending=!1,r}return __extends(t,e),t.prototype.schedule=function(e,t){var n;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var r=this.id,o=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(o,r,t)),this.pending=!0,this.delay=t,this.id=null!==(n=this.id)&&void 0!==n?n:this.requestAsyncId(o,this.id,t),this},t.prototype.requestAsyncId=function(e,t,n){return void 0===n&&(n=0),intervalProvider.setInterval(e.flush.bind(e,this),n)},t.prototype.recycleAsyncId=function(e,t,n){if(void 0===n&&(n=0),null!=n&&this.delay===n&&!1===this.pending)return t;null!=t&&intervalProvider.clearInterval(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(e,t);if(n)return n;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var n,r=!1;try{this.work(e)}catch(e){r=!0,n=e||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),n},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,n=this.scheduler,r=n.actions;this.work=this.state=this.scheduler=null,this.pending=!1,arrRemove(r,this),null!=t&&(this.id=this.recycleAsyncId(n,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Action),Scheduler=function(){function e(t,n){void 0===n&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(e,t,n){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},e.now=dateTimestampProvider.now,e}(),AsyncScheduler=function(e){function t(t,n){void 0===n&&(n=Scheduler.now);var r=e.call(this,t,n)||this;return r.actions=[],r._active=!1,r}return __extends(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var n;this._active=!0;do{if(n=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,n){for(;e=t.shift();)e.unsubscribe();throw n}}},t}(Scheduler),asyncScheduler=new AsyncScheduler(AsyncAction),async=asyncScheduler,EMPTY=new Observable((function(e){return e.complete()}));function isScheduler(e){return e&&isFunction(e.schedule)}var isArrayLike=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function isPromise(e){return isFunction(null==e?void 0:e.then)}function isInteropObservable(e){return isFunction(e[observable])}function isAsyncIterable(e){return Symbol.asyncIterator&&isFunction(null==e?void 0:e[Symbol.asyncIterator])}function createInvalidObservableTypeError(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function getSymbolIterator(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}var iterator=getSymbolIterator();function isIterable(e){return isFunction(null==e?void 0:e[iterator])}function readableStreamLikeToAsyncGenerator(e){return __asyncGenerator(this,arguments,(function(){var t,n,r;return __generator(this,(function(o){switch(o.label){case 0:t=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,__await(t.read())];case 3:return n=o.sent(),r=n.value,n.done?[4,__await(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,__await(r)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}function isReadableStreamLike(e){return isFunction(null==e?void 0:e.getReader)}function innerFrom(e){if(e instanceof Observable)return e;if(null!=e){if(isInteropObservable(e))return fromInteropObservable(e);if(isArrayLike(e))return fromArrayLike(e);if(isPromise(e))return fromPromise(e);if(isAsyncIterable(e))return fromAsyncIterable(e);if(isIterable(e))return fromIterable(e);if(isReadableStreamLike(e))return fromReadableStreamLike(e)}throw createInvalidObservableTypeError(e)}function fromInteropObservable(e){return new Observable((function(t){var n=e[observable]();if(isFunction(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")}))}function fromArrayLike(e){return new Observable((function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()}))}function fromPromise(e){return new Observable((function(t){e.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,reportUnhandledError)}))}function fromIterable(e){return new Observable((function(t){var n,r;try{for(var o=__values(e),s=o.next();!s.done;s=o.next()){var i=s.value;if(t.next(i),t.closed)return}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}t.complete()}))}function fromAsyncIterable(e){return new Observable((function(t){process(e,t).catch((function(e){return t.error(e)}))}))}function fromReadableStreamLike(e){return fromAsyncIterable(readableStreamLikeToAsyncGenerator(e))}function process(e,t){var n,r,o,s;return __awaiter(this,void 0,void 0,(function(){var i,a;return __generator(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),n=__asyncValues(e),c.label=1;case 1:return[4,n.next()];case 2:if((r=c.sent()).done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),o={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))}))}function executeSchedule(e,t,n,r,o){void 0===r&&(r=0),void 0===o&&(o=!1);var s=t.schedule((function(){n(),o?e.add(this.schedule(null,r)):this.unsubscribe()}),r);if(e.add(s),!o)return s}function isValidDate(e){return e instanceof Date&&!isNaN(e)}function map(e,t){return operate((function(n,r){var o=0;n.subscribe(createOperatorSubscriber(r,(function(n){r.next(e.call(t,n,o++))})))}))}function mergeInternals(e,t,n,r,o,s,i,a){var c=[],l=0,d=0,u=!1,h=function(){!u||c.length||l||t.complete()},f=function(e){l++;var o=!1;innerFrom(n(e,d++)).subscribe(createOperatorSubscriber(t,(function(e){t.next(e)}),(function(){o=!0}),void 0,(function(){if(o)try{l--;for(;c.length&&l<r;)e=void 0,e=c.shift(),i||f(e);h()}catch(e){t.error(e)}var e})))};return e.subscribe(createOperatorSubscriber(t,(function(e){return l<r?f(e):c.push(e)}),(function(){u=!0,h()}))),function(){}}function mergeMap(e,t,n){return void 0===n&&(n=1/0),isFunction(t)?mergeMap((function(n,r){return map((function(e,o){return t(n,e,r,o)}))(innerFrom(e(n,r)))}),n):("number"==typeof t&&(n=t),operate((function(t,r){return mergeInternals(t,r,e,n)})))}function timer(e,t,n){void 0===n&&(n=async);var r=-1;return null!=t&&(isScheduler(t)?n=t:r=t),new Observable((function(t){var o=isValidDate(e)?+e-n.now():e;o<0&&(o=0);var s=0;return n.schedule((function(){t.closed||(t.next(s++),0<=r?this.schedule(void 0,r):t.complete())}),o)}))}function filter(e,t){return operate((function(n,r){var o=0;n.subscribe(createOperatorSubscriber(r,(function(n){return e.call(t,n,o++)&&r.next(n)})))}))}function take(e){return e<=0?function(){return EMPTY}:operate((function(t,n){var r=0;t.subscribe(createOperatorSubscriber(n,(function(t){++r<=e&&(n.next(t),e<=r&&n.complete())})))}))}function mapTo(e){return map((function(){return e}))}function delayWhen(e,t){return mergeMap((function(t,n){return innerFrom(e(t,n)).pipe(take(1),mapTo(t))}))}function delay(e,t){void 0===t&&(t=asyncScheduler);var n=timer(e,t);return delayWhen((function(){return n}))}const CALL_TIMEOUT=5e3,AUTH_URL_CALL_TIMEOUT=12e4,DEFAULT_NIP46_RELAYS=["wss://relay.nsec.app/","wss://ephemeral.snowflare.cc/"],NIP46_REQUEST_TIMEOUT=3e4;class Nip46Error extends Error{code;constructor(e,t){super(e),this.name="Nip46Error",this.code=t}get retryable(){return"TIMEOUT"===this.code||"RELAY_DISCONNECTED"===this.code}}class RelayPool{rxNostr;_relayUrls=[];_owned;_connStateSub;constructor(e){e?(this.rxNostr=e,this._owned=!1):(this.rxNostr=Wr({verifier:Ue,connectionStrategy:"lazy-keep",retry:{strategy:"exponential",maxCount:5,initialDelay:1e3},eoseTimeout:1e4,okTimeout:1e4,skipFetchNip11:!0}),this._owned=!0),this._connStateSub=this.rxNostr.createConnectionStateObservable().pipe(filter((e=>"error"===e.state)),delay(3e4)).subscribe((e=>{console.log("RelayPool: auto-reconnecting error relay:",e.from);try{this.rxNostr.reconnect(e.from)}catch(t){console.warn("RelayPool: auto-reconnect failed",e.from,t)}}))}addRelay(e){this._relayUrls.includes(e)||(this._relayUrls.push(e),this._syncRelays())}removeRelay(e){this._relayUrls=this._relayUrls.filter((t=>t!==e)),this._syncRelays()}removeAllRelays(){this._relayUrls=[],this.rxNostr.setDefaultRelays([])}_syncRelays(){this.rxNostr.setDefaultRelays(this._relayUrls)}async connect(e=1e4){if(this._syncRelays(),!this.isAnyConnected())return new Promise((t=>{const n=setTimeout((()=>{r.unsubscribe(),t()}),e),r=this.rxNostr.createConnectionStateObservable().subscribe((e=>{"connected"===e.state&&(clearTimeout(n),r.unsubscribe(),t())}))}))}disconnectAll(){this.rxNostr.setDefaultRelays([])}dispose(){this._connStateSub?.unsubscribe(),this._owned&&this.rxNostr.dispose()}isAnyConnected(){const e=this.rxNostr.getAllRelayStatus();return Object.values(e).some((e=>"connected"===e.connection))}get relayUrls(){return[...this._relayUrls]}async publish(e){await this.rxNostr.cast(e)}async publishToRelays(e,t){await this.rxNostr.cast(e,{on:{relays:t}})}subscribe(e,t){const n=Kr(),r=this.rxNostr.use(n).subscribe({next:e=>{t(e.event)}});return n.emit(e),()=>{r.unsubscribe()}}subscribeOnce(e,t,n){const r=zr(),o=n?{on:{relays:n}}:void 0,s=this.rxNostr.use(r,o).subscribe({next:e=>{t(e.event)}});return r.emit(e),r.over(),()=>{s.unsubscribe()}}reconnect(e){this.rxNostr.reconnect(e)}waitForConnection(e){return this.isAnyConnected()?Promise.resolve():new Promise(((t,n)=>{const r=setTimeout((()=>{o.unsubscribe(),n(new Nip46Error("Failed to connect to any relay","RELAY_DISCONNECTED"))}),e),o=this.rxNostr.createConnectionStateObservable().subscribe((e=>{"connected"===e.state&&(clearTimeout(r),o.unsubscribe(),t())}))}))}}class NostrRpc extends lib.EventEmitter{pool;_signer;requests=new Set;unsub;lastSubscribeFilter;requestTimers=new Map;_useNip44=!1;constructor(e,t){super(),this.pool=e,this._signer=t}subscribe(e){e.kinds=e.kinds?.filter((e=>24133===e)),this.lastSubscribeFilter={...e},this.unsub=this.pool.subscribe(e,(async e=>{try{const t=await this.parseEvent(e);t.method?this.emit("request",t):this.emit("response-"+t.id,t)}catch(e){console.error("error parsing event in subscription",e)}}))}ensureSubscription(){if(this.unsub)return;const e=this._signer.pubkey;console.log("ensureSubscription: subscribing for",e),this.subscribe({kinds:[24133],"#p":[e]})}stop(){this.unsub&&(this.unsub(),this.unsub=void 0)}resubscribe(){this.lastSubscribeFilter?(console.log("resubscribe: re-subscribing with filter",this.lastSubscribeFilter),this.stop(),this.subscribe(this.lastSubscribeFilter)):console.warn("resubscribe: no previous filter to resubscribe with")}isSubscriptionActive(){return!this.lastSubscribeFilter||!!this.unsub}clearPendingRequests(){for(const[e,t]of this.requestTimers.entries())clearTimeout(t),this.requestTimers.delete(e);this.requests.clear(),console.log("clearPendingRequests: all pending requests cleared")}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=e.pubkey,n=this.isNip04(e.content)?this._signer.decrypt:this._signer.decryptNip44,r=await n.call(this._signer,{pubkey:t},e.content),o=JSON.parse(r),{id:s,method:i,params:a,result:c,error:l}=o;return i?{id:s,pubkey:e.pubkey,method:i,params:a,event:e}:{id:s,result:c,error:l,event:e}}async parseNostrConnectReply(e,t){const n=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||"Invalid secret in reply");return n.pubkey}}async listen(e){const t=this._signer.pubkey;return console.log("nostr-login listening for conn to",t,"expecting secret:",e),new Promise(((n,r)=>{const o=setTimeout((()=>{r(new Error("Connection timeout: no response from signer"))}),6e4),s={kinds:[24133],"#p":[t]};this.stop(),this.lastSubscribeFilter=s,this.unsub=this.pool.subscribe(s,(async t=>{try{const s=await this.parseEvent(t);if(s.method?this.emit("request",s):this.emit("response-"+s.id,s),!s.method){const i=s;if("auth_url"===i.result)return void console.log("Ignoring auth_url response in listen");i.result===e?(clearTimeout(o),console.log("Connection established with signer:",t.pubkey),n(t.pubkey)):"ack"===i.result?(console.warn('Received "ack" instead of secret.'),clearTimeout(o),n(t.pubkey)):(console.error("Invalid response:",i),clearTimeout(o),r(new Error(i.error||"Invalid connection response")))}}catch(e){console.error("Error parsing event in listen",e)}}))}))}async connect(e,t,n){return console.log("Sending connect request to",e,"with perms:",n),this.ensureSubscription(),new Promise(((r,o)=>{const s=setTimeout((()=>{o(new Error("Connect timeout: no response from signer"))}),3e4),i=[e,t||"",n||""];this.sendRequest(e,"connect",i,24133,(e=>{clearTimeout(s),"ack"===e.result?(console.log("Connect acknowledged by signer"),r()):(console.error("Connect failed:",e.error),o(new Error(e.error||"Connection rejected by signer")))}))}))}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 this.pool.publish(i)}setResponseHandler(e,t){let n=!1,r=!1;const o=Date.now(),s=()=>{const t=this.requestTimers.get(e);t&&(clearTimeout(t),this.requestTimers.delete(e)),this.requests.delete(e)},i=()=>{const n=this.requestTimers.get(e);n&&clearTimeout(n);const i=setTimeout((()=>{console.warn("nip46 request "+e+" timed out after "+(Date.now()-o)+"ms (authUrl="+r+")"),s(),t&&t({id:e,result:"",error:"Request timeout",event:void 0})}),r?4*NIP46_REQUEST_TIMEOUT:NIP46_REQUEST_TIMEOUT);this.requestTimers.set(e,i)};return i(),new Promise((()=>{const a=c=>{"auth_url"===c.result?(this.once("response-"+e,a),n||(n=!0,r=!0,this.emit("authUrl",c.error),i())):t&&this.requests.has(e)&&(s(),console.log("nostr-login processed nip46 request in",Date.now()-o,"ms"),t(c))};this.once("response-"+e,a)}))}async createRequestEvent(e,t,n,r=[],o=24133){this.requests.add(e);const s={id:e,method:n,params:r},i=JSON.stringify(s),a=this._useNip44&&"create_account"!==n?this._signer.encryptNip44:this._signer.encrypt,c=await a.call(this._signer,{pubkey:t},i),l={kind:o,created_at:Math.floor(Date.now()/1e3),tags:[["p",t]],content:c};return finalizeEvent(l,this._signer.secretKey)}}class IframeNostrRpc extends NostrRpc{peerOrigin;iframePort;iframeRequests=new Map;pingInterval;constructor(e,t,n){super(e,t),this.peerOrigin=n}subscribe(e){this.peerOrigin||super.subscribe(e)}setWorkerIframePort(e){if(!this.peerOrigin)throw new Error("Unexpected iframe port");this.iframePort=e,this.pingInterval&&clearInterval(this.pingInterval),this.pingInterval=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(!verifyEvent(t))throw new Error("Invalid event signature from iframe");const n=await this.parseEvent(t);n.method||(console.log("parsed response",n),this.emit("response-"+n.id,n))}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),this.iframePort.postMessage(i)):await this.pool.publish(i)}stop(){super.stop(),this.pingInterval&&(clearInterval(this.pingInterval),this.pingInterval=void 0)}}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 lib.EventEmitter{rpc;bunkerPubkey;userPubkey="";constructor(e,t,n,r){super(),this.bunkerPubkey=n,this.rpc=new IframeNostrRpc(e,t,r),this.rpc.setUseNip44(!0),this.rpc.on("authUrl",(e=>{this.emit("authUrl",e)}))}async setSignerPubkey(e,t=!1){console.log("setSignerPubkey",e),this.bunkerPubkey=e,this.rpc.on("iframeRestart-"+e,(()=>{this.emit("iframeRestart")})),await this.initUserPubkey(t?e:"")}async initUserPubkey(e){if(this.userPubkey)console.warn("initUserPubkey already called, pubkey:",this.userPubkey);else{if(e)return this.userPubkey=e,void console.log("User pubkey set from hint:",this.userPubkey);console.log("Requesting user pubkey from signer:",this.bunkerPubkey),this.userPubkey=await new Promise(((e,t)=>{if(!this.bunkerPubkey)throw new Error("Signer pubkey not set");const n=setTimeout((()=>{t(new Error("Timeout getting user pubkey"))}),3e4);console.log("get_public_key",this.bunkerPubkey),this.rpc.sendRequest(this.bunkerPubkey,"get_public_key",[],24133,(r=>{clearTimeout(n),r.error?t(new Error(r.error)):(console.log("User pubkey received:",r.result),e(r.result))}))}))}}async listen(e){const t=await this.rpc.listen(e);await this.setSignerPubkey(t)}async connect(e,t){if(!this.bunkerPubkey)throw new Error("No signer pubkey");await this.rpc.connect(this.bunkerPubkey,e,t),await this.setSignerPubkey(this.bunkerPubkey)}async setListenReply(e,t){const n=await this.rpc.parseNostrConnectReply(e,t);await this.setSignerPubkey(n,!0)}async sign(e){return new Promise(((t,n)=>{const r=JSON.stringify(e);this.rpc.sendRequest(this.bunkerPubkey,"sign_event",[r],24133,(e=>{if(e.error)e.error.includes("timeout")||"Request timeout"===e.error?n(new Nip46Error(e.error,"TIMEOUT")):n(new Nip46Error(e.error,"SIGNER_REJECTED"));else try{const n=JSON.parse(e.result);n.sig&&n.pubkey&&n.id?t(n):n.sig?t(n.sig):t(e.result)}catch{t(e.result)}}))}))}async encrypt(e,t){return new Promise(((n,r)=>{this.rpc.sendRequest(this.bunkerPubkey,"nip04_encrypt",[e,t],24133,(e=>{e.error?r(new Nip46Error(e.error,"SIGNER_REJECTED")):n(e.result)}))}))}async decrypt(e,t){return new Promise(((n,r)=>{this.rpc.sendRequest(this.bunkerPubkey,"nip04_decrypt",[e,t],24133,(e=>{e.error?r(new Nip46Error(e.error,"SIGNER_REJECTED")):n(e.result)}))}))}async createAccount2({bunkerPubkey:e,name:t,domain:n,perms:r=""}){const o=[t,n,"",r],s=await new Promise(((t,n)=>{const r=setTimeout((()=>{n(new Error("Timeout creating account"))}),6e4);this.rpc.sendRequest(e,"create_account",o,void 0,(e=>{clearTimeout(r),t(e)}))}));if(console.log("create_account response",s),"error"===s.result||s.error)throw new Error(s.error||"Failed to create account");return s.result}}class BannerManager extends lib.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)})),this.banner.addEventListener("handleCancelTimeout",(()=>{this.emit("cancelTimeout")})),document.body.appendChild(this.banner)}}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),c=r?4:0,l=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+l,a,r)}function Chi(e,t,n){return e&t^~e&n}function Maj(e,t,n){return e&t^e&n^t&n}class HashMD extends Hash{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(this.buffer)}update(e){aexists(this),abytes$1(e=toBytes(e));const{view:t,buffer:n,blockLen:r}=this,o=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){aexists(this),aoutput(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=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(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 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++)i.setUint32(4*e,l[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.destroyed=s,e.finished=o,e.length=r,e.pos=i,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=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=new Uint32Array(64);class SHA256 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: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:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(rotr(i,6)^rotr(i,11)^rotr(i,25))+Chi(i,a,c)+SHA256_K[e]+SHA256_W[e]|0,d=(rotr(n,2)^rotr(n,13)^rotr(n,22))+Maj(n,r,o)|0;l=c,c=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,c=c+this.G|0,l=l+this.H|0,this.set(n,r,o,s,i,a,c,l)}roundClean(){clean(SHA256_W)}destroy(){this.set(0,0,0,0,0,0,0,0),clean(this.buffer)}}const sha256$1=createHasher((()=>new SHA256));class HMAC extends Hash{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ahash(e);const n=toBytes(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),clean(o)}update(e){return aexists(this),this.iHash.update(e),this}digestInto(e){aexists(this),abytes$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}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const hmac=(e,t,n)=>new HMAC(e,t).update(n).digest();hmac.create=(e,t)=>new HMAC(e,t)
|
|
22
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */;const _0n$3=BigInt(0),_1n$3=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$1(e),o=e?.length,s=void 0!==t;if(!r||s&&o!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${t}`:"")+", got "+(r?`length=${o}`:"type="+typeof e))}return e}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""===e?_0n$3:BigInt("0x"+e)}function bytesToNumberBE(e){return hexToNumber(bytesToHex(e))}function bytesToNumberLE(e){return abytes$1(e),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 ensureBytes(e,t,n){let r;if("string"==typeof t)try{r=hexToBytes(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!isBytes$1(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}return r.length,r}const isPosBig=e=>"bigint"==typeof e&&_0n$3<=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(e){let t;for(t=0;e>_0n$3;e>>=_1n$3,t+=1);return t}const bitMask=e=>(_1n$3<<BigInt(e))-_1n$3;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");const r=e=>new Uint8Array(e),o=e=>Uint8Array.of(e);let s=r(e),i=r(e),a=0;const c=()=>{s.fill(1),i.fill(0),a=0},l=(...e)=>n(i,s,...e),d=(e=r(0))=>{i=l(o(0),e),s=l(),0!==e.length&&(i=l(o(1),e),s=l())},u=()=>{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(...n)};return(e,t)=>{let n;for(c(),d(e);!(n=t(u()));)d();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 o=e[t];if(r&&void 0===o)return;const s=typeof o;if(s!==n||null===o)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 o=t.get(n);if(void 0!==o)return o;const s=e(n,...r);return t.set(n,s),s}}
|
|
23
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$2=BigInt(0),_1n$2=BigInt(1),_2n$2=BigInt(2),_3n$1=BigInt(3),_4n$1=BigInt(4),_5n=BigInt(5),_7n=BigInt(7),_8n=BigInt(8),_9n=BigInt(9),_16n=BigInt(16);function mod(e,t){const n=e%t;return n>=_0n$2?n:t+n}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)throw new Error("invert: expected non-zero number");if(t<=_0n$2)throw new Error("invert: expected positive modulus, got "+t);let n=mod(e,t),r=t,o=_0n$2,s=_1n$2;for(;n!==_0n$2;){const e=r%n,t=o-s*(r/n);r=n,n=e,o=s,s=t}if(r!==_1n$2)throw new Error("invert: does not exist");return mod(o,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$2)/_4n$1,r=e.pow(t,n);return assertIsSquare(e,r,t),r}function sqrt5mod8(e,t){const n=(e.ORDER-_5n)/_8n,r=e.mul(t,_2n$2),o=e.pow(r,n),s=e.mul(t,o),i=e.mul(e.mul(s,_2n$2),o),a=e.mul(s,e.sub(i,e.ONE));return assertIsSquare(e,a,t),a}function sqrt9mod16(e){const t=Field(e),n=tonelliShanks(e),r=n(t,t.neg(t.ONE)),o=n(t,r),s=n(t,t.neg(r)),i=(e+_7n)/_16n;return(e,t)=>{let n=e.pow(t,i),a=e.mul(n,r);const c=e.mul(n,o),l=e.mul(n,s),d=e.eql(e.sqr(a),t),u=e.eql(e.sqr(c),t);n=e.cmov(n,a,d),a=e.cmov(l,c,u);const h=e.eql(e.sqr(a),t),f=e.cmov(n,a,h);return assertIsSquare(e,f,t),f}}function tonelliShanks(e){if(e<_3n$1)throw new Error("sqrt is not defined for small field");let t=e-_1n$2,n=0;for(;t%_2n$2===_0n$2;)t/=_2n$2,n++;let r=_2n$2;const o=Field(e);for(;1===FpLegendre(o,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return sqrt3mod4;let s=o.pow(r,t);const i=(t+_1n$2)/_2n$2;return function(e,r){if(e.is0(r))return r;if(1!==FpLegendre(e,r))throw new Error("Cannot find square root");let o=n,a=e.mul(e.ONE,s),c=e.pow(r,t),l=e.pow(r,i);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===o)throw new Error("Cannot find square root");const r=_1n$2<<BigInt(o-t-1),s=e.pow(a,r);o=t,a=e.sqr(s),c=e.mul(c,a),l=e.mul(l,s)}return l}}function FpSqrt(e){return e%_4n$1===_3n$1?sqrt3mod4:e%_8n===_5n?sqrt5mod8:e%_16n===_9n?sqrt9mod16(e):tonelliShanks(e)}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:"number",BITS:"number"});return _validateObject(e,t),e}function FpPow(e,t,n){if(n<_0n$2)throw new Error("invalid exponent, negatives unsupported");if(n===_0n$2)return e.ONE;if(n===_1n$2)return t;let r=e.ONE,o=t;for(;n>_0n$2;)n&_1n$2&&(r=e.mul(r,o)),o=e.sqr(o),n>>=_1n$2;return r}function FpInvertBatch(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce(((t,n,o)=>e.is0(n)?t:(r[o]=t,e.mul(t,n))),e.ONE),s=e.inv(o);return t.reduceRight(((t,n,o)=>e.is0(n)?t:(r[o]=e.mul(t,r[o]),e.mul(t,n))),s),r}function FpLegendre(e,t){const n=(e.ORDER-_1n$2)/_2n$2,r=e.pow(t,n),o=e.eql(r,e.ONE),s=e.eql(r,e.ZERO),i=e.eql(r,e.neg(e.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function nLength(e,t){void 0!==t&&anumber$1(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("invalid field: expected ORDER > 0, got "+e);let o,s,i,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&&(o=e.BITS),e.sqrt&&(s=e.sqrt),"boolean"==typeof e.isLE&&(n=e.isLE),"boolean"==typeof e.modFromBytes&&(a=e.modFromBytes),i=e.allowedLengths}else"number"==typeof t&&(o=t),r.sqrt&&(s=r.sqrt);const{nBitLength:c,nByteLength:l}=nLength(e,o);if(l>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let d;const u=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:l,MASK:bitMask(c),ZERO:_0n$2,ONE:_1n$2,allowedLengths:i,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,isValidNot0:e=>!u.is0(e)&&u.isValid(e),isOdd:e=>(e&_1n$2)===_1n$2,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(u,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:s||(t=>(d||(d=FpSqrt(e)),d(u,t))),toBytes:e=>n?numberToBytesLE(e,l):numberToBytesBE(e,l),fromBytes:(t,r=!0)=>{if(i){if(!i.includes(t.length)||t.length>l)throw new Error("Field.fromBytes: expected "+i+" 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 o=n?bytesToNumberLE(t):bytesToNumberBE(t);if(a&&(o=mod(o,e)),!r&&!u.isValid(o))throw new Error("invalid field element: outside of range 0..ORDER");return o},invertBatch:e=>FpInvertBatch(u,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(u)}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,o=getFieldBytesLength(t),s=getMinHashLength(t);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const i=mod(n?bytesToNumberLE(e):bytesToNumberBE(e),t-_1n$2)+_1n$2;return n?numberToBytesLE(i,o):numberToBytesBE(i,o)}
|
|
24
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$1=BigInt(0),_1n$1=BigInt(1);function negateCt(e,t){const n=t.negate();return e?n:t}function normalizeZ(e,t){const n=FpInvertBatch(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(e),maxNumber:n,shiftBy:BigInt(e)}}function calcOffsets(e,t,n){const{windowSize:r,mask:o,maxNumber:s,shiftBy:i}=n;let a=Number(e&o),c=e>>i;a>r&&(a-=s,c+=_1n$1);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$1)throw new Error("invalid wNAF")}class wNAF{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$1;)t&_1n$1&&(n=n.add(r)),r=r.double(),t>>=_1n$1;return n}precomputeWindow(e,t){const{windows:n,windowSize:r}=calcWOpts(t,this.bits),o=[];let s=e,i=s;for(let e=0;e<n;e++){i=s,o.push(i);for(let e=1;e<r;e++)i=i.add(s),o.push(i);s=i.double()}return o}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let r=this.ZERO,o=this.BASE;const s=calcWOpts(e,this.bits);for(let e=0;e<s.windows;e++){const{nextN:i,offset:a,isZero:c,isNeg:l,isNegF:d,offsetF:u}=calcOffsets(n,e,s);n=i,c?o=o.add(negateCt(d,t[u])):r=r.add(negateCt(l,t[a]))}return assert0(n),{p:r,f:o}}wNAFUnsafe(e,t,n,r=this.ZERO){const o=calcWOpts(e,this.bits);for(let e=0;e<o.windows&&n!==_0n$1;e++){const{nextN:s,offset:i,isZero:a,isNeg:c}=calcOffsets(n,e,o);if(n=s,!a){const e=t[i];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 o=getW(e);return 1===o?this._unsafeLadder(e,t,r):this.wNAFUnsafe(o,this.getPrecomputes(o,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 o=t,s=e.ZERO,i=e.ZERO;for(;n>_0n$1||r>_0n$1;)n&_1n$1&&(s=s.add(o)),r&_1n$1&&(i=i.add(o)),o=o.double(),n>>=_1n$1,r>>=_1n$1;return{p1:s,p2:i}}function pippenger(e,t,n,r){validateMSMPoints(n,e),validateMSMScalars(r,t);const o=n.length,s=r.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");const i=e.ZERO,a=bitLen(BigInt(o));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const l=bitMask(c),d=new Array(Number(l)+1).fill(i);let u=i;for(let e=Math.floor((t.BITS-1)/c)*c;e>=0;e-=c){d.fill(i);for(let t=0;t<s;t++){const o=r[t],s=Number(o>>BigInt(e)&l);d[s]=d[s].add(n[t])}let t=i;for(let e=d.length-1,n=i;e>0;e--)n=n.add(d[e]),t=t.add(n);if(u=u.add(t),0!==e)for(let e=0;e<c;e++)u=u.double()}return u}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(t),t}return Field(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$1))throw new Error(`CURVE.${e} must be positive bigint`)}const o=createField(t.p,n.Fp,r),s=createField(t.n,n.Fn,r),i=["Gx","Gy","a","b"];for(const e of i)if(!o.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:o,Fn:s}}
|
|
25
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const divNearest=(e,t)=>(e+(e>=0?t:-t)/_2n$1)/t;function _splitEndoScalar(e,t,n){const[[r,o],[s,i]]=t,a=divNearest(i*e,n),c=divNearest(-o*e,n);let l=e-a*r-c*s,d=-a*o-c*i;const u=l<_0n,h=d<_0n;u&&(l=-l),h&&(d=-d);const f=bitMask(Math.ceil(bitLen(n)/2))+_1n;if(l<_0n||l>=f||d<_0n||d>=f)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:u,k1:l,k2neg:h,k2:d}}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={Err:DERErr,_tlv:{encode:(e,t)=>{const{Err:n}=DER;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,o=numberToHexUnpadded(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const s=r>127?numberToHexUnpadded(o.length/2|128):"";return numberToHexUnpadded(e)+s+o+t},decode(e,t){const{Err:n}=DER;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const o=t[r++];let s=0;if(!!(128&o)){const e=127&o;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 i=t.subarray(r,r+e);if(i.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===i[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of i)s=s<<8|e;if(r+=e,s<128)throw new n("tlv.decode(long): not minimal encoding")}else s=o;const i=t.subarray(r,r+s);if(i.length!==s)throw new n("tlv.decode: wrong value length");return{v:i,l:t.subarray(r+s)}}},_int:{encode(e){const{Err:t}=DER;if(e<_0n)throw new t("integer: negative integers are not allowed");let n=numberToHexUnpadded(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;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(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=DER,o=ensureBytes("signature",e),{v:s,l:i}=r.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,s),{v:l,l:d}=r.decode(2,c);if(d.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,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},_0n=BigInt(0),_1n=BigInt(1),_2n$1=BigInt(2),_3n=BigInt(3),_4n=BigInt(4);function _normFnElement(e,t){const{BYTES:n}=e;let r;if("bigint"==typeof t)r=t;else{let o=ensureBytes("private key",t);try{r=e.fromBytes(o)}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:o}=n;let s=n.CURVE;const{h:i,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,o);function d(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const u=t.toBytes||function(e,t,n){const{x:o,y:s}=t.toAffine(),i=r.toBytes(o);if(_abool2(n,"isCompressed"),n){d();return concatBytes(pprefix(!r.isOdd(s)),i)}return concatBytes(Uint8Array.of(4),i,r.toBytes(s))},h=t.fromBytes||function(e){_abytes2(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=l,o=e.length,s=e[0],i=e.subarray(1);if(o!==t||2!==s&&3!==s){if(o===n&&4===s){const e=r.BYTES,t=r.fromBytes(i.subarray(0,e)),n=r.fromBytes(i.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 ${o}, expected compressed=${t} or uncompressed=${n}`)}{const e=r.fromBytes(i);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)}d();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),o=f(e);return r.eql(n,o)}if(!p(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const g=r.mul(r.pow(s.a,_3n),_4n),m=r.mul(r.sqr(s.b),BigInt(27));if(r.is0(r.add(g,m)))throw new Error("bad curve params: a or b");function b(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function y(e){if(!(e instanceof x))throw new Error("ProjectivePoint expected")}function w(e){if(!c||!c.basises)throw new Error("no endo");return _splitEndoScalar(e,c.basises,o.ORDER)}const v=memoized(((e,t)=>{const{X:n,Y:o,Z:s}=e;if(r.eql(s,r.ONE))return{x:n,y:o};const i=e.is0();null==t&&(t=i?r.ONE:r.inv(s));const a=r.mul(n,t),c=r.mul(o,t),l=r.mul(s,t);if(i)return{x:r.ZERO,y:r.ZERO};if(!r.eql(l,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),k=memoized((e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:n,y:o}=e.toAffine();if(!r.isValid(n)||!r.isValid(o))throw new Error("bad point: x or y not field elements");if(!p(n,o))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,o,s){return n=new x(r.mul(n.X,e),n.Y,n.Z),t=negateCt(o,t),n=negateCt(s,n),t.add(n)}class x{constructor(e,t,n){this.X=b("x",e),this.Y=b("y",t,!0),this.Z=b("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 x)throw new Error("projective point not allowed");return r.is0(t)&&r.is0(n)?x.ZERO:new x(t,n,r.ONE)}static fromBytes(e){const t=x.fromAffine(h(_abytes2(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return x.fromBytes(ensureBytes("pointHex",e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return C.createCache(this,e),t||this.multiply(_3n),this}assertValidity(){k(this)}hasEvenY(){const{y:e}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(e)}equals(e){y(e);const{X:t,Y:n,Z:o}=this,{X:s,Y:i,Z:a}=e,c=r.eql(r.mul(t,a),r.mul(s,o)),l=r.eql(r.mul(n,a),r.mul(i,o));return c&&l}negate(){return new x(this.X,r.neg(this.Y),this.Z)}double(){const{a:e,b:t}=s,n=r.mul(t,_3n),{X:o,Y:i,Z:a}=this;let c=r.ZERO,l=r.ZERO,d=r.ZERO,u=r.mul(o,o),h=r.mul(i,i),f=r.mul(a,a),p=r.mul(o,i);return p=r.add(p,p),d=r.mul(o,a),d=r.add(d,d),c=r.mul(e,d),l=r.mul(n,f),l=r.add(c,l),c=r.sub(h,l),l=r.add(h,l),l=r.mul(c,l),c=r.mul(p,c),d=r.mul(n,d),f=r.mul(e,f),p=r.sub(u,f),p=r.mul(e,p),p=r.add(p,d),d=r.add(u,u),u=r.add(d,u),u=r.add(u,f),u=r.mul(u,p),l=r.add(l,u),f=r.mul(i,a),f=r.add(f,f),u=r.mul(f,p),c=r.sub(c,u),d=r.mul(f,h),d=r.add(d,d),d=r.add(d,d),new x(c,l,d)}add(e){y(e);const{X:t,Y:n,Z:o}=this,{X:i,Y:a,Z:c}=e;let l=r.ZERO,d=r.ZERO,u=r.ZERO;const h=s.a,f=r.mul(s.b,_3n);let p=r.mul(t,i),g=r.mul(n,a),m=r.mul(o,c),b=r.add(t,n),w=r.add(i,a);b=r.mul(b,w),w=r.add(p,g),b=r.sub(b,w),w=r.add(t,o);let v=r.add(i,c);return w=r.mul(w,v),v=r.add(p,m),w=r.sub(w,v),v=r.add(n,o),l=r.add(a,c),v=r.mul(v,l),l=r.add(g,m),v=r.sub(v,l),u=r.mul(h,w),l=r.mul(f,m),u=r.add(l,u),l=r.sub(g,u),u=r.add(g,u),d=r.mul(l,u),g=r.add(p,p),g=r.add(g,p),m=r.mul(h,m),w=r.mul(f,w),g=r.add(g,m),m=r.sub(p,m),m=r.mul(h,m),w=r.add(w,m),p=r.mul(g,w),d=r.add(d,p),p=r.mul(v,w),l=r.mul(b,l),l=r.sub(l,p),p=r.mul(b,g),u=r.mul(v,u),u=r.add(u,p),new x(l,d,u)}subtract(e){return this.add(e.negate())}is0(){return this.equals(x.ZERO)}multiply(e){const{endo:n}=t;if(!o.isValidNot0(e))throw new Error("invalid scalar: out of range");let r,s;const i=e=>C.cached(this,e,(e=>normalizeZ(x,e)));if(n){const{k1neg:t,k1:o,k2neg:a,k2:c}=w(e),{p:l,f:d}=i(o),{p:u,f:h}=i(c);s=d.add(h),r=E(n.beta,l,u,t,a)}else{const{p:t,f:n}=i(e);r=t,s=n}return normalizeZ(x,[r,s])[0]}multiplyUnsafe(e){const{endo:n}=t,r=this;if(!o.isValid(e))throw new Error("invalid scalar: out of range");if(e===_0n||r.is0())return x.ZERO;if(e===_1n)return r;if(C.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:o,k2neg:s,k2:i}=w(e),{p1:a,p2:c}=mulEndoUnsafe(x,r,o,i);return E(n.beta,a,c,t,s)}return C.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 i===_1n||(e?e(x,this):C.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return i===_1n?this:e?e(x,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(e=!0){return _abool2(e,"isCompressed"),this.assertValidity(),u(x,this,e)}toHex(e=!0){return bytesToHex(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(x,e)}static msm(e,t){return pippenger(x,o,e,t)}static fromPrivateKey(e){return x.BASE.multiply(_normFnElement(o,e))}}x.BASE=new x(s.Gx,s.Gy,r.ONE),x.ZERO=new x(r.ZERO,r.ONE,r.ZERO),x.Fp=r,x.Fn=o;const $=o.BITS,C=new wNAF(x,t.endo?Math.ceil($/2):$);return x.BASE.precompute(8),x}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,o=Object.assign(getWLengths(e.Fp,n),{seed:getMinHashLength(n.ORDER)});function s(e){try{return!!_normFnElement(n,e)}catch(e){return!1}}function i(e=r(o.seed)){return mapHashToField(_abytes2(e,o.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:i}=o;if(n.allowedLengths||r===s)return;const a=ensureBytes("key",t).length;return a===s||a===i}const l={isValidSecretKey:s,isValidPublicKey:function(t,n){const{publicKey:r,publicKeyUncompressed:s}=o;try{const o=t.length;return(!0!==n||o===r)&&((!1!==n||o===s)&&!!e.fromBytes(t))}catch(e){return!1}},randomSecretKey:i,isValidPrivateKey:s,randomPrivateKey:i,normPrivateKeyToScalar:e=>_normFnElement(n,e),precompute:(t=8,n=e.BASE)=>n.precompute(t,!1)};return Object.freeze({getPublicKey:a,getSharedSecret:function(t,r,o=!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(o)},keygen:function(e){const t=i(e);return{secretKey:t,publicKey:a(t)}},Point:e,utils:l,lengths:o})}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,o=n.hmac||((e,...n)=>hmac(t,e,concatBytes(...n))),{Fp:s,Fn:i}=e,{ORDER:a,BITS:c}=i,{keygen:l,getPublicKey:d,getSharedSecret:u,utils:h,lengths:f}=ecdh(e,n),p={prehash:!1,lowS:"boolean"==typeof n.lowS&&n.lowS,format:void 0,extraEntropy:!1},g="compact";function m(e){return e>a>>_1n}function b(e,t){if(!i.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class y{constructor(e,t,n){this.r=b("r",e),this.s=b("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.toSig(_abytes2(e));return new y(t,n)}"recovered"===t&&(n=e[0],t="compact",e=e.subarray(1));const r=i.BYTES,o=e.subarray(0,r),s=e.subarray(r,2*r);return new y(i.fromBytes(o),i.fromBytes(s),n)}static fromHex(e,t){return this.fromBytes(hexToBytes(e),t)}addRecoveryBit(e){return new y(this.r,this.s,e)}recoverPublicKey(t){const n=s.ORDER,{r:r,s:o,recovery:c}=this;if(null==c||![0,1,2,3].includes(c))throw new Error("recovery id invalid");if(a*_2n$1<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 d=s.toBytes(l),u=e.fromBytes(concatBytes(pprefix(!(1&c)),d)),h=i.inv(l),f=v(ensureBytes("msgHash",t)),p=i.create(-f*h),g=i.create(o*h),m=e.BASE.multiplyUnsafe(p).add(u.multiplyUnsafe(g));if(m.is0())throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return m(this.s)}toBytes(e=g){if(validateSigFormat(e),"der"===e)return hexToBytes(DER.hexFromSig(this));const t=i.toBytes(this.r),n=i.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return concatBytes(Uint8Array.of(this.recovery),t,n)}return concatBytes(t,n)}toHex(e){return bytesToHex(this.toBytes(e))}assertValidity(){}static fromCompact(e){return y.fromBytes(ensureBytes("sig",e),"compact")}static fromDER(e){return y.fromBytes(ensureBytes("sig",e),"der")}normalizeS(){return this.hasHighS()?new y(this.r,i.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return bytesToHex(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return bytesToHex(this.toBytes("compact"))}}const w=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=bytesToNumberBE(e),n=8*e.length-c;return n>0?t>>BigInt(n):t},v=n.bits2int_modN||function(e){return i.create(w(e))},k=bitMask(c);function E(e){return aInRange("num < 2^"+c,e,_0n,k),i.toBytes(e)}function x(e,n){return _abytes2(e,void 0,"message"),n?_abytes2(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:l,getPublicKey:d,getSharedSecret:u,utils:h,lengths:f,Point:e,sign:function(n,s,a={}){n=ensureBytes("message",n);const{seed:c,k2sig:l}=function(t,n,o){if(["recovered","canonical"].some((e=>e in o)))throw new Error("sign() legacy options not supported");const{lowS:s,prehash:a,extraEntropy:c}=validateSigOpts(o,p);t=x(t,a);const l=v(t),d=_normFnElement(i,n),u=[E(d),E(l)];if(null!=c&&!1!==c){const e=!0===c?r(f.secretKey):c;u.push(ensureBytes("extraEntropy",e))}const h=concatBytes(...u),g=l;return{seed:h,k2sig:function(t){const n=w(t);if(!i.isValidNot0(n))return;const r=i.inv(n),o=e.BASE.multiply(n).toAffine(),a=i.create(o.x);if(a===_0n)return;const c=i.create(r*i.create(g+a*d));if(c===_0n)return;let l=(o.x===a?0:2)|Number(o.y&_1n),u=c;return s&&m(c)&&(u=i.neg(c),l^=1),new y(a,u,l)}}}(n,s,a);return createHmacDrbg(t.outputLen,i.BYTES,o)(c,l)},verify:function(t,n,r,o={}){const{lowS:s,prehash:a,format:c}=validateSigOpts(o,p);if(r=ensureBytes("publicKey",r),n=x(ensureBytes("message",n),a),"strict"in o)throw new Error("options.strict was renamed to lowS");const l=void 0===c?function(e){let t;const n="string"==typeof e||isBytes$1(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 y(e.r,e.s);else if(n){try{t=y.fromBytes(ensureBytes("sig",e),"der")}catch(e){if(!(e instanceof DER.Err))throw e}if(!t)try{t=y.fromBytes(ensureBytes("sig",e),"compact")}catch(e){return!1}}return t||!1}(t):y.fromBytes(ensureBytes("sig",t),c);if(!1===l)return!1;try{const t=e.fromBytes(r);if(s&&l.hasHighS())return!1;const{r:o,s:a}=l,c=v(n),d=i.inv(a),u=i.create(c*d),h=i.create(o*d),f=e.BASE.multiplyUnsafe(u).add(t.multiplyUnsafe(h));if(f.is0())return!1;return i.create(f.x)===o}catch(e){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:r}=validateSigOpts(n,p);return t=x(t,r),y.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:y,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(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(n.Fn.ORDER,n.Fn.BITS))})}function weierstrass(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=_ecdsa_legacy_opts_to_new(e);return _ecdsa_new_output_to_legacy(e,ecdsa(weierstrassN(t,n),r,o))}
|
|
16
26
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function createCurve(e,t){const n=t=>weierstrass({...e,hash:t});return{...n(t),create:n}}
|
|
17
|
-
/*! 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")]]},_2n=BigInt(2);function sqrtMod(e){const t=secp256k1_CURVE.p,n=BigInt(3),
|
|
18
|
-
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function isBytes(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function abytes(e,...t){if(!isBytes(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 isArrayOf(e,t){return!!Array.isArray(t)&&(0===t.length||(e?t.every((e=>"string"==typeof e)):t.every((e=>Number.isSafeInteger(e)))))}function astr(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function anumber(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function aArr(e){if(!Array.isArray(e))throw new Error("array expected")}function astrArr(e,t){if(!isArrayOf(!0,t))throw new Error(`${e}: array of strings expected`)}function anumArr(e,t){if(!isArrayOf(!1,t))throw new Error(`${e}: array of numbers expected`)}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){const t="string"==typeof e?e.split(""):e,n=t.length;astrArr("alphabet",t);const o=new Map(t.map(((e,t)=>[e,t])));return{encode:o=>(aArr(o),o.map((o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]}))),decode:t=>(aArr(t),t.map((t=>{astr("alphabet.decode",t);const n=o.get(t);if(void 0===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})))}}function join(e=""){return astr("join",e),{encode:t=>(astrArr("join.decode",t),t.join(e)),decode:t=>(astr("join.decode",t),t.split(e))}}function padding(e,t="="){return anumber(e),astr("padding",t),{encode(n){for(astrArr("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){astrArr("padding.decode",n);let o=n.length;if(o*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;o>0&&n[o-1]===t;o--){if((o-1)*e%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,o)}}}const gcd=(e,t)=>0===t?e:gcd(t,e%t),radix2carry=(e,t)=>e+(t-gcd(e,t)),powers=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function convertRadix2(e,t,n,o){if(aArr(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(radix2carry(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${radix2carry(t,n)}`);let r=0,s=0;const i=powers[t],a=powers[n]-1,c=[];for(const o of e){if(anumber(o),o>=i)throw new Error(`convertRadix2: invalid data word=${o} from=${t}`);if(r=r<<t|o,s+t>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)c.push((r>>s-n&a)>>>0);const e=powers[s];if(void 0===e)throw new Error("invalid carry");r&=e-1}if(r=r<<n-s&a,!o&&s>=t)throw new Error("Excess padding");if(!o&&r>0)throw new Error(`Non-zero padding: ${r}`);return o&&s>0&&c.push(r>>>0),c}function radix2(e,t=!1){if(anumber(e),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=>(anumArr("radix2.decode",n),Uint8Array.from(convertRadix2(n,e,8,t)))}}const hasBase64Builtin=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)(),decodeBase64Builtin=(e,t)=>{astr("base64",e);if(e.length>0&&!/^[A-Za-z0-9=+/]+$/.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:"base64",lastChunkHandling:"strict"})},base64=hasBase64Builtin?{encode:e=>(abytes(e),e.toBase64()),decode:e=>decodeBase64Builtin(e)}:chain(radix2(6),alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),padding(6),join("")),decoder=new TextDecoder,u={minPlaintextSize:1,maxPlaintextSize:65535,utf8Encode:utf8ToBytes,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 o=concatBytes(n,t);return hmac(sha256,e,o)},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 o=n.length;if(o<99||o>65603)throw new Error("invalid data length: "+o);const r=n[0];if(2!==r)throw new Error("unknown encryption version "+r);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:o,chacha_nonce:r,hmac_key:s}=u.getMessageKeys(t,n),i=u.pad(e),a=chacha20(o,r,i),c=u.hmacAad(s,a,n);return base64.encode(concatBytes(new Uint8Array([2]),n,a,c))}function decryptNip44(e,t){const{nonce:n,ciphertext:o,mac:r}=u.decodePayload(e),{chacha_key:s,chacha_nonce:i,hmac_key:a}=u.getMessageKeys(t,n);if(!equalBytes(u.hmacAad(a,o,n),r))throw new Error("invalid MAC");const c=chacha20(s,i,o);return u.unpad(c)}class Nip44{cache=new Map;createKey(e,t){return u.getConversationKey(e,t)}getKey(e,t,n){const o=getPublicKey(hexToBytes(e))+t;let r=this.cache.get(o);if(r)return r;const s=this.createKey(e,t);return this.cache.set(o,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{nip44Codec=new Nip44;privateKey;_secretKey;pubkey;constructor(e){this.privateKey=e,this._secretKey=hexToBytes(e),this.pubkey=getPublicKey(this._secretKey)}async sign(e){const t={kind:e.kind,created_at:e.created_at,tags:e.tags,content:e.content};return finalizeEvent(t,this._secretKey).sig}async user(){return{pubkey:this.pubkey}}async encrypt(e,t){return nip04_exports.encrypt(this.privateKey,e.pubkey,t)}async decrypt(e,t){return nip04_exports.decrypt(this.privateKey,e.pubkey,t)}encryptNip44(e,t){return Promise.resolve(this.nip44Codec.encrypt(this.privateKey,e.pubkey,t))}decryptNip44(e,t){return Promise.resolve(this.nip44Codec.decrypt(this.privateKey,e.pubkey,t))}}const OUTBOX_RELAYS=["wss://user.kindpag.es","wss://purplepag.es","wss://relay.nos.social"],NOSTRCONNECT_APPS=[{name:"Nsec.app",domain:"nsec.app",canImport:!0,img:"https://nsec.app/assets/favicon.ico",link:"https://use.nsec.app/<nostrconnect>"},{name:"Amber",img:"https://raw.githubusercontent.com/greenart7c3/Amber/refs/heads/master/assets/android-icon.svg",link:"<nostrconnect>"},{name:"Other key stores",img:"",link:"<nostrconnect>"}],nostrJsonCache=new Map,NOSTR_JSON_CACHE_TTL=3e5,NOSTR_JSON_FETCH_TIMEOUT=5e3;async function fetchNostrJson(e){const t=nostrJsonCache.get(e);if(t&&Date.now()-t.timestamp<NOSTR_JSON_CACHE_TTL)return t.data;const n=new AbortController,o=setTimeout((()=>n.abort()),NOSTR_JSON_FETCH_TIMEOUT);try{const t=await(await fetch(`https://${e}/.well-known/nostr.json`,{signal:n.signal})).json();return nostrJsonCache.set(e,{data:t,timestamp:Date.now()}),t}finally{clearTimeout(o)}}function generatePrivateKey(){return bytesToHex(generateSecretKey())}class AuthNostrService extends lib.EventEmitter{pool;profilePool;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.pool=new RelayPool,this.profilePool=new RelayPool;for(const e of OUTBOX_RELAYS)this.profilePool.addRelay(e);this.profilePool.connect().catch((e=>console.warn("profilePool connect failed",e))),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(){console.log("cancelNostrConnect called"),this.releaseSigner(),this.resetAuth(),this.signerErrCallback&&(this.signerErrCallback("cancelled"),this.signerErrCallback=void 0)}cancelSignerInit(){this.cancelNostrConnect()}cancelPendingRequests(){if(console.log("cancelPendingRequests called (signer preserved)"),this.signer&&this.signer.rpc)try{this.signer.rpc.clearPendingRequests?.()}catch(e){console.warn("Failed to clear pending requests",e)}}async nostrConnect(e,{domain:t="",link:n="",iframeUrl:o="",importConnect:r=!1,customRelays:s}={}){console.log("[nostrConnect] Called",{relay:e,domain:t,link:n,iframeUrl:o,importConnect:r,customRelays:s});const i=s&&s.length>0?s:e?[e]:DEFAULT_NIP46_RELAYS,a={authMethod:"connect",pubkey:"",signerPubkey:"",sk:this.nostrConnectKey,domain:t,relays:i,iframeUrl:o};console.log("[nostrConnect] Created info",a,n),n&&!o&&(console.log("[nostrConnect] Opening Amber"),window.open(n,"_blank","width=400,height=700"));try{console.log("[nostrConnect] Calling initSigner with listen=true"),await this.initSigner(a,{listen:!0}),this.signerPromise&&(console.log("[nostrConnect] Waiting for signerPromise to complete"),await this.signerPromise,console.log("[nostrConnect] signerPromise completed"))}catch(e){throw console.error("[nostrConnect] Failed to initialize signer:",e),new Error(`Connection failed: ${e instanceof Error?e.message:"Unknown error"}`)}if(console.log("[nostrConnect] Checking pubkeys",{pubkey:a.pubkey,signerPubkey:a.signerPubkey}),!a.pubkey||!a.signerPubkey)throw console.error("[nostrConnect] Missing pubkeys after initialization"),new Error("Failed to get pubkey from signer");const c=i.map((e=>`relay=${encodeURIComponent(e)}`)).join("&");return a.bunkerUrl=`bunker://${a.signerPubkey}?${c}`,console.log("[nostrConnect] Generated bunkerUrl",a.bunkerUrl),r||(console.log("[nostrConnect] Calling onAuth"),this.onAuth("login",a)),console.log("[nostrConnect] Completed successfully"),a}async createNostrConnect(){this.nostrConnectKey=generatePrivateKey(),this.nostrConnectSecret=Math.random().toString(36).substring(7);const e=getPublicKey(hexToBytes(this.nostrConnectKey)),t=encodeURIComponent(document.location.host),n=encodeURIComponent(document.location.origin);return`nostrconnect://${e}?image=${encodeURIComponent(await getIcon())}&url=${n}&name=${t}&perms=${encodeURIComponent(this.params.optionsModal.perms||"")}&secret=${this.nostrConnectSecret}`}async getNostrConnectServices(e,t){const n=await this.createNostrConnect(),o=NOSTRCONNECT_APPS.map((e=>({...e}))),r=e&&e.length>0?e:DEFAULT_NIP46_RELAYS;for(const e of o)if(e.link.startsWith("https://")){e.available="loading";const t=r.map((e=>`&relay=${encodeURIComponent(e)}`)).join("");e.link=n+t}else{e.available=!0;const t=r.map((e=>`&relay=${encodeURIComponent(e)}`)).join(""),o=n+t;e.link=e.link.replace("<nostrconnect>",o)}t&&t([...o.map((e=>({...e})))]);const s=o.filter((e=>"loading"===e.available)).map((async s=>{const i=s.domain||"";try{const t=await fetchNostrJson(i),o=t.names._;let a=r;const c=t.nip46[o];!c||!c.length||e&&0!==e.length||(a=c),s.iframeUrl=t.nip46.iframe_url||"";const l=a.map((e=>`&relay=${encodeURIComponent(e)}`)).join(""),d=n+l;s.link=s.iframeUrl?d:s.link,s.available=!0}catch(e){console.log("Service unavailable",i,e),s.available=!1}t&&t([...o.map((e=>({...e})))])}));return await Promise.all(s),[n,o]}async localSignup(e,t){const n=!t;t=t||generatePrivateKey();const o={pubkey:getPublicKey(hexToBytes(t)),sk:t,name:e,authMethod:"local"};console.log(`localSignup name: ${e}`),await this.setLocal(o,n)}async setLocal(e,t){this.releaseSigner(),this.localSigner=new PrivateKeySigner(e.sk),t&&await createProfile(e,this.profilePool,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(hexToBytes(this.localSigner.privateKey))}async importAndConnect(e){const{relay:t,domain:n,link:o,iframeUrl:r}=e;if(!n)throw new Error("Domain required");const s=await this.nostrConnect(t,{domain:n,link:o,importConnect:!0,iframeUrl:r});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();try{if(await this.startAuth(),await this.initSigner(e,{connect:!0}),!e.pubkey||!e.signerPubkey)throw new Error("Failed to initialize signer: missing pubkey");this.onAuth("login",e),await this.endAuth()}catch(e){throw console.error("Failed to set connect:",e),this.resetAuth(),this.releaseSigner(),e}}async createAccount(e){const[t,n]=e.split("@"),o=await getBunkerUrl(`_@${n}`,this.params.optionsModal);console.log("create account bunker's url",o);const r=bunkerUrlToInfo(o);if(!r.signerPubkey)throw new Error("Bad bunker url");const s=Boolean(this.params.userInfo);await this.initSigner(r,{eventToAddAccount:s});return{bunkerUrl:`bunker://${await this.signer.createAccount2({bunkerPubkey:r.signerPubkey,name:t,domain:n,perms:this.params.optionsModal.perms})}?relay=${r.relays?.[0]}`,sk:r.sk}}releaseSigner(){if(console.log("releaseSigner called"),this.signer&&this.signer.rpc){try{this.signer.rpc.clearPendingRequests?.()}catch(e){console.warn("Failed to clear pending requests",e)}try{this.signer.rpc.stop?.()}catch(e){console.warn("Failed to stop RPC subscription",e)}}this.signer=null,this.signerErrCallback&&(this.signerErrCallback("cancelled"),this.signerErrCallback=void 0),this.localSigner=null,this.pool.removeAllRelays(),this.signerPromise=void 0}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(hexToBytes(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.profilePool).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):"",o={type:e};"logout"===e?(this.iframe&&this.iframe.remove(),this.iframe=void 0):(o.pubkey=t.pubkey,o.name=t.name,t.sk&&(o.localNsec=nip19_exports.nsecEncode(hexToBytes(t.sk))),t.relays&&(o.relays=t.relays),t.otpData&&(o.otpData=t.otpData),o.method=t.authMethod||"connect");const r=new CustomEvent("nlAuth",{detail:o});console.log("nostr-login auth",o),document.dispatchEvent(r),this.params.optionsModal.onAuth&&this.params.optionsModal.onAuth(n,o)}catch(e){console.log("onAuth error",e)}}async createIframe(e){if(!e)return;const t=new URL(e);let n;const o="__nostr-login-worker-iframe-"+t.hostname.replaceAll(".","-");n=document.querySelector(`#${o}`),console.log("iframe",o,n),n||(n=document.createElement("iframe"),n.setAttribute("width","0"),n.setAttribute("height","0"),n.setAttribute("border","0"),n.style.display="none",n.id=o,document.body.append(n)),n.setAttribute("src",e);const r=new ReadyListener(["workerReady","workerError"],t.origin);await new Promise((e=>{n.addEventListener("load",e)}));const s=await r.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(){console.log("startAuth"),this.readyCallback&&(console.log("startAuth: previous auth still active, cancelling it first"),this.cancelNostrConnect()),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(),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:o=!1}={}){if(this.signerPromise)try{await this.signerPromise}catch(e){"cancelled"!==e&&console.error("Previous signer promise failed:",e)}console.log("initSigner info",e);const r=e.iframeUrl?new URL(e.iframeUrl).origin:void 0;return r&&(this.starterReady=new ReadyListener(["starterDone","starterError"],r)),this.emit("onIframeUrl",e.iframeUrl),this.signerPromise=new Promise((async(s,i)=>{this.signerErrCallback=e=>{console.log("Signer initialization cancelled or failed:",e),i(e)};try{if(e.relays&&!e.iframeUrl)for(const t of e.relays)this.pool.addRelay(t);await this.pool.connect(1e4);const i=new PrivateKeySigner(e.sk);this.signer=new Nip46Signer(this.pool,i,e.signerPubkey,r),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:o})})),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.bunkerPubkey,console.log("Signer initialized successfully. User pubkey:",e.pubkey,"Signer pubkey:",e.signerPubkey),this.signerErrCallback=void 0,s()}catch(e){console.error("initSigner failure",e),this.signer=null,this.signerErrCallback=void 0,i(e)}})),this.signerPromise}async authNip46(e,{name:t,bunkerUrl:n,sk:o="",domain:r="",iframeUrl:s="",customRelays:i}){try{const a=bunkerUrlToInfo(n,o);if(isBunkerUrl(t)?a.bunkerUrl=t:(a.nip05=t,a.domain=t.split("@")[1]),r&&(a.domain=r),s&&(a.iframeUrl=s),i&&i.length>0&&(a.relays=i),!a.signerPubkey||!a.sk||!a.relays?.[0])throw new Error(`Bad bunker url ${n}`);const c=Boolean(this.params.userInfo);console.log("authNip46",e,a),await this.initSigner(a,{connect:!0,eventToAddAccount:c}),this.onAuth(e,a)}catch(e){throw console.error("nostr login auth failed",e),e}}async signEvent(e){if(this.localSigner)return e.pubkey=this.localSigner.pubkey,e.id=getEventHash(e),e.sig=await this.localSigner.sign(e),console.log("signed (local)",{event:e}),e;let t;for(let n=0;n<=2;n++)try{if(!this.signer)throw new Error("Signer is not initialized. Please reconnect.");await this.ensureRelayConnection(),e.pubkey=this.signer.userPubkey,e.id=getEventHash(e);const t=await(this.signer?.sign(e));return"object"==typeof t&&t.sig?(e.pubkey=t.pubkey||e.pubkey,e.id=t.id||e.id,e.sig=t.sig):e.sig=t,console.log("signed",{event:e,attempt:n}),e}catch(e){t=e;const o=e instanceof Nip46Error&&"SIGNER_REJECTED"===e.code,r=e instanceof Error&&("Cancelled by user"===e.message||"cancelled"===e.message);if(n<2&&!o&&!r){console.warn(`signEvent attempt ${n+1}/3 failed, retrying...`,e);try{await this.forceReconnect()}catch(e){console.warn("forceReconnect failed during retry, will try sign anyway",e)}continue}break}throw t}async forceReconnect(){console.log("forceReconnect: forcing clean relay reconnection..."),this.pool.disconnectAll(),this.ensureRelaysInPool(),await this.pool.connect(1e4),await this.waitForAtLeastOneRelay(8e3),await this.ensureSubscription()}async ensureRelayConnection(){this.ensureRelaysInPool();const e=this.pool.isAnyConnected(),t=!this.signer?.rpc||!1!==this.signer.rpc.isSubscriptionActive?.();e?t||(console.log("ensureRelayConnection: relay connected but subscription dead, resubscribing..."),await this.ensureSubscription()):(console.log("ensureRelayConnection: relay disconnected, forcing clean reconnect..."),this.pool.disconnectAll(),this.ensureRelaysInPool(),await this.pool.connect(1e4),await this.waitForAtLeastOneRelay(8e3),await this.ensureSubscription())}ensureRelaysInPool(){if(0===this.pool.relayUrls.length){console.warn("ensureRelaysInPool: no relays in pool, adding relays");const e=this.params.userInfo?.relays?.length?this.params.userInfo.relays:DEFAULT_NIP46_RELAYS;for(const t of e)this.pool.addRelay(t)}}async ensureSubscription(){if(this.signer&&this.signer.rpc)try{this.signer.rpc.resubscribe?.(),console.log("ensureSubscription: subscription re-established")}catch(e){console.warn("ensureSubscription: failed to resubscribe",e)}}async waitForAtLeastOneRelay(e){const t=Date.now();for(;Date.now()-t<e;){if(this.pool.isAnyConnected())return;await new Promise((e=>setTimeout(e,300)))}if(!this.pool.isAnyConnected())throw new Nip46Error("Failed to connect to any relay","RELAY_DISCONNECTED")}async codec_call(e,t,n){return new Promise(((o,r)=>{this.signer.rpc.sendRequest(this.signer.bunkerPubkey,e,[t,n],24133,(e=>{e.error?e.error.includes("timeout")||"Request timeout"===e.error?r(new Nip46Error(e.error,"TIMEOUT")):r(new Nip46Error(e.error,"SIGNER_REJECTED")):o(e.result)}))}))}async encrypt04(e,t){return await this.ensureRelayConnection(),this.localSigner?this.localSigner.encrypt({pubkey:e},t):this.signer.encrypt(e,t)}async decrypt04(e,t){return await this.ensureRelayConnection(),this.localSigner?this.localSigner.decrypt({pubkey:e},t):this.codec_call("nip04_decrypt",e,t)}async encrypt44(e,t){return await this.ensureRelayConnection(),this.localSigner?this.nip44Codec.encrypt(this.localSigner.privateKey,e,t):this.codec_call("nip44_encrypt",e,t)}async decrypt44(e,t){return await this.ensureRelayConnection(),this.localSigner?this.nip44Codec.decrypt(this.localSigner.privateKey,e,t):this.codec_call("nip44_decrypt",e,t)}}function loadCustomNip46Relays(){try{const e=localStorage.getItem("customNip46Relays");if(e){const t=JSON.parse(e);if(Array.isArray(t)&&t.length>0)return t}}catch(e){console.error("Failed to load custom relays from localStorage",e)}return[...DEFAULT_NIP46_RELAYS]}class ModalManager extends lib.EventEmitter{modal=null;params;extensionService;authNostrService;launcherPromise;accounts=[];recents=[];opt;customNip46Relays=loadCustomNip46Relays();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.customNip46Relays=loadCustomNip46Relays(),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,t.appendChild(this.modal),document.body.appendChild(t),this.authNostrService.getNostrConnectServices(this.customNip46Relays,(e=>{this.modal&&(this.modal.connectionStringServices=e)})).then((([e,t])=>{this.modal&&(this.modal.connectionString=e,this.modal.connectionStringServices=t)})).catch((e=>{console.log("Failed to load nostr connect services",e)}));let n="";return this.launcherPromise=new Promise(((e,o)=>{t.addEventListener("close",(()=>{o(new Error("Closed")),this.authNostrService.resetAuth(),this.modal&&(document.body.removeChild(this.modal.parentNode),this.modal=null)}));const r=async e=>{this.modal&&(this.modal.isLoading=!1),await this.authNostrService.endAuth(),e(),t.close(),this.modal=null},s=async(t,n)=>{this.modal&&(this.modal.isLoading=!0);try{n&&!n.start||await this.authNostrService.startAuth(),await t(),n&&!n.end||await r(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,customRelays:this.customNip46Relays})}))},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,console.log("nostrconnect authUrl",this.modal.authUrl,this.modal.iframeUrl)),await this.authNostrService.importAndConnect(e)}))},d=async e=>{await s((async()=>{const{relay:t,domain:n,link:o,iframeUrl:r}=e||{};console.log("nostrConnect",e,t,n,o,r),this.modal&&r&&(this.modal.authUrl=o,this.modal.iframeUrl=r,console.log("nostrconnect authUrl",this.modal.authUrl,this.modal.iframeUrl)),!e&&this.modal&&(this.modal.isLoading=!1),await this.authNostrService.nostrConnect(t,{domain:n,link:o,iframeUrl:r,customRelays:this.customNip46Relays})}))},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("&","&"),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("",bytesToHex(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("nlRelaysChanged",(async e=>{if(this.customNip46Relays=e.detail,console.log("Custom Nip46 relays updated:",this.customNip46Relays),this.modal){const e=this.modal;await this.authNostrService.getNostrConnectServices(this.customNip46Relays,(t=>{e.connectionStringServices=t})).then((([t,n])=>{e.connectionString=t,e.connectionStringServices=n}))}})),this.modal.addEventListener("nlSignup",(e=>{a(e.detail)})),this.modal.addEventListener("nlLocalSignup",(e=>{h(e.detail)})),this.modal.addEventListener("nlLoginNsec",(async e=>{await s((async()=>{const t=e.detail;if(!t)throw new Error("Please enter your nsec");let n;try{n=nip19_exports.decode(t)}catch(e){throw new Error("Invalid nsec format")}if("nsec"!==n.type)throw new Error("Invalid key type, expected nsec");await this.authNostrService.localSignup("",bytesToHex(n.data))}))})),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=>{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 f=async e=>{let t="";if(e.includes("@")){const{error:n,pubkey:o}=await checkNip05(e);if(!o)throw new Error(n);t=o}else if(e.startsWith("npub")){const{type:n,data:o}=nip19_exports.decode(e);if("npub"!==n)throw new Error("Bad npub");t=o}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,o=await f(t),r=this.opt.otpRequestUrl+(this.opt.otpRequestUrl.includes("?")?"&":"?")+"pubkey="+o,s=await fetch(r);if(200!==s.status)throw console.warn("nostr-login: bad otp reply",s),new Error("Failed to send DM");this.modal.isOTP=!0,n=o,this.modal.isLoading=!1}),{start:!0})})),this.modal.addEventListener("nlLoginOTPCode",(async e=>{await s((async()=>{if(!this.modal)return;const t=e.detail,o=this.opt.otpReplyUrl+(this.opt.otpRequestUrl.includes("?")?"&":"?")+"pubkey="+n+"&code="+t,r=await fetch(o);if(200!==r.status)throw console.warn("nostr-login: bad otp reply",r),new Error("Invalid code");const s=await r.text();this.authNostrService.setOTP(n,s),this.modal.isOTP=!1}),{end:!0})})),this.modal.addEventListener("nlCheckSignup",(async e=>{const{available:t,taken:n,error:o}=await checkNip05(e.detail);this.modal&&(this.modal.error=String(o),!o&&n&&(this.modal.error="Already taken"),this.modal.signupNameIsAvailable=t)})),this.modal.addEventListener("nlCheckLogin",(async e=>{const{available:t,taken:n,error:o}=await checkNip05(e.detail);this.modal&&(this.modal.error=String(o),t&&(this.modal.error="Name not found"),this.modal.loginIsGood=n)}));const p=()=>{this.modal&&(this.modal.isLoading=!1),this.authNostrService.isAuthing()&&this.authNostrService.cancelSignerInit(),t.close(),o(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 o=0;o<n.length;o++){const r=n[o].getAttribute("nl-theme"),s=n[o].getAttribute("start-screen"),i={...e};switch(r&&(i.theme=r),s){case"login":case"login-bunker-url":case"login-read-only":case"signup":case"switch-account":case"welcome":i.startScreen=s}n[o].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.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{}}}class ProcessManager extends lib.EventEmitter{callCount=0;callTimer;pendingCalls=new Map;callIdCounter=0;constructor(){super()}cancelAllPendingCalls(){for(const[e,{reject:t}]of this.pendingCalls.entries())t(new Error("Cancelled by user"));this.pendingCalls.clear(),this.callTimer&&(clearTimeout(this.callTimer),this.callTimer=void 0),this.callCount=0}onAuthUrl(){this.callTimer&&(clearTimeout(this.callTimer),this.callTimer=setTimeout((()=>this.emit("onCallTimeout")),AUTH_URL_CALL_TIMEOUT))}onIframeUrl(){Boolean(this.callTimer)&&clearTimeout(this.callTimer)}async wait(e){this.callTimer||(this.callTimer=setTimeout((()=>this.emit("onCallTimeout")),CALL_TIMEOUT)),this.callCount||this.emit("onCallStart"),this.callCount++;const t=this.callIdCounter++;let n,o;try{o=await new Promise((async(n,o)=>{this.pendingCalls.set(t,{reject:o});try{const o=await e();this.pendingCalls.delete(t),n(o)}catch(e){this.pendingCalls.delete(t),o(e)}}))}catch(e){n=e}if(this.callCount--,this.emit("onCallEnd"),this.callTimer&&clearTimeout(this.callTimer),this.callTimer=void 0,n)throw n;return o}}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)})),this.bannerManager.on("cancelTimeout",(()=>{this.authNostrService.cancelPendingRequests(),this.processManager.cancelAllPendingCalls(),this.bannerManager.onCallEnd()}))}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(),o={...this.params.optionsModal};e&&"default"!==e?o.startScreen=e:(Boolean(t?.length)||Boolean(n?.length))&&(o.startScreen="switch-account"),this.customLaunchCallback&&this.authNostrService.cancelNostrConnect();try{await this.modalManager.launch(o),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)}));const createWorker=()=>new Worker(URL.createObjectURL(new Blob(['class x{constructor(a,b){this.width=b;this.height=a.length/b;this.data=a}static createEmpty(a,b){return new x(new Uint8ClampedArray(a*b),a)}get(a,b){return 0>a||a>=this.width||0>b||b>=this.height?!1:!!this.data[b*this.width+a]}set(a,b,c){this.data[b*this.width+a]=c?1:0}setRegion(a,b,c,d,e){for(let f=b;f<b+d;f++)for(let g=a;g<a+c;g++)this.set(g,f,!!e)}}\nclass A{constructor(a,b,c){this.width=a;a*=b;if(c&&c.length!==a)throw Error("Wrong buffer size");this.data=c||new Uint8ClampedArray(a)}get(a,b){return this.data[b*this.width+a]}set(a,b,c){this.data[b*this.width+a]=c}}\nclass ba{constructor(a){this.bitOffset=this.byteOffset=0;this.bytes=a}readBits(a){if(1>a||32<a||a>this.available())throw Error("Cannot read "+a.toString()+" bits");var b=0;if(0<this.bitOffset){b=8-this.bitOffset;var c=a<b?a:b;b-=c;b=(this.bytes[this.byteOffset]&255>>8-c<<b)>>b;a-=c;this.bitOffset+=c;8===this.bitOffset&&(this.bitOffset=0,this.byteOffset++)}if(0<a){for(;8<=a;)b=b<<8|this.bytes[this.byteOffset]&255,this.byteOffset++,a-=8;0<a&&(c=8-a,b=b<<a|(this.bytes[this.byteOffset]&255>>c<<c)>>c,\nthis.bitOffset+=a)}return b}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var B,C=B||(B={});C.Numeric="numeric";C.Alphanumeric="alphanumeric";C.Byte="byte";C.Kanji="kanji";C.ECI="eci";C.StructuredAppend="structuredappend";var D,E=D||(D={});E[E.Terminator=0]="Terminator";E[E.Numeric=1]="Numeric";E[E.Alphanumeric=2]="Alphanumeric";E[E.Byte=4]="Byte";E[E.Kanji=8]="Kanji";E[E.ECI=7]="ECI";E[E.StructuredAppend=3]="StructuredAppend";let F="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".split("");\nfunction ca(a,b){let c=[],d="";b=a.readBits([8,16,16][b]);for(let e=0;e<b;e++){let f=a.readBits(8);c.push(f)}try{d+=decodeURIComponent(c.map(e=>`%${("0"+e.toString(16)).substr(-2)}`).join(""))}catch(e){}return{bytes:c,text:d}}\nfunction da(a,b){a=new ba(a);let c=9>=b?0:26>=b?1:2;for(b={text:"",bytes:[],chunks:[],version:b};4<=a.available();){var d=a.readBits(4);if(d===D.Terminator)return b;if(d===D.ECI)0===a.readBits(1)?b.chunks.push({type:B.ECI,assignmentNumber:a.readBits(7)}):0===a.readBits(1)?b.chunks.push({type:B.ECI,assignmentNumber:a.readBits(14)}):0===a.readBits(1)?b.chunks.push({type:B.ECI,assignmentNumber:a.readBits(21)}):b.chunks.push({type:B.ECI,assignmentNumber:-1});else if(d===D.Numeric){var e=a,f=[];d="";for(var g=\ne.readBits([10,12,14][c]);3<=g;){var h=e.readBits(10);if(1E3<=h)throw Error("Invalid numeric value above 999");var k=Math.floor(h/100),m=Math.floor(h/10)%10;h%=10;f.push(48+k,48+m,48+h);d+=k.toString()+m.toString()+h.toString();g-=3}if(2===g){g=e.readBits(7);if(100<=g)throw Error("Invalid numeric value above 99");e=Math.floor(g/10);g%=10;f.push(48+e,48+g);d+=e.toString()+g.toString()}else if(1===g){e=e.readBits(4);if(10<=e)throw Error("Invalid numeric value above 9");f.push(48+e);d+=e.toString()}b.text+=\nd;b.bytes.push(...f);b.chunks.push({type:B.Numeric,text:d})}else if(d===D.Alphanumeric){e=a;f=[];d="";for(g=e.readBits([9,11,13][c]);2<=g;)m=e.readBits(11),k=Math.floor(m/45),m%=45,f.push(F[k].charCodeAt(0),F[m].charCodeAt(0)),d+=F[k]+F[m],g-=2;1===g&&(e=e.readBits(6),f.push(F[e].charCodeAt(0)),d+=F[e]);b.text+=d;b.bytes.push(...f);b.chunks.push({type:B.Alphanumeric,text:d})}else if(d===D.Byte)d=ca(a,c),b.text+=d.text,b.bytes.push(...d.bytes),b.chunks.push({type:B.Byte,bytes:d.bytes,text:d.text});\nelse if(d===D.Kanji){f=a;d=[];e=f.readBits([8,10,12][c]);for(g=0;g<e;g++)k=f.readBits(13),k=Math.floor(k/192)<<8|k%192,k=7936>k?k+33088:k+49472,d.push(k>>8,k&255);f=(new TextDecoder("shift-jis")).decode(Uint8Array.from(d));b.text+=f;b.bytes.push(...d);b.chunks.push({type:B.Kanji,bytes:d,text:f})}else d===D.StructuredAppend&&b.chunks.push({type:B.StructuredAppend,currentSequence:a.readBits(4),totalSequence:a.readBits(4),parity:a.readBits(8)})}if(0===a.available()||0===a.readBits(a.available()))return b}\nclass G{constructor(a,b){if(0===b.length)throw Error("No coefficients.");this.field=a;let c=b.length;if(1<c&&0===b[0]){let d=1;for(;d<c&&0===b[d];)d++;if(d===c)this.coefficients=a.zero.coefficients;else for(this.coefficients=new Uint8ClampedArray(c-d),a=0;a<this.coefficients.length;a++)this.coefficients[a]=b[d+a]}else this.coefficients=b}degree(){return this.coefficients.length-1}isZero(){return 0===this.coefficients[0]}getCoefficient(a){return this.coefficients[this.coefficients.length-1-a]}addOrSubtract(a){if(this.isZero())return a;\nif(a.isZero())return this;let b=this.coefficients;a=a.coefficients;b.length>a.length&&([b,a]=[a,b]);let c=new Uint8ClampedArray(a.length),d=a.length-b.length;for(var e=0;e<d;e++)c[e]=a[e];for(e=d;e<a.length;e++)c[e]=b[e-d]^a[e];return new G(this.field,c)}multiply(a){if(0===a)return this.field.zero;if(1===a)return this;let b=this.coefficients.length,c=new Uint8ClampedArray(b);for(let d=0;d<b;d++)c[d]=this.field.multiply(this.coefficients[d],a);return new G(this.field,c)}multiplyPoly(a){if(this.isZero()||\na.isZero())return this.field.zero;let b=this.coefficients,c=b.length;a=a.coefficients;let d=a.length,e=new Uint8ClampedArray(c+d-1);for(let f=0;f<c;f++){let g=b[f];for(let h=0;h<d;h++)e[f+h]=H(e[f+h],this.field.multiply(g,a[h]))}return new G(this.field,e)}multiplyByMonomial(a,b){if(0>a)throw Error("Invalid degree less than 0");if(0===b)return this.field.zero;let c=this.coefficients.length;a=new Uint8ClampedArray(c+a);for(let d=0;d<c;d++)a[d]=this.field.multiply(this.coefficients[d],b);return new G(this.field,\na)}evaluateAt(a){let b=0;if(0===a)return this.getCoefficient(0);let c=this.coefficients.length;if(1===a)return this.coefficients.forEach(d=>{b^=d}),b;b=this.coefficients[0];for(let d=1;d<c;d++)b=H(this.field.multiply(a,b),this.coefficients[d]);return b}}function H(a,b){return a^b}\nclass ea{constructor(a,b,c){this.primitive=a;this.size=b;this.generatorBase=c;this.expTable=Array(this.size);this.logTable=Array(this.size);a=1;for(b=0;b<this.size;b++)this.expTable[b]=a,a*=2,a>=this.size&&(a=(a^this.primitive)&this.size-1);for(a=0;a<this.size-1;a++)this.logTable[this.expTable[a]]=a;this.zero=new G(this,Uint8ClampedArray.from([0]));this.one=new G(this,Uint8ClampedArray.from([1]))}multiply(a,b){return 0===a||0===b?0:this.expTable[(this.logTable[a]+this.logTable[b])%(this.size-1)]}inverse(a){if(0===\na)throw Error("Can\'t invert 0");return this.expTable[this.size-this.logTable[a]-1]}buildMonomial(a,b){if(0>a)throw Error("Invalid monomial degree less than 0");if(0===b)return this.zero;a=new Uint8ClampedArray(a+1);a[0]=b;return new G(this,a)}log(a){if(0===a)throw Error("Can\'t take log(0)");return this.logTable[a]}exp(a){return this.expTable[a]}}\nfunction fa(a,b,c,d){b.degree()<c.degree()&&([b,c]=[c,b]);let e=a.zero;for(var f=a.one;c.degree()>=d/2;){var g=b;let h=e;b=c;e=f;if(b.isZero())return null;c=g;f=a.zero;g=b.getCoefficient(b.degree());for(g=a.inverse(g);c.degree()>=b.degree()&&!c.isZero();){let k=c.degree()-b.degree(),m=a.multiply(c.getCoefficient(c.degree()),g);f=f.addOrSubtract(a.buildMonomial(k,m));c=c.addOrSubtract(b.multiplyByMonomial(k,m))}f=f.multiplyPoly(e).addOrSubtract(h);if(c.degree()>=b.degree())return null}d=f.getCoefficient(0);\nif(0===d)return null;a=a.inverse(d);return[f.multiply(a),c.multiply(a)]}\nfunction ha(a,b){let c=new Uint8ClampedArray(a.length);c.set(a);a=new ea(285,256,0);var d=new G(a,c),e=new Uint8ClampedArray(b),f=!1;for(var g=0;g<b;g++){var h=d.evaluateAt(a.exp(g+a.generatorBase));e[e.length-1-g]=h;0!==h&&(f=!0)}if(!f)return c;d=new G(a,e);d=fa(a,a.buildMonomial(b,1),d,b);if(null===d)return null;b=d[0];g=b.degree();if(1===g)b=[b.getCoefficient(1)];else{e=Array(g);f=0;for(h=1;h<a.size&&f<g;h++)0===b.evaluateAt(h)&&(e[f]=a.inverse(h),f++);b=f!==g?null:e}if(null==b)return null;e=d[1];\nf=b.length;d=Array(f);for(g=0;g<f;g++){h=a.inverse(b[g]);let k=1;for(let m=0;m<f;m++)g!==m&&(k=a.multiply(k,H(1,a.multiply(b[m],h))));d[g]=a.multiply(e.evaluateAt(h),a.inverse(k));0!==a.generatorBase&&(d[g]=a.multiply(d[g],h))}for(e=0;e<b.length;e++){f=c.length-1-a.log(b[e]);if(0>f)return null;c[f]^=d[e]}return c}\nlet I=[{infoBits:null,versionNumber:1,alignmentPatternCenters:[],errorCorrectionLevels:[{ecCodewordsPerBlock:7,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:10,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:16}]},{ecCodewordsPerBlock:13,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:13}]},{ecCodewordsPerBlock:17,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:9}]}]},{infoBits:null,versionNumber:2,alignmentPatternCenters:[6,18],errorCorrectionLevels:[{ecCodewordsPerBlock:10,ecBlocks:[{numBlocks:1,\ndataCodewordsPerBlock:34}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:28}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:22}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:16}]}]},{infoBits:null,versionNumber:3,alignmentPatternCenters:[6,22],errorCorrectionLevels:[{ecCodewordsPerBlock:15,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:55}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:18,\necBlocks:[{numBlocks:2,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:13}]}]},{infoBits:null,versionNumber:4,alignmentPatternCenters:[6,26],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:80}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:32}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:9}]}]},\n{infoBits:null,versionNumber:5,alignmentPatternCenters:[6,30],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:43}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:15},{numBlocks:2,dataCodewordsPerBlock:16}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:11},{numBlocks:2,dataCodewordsPerBlock:12}]}]},{infoBits:null,versionNumber:6,alignmentPatternCenters:[6,\n34],errorCorrectionLevels:[{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:68}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:27}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:15}]}]},{infoBits:31892,versionNumber:7,alignmentPatternCenters:[6,22,38],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:78}]},{ecCodewordsPerBlock:18,\necBlocks:[{numBlocks:4,dataCodewordsPerBlock:31}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:14},{numBlocks:4,dataCodewordsPerBlock:15}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:13},{numBlocks:1,dataCodewordsPerBlock:14}]}]},{infoBits:34236,versionNumber:8,alignmentPatternCenters:[6,24,42],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:97}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:38},\n{numBlocks:2,dataCodewordsPerBlock:39}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:18},{numBlocks:2,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:14},{numBlocks:2,dataCodewordsPerBlock:15}]}]},{infoBits:39577,versionNumber:9,alignmentPatternCenters:[6,26,46],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:36},\n{numBlocks:2,dataCodewordsPerBlock:37}]},{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:16},{numBlocks:4,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:12},{numBlocks:4,dataCodewordsPerBlock:13}]}]},{infoBits:42195,versionNumber:10,alignmentPatternCenters:[6,28,50],errorCorrectionLevels:[{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:68},{numBlocks:2,dataCodewordsPerBlock:69}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,\ndataCodewordsPerBlock:43},{numBlocks:1,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:19},{numBlocks:2,dataCodewordsPerBlock:20}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:15},{numBlocks:2,dataCodewordsPerBlock:16}]}]},{infoBits:48118,versionNumber:11,alignmentPatternCenters:[6,30,54],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:81}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:1,\ndataCodewordsPerBlock:50},{numBlocks:4,dataCodewordsPerBlock:51}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:22},{numBlocks:4,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:12},{numBlocks:8,dataCodewordsPerBlock:13}]}]},{infoBits:51042,versionNumber:12,alignmentPatternCenters:[6,32,58],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:92},{numBlocks:2,dataCodewordsPerBlock:93}]},\n{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:36},{numBlocks:2,dataCodewordsPerBlock:37}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:20},{numBlocks:6,dataCodewordsPerBlock:21}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:14},{numBlocks:4,dataCodewordsPerBlock:15}]}]},{infoBits:55367,versionNumber:13,alignmentPatternCenters:[6,34,62],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:107}]},\n{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:37},{numBlocks:1,dataCodewordsPerBlock:38}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:20},{numBlocks:4,dataCodewordsPerBlock:21}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:11},{numBlocks:4,dataCodewordsPerBlock:12}]}]},{infoBits:58893,versionNumber:14,alignmentPatternCenters:[6,26,46,66],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:115},\n{numBlocks:1,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:40},{numBlocks:5,dataCodewordsPerBlock:41}]},{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:16},{numBlocks:5,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:12},{numBlocks:5,dataCodewordsPerBlock:13}]}]},{infoBits:63784,versionNumber:15,alignmentPatternCenters:[6,26,48,70],errorCorrectionLevels:[{ecCodewordsPerBlock:22,\necBlocks:[{numBlocks:5,dataCodewordsPerBlock:87},{numBlocks:1,dataCodewordsPerBlock:88}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:41},{numBlocks:5,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:24},{numBlocks:7,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:12},{numBlocks:7,dataCodewordsPerBlock:13}]}]},{infoBits:68472,versionNumber:16,alignmentPatternCenters:[6,26,50,\n74],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:98},{numBlocks:1,dataCodewordsPerBlock:99}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:45},{numBlocks:3,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:19},{numBlocks:2,dataCodewordsPerBlock:20}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:15},{numBlocks:13,dataCodewordsPerBlock:16}]}]},{infoBits:70749,\nversionNumber:17,alignmentPatternCenters:[6,30,54,78],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:107},{numBlocks:5,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:46},{numBlocks:1,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:22},{numBlocks:15,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:14},{numBlocks:17,\ndataCodewordsPerBlock:15}]}]},{infoBits:76311,versionNumber:18,alignmentPatternCenters:[6,30,56,82],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:120},{numBlocks:1,dataCodewordsPerBlock:121}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:9,dataCodewordsPerBlock:43},{numBlocks:4,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:22},{numBlocks:1,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,\ndataCodewordsPerBlock:14},{numBlocks:19,dataCodewordsPerBlock:15}]}]},{infoBits:79154,versionNumber:19,alignmentPatternCenters:[6,30,58,86],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:113},{numBlocks:4,dataCodewordsPerBlock:114}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:44},{numBlocks:11,dataCodewordsPerBlock:45}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:21},{numBlocks:4,dataCodewordsPerBlock:22}]},\n{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:9,dataCodewordsPerBlock:13},{numBlocks:16,dataCodewordsPerBlock:14}]}]},{infoBits:84390,versionNumber:20,alignmentPatternCenters:[6,34,62,90],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:107},{numBlocks:5,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:41},{numBlocks:13,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:24},\n{numBlocks:5,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:15},{numBlocks:10,dataCodewordsPerBlock:16}]}]},{infoBits:87683,versionNumber:21,alignmentPatternCenters:[6,28,50,72,94],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:116},{numBlocks:4,dataCodewordsPerBlock:117}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:22},\n{numBlocks:6,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:16},{numBlocks:6,dataCodewordsPerBlock:17}]}]},{infoBits:92361,versionNumber:22,alignmentPatternCenters:[6,26,50,74,98],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:111},{numBlocks:7,dataCodewordsPerBlock:112}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:24},\n{numBlocks:16,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:34,dataCodewordsPerBlock:13}]}]},{infoBits:96236,versionNumber:23,alignmentPatternCenters:[6,30,54,74,102],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:121},{numBlocks:5,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:47},{numBlocks:14,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:24},\n{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:16,dataCodewordsPerBlock:15},{numBlocks:14,dataCodewordsPerBlock:16}]}]},{infoBits:102084,versionNumber:24,alignmentPatternCenters:[6,28,54,80,106],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:117},{numBlocks:4,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:45},{numBlocks:14,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,\necBlocks:[{numBlocks:11,dataCodewordsPerBlock:24},{numBlocks:16,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:30,dataCodewordsPerBlock:16},{numBlocks:2,dataCodewordsPerBlock:17}]}]},{infoBits:102881,versionNumber:25,alignmentPatternCenters:[6,32,58,84,110],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:106},{numBlocks:4,dataCodewordsPerBlock:107}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:47},{numBlocks:13,\ndataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:24},{numBlocks:22,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:15},{numBlocks:13,dataCodewordsPerBlock:16}]}]},{infoBits:110507,versionNumber:26,alignmentPatternCenters:[6,30,58,86,114],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:114},{numBlocks:2,dataCodewordsPerBlock:115}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:19,\ndataCodewordsPerBlock:46},{numBlocks:4,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:28,dataCodewordsPerBlock:22},{numBlocks:6,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:33,dataCodewordsPerBlock:16},{numBlocks:4,dataCodewordsPerBlock:17}]}]},{infoBits:110734,versionNumber:27,alignmentPatternCenters:[6,34,62,90,118],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:122},{numBlocks:4,dataCodewordsPerBlock:123}]},\n{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:45},{numBlocks:3,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:23},{numBlocks:26,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:15},{numBlocks:28,dataCodewordsPerBlock:16}]}]},{infoBits:117786,versionNumber:28,alignmentPatternCenters:[6,26,50,74,98,122],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:117},\n{numBlocks:10,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:45},{numBlocks:23,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:24},{numBlocks:31,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:15},{numBlocks:31,dataCodewordsPerBlock:16}]}]},{infoBits:119615,versionNumber:29,alignmentPatternCenters:[6,30,54,78,102,126],errorCorrectionLevels:[{ecCodewordsPerBlock:30,\necBlocks:[{numBlocks:7,dataCodewordsPerBlock:116},{numBlocks:7,dataCodewordsPerBlock:117}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:21,dataCodewordsPerBlock:45},{numBlocks:7,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:23},{numBlocks:37,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:15},{numBlocks:26,dataCodewordsPerBlock:16}]}]},{infoBits:126325,versionNumber:30,alignmentPatternCenters:[6,\n26,52,78,104,130],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:115},{numBlocks:10,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:47},{numBlocks:10,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:24},{numBlocks:25,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:23,dataCodewordsPerBlock:15},{numBlocks:25,dataCodewordsPerBlock:16}]}]},\n{infoBits:127568,versionNumber:31,alignmentPatternCenters:[6,30,56,82,108,134],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:115},{numBlocks:3,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:46},{numBlocks:29,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:42,dataCodewordsPerBlock:24},{numBlocks:1,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:23,dataCodewordsPerBlock:15},\n{numBlocks:28,dataCodewordsPerBlock:16}]}]},{infoBits:133589,versionNumber:32,alignmentPatternCenters:[6,34,60,86,112,138],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:115}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:46},{numBlocks:23,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:24},{numBlocks:35,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,\ndataCodewordsPerBlock:15},{numBlocks:35,dataCodewordsPerBlock:16}]}]},{infoBits:136944,versionNumber:33,alignmentPatternCenters:[6,30,58,86,114,142],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:115},{numBlocks:1,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:14,dataCodewordsPerBlock:46},{numBlocks:21,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:29,dataCodewordsPerBlock:24},{numBlocks:19,dataCodewordsPerBlock:25}]},\n{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:15},{numBlocks:46,dataCodewordsPerBlock:16}]}]},{infoBits:141498,versionNumber:34,alignmentPatternCenters:[6,34,62,90,118,146],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:115},{numBlocks:6,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:14,dataCodewordsPerBlock:46},{numBlocks:23,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:44,\ndataCodewordsPerBlock:24},{numBlocks:7,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:59,dataCodewordsPerBlock:16},{numBlocks:1,dataCodewordsPerBlock:17}]}]},{infoBits:145311,versionNumber:35,alignmentPatternCenters:[6,30,54,78,102,126,150],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:121},{numBlocks:7,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:47},{numBlocks:26,dataCodewordsPerBlock:48}]},\n{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:39,dataCodewordsPerBlock:24},{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:15},{numBlocks:41,dataCodewordsPerBlock:16}]}]},{infoBits:150283,versionNumber:36,alignmentPatternCenters:[6,24,50,76,102,128,154],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:121},{numBlocks:14,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,\ndataCodewordsPerBlock:47},{numBlocks:34,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:46,dataCodewordsPerBlock:24},{numBlocks:10,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:15},{numBlocks:64,dataCodewordsPerBlock:16}]}]},{infoBits:152622,versionNumber:37,alignmentPatternCenters:[6,28,54,80,106,132,158],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:122},{numBlocks:4,dataCodewordsPerBlock:123}]},\n{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:29,dataCodewordsPerBlock:46},{numBlocks:14,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:49,dataCodewordsPerBlock:24},{numBlocks:10,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:24,dataCodewordsPerBlock:15},{numBlocks:46,dataCodewordsPerBlock:16}]}]},{infoBits:158308,versionNumber:38,alignmentPatternCenters:[6,32,58,84,110,136,162],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,\ndataCodewordsPerBlock:122},{numBlocks:18,dataCodewordsPerBlock:123}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:46},{numBlocks:32,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:48,dataCodewordsPerBlock:24},{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:42,dataCodewordsPerBlock:15},{numBlocks:32,dataCodewordsPerBlock:16}]}]},{infoBits:161089,versionNumber:39,alignmentPatternCenters:[6,26,54,82,110,138,166],\nerrorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:20,dataCodewordsPerBlock:117},{numBlocks:4,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:40,dataCodewordsPerBlock:47},{numBlocks:7,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:43,dataCodewordsPerBlock:24},{numBlocks:22,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:15},{numBlocks:67,dataCodewordsPerBlock:16}]}]},{infoBits:167017,\nversionNumber:40,alignmentPatternCenters:[6,30,58,86,114,142,170],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:118},{numBlocks:6,dataCodewordsPerBlock:119}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:18,dataCodewordsPerBlock:47},{numBlocks:31,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:34,dataCodewordsPerBlock:24},{numBlocks:34,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:20,dataCodewordsPerBlock:15},\n{numBlocks:61,dataCodewordsPerBlock:16}]}]}];function J(a,b){a^=b;for(b=0;a;)b++,a&=a-1;return b}function K(a,b){return b<<1|a}\nlet ia=[{bits:21522,formatInfo:{errorCorrectionLevel:1,dataMask:0}},{bits:20773,formatInfo:{errorCorrectionLevel:1,dataMask:1}},{bits:24188,formatInfo:{errorCorrectionLevel:1,dataMask:2}},{bits:23371,formatInfo:{errorCorrectionLevel:1,dataMask:3}},{bits:17913,formatInfo:{errorCorrectionLevel:1,dataMask:4}},{bits:16590,formatInfo:{errorCorrectionLevel:1,dataMask:5}},{bits:20375,formatInfo:{errorCorrectionLevel:1,dataMask:6}},{bits:19104,formatInfo:{errorCorrectionLevel:1,dataMask:7}},{bits:30660,formatInfo:{errorCorrectionLevel:0,\ndataMask:0}},{bits:29427,formatInfo:{errorCorrectionLevel:0,dataMask:1}},{bits:32170,formatInfo:{errorCorrectionLevel:0,dataMask:2}},{bits:30877,formatInfo:{errorCorrectionLevel:0,dataMask:3}},{bits:26159,formatInfo:{errorCorrectionLevel:0,dataMask:4}},{bits:25368,formatInfo:{errorCorrectionLevel:0,dataMask:5}},{bits:27713,formatInfo:{errorCorrectionLevel:0,dataMask:6}},{bits:26998,formatInfo:{errorCorrectionLevel:0,dataMask:7}},{bits:5769,formatInfo:{errorCorrectionLevel:3,dataMask:0}},{bits:5054,\nformatInfo:{errorCorrectionLevel:3,dataMask:1}},{bits:7399,formatInfo:{errorCorrectionLevel:3,dataMask:2}},{bits:6608,formatInfo:{errorCorrectionLevel:3,dataMask:3}},{bits:1890,formatInfo:{errorCorrectionLevel:3,dataMask:4}},{bits:597,formatInfo:{errorCorrectionLevel:3,dataMask:5}},{bits:3340,formatInfo:{errorCorrectionLevel:3,dataMask:6}},{bits:2107,formatInfo:{errorCorrectionLevel:3,dataMask:7}},{bits:13663,formatInfo:{errorCorrectionLevel:2,dataMask:0}},{bits:12392,formatInfo:{errorCorrectionLevel:2,\ndataMask:1}},{bits:16177,formatInfo:{errorCorrectionLevel:2,dataMask:2}},{bits:14854,formatInfo:{errorCorrectionLevel:2,dataMask:3}},{bits:9396,formatInfo:{errorCorrectionLevel:2,dataMask:4}},{bits:8579,formatInfo:{errorCorrectionLevel:2,dataMask:5}},{bits:11994,formatInfo:{errorCorrectionLevel:2,dataMask:6}},{bits:11245,formatInfo:{errorCorrectionLevel:2,dataMask:7}}],ja=[a=>0===(a.y+a.x)%2,a=>0===a.y%2,a=>0===a.x%3,a=>0===(a.y+a.x)%3,a=>0===(Math.floor(a.y/2)+Math.floor(a.x/3))%2,a=>0===a.x*a.y%\n2+a.x*a.y%3,a=>0===(a.y*a.x%2+a.y*a.x%3)%2,a=>0===((a.y+a.x)%2+a.y*a.x%3)%2];\nfunction ka(a,b,c){c=ja[c.dataMask];let d=a.height;var e=17+4*b.versionNumber;let f=x.createEmpty(e,e);f.setRegion(0,0,9,9,!0);f.setRegion(e-8,0,8,9,!0);f.setRegion(0,e-8,9,8,!0);for(var g of b.alignmentPatternCenters)for(var h of b.alignmentPatternCenters)6===g&&6===h||6===g&&h===e-7||g===e-7&&6===h||f.setRegion(g-2,h-2,5,5,!0);f.setRegion(6,9,1,e-17,!0);f.setRegion(9,6,e-17,1,!0);6<b.versionNumber&&(f.setRegion(e-11,0,3,6,!0),f.setRegion(0,e-11,6,3,!0));b=[];h=g=0;e=!0;for(let k=d-1;0<k;k-=2){6===\nk&&k--;for(let m=0;m<d;m++){let l=e?d-1-m:m;for(let n=0;2>n;n++){let q=k-n;if(!f.get(q,l)){h++;let r=a.get(q,l);c({y:l,x:q})&&(r=!r);g=g<<1|r;8===h&&(b.push(g),g=h=0)}}}e=!e}return b}\nfunction la(a){var b=a.height,c=Math.floor((b-17)/4);if(6>=c)return I[c-1];c=0;for(var d=5;0<=d;d--)for(var e=b-9;e>=b-11;e--)c=K(a.get(e,d),c);d=0;for(e=5;0<=e;e--)for(let g=b-9;g>=b-11;g--)d=K(a.get(e,g),d);a=Infinity;let f;for(let g of I){if(g.infoBits===c||g.infoBits===d)return g;b=J(c,g.infoBits);b<a&&(f=g,a=b);b=J(d,g.infoBits);b<a&&(f=g,a=b)}if(3>=a)return f}\nfunction ma(a){let b=0;for(var c=0;8>=c;c++)6!==c&&(b=K(a.get(c,8),b));for(c=7;0<=c;c--)6!==c&&(b=K(a.get(8,c),b));var d=a.height;c=0;for(var e=d-1;e>=d-7;e--)c=K(a.get(8,e),c);for(e=d-8;e<d;e++)c=K(a.get(e,8),c);a=Infinity;d=null;for(let {bits:f,formatInfo:g}of ia){if(f===b||f===c)return g;e=J(b,f);e<a&&(d=g,a=e);b!==c&&(e=J(c,f),e<a&&(d=g,a=e))}return 3>=a?d:null}\nfunction na(a,b,c){let d=b.errorCorrectionLevels[c],e=[],f=0;d.ecBlocks.forEach(h=>{for(let k=0;k<h.numBlocks;k++)e.push({numDataCodewords:h.dataCodewordsPerBlock,codewords:[]}),f+=h.dataCodewordsPerBlock+d.ecCodewordsPerBlock});if(a.length<f)return null;a=a.slice(0,f);b=d.ecBlocks[0].dataCodewordsPerBlock;for(c=0;c<b;c++)for(var g of e)g.codewords.push(a.shift());if(1<d.ecBlocks.length)for(g=d.ecBlocks[0].numBlocks,b=d.ecBlocks[1].numBlocks,c=0;c<b;c++)e[g+c].codewords.push(a.shift());for(;0<a.length;)for(let h of e)h.codewords.push(a.shift());\nreturn e}function L(a){let b=la(a);if(!b)return null;var c=ma(a);if(!c)return null;a=ka(a,b,c);var d=na(a,b,c.errorCorrectionLevel);if(!d)return null;c=d.reduce((e,f)=>e+f.numDataCodewords,0);c=new Uint8ClampedArray(c);a=0;for(let e of d){d=ha(e.codewords,e.codewords.length-e.numDataCodewords);if(!d)return null;for(let f=0;f<e.numDataCodewords;f++)c[a++]=d[f]}try{return da(c,b.versionNumber)}catch(e){return null}}\nfunction M(a,b,c,d){var e=a.x-b.x+c.x-d.x;let f=a.y-b.y+c.y-d.y;if(0===e&&0===f)return{a11:b.x-a.x,a12:b.y-a.y,a13:0,a21:c.x-b.x,a22:c.y-b.y,a23:0,a31:a.x,a32:a.y,a33:1};let g=b.x-c.x;var h=d.x-c.x;let k=b.y-c.y,m=d.y-c.y;c=g*m-h*k;h=(e*m-h*f)/c;e=(g*f-e*k)/c;return{a11:b.x-a.x+h*b.x,a12:b.y-a.y+h*b.y,a13:h,a21:d.x-a.x+e*d.x,a22:d.y-a.y+e*d.y,a23:e,a31:a.x,a32:a.y,a33:1}}\nfunction oa(a,b,c,d){a=M(a,b,c,d);return{a11:a.a22*a.a33-a.a23*a.a32,a12:a.a13*a.a32-a.a12*a.a33,a13:a.a12*a.a23-a.a13*a.a22,a21:a.a23*a.a31-a.a21*a.a33,a22:a.a11*a.a33-a.a13*a.a31,a23:a.a13*a.a21-a.a11*a.a23,a31:a.a21*a.a32-a.a22*a.a31,a32:a.a12*a.a31-a.a11*a.a32,a33:a.a11*a.a22-a.a12*a.a21}}\nfunction pa(a,b){var c=oa({x:3.5,y:3.5},{x:b.dimension-3.5,y:3.5},{x:b.dimension-6.5,y:b.dimension-6.5},{x:3.5,y:b.dimension-3.5}),d=M(b.topLeft,b.topRight,b.alignmentPattern,b.bottomLeft),e=d.a11*c.a11+d.a21*c.a12+d.a31*c.a13,f=d.a12*c.a11+d.a22*c.a12+d.a32*c.a13,g=d.a13*c.a11+d.a23*c.a12+d.a33*c.a13,h=d.a11*c.a21+d.a21*c.a22+d.a31*c.a23,k=d.a12*c.a21+d.a22*c.a22+d.a32*c.a23,m=d.a13*c.a21+d.a23*c.a22+d.a33*c.a23,l=d.a11*c.a31+d.a21*c.a32+d.a31*c.a33,n=d.a12*c.a31+d.a22*c.a32+d.a32*c.a33,q=d.a13*\nc.a31+d.a23*c.a32+d.a33*c.a33;c=x.createEmpty(b.dimension,b.dimension);d=(r,u)=>{const p=g*r+m*u+q;return{x:(e*r+h*u+l)/p,y:(f*r+k*u+n)/p}};for(let r=0;r<b.dimension;r++)for(let u=0;u<b.dimension;u++){let p=d(u+.5,r+.5);c.set(u,r,a.get(Math.floor(p.x),Math.floor(p.y)))}return{matrix:c,mappingFunction:d}}let N=(a,b)=>Math.sqrt(Math.pow(b.x-a.x,2)+Math.pow(b.y-a.y,2));function O(a){return a.reduce((b,c)=>b+c)}\nfunction qa(a,b,c){let d=N(a,b),e=N(b,c),f=N(a,c),g,h,k;e>=d&&e>=f?[g,h,k]=[b,a,c]:f>=e&&f>=d?[g,h,k]=[a,b,c]:[g,h,k]=[a,c,b];0>(k.x-h.x)*(g.y-h.y)-(k.y-h.y)*(g.x-h.x)&&([g,k]=[k,g]);return{bottomLeft:g,topLeft:h,topRight:k}}\nfunction ra(a,b,c,d){d=(O(P(a,c,d,5))/7+O(P(a,b,d,5))/7+O(P(c,a,d,5))/7+O(P(b,a,d,5))/7)/4;if(1>d)throw Error("Invalid module size");b=Math.round(N(a,b)/d);a=Math.round(N(a,c)/d);a=Math.floor((b+a)/2)+7;switch(a%4){case 0:a++;break;case 2:a--}return{dimension:a,moduleSize:d}}\nfunction Q(a,b,c,d){let e=[{x:Math.floor(a.x),y:Math.floor(a.y)}];var f=Math.abs(b.y-a.y)>Math.abs(b.x-a.x);if(f){var g=Math.floor(a.y);var h=Math.floor(a.x);a=Math.floor(b.y);b=Math.floor(b.x)}else g=Math.floor(a.x),h=Math.floor(a.y),a=Math.floor(b.x),b=Math.floor(b.y);let k=Math.abs(a-g),m=Math.abs(b-h),l=Math.floor(-k/2),n=g<a?1:-1,q=h<b?1:-1,r=!0;for(let u=g,p=h;u!==a+n;u+=n){g=f?p:u;h=f?u:p;if(c.get(g,h)!==r&&(r=!r,e.push({x:g,y:h}),e.length===d+1))break;l+=m;if(0<l){if(p===b)break;p+=q;l-=k}}c=\n[];for(f=0;f<d;f++)e[f]&&e[f+1]?c.push(N(e[f],e[f+1])):c.push(0);return c}function P(a,b,c,d){let e=b.y-a.y,f=b.x-a.x;b=Q(a,b,c,Math.ceil(d/2));a=Q(a,{x:a.x-f,y:a.y-e},c,Math.ceil(d/2));c=b.shift()+a.shift()-1;return a.concat(c).concat(...b)}function R(a,b){let c=O(a)/O(b),d=0;b.forEach((e,f)=>{d+=Math.pow(a[f]-e*c,2)});return{averageSize:c,error:d}}\nfunction S(a,b,c){try{let d=P(a,{x:-1,y:a.y},c,b.length),e=P(a,{x:a.x,y:-1},c,b.length),f=P(a,{x:Math.max(0,a.x-a.y)-1,y:Math.max(0,a.y-a.x)-1},c,b.length),g=P(a,{x:Math.min(c.width,a.x+a.y)+1,y:Math.min(c.height,a.y+a.x)+1},c,b.length),h=R(d,b),k=R(e,b),m=R(f,b),l=R(g,b),n=(h.averageSize+k.averageSize+m.averageSize+l.averageSize)/4;return Math.sqrt(h.error*h.error+k.error*k.error+m.error*m.error+l.error*l.error)+(Math.pow(h.averageSize-n,2)+Math.pow(k.averageSize-n,2)+Math.pow(m.averageSize-n,2)+\nMath.pow(l.averageSize-n,2))/n}catch(d){return Infinity}}function T(a,b){for(var c=Math.round(b.x);a.get(c,Math.round(b.y));)c--;for(var d=Math.round(b.x);a.get(d,Math.round(b.y));)d++;c=(c+d)/2;for(d=Math.round(b.y);a.get(Math.round(c),d);)d--;for(b=Math.round(b.y);a.get(Math.round(c),b);)b++;return{x:c,y:(d+b)/2}}\nfunction sa(a){var b=[],c=[];let d=[];var e=[];for(let p=0;p<=a.height;p++){var f=0,g=!1;let t=[0,0,0,0,0];for(let v=-1;v<=a.width;v++){var h=a.get(v,p);if(h===g)f++;else{t=[t[1],t[2],t[3],t[4],f];f=1;g=h;var k=O(t)/7;k=Math.abs(t[0]-k)<k&&Math.abs(t[1]-k)<k&&Math.abs(t[2]-3*k)<3*k&&Math.abs(t[3]-k)<k&&Math.abs(t[4]-k)<k&&!h;var m=O(t.slice(-3))/3;h=Math.abs(t[2]-m)<m&&Math.abs(t[3]-m)<m&&Math.abs(t[4]-m)<m&&h;if(k){let z=v-t[3]-t[4],y=z-t[2];k={startX:y,endX:z,y:p};m=c.filter(w=>y>=w.bottom.startX&&\ny<=w.bottom.endX||z>=w.bottom.startX&&y<=w.bottom.endX||y<=w.bottom.startX&&z>=w.bottom.endX&&1.5>t[2]/(w.bottom.endX-w.bottom.startX)&&.5<t[2]/(w.bottom.endX-w.bottom.startX));0<m.length?m[0].bottom=k:c.push({top:k,bottom:k})}if(h){let z=v-t[4],y=z-t[3];h={startX:y,y:p,endX:z};k=e.filter(w=>y>=w.bottom.startX&&y<=w.bottom.endX||z>=w.bottom.startX&&y<=w.bottom.endX||y<=w.bottom.startX&&z>=w.bottom.endX&&1.5>t[2]/(w.bottom.endX-w.bottom.startX)&&.5<t[2]/(w.bottom.endX-w.bottom.startX));0<k.length?\nk[0].bottom=h:e.push({top:h,bottom:h})}}}b.push(...c.filter(v=>v.bottom.y!==p&&2<=v.bottom.y-v.top.y));c=c.filter(v=>v.bottom.y===p);d.push(...e.filter(v=>v.bottom.y!==p));e=e.filter(v=>v.bottom.y===p)}b.push(...c.filter(p=>2<=p.bottom.y-p.top.y));d.push(...e);c=[];for(var l of b)2>l.bottom.y-l.top.y||(b=(l.top.startX+l.top.endX+l.bottom.startX+l.bottom.endX)/4,e=(l.top.y+l.bottom.y+1)/2,a.get(Math.round(b),Math.round(e))&&(f=[l.top.endX-l.top.startX,l.bottom.endX-l.bottom.startX,l.bottom.y-l.top.y+\n1],f=O(f)/f.length,g=S({x:Math.round(b),y:Math.round(e)},[1,1,3,1,1],a),c.push({score:g,x:b,y:e,size:f})));if(3>c.length)return null;c.sort((p,t)=>p.score-t.score);l=[];for(b=0;b<Math.min(c.length,5);++b){e=c[b];f=[];for(var n of c)n!==e&&f.push(Object.assign(Object.assign({},n),{score:n.score+Math.pow(n.size-e.size,2)/e.size}));f.sort((p,t)=>p.score-t.score);l.push({points:[e,f[0],f[1]],score:e.score+f[0].score+f[1].score})}l.sort((p,t)=>p.score-t.score);let {topRight:q,topLeft:r,bottomLeft:u}=qa(...l[0].points);\nl=U(a,d,q,r,u);n=[];l&&n.push({alignmentPattern:{x:l.alignmentPattern.x,y:l.alignmentPattern.y},bottomLeft:{x:u.x,y:u.y},dimension:l.dimension,topLeft:{x:r.x,y:r.y},topRight:{x:q.x,y:q.y}});l=T(a,q);b=T(a,r);c=T(a,u);(a=U(a,d,l,b,c))&&n.push({alignmentPattern:{x:a.alignmentPattern.x,y:a.alignmentPattern.y},bottomLeft:{x:c.x,y:c.y},topLeft:{x:b.x,y:b.y},topRight:{x:l.x,y:l.y},dimension:a.dimension});return 0===n.length?null:n}\nfunction U(a,b,c,d,e){let f,g;try{({dimension:f,moduleSize:g}=ra(d,c,e,a))}catch(l){return null}var h=c.x-d.x+e.x,k=c.y-d.y+e.y;c=(N(d,e)+N(d,c))/2/g;e=1-3/c;let m={x:d.x+e*(h-d.x),y:d.y+e*(k-d.y)};b=b.map(l=>{const n=(l.top.startX+l.top.endX+l.bottom.startX+l.bottom.endX)/4;l=(l.top.y+l.bottom.y+1)/2;if(a.get(Math.floor(n),Math.floor(l))){var q=S({x:Math.floor(n),y:Math.floor(l)},[1,1,1],a)+N({x:n,y:l},m);return{x:n,y:l,score:q}}}).filter(l=>!!l).sort((l,n)=>l.score-n.score);return{alignmentPattern:15<=\nc&&b.length?b[0]:m,dimension:f}}\nfunction V(a){var b=sa(a);if(!b)return null;for(let e of b){b=pa(a,e);var c=b.matrix;if(null==c)c=null;else{var d=L(c);if(d)c=d;else{for(d=0;d<c.width;d++)for(let f=d+1;f<c.height;f++)c.get(d,f)!==c.get(f,d)&&(c.set(d,f,!c.get(d,f)),c.set(f,d,!c.get(f,d)));c=L(c)}}if(c)return{binaryData:c.bytes,data:c.text,chunks:c.chunks,version:c.version,location:{topRightCorner:b.mappingFunction(e.dimension,0),topLeftCorner:b.mappingFunction(0,0),bottomRightCorner:b.mappingFunction(e.dimension,e.dimension),bottomLeftCorner:b.mappingFunction(0,\ne.dimension),topRightFinderPattern:e.topRight,topLeftFinderPattern:e.topLeft,bottomLeftFinderPattern:e.bottomLeft,bottomRightAlignmentPattern:e.alignmentPattern},matrix:b.matrix}}return null}let ta={inversionAttempts:"attemptBoth",greyScaleWeights:{red:.2126,green:.7152,blue:.0722,useIntegerApproximation:!1},canOverwriteImage:!0};function W(a,b){Object.keys(b).forEach(c=>{a[c]=b[c]})}\nfunction X(a,b,c,d={}){let e=Object.create(null);W(e,ta);W(e,d);d="onlyInvert"===e.inversionAttempts||"invertFirst"===e.inversionAttempts;var f="attemptBoth"===e.inversionAttempts||d;var g=e.greyScaleWeights,h=e.canOverwriteImage,k=b*c;if(a.length!==4*k)throw Error("Malformed data passed to binarizer.");var m=0;if(h){var l=new Uint8ClampedArray(a.buffer,m,k);m+=k}l=new A(b,c,l);if(g.useIntegerApproximation)for(var n=0;n<c;n++)for(var q=0;q<b;q++){var r=4*(n*b+q);l.set(q,n,g.red*a[r]+g.green*a[r+1]+\ng.blue*a[r+2]+128>>8)}else for(n=0;n<c;n++)for(q=0;q<b;q++)r=4*(n*b+q),l.set(q,n,g.red*a[r]+g.green*a[r+1]+g.blue*a[r+2]);g=Math.ceil(b/8);n=Math.ceil(c/8);q=g*n;if(h){var u=new Uint8ClampedArray(a.buffer,m,q);m+=q}u=new A(g,n,u);for(q=0;q<n;q++)for(r=0;r<g;r++){var p=Infinity,t=0;for(var v=0;8>v;v++)for(let w=0;8>w;w++){let aa=l.get(8*r+w,8*q+v);p=Math.min(p,aa);t=Math.max(t,aa)}v=(p+t)/2;v=Math.min(255,1.11*v);24>=t-p&&(v=p/2,0<q&&0<r&&(t=(u.get(r,q-1)+2*u.get(r-1,q)+u.get(r-1,q-1))/4,p<t&&(v=t)));\nu.set(r,q,v)}h?(q=new Uint8ClampedArray(a.buffer,m,k),m+=k,q=new x(q,b)):q=x.createEmpty(b,c);r=null;f&&(h?(a=new Uint8ClampedArray(a.buffer,m,k),r=new x(a,b)):r=x.createEmpty(b,c));for(b=0;b<n;b++)for(a=0;a<g;a++){c=g-3;c=2>a?2:a>c?c:a;h=n-3;h=2>b?2:b>h?h:b;k=0;for(m=-2;2>=m;m++)for(p=-2;2>=p;p++)k+=u.get(c+m,h+p);c=k/25;for(h=0;8>h;h++)for(k=0;8>k;k++)m=8*a+h,p=8*b+k,t=l.get(m,p),q.set(m,p,t<=c),f&&r.set(m,p,!(t<=c))}f=f?{binarized:q,inverted:r}:{binarized:q};let {binarized:z,inverted:y}=f;(f=V(d?\ny:z))||"attemptBoth"!==e.inversionAttempts&&"invertFirst"!==e.inversionAttempts||(f=V(d?z:y));return f}X.default=X;let Y="dontInvert",Z={red:77,green:150,blue:29,useIntegerApproximation:!0};\nself.onmessage=a=>{let b=a.data.id,c=a.data.data;switch(a.data.type){case "decode":(a=X(c.data,c.width,c.height,{inversionAttempts:Y,greyScaleWeights:Z}))?self.postMessage({id:b,type:"qrResult",data:a.data,cornerPoints:[a.location.topLeftCorner,a.location.topRightCorner,a.location.bottomRightCorner,a.location.bottomLeftCorner]}):self.postMessage({id:b,type:"qrResult",data:null});break;case "grayscaleWeights":Z.red=c.red;Z.green=c.green;Z.blue=c.blue;Z.useIntegerApproximation=c.useIntegerApproximation;\nbreak;case "inversionMode":switch(c){case "original":Y="dontInvert";break;case "invert":Y="onlyInvert";break;case "both":Y="attemptBoth";break;default:throw Error("Invalid inversion mode");}break;case "close":self.close()}}\n']),{type:"application/javascript"}));var qrScannerWorker_min=Object.freeze({__proto__:null,createWorker:createWorker});export{NostrLoginInitializer,cancelNeedAuth,init,launch,logout,setAuth,setDarkMode};
|
|
27
|
+
/*! 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")]]},_2n=BigInt(2);function sqrtMod(e){const t=secp256k1_CURVE.p,n=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,d=l*l*e%t,u=pow2(d,n,t)*d%t,h=pow2(u,n,t)*d%t,f=pow2(h,_2n,t)*l%t,p=pow2(f,o,t)*f%t,g=pow2(p,s,t)*p%t,m=pow2(g,a,t)*g%t,b=pow2(m,c,t)*m%t,y=pow2(b,a,t)*g%t,w=pow2(y,n,t)*d%t,v=pow2(w,i,t)*p%t,k=pow2(v,r,t)*l%t,E=pow2(k,_2n,t);if(!Fpk1.eql(Fpk1.sqr(E),e))throw new Error("Cannot find square root");return E}const Fpk1=Field(secp256k1_CURVE.p,{sqrt:sqrtMod}),secp256k1=createCurve({...secp256k1_CURVE,Fp:Fpk1,lowS:!0,endo:secp256k1_ENDO},sha256$1);function extract(e,t,n){return ahash(e),hmac(e,toBytes(n),toBytes(t))}const HKDF_COUNTER=Uint8Array.from([0]),EMPTY_BUFFER=Uint8Array.of();function expand(e,t,n,r=32){ahash(e),anumber$1(r);const o=e.outputLen;if(r>255*o)throw new Error("Length should be <= 255*HashLen");const s=Math.ceil(r/o);void 0===n&&(n=EMPTY_BUFFER);const i=new Uint8Array(s*o),a=hmac.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let e=0;e<s;e++)HKDF_COUNTER[0]=e+1,c.update(0===e?EMPTY_BUFFER:l).update(n).update(HKDF_COUNTER).digestInto(l),i.set(l,o*e),a._cloneInto(c);return a.destroy(),c.destroy(),clean(l,HKDF_COUNTER),i.slice(0,r)}const sha256=sha256$1;
|
|
28
|
+
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function isBytes(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function abytes(e,...t){if(!isBytes(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 isArrayOf(e,t){return!!Array.isArray(t)&&(0===t.length||(e?t.every((e=>"string"==typeof e)):t.every((e=>Number.isSafeInteger(e)))))}function astr(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function anumber(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function aArr(e){if(!Array.isArray(e))throw new Error("array expected")}function astrArr(e,t){if(!isArrayOf(!0,t))throw new Error(`${e}: array of strings expected`)}function anumArr(e,t){if(!isArrayOf(!1,t))throw new Error(`${e}: array of numbers expected`)}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){const t="string"==typeof e?e.split(""):e,n=t.length;astrArr("alphabet",t);const r=new Map(t.map(((e,t)=>[e,t])));return{encode:r=>(aArr(r),r.map((r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${e}`);return t[r]}))),decode:t=>(aArr(t),t.map((t=>{astr("alphabet.decode",t);const n=r.get(t);if(void 0===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})))}}function join(e=""){return astr("join",e),{encode:t=>(astrArr("join.decode",t),t.join(e)),decode:t=>(astr("join.decode",t),t.split(e))}}function padding(e,t="="){return anumber(e),astr("padding",t),{encode(n){for(astrArr("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){astrArr("padding.decode",n);let r=n.length;if(r*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--){if((r-1)*e%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,r)}}}const gcd=(e,t)=>0===t?e:gcd(t,e%t),radix2carry=(e,t)=>e+(t-gcd(e,t)),powers=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function convertRadix2(e,t,n,r){if(aArr(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(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=powers[t],a=powers[n]-1,c=[];for(const r of e){if(anumber(r),r>=i)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)c.push((o>>s-n&a)>>>0);const e=powers[s];if(void 0===e)throw new Error("invalid carry");o&=e-1}if(o=o<<n-s&a,!r&&s>=t)throw new Error("Excess padding");if(!r&&o>0)throw new Error(`Non-zero padding: ${o}`);return r&&s>0&&c.push(o>>>0),c}function radix2(e,t=!1){if(anumber(e),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=>(anumArr("radix2.decode",n),Uint8Array.from(convertRadix2(n,e,8,t)))}}const hasBase64Builtin=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)(),decodeBase64Builtin=(e,t)=>{astr("base64",e);if(e.length>0&&!/^[A-Za-z0-9=+/]+$/.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:"base64",lastChunkHandling:"strict"})},base64=hasBase64Builtin?{encode:e=>(abytes(e),e.toBase64()),decode:e=>decodeBase64Builtin(e)}:chain(radix2(6),alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),padding(6),join("")),decoder=new TextDecoder,u={minPlaintextSize:1,maxPlaintextSize:65535,utf8Encode:utf8ToBytes,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(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),c=u.hmacAad(s,a,n);return base64.encode(concatBytes(new Uint8Array([2]),n,a,c))}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 c=chacha20(s,i,r);return u.unpad(c)}class Nip44{cache=new Map;createKey(e,t){return u.getConversationKey(e,t)}getKey(e,t){const n=getPublicKey(hexToBytes(e))+t;let r=this.cache.get(n);if(r)return r;const o=this.createKey(e,t);return this.cache.set(n,o),o}encrypt(e,t,n){return encryptNip44(n,this.getKey(e,t))}decrypt(e,t,n){return decryptNip44(n,this.getKey(e,t))}}class PrivateKeySigner{nip44Codec=new Nip44;privateKey;_secretKey;pubkey;get secretKey(){return this._secretKey}constructor(e){this.privateKey=e,this._secretKey=hexToBytes(e),this.pubkey=getPublicKey(this._secretKey)}async sign(e){const t={kind:e.kind,created_at:e.created_at,tags:e.tags,content:e.content};return finalizeEvent(t,this._secretKey).sig}async user(){return{pubkey:this.pubkey}}async encrypt(e,t){return nip04_exports.encrypt(this.privateKey,e.pubkey,t)}async decrypt(e,t){return nip04_exports.decrypt(this.privateKey,e.pubkey,t)}encryptNip44(e,t){return Promise.resolve(this.nip44Codec.encrypt(this.privateKey,e.pubkey,t))}decryptNip44(e,t){return Promise.resolve(this.nip44Codec.decrypt(this.privateKey,e.pubkey,t))}}const OUTBOX_RELAYS=["wss://user.kindpag.es","wss://purplepag.es","wss://relay.nos.social"],NOSTRCONNECT_APPS=[{name:"Nsec.app",domain:"nsec.app",canImport:!0,img:"https://nsec.app/assets/favicon.ico",link:"https://use.nsec.app/<nostrconnect>"},{name:"Amber",img:"https://raw.githubusercontent.com/greenart7c3/Amber/refs/heads/master/assets/android-icon.svg",link:"<nostrconnect>"},{name:"Other key stores",img:"",link:"<nostrconnect>"}],nostrJsonCache=new Map,NOSTR_JSON_CACHE_TTL=3e5,NOSTR_JSON_FETCH_TIMEOUT=5e3;async function fetchNostrJson(e){const t=nostrJsonCache.get(e);if(t&&Date.now()-t.timestamp<NOSTR_JSON_CACHE_TTL)return t.data;const n=new AbortController,r=setTimeout((()=>n.abort()),NOSTR_JSON_FETCH_TIMEOUT);try{const t=await(await fetch(`https://${e}/.well-known/nostr.json`,{signal:n.signal})).json();return nostrJsonCache.set(e,{data:t,timestamp:Date.now()}),t}finally{clearTimeout(r)}}function generatePrivateKey(){return bytesToHex(generateSecretKey())}class AuthNostrService extends lib.EventEmitter{pool;profilePool;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.pool=new RelayPool,this.profilePool=new RelayPool;for(const e of OUTBOX_RELAYS)this.profilePool.addRelay(e);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(){console.log("cancelNostrConnect called"),this.releaseSigner(),this.resetAuth(),this.signerErrCallback&&(this.signerErrCallback("cancelled"),this.signerErrCallback=void 0)}cancelSignerInit(){this.cancelNostrConnect()}cancelPendingRequests(){if(console.log("cancelPendingRequests called (signer preserved)"),this.signer&&this.signer.rpc)try{this.signer.rpc.clearPendingRequests?.()}catch(e){console.warn("Failed to clear pending requests",e)}}async nostrConnect(e,{domain:t="",link:n="",iframeUrl:r="",importConnect:o=!1,customRelays:s}={}){console.log("[nostrConnect] Called",{relay:e,domain:t,link:n,iframeUrl:r,importConnect:o,customRelays:s});const i=s&&s.length>0?s:e?[e]:DEFAULT_NIP46_RELAYS,a={authMethod:"connect",pubkey:"",signerPubkey:"",sk:this.nostrConnectKey,domain:t,relays:i,iframeUrl:r};console.log("[nostrConnect] Created info",a,n),n&&!r&&(console.log("[nostrConnect] Opening Amber"),window.open(n,"_blank","width=400,height=700"));try{console.log("[nostrConnect] Calling initSigner with listen=true"),await this.initSigner(a,{listen:!0}),this.signerPromise&&(console.log("[nostrConnect] Waiting for signerPromise to complete"),await this.signerPromise,console.log("[nostrConnect] signerPromise completed"))}catch(e){throw console.error("[nostrConnect] Failed to initialize signer:",e),new Error(`Connection failed: ${e instanceof Error?e.message:"Unknown error"}`)}if(console.log("[nostrConnect] Checking pubkeys",{pubkey:a.pubkey,signerPubkey:a.signerPubkey}),!a.pubkey||!a.signerPubkey)throw console.error("[nostrConnect] Missing pubkeys after initialization"),new Error("Failed to get pubkey from signer");const c=i.map((e=>`relay=${encodeURIComponent(e)}`)).join("&");return a.bunkerUrl=`bunker://${a.signerPubkey}?${c}`,console.log("[nostrConnect] Generated bunkerUrl",a.bunkerUrl),o||(console.log("[nostrConnect] Calling onAuth"),this.onAuth("login",a)),console.log("[nostrConnect] Completed successfully"),a}async createNostrConnect(){this.nostrConnectKey=generatePrivateKey(),this.nostrConnectSecret=Math.random().toString(36).substring(7);const e=getPublicKey(hexToBytes(this.nostrConnectKey)),t=encodeURIComponent(document.location.host),n=encodeURIComponent(document.location.origin);return`nostrconnect://${e}?image=${encodeURIComponent(await getIcon())}&url=${n}&name=${t}&perms=${encodeURIComponent(this.params.optionsModal.perms||"")}&secret=${this.nostrConnectSecret}`}async getNostrConnectServices(e,t){const n=await this.createNostrConnect(),r=NOSTRCONNECT_APPS.map((e=>({...e}))),o=e&&e.length>0?e:DEFAULT_NIP46_RELAYS;for(const e of r)if(e.link.startsWith("https://")){e.available="loading";const t=o.map((e=>`&relay=${encodeURIComponent(e)}`)).join("");e.link=n+t}else{e.available=!0;const t=o.map((e=>`&relay=${encodeURIComponent(e)}`)).join(""),r=n+t;e.link=e.link.replace("<nostrconnect>",r)}t&&t([...r.map((e=>({...e})))]);const s=r.filter((e=>"loading"===e.available)).map((async s=>{const i=s.domain||"";try{const t=await fetchNostrJson(i),r=t.names._;let a=o;const c=t.nip46[r];!c||!c.length||e&&0!==e.length||(a=c),s.iframeUrl=t.nip46.iframe_url||"";const l=a.map((e=>`&relay=${encodeURIComponent(e)}`)).join(""),d=n+l;s.link=s.iframeUrl?d:s.link,s.available=!0}catch(e){console.log("Service unavailable",i,e),s.available=!1}t&&t([...r.map((e=>({...e})))])}));return await Promise.all(s),[n,r]}async localSignup(e,t){const n=!t;t=t||generatePrivateKey();const r={pubkey:getPublicKey(hexToBytes(t)),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.profilePool,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(hexToBytes(this.localSigner.privateKey))}async importAndConnect(e){const{relay: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();try{if(await this.startAuth(),await this.initSigner(e,{connect:!0}),!e.pubkey||!e.signerPubkey)throw new Error("Failed to initialize signer: missing pubkey");this.onAuth("login",e),await this.endAuth()}catch(e){throw console.error("Failed to set connect:",e),this.resetAuth(),this.releaseSigner(),e}}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})}?relay=${o.relays?.[0]}`,sk:o.sk}}releaseSigner(){if(console.log("releaseSigner called"),this.signer&&this.signer.rpc){try{this.signer.rpc.clearPendingRequests?.()}catch(e){console.warn("Failed to clear pending requests",e)}try{this.signer.rpc.stop?.()}catch(e){console.warn("Failed to stop RPC subscription",e)}}this.signer=null,this.signerErrCallback&&(this.signerErrCallback("cancelled"),this.signerErrCallback=void 0),this.localSigner=null,this.pool.removeAllRelays(),this.signerPromise=void 0}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(hexToBytes(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.profilePool).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(hexToBytes(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(){console.log("startAuth"),this.readyCallback&&(console.log("startAuth: previous auth still active, cancelling it first"),this.cancelNostrConnect()),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(),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(e){"cancelled"!==e&&console.error("Previous signer promise failed:",e)}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=e=>{console.log("Signer initialization cancelled or failed:",e),i(e)};try{if(e.relays&&!e.iframeUrl)for(const t of e.relays)this.pool.addRelay(t);const i=new PrivateKeySigner(e.sk);this.signer=new Nip46Signer(this.pool,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.bunkerPubkey,console.log("Signer initialized successfully. User pubkey:",e.pubkey,"Signer pubkey:",e.signerPubkey),this.signerErrCallback=void 0,s()}catch(e){console.error("initSigner failure",e),this.signer=null,this.signerErrCallback=void 0,i(e)}})),this.signerPromise}async authNip46(e,{name:t,bunkerUrl:n,sk:r="",domain:o="",iframeUrl:s="",customRelays:i}){try{const a=bunkerUrlToInfo(n,r);if(isBunkerUrl(t)?a.bunkerUrl=t:(a.nip05=t,a.domain=t.split("@")[1]),o&&(a.domain=o),s&&(a.iframeUrl=s),i&&i.length>0&&(a.relays=i),!a.signerPubkey||!a.sk||!a.relays?.[0])throw new Error(`Bad bunker url ${n}`);const c=Boolean(this.params.userInfo);console.log("authNip46",e,a),await this.initSigner(a,{connect:!0,eventToAddAccount:c}),this.onAuth(e,a)}catch(e){throw console.error("nostr login auth failed",e),e}}async signEvent(e){if(this.localSigner)return e.pubkey=this.localSigner.pubkey,e.id=getEventHash(e),e.sig=await this.localSigner.sign(e),console.log("signed (local)",{event:e}),e;let t;for(let n=0;n<=2;n++)try{if(!this.signer)throw new Error("Signer is not initialized. Please reconnect.");await this.ensureRelayConnection(),e.pubkey=this.signer.userPubkey,e.id=getEventHash(e);const t=await(this.signer?.sign(e));return"object"==typeof t&&t.sig?(e.pubkey=t.pubkey||e.pubkey,e.id=t.id||e.id,e.sig=t.sig):e.sig=t,console.log("signed",{event:e,attempt:n}),e}catch(e){t=e;const r=e instanceof Nip46Error&&"SIGNER_REJECTED"===e.code,o=e instanceof Error&&("Cancelled by user"===e.message||"cancelled"===e.message);if(n<2&&!r&&!o){console.warn(`signEvent attempt ${n+1}/3 failed, retrying...`,e);try{await this.forceReconnect()}catch(e){console.warn("forceReconnect failed during retry, will try sign anyway",e)}continue}break}throw t}async forceReconnect(){console.log("forceReconnect: forcing relay reconnection..."),this.ensureRelaysInPool();for(const e of this.pool.relayUrls)try{this.pool.reconnect(e)}catch(t){console.warn("forceReconnect: failed to reconnect",e,t)}await this.pool.waitForConnection(8e3),await this.ensureSubscription()}async ensureRelayConnection(){this.ensureRelaysInPool();const e=this.pool.isAnyConnected(),t=!this.signer?.rpc||!1!==this.signer.rpc.isSubscriptionActive?.();if(e)t||(console.log("ensureRelayConnection: relay connected but subscription dead, resubscribing..."),await this.ensureSubscription());else{console.log("ensureRelayConnection: no relay connected, triggering reconnect...");for(const e of this.pool.relayUrls)try{this.pool.reconnect(e)}catch(t){console.warn("ensureRelayConnection: reconnect failed",e,t)}await this.pool.waitForConnection(8e3),await this.ensureSubscription()}}ensureRelaysInPool(){if(0===this.pool.relayUrls.length){console.warn("ensureRelaysInPool: no relays in pool, adding relays");const e=this.params.userInfo?.relays?.length?this.params.userInfo.relays:DEFAULT_NIP46_RELAYS;for(const t of e)this.pool.addRelay(t)}}async ensureSubscription(){if(this.signer&&this.signer.rpc)try{this.signer.rpc.resubscribe?.(),console.log("ensureSubscription: subscription re-established")}catch(e){console.warn("ensureSubscription: failed to resubscribe",e)}}async codec_call(e,t,n){return new Promise(((r,o)=>{this.signer.rpc.sendRequest(this.signer.bunkerPubkey,e,[t,n],24133,(e=>{e.error?e.error.includes("timeout")||"Request timeout"===e.error?o(new Nip46Error(e.error,"TIMEOUT")):o(new Nip46Error(e.error,"SIGNER_REJECTED")):r(e.result)}))}))}async encrypt04(e,t){return await this.ensureRelayConnection(),this.localSigner?this.localSigner.encrypt({pubkey:e},t):this.signer.encrypt(e,t)}async decrypt04(e,t){return await this.ensureRelayConnection(),this.localSigner?this.localSigner.decrypt({pubkey:e},t):this.codec_call("nip04_decrypt",e,t)}async encrypt44(e,t){return await this.ensureRelayConnection(),this.localSigner?this.nip44Codec.encrypt(this.localSigner.privateKey,e,t):this.codec_call("nip44_encrypt",e,t)}async decrypt44(e,t){return await this.ensureRelayConnection(),this.localSigner?this.nip44Codec.decrypt(this.localSigner.privateKey,e,t):this.codec_call("nip44_decrypt",e,t)}}function loadCustomNip46Relays(){try{const e=localStorage.getItem("customNip46Relays");if(e){const t=JSON.parse(e);if(Array.isArray(t)&&t.length>0)return t}}catch(e){console.error("Failed to load custom relays from localStorage",e)}return[...DEFAULT_NIP46_RELAYS]}class ModalManager extends lib.EventEmitter{modal=null;params;extensionService;authNostrService;launcherPromise;accounts=[];recents=[];opt;customNip46Relays=loadCustomNip46Relays();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.customNip46Relays=loadCustomNip46Relays(),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,t.appendChild(this.modal),document.body.appendChild(t),this.authNostrService.getNostrConnectServices(this.customNip46Relays,(e=>{this.modal&&(this.modal.connectionStringServices=e)})).then((([e,t])=>{this.modal&&(this.modal.connectionString=e,this.modal.connectionStringServices=t)})).catch((e=>{console.log("Failed to load nostr connect services",e)}));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(),e(),t.close(),this.modal=null},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,customRelays:this.customNip46Relays})}))},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,console.log("nostrconnect authUrl",this.modal.authUrl,this.modal.iframeUrl)),await this.authNostrService.importAndConnect(e)}))},d=async e=>{await s((async()=>{const{relay: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,console.log("nostrconnect authUrl",this.modal.authUrl,this.modal.iframeUrl)),!e&&this.modal&&(this.modal.isLoading=!1),await this.authNostrService.nostrConnect(t,{domain:n,link:r,iframeUrl:o,customRelays:this.customNip46Relays})}))},u=async e=>{await s((async()=>{if(!e)throw new Error("Please enter some nickname");await this.authNostrService.localSignup(e)}))},h=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("&","&"),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("",bytesToHex(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("nlRelaysChanged",(async e=>{if(this.customNip46Relays=e.detail,console.log("Custom Nip46 relays updated:",this.customNip46Relays),this.modal){const e=this.modal;await this.authNostrService.getNostrConnectServices(this.customNip46Relays,(t=>{e.connectionStringServices=t})).then((([t,n])=>{e.connectionString=t,e.connectionStringServices=n}))}})),this.modal.addEventListener("nlSignup",(e=>{a(e.detail)})),this.modal.addEventListener("nlLocalSignup",(e=>{u(e.detail)})),this.modal.addEventListener("nlLoginNsec",(async e=>{await s((async()=>{const t=e.detail;if(!t)throw new Error("Please enter your nsec");let n;try{n=nip19_exports.decode(t)}catch(e){throw new Error("Invalid nsec format")}if("nsec"!==n.type)throw new Error("Invalid key type, expected nsec");await this.authNostrService.localSignup("",bytesToHex(n.data))}))})),this.modal.addEventListener("nlSignupNjump",(e=>{h()})),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=>{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 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),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 p=()=>{this.modal&&(this.modal.isLoading=!1),this.authNostrService.isAuthing()&&this.authNostrService.cancelSignerInit(),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 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.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{}}}class ProcessManager extends lib.EventEmitter{callCount=0;callTimer;pendingCalls=new Map;callIdCounter=0;constructor(){super()}cancelAllPendingCalls(){for(const[e,{reject:t}]of this.pendingCalls.entries())t(new Error("Cancelled by user"));this.pendingCalls.clear(),this.callTimer&&(clearTimeout(this.callTimer),this.callTimer=void 0),this.callCount=0}onAuthUrl(){this.callTimer&&(clearTimeout(this.callTimer),this.callTimer=setTimeout((()=>this.emit("onCallTimeout")),AUTH_URL_CALL_TIMEOUT))}onIframeUrl(){Boolean(this.callTimer)&&clearTimeout(this.callTimer)}async wait(e){this.callTimer||(this.callTimer=setTimeout((()=>this.emit("onCallTimeout")),CALL_TIMEOUT)),this.callCount||this.emit("onCallStart"),this.callCount++;const t=this.callIdCounter++;let n,r;try{r=await new Promise((async(n,r)=>{this.pendingCalls.set(t,{reject:r});try{const r=await e();this.pendingCalls.delete(t),n(r)}catch(e){this.pendingCalls.delete(t),r(e)}}))}catch(e){n=e}if(this.callCount--,this.emit("onCallEnd"),this.callTimer&&clearTimeout(this.callTimer),this.callTimer=void 0,n)throw n;return r}}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)})),this.bannerManager.on("cancelTimeout",(()=>{this.authNostrService.cancelPendingRequests(),this.processManager.cancelAllPendingCalls(),this.bannerManager.onCallEnd()}))}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)}));const createWorker=()=>new Worker(URL.createObjectURL(new Blob(['class x{constructor(a,b){this.width=b;this.height=a.length/b;this.data=a}static createEmpty(a,b){return new x(new Uint8ClampedArray(a*b),a)}get(a,b){return 0>a||a>=this.width||0>b||b>=this.height?!1:!!this.data[b*this.width+a]}set(a,b,c){this.data[b*this.width+a]=c?1:0}setRegion(a,b,c,d,e){for(let f=b;f<b+d;f++)for(let g=a;g<a+c;g++)this.set(g,f,!!e)}}\nclass A{constructor(a,b,c){this.width=a;a*=b;if(c&&c.length!==a)throw Error("Wrong buffer size");this.data=c||new Uint8ClampedArray(a)}get(a,b){return this.data[b*this.width+a]}set(a,b,c){this.data[b*this.width+a]=c}}\nclass ba{constructor(a){this.bitOffset=this.byteOffset=0;this.bytes=a}readBits(a){if(1>a||32<a||a>this.available())throw Error("Cannot read "+a.toString()+" bits");var b=0;if(0<this.bitOffset){b=8-this.bitOffset;var c=a<b?a:b;b-=c;b=(this.bytes[this.byteOffset]&255>>8-c<<b)>>b;a-=c;this.bitOffset+=c;8===this.bitOffset&&(this.bitOffset=0,this.byteOffset++)}if(0<a){for(;8<=a;)b=b<<8|this.bytes[this.byteOffset]&255,this.byteOffset++,a-=8;0<a&&(c=8-a,b=b<<a|(this.bytes[this.byteOffset]&255>>c<<c)>>c,\nthis.bitOffset+=a)}return b}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var B,C=B||(B={});C.Numeric="numeric";C.Alphanumeric="alphanumeric";C.Byte="byte";C.Kanji="kanji";C.ECI="eci";C.StructuredAppend="structuredappend";var D,E=D||(D={});E[E.Terminator=0]="Terminator";E[E.Numeric=1]="Numeric";E[E.Alphanumeric=2]="Alphanumeric";E[E.Byte=4]="Byte";E[E.Kanji=8]="Kanji";E[E.ECI=7]="ECI";E[E.StructuredAppend=3]="StructuredAppend";let F="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".split("");\nfunction ca(a,b){let c=[],d="";b=a.readBits([8,16,16][b]);for(let e=0;e<b;e++){let f=a.readBits(8);c.push(f)}try{d+=decodeURIComponent(c.map(e=>`%${("0"+e.toString(16)).substr(-2)}`).join(""))}catch(e){}return{bytes:c,text:d}}\nfunction da(a,b){a=new ba(a);let c=9>=b?0:26>=b?1:2;for(b={text:"",bytes:[],chunks:[],version:b};4<=a.available();){var d=a.readBits(4);if(d===D.Terminator)return b;if(d===D.ECI)0===a.readBits(1)?b.chunks.push({type:B.ECI,assignmentNumber:a.readBits(7)}):0===a.readBits(1)?b.chunks.push({type:B.ECI,assignmentNumber:a.readBits(14)}):0===a.readBits(1)?b.chunks.push({type:B.ECI,assignmentNumber:a.readBits(21)}):b.chunks.push({type:B.ECI,assignmentNumber:-1});else if(d===D.Numeric){var e=a,f=[];d="";for(var g=\ne.readBits([10,12,14][c]);3<=g;){var h=e.readBits(10);if(1E3<=h)throw Error("Invalid numeric value above 999");var k=Math.floor(h/100),m=Math.floor(h/10)%10;h%=10;f.push(48+k,48+m,48+h);d+=k.toString()+m.toString()+h.toString();g-=3}if(2===g){g=e.readBits(7);if(100<=g)throw Error("Invalid numeric value above 99");e=Math.floor(g/10);g%=10;f.push(48+e,48+g);d+=e.toString()+g.toString()}else if(1===g){e=e.readBits(4);if(10<=e)throw Error("Invalid numeric value above 9");f.push(48+e);d+=e.toString()}b.text+=\nd;b.bytes.push(...f);b.chunks.push({type:B.Numeric,text:d})}else if(d===D.Alphanumeric){e=a;f=[];d="";for(g=e.readBits([9,11,13][c]);2<=g;)m=e.readBits(11),k=Math.floor(m/45),m%=45,f.push(F[k].charCodeAt(0),F[m].charCodeAt(0)),d+=F[k]+F[m],g-=2;1===g&&(e=e.readBits(6),f.push(F[e].charCodeAt(0)),d+=F[e]);b.text+=d;b.bytes.push(...f);b.chunks.push({type:B.Alphanumeric,text:d})}else if(d===D.Byte)d=ca(a,c),b.text+=d.text,b.bytes.push(...d.bytes),b.chunks.push({type:B.Byte,bytes:d.bytes,text:d.text});\nelse if(d===D.Kanji){f=a;d=[];e=f.readBits([8,10,12][c]);for(g=0;g<e;g++)k=f.readBits(13),k=Math.floor(k/192)<<8|k%192,k=7936>k?k+33088:k+49472,d.push(k>>8,k&255);f=(new TextDecoder("shift-jis")).decode(Uint8Array.from(d));b.text+=f;b.bytes.push(...d);b.chunks.push({type:B.Kanji,bytes:d,text:f})}else d===D.StructuredAppend&&b.chunks.push({type:B.StructuredAppend,currentSequence:a.readBits(4),totalSequence:a.readBits(4),parity:a.readBits(8)})}if(0===a.available()||0===a.readBits(a.available()))return b}\nclass G{constructor(a,b){if(0===b.length)throw Error("No coefficients.");this.field=a;let c=b.length;if(1<c&&0===b[0]){let d=1;for(;d<c&&0===b[d];)d++;if(d===c)this.coefficients=a.zero.coefficients;else for(this.coefficients=new Uint8ClampedArray(c-d),a=0;a<this.coefficients.length;a++)this.coefficients[a]=b[d+a]}else this.coefficients=b}degree(){return this.coefficients.length-1}isZero(){return 0===this.coefficients[0]}getCoefficient(a){return this.coefficients[this.coefficients.length-1-a]}addOrSubtract(a){if(this.isZero())return a;\nif(a.isZero())return this;let b=this.coefficients;a=a.coefficients;b.length>a.length&&([b,a]=[a,b]);let c=new Uint8ClampedArray(a.length),d=a.length-b.length;for(var e=0;e<d;e++)c[e]=a[e];for(e=d;e<a.length;e++)c[e]=b[e-d]^a[e];return new G(this.field,c)}multiply(a){if(0===a)return this.field.zero;if(1===a)return this;let b=this.coefficients.length,c=new Uint8ClampedArray(b);for(let d=0;d<b;d++)c[d]=this.field.multiply(this.coefficients[d],a);return new G(this.field,c)}multiplyPoly(a){if(this.isZero()||\na.isZero())return this.field.zero;let b=this.coefficients,c=b.length;a=a.coefficients;let d=a.length,e=new Uint8ClampedArray(c+d-1);for(let f=0;f<c;f++){let g=b[f];for(let h=0;h<d;h++)e[f+h]=H(e[f+h],this.field.multiply(g,a[h]))}return new G(this.field,e)}multiplyByMonomial(a,b){if(0>a)throw Error("Invalid degree less than 0");if(0===b)return this.field.zero;let c=this.coefficients.length;a=new Uint8ClampedArray(c+a);for(let d=0;d<c;d++)a[d]=this.field.multiply(this.coefficients[d],b);return new G(this.field,\na)}evaluateAt(a){let b=0;if(0===a)return this.getCoefficient(0);let c=this.coefficients.length;if(1===a)return this.coefficients.forEach(d=>{b^=d}),b;b=this.coefficients[0];for(let d=1;d<c;d++)b=H(this.field.multiply(a,b),this.coefficients[d]);return b}}function H(a,b){return a^b}\nclass ea{constructor(a,b,c){this.primitive=a;this.size=b;this.generatorBase=c;this.expTable=Array(this.size);this.logTable=Array(this.size);a=1;for(b=0;b<this.size;b++)this.expTable[b]=a,a*=2,a>=this.size&&(a=(a^this.primitive)&this.size-1);for(a=0;a<this.size-1;a++)this.logTable[this.expTable[a]]=a;this.zero=new G(this,Uint8ClampedArray.from([0]));this.one=new G(this,Uint8ClampedArray.from([1]))}multiply(a,b){return 0===a||0===b?0:this.expTable[(this.logTable[a]+this.logTable[b])%(this.size-1)]}inverse(a){if(0===\na)throw Error("Can\'t invert 0");return this.expTable[this.size-this.logTable[a]-1]}buildMonomial(a,b){if(0>a)throw Error("Invalid monomial degree less than 0");if(0===b)return this.zero;a=new Uint8ClampedArray(a+1);a[0]=b;return new G(this,a)}log(a){if(0===a)throw Error("Can\'t take log(0)");return this.logTable[a]}exp(a){return this.expTable[a]}}\nfunction fa(a,b,c,d){b.degree()<c.degree()&&([b,c]=[c,b]);let e=a.zero;for(var f=a.one;c.degree()>=d/2;){var g=b;let h=e;b=c;e=f;if(b.isZero())return null;c=g;f=a.zero;g=b.getCoefficient(b.degree());for(g=a.inverse(g);c.degree()>=b.degree()&&!c.isZero();){let k=c.degree()-b.degree(),m=a.multiply(c.getCoefficient(c.degree()),g);f=f.addOrSubtract(a.buildMonomial(k,m));c=c.addOrSubtract(b.multiplyByMonomial(k,m))}f=f.multiplyPoly(e).addOrSubtract(h);if(c.degree()>=b.degree())return null}d=f.getCoefficient(0);\nif(0===d)return null;a=a.inverse(d);return[f.multiply(a),c.multiply(a)]}\nfunction ha(a,b){let c=new Uint8ClampedArray(a.length);c.set(a);a=new ea(285,256,0);var d=new G(a,c),e=new Uint8ClampedArray(b),f=!1;for(var g=0;g<b;g++){var h=d.evaluateAt(a.exp(g+a.generatorBase));e[e.length-1-g]=h;0!==h&&(f=!0)}if(!f)return c;d=new G(a,e);d=fa(a,a.buildMonomial(b,1),d,b);if(null===d)return null;b=d[0];g=b.degree();if(1===g)b=[b.getCoefficient(1)];else{e=Array(g);f=0;for(h=1;h<a.size&&f<g;h++)0===b.evaluateAt(h)&&(e[f]=a.inverse(h),f++);b=f!==g?null:e}if(null==b)return null;e=d[1];\nf=b.length;d=Array(f);for(g=0;g<f;g++){h=a.inverse(b[g]);let k=1;for(let m=0;m<f;m++)g!==m&&(k=a.multiply(k,H(1,a.multiply(b[m],h))));d[g]=a.multiply(e.evaluateAt(h),a.inverse(k));0!==a.generatorBase&&(d[g]=a.multiply(d[g],h))}for(e=0;e<b.length;e++){f=c.length-1-a.log(b[e]);if(0>f)return null;c[f]^=d[e]}return c}\nlet I=[{infoBits:null,versionNumber:1,alignmentPatternCenters:[],errorCorrectionLevels:[{ecCodewordsPerBlock:7,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:10,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:16}]},{ecCodewordsPerBlock:13,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:13}]},{ecCodewordsPerBlock:17,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:9}]}]},{infoBits:null,versionNumber:2,alignmentPatternCenters:[6,18],errorCorrectionLevels:[{ecCodewordsPerBlock:10,ecBlocks:[{numBlocks:1,\ndataCodewordsPerBlock:34}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:28}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:22}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:16}]}]},{infoBits:null,versionNumber:3,alignmentPatternCenters:[6,22],errorCorrectionLevels:[{ecCodewordsPerBlock:15,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:55}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:18,\necBlocks:[{numBlocks:2,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:13}]}]},{infoBits:null,versionNumber:4,alignmentPatternCenters:[6,26],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:80}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:32}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:9}]}]},\n{infoBits:null,versionNumber:5,alignmentPatternCenters:[6,30],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:43}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:15},{numBlocks:2,dataCodewordsPerBlock:16}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:11},{numBlocks:2,dataCodewordsPerBlock:12}]}]},{infoBits:null,versionNumber:6,alignmentPatternCenters:[6,\n34],errorCorrectionLevels:[{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:68}]},{ecCodewordsPerBlock:16,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:27}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:15}]}]},{infoBits:31892,versionNumber:7,alignmentPatternCenters:[6,22,38],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:78}]},{ecCodewordsPerBlock:18,\necBlocks:[{numBlocks:4,dataCodewordsPerBlock:31}]},{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:14},{numBlocks:4,dataCodewordsPerBlock:15}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:13},{numBlocks:1,dataCodewordsPerBlock:14}]}]},{infoBits:34236,versionNumber:8,alignmentPatternCenters:[6,24,42],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:97}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:38},\n{numBlocks:2,dataCodewordsPerBlock:39}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:18},{numBlocks:2,dataCodewordsPerBlock:19}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:14},{numBlocks:2,dataCodewordsPerBlock:15}]}]},{infoBits:39577,versionNumber:9,alignmentPatternCenters:[6,26,46],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:36},\n{numBlocks:2,dataCodewordsPerBlock:37}]},{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:16},{numBlocks:4,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:12},{numBlocks:4,dataCodewordsPerBlock:13}]}]},{infoBits:42195,versionNumber:10,alignmentPatternCenters:[6,28,50],errorCorrectionLevels:[{ecCodewordsPerBlock:18,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:68},{numBlocks:2,dataCodewordsPerBlock:69}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,\ndataCodewordsPerBlock:43},{numBlocks:1,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:19},{numBlocks:2,dataCodewordsPerBlock:20}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:15},{numBlocks:2,dataCodewordsPerBlock:16}]}]},{infoBits:48118,versionNumber:11,alignmentPatternCenters:[6,30,54],errorCorrectionLevels:[{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:81}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:1,\ndataCodewordsPerBlock:50},{numBlocks:4,dataCodewordsPerBlock:51}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:22},{numBlocks:4,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:12},{numBlocks:8,dataCodewordsPerBlock:13}]}]},{infoBits:51042,versionNumber:12,alignmentPatternCenters:[6,32,58],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:92},{numBlocks:2,dataCodewordsPerBlock:93}]},\n{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:36},{numBlocks:2,dataCodewordsPerBlock:37}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:20},{numBlocks:6,dataCodewordsPerBlock:21}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:14},{numBlocks:4,dataCodewordsPerBlock:15}]}]},{infoBits:55367,versionNumber:13,alignmentPatternCenters:[6,34,62],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:107}]},\n{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:37},{numBlocks:1,dataCodewordsPerBlock:38}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:20},{numBlocks:4,dataCodewordsPerBlock:21}]},{ecCodewordsPerBlock:22,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:11},{numBlocks:4,dataCodewordsPerBlock:12}]}]},{infoBits:58893,versionNumber:14,alignmentPatternCenters:[6,26,46,66],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:115},\n{numBlocks:1,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:40},{numBlocks:5,dataCodewordsPerBlock:41}]},{ecCodewordsPerBlock:20,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:16},{numBlocks:5,dataCodewordsPerBlock:17}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:12},{numBlocks:5,dataCodewordsPerBlock:13}]}]},{infoBits:63784,versionNumber:15,alignmentPatternCenters:[6,26,48,70],errorCorrectionLevels:[{ecCodewordsPerBlock:22,\necBlocks:[{numBlocks:5,dataCodewordsPerBlock:87},{numBlocks:1,dataCodewordsPerBlock:88}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:41},{numBlocks:5,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:24},{numBlocks:7,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:12},{numBlocks:7,dataCodewordsPerBlock:13}]}]},{infoBits:68472,versionNumber:16,alignmentPatternCenters:[6,26,50,\n74],errorCorrectionLevels:[{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:98},{numBlocks:1,dataCodewordsPerBlock:99}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:45},{numBlocks:3,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:19},{numBlocks:2,dataCodewordsPerBlock:20}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:15},{numBlocks:13,dataCodewordsPerBlock:16}]}]},{infoBits:70749,\nversionNumber:17,alignmentPatternCenters:[6,30,54,78],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:107},{numBlocks:5,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:46},{numBlocks:1,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:22},{numBlocks:15,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:14},{numBlocks:17,\ndataCodewordsPerBlock:15}]}]},{infoBits:76311,versionNumber:18,alignmentPatternCenters:[6,30,56,82],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:120},{numBlocks:1,dataCodewordsPerBlock:121}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:9,dataCodewordsPerBlock:43},{numBlocks:4,dataCodewordsPerBlock:44}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:22},{numBlocks:1,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,\ndataCodewordsPerBlock:14},{numBlocks:19,dataCodewordsPerBlock:15}]}]},{infoBits:79154,versionNumber:19,alignmentPatternCenters:[6,30,58,86],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:113},{numBlocks:4,dataCodewordsPerBlock:114}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:44},{numBlocks:11,dataCodewordsPerBlock:45}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:21},{numBlocks:4,dataCodewordsPerBlock:22}]},\n{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:9,dataCodewordsPerBlock:13},{numBlocks:16,dataCodewordsPerBlock:14}]}]},{infoBits:84390,versionNumber:20,alignmentPatternCenters:[6,34,62,90],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:107},{numBlocks:5,dataCodewordsPerBlock:108}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:41},{numBlocks:13,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:24},\n{numBlocks:5,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:15},{numBlocks:10,dataCodewordsPerBlock:16}]}]},{infoBits:87683,versionNumber:21,alignmentPatternCenters:[6,28,50,72,94],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:116},{numBlocks:4,dataCodewordsPerBlock:117}]},{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:42}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:22},\n{numBlocks:6,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:16},{numBlocks:6,dataCodewordsPerBlock:17}]}]},{infoBits:92361,versionNumber:22,alignmentPatternCenters:[6,26,50,74,98],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:111},{numBlocks:7,dataCodewordsPerBlock:112}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:24},\n{numBlocks:16,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:24,ecBlocks:[{numBlocks:34,dataCodewordsPerBlock:13}]}]},{infoBits:96236,versionNumber:23,alignmentPatternCenters:[6,30,54,74,102],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:121},{numBlocks:5,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:47},{numBlocks:14,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:24},\n{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:16,dataCodewordsPerBlock:15},{numBlocks:14,dataCodewordsPerBlock:16}]}]},{infoBits:102084,versionNumber:24,alignmentPatternCenters:[6,28,54,80,106],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:117},{numBlocks:4,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:45},{numBlocks:14,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,\necBlocks:[{numBlocks:11,dataCodewordsPerBlock:24},{numBlocks:16,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:30,dataCodewordsPerBlock:16},{numBlocks:2,dataCodewordsPerBlock:17}]}]},{infoBits:102881,versionNumber:25,alignmentPatternCenters:[6,32,58,84,110],errorCorrectionLevels:[{ecCodewordsPerBlock:26,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:106},{numBlocks:4,dataCodewordsPerBlock:107}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:47},{numBlocks:13,\ndataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:7,dataCodewordsPerBlock:24},{numBlocks:22,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:15},{numBlocks:13,dataCodewordsPerBlock:16}]}]},{infoBits:110507,versionNumber:26,alignmentPatternCenters:[6,30,58,86,114],errorCorrectionLevels:[{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:114},{numBlocks:2,dataCodewordsPerBlock:115}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:19,\ndataCodewordsPerBlock:46},{numBlocks:4,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:28,dataCodewordsPerBlock:22},{numBlocks:6,dataCodewordsPerBlock:23}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:33,dataCodewordsPerBlock:16},{numBlocks:4,dataCodewordsPerBlock:17}]}]},{infoBits:110734,versionNumber:27,alignmentPatternCenters:[6,34,62,90,118],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:122},{numBlocks:4,dataCodewordsPerBlock:123}]},\n{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:45},{numBlocks:3,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:8,dataCodewordsPerBlock:23},{numBlocks:26,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:15},{numBlocks:28,dataCodewordsPerBlock:16}]}]},{infoBits:117786,versionNumber:28,alignmentPatternCenters:[6,26,50,74,98,122],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:117},\n{numBlocks:10,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:3,dataCodewordsPerBlock:45},{numBlocks:23,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,dataCodewordsPerBlock:24},{numBlocks:31,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:15},{numBlocks:31,dataCodewordsPerBlock:16}]}]},{infoBits:119615,versionNumber:29,alignmentPatternCenters:[6,30,54,78,102,126],errorCorrectionLevels:[{ecCodewordsPerBlock:30,\necBlocks:[{numBlocks:7,dataCodewordsPerBlock:116},{numBlocks:7,dataCodewordsPerBlock:117}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:21,dataCodewordsPerBlock:45},{numBlocks:7,dataCodewordsPerBlock:46}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:1,dataCodewordsPerBlock:23},{numBlocks:37,dataCodewordsPerBlock:24}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:15},{numBlocks:26,dataCodewordsPerBlock:16}]}]},{infoBits:126325,versionNumber:30,alignmentPatternCenters:[6,\n26,52,78,104,130],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:5,dataCodewordsPerBlock:115},{numBlocks:10,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:47},{numBlocks:10,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:15,dataCodewordsPerBlock:24},{numBlocks:25,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:23,dataCodewordsPerBlock:15},{numBlocks:25,dataCodewordsPerBlock:16}]}]},\n{infoBits:127568,versionNumber:31,alignmentPatternCenters:[6,30,56,82,108,134],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:115},{numBlocks:3,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:46},{numBlocks:29,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:42,dataCodewordsPerBlock:24},{numBlocks:1,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:23,dataCodewordsPerBlock:15},\n{numBlocks:28,dataCodewordsPerBlock:16}]}]},{infoBits:133589,versionNumber:32,alignmentPatternCenters:[6,34,60,86,112,138],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:115}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:46},{numBlocks:23,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:24},{numBlocks:35,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,\ndataCodewordsPerBlock:15},{numBlocks:35,dataCodewordsPerBlock:16}]}]},{infoBits:136944,versionNumber:33,alignmentPatternCenters:[6,30,58,86,114,142],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:115},{numBlocks:1,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:14,dataCodewordsPerBlock:46},{numBlocks:21,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:29,dataCodewordsPerBlock:24},{numBlocks:19,dataCodewordsPerBlock:25}]},\n{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:11,dataCodewordsPerBlock:15},{numBlocks:46,dataCodewordsPerBlock:16}]}]},{infoBits:141498,versionNumber:34,alignmentPatternCenters:[6,34,62,90,118,146],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:115},{numBlocks:6,dataCodewordsPerBlock:116}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:14,dataCodewordsPerBlock:46},{numBlocks:23,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:44,\ndataCodewordsPerBlock:24},{numBlocks:7,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:59,dataCodewordsPerBlock:16},{numBlocks:1,dataCodewordsPerBlock:17}]}]},{infoBits:145311,versionNumber:35,alignmentPatternCenters:[6,30,54,78,102,126,150],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:121},{numBlocks:7,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:12,dataCodewordsPerBlock:47},{numBlocks:26,dataCodewordsPerBlock:48}]},\n{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:39,dataCodewordsPerBlock:24},{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:22,dataCodewordsPerBlock:15},{numBlocks:41,dataCodewordsPerBlock:16}]}]},{infoBits:150283,versionNumber:36,alignmentPatternCenters:[6,24,50,76,102,128,154],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:6,dataCodewordsPerBlock:121},{numBlocks:14,dataCodewordsPerBlock:122}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:6,\ndataCodewordsPerBlock:47},{numBlocks:34,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:46,dataCodewordsPerBlock:24},{numBlocks:10,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:2,dataCodewordsPerBlock:15},{numBlocks:64,dataCodewordsPerBlock:16}]}]},{infoBits:152622,versionNumber:37,alignmentPatternCenters:[6,28,54,80,106,132,158],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:17,dataCodewordsPerBlock:122},{numBlocks:4,dataCodewordsPerBlock:123}]},\n{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:29,dataCodewordsPerBlock:46},{numBlocks:14,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:49,dataCodewordsPerBlock:24},{numBlocks:10,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:24,dataCodewordsPerBlock:15},{numBlocks:46,dataCodewordsPerBlock:16}]}]},{infoBits:158308,versionNumber:38,alignmentPatternCenters:[6,32,58,84,110,136,162],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:4,\ndataCodewordsPerBlock:122},{numBlocks:18,dataCodewordsPerBlock:123}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:13,dataCodewordsPerBlock:46},{numBlocks:32,dataCodewordsPerBlock:47}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:48,dataCodewordsPerBlock:24},{numBlocks:14,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:42,dataCodewordsPerBlock:15},{numBlocks:32,dataCodewordsPerBlock:16}]}]},{infoBits:161089,versionNumber:39,alignmentPatternCenters:[6,26,54,82,110,138,166],\nerrorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:20,dataCodewordsPerBlock:117},{numBlocks:4,dataCodewordsPerBlock:118}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:40,dataCodewordsPerBlock:47},{numBlocks:7,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:43,dataCodewordsPerBlock:24},{numBlocks:22,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:10,dataCodewordsPerBlock:15},{numBlocks:67,dataCodewordsPerBlock:16}]}]},{infoBits:167017,\nversionNumber:40,alignmentPatternCenters:[6,30,58,86,114,142,170],errorCorrectionLevels:[{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:19,dataCodewordsPerBlock:118},{numBlocks:6,dataCodewordsPerBlock:119}]},{ecCodewordsPerBlock:28,ecBlocks:[{numBlocks:18,dataCodewordsPerBlock:47},{numBlocks:31,dataCodewordsPerBlock:48}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:34,dataCodewordsPerBlock:24},{numBlocks:34,dataCodewordsPerBlock:25}]},{ecCodewordsPerBlock:30,ecBlocks:[{numBlocks:20,dataCodewordsPerBlock:15},\n{numBlocks:61,dataCodewordsPerBlock:16}]}]}];function J(a,b){a^=b;for(b=0;a;)b++,a&=a-1;return b}function K(a,b){return b<<1|a}\nlet ia=[{bits:21522,formatInfo:{errorCorrectionLevel:1,dataMask:0}},{bits:20773,formatInfo:{errorCorrectionLevel:1,dataMask:1}},{bits:24188,formatInfo:{errorCorrectionLevel:1,dataMask:2}},{bits:23371,formatInfo:{errorCorrectionLevel:1,dataMask:3}},{bits:17913,formatInfo:{errorCorrectionLevel:1,dataMask:4}},{bits:16590,formatInfo:{errorCorrectionLevel:1,dataMask:5}},{bits:20375,formatInfo:{errorCorrectionLevel:1,dataMask:6}},{bits:19104,formatInfo:{errorCorrectionLevel:1,dataMask:7}},{bits:30660,formatInfo:{errorCorrectionLevel:0,\ndataMask:0}},{bits:29427,formatInfo:{errorCorrectionLevel:0,dataMask:1}},{bits:32170,formatInfo:{errorCorrectionLevel:0,dataMask:2}},{bits:30877,formatInfo:{errorCorrectionLevel:0,dataMask:3}},{bits:26159,formatInfo:{errorCorrectionLevel:0,dataMask:4}},{bits:25368,formatInfo:{errorCorrectionLevel:0,dataMask:5}},{bits:27713,formatInfo:{errorCorrectionLevel:0,dataMask:6}},{bits:26998,formatInfo:{errorCorrectionLevel:0,dataMask:7}},{bits:5769,formatInfo:{errorCorrectionLevel:3,dataMask:0}},{bits:5054,\nformatInfo:{errorCorrectionLevel:3,dataMask:1}},{bits:7399,formatInfo:{errorCorrectionLevel:3,dataMask:2}},{bits:6608,formatInfo:{errorCorrectionLevel:3,dataMask:3}},{bits:1890,formatInfo:{errorCorrectionLevel:3,dataMask:4}},{bits:597,formatInfo:{errorCorrectionLevel:3,dataMask:5}},{bits:3340,formatInfo:{errorCorrectionLevel:3,dataMask:6}},{bits:2107,formatInfo:{errorCorrectionLevel:3,dataMask:7}},{bits:13663,formatInfo:{errorCorrectionLevel:2,dataMask:0}},{bits:12392,formatInfo:{errorCorrectionLevel:2,\ndataMask:1}},{bits:16177,formatInfo:{errorCorrectionLevel:2,dataMask:2}},{bits:14854,formatInfo:{errorCorrectionLevel:2,dataMask:3}},{bits:9396,formatInfo:{errorCorrectionLevel:2,dataMask:4}},{bits:8579,formatInfo:{errorCorrectionLevel:2,dataMask:5}},{bits:11994,formatInfo:{errorCorrectionLevel:2,dataMask:6}},{bits:11245,formatInfo:{errorCorrectionLevel:2,dataMask:7}}],ja=[a=>0===(a.y+a.x)%2,a=>0===a.y%2,a=>0===a.x%3,a=>0===(a.y+a.x)%3,a=>0===(Math.floor(a.y/2)+Math.floor(a.x/3))%2,a=>0===a.x*a.y%\n2+a.x*a.y%3,a=>0===(a.y*a.x%2+a.y*a.x%3)%2,a=>0===((a.y+a.x)%2+a.y*a.x%3)%2];\nfunction ka(a,b,c){c=ja[c.dataMask];let d=a.height;var e=17+4*b.versionNumber;let f=x.createEmpty(e,e);f.setRegion(0,0,9,9,!0);f.setRegion(e-8,0,8,9,!0);f.setRegion(0,e-8,9,8,!0);for(var g of b.alignmentPatternCenters)for(var h of b.alignmentPatternCenters)6===g&&6===h||6===g&&h===e-7||g===e-7&&6===h||f.setRegion(g-2,h-2,5,5,!0);f.setRegion(6,9,1,e-17,!0);f.setRegion(9,6,e-17,1,!0);6<b.versionNumber&&(f.setRegion(e-11,0,3,6,!0),f.setRegion(0,e-11,6,3,!0));b=[];h=g=0;e=!0;for(let k=d-1;0<k;k-=2){6===\nk&&k--;for(let m=0;m<d;m++){let l=e?d-1-m:m;for(let n=0;2>n;n++){let q=k-n;if(!f.get(q,l)){h++;let r=a.get(q,l);c({y:l,x:q})&&(r=!r);g=g<<1|r;8===h&&(b.push(g),g=h=0)}}}e=!e}return b}\nfunction la(a){var b=a.height,c=Math.floor((b-17)/4);if(6>=c)return I[c-1];c=0;for(var d=5;0<=d;d--)for(var e=b-9;e>=b-11;e--)c=K(a.get(e,d),c);d=0;for(e=5;0<=e;e--)for(let g=b-9;g>=b-11;g--)d=K(a.get(e,g),d);a=Infinity;let f;for(let g of I){if(g.infoBits===c||g.infoBits===d)return g;b=J(c,g.infoBits);b<a&&(f=g,a=b);b=J(d,g.infoBits);b<a&&(f=g,a=b)}if(3>=a)return f}\nfunction ma(a){let b=0;for(var c=0;8>=c;c++)6!==c&&(b=K(a.get(c,8),b));for(c=7;0<=c;c--)6!==c&&(b=K(a.get(8,c),b));var d=a.height;c=0;for(var e=d-1;e>=d-7;e--)c=K(a.get(8,e),c);for(e=d-8;e<d;e++)c=K(a.get(e,8),c);a=Infinity;d=null;for(let {bits:f,formatInfo:g}of ia){if(f===b||f===c)return g;e=J(b,f);e<a&&(d=g,a=e);b!==c&&(e=J(c,f),e<a&&(d=g,a=e))}return 3>=a?d:null}\nfunction na(a,b,c){let d=b.errorCorrectionLevels[c],e=[],f=0;d.ecBlocks.forEach(h=>{for(let k=0;k<h.numBlocks;k++)e.push({numDataCodewords:h.dataCodewordsPerBlock,codewords:[]}),f+=h.dataCodewordsPerBlock+d.ecCodewordsPerBlock});if(a.length<f)return null;a=a.slice(0,f);b=d.ecBlocks[0].dataCodewordsPerBlock;for(c=0;c<b;c++)for(var g of e)g.codewords.push(a.shift());if(1<d.ecBlocks.length)for(g=d.ecBlocks[0].numBlocks,b=d.ecBlocks[1].numBlocks,c=0;c<b;c++)e[g+c].codewords.push(a.shift());for(;0<a.length;)for(let h of e)h.codewords.push(a.shift());\nreturn e}function L(a){let b=la(a);if(!b)return null;var c=ma(a);if(!c)return null;a=ka(a,b,c);var d=na(a,b,c.errorCorrectionLevel);if(!d)return null;c=d.reduce((e,f)=>e+f.numDataCodewords,0);c=new Uint8ClampedArray(c);a=0;for(let e of d){d=ha(e.codewords,e.codewords.length-e.numDataCodewords);if(!d)return null;for(let f=0;f<e.numDataCodewords;f++)c[a++]=d[f]}try{return da(c,b.versionNumber)}catch(e){return null}}\nfunction M(a,b,c,d){var e=a.x-b.x+c.x-d.x;let f=a.y-b.y+c.y-d.y;if(0===e&&0===f)return{a11:b.x-a.x,a12:b.y-a.y,a13:0,a21:c.x-b.x,a22:c.y-b.y,a23:0,a31:a.x,a32:a.y,a33:1};let g=b.x-c.x;var h=d.x-c.x;let k=b.y-c.y,m=d.y-c.y;c=g*m-h*k;h=(e*m-h*f)/c;e=(g*f-e*k)/c;return{a11:b.x-a.x+h*b.x,a12:b.y-a.y+h*b.y,a13:h,a21:d.x-a.x+e*d.x,a22:d.y-a.y+e*d.y,a23:e,a31:a.x,a32:a.y,a33:1}}\nfunction oa(a,b,c,d){a=M(a,b,c,d);return{a11:a.a22*a.a33-a.a23*a.a32,a12:a.a13*a.a32-a.a12*a.a33,a13:a.a12*a.a23-a.a13*a.a22,a21:a.a23*a.a31-a.a21*a.a33,a22:a.a11*a.a33-a.a13*a.a31,a23:a.a13*a.a21-a.a11*a.a23,a31:a.a21*a.a32-a.a22*a.a31,a32:a.a12*a.a31-a.a11*a.a32,a33:a.a11*a.a22-a.a12*a.a21}}\nfunction pa(a,b){var c=oa({x:3.5,y:3.5},{x:b.dimension-3.5,y:3.5},{x:b.dimension-6.5,y:b.dimension-6.5},{x:3.5,y:b.dimension-3.5}),d=M(b.topLeft,b.topRight,b.alignmentPattern,b.bottomLeft),e=d.a11*c.a11+d.a21*c.a12+d.a31*c.a13,f=d.a12*c.a11+d.a22*c.a12+d.a32*c.a13,g=d.a13*c.a11+d.a23*c.a12+d.a33*c.a13,h=d.a11*c.a21+d.a21*c.a22+d.a31*c.a23,k=d.a12*c.a21+d.a22*c.a22+d.a32*c.a23,m=d.a13*c.a21+d.a23*c.a22+d.a33*c.a23,l=d.a11*c.a31+d.a21*c.a32+d.a31*c.a33,n=d.a12*c.a31+d.a22*c.a32+d.a32*c.a33,q=d.a13*\nc.a31+d.a23*c.a32+d.a33*c.a33;c=x.createEmpty(b.dimension,b.dimension);d=(r,u)=>{const p=g*r+m*u+q;return{x:(e*r+h*u+l)/p,y:(f*r+k*u+n)/p}};for(let r=0;r<b.dimension;r++)for(let u=0;u<b.dimension;u++){let p=d(u+.5,r+.5);c.set(u,r,a.get(Math.floor(p.x),Math.floor(p.y)))}return{matrix:c,mappingFunction:d}}let N=(a,b)=>Math.sqrt(Math.pow(b.x-a.x,2)+Math.pow(b.y-a.y,2));function O(a){return a.reduce((b,c)=>b+c)}\nfunction qa(a,b,c){let d=N(a,b),e=N(b,c),f=N(a,c),g,h,k;e>=d&&e>=f?[g,h,k]=[b,a,c]:f>=e&&f>=d?[g,h,k]=[a,b,c]:[g,h,k]=[a,c,b];0>(k.x-h.x)*(g.y-h.y)-(k.y-h.y)*(g.x-h.x)&&([g,k]=[k,g]);return{bottomLeft:g,topLeft:h,topRight:k}}\nfunction ra(a,b,c,d){d=(O(P(a,c,d,5))/7+O(P(a,b,d,5))/7+O(P(c,a,d,5))/7+O(P(b,a,d,5))/7)/4;if(1>d)throw Error("Invalid module size");b=Math.round(N(a,b)/d);a=Math.round(N(a,c)/d);a=Math.floor((b+a)/2)+7;switch(a%4){case 0:a++;break;case 2:a--}return{dimension:a,moduleSize:d}}\nfunction Q(a,b,c,d){let e=[{x:Math.floor(a.x),y:Math.floor(a.y)}];var f=Math.abs(b.y-a.y)>Math.abs(b.x-a.x);if(f){var g=Math.floor(a.y);var h=Math.floor(a.x);a=Math.floor(b.y);b=Math.floor(b.x)}else g=Math.floor(a.x),h=Math.floor(a.y),a=Math.floor(b.x),b=Math.floor(b.y);let k=Math.abs(a-g),m=Math.abs(b-h),l=Math.floor(-k/2),n=g<a?1:-1,q=h<b?1:-1,r=!0;for(let u=g,p=h;u!==a+n;u+=n){g=f?p:u;h=f?u:p;if(c.get(g,h)!==r&&(r=!r,e.push({x:g,y:h}),e.length===d+1))break;l+=m;if(0<l){if(p===b)break;p+=q;l-=k}}c=\n[];for(f=0;f<d;f++)e[f]&&e[f+1]?c.push(N(e[f],e[f+1])):c.push(0);return c}function P(a,b,c,d){let e=b.y-a.y,f=b.x-a.x;b=Q(a,b,c,Math.ceil(d/2));a=Q(a,{x:a.x-f,y:a.y-e},c,Math.ceil(d/2));c=b.shift()+a.shift()-1;return a.concat(c).concat(...b)}function R(a,b){let c=O(a)/O(b),d=0;b.forEach((e,f)=>{d+=Math.pow(a[f]-e*c,2)});return{averageSize:c,error:d}}\nfunction S(a,b,c){try{let d=P(a,{x:-1,y:a.y},c,b.length),e=P(a,{x:a.x,y:-1},c,b.length),f=P(a,{x:Math.max(0,a.x-a.y)-1,y:Math.max(0,a.y-a.x)-1},c,b.length),g=P(a,{x:Math.min(c.width,a.x+a.y)+1,y:Math.min(c.height,a.y+a.x)+1},c,b.length),h=R(d,b),k=R(e,b),m=R(f,b),l=R(g,b),n=(h.averageSize+k.averageSize+m.averageSize+l.averageSize)/4;return Math.sqrt(h.error*h.error+k.error*k.error+m.error*m.error+l.error*l.error)+(Math.pow(h.averageSize-n,2)+Math.pow(k.averageSize-n,2)+Math.pow(m.averageSize-n,2)+\nMath.pow(l.averageSize-n,2))/n}catch(d){return Infinity}}function T(a,b){for(var c=Math.round(b.x);a.get(c,Math.round(b.y));)c--;for(var d=Math.round(b.x);a.get(d,Math.round(b.y));)d++;c=(c+d)/2;for(d=Math.round(b.y);a.get(Math.round(c),d);)d--;for(b=Math.round(b.y);a.get(Math.round(c),b);)b++;return{x:c,y:(d+b)/2}}\nfunction sa(a){var b=[],c=[];let d=[];var e=[];for(let p=0;p<=a.height;p++){var f=0,g=!1;let t=[0,0,0,0,0];for(let v=-1;v<=a.width;v++){var h=a.get(v,p);if(h===g)f++;else{t=[t[1],t[2],t[3],t[4],f];f=1;g=h;var k=O(t)/7;k=Math.abs(t[0]-k)<k&&Math.abs(t[1]-k)<k&&Math.abs(t[2]-3*k)<3*k&&Math.abs(t[3]-k)<k&&Math.abs(t[4]-k)<k&&!h;var m=O(t.slice(-3))/3;h=Math.abs(t[2]-m)<m&&Math.abs(t[3]-m)<m&&Math.abs(t[4]-m)<m&&h;if(k){let z=v-t[3]-t[4],y=z-t[2];k={startX:y,endX:z,y:p};m=c.filter(w=>y>=w.bottom.startX&&\ny<=w.bottom.endX||z>=w.bottom.startX&&y<=w.bottom.endX||y<=w.bottom.startX&&z>=w.bottom.endX&&1.5>t[2]/(w.bottom.endX-w.bottom.startX)&&.5<t[2]/(w.bottom.endX-w.bottom.startX));0<m.length?m[0].bottom=k:c.push({top:k,bottom:k})}if(h){let z=v-t[4],y=z-t[3];h={startX:y,y:p,endX:z};k=e.filter(w=>y>=w.bottom.startX&&y<=w.bottom.endX||z>=w.bottom.startX&&y<=w.bottom.endX||y<=w.bottom.startX&&z>=w.bottom.endX&&1.5>t[2]/(w.bottom.endX-w.bottom.startX)&&.5<t[2]/(w.bottom.endX-w.bottom.startX));0<k.length?\nk[0].bottom=h:e.push({top:h,bottom:h})}}}b.push(...c.filter(v=>v.bottom.y!==p&&2<=v.bottom.y-v.top.y));c=c.filter(v=>v.bottom.y===p);d.push(...e.filter(v=>v.bottom.y!==p));e=e.filter(v=>v.bottom.y===p)}b.push(...c.filter(p=>2<=p.bottom.y-p.top.y));d.push(...e);c=[];for(var l of b)2>l.bottom.y-l.top.y||(b=(l.top.startX+l.top.endX+l.bottom.startX+l.bottom.endX)/4,e=(l.top.y+l.bottom.y+1)/2,a.get(Math.round(b),Math.round(e))&&(f=[l.top.endX-l.top.startX,l.bottom.endX-l.bottom.startX,l.bottom.y-l.top.y+\n1],f=O(f)/f.length,g=S({x:Math.round(b),y:Math.round(e)},[1,1,3,1,1],a),c.push({score:g,x:b,y:e,size:f})));if(3>c.length)return null;c.sort((p,t)=>p.score-t.score);l=[];for(b=0;b<Math.min(c.length,5);++b){e=c[b];f=[];for(var n of c)n!==e&&f.push(Object.assign(Object.assign({},n),{score:n.score+Math.pow(n.size-e.size,2)/e.size}));f.sort((p,t)=>p.score-t.score);l.push({points:[e,f[0],f[1]],score:e.score+f[0].score+f[1].score})}l.sort((p,t)=>p.score-t.score);let {topRight:q,topLeft:r,bottomLeft:u}=qa(...l[0].points);\nl=U(a,d,q,r,u);n=[];l&&n.push({alignmentPattern:{x:l.alignmentPattern.x,y:l.alignmentPattern.y},bottomLeft:{x:u.x,y:u.y},dimension:l.dimension,topLeft:{x:r.x,y:r.y},topRight:{x:q.x,y:q.y}});l=T(a,q);b=T(a,r);c=T(a,u);(a=U(a,d,l,b,c))&&n.push({alignmentPattern:{x:a.alignmentPattern.x,y:a.alignmentPattern.y},bottomLeft:{x:c.x,y:c.y},topLeft:{x:b.x,y:b.y},topRight:{x:l.x,y:l.y},dimension:a.dimension});return 0===n.length?null:n}\nfunction U(a,b,c,d,e){let f,g;try{({dimension:f,moduleSize:g}=ra(d,c,e,a))}catch(l){return null}var h=c.x-d.x+e.x,k=c.y-d.y+e.y;c=(N(d,e)+N(d,c))/2/g;e=1-3/c;let m={x:d.x+e*(h-d.x),y:d.y+e*(k-d.y)};b=b.map(l=>{const n=(l.top.startX+l.top.endX+l.bottom.startX+l.bottom.endX)/4;l=(l.top.y+l.bottom.y+1)/2;if(a.get(Math.floor(n),Math.floor(l))){var q=S({x:Math.floor(n),y:Math.floor(l)},[1,1,1],a)+N({x:n,y:l},m);return{x:n,y:l,score:q}}}).filter(l=>!!l).sort((l,n)=>l.score-n.score);return{alignmentPattern:15<=\nc&&b.length?b[0]:m,dimension:f}}\nfunction V(a){var b=sa(a);if(!b)return null;for(let e of b){b=pa(a,e);var c=b.matrix;if(null==c)c=null;else{var d=L(c);if(d)c=d;else{for(d=0;d<c.width;d++)for(let f=d+1;f<c.height;f++)c.get(d,f)!==c.get(f,d)&&(c.set(d,f,!c.get(d,f)),c.set(f,d,!c.get(f,d)));c=L(c)}}if(c)return{binaryData:c.bytes,data:c.text,chunks:c.chunks,version:c.version,location:{topRightCorner:b.mappingFunction(e.dimension,0),topLeftCorner:b.mappingFunction(0,0),bottomRightCorner:b.mappingFunction(e.dimension,e.dimension),bottomLeftCorner:b.mappingFunction(0,\ne.dimension),topRightFinderPattern:e.topRight,topLeftFinderPattern:e.topLeft,bottomLeftFinderPattern:e.bottomLeft,bottomRightAlignmentPattern:e.alignmentPattern},matrix:b.matrix}}return null}let ta={inversionAttempts:"attemptBoth",greyScaleWeights:{red:.2126,green:.7152,blue:.0722,useIntegerApproximation:!1},canOverwriteImage:!0};function W(a,b){Object.keys(b).forEach(c=>{a[c]=b[c]})}\nfunction X(a,b,c,d={}){let e=Object.create(null);W(e,ta);W(e,d);d="onlyInvert"===e.inversionAttempts||"invertFirst"===e.inversionAttempts;var f="attemptBoth"===e.inversionAttempts||d;var g=e.greyScaleWeights,h=e.canOverwriteImage,k=b*c;if(a.length!==4*k)throw Error("Malformed data passed to binarizer.");var m=0;if(h){var l=new Uint8ClampedArray(a.buffer,m,k);m+=k}l=new A(b,c,l);if(g.useIntegerApproximation)for(var n=0;n<c;n++)for(var q=0;q<b;q++){var r=4*(n*b+q);l.set(q,n,g.red*a[r]+g.green*a[r+1]+\ng.blue*a[r+2]+128>>8)}else for(n=0;n<c;n++)for(q=0;q<b;q++)r=4*(n*b+q),l.set(q,n,g.red*a[r]+g.green*a[r+1]+g.blue*a[r+2]);g=Math.ceil(b/8);n=Math.ceil(c/8);q=g*n;if(h){var u=new Uint8ClampedArray(a.buffer,m,q);m+=q}u=new A(g,n,u);for(q=0;q<n;q++)for(r=0;r<g;r++){var p=Infinity,t=0;for(var v=0;8>v;v++)for(let w=0;8>w;w++){let aa=l.get(8*r+w,8*q+v);p=Math.min(p,aa);t=Math.max(t,aa)}v=(p+t)/2;v=Math.min(255,1.11*v);24>=t-p&&(v=p/2,0<q&&0<r&&(t=(u.get(r,q-1)+2*u.get(r-1,q)+u.get(r-1,q-1))/4,p<t&&(v=t)));\nu.set(r,q,v)}h?(q=new Uint8ClampedArray(a.buffer,m,k),m+=k,q=new x(q,b)):q=x.createEmpty(b,c);r=null;f&&(h?(a=new Uint8ClampedArray(a.buffer,m,k),r=new x(a,b)):r=x.createEmpty(b,c));for(b=0;b<n;b++)for(a=0;a<g;a++){c=g-3;c=2>a?2:a>c?c:a;h=n-3;h=2>b?2:b>h?h:b;k=0;for(m=-2;2>=m;m++)for(p=-2;2>=p;p++)k+=u.get(c+m,h+p);c=k/25;for(h=0;8>h;h++)for(k=0;8>k;k++)m=8*a+h,p=8*b+k,t=l.get(m,p),q.set(m,p,t<=c),f&&r.set(m,p,!(t<=c))}f=f?{binarized:q,inverted:r}:{binarized:q};let {binarized:z,inverted:y}=f;(f=V(d?\ny:z))||"attemptBoth"!==e.inversionAttempts&&"invertFirst"!==e.inversionAttempts||(f=V(d?z:y));return f}X.default=X;let Y="dontInvert",Z={red:77,green:150,blue:29,useIntegerApproximation:!0};\nself.onmessage=a=>{let b=a.data.id,c=a.data.data;switch(a.data.type){case "decode":(a=X(c.data,c.width,c.height,{inversionAttempts:Y,greyScaleWeights:Z}))?self.postMessage({id:b,type:"qrResult",data:a.data,cornerPoints:[a.location.topLeftCorner,a.location.topRightCorner,a.location.bottomRightCorner,a.location.bottomLeftCorner]}):self.postMessage({id:b,type:"qrResult",data:null});break;case "grayscaleWeights":Z.red=c.red;Z.green=c.green;Z.blue=c.blue;Z.useIntegerApproximation=c.useIntegerApproximation;\nbreak;case "inversionMode":switch(c){case "original":Y="dontInvert";break;case "invert":Y="onlyInvert";break;case "both":Y="attemptBoth";break;default:throw Error("Invalid inversion mode");}break;case "close":self.close()}}\n']),{type:"application/javascript"}));var qrScannerWorker_min=Object.freeze({__proto__:null,createWorker:createWorker});export{NostrLoginInitializer,cancelNeedAuth,init,launch,logout,setAuth,setDarkMode};
|
|
19
29
|
//# sourceMappingURL=index.esm.js.map
|