window.nostr.js 0.4.1 → 0.4.3

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.html CHANGED
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>dev</title>
7
- <script type="module" crossorigin src="/assets/index-Uwioo2GJ.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-odL9uLud.js"></script>
8
8
  </head>
9
9
  <body
10
10
  style="
@@ -1,23 +1,23 @@
1
- var bl=Object.defineProperty;var wl=(Ye,j,Pe)=>j in Ye?bl(Ye,j,{enumerable:!0,configurable:!0,writable:!0,value:Pe}):Ye[j]=Pe;var B=(Ye,j,Pe)=>(wl(Ye,typeof j!="symbol"?j+"":j,Pe),Pe);(function(){"use strict";var Do,Vo,Fo,Go,Yo;const Ye='*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;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,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,[type=button],[type=reset],[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,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--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-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(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;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::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-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(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;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.fixed{position:fixed}.absolute{position:absolute}.bottom-1{bottom:.25rem}.right-2{right:.5rem}.right-3{right:.75rem}.top-0{top:0}.m-auto{margin:auto}.mx-2{margin-left:.5rem;margin-right:.5rem}.my-2{margin-top:.5rem;margin-bottom:.5rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-4{margin-bottom:1rem}.ml-2{margin-left:.5rem}.mr-2{margin-right:.5rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.box-border{box-sizing:border-box}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.h-10{height:2.5rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.w-10{width:2.5rem}.w-40{width:10rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-full{width:100%}.max-w-56{max-width:14rem}@keyframes moveIn{0%{transform:translateY(-10px)}to{transform:translateY(0)}}.animate-fadein{animation:fadeIn 1s ease-in-out,moveIn 1s ease-in-out}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.animate-show{animation:fadeIn .2s ease-in-out}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-grabbing{cursor:grabbing}.cursor-pointer{cursor:pointer}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:.5rem}.overflow-hidden{overflow:hidden}.overflow-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-md{border-radius:.375rem}.border-0{border-width:0px}.border-2{border-width:2px}.border-solid{border-style:solid}.border-transparent{border-color:transparent}.bg-cyan-700{--tw-bg-opacity: 1;background-color:rgb(14 116 144 / var(--tw-bg-opacity))}.bg-cyan-800{--tw-bg-opacity: 1;background-color:rgb(21 94 117 / var(--tw-bg-opacity))}.bg-cyan-900{--tw-bg-opacity: 1;background-color:rgb(22 78 99 / var(--tw-bg-opacity))}.bg-cyan-950{--tw-bg-opacity: 1;background-color:rgb(8 51 68 / var(--tw-bg-opacity))}.bg-green-700{--tw-bg-opacity: 1;background-color:rgb(21 128 61 / var(--tw-bg-opacity))}.bg-green-800{--tw-bg-opacity: 1;background-color:rgb(22 101 52 / var(--tw-bg-opacity))}.bg-green-900{--tw-bg-opacity: 1;background-color:rgb(20 83 45 / var(--tw-bg-opacity))}.bg-green-950{--tw-bg-opacity: 1;background-color:rgb(5 46 22 / var(--tw-bg-opacity))}.bg-neutral-700{--tw-bg-opacity: 1;background-color:rgb(64 64 64 / var(--tw-bg-opacity))}.bg-neutral-800{--tw-bg-opacity: 1;background-color:rgb(38 38 38 / var(--tw-bg-opacity))}.bg-neutral-900{--tw-bg-opacity: 1;background-color:rgb(23 23 23 / var(--tw-bg-opacity))}.bg-neutral-950{--tw-bg-opacity: 1;background-color:rgb(10 10 10 / var(--tw-bg-opacity))}.bg-orange-700{--tw-bg-opacity: 1;background-color:rgb(194 65 12 / var(--tw-bg-opacity))}.bg-orange-800{--tw-bg-opacity: 1;background-color:rgb(154 52 18 / var(--tw-bg-opacity))}.bg-orange-900{--tw-bg-opacity: 1;background-color:rgb(124 45 18 / var(--tw-bg-opacity))}.bg-orange-950{--tw-bg-opacity: 1;background-color:rgb(67 20 7 / var(--tw-bg-opacity))}.bg-purple-700{--tw-bg-opacity: 1;background-color:rgb(126 34 206 / var(--tw-bg-opacity))}.bg-purple-800{--tw-bg-opacity: 1;background-color:rgb(107 33 168 / var(--tw-bg-opacity))}.bg-purple-900{--tw-bg-opacity: 1;background-color:rgb(88 28 135 / var(--tw-bg-opacity))}.bg-purple-950{--tw-bg-opacity: 1;background-color:rgb(59 7 100 / var(--tw-bg-opacity))}.bg-red-700{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity))}.bg-red-800{--tw-bg-opacity: 1;background-color:rgb(153 27 27 / var(--tw-bg-opacity))}.bg-red-900{--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity))}.bg-red-950{--tw-bg-opacity: 1;background-color:rgb(69 10 10 / var(--tw-bg-opacity))}.bg-stone-700{--tw-bg-opacity: 1;background-color:rgb(68 64 60 / var(--tw-bg-opacity))}.bg-stone-800{--tw-bg-opacity: 1;background-color:rgb(41 37 36 / var(--tw-bg-opacity))}.bg-stone-900{--tw-bg-opacity: 1;background-color:rgb(28 25 23 / var(--tw-bg-opacity))}.bg-stone-950{--tw-bg-opacity: 1;background-color:rgb(12 10 9 / var(--tw-bg-opacity))}.bg-transparent{background-color:transparent}.bg-yellow-100{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity))}.bg-gradient-to-b{background-image:linear-gradient(to bottom,var(--tw-gradient-stops))}.from-cyan-900{--tw-gradient-from: #164e63 var(--tw-gradient-from-position);--tw-gradient-to: rgb(22 78 99 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-green-900{--tw-gradient-from: #14532d var(--tw-gradient-from-position);--tw-gradient-to: rgb(20 83 45 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-neutral-900{--tw-gradient-from: #171717 var(--tw-gradient-from-position);--tw-gradient-to: rgb(23 23 23 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-orange-900{--tw-gradient-from: #7c2d12 var(--tw-gradient-from-position);--tw-gradient-to: rgb(124 45 18 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-purple-900{--tw-gradient-from: #581c87 var(--tw-gradient-from-position);--tw-gradient-to: rgb(88 28 135 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-red-900{--tw-gradient-from: #7f1d1d var(--tw-gradient-from-position);--tw-gradient-to: rgb(127 29 29 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-stone-900{--tw-gradient-from: #1c1917 var(--tw-gradient-from-position);--tw-gradient-to: rgb(28 25 23 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.to-cyan-700{--tw-gradient-to: #0e7490 var(--tw-gradient-to-position)}.to-green-700{--tw-gradient-to: #15803d var(--tw-gradient-to-position)}.to-neutral-700{--tw-gradient-to: #404040 var(--tw-gradient-to-position)}.to-orange-700{--tw-gradient-to: #c2410c var(--tw-gradient-to-position)}.to-purple-700{--tw-gradient-to: #7e22ce var(--tw-gradient-to-position)}.to-red-700{--tw-gradient-to: #b91c1c var(--tw-gradient-to-position)}.to-stone-700{--tw-gradient-to: #44403c var(--tw-gradient-to-position)}.p-2{padding:.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.text-center{text-align:center}.font-sans{font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji"}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.leading-3{line-height:.75rem}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.text-cyan-600{--tw-text-opacity: 1;color:rgb(8 145 178 / var(--tw-text-opacity))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity))}.text-neutral-600{--tw-text-opacity: 1;color:rgb(82 82 82 / var(--tw-text-opacity))}.text-neutral-800{--tw-text-opacity: 1;color:rgb(38 38 38 / var(--tw-text-opacity))}.text-orange-600{--tw-text-opacity: 1;color:rgb(234 88 12 / var(--tw-text-opacity))}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity))}.text-stone-600{--tw-text-opacity: 1;color:rgb(87 83 78 / var(--tw-text-opacity))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.underline{text-decoration-line:underline}.no-underline{text-decoration-line:none}.decoration-2{text-decoration-thickness:2px}.underline-offset-4{text-underline-offset:4px}.opacity-25{opacity:.25}.opacity-75{opacity:.75}.shadow-\\[0_0px_10px_0px_rgba\\(0\\,0\\,0\\,0\\.3\\)\\]{--tw-shadow: 0 0px 10px 0px rgba(0,0,0,.3);--tw-shadow-colored: 0 0px 10px 0px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\\[0_0px_30px_0px_rgba\\(0\\,0\\,0\\,0\\.6\\)\\]{--tw-shadow: 0 0px 30px 0px rgba(0,0,0,.6);--tw-shadow-colored: 0 0px 30px 0px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline-dashed{outline-style:dashed}.outline-1{outline-width:1px}.outline-offset-4{outline-offset:4px}.outline-cyan-500{outline-color:#06b6d4}.outline-green-500{outline-color:#22c55e}.outline-neutral-500{outline-color:#737373}.outline-orange-500{outline-color:#f97316}.outline-purple-500{outline-color:#a855f7}.outline-red-500{outline-color:#ef4444}.outline-stone-500{outline-color:#78716c}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.hover\\:bg-cyan-700:hover{--tw-bg-opacity: 1;background-color:rgb(14 116 144 / var(--tw-bg-opacity))}.hover\\:bg-cyan-800:hover{--tw-bg-opacity: 1;background-color:rgb(21 94 117 / var(--tw-bg-opacity))}.hover\\:bg-cyan-900:hover{--tw-bg-opacity: 1;background-color:rgb(22 78 99 / var(--tw-bg-opacity))}.hover\\:bg-cyan-950:hover{--tw-bg-opacity: 1;background-color:rgb(8 51 68 / var(--tw-bg-opacity))}.hover\\:bg-green-700:hover{--tw-bg-opacity: 1;background-color:rgb(21 128 61 / var(--tw-bg-opacity))}.hover\\:bg-green-800:hover{--tw-bg-opacity: 1;background-color:rgb(22 101 52 / var(--tw-bg-opacity))}.hover\\:bg-green-900:hover{--tw-bg-opacity: 1;background-color:rgb(20 83 45 / var(--tw-bg-opacity))}.hover\\:bg-green-950:hover{--tw-bg-opacity: 1;background-color:rgb(5 46 22 / var(--tw-bg-opacity))}.hover\\:bg-neutral-700:hover{--tw-bg-opacity: 1;background-color:rgb(64 64 64 / var(--tw-bg-opacity))}.hover\\:bg-neutral-800:hover{--tw-bg-opacity: 1;background-color:rgb(38 38 38 / var(--tw-bg-opacity))}.hover\\:bg-neutral-900:hover{--tw-bg-opacity: 1;background-color:rgb(23 23 23 / var(--tw-bg-opacity))}.hover\\:bg-neutral-950:hover{--tw-bg-opacity: 1;background-color:rgb(10 10 10 / var(--tw-bg-opacity))}.hover\\:bg-orange-700:hover{--tw-bg-opacity: 1;background-color:rgb(194 65 12 / var(--tw-bg-opacity))}.hover\\:bg-orange-800:hover{--tw-bg-opacity: 1;background-color:rgb(154 52 18 / var(--tw-bg-opacity))}.hover\\:bg-orange-900:hover{--tw-bg-opacity: 1;background-color:rgb(124 45 18 / var(--tw-bg-opacity))}.hover\\:bg-orange-950:hover{--tw-bg-opacity: 1;background-color:rgb(67 20 7 / var(--tw-bg-opacity))}.hover\\:bg-purple-700:hover{--tw-bg-opacity: 1;background-color:rgb(126 34 206 / var(--tw-bg-opacity))}.hover\\:bg-purple-800:hover{--tw-bg-opacity: 1;background-color:rgb(107 33 168 / var(--tw-bg-opacity))}.hover\\:bg-purple-900:hover{--tw-bg-opacity: 1;background-color:rgb(88 28 135 / var(--tw-bg-opacity))}.hover\\:bg-purple-950:hover{--tw-bg-opacity: 1;background-color:rgb(59 7 100 / var(--tw-bg-opacity))}.hover\\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity))}.hover\\:bg-red-800:hover{--tw-bg-opacity: 1;background-color:rgb(153 27 27 / var(--tw-bg-opacity))}.hover\\:bg-red-900:hover{--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity))}.hover\\:bg-red-950:hover{--tw-bg-opacity: 1;background-color:rgb(69 10 10 / var(--tw-bg-opacity))}.hover\\:bg-stone-700:hover{--tw-bg-opacity: 1;background-color:rgb(68 64 60 / var(--tw-bg-opacity))}.hover\\:bg-stone-800:hover{--tw-bg-opacity: 1;background-color:rgb(41 37 36 / var(--tw-bg-opacity))}.hover\\:bg-stone-900:hover{--tw-bg-opacity: 1;background-color:rgb(28 25 23 / var(--tw-bg-opacity))}.hover\\:bg-stone-950:hover{--tw-bg-opacity: 1;background-color:rgb(12 10 9 / var(--tw-bg-opacity))}.disabled\\:cursor-default:disabled{cursor:default}.disabled\\:bg-neutral-400:disabled{--tw-bg-opacity: 1;background-color:rgb(163 163 163 / var(--tw-bg-opacity))}.disabled\\:text-neutral-200:disabled{--tw-text-opacity: 1;color:rgb(229 229 229 / var(--tw-text-opacity))}.group:hover .group-hover\\:underline{text-decoration-line:underline}@media (min-width: 640px){.sm\\:w-96{width:24rem}}';function j(){}function Pe(t){return t()}function or(){return Object.create(null)}function Re(t){t.forEach(Pe)}function nn(t){return typeof t=="function"}function rn(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}let Tt;function Ze(t,e){return t===e?!0:(Tt||(Tt=document.createElement("a")),Tt.href=e,t===Tt.href)}function Jo(t){return Object.keys(t).length===0}function Qo(t,...e){if(t==null){for(const r of e)r(void 0);return j}const n=t.subscribe(...e);return n.unsubscribe?()=>n.unsubscribe():n}function Xo(t,e,n){t.$$.on_destroy.push(Qo(e,n))}const ei=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function O(t,e){t.appendChild(e)}function K(t,e,n){t.insertBefore(e,n||null)}function z(t){t.parentNode&&t.parentNode.removeChild(t)}function ti(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}function P(t){return document.createElement(t)}function on(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function F(t){return document.createTextNode(t)}function Y(){return F(" ")}function sn(){return F("")}function ne(t,e,n,r){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n,r)}function k(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function ni(t){return Array.from(t.childNodes)}function He(t,e){e=""+e,t.data!==e&&(t.data=e)}function rt(t,e){t.value=e??""}function ir(t,e,n){for(let r=0;r<t.options.length;r+=1){const o=t.options[r];if(o.__value===e){o.selected=!0;return}}(!n||e!==void 0)&&(t.selectedIndex=-1)}function ri(t){const e=t.querySelector(":checked");return e&&e.__value}function sr(t,e,n){t.classList.toggle(e,!!n)}let mt;function vt(t){mt=t}function oi(){if(!mt)throw new Error("Function called outside component initialization");return mt}function ii(t){oi().$$.on_mount.push(t)}const ot=[],it=[];let st=[];const cr=[],si=Promise.resolve();let cn=!1;function ci(){cn||(cn=!0,si.then(ar))}function Ct(t){st.push(t)}const an=new Set;let ct=0;function ar(){if(ct!==0)return;const t=mt;do{try{for(;ct<ot.length;){const e=ot[ct];ct++,vt(e),ai(e.$$)}}catch(e){throw ot.length=0,ct=0,e}for(vt(null),ot.length=0,ct=0;it.length;)it.pop()();for(let e=0;e<st.length;e+=1){const n=st[e];an.has(n)||(an.add(n),n())}st.length=0}while(ot.length);for(;cr.length;)cr.pop()();cn=!1,an.clear(),vt(t)}function ai(t){if(t.fragment!==null){t.update(),Re(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(Ct)}}function li(t){const e=[],n=[];st.forEach(r=>t.indexOf(r)===-1?e.push(r):n.push(r)),n.forEach(r=>r()),st=e}const Ut=new Set;let Je;function Pt(){Je={r:0,c:[],p:Je}}function Rt(){Je.r||Re(Je.c),Je=Je.p}function me(t,e){t&&t.i&&(Ut.delete(t),t.i(e))}function xe(t,e,n,r){if(t&&t.o){if(Ut.has(t))return;Ut.add(t),Je.c.push(()=>{Ut.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}else r&&r()}function lr(t){return(t==null?void 0:t.length)!==void 0?t:Array.from(t)}function ur(t){t&&t.c()}function ln(t,e,n){const{fragment:r,after_update:o}=t.$$;r&&r.m(e,n),Ct(()=>{const i=t.$$.on_mount.map(Pe).filter(nn);t.$$.on_destroy?t.$$.on_destroy.push(...i):Re(i),t.$$.on_mount=[]}),o.forEach(Ct)}function un(t,e){const n=t.$$;n.fragment!==null&&(li(n.after_update),Re(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function ui(t,e){t.$$.dirty[0]===-1&&(ot.push(t),ci(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function fr(t,e,n,r,o,i,s=null,c=[-1]){const a=mt;vt(t);const l=t.$$={fragment:null,ctx:[],props:i,update:j,not_equal:o,bound:or(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(a?a.$$.context:[])),callbacks:or(),dirty:c,skip_bound:!1,root:e.target||a.$$.root};s&&s(l.root);let f=!1;if(l.ctx=n?n(t,e.props||{},(u,b,...h)=>{const g=h.length?h[0]:b;return l.ctx&&o(l.ctx[u],l.ctx[u]=g)&&(!l.skip_bound&&l.bound[u]&&l.bound[u](g),f&&ui(t,u)),b}):[],l.update(),f=!0,Re(l.before_update),l.fragment=r?r(l.ctx):!1,e.target){if(e.hydrate){const u=ni(e.target);l.fragment&&l.fragment.l(u),u.forEach(z)}else l.fragment&&l.fragment.c();e.intro&&me(t.$$.fragment),ln(t,e.target,e.anchor),ar()}vt(a)}class dr{constructor(){B(this,"$$");B(this,"$$set")}$destroy(){un(this,1),this.$destroy=j}$on(e,n){if(!nn(n))return j;const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(n),()=>{const o=r.indexOf(n);o!==-1&&r.splice(o,1)}}$set(e){this.$$set&&!Jo(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const fi="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(fi);function di(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var fn={exports:{}};function hr(t,e=100,n={}){if(typeof t!="function")throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);if(e<0)throw new RangeError("`wait` must not be negative.");const{immediate:r}=typeof n=="boolean"?{immediate:n}:n;let o,i,s,c,a;function l(){const u=Date.now()-c;if(u<e&&u>=0)s=setTimeout(l,e-u);else if(s=void 0,!r){const b=o,h=i;o=void 0,i=void 0,a=t.apply(b,h)}}const f=function(...u){if(o&&this!==o)throw new Error("Debounced method called with different contexts.");o=this,i=u,c=Date.now();const b=r&&!s;if(s||(s=setTimeout(l,e)),b){const h=o,g=i;o=void 0,i=void 0,a=t.apply(h,g)}return a};return f.clear=()=>{s&&(clearTimeout(s),s=void 0)},f.flush=()=>{if(!s)return;const u=o,b=i;o=void 0,i=void 0,a=t.apply(u,b),clearTimeout(s),s=void 0},f}fn.exports.debounce=hr,fn.exports=hr;var hi=fn.exports;const gr=di(hi),dn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const hn=t=>t instanceof Uint8Array,gn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ee=(t,e)=>t<<32-e|t>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");const gi=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function fe(t){if(!hn(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=gi[t[n]];return e}function pn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const o=r*2,i=t.slice(o,o+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function pi(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function xt(t){if(typeof t=="string"&&(t=pi(t)),!hn(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function bi(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!hn(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}let pr=class{clone(){return this._cloneInto()}};function br(t){const e=r=>t().update(xt(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function wi(t=32){if(dn&&typeof dn.getRandomValues=="function")return dn.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function wr(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function yr(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function yi(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");wr(t.outputLen),wr(t.blockLen)}function Ht(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function mi(t,e){yr(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const bn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const mr=t=>t instanceof Uint8Array,wn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),_e=(t,e)=>t<<32-e|t>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function vi(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function yn(t){if(typeof t=="string"&&(t=vi(t)),!mr(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function xi(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!mr(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}class vr{clone(){return this._cloneInto()}}function Ei(t){const e=r=>t().update(yn(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function xr(t=32){if(bn&&typeof bn.getRandomValues=="function")return bn.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function _i(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),c=Number(n&i),a=r?4:0,l=r?0:4;t.setUint32(e+a,s,r),t.setUint32(e+l,c,r)}let ki=class extends vr{constructor(e,n,r,o){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=wn(this.buffer)}update(e){Ht(this);const{view:n,buffer:r,blockLen:o}=this;e=yn(e);const i=e.length;for(let s=0;s<i;){const c=Math.min(o-this.pos,i-s);if(c===o){const a=wn(e);for(;o<=i-s;s+=o)this.process(a,s);continue}r.set(e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ht(this),mi(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(r,0),s=0);for(let u=s;u<o;u++)n[u]=0;_i(r,o-8,BigInt(this.length*8),i),this.process(r,0);const c=wn(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)c.setUint32(4*u,f[u],i)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:c}=this;return e.length=o,e.pos=c,e.finished=i,e.destroyed=s,o%n&&e.buffer.set(r),e}};const Si=(t,e,n)=>t&e^~t&n,Ai=(t,e,n)=>t&e^t&n^e&n,Bi=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]),Me=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),je=new Uint32Array(64);let Ii=class extends ki{constructor(){super(64,32,8,!1),this.A=Me[0]|0,this.B=Me[1]|0,this.C=Me[2]|0,this.D=Me[3]|0,this.E=Me[4]|0,this.F=Me[5]|0,this.G=Me[6]|0,this.H=Me[7]|0}get(){const{A:e,B:n,C:r,D:o,E:i,F:s,G:c,H:a}=this;return[e,n,r,o,i,s,c,a]}set(e,n,r,o,i,s,c,a){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(e,n){for(let u=0;u<16;u++,n+=4)je[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const b=je[u-15],h=je[u-2],g=_e(b,7)^_e(b,18)^b>>>3,d=_e(h,17)^_e(h,19)^h>>>10;je[u]=d+je[u-7]+g+je[u-16]|0}let{A:r,B:o,C:i,D:s,E:c,F:a,G:l,H:f}=this;for(let u=0;u<64;u++){const b=_e(c,6)^_e(c,11)^_e(c,25),h=f+b+Si(c,a,l)+Bi[u]+je[u]|0,d=(_e(r,2)^_e(r,13)^_e(r,22))+Ai(r,o,i)|0;f=l,l=a,a=c,c=s+h|0,s=i,i=o,o=r,r=h+d|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(r,o,i,s,c,a,l,f)}roundClean(){je.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const mn=Ei(()=>new Ii);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Er=BigInt(0),Mt=BigInt(1),Oi=BigInt(2),jt=t=>t instanceof Uint8Array,Ni=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function at(t){if(!jt(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=Ni[t[n]];return e}function _r(t){const e=t.toString(16);return e.length&1?`0${e}`:e}function vn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function lt(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const o=r*2,i=t.slice(o,o+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function he(t){return vn(at(t))}function xn(t){if(!jt(t))throw new Error("Uint8Array expected");return vn(at(Uint8Array.from(t).reverse()))}function qe(t,e){return lt(t.toString(16).padStart(e*2,"0"))}function En(t,e){return qe(t,e).reverse()}function Li(t){return lt(_r(t))}function le(t,e,n){let r;if(typeof e=="string")try{r=lt(e)}catch(i){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${i}`)}else if(jt(e))r=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(`${t} expected ${n} bytes, got ${o}`);return r}function Qe(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!jt(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}function Ti(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function Ci(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Ui(t){let e;for(e=0;t>Er;t>>=Mt,e+=1);return e}function Pi(t,e){return t>>BigInt(e)&Mt}const Ri=(t,e,n)=>t|(n?Mt:Er)<<BigInt(e),_n=t=>(Oi<<BigInt(t-1))-Mt,kn=t=>new Uint8Array(t),kr=t=>Uint8Array.from(t);function Sr(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=kn(t),o=kn(t),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},c=(...u)=>n(o,r,...u),a=(u=kn())=>{o=c(kr([0]),u),r=c(),u.length!==0&&(o=c(kr([1]),u),r=c())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const b=[];for(;u<e;){r=c();const h=r.slice();b.push(h),u+=r.length}return Qe(...b)};return(u,b)=>{s(),a(u);let h;for(;!(h=b(l()));)a();return s(),h}}const Hi={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Et(t,e,n={}){const r=(o,i,s)=>{const c=Hi[i];if(typeof c!="function")throw new Error(`Invalid validator "${i}", expected function`);const a=t[o];if(!(s&&a===void 0)&&!c(a,t))throw new Error(`Invalid param ${String(o)}=${a} (${typeof a}), expected ${i}`)};for(const[o,i]of Object.entries(e))r(o,i,!1);for(const[o,i]of Object.entries(n))r(o,i,!0);return t}const Mi=Object.freeze(Object.defineProperty({__proto__:null,bitGet:Pi,bitLen:Ui,bitMask:_n,bitSet:Ri,bytesToHex:at,bytesToNumberBE:he,bytesToNumberLE:xn,concatBytes:Qe,createHmacDrbg:Sr,ensureBytes:le,equalBytes:Ti,hexToBytes:lt,hexToNumber:vn,numberToBytesBE:qe,numberToBytesLE:En,numberToHexUnpadded:_r,numberToVarBytesBE:Li,utf8ToBytes:Ci,validateObject:Et},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const oe=BigInt(0),ee=BigInt(1),Xe=BigInt(2),ji=BigInt(3),Sn=BigInt(4),Ar=BigInt(5),Br=BigInt(8);BigInt(9),BigInt(16);function ie(t,e){const n=t%e;return n>=oe?n:e+n}function qi(t,e,n){if(n<=oe||e<oe)throw new Error("Expected power/modulo > 0");if(n===ee)return oe;let r=ee;for(;e>oe;)e&ee&&(r=r*t%n),t=t*t%n,e>>=ee;return r}function pe(t,e,n){let r=t;for(;e-- >oe;)r*=r,r%=n;return r}function An(t,e){if(t===oe||e<=oe)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=ie(t,e),r=e,o=oe,i=ee;for(;n!==oe;){const c=r/n,a=r%n,l=o-i*c;r=n,n=a,o=i,i=l}if(r!==ee)throw new Error("invert: does not exist");return ie(o,e)}function zi(t){const e=(t-ee)/Xe;let n,r,o;for(n=t-ee,r=0;n%Xe===oe;n/=Xe,r++);for(o=Xe;o<t&&qi(o,e,t)!==t-ee;o++);if(r===1){const s=(t+ee)/Sn;return function(a,l){const f=a.pow(l,s);if(!a.eql(a.sqr(f),l))throw new Error("Cannot find square root");return f}}const i=(n+ee)/Xe;return function(c,a){if(c.pow(a,e)===c.neg(c.ONE))throw new Error("Cannot find square root");let l=r,f=c.pow(c.mul(c.ONE,o),n),u=c.pow(a,i),b=c.pow(a,n);for(;!c.eql(b,c.ONE);){if(c.eql(b,c.ZERO))return c.ZERO;let h=1;for(let d=c.sqr(b);h<l&&!c.eql(d,c.ONE);h++)d=c.sqr(d);const g=c.pow(f,ee<<BigInt(l-h-1));f=c.sqr(g),u=c.mul(u,g),b=c.mul(b,f),l=h}return u}}function Ki(t){if(t%Sn===ji){const e=(t+ee)/Sn;return function(r,o){const i=r.pow(o,e);if(!r.eql(r.sqr(i),o))throw new Error("Cannot find square root");return i}}if(t%Br===Ar){const e=(t-Ar)/Br;return function(r,o){const i=r.mul(o,Xe),s=r.pow(i,e),c=r.mul(o,s),a=r.mul(r.mul(c,Xe),s),l=r.mul(c,r.sub(a,r.ONE));if(!r.eql(r.sqr(l),o))throw new Error("Cannot find square root");return l}}return zi(t)}const $i=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Wi(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=$i.reduce((r,o)=>(r[o]="function",r),e);return Et(t,n)}function Di(t,e,n){if(n<oe)throw new Error("Expected power > 0");if(n===oe)return t.ONE;if(n===ee)return e;let r=t.ONE,o=e;for(;n>oe;)n&ee&&(r=t.mul(r,o)),o=t.sqr(o),n>>=ee;return r}function Vi(t,e){const n=new Array(e.length),r=e.reduce((i,s,c)=>t.is0(s)?i:(n[c]=i,t.mul(i,s)),t.ONE),o=t.inv(r);return e.reduceRight((i,s,c)=>t.is0(s)?i:(n[c]=t.mul(i,n[c]),t.mul(i,s)),o),n}function Ir(t,e){const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Fi(t,e,n=!1,r={}){if(t<=oe)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:o,nByteLength:i}=Ir(t,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Ki(t),c=Object.freeze({ORDER:t,BITS:o,BYTES:i,MASK:_n(o),ZERO:oe,ONE:ee,create:a=>ie(a,t),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return oe<=a&&a<t},is0:a=>a===oe,isOdd:a=>(a&ee)===ee,neg:a=>ie(-a,t),eql:(a,l)=>a===l,sqr:a=>ie(a*a,t),add:(a,l)=>ie(a+l,t),sub:(a,l)=>ie(a-l,t),mul:(a,l)=>ie(a*l,t),pow:(a,l)=>Di(c,a,l),div:(a,l)=>ie(a*An(l,t),t),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>An(a,t),sqrt:r.sqrt||(a=>s(c,a)),invertBatch:a=>Vi(c,a),cmov:(a,l,f)=>f?l:a,toBytes:a=>n?En(a,i):qe(a,i),fromBytes:a=>{if(a.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${a.length}`);return n?xn(a):he(a)}});return Object.freeze(c)}function Or(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Nr(t){const e=Or(t);return e+Math.ceil(e/2)}function Gi(t,e,n=!1){const r=t.length,o=Or(e),i=Nr(e);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=n?he(t):xn(t),c=ie(s,e-ee)+ee;return n?En(c,o):qe(c,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Yi=BigInt(0),Bn=BigInt(1);function Zi(t,e){const n=(o,i)=>{const s=i.negate();return o?s:i},r=o=>{const i=Math.ceil(e/o)+1,s=2**(o-1);return{windows:i,windowSize:s}};return{constTimeNegate:n,unsafeLadder(o,i){let s=t.ZERO,c=o;for(;i>Yi;)i&Bn&&(s=s.add(c)),c=c.double(),i>>=Bn;return s},precomputeWindow(o,i){const{windows:s,windowSize:c}=r(i),a=[];let l=o,f=l;for(let u=0;u<s;u++){f=l,a.push(f);for(let b=1;b<c;b++)f=f.add(l),a.push(f);l=f.double()}return a},wNAF(o,i,s){const{windows:c,windowSize:a}=r(o);let l=t.ZERO,f=t.BASE;const u=BigInt(2**o-1),b=2**o,h=BigInt(o);for(let g=0;g<c;g++){const d=g*a;let p=Number(s&u);s>>=h,p>a&&(p-=b,s+=Bn);const w=d,m=d+Math.abs(p)-1,S=g%2!==0,T=p<0;p===0?f=f.add(n(S,i[w])):l=l.add(n(T,i[m]))}return{p:l,f}},wNAFCached(o,i,s,c){const a=o._WINDOW_SIZE||1;let l=i.get(o);return l||(l=this.precomputeWindow(o,a),a!==1&&i.set(o,c(l))),this.wNAF(a,l,s)}}}function Lr(t){return Wi(t.Fp),Et(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ir(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ji(t){const e=Lr(t);Et(e,{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}=e;if(n){if(!r.eql(o,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:Qi,hexToBytes:Xi}=Mi,et={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:e}=et;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:Qi(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=et,n=typeof t=="string"?Xi(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:o,l:i}=et._parseInt(n.subarray(2)),{d:s,l:c}=et._parseInt(i);if(c.length)throw new e("Invalid signature: left bytes after parsing");return{r:o,s}},hexFromSig(t){const e=l=>Number.parseInt(l[0],16)&8?"00"+l:l,n=l=>{const f=l.toString(16);return f.length&1?`0${f}`:f},r=e(n(t.s)),o=e(n(t.r)),i=r.length/2,s=o.length/2,c=n(i),a=n(s);return`30${n(s+i+4)}02${a}${o}02${c}${r}`}},Ie=BigInt(0),be=BigInt(1);BigInt(2);const Tr=BigInt(3);BigInt(4);function es(t){const e=Ji(t),{Fp:n}=e,r=e.toBytes||((g,d,p)=>{const w=d.toAffine();return Qe(Uint8Array.from([4]),n.toBytes(w.x),n.toBytes(w.y))}),o=e.fromBytes||(g=>{const d=g.subarray(1),p=n.fromBytes(d.subarray(0,n.BYTES)),w=n.fromBytes(d.subarray(n.BYTES,2*n.BYTES));return{x:p,y:w}});function i(g){const{a:d,b:p}=e,w=n.sqr(g),m=n.mul(w,g);return n.add(n.add(m,n.mul(g,d)),p)}if(!n.eql(n.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function s(g){return typeof g=="bigint"&&Ie<g&&g<e.n}function c(g){if(!s(g))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function a(g){const{allowedPrivateKeyLengths:d,nByteLength:p,wrapPrivateKey:w,n:m}=e;if(d&&typeof g!="bigint"){if(g instanceof Uint8Array&&(g=at(g)),typeof g!="string"||!d.includes(g.length))throw new Error("Invalid key");g=g.padStart(p*2,"0")}let S;try{S=typeof g=="bigint"?g:he(le("private key",g,p))}catch{throw new Error(`private key must be ${p} bytes, hex or bigint, not ${typeof g}`)}return w&&(S=ie(S,m)),c(S),S}const l=new Map;function f(g){if(!(g instanceof u))throw new Error("ProjectivePoint expected")}class u{constructor(d,p,w){if(this.px=d,this.py=p,this.pz=w,d==null||!n.isValid(d))throw new Error("x required");if(p==null||!n.isValid(p))throw new Error("y required");if(w==null||!n.isValid(w))throw new Error("z required")}static fromAffine(d){const{x:p,y:w}=d||{};if(!d||!n.isValid(p)||!n.isValid(w))throw new Error("invalid affine point");if(d instanceof u)throw new Error("projective point not allowed");const m=S=>n.eql(S,n.ZERO);return m(p)&&m(w)?u.ZERO:new u(p,w,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){const p=n.invertBatch(d.map(w=>w.pz));return d.map((w,m)=>w.toAffine(p[m])).map(u.fromAffine)}static fromHex(d){const p=u.fromAffine(o(le("pointHex",d)));return p.assertValidity(),p}static fromPrivateKey(d){return u.BASE.multiply(a(d))}_setWindowSize(d){this._WINDOW_SIZE=d,l.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:d,y:p}=this.toAffine();if(!n.isValid(d)||!n.isValid(p))throw new Error("bad point: x or y not FE");const w=n.sqr(p),m=i(d);if(!n.eql(w,m))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:d}=this.toAffine();if(n.isOdd)return!n.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);const{px:p,py:w,pz:m}=this,{px:S,py:T,pz:R}=d,_=n.eql(n.mul(p,R),n.mul(S,m)),x=n.eql(n.mul(w,R),n.mul(T,m));return _&&x}negate(){return new u(this.px,n.neg(this.py),this.pz)}double(){const{a:d,b:p}=e,w=n.mul(p,Tr),{px:m,py:S,pz:T}=this;let R=n.ZERO,_=n.ZERO,x=n.ZERO,y=n.mul(m,m),E=n.mul(S,S),U=n.mul(T,T),N=n.mul(m,S);return N=n.add(N,N),x=n.mul(m,T),x=n.add(x,x),R=n.mul(d,x),_=n.mul(w,U),_=n.add(R,_),R=n.sub(E,_),_=n.add(E,_),_=n.mul(R,_),R=n.mul(N,R),x=n.mul(w,x),U=n.mul(d,U),N=n.sub(y,U),N=n.mul(d,N),N=n.add(N,x),x=n.add(y,y),y=n.add(x,y),y=n.add(y,U),y=n.mul(y,N),_=n.add(_,y),U=n.mul(S,T),U=n.add(U,U),y=n.mul(U,N),R=n.sub(R,y),x=n.mul(U,E),x=n.add(x,x),x=n.add(x,x),new u(R,_,x)}add(d){f(d);const{px:p,py:w,pz:m}=this,{px:S,py:T,pz:R}=d;let _=n.ZERO,x=n.ZERO,y=n.ZERO;const E=e.a,U=n.mul(e.b,Tr);let N=n.mul(p,S),M=n.mul(w,T),W=n.mul(m,R),V=n.add(p,w),v=n.add(S,T);V=n.mul(V,v),v=n.add(N,M),V=n.sub(V,v),v=n.add(p,m);let A=n.add(S,R);return v=n.mul(v,A),A=n.add(N,W),v=n.sub(v,A),A=n.add(w,m),_=n.add(T,R),A=n.mul(A,_),_=n.add(M,W),A=n.sub(A,_),y=n.mul(E,v),_=n.mul(U,W),y=n.add(_,y),_=n.sub(M,y),y=n.add(M,y),x=n.mul(_,y),M=n.add(N,N),M=n.add(M,N),W=n.mul(E,W),v=n.mul(U,v),M=n.add(M,W),W=n.sub(N,W),W=n.mul(E,W),v=n.add(v,W),N=n.mul(M,v),x=n.add(x,N),N=n.mul(A,v),_=n.mul(V,_),_=n.sub(_,N),N=n.mul(V,M),y=n.mul(A,y),y=n.add(y,N),new u(_,x,y)}subtract(d){return this.add(d.negate())}is0(){return this.equals(u.ZERO)}wNAF(d){return h.wNAFCached(this,l,d,p=>{const w=n.invertBatch(p.map(m=>m.pz));return p.map((m,S)=>m.toAffine(w[S])).map(u.fromAffine)})}multiplyUnsafe(d){const p=u.ZERO;if(d===Ie)return p;if(c(d),d===be)return this;const{endo:w}=e;if(!w)return h.unsafeLadder(this,d);let{k1neg:m,k1:S,k2neg:T,k2:R}=w.splitScalar(d),_=p,x=p,y=this;for(;S>Ie||R>Ie;)S&be&&(_=_.add(y)),R&be&&(x=x.add(y)),y=y.double(),S>>=be,R>>=be;return m&&(_=_.negate()),T&&(x=x.negate()),x=new u(n.mul(x.px,w.beta),x.py,x.pz),_.add(x)}multiply(d){c(d);let p=d,w,m;const{endo:S}=e;if(S){const{k1neg:T,k1:R,k2neg:_,k2:x}=S.splitScalar(p);let{p:y,f:E}=this.wNAF(R),{p:U,f:N}=this.wNAF(x);y=h.constTimeNegate(T,y),U=h.constTimeNegate(_,U),U=new u(n.mul(U.px,S.beta),U.py,U.pz),w=y.add(U),m=E.add(N)}else{const{p:T,f:R}=this.wNAF(p);w=T,m=R}return u.normalizeZ([w,m])[0]}multiplyAndAddUnsafe(d,p,w){const m=u.BASE,S=(R,_)=>_===Ie||_===be||!R.equals(m)?R.multiplyUnsafe(_):R.multiply(_),T=S(this,p).add(S(d,w));return T.is0()?void 0:T}toAffine(d){const{px:p,py:w,pz:m}=this,S=this.is0();d==null&&(d=S?n.ONE:n.inv(m));const T=n.mul(p,d),R=n.mul(w,d),_=n.mul(m,d);if(S)return{x:n.ZERO,y:n.ZERO};if(!n.eql(_,n.ONE))throw new Error("invZ was invalid");return{x:T,y:R}}isTorsionFree(){const{h:d,isTorsionFree:p}=e;if(d===be)return!0;if(p)return p(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:d,clearCofactor:p}=e;return d===be?this:p?p(u,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return this.assertValidity(),r(u,this,d)}toHex(d=!0){return at(this.toRawBytes(d))}}u.BASE=new u(e.Gx,e.Gy,n.ONE),u.ZERO=new u(n.ZERO,n.ONE,n.ZERO);const b=e.nBitLength,h=Zi(u,e.endo?Math.ceil(b/2):b);return{CURVE:e,ProjectivePoint:u,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:s}}function ts(t){const e=Lr(t);return Et(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function ns(t){const e=ts(t),{Fp:n,n:r}=e,o=n.BYTES+1,i=2*n.BYTES+1;function s(v){return Ie<v&&v<n.ORDER}function c(v){return ie(v,r)}function a(v){return An(v,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:b}=es({...e,toBytes(v,A,C){const H=A.toAffine(),I=n.toBytes(H.x),q=Qe;return C?q(Uint8Array.from([A.hasEvenY()?2:3]),I):q(Uint8Array.from([4]),I,n.toBytes(H.y))},fromBytes(v){const A=v.length,C=v[0],H=v.subarray(1);if(A===o&&(C===2||C===3)){const I=he(H);if(!s(I))throw new Error("Point is not on curve");const q=u(I);let D=n.sqrt(q);const $=(D&be)===be;return(C&1)===1!==$&&(D=n.neg(D)),{x:I,y:D}}else if(A===i&&C===4){const I=n.fromBytes(H.subarray(0,n.BYTES)),q=n.fromBytes(H.subarray(n.BYTES,2*n.BYTES));return{x:I,y:q}}else throw new Error(`Point of length ${A} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=v=>at(qe(v,e.nByteLength));function g(v){const A=r>>be;return v>A}function d(v){return g(v)?c(-v):v}const p=(v,A,C)=>he(v.slice(A,C));class w{constructor(A,C,H){this.r=A,this.s=C,this.recovery=H,this.assertValidity()}static fromCompact(A){const C=e.nByteLength;return A=le("compactSignature",A,C*2),new w(p(A,0,C),p(A,C,2*C))}static fromDER(A){const{r:C,s:H}=et.toSig(le("DER",A));return new w(C,H)}assertValidity(){if(!b(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!b(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(A){return new w(this.r,this.s,A)}recoverPublicKey(A){const{r:C,s:H,recovery:I}=this,q=x(le("msgHash",A));if(I==null||![0,1,2,3].includes(I))throw new Error("recovery id invalid");const D=I===2||I===3?C+e.n:C;if(D>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const $=I&1?"03":"02",X=l.fromHex($+h(D)),Q=a(D),ce=c(-q*Q),J=c(H*Q),re=l.BASE.multiplyAndAddUnsafe(X,ce,J);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new w(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return lt(this.toDERHex())}toDERHex(){return et.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return lt(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const m={isValidPrivateKey(v){try{return f(v),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const v=Nr(e.n);return Gi(e.randomBytes(v),e.n)},precompute(v=8,A=l.BASE){return A._setWindowSize(v),A.multiply(BigInt(3)),A}};function S(v,A=!0){return l.fromPrivateKey(v).toRawBytes(A)}function T(v){const A=v instanceof Uint8Array,C=typeof v=="string",H=(A||C)&&v.length;return A?H===o||H===i:C?H===2*o||H===2*i:v instanceof l}function R(v,A,C=!0){if(T(v))throw new Error("first arg must be private key");if(!T(A))throw new Error("second arg must be public key");return l.fromHex(A).multiply(f(v)).toRawBytes(C)}const _=e.bits2int||function(v){const A=he(v),C=v.length*8-e.nBitLength;return C>0?A>>BigInt(C):A},x=e.bits2int_modN||function(v){return c(_(v))},y=_n(e.nBitLength);function E(v){if(typeof v!="bigint")throw new Error("bigint expected");if(!(Ie<=v&&v<y))throw new Error(`bigint expected < 2^${e.nBitLength}`);return qe(v,e.nByteLength)}function U(v,A,C=N){if(["recovered","canonical"].some(ae=>ae in C))throw new Error("sign() legacy options not supported");const{hash:H,randomBytes:I}=e;let{lowS:q,prehash:D,extraEntropy:$}=C;q==null&&(q=!0),v=le("msgHash",v),D&&(v=le("prehashed msgHash",H(v)));const X=x(v),Q=f(A),ce=[E(Q),E(X)];if($!=null){const ae=$===!0?I(n.BYTES):$;ce.push(le("extraEntropy",ae))}const J=Qe(...ce),re=X;function ue(ae){const Be=_(ae);if(!b(Be))return;const Ge=a(Be),Ce=l.BASE.multiply(Be).toAffine(),ge=c(Ce.x);if(ge===Ie)return;const Ue=c(Ge*c(re+ge*Q));if(Ue===Ie)return;let Bt=(Ce.x===ge?0:2)|Number(Ce.y&be),It=Ue;return q&&g(Ue)&&(It=d(Ue),Bt^=1),new w(ge,It,Bt)}return{seed:J,k2sig:ue}}const N={lowS:e.lowS,prehash:!1},M={lowS:e.lowS,prehash:!1};function W(v,A,C=N){const{seed:H,k2sig:I}=U(v,A,C),q=e;return Sr(q.hash.outputLen,q.nByteLength,q.hmac)(H,I)}l.BASE._setWindowSize(8);function V(v,A,C,H=M){var Ce;const I=v;if(A=le("msgHash",A),C=le("publicKey",C),"strict"in H)throw new Error("options.strict was renamed to lowS");const{lowS:q,prehash:D}=H;let $,X;try{if(typeof I=="string"||I instanceof Uint8Array)try{$=w.fromDER(I)}catch(ge){if(!(ge instanceof et.Err))throw ge;$=w.fromCompact(I)}else if(typeof I=="object"&&typeof I.r=="bigint"&&typeof I.s=="bigint"){const{r:ge,s:Ue}=I;$=new w(ge,Ue)}else throw new Error("PARSE");X=l.fromHex(C)}catch(ge){if(ge.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(q&&$.hasHighS())return!1;D&&(A=e.hash(A));const{r:Q,s:ce}=$,J=x(A),re=a(ce),ue=c(J*re),ae=c(Q*re),Be=(Ce=l.BASE.multiplyAndAddUnsafe(X,ue,ae))==null?void 0:Ce.toAffine();return Be?c(Be.x)===Q:!1}return{CURVE:e,getPublicKey:S,getSharedSecret:R,sign:W,verify:V,ProjectivePoint:l,Signature:w,utils:m}}let Cr=class extends vr{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,yi(e);const r=yn(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(r.length>o?e.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return Ht(this),this.iHash.update(e),this}digestInto(e){Ht(this),yr(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:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=c,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Ur=(t,e,n)=>new Cr(t,e).update(n).digest();Ur.create=(t,e)=>new Cr(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function rs(t){return{hash:t,hmac:(e,...n)=>Ur(t,e,xi(...n)),randomBytes:xr}}function os(t,e){const n=r=>ns({...t,...rs(r)});return Object.freeze({...n(e),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const qt=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),zt=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Pr=BigInt(1),Kt=BigInt(2),Rr=(t,e)=>(t+e/Kt)/e;function Hr(t){const e=qt,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),l=t*t*t%e,f=l*l*t%e,u=pe(f,n,e)*f%e,b=pe(u,n,e)*f%e,h=pe(b,Kt,e)*l%e,g=pe(h,o,e)*h%e,d=pe(g,i,e)*g%e,p=pe(d,c,e)*d%e,w=pe(p,a,e)*p%e,m=pe(w,c,e)*d%e,S=pe(m,n,e)*f%e,T=pe(S,s,e)*g%e,R=pe(T,r,e)*l%e,_=pe(R,Kt,e);if(!In.eql(In.sqr(_),t))throw new Error("Cannot find square root");return _}const In=Fi(qt,void 0,void 0,{sqrt:Hr}),ut=os({a:BigInt(0),b:BigInt(7),Fp:In,n:zt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=zt,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Pr*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),c=Rr(i*t,e),a=Rr(-r*t,e);let l=ie(t-c*n-a*o,e),f=ie(-c*r-a*i,e);const u=l>s,b=f>s;if(u&&(l=e-l),b&&(f=e-f),l>s||f>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:u,k1:l,k2neg:b,k2:f}}}},mn),$t=BigInt(0),Mr=t=>typeof t=="bigint"&&$t<t&&t<qt,is=t=>typeof t=="bigint"&&$t<t&&t<zt,jr={};function Wt(t,...e){let n=jr[t];if(n===void 0){const r=mn(Uint8Array.from(t,o=>o.charCodeAt(0)));n=Qe(r,r),jr[t]=n}return mn(Qe(n,...e))}const On=t=>t.toRawBytes(!0).slice(1),Nn=t=>qe(t,32),Ln=t=>ie(t,qt),_t=t=>ie(t,zt),Tn=ut.ProjectivePoint,ss=(t,e,n)=>Tn.BASE.multiplyAndAddUnsafe(t,e,n);function Cn(t){let e=ut.utils.normPrivateKeyToScalar(t),n=Tn.fromPrivateKey(e);return{scalar:n.hasEvenY()?e:_t(-e),bytes:On(n)}}function qr(t){if(!Mr(t))throw new Error("bad x: need 0 < x < p");const e=Ln(t*t),n=Ln(e*t+BigInt(7));let r=Hr(n);r%Kt!==$t&&(r=Ln(-r));const o=new Tn(t,r,Pr);return o.assertValidity(),o}function zr(...t){return _t(he(Wt("BIP0340/challenge",...t)))}function cs(t){return Cn(t).bytes}function as(t,e,n=xr(32)){const r=le("message",t),{bytes:o,scalar:i}=Cn(e),s=le("auxRand",n,32),c=Nn(i^he(Wt("BIP0340/aux",s))),a=Wt("BIP0340/nonce",c,o,r),l=_t(he(a));if(l===$t)throw new Error("sign failed: k is zero");const{bytes:f,scalar:u}=Cn(l),b=zr(f,o,r),h=new Uint8Array(64);if(h.set(f,0),h.set(Nn(_t(u+b*i)),32),!Kr(h,r,o))throw new Error("sign: Invalid signature produced");return h}function Kr(t,e,n){const r=le("signature",t,64),o=le("message",e),i=le("publicKey",n,32);try{const s=qr(he(i)),c=he(r.subarray(0,32));if(!Mr(c))return!1;const a=he(r.subarray(32,64));if(!is(a))return!1;const l=zr(Nn(c),On(s),o),f=ss(s,a,_t(-l));return!(!f||!f.hasEvenY()||f.toAffine().x!==c)}catch{return!1}}const de={getPublicKey:cs,sign:as,verify:Kr,utils:{randomPrivateKey:ut.utils.randomPrivateKey,lift_x:qr,pointToBytes:On,numberToBytesBE:qe,bytesToNumberBE:he,taggedHash:Wt,mod:ie}};function Un(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function ls(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function $r(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function us(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Un(t.outputLen),Un(t.blockLen)}function fs(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function ds(t,e){$r(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const ke={number:Un,bool:ls,bytes:$r,hash:us,exists:fs,output:ds};function hs(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),c=Number(n&i),a=r?4:0,l=r?0:4;t.setUint32(e+a,s,r),t.setUint32(e+l,c,r)}class gs extends pr{constructor(e,n,r,o){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=gn(this.buffer)}update(e){ke.exists(this);const{view:n,buffer:r,blockLen:o}=this;e=xt(e);const i=e.length;for(let s=0;s<i;){const c=Math.min(o-this.pos,i-s);if(c===o){const a=gn(e);for(;o<=i-s;s+=o)this.process(a,s);continue}r.set(e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ke.exists(this),ke.output(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(r,0),s=0);for(let u=s;u<o;u++)n[u]=0;hs(r,o-8,BigInt(this.length*8),i),this.process(r,0);const c=gn(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)c.setUint32(4*u,f[u],i)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:c}=this;return e.length=o,e.pos=c,e.finished=i,e.destroyed=s,o%n&&e.buffer.set(r),e}}const ps=(t,e,n)=>t&e^~t&n,bs=(t,e,n)=>t&e^t&n^e&n,ws=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]),ze=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ke=new Uint32Array(64);class Wr extends gs{constructor(){super(64,32,8,!1),this.A=ze[0]|0,this.B=ze[1]|0,this.C=ze[2]|0,this.D=ze[3]|0,this.E=ze[4]|0,this.F=ze[5]|0,this.G=ze[6]|0,this.H=ze[7]|0}get(){const{A:e,B:n,C:r,D:o,E:i,F:s,G:c,H:a}=this;return[e,n,r,o,i,s,c,a]}set(e,n,r,o,i,s,c,a){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(e,n){for(let u=0;u<16;u++,n+=4)Ke[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const b=Ke[u-15],h=Ke[u-2],g=Ee(b,7)^Ee(b,18)^b>>>3,d=Ee(h,17)^Ee(h,19)^h>>>10;Ke[u]=d+Ke[u-7]+g+Ke[u-16]|0}let{A:r,B:o,C:i,D:s,E:c,F:a,G:l,H:f}=this;for(let u=0;u<64;u++){const b=Ee(c,6)^Ee(c,11)^Ee(c,25),h=f+b+ps(c,a,l)+ws[u]+Ke[u]|0,d=(Ee(r,2)^Ee(r,13)^Ee(r,22))+bs(r,o,i)|0;f=l,l=a,a=c,c=s+h|0,s=i,i=o,o=r,r=h+d|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(r,o,i,s,c,a,l,f)}roundClean(){Ke.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class ys extends Wr{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const ft=br(()=>new Wr);br(()=>new ys);var dt=Symbol("verified"),ms=t=>t instanceof Object;function vs(t){if(!ms(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]=="object")return!1}return!0}new TextDecoder("utf-8");var xs=new TextEncoder,Es=class{generateSecretKey(){return de.utils.randomPrivateKey()}getPublicKey(e){return fe(de.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=fe(de.getPublicKey(n)),r.id=Pn(r),r.sig=fe(de.sign(Pn(r),n)),r[dt]=!0,r}verifyEvent(e){if(typeof e[dt]=="boolean")return e[dt];const n=Pn(e);if(n!==e.id)return e[dt]=!1,!1;try{const r=de.verify(e.sig,n,e.pubkey);return e[dt]=r,r}catch{return e[dt]=!1,!1}}};function _s(t){if(!vs(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}function Pn(t){let e=ft(xs.encode(_s(t)));return fe(e)}var Dt=new Es,ks=Dt.generateSecretKey,Dr=Dt.getPublicKey;Dt.finalizeEvent,Dt.verifyEvent;var tt=Symbol("verified"),Ss=t=>t instanceof Object;function As(t){if(!Ss(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]=="object")return!1}return!0}new TextDecoder("utf-8");var Bs=new TextEncoder;function kt(t){t.indexOf("://")===-1&&(t="wss://"+t);let e=new URL(t);return e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}var Is=class{constructor(e){B(this,"value");B(this,"next",null);B(this,"prev",null);this.value=e}},Os=class{constructor(){B(this,"first");B(this,"last");this.first=null,this.last=null}enqueue(e){const n=new Is(e);return this.last?this.last===this.first?(this.last=n,this.last.prev=this.first,this.first.next=n):(n.prev=this.last,this.last.next=n,this.last=n):(this.first=n,this.last=n),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const n=this.first;return this.first=null,this.last=null,n.value}const e=this.first;return this.first=e.next,e.value}},Ns=class{generateSecretKey(){return de.utils.randomPrivateKey()}getPublicKey(e){return fe(de.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=fe(de.getPublicKey(n)),r.id=Rn(r),r.sig=fe(de.sign(Rn(r),n)),r[tt]=!0,r}verifyEvent(e){if(typeof e[tt]=="boolean")return e[tt];const n=Rn(e);if(n!==e.id)return e[tt]=!1,!1;try{const r=de.verify(e.sig,n,e.pubkey);return e[tt]=r,r}catch{return e[tt]=!1,!1}}};function Ls(t){if(!As(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}function Rn(t){let e=ft(Bs.encode(Ls(t)));return fe(e)}var Vt=new Ns;Vt.generateSecretKey,Vt.getPublicKey,Vt.finalizeEvent;var Ts=Vt.verifyEvent,Cs=22242;function Us(t,e){if(t.ids&&t.ids.indexOf(e.id)===-1||t.kinds&&t.kinds.indexOf(e.kind)===-1||t.authors&&t.authors.indexOf(e.pubkey)===-1)return!1;for(let n in t)if(n[0]==="#"){let r=n.slice(1),o=t[`#${r}`];if(o&&!e.tags.find(([i,s])=>i===n.slice(1)&&o.indexOf(s)!==-1))return!1}return!(t.since&&e.created_at<t.since||t.until&&e.created_at>t.until)}function Ps(t,e){for(let n=0;n<t.length;n++)if(Us(t[n],e))return!0;return!1}function Rs(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,o=t.slice(r).indexOf('"')+r+1;return t.slice(o,o+64)}function Hs(t){let e=t.slice(0,22).indexOf('"EVENT"');if(e===-1)return null;let n=t.slice(e+7+1).indexOf('"');if(n===-1)return null;let r=e+7+1+n,o=t.slice(r+1,80).indexOf('"');if(o===-1)return null;let i=r+1+o;return t.slice(r+1,i)}function Ms(t,e){return{kind:Cs,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}async function js(){return new Promise(t=>{const e=new MessageChannel,n=()=>{e.port1.removeEventListener("message",n),t()};e.port1.addEventListener("message",n),e.port2.postMessage(0),e.port1.start()})}var qs=t=>(t[tt]=!0,!0),Vr=class{constructor(e,n){B(this,"url");B(this,"_connected",!1);B(this,"onclose",null);B(this,"onnotice",e=>console.debug(`NOTICE from ${this.url}: ${e}`));B(this,"_onauth",null);B(this,"baseEoseTimeout",4400);B(this,"connectionTimeout",4400);B(this,"openSubs",new Map);B(this,"connectionTimeoutHandle");B(this,"connectionPromise");B(this,"openCountRequests",new Map);B(this,"openEventPublishes",new Map);B(this,"ws");B(this,"incomingMessageQueue",new Os);B(this,"queueRunning",!1);B(this,"challenge");B(this,"serial",0);B(this,"verifyEvent");B(this,"_WebSocket");this.url=kt(e),this.verifyEvent=n.verifyEvent,this._WebSocket=n.websocketImplementation||WebSocket}static async connect(e,n){const r=new Vr(e,n);return await r.connect(),r}closeAllSubscriptions(e){for(let[n,r]of this.openSubs)r.close(e);this.openSubs.clear();for(let[n,r]of this.openEventPublishes)r.reject(new Error(e));this.openEventPublishes.clear();for(let[n,r]of this.openCountRequests)r.reject(new Error(e));this.openCountRequests.clear()}get connected(){return this._connected}async connect(){return this.connectionPromise?this.connectionPromise:(this.challenge=void 0,this.connectionPromise=new Promise((e,n)=>{this.connectionTimeoutHandle=setTimeout(()=>{var r;n("connection timed out"),this.connectionPromise=void 0,(r=this.onclose)==null||r.call(this),this.closeAllSubscriptions("relay connection timed out")},this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(r){n(r);return}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,e()},this.ws.onerror=r=>{var o;n(r.message||"websocket error"),this._connected&&(this._connected=!1,this.connectionPromise=void 0,(o=this.onclose)==null||o.call(this),this.closeAllSubscriptions("relay connection errored"))},this.ws.onclose=async()=>{var r;this._connected&&(this._connected=!1,this.connectionPromise=void 0,(r=this.onclose)==null||r.call(this),this.closeAllSubscriptions("relay connection closed"))},this.ws.onmessage=this._onmessage.bind(this)}),this.connectionPromise)}async runQueue(){for(this.queueRunning=!0;this.handleNext()!==!1;)await js();this.queueRunning=!1}handleNext(){var r,o,i;const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const n=Hs(e);if(n){const s=this.openSubs.get(n);if(!s)return;const c=Rs(e,"id"),a=(r=s.alreadyHaveEvent)==null?void 0:r.call(s,c);if((o=s.receivedEvent)==null||o.call(s,this,c),a)return}try{let s=JSON.parse(e);switch(s[0]){case"EVENT":{const c=this.openSubs.get(s[1]),a=s[2];this.verifyEvent(a)&&Ps(c.filters,a)&&c.onevent(a);return}case"COUNT":{const c=s[1],a=s[2],l=this.openCountRequests.get(c);l&&(l.resolve(a.count),this.openCountRequests.delete(c));return}case"EOSE":{const c=this.openSubs.get(s[1]);if(!c)return;c.receivedEose();return}case"OK":{const c=s[1],a=s[2],l=s[3],f=this.openEventPublishes.get(c);a?f.resolve(l):f.reject(new Error(l)),this.openEventPublishes.delete(c);return}case"CLOSED":{const c=s[1],a=this.openSubs.get(c);if(!a)return;a.closed=!0,a.close(s[2]);return}case"NOTICE":this.onnotice(s[1]);return;case"AUTH":{this.challenge=s[1],(i=this._onauth)==null||i.call(this,s[1]);return}}}catch{return}}async send(e){if(!this.connectionPromise)throw new Error("sending on closed connection");this.connectionPromise.then(()=>{var n;(n=this.ws)==null||n.send(e)})}async auth(e){if(!this.challenge)throw new Error("can't perform auth, no challenge was received");const n=await e(Ms(this.url,this.challenge)),r=new Promise((o,i)=>{this.openEventPublishes.set(n.id,{resolve:o,reject:i})});return this.send('["AUTH",'+JSON.stringify(n)+"]"),r}async publish(e){const n=new Promise((r,o)=>{this.openEventPublishes.set(e.id,{resolve:r,reject:o})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),n}async count(e,n){this.serial++;const r=(n==null?void 0:n.id)||"count:"+this.serial,o=new Promise((i,s)=>{this.openCountRequests.set(r,{resolve:i,reject:s})});return this.send('["COUNT","'+r+'",'+JSON.stringify(e).substring(1)),o}subscribe(e,n){const r=this.prepareSubscription(e,n);return r.fire(),r}prepareSubscription(e,n){this.serial++;const r=n.id||"sub:"+this.serial,o=new zs(this,r,e,n);return this.openSubs.set(r,o),o}close(){var e;this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,(e=this.ws)==null||e.close()}_onmessage(e){this.incomingMessageQueue.enqueue(e.data),this.queueRunning||this.runQueue()}},zs=class{constructor(e,n,r,o){B(this,"relay");B(this,"id");B(this,"closed",!1);B(this,"eosed",!1);B(this,"filters");B(this,"alreadyHaveEvent");B(this,"receivedEvent");B(this,"onevent");B(this,"oneose");B(this,"onclose");B(this,"eoseTimeout");B(this,"eoseTimeoutHandle");this.relay=e,this.filters=r,this.id=n,this.alreadyHaveEvent=o.alreadyHaveEvent,this.receivedEvent=o.receivedEvent,this.eoseTimeout=o.eoseTimeout||e.baseEoseTimeout,this.oneose=o.oneose,this.onclose=o.onclose,this.onevent=o.onevent||(i=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,i)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){var e;this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,(e=this.oneose)==null||e.call(this))}close(e="closed by caller"){var n;!this.closed&&this.relay.connected&&(this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]"),this.closed=!0),this.relay.openSubs.delete(this.id),(n=this.onclose)==null||n.call(this,e)}},Ks=class{constructor(e){B(this,"relays",new Map);B(this,"seenOn",new Map);B(this,"trackRelays",!1);B(this,"verifyEvent");B(this,"trustedRelayURLs",new Set);B(this,"_WebSocket");this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation}async ensureRelay(e,n){e=kt(e);let r=this.relays.get(e);return r||(r=new Vr(e,{verifyEvent:this.trustedRelayURLs.has(e)?qs:this.verifyEvent,websocketImplementation:this._WebSocket}),n!=null&&n.connectionTimeout&&(r.connectionTimeout=n.connectionTimeout),this.relays.set(e,r)),await r.connect(),r}close(e){e.map(kt).forEach(n=>{var r;(r=this.relays.get(n))==null||r.close()})}subscribeMany(e,n,r){return this.subscribeManyMap(Object.fromEntries(e.map(o=>[o,n])),r)}subscribeManyMap(e,n){this.trackRelays&&(n.receivedEvent=(b,h)=>{let g=this.seenOn.get(h);g||(g=new Set,this.seenOn.set(h,g)),g.add(b)});const r=new Set,o=[],i=Object.keys(e).length,s=[];let c=b=>{var h;s[b]=!0,s.filter(g=>g).length===i&&((h=n.oneose)==null||h.call(n),c=()=>{})};const a=[];let l=(b,h)=>{var g;c(b),a[b]=h,a.filter(d=>d).length===i&&((g=n.onclose)==null||g.call(n,a),l=()=>{})};const f=b=>{var g;if((g=n.alreadyHaveEvent)!=null&&g.call(n,b))return!0;const h=r.has(b);return r.add(b),h},u=Promise.all(Object.entries(e).map(async(b,h,g)=>{if(g.indexOf(b)!==h){l(h,"duplicate url");return}let[d,p]=b;d=kt(d);let w;try{w=await this.ensureRelay(d,{connectionTimeout:n.maxWait?Math.max(n.maxWait*.8,n.maxWait-1e3):void 0})}catch(S){l(h,(S==null?void 0:S.message)||String(S));return}let m=w.subscribe(p,{...n,oneose:()=>c(h),onclose:S=>l(h,S),alreadyHaveEvent:f,eoseTimeout:n.maxWait});o.push(m)}));return{async close(){await u,o.forEach(b=>{b.close()})}}}subscribeManyEose(e,n,r){const o=this.subscribeMany(e,n,{...r,oneose(){o.close()}});return o}async querySync(e,n,r){return new Promise(async o=>{const i=[];this.subscribeManyEose(e,[n],{...r,onevent(s){i.push(s)},onclose(s){o(i)}})})}async get(e,n,r){n.limit=1;const o=await this.querySync(e,n,r);return o.sort((i,s)=>s.created_at-i.created_at),o[0]||null}publish(e,n){return e.map(kt).map(async(r,o,i)=>{if(i.indexOf(r)!==o)return Promise.reject("duplicate url");let s=await this.ensureRelay(r);return s.publish(n).then(c=>{if(this.trackRelays){let a=this.seenOn.get(n.id);a||(a=new Set,this.seenOn.set(n.id,a)),a.add(s)}return c})})}listConnectionStatus(){const e=new Map;return this.relays.forEach((n,r)=>e.set(r,n.connected)),e}destroy(){this.relays.forEach(e=>e.close()),this.relays=new Map}},Fr;try{Fr=WebSocket}catch{}var $s=class extends Ks{constructor(){super({verifyEvent:Ts,websocketImplementation:Fr})}};function Hn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Gr(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function Yr(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function we(t,...e){if(!Yr(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function ht(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Mn(t,e){we(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */const te=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),Ws=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function jn(t){if(typeof t!="string")throw new Error(`string expected, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function $e(t){if(typeof t=="string")t=jn(t);else if(Yr(t))t=t.slice();else throw new Error(`Uint8Array expected, got ${typeof t}`);return t}function Ds(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function Vs(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}const Fs=(t,e)=>(Object.assign(e,t),e),Oe=16,qn=new Uint8Array(16),Se=te(qn),Gs=225,Ys=(t,e,n,r)=>{const o=r&1;return{s3:n<<31|r>>>1,s2:e<<31|n>>>1,s1:t<<31|e>>>1,s0:t>>>1^Gs<<24&-(o&1)}},ye=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255|0;function Zs(t){t.reverse();const e=t[15]&1;let n=0;for(let r=0;r<t.length;r++){const o=t[r];t[r]=o>>>1|n,n=(o&1)<<7}return t[0]^=-e&225,t}const Js=t=>t>64*1024?8:t>1024?4:2;class Zr{constructor(e,n){this.blockLen=Oe,this.outputLen=Oe,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,e=$e(e),we(e,16);const r=Ws(e);let o=r.getUint32(0,!1),i=r.getUint32(4,!1),s=r.getUint32(8,!1),c=r.getUint32(12,!1);const a=[];for(let g=0;g<128;g++)a.push({s0:ye(o),s1:ye(i),s2:ye(s),s3:ye(c)}),{s0:o,s1:i,s2:s,s3:c}=Ys(o,i,s,c);const l=Js(n||1024);if(![1,2,4,8].includes(l))throw new Error(`ghash: wrong window size=${l}, should be 2, 4 or 8`);this.W=l;const u=128/l,b=this.windowSize=2**l,h=[];for(let g=0;g<u;g++)for(let d=0;d<b;d++){let p=0,w=0,m=0,S=0;for(let T=0;T<l;T++){if(!(d>>>l-T-1&1))continue;const{s0:_,s1:x,s2:y,s3:E}=a[l*g+T];p^=_,w^=x,m^=y,S^=E}h.push({s0:p,s1:w,s2:m,s3:S})}this.t=h}_updateBlock(e,n,r,o){e^=this.s0,n^=this.s1,r^=this.s2,o^=this.s3;const{W:i,t:s,windowSize:c}=this;let a=0,l=0,f=0,u=0;const b=(1<<i)-1;let h=0;for(const g of[e,n,r,o])for(let d=0;d<4;d++){const p=g>>>8*d&255;for(let w=8/i-1;w>=0;w--){const m=p>>>i*w&b,{s0:S,s1:T,s2:R,s3:_}=s[h*c+m];a^=S,l^=T,f^=R,u^=_,h+=1}}this.s0=a,this.s1=l,this.s2=f,this.s3=u}update(e){e=$e(e),ht(this);const n=te(e),r=Math.floor(e.length/Oe),o=e.length%Oe;for(let i=0;i<r;i++)this._updateBlock(n[i*4+0],n[i*4+1],n[i*4+2],n[i*4+3]);return o&&(qn.set(e.subarray(r*Oe)),this._updateBlock(Se[0],Se[1],Se[2],Se[3]),Se.fill(0)),this}destroy(){const{t:e}=this;for(const n of e)n.s0=0,n.s1=0,n.s2=0,n.s3=0}digestInto(e){ht(this),Mn(e,this),this.finished=!0;const{s0:n,s1:r,s2:o,s3:i}=this,s=te(e);return s[0]=n,s[1]=r,s[2]=o,s[3]=i,e}digest(){const e=new Uint8Array(Oe);return this.digestInto(e),this.destroy(),e}}class Qs extends Zr{constructor(e,n){e=$e(e);const r=Zs(e.slice());super(r,n),r.fill(0)}update(e){e=$e(e),ht(this);const n=te(e),r=e.length%Oe,o=Math.floor(e.length/Oe);for(let i=0;i<o;i++)this._updateBlock(ye(n[i*4+3]),ye(n[i*4+2]),ye(n[i*4+1]),ye(n[i*4+0]));return r&&(qn.set(e.subarray(o*Oe)),this._updateBlock(ye(Se[3]),ye(Se[2]),ye(Se[1]),ye(Se[0])),Se.fill(0)),this}digestInto(e){ht(this),Mn(e,this),this.finished=!0;const{s0:n,s1:r,s2:o,s3:i}=this,s=te(e);return s[0]=n,s[1]=r,s[2]=o,s[3]=i,e.reverse()}}function Jr(t){const e=(r,o)=>t(o,r.length).update($e(r)).digest(),n=t(new Uint8Array(16),0);return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=(r,o)=>t(r,o),e}Jr((t,e)=>new Zr(t,e)),Jr((t,e)=>new Qs(t,e));const We=16,Xs=283;function zn(t){return t<<1^Xs&-(t>>7)}function gt(t,e){let n=0;for(;e>0;e>>=1)n^=t&-(e&1),t=zn(t);return n}const Kn=(()=>{let t=new Uint8Array(256);for(let n=0,r=1;n<256;n++,r^=zn(r))t[n]=r;const e=new Uint8Array(256);e[0]=99;for(let n=0;n<255;n++){let r=t[255-n];r|=r<<8,e[t[n]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return e})(),ec=Kn.map((t,e)=>Kn.indexOf(e)),tc=t=>t<<24|t>>>8,$n=t=>t<<8|t>>>24;function Qr(t,e){if(t.length!==256)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((l,f)=>e(t[f])),r=n.map($n),o=r.map($n),i=o.map($n),s=new Uint32Array(256*256),c=new Uint32Array(256*256),a=new Uint16Array(256*256);for(let l=0;l<256;l++)for(let f=0;f<256;f++){const u=l*256+f;s[u]=n[l]^r[f],c[u]=o[l]^i[f],a[u]=t[l]<<8|t[f]}return{sbox:t,sbox2:a,T0:n,T1:r,T2:o,T3:i,T01:s,T23:c}}const Wn=Qr(Kn,t=>gt(t,3)<<24|t<<16|t<<8|gt(t,2)),Xr=Qr(ec,t=>gt(t,11)<<24|gt(t,13)<<16|gt(t,9)<<8|gt(t,14)),nc=(()=>{const t=new Uint8Array(16);for(let e=0,n=1;e<16;e++,n=zn(n))t[e]=n;return t})();function eo(t){we(t);const e=t.length;if(![16,24,32].includes(e))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${e}`);const{sbox2:n}=Wn,r=te(t),o=r.length,i=c=>Ae(n,c,c,c,c),s=new Uint32Array(e+28);s.set(r);for(let c=o;c<s.length;c++){let a=s[c-1];c%o===0?a=i(tc(a))^nc[c/o-1]:o>6&&c%o===4&&(a=i(a)),s[c]=s[c-o]^a}return s}function rc(t){const e=eo(t),n=e.slice(),r=e.length,{sbox2:o}=Wn,{T0:i,T1:s,T2:c,T3:a}=Xr;for(let l=0;l<r;l+=4)for(let f=0;f<4;f++)n[l+f]=e[r-l-4+f];e.fill(0);for(let l=4;l<r-4;l++){const f=n[l],u=Ae(o,f,f,f,f);n[l]=i[u&255]^s[u>>>8&255]^c[u>>>16&255]^a[u>>>24]}return n}function De(t,e,n,r,o,i){return t[n<<8&65280|r>>>8&255]^e[o>>>8&65280|i>>>24&255]}function Ae(t,e,n,r,o){return t[e&255|n&65280]|t[r>>>16&255|o>>>16&65280]<<16}function to(t,e,n,r,o){const{sbox2:i,T01:s,T23:c}=Wn;let a=0;e^=t[a++],n^=t[a++],r^=t[a++],o^=t[a++];const l=t.length/4-2;for(let g=0;g<l;g++){const d=t[a++]^De(s,c,e,n,r,o),p=t[a++]^De(s,c,n,r,o,e),w=t[a++]^De(s,c,r,o,e,n),m=t[a++]^De(s,c,o,e,n,r);e=d,n=p,r=w,o=m}const f=t[a++]^Ae(i,e,n,r,o),u=t[a++]^Ae(i,n,r,o,e),b=t[a++]^Ae(i,r,o,e,n),h=t[a++]^Ae(i,o,e,n,r);return{s0:f,s1:u,s2:b,s3:h}}function oc(t,e,n,r,o){const{sbox2:i,T01:s,T23:c}=Xr;let a=0;e^=t[a++],n^=t[a++],r^=t[a++],o^=t[a++];const l=t.length/4-2;for(let g=0;g<l;g++){const d=t[a++]^De(s,c,e,o,r,n),p=t[a++]^De(s,c,n,e,o,r),w=t[a++]^De(s,c,r,n,e,o),m=t[a++]^De(s,c,o,r,n,e);e=d,n=p,r=w,o=m}const f=t[a++]^Ae(i,e,o,r,n),u=t[a++]^Ae(i,n,e,o,r),b=t[a++]^Ae(i,r,n,e,o),h=t[a++]^Ae(i,o,r,n,e);return{s0:f,s1:u,s2:b,s3:h}}function no(t,e){if(!e)return new Uint8Array(t);if(we(e),e.length<t)throw new Error(`aes: wrong destination length, expected at least ${t}, got: ${e.length}`);return e}function ic(t){if(we(t),t.length%We!==0)throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${We}`)}function sc(t,e,n){let r=t.length;const o=r%We;if(!e&&o!==0)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const i=te(t);if(e){let a=We-o;a||(a=We),r=r+a}const s=no(r,n),c=te(s);return{b:i,o:c,out:s}}function cc(t,e){if(!e)return t;const n=t.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=t[n-1];if(r<=0||r>16)throw new Error(`aes/pcks5: wrong padding byte: ${r}`);const o=t.subarray(0,-r);for(let i=0;i<r;i++)if(t[n-i-1]!==r)throw new Error("aes/pcks5: wrong padding");return o}function ac(t){const e=new Uint8Array(16),n=te(e);e.set(t);const r=We-t.length;for(let o=We-r;o<We;o++)e[o]=r;return n}const ro=Fs({blockSize:16,nonceLength:16},function(e,n,r={}){we(e),we(n,16);const o=!r.disablePadding;return{encrypt:(i,s)=>{const c=eo(e),{b:a,o:l,out:f}=sc(i,o,s),u=te(n);let b=u[0],h=u[1],g=u[2],d=u[3],p=0;for(;p+4<=a.length;)b^=a[p+0],h^=a[p+1],g^=a[p+2],d^=a[p+3],{s0:b,s1:h,s2:g,s3:d}=to(c,b,h,g,d),l[p++]=b,l[p++]=h,l[p++]=g,l[p++]=d;if(o){const w=ac(i.subarray(p*4));b^=w[0],h^=w[1],g^=w[2],d^=w[3],{s0:b,s1:h,s2:g,s3:d}=to(c,b,h,g,d),l[p++]=b,l[p++]=h,l[p++]=g,l[p++]=d}return c.fill(0),f},decrypt:(i,s)=>{ic(i);const c=rc(e),a=te(n),l=no(i.length,s),f=te(i),u=te(l);let b=a[0],h=a[1],g=a[2],d=a[3];for(let p=0;p+4<=f.length;){const w=b,m=h,S=g,T=d;b=f[p+0],h=f[p+1],g=f[p+2],d=f[p+3];const{s0:R,s1:_,s2:x,s3:y}=oc(c,b,h,g,d);u[p++]=R^w,u[p++]=_^m,u[p++]=x^S,u[p++]=y^T}return c.fill(0),cc(l,o)}}});/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function pt(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function Ne(...t){const e=(o,i)=>s=>o(i(s)),n=Array.from(t).reverse().reduce((o,i)=>o?e(o,i.encode):i.encode,void 0),r=t.reduce((o,i)=>o?e(o,i.decode):i.decode,void 0);return{encode:n,decode:r}}function Le(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return e.map(n=>{if(pt(n),n<0||n>=t.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${t.length})`);return t[n]})},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("alphabet.decode input should be array of strings");return e.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=t.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${t}`);return r})}}}function Te(t=""){if(typeof t!="string")throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of e)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return e.join(t)},decode:e=>{if(typeof e!="string")throw new Error("join.decode input should be string");return e.split(t)}}}function Ft(t,e="="){if(pt(t),typeof e!="string")throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let r of n)if(typeof r!="string")throw new Error(`padding.encode: non-string input=${r}`);for(;n.length*t%8;)n.push(e);return n},decode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let o of n)if(typeof o!="string")throw new Error(`padding.decode: non-string input=${o}`);let r=n.length;if(r*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--)if(!((r-1)*t%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function oo(t){if(typeof t!="function")throw new Error("normalize fn should be function");return{encode:e=>e,decode:e=>t(e)}}function io(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let r=0;const o=[],i=Array.from(t);for(i.forEach(s=>{if(pt(s),s<0||s>=e)throw new Error(`Wrong integer: ${s}`)});;){let s=0,c=!0;for(let a=r;a<i.length;a++){const l=i[a],f=e*s+l;if(!Number.isSafeInteger(f)||e*s/e!==s||f-l!==e*s)throw new Error("convertRadix: carry overflow");if(s=f%n,i[a]=Math.floor(f/n),!Number.isSafeInteger(i[a])||i[a]*n+s!==f)throw new Error("convertRadix: carry overflow");if(c)i[a]?c=!1:r=a;else continue}if(o.push(s),c)break}for(let s=0;s<t.length-1&&t[s]===0;s++)o.push(0);return o.reverse()}const so=(t,e)=>e?so(e,t%e):t,Gt=(t,e)=>t+(e-so(t,e));function Dn(t,e,n,r){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Gt(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${Gt(e,n)}`);let o=0,i=0;const s=2**n-1,c=[];for(const a of t){if(pt(a),a>=2**e)throw new Error(`convertRadix2: invalid data word=${a} from=${e}`);if(o=o<<e|a,i+e>32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${e}`);for(i+=e;i>=n;i-=n)c.push((o>>i-n&s)>>>0);o&=2**i-1}if(o=o<<n-i&s,!r&&i>=e)throw new Error("Excess padding");if(!r&&o)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&c.push(o>>>0),c}function lc(t){return pt(t),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return io(Array.from(e),2**8,t)},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("radix.decode input should be array of strings");return Uint8Array.from(io(e,t,2**8))}}}function Ve(t,e=!1){if(pt(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Gt(8,t)>32||Gt(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return Dn(Array.from(n),8,t,!e)},decode:n=>{if(!Array.isArray(n)||n.length&&typeof n[0]!="number")throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(Dn(n,t,8,e))}}}function co(t){if(typeof t!="function")throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch{}}}const uc=Ne(Ve(4),Le("0123456789ABCDEF"),Te("")),fc=Ne(Ve(5),Le("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Ft(5),Te(""));Ne(Ve(5),Le("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Ft(5),Te("")),Ne(Ve(5),Le("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Te(""),oo(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const bt=Ne(Ve(6),Le("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Ft(6),Te("")),dc=Ne(Ve(6),Le("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Ft(6),Te("")),Vn=t=>Ne(lc(58),Le(t),Te("")),Fn=Vn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");Vn("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),Vn("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const ao=[0,2,3,5,6,7,9,10,11],hc={encode(t){let e="";for(let n=0;n<t.length;n+=8){const r=t.subarray(n,n+8);e+=Fn.encode(r).padStart(ao[r.length],"1")}return e},decode(t){let e=[];for(let n=0;n<t.length;n+=11){const r=t.slice(n,n+11),o=ao.indexOf(r.length),i=Fn.decode(r);for(let s=0;s<i.length-o;s++)if(i[s]!==0)throw new Error("base58xmr: wrong padding");e=e.concat(Array.from(i.slice(i.length-o)))}return Uint8Array.from(e)}},Gn=Ne(Le("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Te("")),lo=[996825010,642813549,513874426,1027748829,705979059];function St(t){const e=t>>25;let n=(t&33554431)<<5;for(let r=0;r<lo.length;r++)(e>>r&1)===1&&(n^=lo[r]);return n}function uo(t,e,n=1){const r=t.length;let o=1;for(let i=0;i<r;i++){const s=t.charCodeAt(i);if(s<33||s>126)throw new Error(`Invalid prefix (${t})`);o=St(o)^s>>5}o=St(o);for(let i=0;i<r;i++)o=St(o)^t.charCodeAt(i)&31;for(let i of e)o=St(o)^i;for(let i=0;i<6;i++)o=St(o);return o^=n,Gn.encode(Dn([o%2**30],30,5,!1))}function fo(t){const e=t==="bech32"?1:734539939,n=Ve(5),r=n.decode,o=n.encode,i=co(r);function s(f,u,b=90){if(typeof f!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof f}`);if(!Array.isArray(u)||u.length&&typeof u[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof u}`);const h=f.length+7+u.length;if(b!==!1&&h>b)throw new TypeError(`Length ${h} exceeds limit ${b}`);return f=f.toLowerCase(),`${f}1${Gn.encode(u)}${uo(f,u,e)}`}function c(f,u=90){if(typeof f!="string")throw new Error(`bech32.decode input should be string, not ${typeof f}`);if(f.length<8||u!==!1&&f.length>u)throw new TypeError(`Wrong string length: ${f.length} (${f}). Expected (8..${u})`);const b=f.toLowerCase();if(f!==b&&f!==f.toUpperCase())throw new Error("String must be lowercase or uppercase");f=b;const h=f.lastIndexOf("1");if(h===0||h===-1)throw new Error('Letter "1" must be present between prefix and data only');const g=f.slice(0,h),d=f.slice(h+1);if(d.length<6)throw new Error("Data must be at least 6 characters long");const p=Gn.decode(d).slice(0,-6),w=uo(g,p,e);if(!d.endsWith(w))throw new Error(`Invalid checksum in ${f}: expected "${w}"`);return{prefix:g,words:p}}const a=co(c);function l(f){const{prefix:u,words:b}=c(f,!1);return{prefix:u,words:b,bytes:r(b)}}return{encode:s,decode:c,decodeToBytes:l,decodeUnsafe:a,fromWords:r,fromWordsUnsafe:i,toWords:o}}const ho=fo("bech32");fo("bech32m");const gc={encode:t=>new TextDecoder().decode(t),decode:t=>new TextEncoder().encode(t)},pc=Ne(Ve(4),Le("0123456789abcdef"),Te(""),oo(t=>{if(typeof t!="string"||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()}));`${Object.keys({utf8:gc,hex:pc,base16:uc,base32:fc,base64:bt,base64url:dc,base58:Fn,base58xmr:hc}).join(", ")}`;const se=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class bc{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=$e(e),we(e,32);const n=se(e,0),r=se(e,2),o=se(e,4),i=se(e,6),s=se(e,8),c=se(e,10),a=se(e,12),l=se(e,14);this.r[0]=n&8191,this.r[1]=(n>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|i<<9)&8191,this.r[4]=(i>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|c<<2)&8191,this.r[7]=(c>>>11|a<<5)&8065,this.r[8]=(a>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let f=0;f<8;f++)this.pad[f]=se(e,16+2*f)}process(e,n,r=!1){const o=r?0:2048,{h:i,r:s}=this,c=s[0],a=s[1],l=s[2],f=s[3],u=s[4],b=s[5],h=s[6],g=s[7],d=s[8],p=s[9],w=se(e,n+0),m=se(e,n+2),S=se(e,n+4),T=se(e,n+6),R=se(e,n+8),_=se(e,n+10),x=se(e,n+12),y=se(e,n+14);let E=i[0]+(w&8191),U=i[1]+((w>>>13|m<<3)&8191),N=i[2]+((m>>>10|S<<6)&8191),M=i[3]+((S>>>7|T<<9)&8191),W=i[4]+((T>>>4|R<<12)&8191),V=i[5]+(R>>>1&8191),v=i[6]+((R>>>14|_<<2)&8191),A=i[7]+((_>>>11|x<<5)&8191),C=i[8]+((x>>>8|y<<8)&8191),H=i[9]+(y>>>5|o),I=0,q=I+E*c+U*(5*p)+N*(5*d)+M*(5*g)+W*(5*h);I=q>>>13,q&=8191,q+=V*(5*b)+v*(5*u)+A*(5*f)+C*(5*l)+H*(5*a),I+=q>>>13,q&=8191;let D=I+E*a+U*c+N*(5*p)+M*(5*d)+W*(5*g);I=D>>>13,D&=8191,D+=V*(5*h)+v*(5*b)+A*(5*u)+C*(5*f)+H*(5*l),I+=D>>>13,D&=8191;let $=I+E*l+U*a+N*c+M*(5*p)+W*(5*d);I=$>>>13,$&=8191,$+=V*(5*g)+v*(5*h)+A*(5*b)+C*(5*u)+H*(5*f),I+=$>>>13,$&=8191;let X=I+E*f+U*l+N*a+M*c+W*(5*p);I=X>>>13,X&=8191,X+=V*(5*d)+v*(5*g)+A*(5*h)+C*(5*b)+H*(5*u),I+=X>>>13,X&=8191;let Q=I+E*u+U*f+N*l+M*a+W*c;I=Q>>>13,Q&=8191,Q+=V*(5*p)+v*(5*d)+A*(5*g)+C*(5*h)+H*(5*b),I+=Q>>>13,Q&=8191;let ce=I+E*b+U*u+N*f+M*l+W*a;I=ce>>>13,ce&=8191,ce+=V*c+v*(5*p)+A*(5*d)+C*(5*g)+H*(5*h),I+=ce>>>13,ce&=8191;let J=I+E*h+U*b+N*u+M*f+W*l;I=J>>>13,J&=8191,J+=V*a+v*c+A*(5*p)+C*(5*d)+H*(5*g),I+=J>>>13,J&=8191;let re=I+E*g+U*h+N*b+M*u+W*f;I=re>>>13,re&=8191,re+=V*l+v*a+A*c+C*(5*p)+H*(5*d),I+=re>>>13,re&=8191;let ue=I+E*d+U*g+N*h+M*b+W*u;I=ue>>>13,ue&=8191,ue+=V*f+v*l+A*a+C*c+H*(5*p),I+=ue>>>13,ue&=8191;let ae=I+E*p+U*d+N*g+M*h+W*b;I=ae>>>13,ae&=8191,ae+=V*u+v*f+A*l+C*a+H*c,I+=ae>>>13,ae&=8191,I=(I<<2)+I|0,I=I+q|0,q=I&8191,I=I>>>13,D+=I,i[0]=q,i[1]=D,i[2]=$,i[3]=X,i[4]=Q,i[5]=ce,i[6]=J,i[7]=re,i[8]=ue,i[9]=ae}finalize(){const{h:e,pad:n}=this,r=new Uint16Array(10);let o=e[1]>>>13;e[1]&=8191;for(let c=2;c<10;c++)e[c]+=o,o=e[c]>>>13,e[c]&=8191;e[0]+=o*5,o=e[0]>>>13,e[0]&=8191,e[1]+=o,o=e[1]>>>13,e[1]&=8191,e[2]+=o,r[0]=e[0]+5,o=r[0]>>>13,r[0]&=8191;for(let c=1;c<10;c++)r[c]=e[c]+o,o=r[c]>>>13,r[c]&=8191;r[9]-=8192;let i=(o^1)-1;for(let c=0;c<10;c++)r[c]&=i;i=~i;for(let c=0;c<10;c++)e[c]=e[c]&i|r[c];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let s=e[0]+n[0];e[0]=s&65535;for(let c=1;c<8;c++)s=(e[c]+n[c]|0)+(s>>>16)|0,e[c]=s&65535}update(e){ht(this);const{buffer:n,blockLen:r}=this;e=$e(e);const o=e.length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s===r){for(;r<=o-i;i+=r)this.process(e,i);continue}n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(n,0,!1),this.pos=0)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(e){ht(this),Mn(e,this),this.finished=!0;const{buffer:n,h:r}=this;let{pos:o}=this;if(o){for(n[o++]=1;o<16;o++)n[o]=0;this.process(n,0,!0)}this.finalize();let i=0;for(let s=0;s<8;s++)e[i++]=r[s]>>>0,e[i++]=r[s]>>>8;return e}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}}function wc(t){const e=(r,o)=>t(o).update($e(r)).digest(),n=t(new Uint8Array(32));return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}wc(t=>new bc(t));const yc=jn("expand 16-byte k"),mc=jn("expand 32-byte k"),vc=te(yc),xc=te(mc);function G(t,e){return t<<e|t>>>32-e}function Yn(t){return t.byteOffset%4===0}const Yt=64,Ec=16,go=2**32-1,po=new Uint32Array;function _c(t,e,n,r,o,i,s,c){const a=o.length,l=new Uint8Array(Yt),f=te(l),u=Yn(o)&&Yn(i),b=u?te(o):po,h=u?te(i):po;for(let g=0;g<a;s++){if(t(e,n,r,f,s,c),s>=go)throw new Error("arx: counter overflow");const d=Math.min(Yt,a-g);if(u&&d===Yt){const p=g/4;if(g%4!==0)throw new Error("arx: invalid block position");for(let w=0,m;w<Ec;w++)m=p+w,h[m]=b[m]^f[w];g+=Yt;continue}for(let p=0,w;p<d;p++)w=g+p,i[w]=o[w]^l[p];g+=d}}function kc(t,e){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:i,rounds:s}=Ds({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return Hn(o),Hn(s),Gr(i),Gr(n),(c,a,l,f,u=0)=>{we(c),we(a),we(l);const b=l.length;if(f||(f=new Uint8Array(b)),we(f),Hn(u),u<0||u>=go)throw new Error("arx: counter overflow");if(f.length<b)throw new Error(`arx: output (${f.length}) is shorter than data (${b})`);const h=[];let g=c.length,d,p;if(g===32)d=c.slice(),h.push(d),p=xc;else if(g===16&&n)d=new Uint8Array(32),d.set(c),d.set(c,16),p=vc,h.push(d);else throw new Error(`arx: invalid 32-byte key, got length=${g}`);Yn(a)||(a=a.slice(),h.push(a));const w=te(d);if(r){if(a.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(p,w,te(a.subarray(0,16)),w),a=a.subarray(16)}const m=16-o;if(m!==a.length)throw new Error(`arx: nonce must be ${m} or 16 bytes`);if(m!==12){const T=new Uint8Array(12);T.set(a,i?0:12-a.length),a=T,h.push(a)}const S=te(a);for(_c(t,p,w,S,l,f,u,s);h.length>0;)h.pop().fill(0);return f}}function Sc(t,e,n,r,o,i=20){let s=t[0],c=t[1],a=t[2],l=t[3],f=e[0],u=e[1],b=e[2],h=e[3],g=e[4],d=e[5],p=e[6],w=e[7],m=o,S=n[0],T=n[1],R=n[2],_=s,x=c,y=a,E=l,U=f,N=u,M=b,W=h,V=g,v=d,A=p,C=w,H=m,I=S,q=T,D=R;for(let X=0;X<i;X+=2)_=_+U|0,H=G(H^_,16),V=V+H|0,U=G(U^V,12),_=_+U|0,H=G(H^_,8),V=V+H|0,U=G(U^V,7),x=x+N|0,I=G(I^x,16),v=v+I|0,N=G(N^v,12),x=x+N|0,I=G(I^x,8),v=v+I|0,N=G(N^v,7),y=y+M|0,q=G(q^y,16),A=A+q|0,M=G(M^A,12),y=y+M|0,q=G(q^y,8),A=A+q|0,M=G(M^A,7),E=E+W|0,D=G(D^E,16),C=C+D|0,W=G(W^C,12),E=E+W|0,D=G(D^E,8),C=C+D|0,W=G(W^C,7),_=_+N|0,D=G(D^_,16),A=A+D|0,N=G(N^A,12),_=_+N|0,D=G(D^_,8),A=A+D|0,N=G(N^A,7),x=x+M|0,H=G(H^x,16),C=C+H|0,M=G(M^C,12),x=x+M|0,H=G(H^x,8),C=C+H|0,M=G(M^C,7),y=y+W|0,I=G(I^y,16),V=V+I|0,W=G(W^V,12),y=y+W|0,I=G(I^y,8),V=V+I|0,W=G(W^V,7),E=E+U|0,q=G(q^E,16),v=v+q|0,U=G(U^v,12),E=E+U|0,q=G(q^E,8),v=v+q|0,U=G(U^v,7);let $=0;r[$++]=s+_|0,r[$++]=c+x|0,r[$++]=a+y|0,r[$++]=l+E|0,r[$++]=f+U|0,r[$++]=u+N|0,r[$++]=b+M|0,r[$++]=h+W|0,r[$++]=g+V|0,r[$++]=d+v|0,r[$++]=p+A|0,r[$++]=w+C|0,r[$++]=m+H|0,r[$++]=S+I|0,r[$++]=T+q|0,r[$++]=R+D|0}const Ac=kc(Sc,{counterRight:!1,counterLength:4,allowShortKeys:!1});class bo extends pr{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,ke.hash(e);const r=xt(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(r.length>o?e.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return ke.exists(this),this.iHash.update(e),this}digestInto(e){ke.exists(this),ke.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=c,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Zt=(t,e,n)=>new bo(t,e).update(n).digest();Zt.create=(t,e)=>new bo(t,e);function Bc(t,e,n){return ke.hash(t),n===void 0&&(n=new Uint8Array(t.outputLen)),Zt(t,xt(n),xt(e))}const Zn=new Uint8Array([0]),wo=new Uint8Array;function Ic(t,e,n,r=32){if(ke.hash(t),ke.number(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/t.outputLen);n===void 0&&(n=wo);const i=new Uint8Array(o*t.outputLen),s=Zt.create(t,e),c=s._cloneInto(),a=new Uint8Array(s.outputLen);for(let l=0;l<o;l++)Zn[0]=l+1,c.update(l===0?wo:a).update(n).update(Zn).digestInto(a),i.set(a,t.outputLen*l),s._cloneInto(c);return s.destroy(),c.destroy(),a.fill(0),Zn.fill(0),i.slice(0,r)}var nt=Symbol("verified"),Oc=t=>t instanceof Object;function Nc(t){if(!Oc(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]=="object")return!1}return!0}var yo=new TextDecoder("utf-8"),mo=new TextEncoder;function At(t){t.indexOf("://")===-1&&(t="wss://"+t);let e=new URL(t);return e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}var Lc=class{constructor(t){B(this,"value");B(this,"next",null);B(this,"prev",null);this.value=t}},Tc=class{constructor(){B(this,"first");B(this,"last");this.first=null,this.last=null}enqueue(t){const e=new Lc(t);return this.last?this.last===this.first?(this.last=e,this.last.prev=this.first,this.first.next=e):(e.prev=this.last,this.last.next=e,this.last=e):(this.first=e,this.last=e),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const e=this.first;return this.first=null,this.last=null,e.value}const t=this.first;return this.first=t.next,t.value}},Cc=class{generateSecretKey(){return de.utils.randomPrivateKey()}getPublicKey(t){return fe(de.getPublicKey(t))}finalizeEvent(t,e){const n=t;return n.pubkey=fe(de.getPublicKey(e)),n.id=Jn(n),n.sig=fe(de.sign(Jn(n),e)),n[nt]=!0,n}verifyEvent(t){if(typeof t[nt]=="boolean")return t[nt];const e=Jn(t);if(e!==t.id)return t[nt]=!1,!1;try{const n=de.verify(t.sig,e,t.pubkey);return t[nt]=n,n}catch{return t[nt]=!1,!1}}};function Uc(t){if(!Nc(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}function Jn(t){let e=ft(mo.encode(Uc(t)));return fe(e)}var Jt=new Cc,Pc=Jt.generateSecretKey,Rc=Jt.getPublicKey,Hc=Jt.finalizeEvent,vo=Jt.verifyEvent;async function Mc(t,e,n){const r=t instanceof Uint8Array?fe(t):t,o=ut.getSharedSecret(r,"02"+e),i=xo(o);let s=Uint8Array.from(wi(16)),c=mo.encode(n),a=ro(i,s).encrypt(c),l=bt.encode(new Uint8Array(a)),f=bt.encode(new Uint8Array(s.buffer));return`${l}?iv=${f}`}async function jc(t,e,n){const r=t instanceof Uint8Array?fe(t):t;let[o,i]=n.split("?iv="),s=ut.getSharedSecret(r,"02"+e),c=xo(s),a=bt.decode(i),l=bt.decode(o),f=ro(c,a).decrypt(l);return yo.decode(f)}function xo(t){return t.slice(1,33)}var qc=1,zc=65535;function Kc(t,e){const n=ut.getSharedSecret(t,"02"+e).subarray(1,33);return Bc(ft,n,"nip44-v2")}function $c(t,e){const n=Ic(ft,t,e,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function Wc(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("expected positive integer");if(t<=32)return 32;const e=1<<Math.floor(Math.log2(t-1))+1,n=e<=256?32:e/8;return n*(Math.floor((t-1)/n)+1)}function Dc(t){const e=new DataView(t.buffer).getUint16(0),n=t.subarray(2,2+e);if(e<qc||e>zc||n.length!==e||t.length!==2+Wc(e))throw new Error("invalid padding");return yo.decode(n)}function Vc(t,e,n){if(n.length!==32)throw new Error("AAD associated data must be 32 bytes");const r=bi(n,e);return Zt(ft,t,r)}function Fc(t){if(typeof t!="string")throw new Error("payload must be a valid string");const e=t.length;if(e<132||e>87472)throw new Error("invalid payload length: "+e);if(t[0]==="#")throw new Error("unknown encryption version");let n;try{n=bt.decode(t)}catch(i){throw new Error("invalid base64: "+i.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const o=n[0];if(o!==2)throw new Error("unknown encryption version "+o);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}function Gc(t,e){const{nonce:n,ciphertext:r,mac:o}=Fc(t),{chacha_key:i,chacha_nonce:s,hmac_key:c}=$c(e,n),a=Vc(c,r,n);if(!Vs(a,o))throw new Error("invalid MAC");const l=Ac(i,s,r);return Dc(l)}var Yc=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,Zc;try{Zc=fetch}catch{}var Jc=22242,Qn=24133,Qc=31990;function Xc(t,e){if(t.ids&&t.ids.indexOf(e.id)===-1||t.kinds&&t.kinds.indexOf(e.kind)===-1||t.authors&&t.authors.indexOf(e.pubkey)===-1)return!1;for(let n in t)if(n[0]==="#"){let r=n.slice(1),o=t[`#${r}`];if(o&&!e.tags.find(([i,s])=>i===n.slice(1)&&o.indexOf(s)!==-1))return!1}return!(t.since&&e.created_at<t.since||t.until&&e.created_at>t.until)}function ea(t,e){for(let n=0;n<t.length;n++)if(Xc(t[n],e))return!0;return!1}function ta(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,o=t.slice(r).indexOf('"')+r+1;return t.slice(o,o+64)}function na(t){let e=t.slice(0,22).indexOf('"EVENT"');if(e===-1)return null;let n=t.slice(e+7+1).indexOf('"');if(n===-1)return null;let r=e+7+1+n,o=t.slice(r+1,80).indexOf('"');if(o===-1)return null;let i=r+1+o;return t.slice(r+1,i)}function ra(t,e){return{kind:Jc,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}async function oa(){return new Promise(t=>{const e=new MessageChannel,n=()=>{e.port1.removeEventListener("message",n),t()};e.port1.addEventListener("message",n),e.port2.postMessage(0),e.port1.start()})}var ia=t=>(t[nt]=!0,!0),Eo=class{constructor(t,e){B(this,"url");B(this,"_connected",!1);B(this,"onclose",null);B(this,"onnotice",t=>console.debug(`NOTICE from ${this.url}: ${t}`));B(this,"_onauth",null);B(this,"baseEoseTimeout",4400);B(this,"connectionTimeout",4400);B(this,"openSubs",new Map);B(this,"connectionTimeoutHandle");B(this,"connectionPromise");B(this,"openCountRequests",new Map);B(this,"openEventPublishes",new Map);B(this,"ws");B(this,"incomingMessageQueue",new Tc);B(this,"queueRunning",!1);B(this,"challenge");B(this,"serial",0);B(this,"verifyEvent");B(this,"_WebSocket");this.url=At(t),this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation||WebSocket}static async connect(t,e){const n=new Eo(t,e);return await n.connect(),n}closeAllSubscriptions(t){for(let[e,n]of this.openSubs)n.close(t);this.openSubs.clear();for(let[e,n]of this.openEventPublishes)n.reject(new Error(t));this.openEventPublishes.clear();for(let[e,n]of this.openCountRequests)n.reject(new Error(t));this.openCountRequests.clear()}get connected(){return this._connected}async connect(){return this.connectionPromise?this.connectionPromise:(this.challenge=void 0,this.connectionPromise=new Promise((t,e)=>{this.connectionTimeoutHandle=setTimeout(()=>{var n;e("connection timed out"),this.connectionPromise=void 0,(n=this.onclose)==null||n.call(this),this.closeAllSubscriptions("relay connection timed out")},this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(n){e(n);return}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,t()},this.ws.onerror=n=>{var r;e(n.message||"websocket error"),this._connected&&(this._connected=!1,this.connectionPromise=void 0,(r=this.onclose)==null||r.call(this),this.closeAllSubscriptions("relay connection errored"))},this.ws.onclose=async()=>{var n;this._connected&&(this._connected=!1,this.connectionPromise=void 0,(n=this.onclose)==null||n.call(this),this.closeAllSubscriptions("relay connection closed"))},this.ws.onmessage=this._onmessage.bind(this)}),this.connectionPromise)}async runQueue(){for(this.queueRunning=!0;this.handleNext()!==!1;)await oa();this.queueRunning=!1}handleNext(){var n,r,o;const t=this.incomingMessageQueue.dequeue();if(!t)return!1;const e=na(t);if(e){const i=this.openSubs.get(e);if(!i)return;const s=ta(t,"id"),c=(n=i.alreadyHaveEvent)==null?void 0:n.call(i,s);if((r=i.receivedEvent)==null||r.call(i,this,s),c)return}try{let i=JSON.parse(t);switch(i[0]){case"EVENT":{const s=this.openSubs.get(i[1]),c=i[2];this.verifyEvent(c)&&ea(s.filters,c)&&s.onevent(c);return}case"COUNT":{const s=i[1],c=i[2],a=this.openCountRequests.get(s);a&&(a.resolve(c.count),this.openCountRequests.delete(s));return}case"EOSE":{const s=this.openSubs.get(i[1]);if(!s)return;s.receivedEose();return}case"OK":{const s=i[1],c=i[2],a=i[3],l=this.openEventPublishes.get(s);c?l.resolve(a):l.reject(new Error(a)),this.openEventPublishes.delete(s);return}case"CLOSED":{const s=i[1],c=this.openSubs.get(s);if(!c)return;c.closed=!0,c.close(i[2]);return}case"NOTICE":this.onnotice(i[1]);return;case"AUTH":{this.challenge=i[1],(o=this._onauth)==null||o.call(this,i[1]);return}}}catch{return}}async send(t){if(!this.connectionPromise)throw new Error("sending on closed connection");this.connectionPromise.then(()=>{var e;(e=this.ws)==null||e.send(t)})}async auth(t){if(!this.challenge)throw new Error("can't perform auth, no challenge was received");const e=await t(ra(this.url,this.challenge)),n=new Promise((r,o)=>{this.openEventPublishes.set(e.id,{resolve:r,reject:o})});return this.send('["AUTH",'+JSON.stringify(e)+"]"),n}async publish(t){const e=new Promise((n,r)=>{this.openEventPublishes.set(t.id,{resolve:n,reject:r})});return this.send('["EVENT",'+JSON.stringify(t)+"]"),e}async count(t,e){this.serial++;const n=(e==null?void 0:e.id)||"count:"+this.serial,r=new Promise((o,i)=>{this.openCountRequests.set(n,{resolve:o,reject:i})});return this.send('["COUNT","'+n+'",'+JSON.stringify(t).substring(1)),r}subscribe(t,e){const n=this.prepareSubscription(t,e);return n.fire(),n}prepareSubscription(t,e){this.serial++;const n=e.id||"sub:"+this.serial,r=new sa(this,n,t,e);return this.openSubs.set(n,r),r}close(){var t;this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,(t=this.ws)==null||t.close()}_onmessage(t){this.incomingMessageQueue.enqueue(t.data),this.queueRunning||this.runQueue()}},sa=class{constructor(t,e,n,r){B(this,"relay");B(this,"id");B(this,"closed",!1);B(this,"eosed",!1);B(this,"filters");B(this,"alreadyHaveEvent");B(this,"receivedEvent");B(this,"onevent");B(this,"oneose");B(this,"onclose");B(this,"eoseTimeout");B(this,"eoseTimeoutHandle");this.relay=t,this.filters=n,this.id=e,this.alreadyHaveEvent=r.alreadyHaveEvent,this.receivedEvent=r.receivedEvent,this.eoseTimeout=r.eoseTimeout||t.baseEoseTimeout,this.oneose=r.oneose,this.onclose=r.onclose,this.onevent=r.onevent||(o=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,o)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){var t;this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,(t=this.oneose)==null||t.call(this))}close(t="closed by caller"){var e;!this.closed&&this.relay.connected&&(this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]"),this.closed=!0),this.relay.openSubs.delete(this.id),(e=this.onclose)==null||e.call(this,t)}},ca=class{constructor(t){B(this,"relays",new Map);B(this,"seenOn",new Map);B(this,"trackRelays",!1);B(this,"verifyEvent");B(this,"trustedRelayURLs",new Set);B(this,"_WebSocket");this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation}async ensureRelay(t,e){t=At(t);let n=this.relays.get(t);return n||(n=new Eo(t,{verifyEvent:this.trustedRelayURLs.has(t)?ia:this.verifyEvent,websocketImplementation:this._WebSocket}),e!=null&&e.connectionTimeout&&(n.connectionTimeout=e.connectionTimeout),this.relays.set(t,n)),await n.connect(),n}close(t){t.map(At).forEach(e=>{var n;(n=this.relays.get(e))==null||n.close()})}subscribeMany(t,e,n){return this.subscribeManyMap(Object.fromEntries(t.map(r=>[r,e])),n)}subscribeManyMap(t,e){this.trackRelays&&(e.receivedEvent=(u,b)=>{let h=this.seenOn.get(b);h||(h=new Set,this.seenOn.set(b,h)),h.add(u)});const n=new Set,r=[],o=Object.keys(t).length,i=[];let s=u=>{var b;i[u]=!0,i.filter(h=>h).length===o&&((b=e.oneose)==null||b.call(e),s=()=>{})};const c=[];let a=(u,b)=>{var h;s(u),c[u]=b,c.filter(g=>g).length===o&&((h=e.onclose)==null||h.call(e,c),a=()=>{})};const l=u=>{var h;if((h=e.alreadyHaveEvent)!=null&&h.call(e,u))return!0;const b=n.has(u);return n.add(u),b},f=Promise.all(Object.entries(t).map(async(u,b,h)=>{if(h.indexOf(u)!==b){a(b,"duplicate url");return}let[g,d]=u;g=At(g);let p;try{p=await this.ensureRelay(g,{connectionTimeout:e.maxWait?Math.max(e.maxWait*.8,e.maxWait-1e3):void 0})}catch(m){a(b,(m==null?void 0:m.message)||String(m));return}let w=p.subscribe(d,{...e,oneose:()=>s(b),onclose:m=>a(b,m),alreadyHaveEvent:l,eoseTimeout:e.maxWait});r.push(w)}));return{async close(){await f,r.forEach(u=>{u.close()})}}}subscribeManyEose(t,e,n){const r=this.subscribeMany(t,e,{...n,oneose(){r.close()}});return r}async querySync(t,e,n){return new Promise(async r=>{const o=[];this.subscribeManyEose(t,[e],{...n,onevent(i){o.push(i)},onclose(i){r(o)}})})}async get(t,e,n){e.limit=1;const r=await this.querySync(t,e,n);return r.sort((o,i)=>i.created_at-o.created_at),r[0]||null}publish(t,e){return t.map(At).map(async(n,r,o)=>{if(o.indexOf(n)!==r)return Promise.reject("duplicate url");let i=await this.ensureRelay(n);return i.publish(e).then(s=>{if(this.trackRelays){let c=this.seenOn.get(e.id);c||(c=new Set,this.seenOn.set(e.id,c)),c.add(i)}return s})})}listConnectionStatus(){const t=new Map;return this.relays.forEach((e,n)=>t.set(n,e.connected)),t}destroy(){this.relays.forEach(t=>t.close()),this.relays=new Map}},_o;try{_o=WebSocket}catch{}var aa=class extends ca{constructor(){super({verifyEvent:vo,websocketImplementation:_o})}},ko;try{ko=fetch}catch{}var Qt=/^bunker:\/\/([0-9a-f]{64})\??([?\/\w:.=&%-]*)$/,la=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;async function So(t){let e=t.match(Qt);if(e)try{const n=e[1],r=new URLSearchParams(e[2]);return{pubkey:n,relays:r.getAll("relay"),secret:r.get("secret")}}catch{}return Ao(t)}async function Ao(t){const e=t.match(Yc);if(!e)return null;const[n,r="_",o]=e;try{const i=`https://${o}/.well-known/nostr.json?name=${r}`,s=await(await ko(i,{redirect:"error"})).json();let c=s.names[r],a=s.nip46[c]||[];return{pubkey:c,relays:a,secret:null}}catch{return null}}var Bo=class{constructor(t,e,n={}){B(this,"pool");B(this,"subCloser");B(this,"isOpen");B(this,"serial");B(this,"idPrefix");B(this,"listeners");B(this,"waitingForAuth");B(this,"secretKey");B(this,"bp");B(this,"cachedPubKey");if(e.relays.length===0)throw new Error("no relays are specified for this bunker");this.pool=n.pool||new aa,this.secretKey=t,this.bp=e,this.isOpen=!1,this.idPrefix=Math.random().toString(36).substring(7),this.serial=0,this.listeners={},this.waitingForAuth={};const r=this.listeners,o=this.waitingForAuth,i=this.secretKey;this.subCloser=this.pool.subscribeMany(this.bp.relays,[{kinds:[Qn],"#p":[Rc(this.secretKey)]}],{async onevent(s){let c;try{c=JSON.parse(await jc(t,s.pubkey,s.content))}catch{c=JSON.parse(Gc(s.content,Kc(i,s.pubkey)))}const{id:a,result:l,error:f}=c;if(l==="auth_url"&&o[a]){delete o[a],n.onauth?n.onauth(f):console.warn(`nostr-tools/nip46: remote signer ${e.pubkey} tried to send an "auth_url"='${f}' but there was no onauth() callback configured.`);return}let u=r[a];u&&(f?u.reject(f):l&&u.resolve(l),delete r[a])}}),this.isOpen=!0}async close(){this.isOpen=!1,this.subCloser.close()}async sendRequest(t,e){return new Promise(async(n,r)=>{try{if(!this.isOpen)throw new Error("this signer is not open anymore, create a new one");this.serial++;const o=`${this.idPrefix}-${this.serial}`,i=await Mc(this.secretKey,this.bp.pubkey,JSON.stringify({id:o,method:t,params:e})),s=Hc({kind:Qn,tags:[["p",this.bp.pubkey]],content:i,created_at:Math.floor(Date.now()/1e3)},this.secretKey);this.listeners[o]={resolve:n,reject:r},this.waitingForAuth[o]=!0,await Promise.any(this.pool.publish(this.bp.relays,s))}catch(o){r(o)}})}async ping(){let t=await this.sendRequest("ping",[]);if(t!=="pong")throw new Error(`result is not pong: ${t}`)}async connect(){await this.sendRequest("connect",[this.bp.pubkey,this.bp.secret||""])}async getPublicKey(){return this.cachedPubKey||(this.cachedPubKey=await this.sendRequest("get_public_key",[])),this.cachedPubKey}async getRelays(){return JSON.parse(await this.sendRequest("get_relays",[]))}async signEvent(t){let e=await this.sendRequest("sign_event",[JSON.stringify(t)]),n=JSON.parse(e);if(n.pubkey===this.bp.pubkey&&vo(n))return n;throw new Error(`event returned from bunker is improperly signed: ${JSON.stringify(n)}`)}async nip04Encrypt(t,e){return await this.sendRequest("nip04_encrypt",[t,e])}async nip04Decrypt(t,e){return await this.sendRequest("nip04_decrypt",[t,e])}async nip44GetKey(t){let e=await this.sendRequest("nip44_get_key",[t]);return pn(e)}async nip44Encrypt(t,e){return await this.sendRequest("nip44_encrypt",[t,e])}async nip44Decrypt(t,e){return await this.sendRequest("nip44_decrypt",[t,e])}};async function ua(t,e,n,r,o,i=Pc()){if(o&&!la.test(o))throw new Error("Invalid email");let s=new Bo(i,t.bunkerPointer,e),c=await s.sendRequest("create_account",[n,r,o||""]);return s.bp.pubkey=c,await s.connect(),s}async function fa(t,e){const n=await t.querySync(e,{kinds:[Qc],"#k":[Qn.toString()]});return n.sort((o,i)=>i.created_at-o.created_at),(await Promise.all(n.map(async(o,i)=>{try{const s=JSON.parse(o.content);try{if(n.findIndex(a=>JSON.parse(a.content).nip05===s.nip05)!==i)return}catch{}const c=await Ao(s.nip05);if(c&&c.pubkey===o.pubkey&&c.relays.length)return{bunkerPointer:c,nip05:s.nip05,domain:s.nip05.split("@")[1],name:s.name||s.display_name,picture:s.picture,about:s.about,website:s.website,local:!1}}catch{return}}))).filter(o=>o!==void 0)}var Io=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,Oo;try{Oo=fetch}catch{}async function da(t){var i;const e=t.match(Io);if(!e)return null;const[n,r="_",o]=e;try{const s=`https://${o}/.well-known/nostr.json?name=${r}`,c=await(await Oo(s,{redirect:"error"})).json();let a=c.names[r];return a?{pubkey:a,relays:(i=c.relays)==null?void 0:i[a]}:null}catch{return null}}new TextDecoder("utf-8"),new TextEncoder;var ha=5e3;function ga(t){return ba("npub",pn(t))}function pa(t,e){let n=ho.toWords(e);return ho.encode(t,n,ha)}function ba(t,e){return pa(t,e)}const wt=[];function wa(t,e=j){let n;const r=new Set;function o(c){if(rn(t,c)&&(t=c,n)){const a=!wt.length;for(const l of r)l[1](),wt.push(l,t);if(a){for(let l=0;l<wt.length;l+=2)wt[l][0](wt[l+1]);wt.length=0}}}function i(c){o(c(t))}function s(c,a=j){const l=[c,a];return r.add(l),r.size===1&&(n=e(o,i)||j),c(t),()=>{r.delete(l),r.size===0&&n&&(n(),n=null)}}return{set:o,update:i,subscribe:s}}const ya=t=>{const{subscribe:e,set:n}=wa(void 0,()=>{const r=window.matchMedia(t);n(r.matches);const o=()=>n(r.matches);return r.addEventListener("change",o),()=>{r.removeEventListener("change",o)}});return{subscribe:e}};function ma(t){let e,n,r;return{c(){e=on("svg"),n=on("circle"),r=on("path"),k(n,"class","opacity-25"),k(n,"cx","12"),k(n,"cy","12"),k(n,"r","10"),k(n,"stroke","currentColor"),k(n,"stroke-width","4"),k(r,"class","opacity-75"),k(r,"fill","currentColor"),k(r,"d","M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"),k(e,"class","ml-2 h-5 w-5 animate-spin text-white"),k(e,"xmlns","http://www.w3.org/2000/svg"),k(e,"fill","none"),k(e,"viewBox","0 0 24 24")},m(o,i){K(o,e,i),O(e,n),O(e,r)},p:j,i:j,o:j,d(o){o&&z(e)}}}class No extends dr{constructor(e){super(),fr(this,e,null,ma,rn,{})}}const{window:Xn}=ei;function Lo(t,e,n){const r=t.slice();return r[82]=e[n],r}function va(t){let e,n,r,o,i,s,c,a,l,f,u,b,h=!t[22]&&!t[15]&&!t[16]&&!t[17]&&To(t);const g=[Oa,Ia,Ba,Aa,Sa,ka,_a],d=[];function p(w,m){return w[15]?0:w[16]?1:w[17]?2:w[22]?3:w[19]?4:w[23]?6:5}return c=p(t),a=d[c]=g[c](t),{c(){e=P("div"),n=P("button"),r=F("⤫"),i=Y(),h&&h.c(),s=Y(),a.c(),k(n,"class",o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+t[0]+"-600"),k(e,"class",l="animate-show rounded-md bg-gradient-to-b px-8 py-8 shadow-[0_0px_30px_0px_rgba(0,0,0,0.6)] transition-all sm:w-96 from-"+t[0]+"-900 to-"+t[0]+"-700 "+t[29])},m(w,m){K(w,e,m),O(e,n),O(n,r),O(e,i),h&&h.m(e,null),O(e,s),d[c].m(e,null),f=!0,u||(b=ne(n,"click",function(){nn(t[22]?t[35]:t[33])&&(t[22]?t[35]:t[33]).apply(this,arguments)}),u=!0)},p(w,m){t=w,(!f||m[0]&1&&o!==(o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+t[0]+"-600"))&&k(n,"class",o),!t[22]&&!t[15]&&!t[16]&&!t[17]?h?h.p(t,m):(h=To(t),h.c(),h.m(e,s)):h&&(h.d(1),h=null);let S=c;c=p(t),c===S?d[c].p(t,m):(Pt(),xe(d[S],1,1,()=>{d[S]=null}),Rt(),a=d[c],a?a.p(t,m):(a=d[c]=g[c](t),a.c()),me(a,1),a.m(e,null)),(!f||m[0]&536870913&&l!==(l="animate-show rounded-md bg-gradient-to-b px-8 py-8 shadow-[0_0px_30px_0px_rgba(0,0,0,0.6)] transition-all sm:w-96 from-"+t[0]+"-900 to-"+t[0]+"-700 "+t[29]))&&k(e,"class",l)},i(w){f||(me(a),f=!0)},o(w){xe(a),f=!1},d(w){w&&z(e),h&&h.d(),d[c].d(),u=!1,b()}}}function xa(t){let e,n,r,o,i;const s=[Pa,Ua,Ca,Ta],c=[];function a(l,f){return l[14]?0:l[23]?l[2]?3:2:1}return n=a(t),r=c[n]=s[n](t),{c(){e=P("div"),r.c(),k(e,"class",o="rounded px-2 py-2 shadow-[0_0px_10px_0px_rgba(0,0,0,0.3)] transition-all duration-200 bg-"+t[0]+"-700 hover:bg-"+t[0]+"-800 "+t[29])},m(l,f){K(l,e,f),c[n].m(e,null),i=!0},p(l,f){let u=n;n=a(l),n===u?c[n].p(l,f):(Pt(),xe(c[u],1,1,()=>{c[u]=null}),Rt(),r=c[n],r?r.p(l,f):(r=c[n]=s[n](l),r.c()),me(r,1),r.m(e,null)),(!i||f[0]&536870913&&o!==(o="rounded px-2 py-2 shadow-[0_0px_10px_0px_rgba(0,0,0,0.3)] transition-all duration-200 bg-"+l[0]+"-700 hover:bg-"+l[0]+"-800 "+l[29]))&&k(e,"class",o)},i(l){i||(me(r),i=!0)},o(l){xe(r),i=!1},d(l){l&&z(e),c[n].d()}}}function Ea(t){return{c:j,m:j,p:j,i:j,o:j,d:j}}function To(t){let e,n,r,o,i;return{c(){e=P("button"),n=F("?"),k(e,"class",r="absolute bottom-1 right-3 cursor-pointer bg-transparent text-xl text-"+t[0]+"-600")},m(s,c){K(s,e,c),O(e,n),o||(i=ne(e,"click",t[34]),o=!0)},p(s,c){c[0]&1&&r!==(r="absolute bottom-1 right-3 cursor-pointer bg-transparent text-xl text-"+s[0]+"-600")&&k(e,"class",r)},d(s){s&&z(e),o=!1,i()}}}function _a(t){let e,n,r,o,i,s,c=t[23].npub+"",a,l,f,u,b,h,g,d,p,w,m,S=Dr(t[13])+"",T,R,_,x=(t[23].picture||t[23].name)&&Co(t);return{c(){e=P("div"),n=P("div"),n.textContent="You are connected to Nostr as",r=Y(),o=P("a"),x&&x.c(),i=Y(),s=P("div"),a=F(c),f=Y(),u=P("button"),b=F("Disconnect"),g=Y(),d=P("div"),p=F("This webpage is using the public key:"),w=P("br"),m=Y(),T=F(S),k(n,"class","mb-4 text-sm"),k(s,"class","block break-all"),k(o,"target","_blank"),k(o,"href",l="https://nosta.me/"+t[23].npub),k(o,"class","group text-white no-underline"),k(e,"class","text-center"),k(u,"class",h="my-2 mt-6 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),k(d,"class","mt-6 block break-all text-center text-sm")},m(y,E){K(y,e,E),O(e,n),O(e,r),O(e,o),x&&x.m(o,null),O(o,i),O(o,s),O(s,a),K(y,f,E),K(y,u,E),O(u,b),K(y,g,E),K(y,d,E),O(d,p),O(d,w),O(d,m),O(d,T),R||(_=ne(u,"click",t[37]),R=!0)},p(y,E){y[23].picture||y[23].name?x?x.p(y,E):(x=Co(y),x.c(),x.m(o,i)):x&&(x.d(1),x=null),E[0]&8388608&&c!==(c=y[23].npub+"")&&He(a,c),E[0]&8388608&&l!==(l="https://nosta.me/"+y[23].npub)&&k(o,"href",l),E[0]&1&&h!==(h="my-2 mt-6 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white bg-"+y[0]+"-900 hover:bg-"+y[0]+"-950")&&k(u,"class",h),E[0]&8192&&S!==(S=Dr(y[13])+"")&&He(T,S)},i:j,o:j,d(y){y&&(z(e),z(f),z(u),z(g),z(d)),x&&x.d(),R=!1,_()}}}function ka(t){let e,n,r,o,i,s,c,a,l,f,u,b,h,g,d,p,w,m=t[21]&&Ro(t);const S=[La,Na],T=[];function R(y,E){return y[14]?0:1}a=R(t),l=T[a]=S[a](t);let _=t[14]&&t[18]&&Ho(t),x=!t[14]&&Mo(t);return{c(){e=P("div"),e.textContent="How do you want to connect to Nostr?",n=Y(),r=P("form"),o=P("input"),i=Y(),m&&m.c(),s=Y(),c=P("button"),l.c(),b=Y(),_&&_.c(),h=Y(),x&&x.c(),g=sn(),k(e,"class","text-center text-lg"),k(o,"class","box-border w-full rounded px-2 py-1 text-lg text-neutral-800 outline-none"),k(o,"placeholder","user@provider or bunker://..."),o.autofocus=!0,o.disabled=t[14],k(o,"autocapitalize","none"),k(c,"class",f="mt-4 flex w-full cursor-pointer items-center justify-center rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),c.disabled=u=!t[28]||t[14],k(r,"class","mb-1 mt-4 flex flex-col")},m(y,E){K(y,e,E),K(y,n,E),K(y,r,E),O(r,o),t[55](o),rt(o,t[4]),O(r,i),m&&m.m(r,null),O(r,s),O(r,c),T[a].m(c,null),O(r,b),_&&_.m(r,null),K(y,h,E),x&&x.m(y,E),K(y,g,E),d=!0,o.focus(),p||(w=[ne(o,"input",t[56]),ne(r,"submit",t[36])],p=!0)},p(y,E){(!d||E[0]&16384)&&(o.disabled=y[14]),E[0]&16&&o.value!==y[4]&&rt(o,y[4]),y[21]?m?m.p(y,E):(m=Ro(y),m.c(),m.m(r,s)):m&&(m.d(1),m=null);let U=a;a=R(y),a!==U&&(Pt(),xe(T[U],1,1,()=>{T[U]=null}),Rt(),l=T[a],l||(l=T[a]=S[a](y),l.c()),me(l,1),l.m(c,null)),(!d||E[0]&1&&f!==(f="mt-4 flex w-full cursor-pointer items-center justify-center rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+y[0]+"-900 hover:bg-"+y[0]+"-950"))&&k(c,"class",f),(!d||E[0]&268451840&&u!==(u=!y[28]||y[14]))&&(c.disabled=u),y[14]&&y[18]?_?_.p(y,E):(_=Ho(y),_.c(),_.m(r,null)):_&&(_.d(1),_=null),y[14]?x&&(x.d(1),x=null):x?x.p(y,E):(x=Mo(y),x.c(),x.m(g.parentNode,g))},i(y){d||(me(l),d=!0)},o(y){xe(l),d=!1},d(y){y&&(z(e),z(n),z(r),z(h),z(g)),t[55](null),m&&m.d(),T[a].d(),_&&_.d(),x&&x.d(y),p=!1,Re(w)}}}function Sa(t){let e,n,r,o,i,s,c,a,l,f,u,b,h,g,d,p,w,m,S,T,R,_,x=lr(t[24]),y=[];for(let E=0;E<x.length;E+=1)y[E]=jo(Lo(t,x,E));return{c(){e=P("div"),e.textContent="Create a Nostr account",n=Y(),r=P("form"),o=P("div"),i=P("input"),s=Y(),c=P("div"),c.textContent="@",a=Y(),l=P("select");for(let E=0;E<y.length;E+=1)y[E].c();f=Y(),u=P("button"),b=F("Continue »"),d=Y(),p=P("div"),w=F("Do you already have a Nostr address?"),m=P("br"),S=Y(),T=P("button"),T.textContent="Login now",k(e,"class","text-center text-lg"),k(i,"class","box-border w-40 rounded px-2 py-1 text-lg text-neutral-800 outline-none"),k(i,"placeholder","bob"),i.autofocus=!0,k(i,"autocapitalize","none"),k(c,"class","mx-2 text-2xl"),k(l,"class","box-border w-full rounded px-2 py-1 text-lg text-neutral-800 outline-none"),t[12]===void 0&&Ct(()=>t[54].call(l)),k(o,"class","flex flex-row"),k(u,"class",h="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),u.disabled=g=!t[12]||!t[11]||t[20],k(r,"class","mb-1 mt-4"),k(T,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),k(p,"class","mt-6 text-center text-sm leading-3")},m(E,U){K(E,e,U),K(E,n,U),K(E,r,U),O(r,o),O(o,i),t[52](i),rt(i,t[11]),O(o,s),O(o,c),O(o,a),O(o,l);for(let N=0;N<y.length;N+=1)y[N]&&y[N].m(l,null);ir(l,t[12],!0),O(r,f),O(r,u),O(u,b),K(E,d,U),K(E,p,U),O(p,w),O(p,m),O(p,S),O(p,T),i.focus(),R||(_=[ne(i,"input",t[53]),ne(i,"input",t[41]),ne(l,"change",t[54]),ne(r,"submit",t[40]),ne(T,"click",t[39])],R=!0)},p(E,U){if(U[0]&2048&&i.value!==E[11]&&rt(i,E[11]),U[0]&16777216){x=lr(E[24]);let N;for(N=0;N<x.length;N+=1){const M=Lo(E,x,N);y[N]?y[N].p(M,U):(y[N]=jo(M),y[N].c(),y[N].m(l,null))}for(;N<y.length;N+=1)y[N].d(1);y.length=x.length}U[0]&16781312&&ir(l,E[12]),U[0]&1&&h!==(h="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+E[0]+"-900 hover:bg-"+E[0]+"-950")&&k(u,"class",h),U[0]&17831936&&g!==(g=!E[12]||!E[11]||E[20])&&(u.disabled=g)},i:j,o:j,d(E){E&&(z(e),z(n),z(r),z(d),z(p)),t[52](null),ti(y,E),R=!1,Re(_)}}}function Aa(t){let e,n,r;return{c(){e=P("div"),e.textContent="What is that?",n=Y(),r=P("div"),r.innerHTML=`<p class="mb mt-4">This widget is created with <i>window.nostr.js</i>, a small script
1
+ var Va=Object.defineProperty;var Fa=(Ke,H,$e)=>H in Ke?Va(Ke,H,{enumerable:!0,configurable:!0,writable:!0,value:$e}):Ke[H]=$e;var E=(Ke,H,$e)=>Fa(Ke,typeof H!="symbol"?H+"":H,$e);(function(){"use strict";var No,To,Co,Po,Lo;const Ke='*,:before,:after{--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-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(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;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::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-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(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;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;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,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color: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,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.fixed{position:fixed}.absolute{position:absolute}.bottom-1{bottom:.25rem}.right-2{right:.5rem}.right-3{right:.75rem}.top-0{top:0}.m-auto{margin:auto}.mx-2{margin-left:.5rem;margin-right:.5rem}.my-2{margin-top:.5rem;margin-bottom:.5rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-4{margin-bottom:1rem}.ml-2{margin-left:.5rem}.mr-2{margin-right:.5rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.box-border{box-sizing:border-box}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.h-10{height:2.5rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.w-10{width:2.5rem}.w-40{width:10rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-full{width:100%}.max-w-56{max-width:14rem}@keyframes moveIn{0%{transform:translateY(-10px)}to{transform:translateY(0)}}.animate-fadein{animation:fadeIn 1s ease-in-out,moveIn 1s ease-in-out}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.animate-show{animation:fadeIn .2s ease-in-out}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-grabbing{cursor:grabbing}.cursor-pointer{cursor:pointer}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:.5rem}.overflow-hidden{overflow:hidden}.overflow-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-md{border-radius:.375rem}.border-0{border-width:0px}.border-2{border-width:2px}.border-solid{border-style:solid}.border-transparent{border-color:transparent}.bg-cyan-700{--tw-bg-opacity: 1;background-color:rgb(14 116 144 / var(--tw-bg-opacity))}.bg-cyan-800{--tw-bg-opacity: 1;background-color:rgb(21 94 117 / var(--tw-bg-opacity))}.bg-cyan-900{--tw-bg-opacity: 1;background-color:rgb(22 78 99 / var(--tw-bg-opacity))}.bg-cyan-950{--tw-bg-opacity: 1;background-color:rgb(8 51 68 / var(--tw-bg-opacity))}.bg-green-700{--tw-bg-opacity: 1;background-color:rgb(21 128 61 / var(--tw-bg-opacity))}.bg-green-800{--tw-bg-opacity: 1;background-color:rgb(22 101 52 / var(--tw-bg-opacity))}.bg-green-900{--tw-bg-opacity: 1;background-color:rgb(20 83 45 / var(--tw-bg-opacity))}.bg-green-950{--tw-bg-opacity: 1;background-color:rgb(5 46 22 / var(--tw-bg-opacity))}.bg-neutral-700{--tw-bg-opacity: 1;background-color:rgb(64 64 64 / var(--tw-bg-opacity))}.bg-neutral-800{--tw-bg-opacity: 1;background-color:rgb(38 38 38 / var(--tw-bg-opacity))}.bg-neutral-900{--tw-bg-opacity: 1;background-color:rgb(23 23 23 / var(--tw-bg-opacity))}.bg-neutral-950{--tw-bg-opacity: 1;background-color:rgb(10 10 10 / var(--tw-bg-opacity))}.bg-orange-700{--tw-bg-opacity: 1;background-color:rgb(194 65 12 / var(--tw-bg-opacity))}.bg-orange-800{--tw-bg-opacity: 1;background-color:rgb(154 52 18 / var(--tw-bg-opacity))}.bg-orange-900{--tw-bg-opacity: 1;background-color:rgb(124 45 18 / var(--tw-bg-opacity))}.bg-orange-950{--tw-bg-opacity: 1;background-color:rgb(67 20 7 / var(--tw-bg-opacity))}.bg-purple-700{--tw-bg-opacity: 1;background-color:rgb(126 34 206 / var(--tw-bg-opacity))}.bg-purple-800{--tw-bg-opacity: 1;background-color:rgb(107 33 168 / var(--tw-bg-opacity))}.bg-purple-900{--tw-bg-opacity: 1;background-color:rgb(88 28 135 / var(--tw-bg-opacity))}.bg-purple-950{--tw-bg-opacity: 1;background-color:rgb(59 7 100 / var(--tw-bg-opacity))}.bg-red-700{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity))}.bg-red-800{--tw-bg-opacity: 1;background-color:rgb(153 27 27 / var(--tw-bg-opacity))}.bg-red-900{--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity))}.bg-red-950{--tw-bg-opacity: 1;background-color:rgb(69 10 10 / var(--tw-bg-opacity))}.bg-stone-700{--tw-bg-opacity: 1;background-color:rgb(68 64 60 / var(--tw-bg-opacity))}.bg-stone-800{--tw-bg-opacity: 1;background-color:rgb(41 37 36 / var(--tw-bg-opacity))}.bg-stone-900{--tw-bg-opacity: 1;background-color:rgb(28 25 23 / var(--tw-bg-opacity))}.bg-stone-950{--tw-bg-opacity: 1;background-color:rgb(12 10 9 / var(--tw-bg-opacity))}.bg-transparent{background-color:transparent}.bg-yellow-100{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity))}.bg-gradient-to-b{background-image:linear-gradient(to bottom,var(--tw-gradient-stops))}.from-cyan-900{--tw-gradient-from: #164e63 var(--tw-gradient-from-position);--tw-gradient-to: rgb(22 78 99 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-green-900{--tw-gradient-from: #14532d var(--tw-gradient-from-position);--tw-gradient-to: rgb(20 83 45 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-neutral-900{--tw-gradient-from: #171717 var(--tw-gradient-from-position);--tw-gradient-to: rgb(23 23 23 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-orange-900{--tw-gradient-from: #7c2d12 var(--tw-gradient-from-position);--tw-gradient-to: rgb(124 45 18 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-purple-900{--tw-gradient-from: #581c87 var(--tw-gradient-from-position);--tw-gradient-to: rgb(88 28 135 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-red-900{--tw-gradient-from: #7f1d1d var(--tw-gradient-from-position);--tw-gradient-to: rgb(127 29 29 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-stone-900{--tw-gradient-from: #1c1917 var(--tw-gradient-from-position);--tw-gradient-to: rgb(28 25 23 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.to-cyan-700{--tw-gradient-to: #0e7490 var(--tw-gradient-to-position)}.to-green-700{--tw-gradient-to: #15803d var(--tw-gradient-to-position)}.to-neutral-700{--tw-gradient-to: #404040 var(--tw-gradient-to-position)}.to-orange-700{--tw-gradient-to: #c2410c var(--tw-gradient-to-position)}.to-purple-700{--tw-gradient-to: #7e22ce var(--tw-gradient-to-position)}.to-red-700{--tw-gradient-to: #b91c1c var(--tw-gradient-to-position)}.to-stone-700{--tw-gradient-to: #44403c var(--tw-gradient-to-position)}.p-2{padding:.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.text-center{text-align:center}.font-sans{font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji"}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.leading-3{line-height:.75rem}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.text-cyan-600{--tw-text-opacity: 1;color:rgb(8 145 178 / var(--tw-text-opacity))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity))}.text-neutral-600{--tw-text-opacity: 1;color:rgb(82 82 82 / var(--tw-text-opacity))}.text-neutral-800{--tw-text-opacity: 1;color:rgb(38 38 38 / var(--tw-text-opacity))}.text-orange-600{--tw-text-opacity: 1;color:rgb(234 88 12 / var(--tw-text-opacity))}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity))}.text-stone-600{--tw-text-opacity: 1;color:rgb(87 83 78 / var(--tw-text-opacity))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.underline{text-decoration-line:underline}.no-underline{text-decoration-line:none}.decoration-2{text-decoration-thickness:2px}.underline-offset-4{text-underline-offset:4px}.opacity-25{opacity:.25}.opacity-75{opacity:.75}.shadow-\\[0_0px_10px_0px_rgba\\(0\\,0\\,0\\,0\\.3\\)\\]{--tw-shadow: 0 0px 10px 0px rgba(0,0,0,.3);--tw-shadow-colored: 0 0px 10px 0px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\\[0_0px_30px_0px_rgba\\(0\\,0\\,0\\,0\\.6\\)\\]{--tw-shadow: 0 0px 30px 0px rgba(0,0,0,.6);--tw-shadow-colored: 0 0px 30px 0px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline-dashed{outline-style:dashed}.outline-1{outline-width:1px}.outline-offset-4{outline-offset:4px}.outline-cyan-500{outline-color:#06b6d4}.outline-green-500{outline-color:#22c55e}.outline-neutral-500{outline-color:#737373}.outline-orange-500{outline-color:#f97316}.outline-purple-500{outline-color:#a855f7}.outline-red-500{outline-color:#ef4444}.outline-stone-500{outline-color:#78716c}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.hover\\:bg-cyan-700:hover{--tw-bg-opacity: 1;background-color:rgb(14 116 144 / var(--tw-bg-opacity))}.hover\\:bg-cyan-800:hover{--tw-bg-opacity: 1;background-color:rgb(21 94 117 / var(--tw-bg-opacity))}.hover\\:bg-cyan-900:hover{--tw-bg-opacity: 1;background-color:rgb(22 78 99 / var(--tw-bg-opacity))}.hover\\:bg-cyan-950:hover{--tw-bg-opacity: 1;background-color:rgb(8 51 68 / var(--tw-bg-opacity))}.hover\\:bg-green-700:hover{--tw-bg-opacity: 1;background-color:rgb(21 128 61 / var(--tw-bg-opacity))}.hover\\:bg-green-800:hover{--tw-bg-opacity: 1;background-color:rgb(22 101 52 / var(--tw-bg-opacity))}.hover\\:bg-green-900:hover{--tw-bg-opacity: 1;background-color:rgb(20 83 45 / var(--tw-bg-opacity))}.hover\\:bg-green-950:hover{--tw-bg-opacity: 1;background-color:rgb(5 46 22 / var(--tw-bg-opacity))}.hover\\:bg-neutral-700:hover{--tw-bg-opacity: 1;background-color:rgb(64 64 64 / var(--tw-bg-opacity))}.hover\\:bg-neutral-800:hover{--tw-bg-opacity: 1;background-color:rgb(38 38 38 / var(--tw-bg-opacity))}.hover\\:bg-neutral-900:hover{--tw-bg-opacity: 1;background-color:rgb(23 23 23 / var(--tw-bg-opacity))}.hover\\:bg-neutral-950:hover{--tw-bg-opacity: 1;background-color:rgb(10 10 10 / var(--tw-bg-opacity))}.hover\\:bg-orange-700:hover{--tw-bg-opacity: 1;background-color:rgb(194 65 12 / var(--tw-bg-opacity))}.hover\\:bg-orange-800:hover{--tw-bg-opacity: 1;background-color:rgb(154 52 18 / var(--tw-bg-opacity))}.hover\\:bg-orange-900:hover{--tw-bg-opacity: 1;background-color:rgb(124 45 18 / var(--tw-bg-opacity))}.hover\\:bg-orange-950:hover{--tw-bg-opacity: 1;background-color:rgb(67 20 7 / var(--tw-bg-opacity))}.hover\\:bg-purple-700:hover{--tw-bg-opacity: 1;background-color:rgb(126 34 206 / var(--tw-bg-opacity))}.hover\\:bg-purple-800:hover{--tw-bg-opacity: 1;background-color:rgb(107 33 168 / var(--tw-bg-opacity))}.hover\\:bg-purple-900:hover{--tw-bg-opacity: 1;background-color:rgb(88 28 135 / var(--tw-bg-opacity))}.hover\\:bg-purple-950:hover{--tw-bg-opacity: 1;background-color:rgb(59 7 100 / var(--tw-bg-opacity))}.hover\\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity))}.hover\\:bg-red-800:hover{--tw-bg-opacity: 1;background-color:rgb(153 27 27 / var(--tw-bg-opacity))}.hover\\:bg-red-900:hover{--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity))}.hover\\:bg-red-950:hover{--tw-bg-opacity: 1;background-color:rgb(69 10 10 / var(--tw-bg-opacity))}.hover\\:bg-stone-700:hover{--tw-bg-opacity: 1;background-color:rgb(68 64 60 / var(--tw-bg-opacity))}.hover\\:bg-stone-800:hover{--tw-bg-opacity: 1;background-color:rgb(41 37 36 / var(--tw-bg-opacity))}.hover\\:bg-stone-900:hover{--tw-bg-opacity: 1;background-color:rgb(28 25 23 / var(--tw-bg-opacity))}.hover\\:bg-stone-950:hover{--tw-bg-opacity: 1;background-color:rgb(12 10 9 / var(--tw-bg-opacity))}.disabled\\:cursor-default:disabled{cursor:default}.disabled\\:bg-neutral-400:disabled{--tw-bg-opacity: 1;background-color:rgb(163 163 163 / var(--tw-bg-opacity))}.disabled\\:text-neutral-200:disabled{--tw-text-opacity: 1;color:rgb(229 229 229 / var(--tw-text-opacity))}.group:hover .group-hover\\:underline{text-decoration-line:underline}@media (min-width: 640px){.sm\\:w-96{width:24rem}}';function H(){}function $e(t){return t()}function Wn(){return Object.create(null)}function Ne(t){t.forEach($e)}function Vt(t){return typeof t=="function"}function Ft(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}let _t;function Qe(t,e){return t===e?!0:(_t||(_t=document.createElement("a")),_t.href=e,t===_t.href)}function Ro(t){return Object.keys(t).length===0}function Mo(t,...e){if(t==null){for(const r of e)r(void 0);return H}const n=t.subscribe(...e);return n.unsubscribe?()=>n.unsubscribe():n}function qo(t,e,n){t.$$.on_destroy.push(Mo(e,n))}const jo=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function B(t,e){t.appendChild(e)}function j(t,e,n){t.insertBefore(e,n||null)}function q(t){t.parentNode&&t.parentNode.removeChild(t)}function zo(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}function C(t){return document.createElement(t)}function Yt(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function V(t){return document.createTextNode(t)}function G(){return V(" ")}function Vn(){return V("")}function X(t,e,n,r){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n,r)}function x(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function Ko(t){return Array.from(t.childNodes)}function Te(t,e){e=""+e,t.data!==e&&(t.data=e)}function Xe(t,e){t.value=e??""}function Fn(t,e,n){for(let r=0;r<t.options.length;r+=1){const o=t.options[r];if(o.__value===e){o.selected=!0;return}}(!n||e!==void 0)&&(t.selectedIndex=-1)}function $o(t){const e=t.querySelector(":checked");return e&&e.__value}function Yn(t,e,n){t.classList.toggle(e,!!n)}let ht;function gt(t){ht=t}function Do(){if(!ht)throw new Error("Function called outside component initialization");return ht}function Wo(t){Do().$$.on_mount.push(t)}const et=[],pt=[];let tt=[];const Gn=[],Vo=Promise.resolve();let Gt=!1;function Fo(){Gt||(Gt=!0,Vo.then(Zn))}function kt(t){tt.push(t)}const Zt=new Set;let nt=0;function Zn(){if(nt!==0)return;const t=ht;do{try{for(;nt<et.length;){const e=et[nt];nt++,gt(e),Yo(e.$$)}}catch(e){throw et.length=0,nt=0,e}for(gt(null),et.length=0,nt=0;pt.length;)pt.pop()();for(let e=0;e<tt.length;e+=1){const n=tt[e];Zt.has(n)||(Zt.add(n),n())}tt.length=0}while(et.length);for(;Gn.length;)Gn.pop()();Gt=!1,Zt.clear(),gt(t)}function Yo(t){if(t.fragment!==null){t.update(),Ne(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(kt)}}function Go(t){const e=[],n=[];tt.forEach(r=>t.indexOf(r)===-1?e.push(r):n.push(r)),n.forEach(r=>r()),tt=e}const St=new Set;let De;function At(){De={r:0,c:[],p:De}}function Bt(){De.r||Ne(De.c),De=De.p}function de(t,e){t&&t.i&&(St.delete(t),t.i(e))}function be(t,e,n,r){if(t&&t.o){if(St.has(t))return;St.add(t),De.c.push(()=>{St.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}else r&&r()}function Jn(t){return(t==null?void 0:t.length)!==void 0?t:Array.from(t)}function Qn(t){t&&t.c()}function Jt(t,e,n){const{fragment:r,after_update:o}=t.$$;r&&r.m(e,n),kt(()=>{const i=t.$$.on_mount.map($e).filter(Vt);t.$$.on_destroy?t.$$.on_destroy.push(...i):Ne(i),t.$$.on_mount=[]}),o.forEach(kt)}function Qt(t,e){const n=t.$$;n.fragment!==null&&(Go(n.after_update),Ne(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Zo(t,e){t.$$.dirty[0]===-1&&(et.push(t),Fo(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function Xn(t,e,n,r,o,i,s=null,a=[-1]){const c=ht;gt(t);const l=t.$$={fragment:null,ctx:[],props:i,update:H,not_equal:o,bound:Wn(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(c?c.$$.context:[])),callbacks:Wn(),dirty:a,skip_bound:!1,root:e.target||c.$$.root};s&&s(l.root);let f=!1;if(l.ctx=n?n(t,e.props||{},(u,g,...h)=>{const b=h.length?h[0]:g;return l.ctx&&o(l.ctx[u],l.ctx[u]=b)&&(!l.skip_bound&&l.bound[u]&&l.bound[u](b),f&&Zo(t,u)),g}):[],l.update(),f=!0,Ne(l.before_update),l.fragment=r?r(l.ctx):!1,e.target){if(e.hydrate){const u=Ko(e.target);l.fragment&&l.fragment.l(u),u.forEach(q)}else l.fragment&&l.fragment.c();e.intro&&de(t.$$.fragment),Jt(t,e.target,e.anchor),Zn()}gt(c)}class er{constructor(){E(this,"$$");E(this,"$$set")}$destroy(){Qt(this,1),this.$destroy=H}$on(e,n){if(!Vt(n))return H;const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(n),()=>{const o=r.indexOf(n);o!==-1&&r.splice(o,1)}}$set(e){this.$$set&&!Ro(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Jo="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Jo);function Qo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Xt={exports:{}};function tr(t,e=100,n={}){if(typeof t!="function")throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);if(e<0)throw new RangeError("`wait` must not be negative.");const{immediate:r}=typeof n=="boolean"?{immediate:n}:n;let o,i,s,a,c;function l(){const u=Date.now()-a;if(u<e&&u>=0)s=setTimeout(l,e-u);else if(s=void 0,!r){const g=o,h=i;o=void 0,i=void 0,c=t.apply(g,h)}}const f=function(...u){if(o&&this!==o)throw new Error("Debounced method called with different contexts.");o=this,i=u,a=Date.now();const g=r&&!s;if(s||(s=setTimeout(l,e)),g){const h=o,b=i;o=void 0,i=void 0,c=t.apply(h,b)}return c};return f.clear=()=>{s&&(clearTimeout(s),s=void 0)},f.flush=()=>{if(!s)return;const u=o,g=i;o=void 0,i=void 0,c=t.apply(u,g),clearTimeout(s),s=void 0},f}Xt.exports.debounce=tr,Xt.exports=tr;var Xo=Xt.exports;const nr=Qo(Xo),en=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const tn=t=>t instanceof Uint8Array,nn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),we=(t,e)=>t<<32-e|t>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");const ei=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function oe(t){if(!tn(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=ei[t[n]];return e}function rn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const o=r*2,i=t.slice(o,o+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function ti(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function bt(t){if(typeof t=="string"&&(t=ti(t)),!tn(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function ni(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!tn(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}let rr=class{clone(){return this._cloneInto()}};function or(t){const e=r=>t().update(bt(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function ri(t=32){if(en&&typeof en.getRandomValues=="function")return en.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function ir(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function sr(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function oi(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ir(t.outputLen),ir(t.blockLen)}function It(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function ii(t,e){sr(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const on=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const cr=t=>t instanceof Uint8Array,sn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),ye=(t,e)=>t<<32-e|t>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function si(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function cn(t){if(typeof t=="string"&&(t=si(t)),!cr(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function ci(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!cr(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}class ar{clone(){return this._cloneInto()}}function ai(t){const e=r=>t().update(cn(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function lr(t=32){if(on&&typeof on.getRandomValues=="function")return on.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function li(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),c=r?4:0,l=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+l,a,r)}let ui=class extends ar{constructor(e,n,r,o){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=sn(this.buffer)}update(e){It(this);const{view:n,buffer:r,blockLen:o}=this;e=cn(e);const i=e.length;for(let s=0;s<i;){const a=Math.min(o-this.pos,i-s);if(a===o){const c=sn(e);for(;o<=i-s;s+=o)this.process(c,s);continue}r.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){It(this),ii(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(r,0),s=0);for(let u=s;u<o;u++)n[u]=0;li(r,o-8,BigInt(this.length*8),i),this.process(r,0);const a=sn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,f[u],i)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=s,o%n&&e.buffer.set(r),e}};const fi=(t,e,n)=>t&e^~t&n,di=(t,e,n)=>t&e^t&n^e&n,hi=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]),Ce=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pe=new Uint32Array(64);let gi=class extends ui{constructor(){super(64,32,8,!1),this.A=Ce[0]|0,this.B=Ce[1]|0,this.C=Ce[2]|0,this.D=Ce[3]|0,this.E=Ce[4]|0,this.F=Ce[5]|0,this.G=Ce[6]|0,this.H=Ce[7]|0}get(){const{A:e,B:n,C:r,D:o,E:i,F:s,G:a,H:c}=this;return[e,n,r,o,i,s,a,c]}set(e,n,r,o,i,s,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,n){for(let u=0;u<16;u++,n+=4)Pe[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const g=Pe[u-15],h=Pe[u-2],b=ye(g,7)^ye(g,18)^g>>>3,d=ye(h,17)^ye(h,19)^h>>>10;Pe[u]=d+Pe[u-7]+b+Pe[u-16]|0}let{A:r,B:o,C:i,D:s,E:a,F:c,G:l,H:f}=this;for(let u=0;u<64;u++){const g=ye(a,6)^ye(a,11)^ye(a,25),h=f+g+fi(a,c,l)+hi[u]+Pe[u]|0,d=(ye(r,2)^ye(r,13)^ye(r,22))+di(r,o,i)|0;f=l,l=c,c=a,a=s+h|0,s=i,i=o,o=r,r=h+d|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(r,o,i,s,a,c,l,f)}roundClean(){Pe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const an=ai(()=>new gi);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ur=BigInt(0),Ot=BigInt(1),pi=BigInt(2),Nt=t=>t instanceof Uint8Array,bi=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function rt(t){if(!Nt(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=bi[t[n]];return e}function fr(t){const e=t.toString(16);return e.length&1?`0${e}`:e}function ln(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function ot(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const o=r*2,i=t.slice(o,o+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function ce(t){return ln(rt(t))}function un(t){if(!Nt(t))throw new Error("Uint8Array expected");return ln(rt(Uint8Array.from(t).reverse()))}function Le(t,e){return ot(t.toString(16).padStart(e*2,"0"))}function fn(t,e){return Le(t,e).reverse()}function wi(t){return ot(fr(t))}function ne(t,e,n){let r;if(typeof e=="string")try{r=ot(e)}catch(i){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${i}`)}else if(Nt(e))r=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(`${t} expected ${n} bytes, got ${o}`);return r}function We(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!Nt(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}function yi(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function mi(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function vi(t){let e;for(e=0;t>ur;t>>=Ot,e+=1);return e}function xi(t,e){return t>>BigInt(e)&Ot}const Ei=(t,e,n)=>t|(n?Ot:ur)<<BigInt(e),dn=t=>(pi<<BigInt(t-1))-Ot,hn=t=>new Uint8Array(t),dr=t=>Uint8Array.from(t);function hr(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=hn(t),o=hn(t),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},a=(...u)=>n(o,r,...u),c=(u=hn())=>{o=a(dr([0]),u),r=a(),u.length!==0&&(o=a(dr([1]),u),r=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const g=[];for(;u<e;){r=a();const h=r.slice();g.push(h),u+=r.length}return We(...g)};return(u,g)=>{s(),c(u);let h;for(;!(h=g(l()));)c();return s(),h}}const _i={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function wt(t,e,n={}){const r=(o,i,s)=>{const a=_i[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const c=t[o];if(!(s&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${i}`)};for(const[o,i]of Object.entries(e))r(o,i,!1);for(const[o,i]of Object.entries(n))r(o,i,!0);return t}const ki=Object.freeze(Object.defineProperty({__proto__:null,bitGet:xi,bitLen:vi,bitMask:dn,bitSet:Ei,bytesToHex:rt,bytesToNumberBE:ce,bytesToNumberLE:un,concatBytes:We,createHmacDrbg:hr,ensureBytes:ne,equalBytes:yi,hexToBytes:ot,hexToNumber:ln,numberToBytesBE:Le,numberToBytesLE:fn,numberToHexUnpadded:fr,numberToVarBytesBE:wi,utf8ToBytes:mi,validateObject:wt},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ee=BigInt(0),J=BigInt(1),Ve=BigInt(2),Si=BigInt(3),gn=BigInt(4),gr=BigInt(5),pr=BigInt(8);BigInt(9),BigInt(16);function te(t,e){const n=t%e;return n>=ee?n:e+n}function Ai(t,e,n){if(n<=ee||e<ee)throw new Error("Expected power/modulo > 0");if(n===J)return ee;let r=J;for(;e>ee;)e&J&&(r=r*t%n),t=t*t%n,e>>=J;return r}function ue(t,e,n){let r=t;for(;e-- >ee;)r*=r,r%=n;return r}function pn(t,e){if(t===ee||e<=ee)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=te(t,e),r=e,o=ee,i=J;for(;n!==ee;){const a=r/n,c=r%n,l=o-i*a;r=n,n=c,o=i,i=l}if(r!==J)throw new Error("invert: does not exist");return te(o,e)}function Bi(t){const e=(t-J)/Ve;let n,r,o;for(n=t-J,r=0;n%Ve===ee;n/=Ve,r++);for(o=Ve;o<t&&Ai(o,e,t)!==t-J;o++);if(r===1){const s=(t+J)/gn;return function(c,l){const f=c.pow(l,s);if(!c.eql(c.sqr(f),l))throw new Error("Cannot find square root");return f}}const i=(n+J)/Ve;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=r,f=a.pow(a.mul(a.ONE,o),n),u=a.pow(c,i),g=a.pow(c,n);for(;!a.eql(g,a.ONE);){if(a.eql(g,a.ZERO))return a.ZERO;let h=1;for(let d=a.sqr(g);h<l&&!a.eql(d,a.ONE);h++)d=a.sqr(d);const b=a.pow(f,J<<BigInt(l-h-1));f=a.sqr(b),u=a.mul(u,b),g=a.mul(g,f),l=h}return u}}function Ii(t){if(t%gn===Si){const e=(t+J)/gn;return function(r,o){const i=r.pow(o,e);if(!r.eql(r.sqr(i),o))throw new Error("Cannot find square root");return i}}if(t%pr===gr){const e=(t-gr)/pr;return function(r,o){const i=r.mul(o,Ve),s=r.pow(i,e),a=r.mul(o,s),c=r.mul(r.mul(a,Ve),s),l=r.mul(a,r.sub(c,r.ONE));if(!r.eql(r.sqr(l),o))throw new Error("Cannot find square root");return l}}return Bi(t)}const Oi=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ni(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=Oi.reduce((r,o)=>(r[o]="function",r),e);return wt(t,n)}function Ti(t,e,n){if(n<ee)throw new Error("Expected power > 0");if(n===ee)return t.ONE;if(n===J)return e;let r=t.ONE,o=e;for(;n>ee;)n&J&&(r=t.mul(r,o)),o=t.sqr(o),n>>=J;return r}function Ci(t,e){const n=new Array(e.length),r=e.reduce((i,s,a)=>t.is0(s)?i:(n[a]=i,t.mul(i,s)),t.ONE),o=t.inv(r);return e.reduceRight((i,s,a)=>t.is0(s)?i:(n[a]=t.mul(i,n[a]),t.mul(i,s)),o),n}function br(t,e){const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Pi(t,e,n=!1,r={}){if(t<=ee)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:o,nByteLength:i}=br(t,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Ii(t),a=Object.freeze({ORDER:t,BITS:o,BYTES:i,MASK:dn(o),ZERO:ee,ONE:J,create:c=>te(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ee<=c&&c<t},is0:c=>c===ee,isOdd:c=>(c&J)===J,neg:c=>te(-c,t),eql:(c,l)=>c===l,sqr:c=>te(c*c,t),add:(c,l)=>te(c+l,t),sub:(c,l)=>te(c-l,t),mul:(c,l)=>te(c*l,t),pow:(c,l)=>Ti(a,c,l),div:(c,l)=>te(c*pn(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>pn(c,t),sqrt:r.sqrt||(c=>s(a,c)),invertBatch:c=>Ci(a,c),cmov:(c,l,f)=>f?l:c,toBytes:c=>n?fn(c,i):Le(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return n?un(c):ce(c)}});return Object.freeze(a)}function wr(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function yr(t){const e=wr(t);return e+Math.ceil(e/2)}function Li(t,e,n=!1){const r=t.length,o=wr(e),i=yr(e);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=n?ce(t):un(t),a=te(s,e-J)+J;return n?fn(a,o):Le(a,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ui=BigInt(0),bn=BigInt(1);function Hi(t,e){const n=(o,i)=>{const s=i.negate();return o?s:i},r=o=>{const i=Math.ceil(e/o)+1,s=2**(o-1);return{windows:i,windowSize:s}};return{constTimeNegate:n,unsafeLadder(o,i){let s=t.ZERO,a=o;for(;i>Ui;)i&bn&&(s=s.add(a)),a=a.double(),i>>=bn;return s},precomputeWindow(o,i){const{windows:s,windowSize:a}=r(i),c=[];let l=o,f=l;for(let u=0;u<s;u++){f=l,c.push(f);for(let g=1;g<a;g++)f=f.add(l),c.push(f);l=f.double()}return c},wNAF(o,i,s){const{windows:a,windowSize:c}=r(o);let l=t.ZERO,f=t.BASE;const u=BigInt(2**o-1),g=2**o,h=BigInt(o);for(let b=0;b<a;b++){const d=b*c;let p=Number(s&u);s>>=h,p>c&&(p-=g,s+=bn);const w=d,y=d+Math.abs(p)-1,A=b%2!==0,N=p<0;p===0?f=f.add(n(A,i[w])):l=l.add(n(N,i[y]))}return{p:l,f}},wNAFCached(o,i,s,a){const c=o._WINDOW_SIZE||1;let l=i.get(o);return l||(l=this.precomputeWindow(o,c),c!==1&&i.set(o,a(l))),this.wNAF(c,l,s)}}}function mr(t){return Ni(t.Fp),wt(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...br(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ri(t){const e=mr(t);wt(e,{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}=e;if(n){if(!r.eql(o,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:Mi,hexToBytes:qi}=ki,Fe={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:e}=Fe;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:Mi(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=Fe,n=typeof t=="string"?qi(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:o,l:i}=Fe._parseInt(n.subarray(2)),{d:s,l:a}=Fe._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:o,s}},hexFromSig(t){const e=l=>Number.parseInt(l[0],16)&8?"00"+l:l,n=l=>{const f=l.toString(16);return f.length&1?`0${f}`:f},r=e(n(t.s)),o=e(n(t.r)),i=r.length/2,s=o.length/2,a=n(i),c=n(s);return`30${n(s+i+4)}02${c}${o}02${a}${r}`}},xe=BigInt(0),fe=BigInt(1);BigInt(2);const vr=BigInt(3);BigInt(4);function ji(t){const e=Ri(t),{Fp:n}=e,r=e.toBytes||((b,d,p)=>{const w=d.toAffine();return We(Uint8Array.from([4]),n.toBytes(w.x),n.toBytes(w.y))}),o=e.fromBytes||(b=>{const d=b.subarray(1),p=n.fromBytes(d.subarray(0,n.BYTES)),w=n.fromBytes(d.subarray(n.BYTES,2*n.BYTES));return{x:p,y:w}});function i(b){const{a:d,b:p}=e,w=n.sqr(b),y=n.mul(w,b);return n.add(n.add(y,n.mul(b,d)),p)}if(!n.eql(n.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function s(b){return typeof b=="bigint"&&xe<b&&b<e.n}function a(b){if(!s(b))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(b){const{allowedPrivateKeyLengths:d,nByteLength:p,wrapPrivateKey:w,n:y}=e;if(d&&typeof b!="bigint"){if(b instanceof Uint8Array&&(b=rt(b)),typeof b!="string"||!d.includes(b.length))throw new Error("Invalid key");b=b.padStart(p*2,"0")}let A;try{A=typeof b=="bigint"?b:ce(ne("private key",b,p))}catch{throw new Error(`private key must be ${p} bytes, hex or bigint, not ${typeof b}`)}return w&&(A=te(A,y)),a(A),A}const l=new Map;function f(b){if(!(b instanceof u))throw new Error("ProjectivePoint expected")}class u{constructor(d,p,w){if(this.px=d,this.py=p,this.pz=w,d==null||!n.isValid(d))throw new Error("x required");if(p==null||!n.isValid(p))throw new Error("y required");if(w==null||!n.isValid(w))throw new Error("z required")}static fromAffine(d){const{x:p,y:w}=d||{};if(!d||!n.isValid(p)||!n.isValid(w))throw new Error("invalid affine point");if(d instanceof u)throw new Error("projective point not allowed");const y=A=>n.eql(A,n.ZERO);return y(p)&&y(w)?u.ZERO:new u(p,w,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){const p=n.invertBatch(d.map(w=>w.pz));return d.map((w,y)=>w.toAffine(p[y])).map(u.fromAffine)}static fromHex(d){const p=u.fromAffine(o(ne("pointHex",d)));return p.assertValidity(),p}static fromPrivateKey(d){return u.BASE.multiply(c(d))}_setWindowSize(d){this._WINDOW_SIZE=d,l.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:d,y:p}=this.toAffine();if(!n.isValid(d)||!n.isValid(p))throw new Error("bad point: x or y not FE");const w=n.sqr(p),y=i(d);if(!n.eql(w,y))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:d}=this.toAffine();if(n.isOdd)return!n.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);const{px:p,py:w,pz:y}=this,{px:A,py:N,pz:U}=d,k=n.eql(n.mul(p,U),n.mul(A,y)),v=n.eql(n.mul(w,U),n.mul(N,y));return k&&v}negate(){return new u(this.px,n.neg(this.py),this.pz)}double(){const{a:d,b:p}=e,w=n.mul(p,vr),{px:y,py:A,pz:N}=this;let U=n.ZERO,k=n.ZERO,v=n.ZERO,m=n.mul(y,y),S=n.mul(A,A),T=n.mul(N,N),P=n.mul(y,A);return P=n.add(P,P),v=n.mul(y,N),v=n.add(v,v),U=n.mul(d,v),k=n.mul(w,T),k=n.add(U,k),U=n.sub(S,k),k=n.add(S,k),k=n.mul(U,k),U=n.mul(P,U),v=n.mul(w,v),T=n.mul(d,T),P=n.sub(m,T),P=n.mul(d,P),P=n.add(P,v),v=n.add(m,m),m=n.add(v,m),m=n.add(m,T),m=n.mul(m,P),k=n.add(k,m),T=n.mul(A,N),T=n.add(T,T),m=n.mul(T,P),U=n.sub(U,m),v=n.mul(T,S),v=n.add(v,v),v=n.add(v,v),new u(U,k,v)}add(d){f(d);const{px:p,py:w,pz:y}=this,{px:A,py:N,pz:U}=d;let k=n.ZERO,v=n.ZERO,m=n.ZERO;const S=e.a,T=n.mul(e.b,vr);let P=n.mul(p,A),D=n.mul(w,N),$=n.mul(y,U),W=n.add(p,w),_=n.add(A,N);W=n.mul(W,_),_=n.add(P,D),W=n.sub(W,_),_=n.add(p,y);let I=n.add(A,U);return _=n.mul(_,I),I=n.add(P,$),_=n.sub(_,I),I=n.add(w,y),k=n.add(N,U),I=n.mul(I,k),k=n.add(D,$),I=n.sub(I,k),m=n.mul(S,_),k=n.mul(T,$),m=n.add(k,m),k=n.sub(D,m),m=n.add(D,m),v=n.mul(k,m),D=n.add(P,P),D=n.add(D,P),$=n.mul(S,$),_=n.mul(T,_),D=n.add(D,$),$=n.sub(P,$),$=n.mul(S,$),_=n.add(_,$),P=n.mul(D,_),v=n.add(v,P),P=n.mul(I,_),k=n.mul(W,k),k=n.sub(k,P),P=n.mul(W,D),m=n.mul(I,m),m=n.add(m,P),new u(k,v,m)}subtract(d){return this.add(d.negate())}is0(){return this.equals(u.ZERO)}wNAF(d){return h.wNAFCached(this,l,d,p=>{const w=n.invertBatch(p.map(y=>y.pz));return p.map((y,A)=>y.toAffine(w[A])).map(u.fromAffine)})}multiplyUnsafe(d){const p=u.ZERO;if(d===xe)return p;if(a(d),d===fe)return this;const{endo:w}=e;if(!w)return h.unsafeLadder(this,d);let{k1neg:y,k1:A,k2neg:N,k2:U}=w.splitScalar(d),k=p,v=p,m=this;for(;A>xe||U>xe;)A&fe&&(k=k.add(m)),U&fe&&(v=v.add(m)),m=m.double(),A>>=fe,U>>=fe;return y&&(k=k.negate()),N&&(v=v.negate()),v=new u(n.mul(v.px,w.beta),v.py,v.pz),k.add(v)}multiply(d){a(d);let p=d,w,y;const{endo:A}=e;if(A){const{k1neg:N,k1:U,k2neg:k,k2:v}=A.splitScalar(p);let{p:m,f:S}=this.wNAF(U),{p:T,f:P}=this.wNAF(v);m=h.constTimeNegate(N,m),T=h.constTimeNegate(k,T),T=new u(n.mul(T.px,A.beta),T.py,T.pz),w=m.add(T),y=S.add(P)}else{const{p:N,f:U}=this.wNAF(p);w=N,y=U}return u.normalizeZ([w,y])[0]}multiplyAndAddUnsafe(d,p,w){const y=u.BASE,A=(U,k)=>k===xe||k===fe||!U.equals(y)?U.multiplyUnsafe(k):U.multiply(k),N=A(this,p).add(A(d,w));return N.is0()?void 0:N}toAffine(d){const{px:p,py:w,pz:y}=this,A=this.is0();d==null&&(d=A?n.ONE:n.inv(y));const N=n.mul(p,d),U=n.mul(w,d),k=n.mul(y,d);if(A)return{x:n.ZERO,y:n.ZERO};if(!n.eql(k,n.ONE))throw new Error("invZ was invalid");return{x:N,y:U}}isTorsionFree(){const{h:d,isTorsionFree:p}=e;if(d===fe)return!0;if(p)return p(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:d,clearCofactor:p}=e;return d===fe?this:p?p(u,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return this.assertValidity(),r(u,this,d)}toHex(d=!0){return rt(this.toRawBytes(d))}}u.BASE=new u(e.Gx,e.Gy,n.ONE),u.ZERO=new u(n.ZERO,n.ONE,n.ZERO);const g=e.nBitLength,h=Hi(u,e.endo?Math.ceil(g/2):g);return{CURVE:e,ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:s}}function zi(t){const e=mr(t);return wt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Ki(t){const e=zi(t),{Fp:n,n:r}=e,o=n.BYTES+1,i=2*n.BYTES+1;function s(_){return xe<_&&_<n.ORDER}function a(_){return te(_,r)}function c(_){return pn(_,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:g}=ji({...e,toBytes(_,I,L){const M=I.toAffine(),R=n.toBytes(M.x),z=We;return L?z(Uint8Array.from([I.hasEvenY()?2:3]),R):z(Uint8Array.from([4]),R,n.toBytes(M.y))},fromBytes(_){const I=_.length,L=_[0],M=_.subarray(1);if(I===o&&(L===2||L===3)){const R=ce(M);if(!s(R))throw new Error("Point is not on curve");const z=u(R);let Y=n.sqrt(z);const K=(Y&fe)===fe;return(L&1)===1!==K&&(Y=n.neg(Y)),{x:R,y:Y}}else if(I===i&&L===4){const R=n.fromBytes(M.subarray(0,n.BYTES)),z=n.fromBytes(M.subarray(n.BYTES,2*n.BYTES));return{x:R,y:z}}else throw new Error(`Point of length ${I} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=_=>rt(Le(_,e.nByteLength));function b(_){const I=r>>fe;return _>I}function d(_){return b(_)?a(-_):_}const p=(_,I,L)=>ce(_.slice(I,L));class w{constructor(I,L,M){this.r=I,this.s=L,this.recovery=M,this.assertValidity()}static fromCompact(I){const L=e.nByteLength;return I=ne("compactSignature",I,L*2),new w(p(I,0,L),p(I,L,2*L))}static fromDER(I){const{r:L,s:M}=Fe.toSig(ne("DER",I));return new w(L,M)}assertValidity(){if(!g(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!g(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(I){return new w(this.r,this.s,I)}recoverPublicKey(I){const{r:L,s:M,recovery:R}=this,z=v(ne("msgHash",I));if(R==null||![0,1,2,3].includes(R))throw new Error("recovery id invalid");const Y=R===2||R===3?L+e.n:L;if(Y>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const K=R&1?"03":"02",se=l.fromHex(K+h(Y)),Q=c(Y),he=a(-z*Q),ge=a(M*Q),pe=l.BASE.multiplyAndAddUnsafe(se,he,ge);if(!pe)throw new Error("point at infinify");return pe.assertValidity(),pe}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new w(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return ot(this.toDERHex())}toDERHex(){return Fe.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ot(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const y={isValidPrivateKey(_){try{return f(_),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const _=yr(e.n);return Li(e.randomBytes(_),e.n)},precompute(_=8,I=l.BASE){return I._setWindowSize(_),I.multiply(BigInt(3)),I}};function A(_,I=!0){return l.fromPrivateKey(_).toRawBytes(I)}function N(_){const I=_ instanceof Uint8Array,L=typeof _=="string",M=(I||L)&&_.length;return I?M===o||M===i:L?M===2*o||M===2*i:_ instanceof l}function U(_,I,L=!0){if(N(_))throw new Error("first arg must be private key");if(!N(I))throw new Error("second arg must be public key");return l.fromHex(I).multiply(f(_)).toRawBytes(L)}const k=e.bits2int||function(_){const I=ce(_),L=_.length*8-e.nBitLength;return L>0?I>>BigInt(L):I},v=e.bits2int_modN||function(_){return a(k(_))},m=dn(e.nBitLength);function S(_){if(typeof _!="bigint")throw new Error("bigint expected");if(!(xe<=_&&_<m))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Le(_,e.nByteLength)}function T(_,I,L=P){if(["recovered","canonical"].some(le=>le in L))throw new Error("sign() legacy options not supported");const{hash:M,randomBytes:R}=e;let{lowS:z,prehash:Y,extraEntropy:K}=L;z==null&&(z=!0),_=ne("msgHash",_),Y&&(_=ne("prehashed msgHash",M(_)));const se=v(_),Q=f(I),he=[S(Q),S(se)];if(K!=null){const le=K===!0?R(n.BYTES):K;he.push(ne("extraEntropy",le))}const ge=We(...he),pe=se;function Ze(le){const Ae=k(le);if(!g(Ae))return;const Et=c(Ae),Be=l.BASE.multiply(Ae).toAffine(),ae=a(Be.x);if(ae===xe)return;const Ie=a(Et*a(pe+ae*Q));if(Ie===xe)return;let Je=(Be.x===ae?0:2)|Number(Be.y&fe),ze=Ie;return z&&b(Ie)&&(ze=d(Ie),Je^=1),new w(ae,ze,Je)}return{seed:ge,k2sig:Ze}}const P={lowS:e.lowS,prehash:!1},D={lowS:e.lowS,prehash:!1};function $(_,I,L=P){const{seed:M,k2sig:R}=T(_,I,L),z=e;return hr(z.hash.outputLen,z.nByteLength,z.hmac)(M,R)}l.BASE._setWindowSize(8);function W(_,I,L,M=D){var Be;const R=_;if(I=ne("msgHash",I),L=ne("publicKey",L),"strict"in M)throw new Error("options.strict was renamed to lowS");const{lowS:z,prehash:Y}=M;let K,se;try{if(typeof R=="string"||R instanceof Uint8Array)try{K=w.fromDER(R)}catch(ae){if(!(ae instanceof Fe.Err))throw ae;K=w.fromCompact(R)}else if(typeof R=="object"&&typeof R.r=="bigint"&&typeof R.s=="bigint"){const{r:ae,s:Ie}=R;K=new w(ae,Ie)}else throw new Error("PARSE");se=l.fromHex(L)}catch(ae){if(ae.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(z&&K.hasHighS())return!1;Y&&(I=e.hash(I));const{r:Q,s:he}=K,ge=v(I),pe=c(he),Ze=a(ge*pe),le=a(Q*pe),Ae=(Be=l.BASE.multiplyAndAddUnsafe(se,Ze,le))==null?void 0:Be.toAffine();return Ae?a(Ae.x)===Q:!1}return{CURVE:e,getPublicKey:A,getSharedSecret:U,sign:$,verify:W,ProjectivePoint:l,Signature:w,utils:y}}let xr=class extends ar{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,oi(e);const r=cn(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(r.length>o?e.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return It(this),this.iHash.update(e),this}digestInto(e){It(this),sr(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:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Er=(t,e,n)=>new xr(t,e).update(n).digest();Er.create=(t,e)=>new xr(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function $i(t){return{hash:t,hmac:(e,...n)=>Er(t,e,ci(...n)),randomBytes:lr}}function Di(t,e){const n=r=>Ki({...t,...$i(r)});return Object.freeze({...n(e),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Tt=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ct=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_r=BigInt(1),Pt=BigInt(2),kr=(t,e)=>(t+e/Pt)/e;function Sr(t){const e=Tt,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,f=l*l*t%e,u=ue(f,n,e)*f%e,g=ue(u,n,e)*f%e,h=ue(g,Pt,e)*l%e,b=ue(h,o,e)*h%e,d=ue(b,i,e)*b%e,p=ue(d,a,e)*d%e,w=ue(p,c,e)*p%e,y=ue(w,a,e)*d%e,A=ue(y,n,e)*f%e,N=ue(A,s,e)*b%e,U=ue(N,r,e)*l%e,k=ue(U,Pt,e);if(!wn.eql(wn.sqr(k),t))throw new Error("Cannot find square root");return k}const wn=Pi(Tt,void 0,void 0,{sqrt:Sr}),it=Di({a:BigInt(0),b:BigInt(7),Fp:wn,n:Ct,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Ct,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-_r*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=kr(i*t,e),c=kr(-r*t,e);let l=te(t-a*n-c*o,e),f=te(-a*r-c*i,e);const u=l>s,g=f>s;if(u&&(l=e-l),g&&(f=e-f),l>s||f>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:u,k1:l,k2neg:g,k2:f}}}},an),Lt=BigInt(0),Ar=t=>typeof t=="bigint"&&Lt<t&&t<Tt,Wi=t=>typeof t=="bigint"&&Lt<t&&t<Ct,Br={};function Ut(t,...e){let n=Br[t];if(n===void 0){const r=an(Uint8Array.from(t,o=>o.charCodeAt(0)));n=We(r,r),Br[t]=n}return an(We(n,...e))}const yn=t=>t.toRawBytes(!0).slice(1),mn=t=>Le(t,32),vn=t=>te(t,Tt),yt=t=>te(t,Ct),xn=it.ProjectivePoint,Vi=(t,e,n)=>xn.BASE.multiplyAndAddUnsafe(t,e,n);function En(t){let e=it.utils.normPrivateKeyToScalar(t),n=xn.fromPrivateKey(e);return{scalar:n.hasEvenY()?e:yt(-e),bytes:yn(n)}}function Ir(t){if(!Ar(t))throw new Error("bad x: need 0 < x < p");const e=vn(t*t),n=vn(e*t+BigInt(7));let r=Sr(n);r%Pt!==Lt&&(r=vn(-r));const o=new xn(t,r,_r);return o.assertValidity(),o}function Or(...t){return yt(ce(Ut("BIP0340/challenge",...t)))}function Fi(t){return En(t).bytes}function Yi(t,e,n=lr(32)){const r=ne("message",t),{bytes:o,scalar:i}=En(e),s=ne("auxRand",n,32),a=mn(i^ce(Ut("BIP0340/aux",s))),c=Ut("BIP0340/nonce",a,o,r),l=yt(ce(c));if(l===Lt)throw new Error("sign failed: k is zero");const{bytes:f,scalar:u}=En(l),g=Or(f,o,r),h=new Uint8Array(64);if(h.set(f,0),h.set(mn(yt(u+g*i)),32),!Nr(h,r,o))throw new Error("sign: Invalid signature produced");return h}function Nr(t,e,n){const r=ne("signature",t,64),o=ne("message",e),i=ne("publicKey",n,32);try{const s=Ir(ce(i)),a=ce(r.subarray(0,32));if(!Ar(a))return!1;const c=ce(r.subarray(32,64));if(!Wi(c))return!1;const l=Or(mn(a),yn(s),o),f=Vi(s,c,yt(-l));return!(!f||!f.hasEvenY()||f.toAffine().x!==a)}catch{return!1}}const ie={getPublicKey:Fi,sign:Yi,verify:Nr,utils:{randomPrivateKey:it.utils.randomPrivateKey,lift_x:Ir,pointToBytes:yn,numberToBytesBE:Le,bytesToNumberBE:ce,taggedHash:Ut,mod:te}};function _n(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Gi(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function Tr(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Zi(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");_n(t.outputLen),_n(t.blockLen)}function Ji(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Qi(t,e){Tr(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const me={number:_n,bool:Gi,bytes:Tr,hash:Zi,exists:Ji,output:Qi};function Xi(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),c=r?4:0,l=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+l,a,r)}class es extends rr{constructor(e,n,r,o){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=nn(this.buffer)}update(e){me.exists(this);const{view:n,buffer:r,blockLen:o}=this;e=bt(e);const i=e.length;for(let s=0;s<i;){const a=Math.min(o-this.pos,i-s);if(a===o){const c=nn(e);for(;o<=i-s;s+=o)this.process(c,s);continue}r.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){me.exists(this),me.output(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(r,0),s=0);for(let u=s;u<o;u++)n[u]=0;Xi(r,o-8,BigInt(this.length*8),i),this.process(r,0);const a=nn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,f[u],i)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=s,o%n&&e.buffer.set(r),e}}const ts=(t,e,n)=>t&e^~t&n,ns=(t,e,n)=>t&e^t&n^e&n,rs=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]),Ue=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),He=new Uint32Array(64);class Cr extends es{constructor(){super(64,32,8,!1),this.A=Ue[0]|0,this.B=Ue[1]|0,this.C=Ue[2]|0,this.D=Ue[3]|0,this.E=Ue[4]|0,this.F=Ue[5]|0,this.G=Ue[6]|0,this.H=Ue[7]|0}get(){const{A:e,B:n,C:r,D:o,E:i,F:s,G:a,H:c}=this;return[e,n,r,o,i,s,a,c]}set(e,n,r,o,i,s,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,n){for(let u=0;u<16;u++,n+=4)He[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const g=He[u-15],h=He[u-2],b=we(g,7)^we(g,18)^g>>>3,d=we(h,17)^we(h,19)^h>>>10;He[u]=d+He[u-7]+b+He[u-16]|0}let{A:r,B:o,C:i,D:s,E:a,F:c,G:l,H:f}=this;for(let u=0;u<64;u++){const g=we(a,6)^we(a,11)^we(a,25),h=f+g+ts(a,c,l)+rs[u]+He[u]|0,d=(we(r,2)^we(r,13)^we(r,22))+ns(r,o,i)|0;f=l,l=c,c=a,a=s+h|0,s=i,i=o,o=r,r=h+d|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(r,o,i,s,a,c,l,f)}roundClean(){He.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class os extends Cr{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const st=or(()=>new Cr);or(()=>new os);var ct=Symbol("verified"),is=t=>t instanceof Object;function ss(t){if(!is(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]=="object")return!1}return!0}new TextDecoder("utf-8");var cs=new TextEncoder,as=class{generateSecretKey(){return ie.utils.randomPrivateKey()}getPublicKey(e){return oe(ie.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=oe(ie.getPublicKey(n)),r.id=kn(r),r.sig=oe(ie.sign(kn(r),n)),r[ct]=!0,r}verifyEvent(e){if(typeof e[ct]=="boolean")return e[ct];const n=kn(e);if(n!==e.id)return e[ct]=!1,!1;try{const r=ie.verify(e.sig,n,e.pubkey);return e[ct]=r,r}catch{return e[ct]=!1,!1}}};function ls(t){if(!ss(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}function kn(t){let e=st(cs.encode(ls(t)));return oe(e)}var Ht=new as,us=Ht.generateSecretKey,Pr=Ht.getPublicKey;Ht.finalizeEvent,Ht.verifyEvent;var Ye=Symbol("verified"),fs=t=>t instanceof Object;function ds(t){if(!fs(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]=="object")return!1}return!0}new TextDecoder("utf-8");var hs=new TextEncoder;function mt(t){t.indexOf("://")===-1&&(t="wss://"+t);let e=new URL(t);return e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}var gs=class{constructor(e){E(this,"value");E(this,"next",null);E(this,"prev",null);this.value=e}},ps=class{constructor(){E(this,"first");E(this,"last");this.first=null,this.last=null}enqueue(e){const n=new gs(e);return this.last?this.last===this.first?(this.last=n,this.last.prev=this.first,this.first.next=n):(n.prev=this.last,this.last.next=n,this.last=n):(this.first=n,this.last=n),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const n=this.first;return this.first=null,this.last=null,n.value}const e=this.first;return this.first=e.next,e.value}},bs=class{generateSecretKey(){return ie.utils.randomPrivateKey()}getPublicKey(e){return oe(ie.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=oe(ie.getPublicKey(n)),r.id=Sn(r),r.sig=oe(ie.sign(Sn(r),n)),r[Ye]=!0,r}verifyEvent(e){if(typeof e[Ye]=="boolean")return e[Ye];const n=Sn(e);if(n!==e.id)return e[Ye]=!1,!1;try{const r=ie.verify(e.sig,n,e.pubkey);return e[Ye]=r,r}catch{return e[Ye]=!1,!1}}};function ws(t){if(!ds(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}function Sn(t){let e=st(hs.encode(ws(t)));return oe(e)}var Rt=new bs;Rt.generateSecretKey,Rt.getPublicKey,Rt.finalizeEvent;var ys=Rt.verifyEvent,ms=22242;function vs(t,e){if(t.ids&&t.ids.indexOf(e.id)===-1||t.kinds&&t.kinds.indexOf(e.kind)===-1||t.authors&&t.authors.indexOf(e.pubkey)===-1)return!1;for(let n in t)if(n[0]==="#"){let r=n.slice(1),o=t[`#${r}`];if(o&&!e.tags.find(([i,s])=>i===n.slice(1)&&o.indexOf(s)!==-1))return!1}return!(t.since&&e.created_at<t.since||t.until&&e.created_at>t.until)}function xs(t,e){for(let n=0;n<t.length;n++)if(vs(t[n],e))return!0;return!1}function Es(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,o=t.slice(r).indexOf('"')+r+1;return t.slice(o,o+64)}function _s(t){let e=t.slice(0,22).indexOf('"EVENT"');if(e===-1)return null;let n=t.slice(e+7+1).indexOf('"');if(n===-1)return null;let r=e+7+1+n,o=t.slice(r+1,80).indexOf('"');if(o===-1)return null;let i=r+1+o;return t.slice(r+1,i)}function ks(t,e){return{kind:ms,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}async function Ss(){return new Promise(t=>{const e=new MessageChannel,n=()=>{e.port1.removeEventListener("message",n),t()};e.port1.addEventListener("message",n),e.port2.postMessage(0),e.port1.start()})}var As=t=>(t[Ye]=!0,!0),Lr=class{constructor(e,n){E(this,"url");E(this,"_connected",!1);E(this,"onclose",null);E(this,"onnotice",e=>console.debug(`NOTICE from ${this.url}: ${e}`));E(this,"_onauth",null);E(this,"baseEoseTimeout",4400);E(this,"connectionTimeout",4400);E(this,"openSubs",new Map);E(this,"connectionTimeoutHandle");E(this,"connectionPromise");E(this,"openCountRequests",new Map);E(this,"openEventPublishes",new Map);E(this,"ws");E(this,"incomingMessageQueue",new ps);E(this,"queueRunning",!1);E(this,"challenge");E(this,"serial",0);E(this,"verifyEvent");E(this,"_WebSocket");this.url=mt(e),this.verifyEvent=n.verifyEvent,this._WebSocket=n.websocketImplementation||WebSocket}static async connect(e,n){const r=new Lr(e,n);return await r.connect(),r}closeAllSubscriptions(e){for(let[n,r]of this.openSubs)r.close(e);this.openSubs.clear();for(let[n,r]of this.openEventPublishes)r.reject(new Error(e));this.openEventPublishes.clear();for(let[n,r]of this.openCountRequests)r.reject(new Error(e));this.openCountRequests.clear()}get connected(){return this._connected}async connect(){return this.connectionPromise?this.connectionPromise:(this.challenge=void 0,this.connectionPromise=new Promise((e,n)=>{this.connectionTimeoutHandle=setTimeout(()=>{var r;n("connection timed out"),this.connectionPromise=void 0,(r=this.onclose)==null||r.call(this),this.closeAllSubscriptions("relay connection timed out")},this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(r){n(r);return}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,e()},this.ws.onerror=r=>{var o;n(r.message||"websocket error"),this._connected&&(this._connected=!1,this.connectionPromise=void 0,(o=this.onclose)==null||o.call(this),this.closeAllSubscriptions("relay connection errored"))},this.ws.onclose=async()=>{var r;this._connected&&(this._connected=!1,this.connectionPromise=void 0,(r=this.onclose)==null||r.call(this),this.closeAllSubscriptions("relay connection closed"))},this.ws.onmessage=this._onmessage.bind(this)}),this.connectionPromise)}async runQueue(){for(this.queueRunning=!0;this.handleNext()!==!1;)await Ss();this.queueRunning=!1}handleNext(){var r,o,i;const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const n=_s(e);if(n){const s=this.openSubs.get(n);if(!s)return;const a=Es(e,"id"),c=(r=s.alreadyHaveEvent)==null?void 0:r.call(s,a);if((o=s.receivedEvent)==null||o.call(s,this,a),c)return}try{let s=JSON.parse(e);switch(s[0]){case"EVENT":{const a=this.openSubs.get(s[1]),c=s[2];this.verifyEvent(c)&&xs(a.filters,c)&&a.onevent(c);return}case"COUNT":{const a=s[1],c=s[2],l=this.openCountRequests.get(a);l&&(l.resolve(c.count),this.openCountRequests.delete(a));return}case"EOSE":{const a=this.openSubs.get(s[1]);if(!a)return;a.receivedEose();return}case"OK":{const a=s[1],c=s[2],l=s[3],f=this.openEventPublishes.get(a);c?f.resolve(l):f.reject(new Error(l)),this.openEventPublishes.delete(a);return}case"CLOSED":{const a=s[1],c=this.openSubs.get(a);if(!c)return;c.closed=!0,c.close(s[2]);return}case"NOTICE":this.onnotice(s[1]);return;case"AUTH":{this.challenge=s[1],(i=this._onauth)==null||i.call(this,s[1]);return}}}catch{return}}async send(e){if(!this.connectionPromise)throw new Error("sending on closed connection");this.connectionPromise.then(()=>{var n;(n=this.ws)==null||n.send(e)})}async auth(e){if(!this.challenge)throw new Error("can't perform auth, no challenge was received");const n=await e(ks(this.url,this.challenge)),r=new Promise((o,i)=>{this.openEventPublishes.set(n.id,{resolve:o,reject:i})});return this.send('["AUTH",'+JSON.stringify(n)+"]"),r}async publish(e){const n=new Promise((r,o)=>{this.openEventPublishes.set(e.id,{resolve:r,reject:o})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),n}async count(e,n){this.serial++;const r=(n==null?void 0:n.id)||"count:"+this.serial,o=new Promise((i,s)=>{this.openCountRequests.set(r,{resolve:i,reject:s})});return this.send('["COUNT","'+r+'",'+JSON.stringify(e).substring(1)),o}subscribe(e,n){const r=this.prepareSubscription(e,n);return r.fire(),r}prepareSubscription(e,n){this.serial++;const r=n.id||"sub:"+this.serial,o=new Bs(this,r,e,n);return this.openSubs.set(r,o),o}close(){var e;this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,(e=this.ws)==null||e.close()}_onmessage(e){this.incomingMessageQueue.enqueue(e.data),this.queueRunning||this.runQueue()}},Bs=class{constructor(e,n,r,o){E(this,"relay");E(this,"id");E(this,"closed",!1);E(this,"eosed",!1);E(this,"filters");E(this,"alreadyHaveEvent");E(this,"receivedEvent");E(this,"onevent");E(this,"oneose");E(this,"onclose");E(this,"eoseTimeout");E(this,"eoseTimeoutHandle");this.relay=e,this.filters=r,this.id=n,this.alreadyHaveEvent=o.alreadyHaveEvent,this.receivedEvent=o.receivedEvent,this.eoseTimeout=o.eoseTimeout||e.baseEoseTimeout,this.oneose=o.oneose,this.onclose=o.onclose,this.onevent=o.onevent||(i=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,i)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){var e;this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,(e=this.oneose)==null||e.call(this))}close(e="closed by caller"){var n;!this.closed&&this.relay.connected&&(this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]"),this.closed=!0),this.relay.openSubs.delete(this.id),(n=this.onclose)==null||n.call(this,e)}},Is=class{constructor(e){E(this,"relays",new Map);E(this,"seenOn",new Map);E(this,"trackRelays",!1);E(this,"verifyEvent");E(this,"trustedRelayURLs",new Set);E(this,"_WebSocket");this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation}async ensureRelay(e,n){e=mt(e);let r=this.relays.get(e);return r||(r=new Lr(e,{verifyEvent:this.trustedRelayURLs.has(e)?As:this.verifyEvent,websocketImplementation:this._WebSocket}),n!=null&&n.connectionTimeout&&(r.connectionTimeout=n.connectionTimeout),this.relays.set(e,r)),await r.connect(),r}close(e){e.map(mt).forEach(n=>{var r;(r=this.relays.get(n))==null||r.close()})}subscribeMany(e,n,r){return this.subscribeManyMap(Object.fromEntries(e.map(o=>[o,n])),r)}subscribeManyMap(e,n){this.trackRelays&&(n.receivedEvent=(g,h)=>{let b=this.seenOn.get(h);b||(b=new Set,this.seenOn.set(h,b)),b.add(g)});const r=new Set,o=[],i=Object.keys(e).length,s=[];let a=g=>{var h;s[g]=!0,s.filter(b=>b).length===i&&((h=n.oneose)==null||h.call(n),a=()=>{})};const c=[];let l=(g,h)=>{var b;a(g),c[g]=h,c.filter(d=>d).length===i&&((b=n.onclose)==null||b.call(n,c),l=()=>{})};const f=g=>{var b;if((b=n.alreadyHaveEvent)!=null&&b.call(n,g))return!0;const h=r.has(g);return r.add(g),h},u=Promise.all(Object.entries(e).map(async(g,h,b)=>{if(b.indexOf(g)!==h){l(h,"duplicate url");return}let[d,p]=g;d=mt(d);let w;try{w=await this.ensureRelay(d,{connectionTimeout:n.maxWait?Math.max(n.maxWait*.8,n.maxWait-1e3):void 0})}catch(A){l(h,(A==null?void 0:A.message)||String(A));return}let y=w.subscribe(p,{...n,oneose:()=>a(h),onclose:A=>l(h,A),alreadyHaveEvent:f,eoseTimeout:n.maxWait});o.push(y)}));return{async close(){await u,o.forEach(g=>{g.close()})}}}subscribeManyEose(e,n,r){const o=this.subscribeMany(e,n,{...r,oneose(){o.close()}});return o}async querySync(e,n,r){return new Promise(async o=>{const i=[];this.subscribeManyEose(e,[n],{...r,onevent(s){i.push(s)},onclose(s){o(i)}})})}async get(e,n,r){n.limit=1;const o=await this.querySync(e,n,r);return o.sort((i,s)=>s.created_at-i.created_at),o[0]||null}publish(e,n){return e.map(mt).map(async(r,o,i)=>{if(i.indexOf(r)!==o)return Promise.reject("duplicate url");let s=await this.ensureRelay(r);return s.publish(n).then(a=>{if(this.trackRelays){let c=this.seenOn.get(n.id);c||(c=new Set,this.seenOn.set(n.id,c)),c.add(s)}return a})})}listConnectionStatus(){const e=new Map;return this.relays.forEach((n,r)=>e.set(r,n.connected)),e}destroy(){this.relays.forEach(e=>e.close()),this.relays=new Map}},Ur;try{Ur=WebSocket}catch{}var Os=class extends Is{constructor(){super({verifyEvent:ys,websocketImplementation:Ur})}};function An(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Hr(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function Ns(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Ee(t,...e){if(!Ns(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */const re=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function Ts(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function Cs(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}const Ps=(t,e)=>(Object.assign(e,t),e),Re=16,Ls=283;function Bn(t){return t<<1^Ls&-(t>>7)}function at(t,e){let n=0;for(;e>0;e>>=1)n^=t&-(e&1),t=Bn(t);return n}const In=(()=>{let t=new Uint8Array(256);for(let n=0,r=1;n<256;n++,r^=Bn(r))t[n]=r;const e=new Uint8Array(256);e[0]=99;for(let n=0;n<255;n++){let r=t[255-n];r|=r<<8,e[t[n]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return e})(),Us=In.map((t,e)=>In.indexOf(e)),Hs=t=>t<<24|t>>>8,On=t=>t<<8|t>>>24;function Rr(t,e){if(t.length!==256)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((l,f)=>e(t[f])),r=n.map(On),o=r.map(On),i=o.map(On),s=new Uint32Array(256*256),a=new Uint32Array(256*256),c=new Uint16Array(256*256);for(let l=0;l<256;l++)for(let f=0;f<256;f++){const u=l*256+f;s[u]=n[l]^r[f],a[u]=o[l]^i[f],c[u]=t[l]<<8|t[f]}return{sbox:t,sbox2:c,T0:n,T1:r,T2:o,T3:i,T01:s,T23:a}}const Nn=Rr(In,t=>at(t,3)<<24|t<<16|t<<8|at(t,2)),Mr=Rr(Us,t=>at(t,11)<<24|at(t,13)<<16|at(t,9)<<8|at(t,14)),Rs=(()=>{const t=new Uint8Array(16);for(let e=0,n=1;e<16;e++,n=Bn(n))t[e]=n;return t})();function qr(t){Ee(t);const e=t.length;if(![16,24,32].includes(e))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${e}`);const{sbox2:n}=Nn,r=re(t),o=r.length,i=a=>ve(n,a,a,a,a),s=new Uint32Array(e+28);s.set(r);for(let a=o;a<s.length;a++){let c=s[a-1];a%o===0?c=i(Hs(c))^Rs[a/o-1]:o>6&&a%o===4&&(c=i(c)),s[a]=s[a-o]^c}return s}function Ms(t){const e=qr(t),n=e.slice(),r=e.length,{sbox2:o}=Nn,{T0:i,T1:s,T2:a,T3:c}=Mr;for(let l=0;l<r;l+=4)for(let f=0;f<4;f++)n[l+f]=e[r-l-4+f];e.fill(0);for(let l=4;l<r-4;l++){const f=n[l],u=ve(o,f,f,f,f);n[l]=i[u&255]^s[u>>>8&255]^a[u>>>16&255]^c[u>>>24]}return n}function Me(t,e,n,r,o,i){return t[n<<8&65280|r>>>8&255]^e[o>>>8&65280|i>>>24&255]}function ve(t,e,n,r,o){return t[e&255|n&65280]|t[r>>>16&255|o>>>16&65280]<<16}function jr(t,e,n,r,o){const{sbox2:i,T01:s,T23:a}=Nn;let c=0;e^=t[c++],n^=t[c++],r^=t[c++],o^=t[c++];const l=t.length/4-2;for(let b=0;b<l;b++){const d=t[c++]^Me(s,a,e,n,r,o),p=t[c++]^Me(s,a,n,r,o,e),w=t[c++]^Me(s,a,r,o,e,n),y=t[c++]^Me(s,a,o,e,n,r);e=d,n=p,r=w,o=y}const f=t[c++]^ve(i,e,n,r,o),u=t[c++]^ve(i,n,r,o,e),g=t[c++]^ve(i,r,o,e,n),h=t[c++]^ve(i,o,e,n,r);return{s0:f,s1:u,s2:g,s3:h}}function qs(t,e,n,r,o){const{sbox2:i,T01:s,T23:a}=Mr;let c=0;e^=t[c++],n^=t[c++],r^=t[c++],o^=t[c++];const l=t.length/4-2;for(let b=0;b<l;b++){const d=t[c++]^Me(s,a,e,o,r,n),p=t[c++]^Me(s,a,n,e,o,r),w=t[c++]^Me(s,a,r,n,e,o),y=t[c++]^Me(s,a,o,r,n,e);e=d,n=p,r=w,o=y}const f=t[c++]^ve(i,e,o,r,n),u=t[c++]^ve(i,n,e,o,r),g=t[c++]^ve(i,r,n,e,o),h=t[c++]^ve(i,o,r,n,e);return{s0:f,s1:u,s2:g,s3:h}}function zr(t,e){if(!e)return new Uint8Array(t);if(Ee(e),e.length<t)throw new Error(`aes: wrong destination length, expected at least ${t}, got: ${e.length}`);return e}function js(t){if(Ee(t),t.length%Re!==0)throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${Re}`)}function zs(t,e,n){let r=t.length;const o=r%Re;if(!e&&o!==0)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const i=re(t);if(e){let c=Re-o;c||(c=Re),r=r+c}const s=zr(r,n),a=re(s);return{b:i,o:a,out:s}}function Ks(t,e){if(!e)return t;const n=t.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=t[n-1];if(r<=0||r>16)throw new Error(`aes/pcks5: wrong padding byte: ${r}`);const o=t.subarray(0,-r);for(let i=0;i<r;i++)if(t[n-i-1]!==r)throw new Error("aes/pcks5: wrong padding");return o}function $s(t){const e=new Uint8Array(16),n=re(e);e.set(t);const r=Re-t.length;for(let o=Re-r;o<Re;o++)e[o]=r;return n}const Kr=Ps({blockSize:16,nonceLength:16},function(e,n,r={}){Ee(e),Ee(n,16);const o=!r.disablePadding;return{encrypt:(i,s)=>{const a=qr(e),{b:c,o:l,out:f}=zs(i,o,s),u=re(n);let g=u[0],h=u[1],b=u[2],d=u[3],p=0;for(;p+4<=c.length;)g^=c[p+0],h^=c[p+1],b^=c[p+2],d^=c[p+3],{s0:g,s1:h,s2:b,s3:d}=jr(a,g,h,b,d),l[p++]=g,l[p++]=h,l[p++]=b,l[p++]=d;if(o){const w=$s(i.subarray(p*4));g^=w[0],h^=w[1],b^=w[2],d^=w[3],{s0:g,s1:h,s2:b,s3:d}=jr(a,g,h,b,d),l[p++]=g,l[p++]=h,l[p++]=b,l[p++]=d}return a.fill(0),f},decrypt:(i,s)=>{js(i);const a=Ms(e),c=re(n),l=zr(i.length,s),f=re(i),u=re(l);let g=c[0],h=c[1],b=c[2],d=c[3];for(let p=0;p+4<=f.length;){const w=g,y=h,A=b,N=d;g=f[p+0],h=f[p+1],b=f[p+2],d=f[p+3];const{s0:U,s1:k,s2:v,s3:m}=qs(a,g,h,b,d);u[p++]=U^w,u[p++]=k^y,u[p++]=v^A,u[p++]=m^N}return a.fill(0),Ks(l,o)}}});/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function lt(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function _e(...t){const e=(o,i)=>s=>o(i(s)),n=Array.from(t).reverse().reduce((o,i)=>o?e(o,i.encode):i.encode,void 0),r=t.reduce((o,i)=>o?e(o,i.decode):i.decode,void 0);return{encode:n,decode:r}}function ke(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return e.map(n=>{if(lt(n),n<0||n>=t.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${t.length})`);return t[n]})},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("alphabet.decode input should be array of strings");return e.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=t.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${t}`);return r})}}}function Se(t=""){if(typeof t!="string")throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of e)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return e.join(t)},decode:e=>{if(typeof e!="string")throw new Error("join.decode input should be string");return e.split(t)}}}function Mt(t,e="="){if(lt(t),typeof e!="string")throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let r of n)if(typeof r!="string")throw new Error(`padding.encode: non-string input=${r}`);for(;n.length*t%8;)n.push(e);return n},decode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let o of n)if(typeof o!="string")throw new Error(`padding.decode: non-string input=${o}`);let r=n.length;if(r*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--)if(!((r-1)*t%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function $r(t){if(typeof t!="function")throw new Error("normalize fn should be function");return{encode:e=>e,decode:e=>t(e)}}function Dr(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let r=0;const o=[],i=Array.from(t);for(i.forEach(s=>{if(lt(s),s<0||s>=e)throw new Error(`Wrong integer: ${s}`)});;){let s=0,a=!0;for(let c=r;c<i.length;c++){const l=i[c],f=e*s+l;if(!Number.isSafeInteger(f)||e*s/e!==s||f-l!==e*s)throw new Error("convertRadix: carry overflow");if(s=f%n,i[c]=Math.floor(f/n),!Number.isSafeInteger(i[c])||i[c]*n+s!==f)throw new Error("convertRadix: carry overflow");if(a)i[c]?a=!1:r=c;else continue}if(o.push(s),a)break}for(let s=0;s<t.length-1&&t[s]===0;s++)o.push(0);return o.reverse()}const Wr=(t,e)=>e?Wr(e,t%e):t,qt=(t,e)=>t+(e-Wr(t,e));function Tn(t,e,n,r){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(qt(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${qt(e,n)}`);let o=0,i=0;const s=2**n-1,a=[];for(const c of t){if(lt(c),c>=2**e)throw new Error(`convertRadix2: invalid data word=${c} from=${e}`);if(o=o<<e|c,i+e>32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${e}`);for(i+=e;i>=n;i-=n)a.push((o>>i-n&s)>>>0);o&=2**i-1}if(o=o<<n-i&s,!r&&i>=e)throw new Error("Excess padding");if(!r&&o)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&a.push(o>>>0),a}function Ds(t){return lt(t),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Dr(Array.from(e),2**8,t)},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("radix.decode input should be array of strings");return Uint8Array.from(Dr(e,t,2**8))}}}function qe(t,e=!1){if(lt(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(qt(8,t)>32||qt(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return Tn(Array.from(n),8,t,!e)},decode:n=>{if(!Array.isArray(n)||n.length&&typeof n[0]!="number")throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(Tn(n,t,8,e))}}}function Vr(t){if(typeof t!="function")throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch{}}}const Ws=_e(qe(4),ke("0123456789ABCDEF"),Se("")),Vs=_e(qe(5),ke("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Mt(5),Se(""));_e(qe(5),ke("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Mt(5),Se("")),_e(qe(5),ke("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Se(""),$r(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const ut=_e(qe(6),ke("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Mt(6),Se("")),Fs=_e(qe(6),ke("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Mt(6),Se("")),Cn=t=>_e(Ds(58),ke(t),Se("")),Pn=Cn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");Cn("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),Cn("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const Fr=[0,2,3,5,6,7,9,10,11],Ys={encode(t){let e="";for(let n=0;n<t.length;n+=8){const r=t.subarray(n,n+8);e+=Pn.encode(r).padStart(Fr[r.length],"1")}return e},decode(t){let e=[];for(let n=0;n<t.length;n+=11){const r=t.slice(n,n+11),o=Fr.indexOf(r.length),i=Pn.decode(r);for(let s=0;s<i.length-o;s++)if(i[s]!==0)throw new Error("base58xmr: wrong padding");e=e.concat(Array.from(i.slice(i.length-o)))}return Uint8Array.from(e)}},Ln=_e(ke("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Se("")),Yr=[996825010,642813549,513874426,1027748829,705979059];function vt(t){const e=t>>25;let n=(t&33554431)<<5;for(let r=0;r<Yr.length;r++)(e>>r&1)===1&&(n^=Yr[r]);return n}function Gr(t,e,n=1){const r=t.length;let o=1;for(let i=0;i<r;i++){const s=t.charCodeAt(i);if(s<33||s>126)throw new Error(`Invalid prefix (${t})`);o=vt(o)^s>>5}o=vt(o);for(let i=0;i<r;i++)o=vt(o)^t.charCodeAt(i)&31;for(let i of e)o=vt(o)^i;for(let i=0;i<6;i++)o=vt(o);return o^=n,Ln.encode(Tn([o%2**30],30,5,!1))}function Zr(t){const e=t==="bech32"?1:734539939,n=qe(5),r=n.decode,o=n.encode,i=Vr(r);function s(f,u,g=90){if(typeof f!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof f}`);if(!Array.isArray(u)||u.length&&typeof u[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof u}`);const h=f.length+7+u.length;if(g!==!1&&h>g)throw new TypeError(`Length ${h} exceeds limit ${g}`);return f=f.toLowerCase(),`${f}1${Ln.encode(u)}${Gr(f,u,e)}`}function a(f,u=90){if(typeof f!="string")throw new Error(`bech32.decode input should be string, not ${typeof f}`);if(f.length<8||u!==!1&&f.length>u)throw new TypeError(`Wrong string length: ${f.length} (${f}). Expected (8..${u})`);const g=f.toLowerCase();if(f!==g&&f!==f.toUpperCase())throw new Error("String must be lowercase or uppercase");f=g;const h=f.lastIndexOf("1");if(h===0||h===-1)throw new Error('Letter "1" must be present between prefix and data only');const b=f.slice(0,h),d=f.slice(h+1);if(d.length<6)throw new Error("Data must be at least 6 characters long");const p=Ln.decode(d).slice(0,-6),w=Gr(b,p,e);if(!d.endsWith(w))throw new Error(`Invalid checksum in ${f}: expected "${w}"`);return{prefix:b,words:p}}const c=Vr(a);function l(f){const{prefix:u,words:g}=a(f,!1);return{prefix:u,words:g,bytes:r(g)}}return{encode:s,decode:a,decodeToBytes:l,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:i,toWords:o}}const Jr=Zr("bech32");Zr("bech32m");const Gs={encode:t=>new TextDecoder().decode(t),decode:t=>new TextEncoder().encode(t)},Zs=_e(qe(4),ke("0123456789abcdef"),Se(""),$r(t=>{if(typeof t!="string"||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()}));`${Object.keys({utf8:Gs,hex:Zs,base16:Ws,base32:Vs,base64:ut,base64url:Fs,base58:Pn,base58xmr:Ys}).join(", ")}`;const Qr=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),Js=Qr("expand 16-byte k"),Qs=Qr("expand 32-byte k"),Xs=re(Js),Xr=re(Qs);Xr.slice();function F(t,e){return t<<e|t>>>32-e}function Un(t){return t.byteOffset%4===0}const jt=64,ec=16,eo=2**32-1,to=new Uint32Array;function tc(t,e,n,r,o,i,s,a){const c=o.length,l=new Uint8Array(jt),f=re(l),u=Un(o)&&Un(i),g=u?re(o):to,h=u?re(i):to;for(let b=0;b<c;s++){if(t(e,n,r,f,s,a),s>=eo)throw new Error("arx: counter overflow");const d=Math.min(jt,c-b);if(u&&d===jt){const p=b/4;if(b%4!==0)throw new Error("arx: invalid block position");for(let w=0,y;w<ec;w++)y=p+w,h[y]=g[y]^f[w];b+=jt;continue}for(let p=0,w;p<d;p++)w=b+p,i[w]=o[w]^l[p];b+=d}}function nc(t,e){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:i,rounds:s}=Ts({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return An(o),An(s),Hr(i),Hr(n),(a,c,l,f,u=0)=>{Ee(a),Ee(c),Ee(l);const g=l.length;if(f||(f=new Uint8Array(g)),Ee(f),An(u),u<0||u>=eo)throw new Error("arx: counter overflow");if(f.length<g)throw new Error(`arx: output (${f.length}) is shorter than data (${g})`);const h=[];let b=a.length,d,p;if(b===32)d=a.slice(),h.push(d),p=Xr;else if(b===16&&n)d=new Uint8Array(32),d.set(a),d.set(a,16),p=Xs,h.push(d);else throw new Error(`arx: invalid 32-byte key, got length=${b}`);Un(c)||(c=c.slice(),h.push(c));const w=re(d);if(r){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(p,w,re(c.subarray(0,16)),w),c=c.subarray(16)}const y=16-o;if(y!==c.length)throw new Error(`arx: nonce must be ${y} or 16 bytes`);if(y!==12){const N=new Uint8Array(12);N.set(c,i?0:12-c.length),c=N,h.push(c)}const A=re(c);for(tc(t,p,w,A,l,f,u,s);h.length>0;)h.pop().fill(0);return f}}function rc(t,e,n,r,o,i=20){let s=t[0],a=t[1],c=t[2],l=t[3],f=e[0],u=e[1],g=e[2],h=e[3],b=e[4],d=e[5],p=e[6],w=e[7],y=o,A=n[0],N=n[1],U=n[2],k=s,v=a,m=c,S=l,T=f,P=u,D=g,$=h,W=b,_=d,I=p,L=w,M=y,R=A,z=N,Y=U;for(let se=0;se<i;se+=2)k=k+T|0,M=F(M^k,16),W=W+M|0,T=F(T^W,12),k=k+T|0,M=F(M^k,8),W=W+M|0,T=F(T^W,7),v=v+P|0,R=F(R^v,16),_=_+R|0,P=F(P^_,12),v=v+P|0,R=F(R^v,8),_=_+R|0,P=F(P^_,7),m=m+D|0,z=F(z^m,16),I=I+z|0,D=F(D^I,12),m=m+D|0,z=F(z^m,8),I=I+z|0,D=F(D^I,7),S=S+$|0,Y=F(Y^S,16),L=L+Y|0,$=F($^L,12),S=S+$|0,Y=F(Y^S,8),L=L+Y|0,$=F($^L,7),k=k+P|0,Y=F(Y^k,16),I=I+Y|0,P=F(P^I,12),k=k+P|0,Y=F(Y^k,8),I=I+Y|0,P=F(P^I,7),v=v+D|0,M=F(M^v,16),L=L+M|0,D=F(D^L,12),v=v+D|0,M=F(M^v,8),L=L+M|0,D=F(D^L,7),m=m+$|0,R=F(R^m,16),W=W+R|0,$=F($^W,12),m=m+$|0,R=F(R^m,8),W=W+R|0,$=F($^W,7),S=S+T|0,z=F(z^S,16),_=_+z|0,T=F(T^_,12),S=S+T|0,z=F(z^S,8),_=_+z|0,T=F(T^_,7);let K=0;r[K++]=s+k|0,r[K++]=a+v|0,r[K++]=c+m|0,r[K++]=l+S|0,r[K++]=f+T|0,r[K++]=u+P|0,r[K++]=g+D|0,r[K++]=h+$|0,r[K++]=b+W|0,r[K++]=d+_|0,r[K++]=p+I|0,r[K++]=w+L|0,r[K++]=y+M|0,r[K++]=A+R|0,r[K++]=N+z|0,r[K++]=U+Y|0}const oc=nc(rc,{counterRight:!1,counterLength:4,allowShortKeys:!1});class no extends rr{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,me.hash(e);const r=bt(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(r.length>o?e.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return me.exists(this),this.iHash.update(e),this}digestInto(e){me.exists(this),me.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const zt=(t,e,n)=>new no(t,e).update(n).digest();zt.create=(t,e)=>new no(t,e);function ic(t,e,n){return me.hash(t),zt(t,bt(n),bt(e))}const Hn=new Uint8Array([0]),ro=new Uint8Array;function sc(t,e,n,r=32){if(me.hash(t),me.number(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/t.outputLen);n===void 0&&(n=ro);const i=new Uint8Array(o*t.outputLen),s=zt.create(t,e),a=s._cloneInto(),c=new Uint8Array(s.outputLen);for(let l=0;l<o;l++)Hn[0]=l+1,a.update(l===0?ro:c).update(n).update(Hn).digestInto(c),i.set(c,t.outputLen*l),s._cloneInto(a);return s.destroy(),a.destroy(),c.fill(0),Hn.fill(0),i.slice(0,r)}var Ge=Symbol("verified"),cc=t=>t instanceof Object;function ac(t){if(!cc(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]=="object")return!1}return!0}var oo=new TextDecoder("utf-8"),io=new TextEncoder;function xt(t){t.indexOf("://")===-1&&(t="wss://"+t);let e=new URL(t);return e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}var lc=class{constructor(t){E(this,"value");E(this,"next",null);E(this,"prev",null);this.value=t}},uc=class{constructor(){E(this,"first");E(this,"last");this.first=null,this.last=null}enqueue(t){const e=new lc(t);return this.last?this.last===this.first?(this.last=e,this.last.prev=this.first,this.first.next=e):(e.prev=this.last,this.last.next=e,this.last=e):(this.first=e,this.last=e),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const e=this.first;return this.first=null,this.last=null,e.value}const t=this.first;return this.first=t.next,t.value}},fc=class{generateSecretKey(){return ie.utils.randomPrivateKey()}getPublicKey(t){return oe(ie.getPublicKey(t))}finalizeEvent(t,e){const n=t;return n.pubkey=oe(ie.getPublicKey(e)),n.id=Rn(n),n.sig=oe(ie.sign(Rn(n),e)),n[Ge]=!0,n}verifyEvent(t){if(typeof t[Ge]=="boolean")return t[Ge];const e=Rn(t);if(e!==t.id)return t[Ge]=!1,!1;try{const n=ie.verify(t.sig,e,t.pubkey);return t[Ge]=n,n}catch{return t[Ge]=!1,!1}}};function dc(t){if(!ac(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}function Rn(t){let e=st(io.encode(dc(t)));return oe(e)}var Kt=new fc,hc=Kt.generateSecretKey,gc=Kt.getPublicKey,pc=Kt.finalizeEvent,so=Kt.verifyEvent;async function bc(t,e,n){const r=t instanceof Uint8Array?oe(t):t,o=it.getSharedSecret(r,"02"+e),i=co(o);let s=Uint8Array.from(ri(16)),a=io.encode(n),c=Kr(i,s).encrypt(a),l=ut.encode(new Uint8Array(c)),f=ut.encode(new Uint8Array(s.buffer));return`${l}?iv=${f}`}async function wc(t,e,n){const r=t instanceof Uint8Array?oe(t):t;let[o,i]=n.split("?iv="),s=it.getSharedSecret(r,"02"+e),a=co(s),c=ut.decode(i),l=ut.decode(o),f=Kr(a,c).decrypt(l);return oo.decode(f)}function co(t){return t.slice(1,33)}var yc=1,mc=65535;function vc(t,e){const n=it.getSharedSecret(t,"02"+e).subarray(1,33);return ic(st,n,"nip44-v2")}function xc(t,e){const n=sc(st,t,e,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function Ec(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("expected positive integer");if(t<=32)return 32;const e=1<<Math.floor(Math.log2(t-1))+1,n=e<=256?32:e/8;return n*(Math.floor((t-1)/n)+1)}function _c(t){const e=new DataView(t.buffer).getUint16(0),n=t.subarray(2,2+e);if(e<yc||e>mc||n.length!==e||t.length!==2+Ec(e))throw new Error("invalid padding");return oo.decode(n)}function kc(t,e,n){if(n.length!==32)throw new Error("AAD associated data must be 32 bytes");const r=ni(n,e);return zt(st,t,r)}function Sc(t){if(typeof t!="string")throw new Error("payload must be a valid string");const e=t.length;if(e<132||e>87472)throw new Error("invalid payload length: "+e);if(t[0]==="#")throw new Error("unknown encryption version");let n;try{n=ut.decode(t)}catch(i){throw new Error("invalid base64: "+i.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const o=n[0];if(o!==2)throw new Error("unknown encryption version "+o);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}function Ac(t,e){const{nonce:n,ciphertext:r,mac:o}=Sc(t),{chacha_key:i,chacha_nonce:s,hmac_key:a}=xc(e,n),c=kc(a,r,n);if(!Cs(c,o))throw new Error("invalid MAC");const l=oc(i,s,r);return _c(l)}var Bc=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,Ic;try{Ic=fetch}catch{}var Oc=22242,Mn=24133,Nc=31990;function Tc(t,e){if(t.ids&&t.ids.indexOf(e.id)===-1||t.kinds&&t.kinds.indexOf(e.kind)===-1||t.authors&&t.authors.indexOf(e.pubkey)===-1)return!1;for(let n in t)if(n[0]==="#"){let r=n.slice(1),o=t[`#${r}`];if(o&&!e.tags.find(([i,s])=>i===n.slice(1)&&o.indexOf(s)!==-1))return!1}return!(t.since&&e.created_at<t.since||t.until&&e.created_at>t.until)}function Cc(t,e){for(let n=0;n<t.length;n++)if(Tc(t[n],e))return!0;return!1}function Pc(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,o=t.slice(r).indexOf('"')+r+1;return t.slice(o,o+64)}function Lc(t){let e=t.slice(0,22).indexOf('"EVENT"');if(e===-1)return null;let n=t.slice(e+7+1).indexOf('"');if(n===-1)return null;let r=e+7+1+n,o=t.slice(r+1,80).indexOf('"');if(o===-1)return null;let i=r+1+o;return t.slice(r+1,i)}function Uc(t,e){return{kind:Oc,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}async function Hc(){return new Promise(t=>{const e=new MessageChannel,n=()=>{e.port1.removeEventListener("message",n),t()};e.port1.addEventListener("message",n),e.port2.postMessage(0),e.port1.start()})}var Rc=t=>(t[Ge]=!0,!0),ao=class{constructor(t,e){E(this,"url");E(this,"_connected",!1);E(this,"onclose",null);E(this,"onnotice",t=>console.debug(`NOTICE from ${this.url}: ${t}`));E(this,"_onauth",null);E(this,"baseEoseTimeout",4400);E(this,"connectionTimeout",4400);E(this,"openSubs",new Map);E(this,"connectionTimeoutHandle");E(this,"connectionPromise");E(this,"openCountRequests",new Map);E(this,"openEventPublishes",new Map);E(this,"ws");E(this,"incomingMessageQueue",new uc);E(this,"queueRunning",!1);E(this,"challenge");E(this,"serial",0);E(this,"verifyEvent");E(this,"_WebSocket");this.url=xt(t),this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation||WebSocket}static async connect(t,e){const n=new ao(t,e);return await n.connect(),n}closeAllSubscriptions(t){for(let[e,n]of this.openSubs)n.close(t);this.openSubs.clear();for(let[e,n]of this.openEventPublishes)n.reject(new Error(t));this.openEventPublishes.clear();for(let[e,n]of this.openCountRequests)n.reject(new Error(t));this.openCountRequests.clear()}get connected(){return this._connected}async connect(){return this.connectionPromise?this.connectionPromise:(this.challenge=void 0,this.connectionPromise=new Promise((t,e)=>{this.connectionTimeoutHandle=setTimeout(()=>{var n;e("connection timed out"),this.connectionPromise=void 0,(n=this.onclose)==null||n.call(this),this.closeAllSubscriptions("relay connection timed out")},this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(n){e(n);return}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,t()},this.ws.onerror=n=>{var r;e(n.message||"websocket error"),this._connected&&(this._connected=!1,this.connectionPromise=void 0,(r=this.onclose)==null||r.call(this),this.closeAllSubscriptions("relay connection errored"))},this.ws.onclose=async()=>{var n;this._connected&&(this._connected=!1,this.connectionPromise=void 0,(n=this.onclose)==null||n.call(this),this.closeAllSubscriptions("relay connection closed"))},this.ws.onmessage=this._onmessage.bind(this)}),this.connectionPromise)}async runQueue(){for(this.queueRunning=!0;this.handleNext()!==!1;)await Hc();this.queueRunning=!1}handleNext(){var n,r,o;const t=this.incomingMessageQueue.dequeue();if(!t)return!1;const e=Lc(t);if(e){const i=this.openSubs.get(e);if(!i)return;const s=Pc(t,"id"),a=(n=i.alreadyHaveEvent)==null?void 0:n.call(i,s);if((r=i.receivedEvent)==null||r.call(i,this,s),a)return}try{let i=JSON.parse(t);switch(i[0]){case"EVENT":{const s=this.openSubs.get(i[1]),a=i[2];this.verifyEvent(a)&&Cc(s.filters,a)&&s.onevent(a);return}case"COUNT":{const s=i[1],a=i[2],c=this.openCountRequests.get(s);c&&(c.resolve(a.count),this.openCountRequests.delete(s));return}case"EOSE":{const s=this.openSubs.get(i[1]);if(!s)return;s.receivedEose();return}case"OK":{const s=i[1],a=i[2],c=i[3],l=this.openEventPublishes.get(s);a?l.resolve(c):l.reject(new Error(c)),this.openEventPublishes.delete(s);return}case"CLOSED":{const s=i[1],a=this.openSubs.get(s);if(!a)return;a.closed=!0,a.close(i[2]);return}case"NOTICE":this.onnotice(i[1]);return;case"AUTH":{this.challenge=i[1],(o=this._onauth)==null||o.call(this,i[1]);return}}}catch{return}}async send(t){if(!this.connectionPromise)throw new Error("sending on closed connection");this.connectionPromise.then(()=>{var e;(e=this.ws)==null||e.send(t)})}async auth(t){if(!this.challenge)throw new Error("can't perform auth, no challenge was received");const e=await t(Uc(this.url,this.challenge)),n=new Promise((r,o)=>{this.openEventPublishes.set(e.id,{resolve:r,reject:o})});return this.send('["AUTH",'+JSON.stringify(e)+"]"),n}async publish(t){const e=new Promise((n,r)=>{this.openEventPublishes.set(t.id,{resolve:n,reject:r})});return this.send('["EVENT",'+JSON.stringify(t)+"]"),e}async count(t,e){this.serial++;const n=(e==null?void 0:e.id)||"count:"+this.serial,r=new Promise((o,i)=>{this.openCountRequests.set(n,{resolve:o,reject:i})});return this.send('["COUNT","'+n+'",'+JSON.stringify(t).substring(1)),r}subscribe(t,e){const n=this.prepareSubscription(t,e);return n.fire(),n}prepareSubscription(t,e){this.serial++;const n=e.id||"sub:"+this.serial,r=new Mc(this,n,t,e);return this.openSubs.set(n,r),r}close(){var t;this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,(t=this.ws)==null||t.close()}_onmessage(t){this.incomingMessageQueue.enqueue(t.data),this.queueRunning||this.runQueue()}},Mc=class{constructor(t,e,n,r){E(this,"relay");E(this,"id");E(this,"closed",!1);E(this,"eosed",!1);E(this,"filters");E(this,"alreadyHaveEvent");E(this,"receivedEvent");E(this,"onevent");E(this,"oneose");E(this,"onclose");E(this,"eoseTimeout");E(this,"eoseTimeoutHandle");this.relay=t,this.filters=n,this.id=e,this.alreadyHaveEvent=r.alreadyHaveEvent,this.receivedEvent=r.receivedEvent,this.eoseTimeout=r.eoseTimeout||t.baseEoseTimeout,this.oneose=r.oneose,this.onclose=r.onclose,this.onevent=r.onevent||(o=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,o)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){var t;this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,(t=this.oneose)==null||t.call(this))}close(t="closed by caller"){var e;!this.closed&&this.relay.connected&&(this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]"),this.closed=!0),this.relay.openSubs.delete(this.id),(e=this.onclose)==null||e.call(this,t)}},qc=class{constructor(t){E(this,"relays",new Map);E(this,"seenOn",new Map);E(this,"trackRelays",!1);E(this,"verifyEvent");E(this,"trustedRelayURLs",new Set);E(this,"_WebSocket");this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation}async ensureRelay(t,e){t=xt(t);let n=this.relays.get(t);return n||(n=new ao(t,{verifyEvent:this.trustedRelayURLs.has(t)?Rc:this.verifyEvent,websocketImplementation:this._WebSocket}),e!=null&&e.connectionTimeout&&(n.connectionTimeout=e.connectionTimeout),this.relays.set(t,n)),await n.connect(),n}close(t){t.map(xt).forEach(e=>{var n;(n=this.relays.get(e))==null||n.close()})}subscribeMany(t,e,n){return this.subscribeManyMap(Object.fromEntries(t.map(r=>[r,e])),n)}subscribeManyMap(t,e){this.trackRelays&&(e.receivedEvent=(u,g)=>{let h=this.seenOn.get(g);h||(h=new Set,this.seenOn.set(g,h)),h.add(u)});const n=new Set,r=[],o=Object.keys(t).length,i=[];let s=u=>{var g;i[u]=!0,i.filter(h=>h).length===o&&((g=e.oneose)==null||g.call(e),s=()=>{})};const a=[];let c=(u,g)=>{var h;s(u),a[u]=g,a.filter(b=>b).length===o&&((h=e.onclose)==null||h.call(e,a),c=()=>{})};const l=u=>{var h;if((h=e.alreadyHaveEvent)!=null&&h.call(e,u))return!0;const g=n.has(u);return n.add(u),g},f=Promise.all(Object.entries(t).map(async(u,g,h)=>{if(h.indexOf(u)!==g){c(g,"duplicate url");return}let[b,d]=u;b=xt(b);let p;try{p=await this.ensureRelay(b,{connectionTimeout:e.maxWait?Math.max(e.maxWait*.8,e.maxWait-1e3):void 0})}catch(y){c(g,(y==null?void 0:y.message)||String(y));return}let w=p.subscribe(d,{...e,oneose:()=>s(g),onclose:y=>c(g,y),alreadyHaveEvent:l,eoseTimeout:e.maxWait});r.push(w)}));return{async close(){await f,r.forEach(u=>{u.close()})}}}subscribeManyEose(t,e,n){const r=this.subscribeMany(t,e,{...n,oneose(){r.close()}});return r}async querySync(t,e,n){return new Promise(async r=>{const o=[];this.subscribeManyEose(t,[e],{...n,onevent(i){o.push(i)},onclose(i){r(o)}})})}async get(t,e,n){e.limit=1;const r=await this.querySync(t,e,n);return r.sort((o,i)=>i.created_at-o.created_at),r[0]||null}publish(t,e){return t.map(xt).map(async(n,r,o)=>{if(o.indexOf(n)!==r)return Promise.reject("duplicate url");let i=await this.ensureRelay(n);return i.publish(e).then(s=>{if(this.trackRelays){let a=this.seenOn.get(e.id);a||(a=new Set,this.seenOn.set(e.id,a)),a.add(i)}return s})})}listConnectionStatus(){const t=new Map;return this.relays.forEach((e,n)=>t.set(n,e.connected)),t}destroy(){this.relays.forEach(t=>t.close()),this.relays=new Map}},lo;try{lo=WebSocket}catch{}var jc=class extends qc{constructor(){super({verifyEvent:so,websocketImplementation:lo})}},uo;try{uo=fetch}catch{}var $t=/^bunker:\/\/([0-9a-f]{64})\??([?\/\w:.=&%-]*)$/;async function zc(t){let e=t.match($t);if(e)try{const n=e[1],r=new URLSearchParams(e[2]);return{pubkey:n,relays:r.getAll("relay"),secret:r.get("secret")}}catch{}return fo(t)}async function fo(t){const e=t.match(Bc);if(!e)return null;const[n,r="_",o]=e;try{const i=`https://${o}/.well-known/nostr.json?name=${r}`,s=await(await uo(i,{redirect:"error"})).json();let a=s.names[r],c=s.nip46[a]||[];return{pubkey:a,relays:c,secret:null}}catch{return null}}var ho=class{constructor(t,e,n={}){E(this,"pool");E(this,"subCloser");E(this,"isOpen");E(this,"serial");E(this,"idPrefix");E(this,"listeners");E(this,"waitingForAuth");E(this,"secretKey");E(this,"bp");E(this,"cachedPubKey");if(e.relays.length===0)throw new Error("no relays are specified for this bunker");this.pool=n.pool||new jc,this.secretKey=t,this.bp=e,this.isOpen=!1,this.idPrefix=Math.random().toString(36).substring(7),this.serial=0,this.listeners={},this.waitingForAuth={};const r=this.listeners,o=this.waitingForAuth,i=this.secretKey;this.subCloser=this.pool.subscribeMany(this.bp.relays,[{kinds:[Mn],"#p":[gc(this.secretKey)]}],{async onevent(s){let a;try{a=JSON.parse(await wc(t,s.pubkey,s.content))}catch{a=JSON.parse(Ac(s.content,vc(i,s.pubkey)))}const{id:c,result:l,error:f}=a;if(l==="auth_url"&&o[c]){delete o[c],n.onauth?n.onauth(f):console.warn(`nostr-tools/nip46: remote signer ${e.pubkey} tried to send an "auth_url"='${f}' but there was no onauth() callback configured.`);return}let u=r[c];u&&(f?u.reject(f):l&&u.resolve(l),delete r[c])}}),this.isOpen=!0}async close(){this.isOpen=!1,this.subCloser.close()}async sendRequest(t,e){return new Promise(async(n,r)=>{try{if(!this.isOpen)throw new Error("this signer is not open anymore, create a new one");this.serial++;const o=`${this.idPrefix}-${this.serial}`,i=await bc(this.secretKey,this.bp.pubkey,JSON.stringify({id:o,method:t,params:e})),s=pc({kind:Mn,tags:[["p",this.bp.pubkey]],content:i,created_at:Math.floor(Date.now()/1e3)},this.secretKey);this.listeners[o]={resolve:n,reject:r},this.waitingForAuth[o]=!0,await Promise.any(this.pool.publish(this.bp.relays,s))}catch(o){r(o)}})}async ping(){let t=await this.sendRequest("ping",[]);if(t!=="pong")throw new Error(`result is not pong: ${t}`)}async connect(){await this.sendRequest("connect",[this.bp.pubkey,this.bp.secret||""])}async getPublicKey(){return this.cachedPubKey||(this.cachedPubKey=await this.sendRequest("get_public_key",[])),this.cachedPubKey}async getRelays(){return JSON.parse(await this.sendRequest("get_relays",[]))}async signEvent(t){let e=await this.sendRequest("sign_event",[JSON.stringify(t)]),n=JSON.parse(e);if(n.pubkey===this.bp.pubkey&&so(n))return n;throw new Error(`event returned from bunker is improperly signed: ${JSON.stringify(n)}`)}async nip04Encrypt(t,e){return await this.sendRequest("nip04_encrypt",[t,e])}async nip04Decrypt(t,e){return await this.sendRequest("nip04_decrypt",[t,e])}async nip44GetKey(t){let e=await this.sendRequest("nip44_get_key",[t]);return rn(e)}async nip44Encrypt(t,e){return await this.sendRequest("nip44_encrypt",[t,e])}async nip44Decrypt(t,e){return await this.sendRequest("nip44_decrypt",[t,e])}};async function Kc(t,e,n,r,o,i=hc()){let s=new ho(i,t.bunkerPointer,e),a=await s.sendRequest("create_account",[n,r,""]);return s.bp.pubkey=a,await s.connect(),s}async function $c(t,e){const n=await t.querySync(e,{kinds:[Nc],"#k":[Mn.toString()]});return n.sort((o,i)=>i.created_at-o.created_at),(await Promise.all(n.map(async(o,i)=>{try{const s=JSON.parse(o.content);try{if(n.findIndex(c=>JSON.parse(c.content).nip05===s.nip05)!==i)return}catch{}const a=await fo(s.nip05);if(a&&a.pubkey===o.pubkey&&a.relays.length)return{bunkerPointer:a,nip05:s.nip05,domain:s.nip05.split("@")[1],name:s.name||s.display_name,picture:s.picture,about:s.about,website:s.website,local:!1}}catch{return}}))).filter(o=>o!==void 0)}var go=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,po;try{po=fetch}catch{}async function Dc(t){var i;const e=t.match(go);if(!e)return null;const[n,r="_",o]=e;try{const s=`https://${o}/.well-known/nostr.json?name=${r}`,a=await(await po(s,{redirect:"error"})).json();let c=a.names[r];return c?{pubkey:c,relays:(i=a.relays)==null?void 0:i[c]}:null}catch{return null}}new TextDecoder("utf-8"),new TextEncoder;var Wc=5e3;function Vc(t){return Yc("npub",rn(t))}function Fc(t,e){let n=Jr.toWords(e);return Jr.encode(t,n,Wc)}function Yc(t,e){return Fc(t,e)}const ft=[];function Gc(t,e=H){let n;const r=new Set;function o(a){if(Ft(t,a)&&(t=a,n)){const c=!ft.length;for(const l of r)l[1](),ft.push(l,t);if(c){for(let l=0;l<ft.length;l+=2)ft[l][0](ft[l+1]);ft.length=0}}}function i(a){o(a(t))}function s(a,c=H){const l=[a,c];return r.add(l),r.size===1&&(n=e(o,i)||H),a(t),()=>{r.delete(l),r.size===0&&n&&(n(),n=null)}}return{set:o,update:i,subscribe:s}}const Zc=t=>{const{subscribe:e,set:n}=Gc(void 0,()=>{const r=window.matchMedia(t);n(r.matches);const o=()=>n(r.matches);return r.addEventListener("change",o),()=>{r.removeEventListener("change",o)}});return{subscribe:e}};function Jc(t){let e,n,r;return{c(){e=Yt("svg"),n=Yt("circle"),r=Yt("path"),x(n,"class","opacity-25"),x(n,"cx","12"),x(n,"cy","12"),x(n,"r","10"),x(n,"stroke","currentColor"),x(n,"stroke-width","4"),x(r,"class","opacity-75"),x(r,"fill","currentColor"),x(r,"d","M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"),x(e,"class","ml-2 h-5 w-5 animate-spin text-white"),x(e,"xmlns","http://www.w3.org/2000/svg"),x(e,"fill","none"),x(e,"viewBox","0 0 24 24")},m(o,i){j(o,e,i),B(e,n),B(e,r)},p:H,i:H,o:H,d(o){o&&q(e)}}}class bo extends er{constructor(e){super(),Xn(this,e,null,Jc,Ft,{})}}const{window:qn}=jo;function wo(t,e,n){const r=t.slice();return r[78]=e[n],r}function Qc(t){let e,n,r,o,i,s,a,c,l,f,u,g,h=!t[20]&&!t[13]&&!t[14]&&!t[15]&&yo(t);const b=[ca,sa,ia,oa,ra,na,ta],d=[];function p(w,y){return w[13]?0:w[14]?1:w[15]?2:w[20]?3:w[17]?4:w[21]?6:5}return a=p(t),c=d[a]=b[a](t),{c(){e=C("div"),n=C("button"),r=V("⤫"),i=G(),h&&h.c(),s=G(),c.c(),x(n,"class",o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+t[0]+"-600"),x(e,"class",l="animate-show rounded-md bg-gradient-to-b px-8 py-8 shadow-[0_0px_30px_0px_rgba(0,0,0,0.6)] transition-all sm:w-96 from-"+t[0]+"-900 to-"+t[0]+"-700 "+t[27])},m(w,y){j(w,e,y),B(e,n),B(n,r),B(e,i),h&&h.m(e,null),B(e,s),d[a].m(e,null),f=!0,u||(g=X(n,"click",function(){Vt(t[20]?t[32]:t[30])&&(t[20]?t[32]:t[30]).apply(this,arguments)}),u=!0)},p(w,y){t=w,(!f||y[0]&1&&o!==(o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+t[0]+"-600"))&&x(n,"class",o),!t[20]&&!t[13]&&!t[14]&&!t[15]?h?h.p(t,y):(h=yo(t),h.c(),h.m(e,s)):h&&(h.d(1),h=null);let A=a;a=p(t),a===A?d[a].p(t,y):(At(),be(d[A],1,1,()=>{d[A]=null}),Bt(),c=d[a],c?c.p(t,y):(c=d[a]=b[a](t),c.c()),de(c,1),c.m(e,null)),(!f||y[0]&134217729&&l!==(l="animate-show rounded-md bg-gradient-to-b px-8 py-8 shadow-[0_0px_30px_0px_rgba(0,0,0,0.6)] transition-all sm:w-96 from-"+t[0]+"-900 to-"+t[0]+"-700 "+t[27]))&&x(e,"class",l)},i(w){f||(de(c),f=!0)},o(w){be(c),f=!1},d(w){w&&q(e),h&&h.d(),d[a].d(),u=!1,g()}}}function Xc(t){let e,n,r,o,i;const s=[ha,da,fa,ua],a=[];function c(l,f){return l[12]?0:l[21]?l[2]?3:2:1}return n=c(t),r=a[n]=s[n](t),{c(){e=C("div"),r.c(),x(e,"class",o="rounded px-2 py-2 shadow-[0_0px_10px_0px_rgba(0,0,0,0.3)] transition-all duration-200 bg-"+t[0]+"-700 hover:bg-"+t[0]+"-800 "+t[27])},m(l,f){j(l,e,f),a[n].m(e,null),i=!0},p(l,f){let u=n;n=c(l),n===u?a[n].p(l,f):(At(),be(a[u],1,1,()=>{a[u]=null}),Bt(),r=a[n],r?r.p(l,f):(r=a[n]=s[n](l),r.c()),de(r,1),r.m(e,null)),(!i||f[0]&134217729&&o!==(o="rounded px-2 py-2 shadow-[0_0px_10px_0px_rgba(0,0,0,0.3)] transition-all duration-200 bg-"+l[0]+"-700 hover:bg-"+l[0]+"-800 "+l[27]))&&x(e,"class",o)},i(l){i||(de(r),i=!0)},o(l){be(r),i=!1},d(l){l&&q(e),a[n].d()}}}function ea(t){return{c:H,m:H,p:H,i:H,o:H,d:H}}function yo(t){let e,n,r,o,i;return{c(){e=C("button"),n=V("?"),x(e,"class",r="absolute bottom-1 right-3 cursor-pointer bg-transparent text-xl text-"+t[0]+"-600")},m(s,a){j(s,e,a),B(e,n),o||(i=X(e,"click",t[31]),o=!0)},p(s,a){a[0]&1&&r!==(r="absolute bottom-1 right-3 cursor-pointer bg-transparent text-xl text-"+s[0]+"-600")&&x(e,"class",r)},d(s){s&&q(e),o=!1,i()}}}function ta(t){let e,n,r,o,i,s,a=t[21].npub+"",c,l,f,u,g,h,b,d,p,w,y,A=Pr(t[11])+"",N,U,k,v=(t[21].picture||t[21].name)&&mo(t);return{c(){e=C("div"),n=C("div"),n.textContent="You are connected to Nostr as",r=G(),o=C("a"),v&&v.c(),i=G(),s=C("div"),c=V(a),f=G(),u=C("button"),g=V("Disconnect"),b=G(),d=C("div"),p=V("This webpage is using the public key:"),w=C("br"),y=G(),N=V(A),x(n,"class","mb-4 text-sm"),x(s,"class","block break-all"),x(o,"target","_blank"),x(o,"href",l="https://nosta.me/"+t[21].npub),x(o,"class","group text-white no-underline"),x(e,"class","text-center"),x(u,"class",h="my-2 mt-6 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),x(d,"class","mt-6 block break-all text-center text-sm")},m(m,S){j(m,e,S),B(e,n),B(e,r),B(e,o),v&&v.m(o,null),B(o,i),B(o,s),B(s,c),j(m,f,S),j(m,u,S),B(u,g),j(m,b,S),j(m,d,S),B(d,p),B(d,w),B(d,y),B(d,N),U||(k=X(u,"click",t[34]),U=!0)},p(m,S){m[21].picture||m[21].name?v?v.p(m,S):(v=mo(m),v.c(),v.m(o,i)):v&&(v.d(1),v=null),S[0]&2097152&&a!==(a=m[21].npub+"")&&Te(c,a),S[0]&2097152&&l!==(l="https://nosta.me/"+m[21].npub)&&x(o,"href",l),S[0]&1&&h!==(h="my-2 mt-6 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white bg-"+m[0]+"-900 hover:bg-"+m[0]+"-950")&&x(u,"class",h),S[0]&2048&&A!==(A=Pr(m[11])+"")&&Te(N,A)},i:H,o:H,d(m){m&&(q(e),q(f),q(u),q(b),q(d)),v&&v.d(),U=!1,k()}}}function na(t){let e,n,r,o,i,s,a,c,l,f,u,g,h,b,d,p,w,y=t[19]&&Eo(t);const A=[la,aa],N=[];function U(m,S){return m[12]?0:1}c=U(t),l=N[c]=A[c](t);let k=t[12]&&t[16]&&_o(t),v=!t[12]&&ko(t);return{c(){e=C("div"),e.textContent="How do you want to connect to Nostr?",n=G(),r=C("form"),o=C("input"),i=G(),y&&y.c(),s=G(),a=C("button"),l.c(),g=G(),k&&k.c(),h=G(),v&&v.c(),b=Vn(),x(e,"class","text-center text-lg"),x(o,"class","box-border w-full rounded px-2 py-1 text-lg text-neutral-800 outline-none"),x(o,"placeholder","user@provider or bunker://..."),o.autofocus=!0,o.disabled=t[12],x(o,"autocapitalize","none"),x(a,"class",f="mt-4 flex w-full cursor-pointer items-center justify-center rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),a.disabled=u=!t[26]||t[12],x(r,"class","mb-1 mt-4 flex flex-col")},m(m,S){j(m,e,S),j(m,n,S),j(m,r,S),B(r,o),t[52](o),Xe(o,t[4]),B(r,i),y&&y.m(r,null),B(r,s),B(r,a),N[c].m(a,null),B(r,g),k&&k.m(r,null),j(m,h,S),v&&v.m(m,S),j(m,b,S),d=!0,o.focus(),p||(w=[X(o,"input",t[53]),X(r,"submit",t[33])],p=!0)},p(m,S){(!d||S[0]&4096)&&(o.disabled=m[12]),S[0]&16&&o.value!==m[4]&&Xe(o,m[4]),m[19]?y?y.p(m,S):(y=Eo(m),y.c(),y.m(r,s)):y&&(y.d(1),y=null);let T=c;c=U(m),c!==T&&(At(),be(N[T],1,1,()=>{N[T]=null}),Bt(),l=N[c],l||(l=N[c]=A[c](m),l.c()),de(l,1),l.m(a,null)),(!d||S[0]&1&&f!==(f="mt-4 flex w-full cursor-pointer items-center justify-center rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+m[0]+"-900 hover:bg-"+m[0]+"-950"))&&x(a,"class",f),(!d||S[0]&67112960&&u!==(u=!m[26]||m[12]))&&(a.disabled=u),m[12]&&m[16]?k?k.p(m,S):(k=_o(m),k.c(),k.m(r,null)):k&&(k.d(1),k=null),m[12]?v&&(v.d(1),v=null):v?v.p(m,S):(v=ko(m),v.c(),v.m(b.parentNode,b))},i(m){d||(de(l),d=!0)},o(m){be(l),d=!1},d(m){m&&(q(e),q(n),q(r),q(h),q(b)),t[52](null),y&&y.d(),N[c].d(),k&&k.d(),v&&v.d(m),p=!1,Ne(w)}}}function ra(t){let e,n,r,o,i,s,a,c,l,f,u,g,h,b,d,p,w,y,A,N,U,k,v=Jn(t[22]),m=[];for(let S=0;S<v.length;S+=1)m[S]=So(wo(t,v,S));return{c(){e=C("div"),e.textContent="Create a Nostr account",n=G(),r=C("form"),o=C("div"),i=C("input"),s=G(),a=C("div"),a.textContent="@",c=G(),l=C("select");for(let S=0;S<m.length;S+=1)m[S].c();f=G(),u=C("button"),g=V("Continue »"),d=G(),p=C("div"),w=V("Do you already have a Nostr address?"),y=C("br"),A=G(),N=C("button"),N.textContent="Login now",x(e,"class","text-center text-lg"),x(i,"class","box-border w-40 rounded px-2 py-1 text-lg text-neutral-800 outline-none"),x(i,"placeholder","bob"),i.autofocus=!0,x(i,"autocapitalize","none"),x(a,"class","mx-2 text-2xl"),x(l,"class","box-border w-full rounded px-2 py-1 text-lg text-neutral-800 outline-none"),t[10]===void 0&&kt(()=>t[51].call(l)),x(o,"class","flex flex-row"),x(u,"class",h="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),u.disabled=b=!t[10]||!t[9]||t[18],x(r,"class","mb-1 mt-4"),x(N,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),x(p,"class","mt-6 text-center text-sm leading-3")},m(S,T){j(S,e,T),j(S,n,T),j(S,r,T),B(r,o),B(o,i),t[49](i),Xe(i,t[9]),B(o,s),B(o,a),B(o,c),B(o,l);for(let P=0;P<m.length;P+=1)m[P]&&m[P].m(l,null);Fn(l,t[10],!0),B(r,f),B(r,u),B(u,g),j(S,d,T),j(S,p,T),B(p,w),B(p,y),B(p,A),B(p,N),i.focus(),U||(k=[X(i,"input",t[50]),X(i,"input",t[38]),X(l,"change",t[51]),X(r,"submit",t[37]),X(N,"click",t[36])],U=!0)},p(S,T){if(T[0]&512&&i.value!==S[9]&&Xe(i,S[9]),T[0]&4194304){v=Jn(S[22]);let P;for(P=0;P<v.length;P+=1){const D=wo(S,v,P);m[P]?m[P].p(D,T):(m[P]=So(D),m[P].c(),m[P].m(l,null))}for(;P<m.length;P+=1)m[P].d(1);m.length=v.length}T[0]&4195328&&Fn(l,S[10]),T[0]&1&&h!==(h="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+S[0]+"-900 hover:bg-"+S[0]+"-950")&&x(u,"class",h),T[0]&4457984&&b!==(b=!S[10]||!S[9]||S[18])&&(u.disabled=b)},i:H,o:H,d(S){S&&(q(e),q(n),q(r),q(d),q(p)),t[49](null),zo(m,S),U=!1,Ne(k)}}}function oa(t){let e,n,r;return{c(){e=C("div"),e.textContent="What is that?",n=G(),r=C("div"),r.innerHTML=`<p class="mb mt-4">This widget is created with <i>window.nostr.js</i>, a small script
2
2
  you can drop in any page that already uses NIP-07 and make it also
3
3
  work with NIP-46 automatically when the user doesn&#39;t have an
4
4
  extension installed.
5
5
  <br/>
6
6
  It adds a small floating button on the side of the window that users
7
7
  can use to create Nostr accuonts or connect to their NIP-46 bunkers.</p> <p class="mt-4">This tool is opensource, get the code from the <a target="_blank" class="underline" href="https://github.com/fiatjaf/window.nostr.js">project&#39;s page</a>.</p> <p class="mt-4">You don&#39;t know what Nostr is?
8
- <a target="_blank" class="underline" href="https://www.nostr.com">Learn more</a>.</p>`,k(e,"class","text-center text-lg"),k(r,"class","text-base leading-5")},m(o,i){K(o,e,i),K(o,n,i),K(o,r,i)},p:j,i:j,o:j,d(o){o&&(z(e),z(n),z(r))}}}function Ba(t){let e,n,r,o,i,s,c=new URL(t[17]).host+"",a,l,f,u,b,h,g,d,p,w;return{c(){e=P("div"),n=P("div"),n.textContent="An action requires your confirmation",r=Y(),o=P("div"),i=F("Now you a new window will bring you to "),s=P("strong"),a=F(c),l=F(`
8
+ <a target="_blank" class="underline" href="https://www.nostr.com">Learn more</a>.</p>`,x(e,"class","text-center text-lg"),x(r,"class","text-base leading-5")},m(o,i){j(o,e,i),j(o,n,i),j(o,r,i)},p:H,i:H,o:H,d(o){o&&(q(e),q(n),q(r))}}}function ia(t){let e,n,r,o,i,s,a=new URL(t[15]).host+"",c,l,f,u,g,h,b,d,p,w;return{c(){e=C("div"),n=C("div"),n.textContent="An action requires your confirmation",r=G(),o=C("div"),i=V("Now you a new window will bring you to "),s=C("strong"),c=V(a),l=V(`
9
9
  where you can approve the current action. If nothing happens check that
10
- if your browser is blocking popups, pleaase.`),f=P("br"),u=F(`
11
- After that you will be returned to this page.`),b=Y(),h=P("button"),g=F("Confirm action »"),k(n,"class","text-center text-lg"),k(o,"class","mt-4 text-center text-sm leading-4"),k(h,"class",d="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),k(e,"class","m-auto w-full")},m(m,S){K(m,e,S),O(e,n),O(e,r),O(e,o),O(o,i),O(o,s),O(s,a),O(o,l),O(o,f),O(o,u),O(e,b),O(e,h),O(h,g),p||(w=ne(h,"click",t[51]),p=!0)},p(m,S){S[0]&131072&&c!==(c=new URL(m[17]).host+"")&&He(a,c),S[0]&1&&d!==(d="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+m[0]+"-900 hover:bg-"+m[0]+"-950")&&k(h,"class",d)},i:j,o:j,d(m){m&&z(e),p=!1,w()}}}function Ia(t){let e,n,r,o,i,s,c=new URL(t[16]).host+"",a,l,f,u,b,h,g,d,p,w;return{c(){e=P("div"),n=P("div"),n.textContent="Login into a Nostr account",r=Y(),o=P("div"),i=F("Now you a new window will bring you to "),s=P("strong"),a=F(c),l=F(`
10
+ if your browser is blocking popups, pleaase.`),f=C("br"),u=V(`
11
+ After that you will be returned to this page.`),g=G(),h=C("button"),b=V("Confirm action »"),x(n,"class","text-center text-lg"),x(o,"class","mt-4 text-center text-sm leading-4"),x(h,"class",d="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),x(e,"class","m-auto w-full")},m(y,A){j(y,e,A),B(e,n),B(e,r),B(e,o),B(o,i),B(o,s),B(s,c),B(o,l),B(o,f),B(o,u),B(e,g),B(e,h),B(h,b),p||(w=X(h,"click",t[48]),p=!0)},p(y,A){A[0]&32768&&a!==(a=new URL(y[15]).host+"")&&Te(c,a),A[0]&1&&d!==(d="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+y[0]+"-900 hover:bg-"+y[0]+"-950")&&x(h,"class",d)},i:H,o:H,d(y){y&&q(e),p=!1,w()}}}function sa(t){let e,n,r,o,i,s,a=new URL(t[14]).host+"",c,l,f,u,g,h,b,d,p,w;return{c(){e=C("div"),n=C("div"),n.textContent="Login into a Nostr account",r=G(),o=C("div"),i=V("Now you a new window will bring you to "),s=C("strong"),c=V(a),l=V(`
12
12
  where you can login and approve the permissions. If nothing happens check
13
- that if your browser is blocking popups, pleaase.`),f=P("br"),u=F(`
14
- After that you will be returned to this page.`),b=Y(),h=P("button"),g=F("Login now »"),k(n,"class","text-center text-lg"),k(o,"class","mt-4 text-center text-sm leading-4"),k(h,"class",d="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),k(e,"class","m-auto w-full")},m(m,S){K(m,e,S),O(e,n),O(e,r),O(e,o),O(o,i),O(o,s),O(s,a),O(o,l),O(o,f),O(o,u),O(e,b),O(e,h),O(h,g),p||(w=ne(h,"click",t[50]),p=!0)},p(m,S){S[0]&65536&&c!==(c=new URL(m[16]).host+"")&&He(a,c),S[0]&1&&d!==(d="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+m[0]+"-900 hover:bg-"+m[0]+"-950")&&k(h,"class",d)},i:j,o:j,d(m){m&&z(e),p=!1,w()}}}function Oa(t){let e,n,r,o,i,s,c=new URL(t[15]).host+"",a,l,f,u,b,h,g,d,p,w;return{c(){e=P("div"),n=P("div"),n.textContent="Create a Nostr account",r=Y(),o=P("div"),i=F("Now you a new window will bring you to "),s=P("strong"),a=F(c),l=F(`
13
+ that if your browser is blocking popups, pleaase.`),f=C("br"),u=V(`
14
+ After that you will be returned to this page.`),g=G(),h=C("button"),b=V("Login now »"),x(n,"class","text-center text-lg"),x(o,"class","mt-4 text-center text-sm leading-4"),x(h,"class",d="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),x(e,"class","m-auto w-full")},m(y,A){j(y,e,A),B(e,n),B(e,r),B(e,o),B(o,i),B(o,s),B(s,c),B(o,l),B(o,f),B(o,u),B(e,g),B(e,h),B(h,b),p||(w=X(h,"click",t[47]),p=!0)},p(y,A){A[0]&16384&&a!==(a=new URL(y[14]).host+"")&&Te(c,a),A[0]&1&&d!==(d="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+y[0]+"-900 hover:bg-"+y[0]+"-950")&&x(h,"class",d)},i:H,o:H,d(y){y&&q(e),p=!1,w()}}}function ca(t){let e,n,r,o,i,s,a=new URL(t[13]).host+"",c,l,f,u,g,h,b,d,p,w;return{c(){e=C("div"),n=C("div"),n.textContent="Create a Nostr account",r=G(),o=C("div"),i=V("Now you a new window will bring you to "),s=C("strong"),c=V(a),l=V(`
15
15
  where the account creation will take place. If nothing happens check
16
- that if your browser is blocking popups, pleaase.`),f=P("br"),u=F(`
17
- After that you will be returned to this page.`),b=Y(),h=P("button"),g=F("Start account creation »"),k(n,"class","text-center text-lg"),k(o,"class","mt-4 text-center text-sm leading-4"),k(h,"class",d="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),k(e,"class","m-auto w-full")},m(m,S){K(m,e,S),O(e,n),O(e,r),O(e,o),O(o,i),O(o,s),O(s,a),O(o,l),O(o,f),O(o,u),O(e,b),O(e,h),O(h,g),p||(w=ne(h,"click",t[49]),p=!0)},p(m,S){S[0]&32768&&c!==(c=new URL(m[15]).host+"")&&He(a,c),S[0]&1&&d!==(d="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+m[0]+"-900 hover:bg-"+m[0]+"-950")&&k(h,"class",d)},i:j,o:j,d(m){m&&z(e),p=!1,w()}}}function Co(t){let e,n,r=t[23].picture&&Uo(t),o=t[23].name&&Po(t);return{c(){e=P("div"),r&&r.c(),n=Y(),o&&o.c(),k(e,"class","mb-2 flex items-center justify-center gap-2")},m(i,s){K(i,e,s),r&&r.m(e,null),O(e,n),o&&o.m(e,null)},p(i,s){i[23].picture?r?r.p(i,s):(r=Uo(i),r.c(),r.m(e,n)):r&&(r.d(1),r=null),i[23].name?o?o.p(i,s):(o=Po(i),o.c(),o.m(e,null)):o&&(o.d(1),o=null)},d(i){i&&z(e),r&&r.d(),o&&o.d()}}}function Uo(t){let e,n,r;return{c(){e=P("img"),Ze(e.src,n=t[23].picture)||k(e,"src",n),k(e,"alt",""),k(e,"class",r="h-10 w-10 rounded-full border-2 border-solid border-transparent group-hover:border-"+t[0]+"-100")},m(o,i){K(o,e,i)},p(o,i){i[0]&8388608&&!Ze(e.src,n=o[23].picture)&&k(e,"src",n),i[0]&1&&r!==(r="h-10 w-10 rounded-full border-2 border-solid border-transparent group-hover:border-"+o[0]+"-100")&&k(e,"class",r)},d(o){o&&z(e)}}}function Po(t){let e,n=t[23].name+"",r;return{c(){e=P("div"),r=F(n),k(e,"class","text-3xl decoration-2 underline-offset-4 group-hover:underline")},m(o,i){K(o,e,i),O(e,r)},p(o,i){i[0]&8388608&&n!==(n=o[23].name+"")&&He(r,n)},d(o){o&&z(e)}}}function Ro(t){let e,n;return{c(){e=P("div"),n=F(t[21]),k(e,"class","my-2 rounded bg-yellow-100 p-2 text-center text-sm leading-4 text-red-400")},m(r,o){K(r,e,o),O(e,n)},p(r,o){o[0]&2097152&&He(n,r[21])},d(r){r&&z(e)}}}function Na(t){let e;return{c(){e=F("Connect »")},m(n,r){K(n,e,r)},i:j,o:j,d(n){n&&z(e)}}}function La(t){let e,n,r;return n=new No({}),{c(){e=F(`Connecting to bunker
18
- `),ur(n.$$.fragment)},m(o,i){K(o,e,i),ln(n,o,i),r=!0},i(o){r||(me(n.$$.fragment,o),r=!0)},o(o){xe(n.$$.fragment,o),r=!1},d(o){o&&z(e),un(n,o)}}}function Ho(t){let e,n,r,o,i;return{c(){e=P("div"),n=F(`Waiting too much?
19
- `),r=P("button"),r.textContent="Cancel the connection",k(r,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),k(e,"class","mt-6 text-center text-sm leading-3")},m(s,c){K(s,e,c),O(e,n),O(e,r),o||(i=ne(r,"click",t[42]),o=!0)},p:j,d(s){s&&z(e),o=!1,i()}}}function Mo(t){let e,n,r,o,i,s,c;return{c(){e=P("div"),n=F("Do you need a Nostr account?"),r=P("br"),o=Y(),i=P("button"),i.textContent="Sign up now",k(i,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),k(e,"class","mt-6 text-center text-sm leading-3")},m(a,l){K(a,e,l),O(e,n),O(e,r),O(e,o),O(e,i),s||(c=ne(i,"click",t[38]),s=!0)},p:j,d(a){a&&z(e),s=!1,c()}}}function jo(t){let e,n,r;return{c(){e=P("option"),k(e,"label",n=t[82].domain),e.__value=r=t[82],rt(e,e.__value),k(e,"class","px-2 py-1 text-lg")},m(o,i){K(o,e,i)},p(o,i){i[0]&16777216&&n!==(n=o[82].domain)&&k(e,"label",n),i[0]&16777216&&r!==(r=o[82])&&(e.__value=r,rt(e,e.__value))},d(o){o&&z(e)}}}function Ta(t){let e,n;return{c(){e=P("img"),Ze(e.src,n=t[23].picture)||k(e,"src",n),k(e,"alt",""),k(e,"class","h-6 w-6 rounded-full")},m(r,o){K(r,e,o)},p(r,o){o[0]&8388608&&!Ze(e.src,n=r[23].picture)&&k(e,"src",n)},i:j,o:j,d(r){r&&z(e)}}}function Ca(t){let e,n,r,o=(t[23].name||t[23].npub.slice(0,7)+"…"+t[23].npub.slice(-4))+"",i;function s(l,f){return l[23].picture?Ha:Ra}let c=s(t),a=c(t);return{c(){e=P("div"),a.c(),n=Y(),r=P("div"),i=F(o),k(r,"class","inline-block max-w-56 overflow-hidden overflow-ellipsis whitespace-nowrap"),k(e,"class","flex items-center px-2")},m(l,f){K(l,e,f),a.m(e,null),O(e,n),O(e,r),O(r,i)},p(l,f){c===(c=s(l))&&a?a.p(l,f):(a.d(1),a=c(l),a&&(a.c(),a.m(e,n))),f[0]&8388608&&o!==(o=(l[23].name||l[23].npub.slice(0,7)+"…"+l[23].npub.slice(-4))+"")&&He(i,o)},i:j,o:j,d(l){l&&z(e),a.d()}}}function Ua(t){let e;function n(i,s){return i[2]?ja:Ma}let r=n(t),o=r(t);return{c(){o.c(),e=sn()},m(i,s){o.m(i,s),K(i,e,s)},p(i,s){r!==(r=n(i))&&(o.d(1),o=r(i),o&&(o.c(),o.m(e.parentNode,e)))},i:j,o:j,d(i){i&&z(e),o.d(i)}}}function Pa(t){let e,n,r,o;return r=new No({}),{c(){e=P("div"),n=F(`Connecting to bunker
20
- `),ur(r.$$.fragment),k(e,"class","flex items-center px-2")},m(i,s){K(i,e,s),O(e,n),ln(r,e,null),o=!0},p:j,i(i){o||(me(r.$$.fragment,i),o=!0)},o(i){xe(r.$$.fragment,i),o=!1},d(i){i&&z(e),un(r)}}}function Ra(t){let e;return{c(){e=P("span"),e.textContent="☉",k(e,"class","mr-2")},m(n,r){K(n,e,r)},p:j,d(n){n&&z(e)}}}function Ha(t){let e,n;return{c(){e=P("img"),Ze(e.src,n=t[23].picture)||k(e,"src",n),k(e,"alt",""),k(e,"class","mr-2 h-5 w-5 rounded-full")},m(r,o){K(r,e,o)},p(r,o){o[0]&8388608&&!Ze(e.src,n=r[23].picture)&&k(e,"src",n)},d(r){r&&z(e)}}}function Ma(t){let e;return{c(){e=P("div"),e.textContent="Connect with Nostr",k(e,"class","flex items-center px-2")},m(n,r){K(n,e,r)},d(n){n&&z(e)}}}function ja(t){let e;return{c(){e=P("div"),e.textContent="N",k(e,"class","w-6 text-center")},m(n,r){K(n,e,r)},d(n){n&&z(e)}}}function qo(t){let e,n,r,o;return{c(){e=P("iframe"),k(e,"title","~"),Ze(e.src,n="https://the-nostr.org/iframe.html")||k(e,"src",n)},m(i,s){K(i,e,s),t[58](e),r||(o=ne(e,"load",t[31]),r=!0)},p:j,d(i){i&&z(e),t[58](null),r=!1,o()}}}function qa(t){let e,n,r,o,i,s,c,a,l;const f=[Ea,xa,va],u=[];function b(g,d){return!g[27]&&!g[23]&&g[1]?0:g[27]?2:1}n=b(t),r=u[n]=f[n](t);let h=t[7]&&qo(t);return{c(){e=P("div"),r.c(),i=Y(),h&&h.c(),s=sn(),k(e,"class","draggable animate-fadein font-sans text-white"),k(e,"style",o="position: fixed; "+(t[27]&&t[5]?"width: 100vw;":"")+"; right: "+(t[27]&&t[5]?"0":t[3])+"px; user-select: none; "+(t[27]&&t[5]?"bottom: 0px":t[26]+":"+t[25]+"px")),sr(e,"cursor-pointer",!t[23]&&!t[27])},m(g,d){K(g,e,d),u[n].m(e,null),t[57](e),K(g,i,d),h&&h.m(g,d),K(g,s,d),c=!0,a||(l=[ne(Xn,"click",t[32]),ne(Xn,"mouseup",t[45]),ne(Xn,"mousemove",t[44]),ne(e,"mousedown",t[43])],a=!0)},p(g,d){let p=n;n=b(g),n===p?u[n].p(g,d):(Pt(),xe(u[p],1,1,()=>{u[p]=null}),Rt(),r=u[n],r?r.p(g,d):(r=u[n]=f[n](g),r.c()),me(r,1),r.m(e,null)),(!c||d[0]&234881064&&o!==(o="position: fixed; "+(g[27]&&g[5]?"width: 100vw;":"")+"; right: "+(g[27]&&g[5]?"0":g[3])+"px; user-select: none; "+(g[27]&&g[5]?"bottom: 0px":g[26]+":"+g[25]+"px")))&&k(e,"style",o),(!c||d[0]&142606336)&&sr(e,"cursor-pointer",!g[23]&&!g[27]),g[7]?h?h.p(g,d):(h=qo(g),h.c(),h.m(s.parentNode,s)):h&&(h.d(1),h=null)},i(g){c||(me(r),c=!0)},o(g){xe(r),c=!1},d(g){g&&(z(e),z(i),z(s)),u[n].d(),t[57](null),h&&h.d(g),a=!1,Re(l)}}}const zo="We could not connect to a NIP-46 bunker with that url, are you sure it is set up correctly?",Ko="We were not able to connect using this address. For it to work it has to come from a NIP-46 provider.",Fe=20;function er(t){return window.open(t,"window.nostr","width=600,height=800,popup=yes")}function za(t,e,n){let r,o,i,s,c,a;const l=ya("only screen and (max-width: 640px)");Xo(t,l,L=>n(5,a=L));const f={ORIGIN:"wnj:origin",CLIENT_SECRET:"wnj:clientSecret",Y_POS:"wnj:ypos",CALLBACK_TOKEN:"wnj:callbackToken",BUNKER_POINTER:"wnj:bunkerPointer",CACHED_PUBKEY:"wnj:cachedPubKey",IGNORE_IFRAME:"wnj:ignoreIframe"};let u,{accent:b}=e,{position:h="top"}=e,{startHidden:g}=e,{compactMode:d}=e;const p=window,w=new $s;let m=!1,S,T,R,_,x,y,E;const U=localStorage.getItem(f.CLIENT_SECRET);U?E=pn(U):(E=ks(),localStorage.setItem(f.CLIENT_SECRET,fe(E)));let N="closed",M,W,V,v,A,C,H=null,I=null,q=null,D=!1,$,X,Q,ce=!1,J,re,ue=[],{right:ae=20}=e,Be=!1,Ge=!1,Ce,ge,Ue;const Bt={pool:w,onauth(L){$?n(15,H=L):J?(n(17,q=L),n(27,i=!0)):n(16,I=L)}},It=gr(()=>{switch(N){case"justopened":n(47,N="opened");break;case"justclosed":n(47,N="closed");break}},500);function Xt(){n(47,N="justopened"),It()}function Ot(){n(47,N="justclosed"),It()}function en(){if(M&&!C){Nt();return}Xt()}rr();let Zo={isWnj:!0,async getPublicKey(){return!A&&!C&&Xt(),(await v).getPublicKey()},async signEvent(L){try{return!A&&!C&&en(),await(await v).signEvent(L)}finally{n(17,q=null),Ot()}},async getRelays(){return!A&&!C&&en(),(await v).getRelays()},nip04:{async encrypt(L,Z){return!A&&!C&&en(),(await v).nip04Encrypt(L,Z)},async decrypt(L,Z){return!A&&!C&&en(),(await v).nip04Decrypt(L,Z)}}};function rr(){Ot(),M=null,v=new Promise((L,Z)=>{W=L,V=Z}),n(23,J=null),n(14,A=!1),n(18,D=!1),n(19,$=!1),C=!1,re=null,n(21,Q="")}ii(()=>{if(!M){let L=localStorage.getItem(f.BUNKER_POINTER);L?(M=JSON.parse(L),tn(),localStorage.getItem(f.CACHED_PUBKEY)||Nt()):localStorage.getItem(f.IGNORE_IFRAME)||n(7,m=!0)}if(p.nostr&&!p.nostr.isWnj){p.destroyWnj();return}else Object.defineProperty(window,"nostr",{get(){return Zo},set(L){Zo=L,L.isWnj||p.destroyWnj()},configurable:!0});return()=>{re&&re.close()}});function Wa(){var Z;window.addEventListener("message",L),(Z=S==null?void 0:S.contentWindow)==null||Z.postMessage({getbunker:!0},"*");async function L(ve){let{bunker:Lt}=ve.data;Lt&&(M=await So(Lt),tn(),Nt(),window.removeEventListener("message",L))}}function Da(L){Math.abs(o-ge)>6||Date.now()-Ue>600||N==="justopened"||N==="justclosed"||(L.composedPath().find(Z=>Z.id==="wnj")?Xt():Ot())}function Va(L){Ot(),n(19,$=!1),n(15,H=null),n(16,I=null),n(17,q=null),L.stopPropagation()}function Fa(L){n(22,ce=!0),L.stopPropagation()}function Ga(L){n(22,ce=!1),L.stopPropagation()}async function Ya(L){L.preventDefault();try{if(M=await So(T.value),!M){T.value.match(Qt)?n(21,Q=zo):n(21,Q=Ko);return}T.setCustomValidity(""),n(21,Q=""),await Nt(),tn()}catch{T.value.match(Qt)?n(21,Q=zo):n(21,Q=Ko),n(14,A=!1)}}async function Za(L){L.preventDefault(),localStorage.removeItem(f.BUNKER_POINTER),localStorage.removeItem(f.CACHED_PUBKEY),localStorage.setItem(f.IGNORE_IFRAME,""),rr()}async function Ja(L){L.preventDefault(),n(19,$=!0),ue.length===0&&(n(24,ue=await fa(w,["wss://relay.nostr.band","wss://nos.lol","wss://nostr-pub.wellorder.net"])),n(12,y=ue[0]))}function Qa(L){n(19,$=!1)}async function Xa(L){if(L.preventDefault(),!y)return;n(20,X=!0);let Z=await ua(y,Bt,_.value,y.domain,void 0,E);n(20,X=!1),Xt(),n(19,$=!1),M=Z.bp,tn(),Nt(Z)}const el=gr(async()=>{y&&_.value.length>0&&(await da(_.value+"@"+y.domain)?_.setCustomValidity(`'${_.value}' is already taken.`):_.setCustomValidity(""))},500);function tl(){n(18,D=!1),n(14,A=!1),V("connection aborted"),rr()}async function Nt(L=void 0){L=L||new Bo(E,M,Bt),n(14,A=!0);let Z=setTimeout(()=>{n(18,D=!0),n(27,i=!0)},5e3);try{await L.connect(),C=!0,localStorage.setItem(f.BUNKER_POINTER,JSON.stringify(M)),Ot(),W(L)}catch(ve){V((ve==null?void 0:ve.message)||String(ve))}finally{clearTimeout(Z),n(14,A=!1),n(18,D=!1),n(15,H=null),n(16,I=null),n(17,q=null)}}async function tn(){let L=localStorage.getItem(f.CACHED_PUBKEY);L||(L=await(await v).getPublicKey(),localStorage.setItem(f.CACHED_PUBKEY,L)),n(23,J={pubkey:L,npub:ga(L),event:null}),re=w.subscribeMany(["wss://purplepag.es","wss://relay.snort.social","wss://relay.nos.social"],[{kinds:[0],authors:[L]}],{onevent(Z){var ve;if(!((((ve=J.event)==null?void 0:ve.created_at)||0)>=Z.created_at))try{let{name:Lt,picture:pl}=JSON.parse(Z.content);n(23,J.event=Z,J),n(23,J.name=Lt,J),n(23,J.picture=pl,J)}catch{}}})}function nl(L){if(i)return;Be=!0;const Z=u.getBoundingClientRect();Ce=L.clientY-Z.top,ge=o,Ue=Date.now()}function rl(L){Be&&(r==="top"?n(25,o=L.clientY):n(25,o=window.innerHeight-L.clientY),n(25,o-=Ce),n(48,Ge=!0),o<Fe&&n(25,o=Fe),o>window.innerHeight-Fe&&n(25,o=window.innerHeight-Fe))}function ol(){if(Be=!1,setTimeout(()=>{n(48,Ge=!1)},10),Ge){const L=u.getBoundingClientRect(),Z=window.innerHeight,ve=Z/2;L.top<ve?(n(26,r="top"),n(25,o=L.top)):(n(26,r="bottom"),n(25,o=Z-L.bottom)),o<Fe&&n(25,o=Fe),localStorage.setItem(f.ORIGIN,r),localStorage.setItem(f.Y_POS,o.toString())}}const il=()=>er(H),sl=()=>er(I),cl=()=>{er(q)};function al(L){it[L?"unshift":"push"](()=>{_=L,n(10,_)})}function ll(){x=this.value,n(11,x)}function ul(){y=ri(this),n(12,y),n(24,ue)}function fl(L){it[L?"unshift":"push"](()=>{T=L,n(9,T)})}function dl(){R=this.value,n(4,R)}function hl(L){it[L?"unshift":"push"](()=>{u=L,n(6,u)})}function gl(L){it[L?"unshift":"push"](()=>{S=L,n(8,S)})}return t.$$set=L=>{"accent"in L&&n(0,b=L.accent),"position"in L&&n(46,h=L.position),"startHidden"in L&&n(1,g=L.startHidden),"compactMode"in L&&n(2,d=L.compactMode),"right"in L&&n(3,ae=L.right)},t.$$.update=()=>{t.$$.dirty[0]&32|t.$$.dirty[1]&32768&&n(26,r=a?"bottom":localStorage.getItem(f.ORIGIN)||h),t.$$.dirty[0]&32&&n(25,o=a?Fe:parseInt(localStorage.getItem(f.Y_POS)||"0")||Fe),t.$$.dirty[1]&65536&&n(27,i=N==="justopened"||N==="opened"),t.$$.dirty[0]&1|t.$$.dirty[1]&131072&&n(29,s=Ge?"cursor-grabbing outline-dashed outline-"+b+"-500 outline-1 outline-offset-4":"outline-none"),t.$$.dirty[0]&16&&n(28,c=R&&(R.match(Qt)||R.match(Io)))},[b,g,d,ae,R,a,u,m,S,T,_,x,y,E,A,H,I,q,D,$,X,Q,ce,J,ue,o,r,i,c,s,l,Wa,Da,Va,Fa,Ga,Ya,Za,Ja,Qa,Xa,el,tl,nl,rl,ol,h,N,Ge,il,sl,cl,al,ll,ul,fl,dl,hl,gl]}class Ka extends dr{constructor(e){super(),fr(this,e,za,qa,rn,{accent:0,position:46,startHidden:1,compactMode:2,right:3},null,[-1,-1,-1])}}const yt=window;yt.destroyWnj=()=>{setTimeout(()=>{$a.$destroy()},1)};const tr=document.createElement("div");tr.style.zIndex="90000",document.body.appendChild(tr);const nr=document.createElement("div");nr.id="wnj";const $o=document.createElement("style");$o.innerHTML=Ye;const Wo=tr.attachShadow({mode:"open"});Wo.appendChild(nr),Wo.appendChild($o);const $a=new Ka({target:nr,props:{accent:((Do=yt.wnjParams)==null?void 0:Do.accent)||"cyan",position:((Vo=yt.wnjParams)==null?void 0:Vo.position)==="bottom"?"bottom":"top",startHidden:(Fo=yt.wnjParams)==null?void 0:Fo.startHidden,compactMode:(Go=yt.wnjParams)==null?void 0:Go.compactMode}});if(!((Yo=yt.wnjParams)!=null&&Yo.disableOverflowFix)){const t=document.createElement("style"),e=`
16
+ that if your browser is blocking popups, pleaase.`),f=C("br"),u=V(`
17
+ After that you will be returned to this page.`),g=G(),h=C("button"),b=V("Start account creation »"),x(n,"class","text-center text-lg"),x(o,"class","mt-4 text-center text-sm leading-4"),x(h,"class",d="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),x(e,"class","m-auto w-full")},m(y,A){j(y,e,A),B(e,n),B(e,r),B(e,o),B(o,i),B(o,s),B(s,c),B(o,l),B(o,f),B(o,u),B(e,g),B(e,h),B(h,b),p||(w=X(h,"click",t[46]),p=!0)},p(y,A){A[0]&8192&&a!==(a=new URL(y[13]).host+"")&&Te(c,a),A[0]&1&&d!==(d="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+y[0]+"-900 hover:bg-"+y[0]+"-950")&&x(h,"class",d)},i:H,o:H,d(y){y&&q(e),p=!1,w()}}}function mo(t){let e,n,r=t[21].picture&&vo(t),o=t[21].name&&xo(t);return{c(){e=C("div"),r&&r.c(),n=G(),o&&o.c(),x(e,"class","mb-2 flex items-center justify-center gap-2")},m(i,s){j(i,e,s),r&&r.m(e,null),B(e,n),o&&o.m(e,null)},p(i,s){i[21].picture?r?r.p(i,s):(r=vo(i),r.c(),r.m(e,n)):r&&(r.d(1),r=null),i[21].name?o?o.p(i,s):(o=xo(i),o.c(),o.m(e,null)):o&&(o.d(1),o=null)},d(i){i&&q(e),r&&r.d(),o&&o.d()}}}function vo(t){let e,n,r;return{c(){e=C("img"),Qe(e.src,n=t[21].picture)||x(e,"src",n),x(e,"alt",""),x(e,"class",r="h-10 w-10 rounded-full border-2 border-solid border-transparent group-hover:border-"+t[0]+"-100")},m(o,i){j(o,e,i)},p(o,i){i[0]&2097152&&!Qe(e.src,n=o[21].picture)&&x(e,"src",n),i[0]&1&&r!==(r="h-10 w-10 rounded-full border-2 border-solid border-transparent group-hover:border-"+o[0]+"-100")&&x(e,"class",r)},d(o){o&&q(e)}}}function xo(t){let e,n=t[21].name+"",r;return{c(){e=C("div"),r=V(n),x(e,"class","text-3xl decoration-2 underline-offset-4 group-hover:underline")},m(o,i){j(o,e,i),B(e,r)},p(o,i){i[0]&2097152&&n!==(n=o[21].name+"")&&Te(r,n)},d(o){o&&q(e)}}}function Eo(t){let e,n;return{c(){e=C("div"),n=V(t[19]),x(e,"class","my-2 rounded bg-yellow-100 p-2 text-center text-sm leading-4 text-red-400")},m(r,o){j(r,e,o),B(e,n)},p(r,o){o[0]&524288&&Te(n,r[19])},d(r){r&&q(e)}}}function aa(t){let e;return{c(){e=V("Connect »")},m(n,r){j(n,e,r)},i:H,o:H,d(n){n&&q(e)}}}function la(t){let e,n,r;return n=new bo({}),{c(){e=V(`Connecting to bunker
18
+ `),Qn(n.$$.fragment)},m(o,i){j(o,e,i),Jt(n,o,i),r=!0},i(o){r||(de(n.$$.fragment,o),r=!0)},o(o){be(n.$$.fragment,o),r=!1},d(o){o&&q(e),Qt(n,o)}}}function _o(t){let e,n,r,o,i;return{c(){e=C("div"),n=V(`Waiting too much?
19
+ `),r=C("button"),r.textContent="Cancel the connection",x(r,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),x(e,"class","mt-6 text-center text-sm leading-3")},m(s,a){j(s,e,a),B(e,n),B(e,r),o||(i=X(r,"click",t[39]),o=!0)},p:H,d(s){s&&q(e),o=!1,i()}}}function ko(t){let e,n,r,o,i,s,a;return{c(){e=C("div"),n=V("Do you need a Nostr account?"),r=C("br"),o=G(),i=C("button"),i.textContent="Sign up now",x(i,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),x(e,"class","mt-6 text-center text-sm leading-3")},m(c,l){j(c,e,l),B(e,n),B(e,r),B(e,o),B(e,i),s||(a=X(i,"click",t[35]),s=!0)},p:H,d(c){c&&q(e),s=!1,a()}}}function So(t){let e,n,r;return{c(){e=C("option"),x(e,"label",n=t[78].domain),e.__value=r=t[78],Xe(e,e.__value),x(e,"class","px-2 py-1 text-lg")},m(o,i){j(o,e,i)},p(o,i){i[0]&4194304&&n!==(n=o[78].domain)&&x(e,"label",n),i[0]&4194304&&r!==(r=o[78])&&(e.__value=r,Xe(e,e.__value))},d(o){o&&q(e)}}}function ua(t){let e,n;return{c(){e=C("img"),Qe(e.src,n=t[21].picture)||x(e,"src",n),x(e,"alt",""),x(e,"class","h-6 w-6 rounded-full")},m(r,o){j(r,e,o)},p(r,o){o[0]&2097152&&!Qe(e.src,n=r[21].picture)&&x(e,"src",n)},i:H,o:H,d(r){r&&q(e)}}}function fa(t){let e,n,r,o=(t[21].name||t[21].npub.slice(0,7)+"…"+t[21].npub.slice(-4))+"",i;function s(l,f){return l[21].picture?pa:ga}let a=s(t),c=a(t);return{c(){e=C("div"),c.c(),n=G(),r=C("div"),i=V(o),x(r,"class","inline-block max-w-56 overflow-hidden overflow-ellipsis whitespace-nowrap"),x(e,"class","flex items-center px-2")},m(l,f){j(l,e,f),c.m(e,null),B(e,n),B(e,r),B(r,i)},p(l,f){a===(a=s(l))&&c?c.p(l,f):(c.d(1),c=a(l),c&&(c.c(),c.m(e,n))),f[0]&2097152&&o!==(o=(l[21].name||l[21].npub.slice(0,7)+"…"+l[21].npub.slice(-4))+"")&&Te(i,o)},i:H,o:H,d(l){l&&q(e),c.d()}}}function da(t){let e;function n(i,s){return i[2]?wa:ba}let r=n(t),o=r(t);return{c(){o.c(),e=Vn()},m(i,s){o.m(i,s),j(i,e,s)},p(i,s){r!==(r=n(i))&&(o.d(1),o=r(i),o&&(o.c(),o.m(e.parentNode,e)))},i:H,o:H,d(i){i&&q(e),o.d(i)}}}function ha(t){let e,n,r,o;return r=new bo({}),{c(){e=C("div"),n=V(`Connecting to bunker
20
+ `),Qn(r.$$.fragment),x(e,"class","flex items-center px-2")},m(i,s){j(i,e,s),B(e,n),Jt(r,e,null),o=!0},p:H,i(i){o||(de(r.$$.fragment,i),o=!0)},o(i){be(r.$$.fragment,i),o=!1},d(i){i&&q(e),Qt(r)}}}function ga(t){let e;return{c(){e=C("span"),e.textContent="☉",x(e,"class","mr-2")},m(n,r){j(n,e,r)},p:H,d(n){n&&q(e)}}}function pa(t){let e,n;return{c(){e=C("img"),Qe(e.src,n=t[21].picture)||x(e,"src",n),x(e,"alt",""),x(e,"class","mr-2 h-5 w-5 rounded-full")},m(r,o){j(r,e,o)},p(r,o){o[0]&2097152&&!Qe(e.src,n=r[21].picture)&&x(e,"src",n)},d(r){r&&q(e)}}}function ba(t){let e;return{c(){e=C("div"),e.textContent="Connect with Nostr",x(e,"class","flex items-center px-2")},m(n,r){j(n,e,r)},d(n){n&&q(e)}}}function wa(t){let e;return{c(){e=C("div"),e.textContent="N",x(e,"class","w-6 text-center")},m(n,r){j(n,e,r)},d(n){n&&q(e)}}}function ya(t){let e,n,r,o,i,s,a;const c=[ea,Xc,Qc],l=[];function f(u,g){return!u[25]&&!u[21]&&u[1]?0:u[25]?2:1}return n=f(t),r=l[n]=c[n](t),{c(){e=C("div"),r.c(),x(e,"class","draggable animate-fadein font-sans text-white"),x(e,"style",o="position: fixed; "+(t[25]&&t[5]?"width: 100vw;":"")+"; right: "+(t[25]&&t[5]?"0":t[3])+"px; user-select: none; "+(t[25]&&t[5]?"bottom: 0px":t[24]+":"+t[23]+"px")),Yn(e,"cursor-pointer",!t[21]&&!t[25])},m(u,g){j(u,e,g),l[n].m(e,null),t[54](e),i=!0,s||(a=[X(qn,"click",t[29]),X(qn,"mouseup",t[42]),X(qn,"mousemove",t[41]),X(e,"mousedown",t[40])],s=!0)},p(u,g){let h=n;n=f(u),n===h?l[n].p(u,g):(At(),be(l[h],1,1,()=>{l[h]=null}),Bt(),r=l[n],r?r.p(u,g):(r=l[n]=c[n](u),r.c()),de(r,1),r.m(e,null)),(!i||g[0]&58720296&&o!==(o="position: fixed; "+(u[25]&&u[5]?"width: 100vw;":"")+"; right: "+(u[25]&&u[5]?"0":u[3])+"px; user-select: none; "+(u[25]&&u[5]?"bottom: 0px":u[24]+":"+u[23]+"px")))&&x(e,"style",o),(!i||g[0]&35651584)&&Yn(e,"cursor-pointer",!u[21]&&!u[25])},i(u){i||(de(r),i=!0)},o(u){be(r),i=!1},d(u){u&&q(e),l[n].d(),t[54](null),s=!1,Ne(a)}}}const Ao="We could not connect to a NIP-46 bunker with that url, are you sure it is set up correctly?",Bo="We were not able to connect using this address. For it to work it has to come from a NIP-46 provider.",je=20;function jn(t){return window.open(t,"window.nostr","width=600,height=800,popup=yes")}function ma(t,e,n){let r,o,i,s,a,c;const l=Zc("only screen and (max-width: 640px)");qo(t,l,O=>n(5,c=O));const f={ORIGIN:"wnj:origin",CLIENT_SECRET:"wnj:clientSecret",Y_POS:"wnj:ypos",CALLBACK_TOKEN:"wnj:callbackToken",BUNKER_POINTER:"wnj:bunkerPointer",CACHED_PUBKEY:"wnj:cachedPubKey"};let u,{accent:g}=e,{position:h="top"}=e,{startHidden:b}=e,{compactMode:d}=e;const p=window,w=new Os;let y,A,N,U,k,v;const m=localStorage.getItem(f.CLIENT_SECRET);m?v=rn(m):(v=us(),localStorage.setItem(f.CLIENT_SECRET,oe(v)));let S="closed",T,P,D,$,W,_,I=null,L=null,M=null,R=!1,z,Y,K,se=!1,Q,he,ge=[],{right:pe=20}=e,Ze=!1,le=!1,Ae,Et,Be;const ae={pool:w,onauth(O){z?n(13,I=O):Q?(n(15,M=O),n(25,i=!0)):n(14,L=O)}},Ie=nr(()=>{switch(S){case"justopened":n(44,S="opened");break;case"justclosed":n(44,S="closed");break}},500);function Je(){n(44,S="justopened"),Ie()}function ze(){n(44,S="justclosed"),Ie()}function Dt(){if(T&&!_){Wt();return}Je()}$n();let Uo={isWnj:!0,async getPublicKey(){return!W&&!_&&Je(),(await $).getPublicKey()},async signEvent(O){try{return!W&&!_&&Dt(),await(await $).signEvent(O)}finally{n(15,M=null),ze()}},async getRelays(){return!W&&!_&&Dt(),(await $).getRelays()},nip04:{async encrypt(O,Z){return!W&&!_&&Dt(),(await $).nip04Encrypt(O,Z)},async decrypt(O,Z){return!W&&!_&&Dt(),(await $).nip04Decrypt(O,Z)}}};function $n(){ze(),T=null,$=new Promise((O,Z)=>{P=O,D=Z}),n(21,Q=null),n(12,W=!1),n(16,R=!1),n(17,z=!1),_=!1,he=null,n(19,K="")}Wo(()=>{if(!T){let O=localStorage.getItem(f.BUNKER_POINTER);O&&(T=JSON.parse(O),Dn(),localStorage.getItem(f.CACHED_PUBKEY)||Wt())}if(p.nostr&&!p.nostr.isWnj){p.destroyWnj();return}else Object.defineProperty(window,"nostr",{get(){return Uo},set(O){Uo=O,O.isWnj||p.destroyWnj()},configurable:!0});return()=>{he&&he.close()}});function Ea(O){Math.abs(o-Et)>6||Date.now()-Be>600||S==="justopened"||S==="justclosed"||(O.composedPath().find(Z=>Z.id==="wnj")?Je():ze())}function _a(O){ze(),n(17,z=!1),n(13,I=null),n(14,L=null),n(15,M=null),O.stopPropagation()}function ka(O){n(20,se=!0),O.stopPropagation()}function Sa(O){n(20,se=!1),O.stopPropagation()}async function Aa(O){O.preventDefault();try{if(T=await zc(y.value),!T){y.value.match($t)?n(19,K=Ao):n(19,K=Bo);return}y.setCustomValidity(""),n(19,K=""),await Wt(),Dn()}catch{y.value.match($t)?n(19,K=Ao):n(19,K=Bo),n(12,W=!1)}}async function Ba(O){O.preventDefault(),localStorage.removeItem(f.BUNKER_POINTER),localStorage.removeItem(f.CACHED_PUBKEY),$n()}async function Ia(O){O.preventDefault(),n(17,z=!0),ge.length===0&&(n(22,ge=await $c(w,["wss://relay.nostr.band","wss://nos.lol","wss://nostr-pub.wellorder.net"])),n(10,k=ge[0]))}function Oa(O){n(17,z=!1)}async function Na(O){if(O.preventDefault(),!k)return;n(18,Y=!0);let Z=await Kc(k,ae,N.value,k.domain,void 0,v);n(18,Y=!1),Je(),n(17,z=!1),T=Z.bp,Dn(),Wt(Z)}const Ta=nr(async()=>{k&&N.value.length>0&&(await Dc(N.value+"@"+k.domain)?N.setCustomValidity(`'${N.value}' is already taken.`):N.setCustomValidity(""))},500);function Ca(){n(16,R=!1),n(12,W=!1),D("connection aborted"),$n()}async function Wt(O=void 0){O=O||new ho(v,T,ae),n(12,W=!0);let Z=setTimeout(()=>{n(16,R=!0),n(25,i=!0)},5e3);try{await O.connect(),_=!0,localStorage.setItem(f.BUNKER_POINTER,JSON.stringify(T)),ze(),P(O)}catch(Oe){D((Oe==null?void 0:Oe.message)||String(Oe))}finally{clearTimeout(Z),n(12,W=!1),n(16,R=!1),n(13,I=null),n(14,L=null),n(15,M=null)}}async function Dn(){let O=localStorage.getItem(f.CACHED_PUBKEY);O||(O=await(await $).getPublicKey(),localStorage.setItem(f.CACHED_PUBKEY,O)),n(21,Q={pubkey:O,npub:Vc(O),event:null}),he=w.subscribeMany(["wss://purplepag.es","wss://relay.snort.social","wss://relay.nos.social"],[{kinds:[0],authors:[O]}],{onevent(Z){var Oe;if(!((((Oe=Q.event)==null?void 0:Oe.created_at)||0)>=Z.created_at))try{let{name:Ho,picture:Wa}=JSON.parse(Z.content);n(21,Q.event=Z,Q),n(21,Q.name=Ho,Q),n(21,Q.picture=Wa,Q)}catch{}}})}function Pa(O){if(i)return;Ze=!0;const Z=u.getBoundingClientRect();Ae=O.clientY-Z.top,Et=o,Be=Date.now()}function La(O){Ze&&(r==="top"?n(23,o=O.clientY):n(23,o=window.innerHeight-O.clientY),n(23,o-=Ae),n(45,le=!0),o<je&&n(23,o=je),o>window.innerHeight-je&&n(23,o=window.innerHeight-je))}function Ua(){if(Ze=!1,setTimeout(()=>{n(45,le=!1)},10),le){const O=u.getBoundingClientRect(),Z=window.innerHeight,Oe=Z/2;O.top<Oe?(n(24,r="top"),n(23,o=O.top)):(n(24,r="bottom"),n(23,o=Z-O.bottom)),o<je&&n(23,o=je),localStorage.setItem(f.ORIGIN,r),localStorage.setItem(f.Y_POS,o.toString())}}const Ha=()=>jn(I),Ra=()=>jn(L),Ma=()=>{jn(M)};function qa(O){pt[O?"unshift":"push"](()=>{N=O,n(8,N)})}function ja(){U=this.value,n(9,U)}function za(){k=$o(this),n(10,k),n(22,ge)}function Ka(O){pt[O?"unshift":"push"](()=>{y=O,n(7,y)})}function $a(){A=this.value,n(4,A)}function Da(O){pt[O?"unshift":"push"](()=>{u=O,n(6,u)})}return t.$$set=O=>{"accent"in O&&n(0,g=O.accent),"position"in O&&n(43,h=O.position),"startHidden"in O&&n(1,b=O.startHidden),"compactMode"in O&&n(2,d=O.compactMode),"right"in O&&n(3,pe=O.right)},t.$$.update=()=>{t.$$.dirty[0]&32|t.$$.dirty[1]&4096&&n(24,r=c?"bottom":localStorage.getItem(f.ORIGIN)||h),t.$$.dirty[0]&32&&n(23,o=c?je:parseInt(localStorage.getItem(f.Y_POS)||"0")||je),t.$$.dirty[1]&8192&&n(25,i=S==="justopened"||S==="opened"),t.$$.dirty[0]&1|t.$$.dirty[1]&16384&&n(27,s=le?"cursor-grabbing outline-dashed outline-"+g+"-500 outline-1 outline-offset-4":"outline-none"),t.$$.dirty[0]&16&&n(26,a=A&&(A.match($t)||A.match(go)))},[g,b,d,pe,A,c,u,y,N,U,k,v,W,I,L,M,R,z,Y,K,se,Q,ge,o,r,i,a,s,l,Ea,_a,ka,Sa,Aa,Ba,Ia,Oa,Na,Ta,Ca,Pa,La,Ua,h,S,le,Ha,Ra,Ma,qa,ja,za,Ka,$a,Da]}class va extends er{constructor(e){super(),Xn(this,e,ma,ya,Ft,{accent:0,position:43,startHidden:1,compactMode:2,right:3},null,[-1,-1,-1])}}const dt=window;dt.destroyWnj=()=>{setTimeout(()=>{xa.$destroy()},1)};const zn=document.createElement("div");zn.style.zIndex="90000",document.body.appendChild(zn);const Kn=document.createElement("div");Kn.id="wnj";const Io=document.createElement("style");Io.innerHTML=Ke;const Oo=zn.attachShadow({mode:"open"});Oo.appendChild(Kn),Oo.appendChild(Io);const xa=new va({target:Kn,props:{accent:((No=dt.wnjParams)==null?void 0:No.accent)||"cyan",position:((To=dt.wnjParams)==null?void 0:To.position)==="bottom"?"bottom":"top",startHidden:(Co=dt.wnjParams)==null?void 0:Co.startHidden,compactMode:(Po=dt.wnjParams)==null?void 0:Po.compactMode}});if(!((Lo=dt.wnjParams)!=null&&Lo.disableOverflowFix)){const t=document.createElement("style"),e=`
21
21
  html, body {
22
22
  overflow: auto;
23
23
  height: 100%;
package/justfile CHANGED
@@ -4,15 +4,10 @@ set unstable
4
4
  dev:
5
5
  vite --port 13471
6
6
 
7
- build: wnj iframe
8
-
9
- wnj:
7
+ build:
10
8
  vite build
11
9
  mv dist/assets/*.js dist/window.nostr.js
12
10
 
13
- iframe:
14
- node ./iframe/build.js
15
-
16
11
  demo:
17
12
  xdg-open demo/index.html
18
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "window.nostr.js",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "type": "module",
5
5
  "main": "dist/window.nostr.js",
6
6
  "devDependencies": {
package/src/App.svelte CHANGED
@@ -32,7 +32,6 @@
32
32
  CALLBACK_TOKEN: 'wnj:callbackToken',
33
33
  BUNKER_POINTER: 'wnj:bunkerPointer',
34
34
  CACHED_PUBKEY: 'wnj:cachedPubKey',
35
- IGNORE_IFRAME: 'wnj:ignoreIframe'
36
35
  }
37
36
 
38
37
  let myself: HTMLDivElement
@@ -47,8 +46,6 @@
47
46
 
48
47
  const win = window as any
49
48
  const pool = new SimplePool()
50
- let useIframe = false
51
- let iframe: HTMLIFrameElement | undefined
52
49
  let bunkerInput: HTMLInputElement
53
50
  let bunkerInputValue: string
54
51
  let nameInput: HTMLInputElement
@@ -227,11 +224,6 @@
227
224
  if (!cachedPubkey) {
228
225
  connect()
229
226
  }
230
- } else {
231
- // when we don't have any bunker data stored, we can still check the iframe for it
232
- if (!localStorage.getItem(lskeys.IGNORE_IFRAME)) {
233
- useIframe = true
234
- }
235
227
  }
236
228
  }
237
229
 
@@ -264,21 +256,6 @@
264
256
  }
265
257
  })
266
258
 
267
- function onIframeLoaded() {
268
- window.addEventListener('message', handleMessage)
269
- iframe?.contentWindow?.postMessage({getbunker: true}, '*')
270
-
271
- async function handleMessage(ev: MessageEvent) {
272
- let {bunker} = ev.data
273
- if (bunker) {
274
- bunkerPointer = await parseBunkerInput(bunker)
275
- identify()
276
- connect()
277
- window.removeEventListener('message', handleMessage)
278
- }
279
- }
280
- }
281
-
282
259
  function handleClick(ev: MouseEvent) {
283
260
  if (Math.abs(ypos - yposStart) > 6 || Date.now() - clickStart > 600) {
284
261
  return
@@ -343,7 +320,6 @@
343
320
  ev.preventDefault()
344
321
  localStorage.removeItem(lskeys.BUNKER_POINTER)
345
322
  localStorage.removeItem(lskeys.CACHED_PUBKEY)
346
- localStorage.setItem(lskeys.IGNORE_IFRAME, '')
347
323
  reset()
348
324
  }
349
325
 
@@ -840,11 +816,3 @@
840
816
  </div>
841
817
  {/if}
842
818
  </div>
843
- {#if useIframe}
844
- <iframe
845
- title="~"
846
- bind:this={iframe}
847
- on:load={onIframeLoaded}
848
- src="https://the-nostr.org/iframe.html"
849
- ></iframe>
850
- {/if}
package/dist/iframe.js DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- (() => {
3
- // iframe/iframe.ts
4
- var SHARED_BUNKER_KEY = "wnj:root:sharedBunker";
5
- window.onmessage = async (ev) => {
6
- const { bunker, getbunker } = ev.data;
7
- if (bunker) {
8
- if (!ev.origin.startsWith("https://join.the-nostr.org") && !ev.origin.startsWith("http://localhost:6711")) {
9
- return;
10
- }
11
- if (bunker) {
12
- localStorage.setItem(SHARED_BUNKER_KEY, bunker);
13
- } else {
14
- console.error("wnj iframe got an invalid bunker url:", bunker);
15
- }
16
- }
17
- if (getbunker) {
18
- const bunker2 = localStorage.getItem(SHARED_BUNKER_KEY);
19
- window.parent.postMessage({ bunker: bunker2 }, "*");
20
- }
21
- };
22
- })();
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../iframe/iframe.ts"],
4
- "sourcesContent": ["const SHARED_BUNKER_KEY = 'wnj:root:sharedBunker'\n\nwindow.onmessage = async (ev: MessageEvent) => {\n const {bunker, getbunker} = ev.data\n\n // set the bunker URL\n if (bunker) {\n // we only accept these websites to be setting the bunker URL\n if (\n !ev.origin.startsWith('https://join.the-nostr.org') &&\n !ev.origin.startsWith('http://localhost:6711')\n ) {\n return\n }\n\n if (bunker) {\n localStorage.setItem(SHARED_BUNKER_KEY, bunker)\n } else {\n console.error('wnj iframe got an invalid bunker url:', bunker)\n }\n }\n\n if (getbunker) {\n // any website can get the bunker URL if it is set\n const bunker = localStorage.getItem(SHARED_BUNKER_KEY)\n window.parent.postMessage({bunker}, '*') // we reply even if it's undefined so they know\n }\n}\n"],
5
- "mappings": ";;;AAAA,MAAM,oBAAoB;AAE1B,SAAO,YAAY,OAAO,OAAqB;AAC7C,UAAM,EAAC,QAAQ,UAAS,IAAI,GAAG;AAG/B,QAAI,QAAQ;AAEV,UACE,CAAC,GAAG,OAAO,WAAW,4BAA4B,KAClD,CAAC,GAAG,OAAO,WAAW,uBAAuB,GAC7C;AACA;AAAA,MACF;AAEA,UAAI,QAAQ;AACV,qBAAa,QAAQ,mBAAmB,MAAM;AAAA,MAChD,OAAO;AACL,gBAAQ,MAAM,yCAAyC,MAAM;AAAA,MAC/D;AAAA,IACF;AAEA,QAAI,WAAW;AAEb,YAAMA,UAAS,aAAa,QAAQ,iBAAiB;AACrD,aAAO,OAAO,YAAY,EAAC,QAAAA,QAAM,GAAG,GAAG;AAAA,IACzC;AAAA,EACF;",
6
- "names": ["bunker"]
7
- }
package/iframe/build.js DELETED
@@ -1,9 +0,0 @@
1
- import {build} from 'esbuild'
2
-
3
- build({
4
- entryPoints: ['iframe/iframe.ts'],
5
- bundle: true,
6
- sourcemap: 'external',
7
- outfile: 'dist/iframe.js',
8
- format: 'iife'
9
- }).then(() => console.log('iframe built'))
package/iframe/iframe.ts DELETED
@@ -1,28 +0,0 @@
1
- const SHARED_BUNKER_KEY = 'wnj:root:sharedBunker'
2
-
3
- window.onmessage = async (ev: MessageEvent) => {
4
- const {bunker, getbunker} = ev.data
5
-
6
- // set the bunker URL
7
- if (bunker) {
8
- // we only accept these websites to be setting the bunker URL
9
- if (
10
- !ev.origin.startsWith('https://join.the-nostr.org') &&
11
- !ev.origin.startsWith('http://localhost:6711')
12
- ) {
13
- return
14
- }
15
-
16
- if (bunker) {
17
- localStorage.setItem(SHARED_BUNKER_KEY, bunker)
18
- } else {
19
- console.error('wnj iframe got an invalid bunker url:', bunker)
20
- }
21
- }
22
-
23
- if (getbunker) {
24
- // any website can get the bunker URL if it is set
25
- const bunker = localStorage.getItem(SHARED_BUNKER_KEY)
26
- window.parent.postMessage({bunker}, '*') // we reply even if it's undefined so they know
27
- }
28
- }