diff --git a/ventures/lineage/orgchain/assets/index-C2KQkSf9.css b/ventures/lineage/orgchain/assets/index-BwSr_QKO.css similarity index 96% rename from ventures/lineage/orgchain/assets/index-C2KQkSf9.css rename to ventures/lineage/orgchain/assets/index-BwSr_QKO.css index 936632e..accc49e 100644 --- a/ventures/lineage/orgchain/assets/index-C2KQkSf9.css +++ b/ventures/lineage/orgchain/assets/index-BwSr_QKO.css @@ -1 +1 @@ -:root{--concrete: #e4e3dd;--slab: #f6f5f1;--ink: #141414;--ink-2: #4a4944;--ink-3: #66655f;--signal: #ffc21a;--on-signal: #141414;--ok: #1d7a3a;--danger: #b3261e;--focus: #2346ff;--band: #141414;--band-fg: #f6f5f1;--band-muted: #b0afa8;--shadow: #141414;--mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;--display: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;--t-xs: .75rem;--t-s: .8125rem;--t-m: .9375rem;--t-l: 1.25rem;--gutter: max(16px, env(safe-area-inset-left, 0px));color-scheme:light}@media(prefers-color-scheme:dark){:root:not([data-theme=light]){--concrete: #151514;--slab: #1e1e1c;--ink: #ecebe4;--ink-2: #b9b8b0;--ink-3: #94938b;--ok: #62c784;--danger: #ff8a7f;--focus: #93a8ff;--band: #0b0b0a;--band-fg: #ecebe4;--band-muted: #9d9c95;--shadow: #4d4c47;color-scheme:dark}}:root[data-theme=dark]{--concrete: #151514;--slab: #1e1e1c;--ink: #ecebe4;--ink-2: #b9b8b0;--ink-3: #94938b;--ok: #62c784;--danger: #ff8a7f;--focus: #93a8ff;--band: #0b0b0a;--band-fg: #ecebe4;--band-muted: #9d9c95;--shadow: #4d4c47;color-scheme:dark}*{box-sizing:border-box}[hidden]{display:none!important}html{-webkit-text-size-adjust:100%}body{margin:0;background:var(--concrete);color:var(--ink);font:400 var(--t-m)/1.5 var(--mono)}body.busy{cursor:progress}::selection{background:var(--signal);color:var(--on-signal)}button,select,input,textarea{font:inherit;color:inherit}:focus-visible{outline:3px solid var(--focus);outline-offset:2px}a{color:inherit;text-decoration-thickness:2px;text-underline-offset:3px}b{font-weight:700}.band{background:var(--band);color:var(--band-fg);border-bottom:3px solid var(--ink)}.band-in{max-width:1320px;margin:0 auto;padding:16px var(--gutter) 14px;display:flex;flex-wrap:wrap;gap:14px 32px;align-items:flex-end;justify-content:space-between}.kicker{margin:0 0 8px;font:700 var(--t-xs)/1 var(--mono);letter-spacing:.12em;text-transform:uppercase;color:var(--band-muted)}.kicker a{color:var(--band-fg)}.wordmark{margin:0;font:900 clamp(2.25rem,6vw,3.5rem)/.84 var(--display);letter-spacing:-.05em;text-transform:uppercase}.lede{margin:10px 0 0;color:var(--band-muted);font-size:var(--t-s);max-width:88ch}.lede b{color:var(--band-fg)}.flags{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.flag{font:700 var(--t-xs)/1 var(--mono);letter-spacing:.1em;text-transform:uppercase;padding:7px 9px 6px;border:2px solid var(--band-fg);background:transparent;color:var(--band-fg);border-radius:0}.flag.hz{background:var(--signal);border-color:var(--signal);color:var(--on-signal)}button.flag{cursor:pointer}button.flag:hover{background:var(--band-fg);color:var(--band)}.clock{background:var(--slab);border-bottom:3px solid var(--ink);position:sticky;top:0;z-index:5}.clock-in{max-width:1320px;margin:0 auto;padding:10px var(--gutter);display:flex;flex-wrap:wrap;gap:10px 18px;align-items:center}.tempo{display:flex;flex-wrap:wrap;align-items:center}.tempo .lab{margin:0 10px 0 0}.seg{font:700 var(--t-xs)/1 var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:9px 10px 8px;border:2px solid var(--ink);background:var(--slab);color:var(--ink);cursor:pointer;border-radius:0;margin-left:-2px}.seg:first-of-type{margin-left:0}.seg:hover:not([aria-pressed=true]){background:var(--concrete)}.seg[aria-pressed=true]{background:var(--ink);color:var(--slab)}.seg:focus-visible{position:relative;z-index:1}.beatno{margin:0;flex:1 1 22ch;font-size:var(--t-s);color:var(--ink-2)}.beatno b{color:var(--ink);font-size:var(--t-m)}.say{max-width:1320px;margin:0 auto;padding:0 var(--gutter) 10px;font-size:var(--t-s);color:var(--ink-2)}.say:empty{display:none}.say.bad{color:var(--danger);font-weight:700}.wrap{max-width:1320px;margin:0 auto;padding:32px var(--gutter) 56px;display:grid;gap:40px}.work{display:grid;gap:36px 28px;align-items:start;grid-template-columns:minmax(0,250px) minmax(0,1fr) minmax(0,390px);grid-template-areas:"hold tree side" "hold time side";grid-template-rows:auto 1fr}.hold-blk{grid-area:hold}.tree-blk{grid-area:tree}.time-blk{grid-area:time}.side{grid-area:side;display:grid;gap:36px;min-width:0}.blk{display:flex;flex-direction:column;align-items:flex-start;min-width:0}.blk>.panel{align-self:stretch}.tab{margin:0;background:var(--ink);color:var(--slab);font:700 var(--t-xs)/1 var(--mono);letter-spacing:.14em;text-transform:uppercase;padding:8px 11px 7px;display:flex;gap:12px;max-width:100%}.tab .sub{font-weight:400;letter-spacing:.06em;text-transform:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tab .sub:empty{display:none}.panel{background:var(--slab);border:3px solid var(--ink);box-shadow:8px 8px 0 var(--shadow);min-width:0}.pad{padding:16px 18px}.lab{display:block;font:700 var(--t-xs)/1.2 var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--ink-2)}.lab span{font-weight:400;letter-spacing:.04em;text-transform:none}.note{margin:0;font-size:var(--t-s);color:var(--ink-2)}.note p{margin:0 0 12px}.wait{margin:0;padding:4px 16px;color:var(--ink-3);font-size:var(--t-s)}.hint{margin:8px 0 0;font-size:var(--t-xs);color:var(--ink-2)}input:not([type]),input[type=text],select,textarea{width:100%;padding:8px 10px;border:2px solid var(--ink);border-radius:0;background:var(--concrete);min-width:0}textarea{resize:vertical;line-height:1.5}.line{display:flex;flex-wrap:wrap;gap:10px;align-items:stretch}.line input{flex:1 1 12ch;width:auto}.btn{font:700 var(--t-s)/1 var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:10px 12px 9px;background:var(--slab);color:var(--ink);border:2px solid var(--ink);box-shadow:3px 3px 0 var(--shadow);cursor:pointer;border-radius:0}.btn:hover{background:var(--concrete)}.btn:active{transform:translate(3px,3px);box-shadow:none}.btn.primary{background:var(--signal);color:var(--on-signal);border-color:var(--ink)}.btn.danger{background:var(--danger);color:var(--slab)}.btn.sm{font-size:var(--t-xs);padding:7px 9px 6px;box-shadow:2px 2px 0 var(--shadow)}.btn.sm:active{transform:translate(2px,2px)}.btn:disabled,.seg:disabled{cursor:not-allowed;background:var(--concrete);color:var(--ink-3);border-color:var(--ink-3);box-shadow:none;transform:none}.holds{list-style:none;margin:0;padding:0}.holds li+li{border-top:2px solid var(--ink)}.hold{width:100%;display:grid;gap:3px;text-align:left;background:transparent;border:0;padding:12px 18px;cursor:pointer;border-radius:0}.hold:hover .hn{text-decoration:underline;text-underline-offset:3px}.hn{font-weight:700;overflow-wrap:anywhere}.hm{font-size:var(--t-xs);color:var(--ink-2)}.hold.on{background:var(--signal)}.hold.on .hn,.hold.on .hm{color:var(--on-signal)}.hold.gone .hn{text-decoration:line-through;text-decoration-thickness:2px}.holds:not(:empty)~.found{border-top:3px solid var(--ink)}.empty p{margin:0;font-size:var(--t-s);color:var(--ink-2)}.found .lab{margin-bottom:8px}.sample{border-top:2px dashed var(--ink-3)}.tree{padding:12px 0;font-size:.875rem;overflow-x:auto}.row{display:flex;align-items:stretch;min-width:max-content}.sel{flex:1;display:flex;align-items:baseline;text-align:left;background:transparent;border:0;padding:4px 14px 4px 16px;cursor:pointer;line-height:1.55;border-radius:0}.sel:hover .l{text-decoration:underline;text-underline-offset:3px}.g{white-space:pre;color:var(--ink-3);flex:none}.p{white-space:pre;font-weight:700;flex:none}.l{flex:none;color:var(--ink);font-weight:700;white-space:nowrap}.v{flex:1 0 auto;display:flex;gap:5px;justify-content:flex-end;align-items:center;margin-left:2ch}.grp{padding:0 14px 0 16px;line-height:1.55;color:var(--ink-3)}.gl{color:var(--ink-2)}.row.on .sel{background:var(--signal)}.row.on .g,.row.on .p,.row.on .l,.row.on .mk,.row.on .belt{color:var(--on-signal);border-color:var(--on-signal)}.row.gone .l,.row.gone .p{text-decoration:line-through;text-decoration-thickness:2px}.row.gone .l{color:var(--ink-2)}.row.cue .l{font-weight:400;font-style:italic}.mk{font:700 .6875rem/1 var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:3px 5px 2px;border:2px solid currentColor;color:var(--ink-2);white-space:nowrap}.mk.ok{color:var(--ok)}.mk.bad{color:var(--danger)}.belt{display:inline-flex;align-items:center;gap:5px;font:700 .6875rem/1 var(--mono);padding:2px 5px 2px 3px;border:2px solid var(--ink);color:var(--ink);white-space:nowrap}.belt:before{content:"";width:10px;height:10px;flex:none;border:1.5px solid currentColor;background:#f6f5f1}.belt.green:before{background:#1d7a3a}.belt.black:before{background:#141414}.verbs{display:flex;flex-wrap:wrap;border-bottom:3px solid var(--ink)}.verbs button{flex:1 1 auto;font:700 var(--t-s)/1 var(--mono);padding:12px 10px;background:transparent;border:0;border-right:2px solid var(--ink);color:var(--ink-2);cursor:pointer;border-radius:0}.verbs button:last-child{border-right:0}.verbs button.off{color:var(--ink-3)}.verbs button:hover:not([aria-pressed=true]){color:var(--ink);text-decoration:underline;text-underline-offset:3px}.verbs button[aria-pressed=true]{background:var(--ink);color:var(--slab)}.why{margin:0;font-size:var(--t-s);color:var(--ink-2)}.keyline{margin:0;padding:10px 18px;font-size:var(--t-xs);color:var(--ink-2);overflow-wrap:anywhere;border-bottom:1px dashed var(--ink-3)}.keyline:empty{display:none}.why:empty{display:none}.vf{display:grid;gap:6px}.vf .lab{margin-top:8px}.vh{margin:0;font-size:var(--t-s);color:var(--ink-2)}.vh b{color:var(--ink)}.vf .go,.vf .line{margin-top:12px}.vf>.go{justify-self:start}.vf .line .go{margin-top:0}.kinds{border:0;margin:0;padding:0;display:grid;gap:6px;min-width:0}.kinds legend{padding:0;margin:8px 0 6px}.kinds label{display:flex;gap:8px;align-items:baseline;cursor:pointer;font-weight:700}.kinds label span{font-weight:400;font-size:var(--t-s);color:var(--ink-2)}.kinds input{accent-color:var(--ink);margin:0}.ih{padding:16px 18px 14px;border-bottom:3px solid var(--ink)}.eyebrow{margin:0 0 8px;font:700 var(--t-xs)/1.3 var(--mono);letter-spacing:.12em;text-transform:uppercase;color:var(--ink-2);overflow-wrap:anywhere}.it{margin:0;font:700 var(--t-l)/1.25 var(--mono);overflow-wrap:anywhere}.idesc{margin:10px 0 0;color:var(--ink-2);font-size:var(--t-s)}.chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:12px}.chip{font:700 var(--t-xs)/1 var(--mono);letter-spacing:.08em;text-transform:uppercase;padding:5px 7px 4px;border:2px solid currentColor}.chip.ok{color:var(--ok)}.chip.bad{color:var(--danger)}.ib{padding:4px 18px 18px;display:grid;gap:16px}.fl{margin:0;display:grid}.f{display:grid;gap:4px;padding-top:12px;margin-top:12px;border-top:1px dashed var(--ink-3)}.f:first-child{border-top:0}.f dt{font:700 var(--t-xs)/1.2 var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--ink-2)}.f dd{margin:0;font-size:var(--t-s);overflow-wrap:anywhere;min-width:0}.list{list-style:none;margin:8px 0 0;padding:0;display:grid;gap:8px;font-size:var(--t-s)}.list .when{color:var(--ink-2)}.code{border:2px solid var(--ink);min-width:0}.code-h{padding:6px 10px;border-bottom:2px solid var(--ink);background:var(--concrete);font:700 var(--t-xs)/1.3 var(--mono);letter-spacing:.08em;text-transform:uppercase;color:var(--ink-2)}.code pre{margin:0;padding:10px;font-size:var(--t-xs);line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere}.fn{display:block;margin-top:4px;font-size:var(--t-xs);color:var(--ink-2)}.keys{display:grid;gap:10px;min-width:0}.keys .fl{margin-top:-4px}.keys .f:first-child{margin-top:0}.keys .lab:not(:first-child){margin-top:6px}.leaves{margin:0}.leaves code{display:block;margin-top:2px;font:var(--t-xs)/1.5 var(--mono);overflow-wrap:anywhere}.cph{display:flex;align-items:center;justify-content:space-between;gap:8px}.cph span{min-width:0;overflow-wrap:anywhere}.cp{flex:none;font:700 var(--t-xs)/1 var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:5px 8px 4px;border:2px solid var(--ink);border-radius:0;background:var(--slab);color:var(--ink);cursor:pointer}.cp:hover{background:var(--signal);color:var(--on-signal)}.secret{border:2px solid var(--ink)}.hz{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px;background:repeating-linear-gradient(-45deg,var(--signal) 0 12px,#141414 12px 24px)}.hz-l{background:#141414;color:var(--signal);font:700 var(--t-xs)/1 var(--mono);letter-spacing:.12em;text-transform:uppercase;padding:6px 8px 5px}.sb{display:grid;gap:10px;padding:12px}.scrub{flex:1 1 400px;display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center}.scrub .lab{margin:0}.scrub input[type=range]{flex:1 1 120px;min-width:80px;min-width:0;margin:0;height:28px;accent-color:var(--ink);cursor:pointer}.scrub output{font:700 var(--t-s)/1 var(--mono);min-width:12ch;white-space:nowrap}.beats{list-style:none;margin:0;padding:6px 0;max-height:480px;overflow:auto;overscroll-behavior:contain}.beat{padding:10px 18px}.beat+.beat{border-top:1px dashed var(--ink-3)}.bh{margin:0 0 6px;font:700 var(--t-xs)/1.3 var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--ink-2);display:flex;flex-wrap:wrap;gap:4px 12px}.bt{font-weight:400;letter-spacing:.04em}.beat.now .bh .bn{background:var(--signal);color:var(--on-signal);padding:2px 5px;margin:-2px -5px}.evs{list-style:none;margin:0;padding:0;display:grid;gap:2px}.ev{width:calc(100% + 6px);display:flex;gap:1ch;text-align:left;background:transparent;border:0;padding:3px 6px;margin-left:-6px;cursor:pointer;border-radius:0;font-size:var(--t-s)}.ev .op{flex:none;min-width:9ch;font-weight:700}.ev .es{min-width:0;color:var(--ink-2);overflow-wrap:anywhere}.ev:hover .es{text-decoration:underline;text-underline-offset:3px}.ev.bad .op,.ev.bad .es{color:var(--danger)}.beat.later .bh,.beat.later .op,.beat.later .es{color:var(--ink-3)}.beat.later .ev .op{font-weight:400}.ev.on{background:var(--signal)}.ev.on .op,.ev.on .es{color:var(--on-signal)}.foot{display:grid;gap:10px;color:var(--ink-2);font-size:var(--t-s);max-width:100ch}.foot p{margin:0}.labrow{display:flex;flex-wrap:wrap;gap:10px;align-items:center}.confirm{flex-basis:100%;display:flex;flex-wrap:wrap;gap:10px;align-items:center;padding:10px 12px;border:2px dashed var(--ink);color:var(--ink)}@media(min-width:761px){.scrub{flex-wrap:nowrap}}@media(max-width:1120px){.work{grid-template-columns:minmax(0,1fr) minmax(0,370px);grid-template-rows:auto auto 1fr;grid-template-areas:"hold side" "tree side" "time side"}}@media(max-width:760px){.clock{position:static}.work{grid-template-columns:minmax(0,1fr);grid-template-rows:none;grid-template-areas:"hold" "tree" "side" "time"}}@media(max-width:640px){.panel{box-shadow:5px 5px 0 var(--shadow)}.flag.proto{display:none}.tree{font-size:var(--t-s)}.sel,.grp{padding-left:10px}.v .belt{display:none}.beat{padding:10px 14px}.ev{flex-direction:column;gap:0}}@media(prefers-reduced-motion:reduce){.btn:active,.btn.sm:active{transform:none}}.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.code-h{margin:0} +:root{--concrete: #e4e3dd;--slab: #f6f5f1;--ink: #141414;--ink-2: #4a4944;--ink-3: #66655f;--signal: #ffc21a;--on-signal: #141414;--ok: #1d7a3a;--danger: #b3261e;--focus: #2346ff;--band: #141414;--band-fg: #f6f5f1;--band-muted: #b0afa8;--shadow: #141414;--mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;--display: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;--t-xs: .75rem;--t-s: .8125rem;--t-m: .9375rem;--t-l: 1.25rem;--gutter: max(16px, env(safe-area-inset-left, 0px));color-scheme:light}@media(prefers-color-scheme:dark){:root:not([data-theme=light]){--concrete: #151514;--slab: #1e1e1c;--ink: #ecebe4;--ink-2: #b9b8b0;--ink-3: #94938b;--ok: #62c784;--danger: #ff8a7f;--focus: #93a8ff;--band: #0b0b0a;--band-fg: #ecebe4;--band-muted: #9d9c95;--shadow: #4d4c47;color-scheme:dark}}:root[data-theme=dark]{--concrete: #151514;--slab: #1e1e1c;--ink: #ecebe4;--ink-2: #b9b8b0;--ink-3: #94938b;--ok: #62c784;--danger: #ff8a7f;--focus: #93a8ff;--band: #0b0b0a;--band-fg: #ecebe4;--band-muted: #9d9c95;--shadow: #4d4c47;color-scheme:dark}*{box-sizing:border-box}[hidden]{display:none!important}html{-webkit-text-size-adjust:100%}body{margin:0;background:var(--concrete);color:var(--ink);font:400 var(--t-m)/1.5 var(--mono)}body.busy{cursor:progress}::selection{background:var(--signal);color:var(--on-signal)}button,select,input,textarea{font:inherit;color:inherit}:focus-visible{outline:3px solid var(--focus);outline-offset:2px}a{color:inherit;text-decoration-thickness:2px;text-underline-offset:3px}b{font-weight:700}.band{background:var(--band);color:var(--band-fg);border-bottom:3px solid var(--ink)}.band-in{max-width:1320px;margin:0 auto;padding:16px var(--gutter) 14px;display:flex;flex-wrap:wrap;gap:14px 32px;align-items:flex-end;justify-content:space-between}.kicker{margin:0 0 8px;font:700 var(--t-xs)/1 var(--mono);letter-spacing:.12em;text-transform:uppercase;color:var(--band-muted)}.kicker a{color:var(--band-fg)}.wordmark{margin:0;font:900 clamp(2.25rem,6vw,3.5rem)/.84 var(--display);letter-spacing:-.05em;text-transform:uppercase}.lede{margin:10px 0 0;color:var(--band-muted);font-size:var(--t-s);max-width:88ch}.lede b{color:var(--band-fg)}.flags{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.flag{font:700 var(--t-xs)/1 var(--mono);letter-spacing:.1em;text-transform:uppercase;padding:7px 9px 6px;border:2px solid var(--band-fg);background:transparent;color:var(--band-fg);border-radius:0}.flag.hz{background:var(--signal);border-color:var(--signal);color:var(--on-signal)}button.flag{cursor:pointer}button.flag:hover{background:var(--band-fg);color:var(--band)}.clock{background:var(--slab);border-bottom:3px solid var(--ink);position:sticky;top:0;z-index:5}.clock-in{max-width:1320px;margin:0 auto;padding:10px var(--gutter);display:flex;flex-wrap:wrap;gap:10px 18px;align-items:center}.tempo{display:flex;flex-wrap:wrap;align-items:center}.tempo .lab{margin:0 10px 0 0}.seg{font:700 var(--t-xs)/1 var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:9px 10px 8px;border:2px solid var(--ink);background:var(--slab);color:var(--ink);cursor:pointer;border-radius:0;margin-left:-2px}.seg:first-of-type{margin-left:0}.seg:hover:not([aria-pressed=true]){background:var(--concrete)}.seg[aria-pressed=true]{background:var(--ink);color:var(--slab)}.seg:focus-visible{position:relative;z-index:1}.beatno{margin:0;flex:1 1 22ch;font-size:var(--t-s);color:var(--ink-2)}.beatno b{color:var(--ink);font-size:var(--t-m)}.say{max-width:1320px;margin:0 auto;padding:0 var(--gutter) 10px;font-size:var(--t-s);color:var(--ink-2)}.say:empty{display:none}.say.bad{color:var(--danger);font-weight:700}.wrap{max-width:1320px;margin:0 auto;padding:32px var(--gutter) 56px;display:grid;gap:40px}.work{display:grid;gap:36px 28px;align-items:start;grid-template-columns:minmax(0,250px) minmax(0,1fr) minmax(0,390px);grid-template-areas:"hold tree side" "hold time side";grid-template-rows:auto 1fr}.hold-blk{grid-area:hold}.tree-blk{grid-area:tree}.time-blk{grid-area:time}.side{grid-area:side;display:grid;gap:36px;min-width:0}.blk{display:flex;flex-direction:column;align-items:flex-start;min-width:0}.blk>.panel{align-self:stretch}.tab{margin:0;background:var(--ink);color:var(--slab);font:700 var(--t-xs)/1 var(--mono);letter-spacing:.14em;text-transform:uppercase;padding:8px 11px 7px;display:flex;gap:12px;max-width:100%}.tab .sub{font-weight:400;letter-spacing:.06em;text-transform:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tab .sub:empty{display:none}.panel{background:var(--slab);border:3px solid var(--ink);box-shadow:8px 8px 0 var(--shadow);min-width:0}.pad{padding:16px 18px}.lab{display:block;font:700 var(--t-xs)/1.2 var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--ink-2)}.lab span{font-weight:400;letter-spacing:.04em;text-transform:none}.note{margin:0;font-size:var(--t-s);color:var(--ink-2)}.note p{margin:0 0 12px}.wait{margin:0;padding:4px 16px;color:var(--ink-3);font-size:var(--t-s)}.hint{margin:8px 0 0;font-size:var(--t-xs);color:var(--ink-2)}input:not([type]),input[type=text],select,textarea{width:100%;padding:8px 10px;border:2px solid var(--ink);border-radius:0;background:var(--concrete);min-width:0}textarea{resize:vertical;line-height:1.5}.line{display:flex;flex-wrap:wrap;gap:10px;align-items:stretch}.line input{flex:1 1 12ch;width:auto}.btn{font:700 var(--t-s)/1 var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:10px 12px 9px;background:var(--slab);color:var(--ink);border:2px solid var(--ink);box-shadow:3px 3px 0 var(--shadow);cursor:pointer;border-radius:0}.btn:hover{background:var(--concrete)}.btn:active{transform:translate(3px,3px);box-shadow:none}.btn.primary{background:var(--signal);color:var(--on-signal);border-color:var(--ink)}.btn.danger{background:var(--danger);color:var(--slab)}.btn.sm{font-size:var(--t-xs);padding:7px 9px 6px;box-shadow:2px 2px 0 var(--shadow)}.btn.sm:active{transform:translate(2px,2px)}.btn:disabled,.seg:disabled{cursor:not-allowed;background:var(--concrete);color:var(--ink-3);border-color:var(--ink-3);box-shadow:none;transform:none}.holds{list-style:none;margin:0;padding:0}.holds li+li{border-top:2px solid var(--ink)}.hold{width:100%;display:grid;gap:3px;text-align:left;background:transparent;border:0;padding:12px 18px;cursor:pointer;border-radius:0}.hold:hover .hn{text-decoration:underline;text-underline-offset:3px}.hn{font-weight:700;overflow-wrap:anywhere}.hm{font-size:var(--t-xs);color:var(--ink-2)}.hold.on{background:var(--signal)}.hold.on .hn,.hold.on .hm{color:var(--on-signal)}.hold.gone .hn{text-decoration:line-through;text-decoration-thickness:2px}.holds:not(:empty)~.found{border-top:3px solid var(--ink)}.empty p{margin:0;font-size:var(--t-s);color:var(--ink-2)}.found .lab{margin-bottom:8px}.sample{border-top:2px dashed var(--ink-3)}.tree{padding:12px 0;font-size:.875rem;overflow-x:auto}.row{display:flex;align-items:stretch;min-width:max-content}.sel{flex:1;display:flex;align-items:baseline;text-align:left;background:transparent;border:0;padding:4px 14px 4px 16px;cursor:pointer;line-height:1.55;border-radius:0}.sel:hover .l{text-decoration:underline;text-underline-offset:3px}.g{white-space:pre;color:var(--ink-3);flex:none}.p{white-space:pre;font-weight:700;flex:none}.l{flex:none;color:var(--ink);font-weight:700;white-space:nowrap}.v{flex:1 0 auto;display:flex;gap:5px;justify-content:flex-end;align-items:center;margin-left:2ch}.grp{padding:0 14px 0 16px;line-height:1.55;color:var(--ink-3)}.gl{color:var(--ink-2)}.row.on .sel{background:var(--signal)}.row.on .g,.row.on .p,.row.on .l,.row.on .mk,.row.on .belt{color:var(--on-signal);border-color:var(--on-signal)}.row.gone .l,.row.gone .p{text-decoration:line-through;text-decoration-thickness:2px}.row.gone .l{color:var(--ink-2)}.row.cue .l{font-weight:400;font-style:italic}.mk{font:700 .6875rem/1 var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:3px 5px 2px;border:2px solid currentColor;color:var(--ink-2);white-space:nowrap}.mk.ok{color:var(--ok)}.mk.bad{color:var(--danger)}.belt{display:inline-flex;align-items:center;gap:5px;font:700 .6875rem/1 var(--mono);padding:2px 5px 2px 3px;border:2px solid var(--ink);color:var(--ink);white-space:nowrap}.belt:before{content:"";width:10px;height:10px;flex:none;border:1.5px solid currentColor;background:#f6f5f1}.belt.green:before{background:#1d7a3a}.belt.black:before{background:#141414}.verbs{display:flex;flex-wrap:wrap;border-bottom:3px solid var(--ink)}.verbs button{flex:1 1 auto;font:700 var(--t-s)/1 var(--mono);padding:12px 10px;background:transparent;border:0;border-right:2px solid var(--ink);color:var(--ink-2);cursor:pointer;border-radius:0}.verbs button:last-child{border-right:0}.verbs button.off{color:var(--ink-3)}.verbs button:hover:not([aria-pressed=true]){color:var(--ink);text-decoration:underline;text-underline-offset:3px}.verbs button[aria-pressed=true]{background:var(--ink);color:var(--slab)}.why{margin:0;font-size:var(--t-s);color:var(--ink-2)}.keyline{margin:0;padding:10px 18px;font-size:var(--t-xs);color:var(--ink-2);overflow-wrap:anywhere;border-bottom:1px dashed var(--ink-3)}.keyline:empty{display:none}.why:empty{display:none}.vf{display:grid;gap:6px}.vf .lab{margin-top:8px}.vh{margin:0;font-size:var(--t-s);color:var(--ink-2)}.vh b{color:var(--ink)}.vf .go,.vf .line{margin-top:12px}.vf>.go{justify-self:start}.vf .line .go{margin-top:0}.kinds{border:0;margin:0;padding:0;display:grid;gap:6px;min-width:0}.kinds legend{padding:0;margin:8px 0 6px}.kinds label{display:flex;gap:8px;align-items:baseline;cursor:pointer;font-weight:700}.kinds label span{font-weight:400;font-size:var(--t-s);color:var(--ink-2)}.kinds input{accent-color:var(--ink);margin:0}.ih{padding:16px 18px 14px;border-bottom:3px solid var(--ink)}.eyebrow{margin:0 0 8px;font:700 var(--t-xs)/1.3 var(--mono);letter-spacing:.12em;text-transform:uppercase;color:var(--ink-2);overflow-wrap:anywhere}.it{margin:0;font:700 var(--t-l)/1.25 var(--mono);overflow-wrap:anywhere}.idesc{margin:10px 0 0;color:var(--ink-2);font-size:var(--t-s)}.chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:12px}.chip{font:700 var(--t-xs)/1 var(--mono);letter-spacing:.08em;text-transform:uppercase;padding:5px 7px 4px;border:2px solid currentColor}.chip.ok{color:var(--ok)}.chip.bad{color:var(--danger)}.ib{padding:4px 18px 18px;display:grid;gap:16px}.fl{margin:0;display:grid}.f{display:grid;gap:4px;padding-top:12px;margin-top:12px;border-top:1px dashed var(--ink-3)}.f:first-child{border-top:0}.f dt{font:700 var(--t-xs)/1.2 var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--ink-2)}.f dd{margin:0;font-size:var(--t-s);overflow-wrap:anywhere;min-width:0}.list{list-style:none;margin:8px 0 0;padding:0;display:grid;gap:8px;font-size:var(--t-s)}.list .when{color:var(--ink-2)}.code{border:2px solid var(--ink);min-width:0}.code-h{padding:6px 10px;border-bottom:2px solid var(--ink);background:var(--concrete);font:700 var(--t-xs)/1.3 var(--mono);letter-spacing:.08em;text-transform:uppercase;color:var(--ink-2)}.code pre{margin:0;padding:10px;font-size:var(--t-xs);line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere}.fn{display:block;margin-top:4px;font-size:var(--t-xs);color:var(--ink-2)}.keys{display:grid;gap:10px;min-width:0}.keys .fl{margin-top:-4px}.keys .f:first-child{margin-top:0}.keys .lab:not(:first-child){margin-top:6px}.leaves{margin:0}.leaves code{display:block;margin-top:2px;font:var(--t-xs)/1.5 var(--mono);overflow-wrap:anywhere}.cph{display:flex;align-items:center;justify-content:space-between;gap:8px}.cph span{min-width:0;overflow-wrap:anywhere}.cp{flex:none;font:700 var(--t-xs)/1 var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:5px 8px 4px;border:2px solid var(--ink);border-radius:0;background:var(--slab);color:var(--ink);cursor:pointer}.cp:hover{background:var(--signal);color:var(--on-signal)}.secret{border:2px solid var(--ink)}.hz{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px;background:repeating-linear-gradient(-45deg,var(--signal) 0 12px,#141414 12px 24px)}.hz-l{background:#141414;color:var(--signal);font:700 var(--t-xs)/1 var(--mono);letter-spacing:.12em;text-transform:uppercase;padding:6px 8px 5px}.sb{display:grid;gap:10px;padding:12px}.scrub{flex:1 1 400px;display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center}.scrub .lab{margin:0}.scrub input[type=range]{flex:1 1 120px;min-width:80px;min-width:0;margin:0;height:28px;accent-color:var(--ink);cursor:pointer}.scrub output{font:700 var(--t-s)/1 var(--mono);min-width:12ch;white-space:nowrap}.beats{list-style:none;margin:0;padding:6px 0;max-height:480px;overflow:auto;overscroll-behavior:contain}.beat{padding:10px 18px}.beat+.beat{border-top:1px dashed var(--ink-3)}.bh{margin:0 0 6px;font:700 var(--t-xs)/1.3 var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--ink-2);display:flex;flex-wrap:wrap;gap:4px 12px}.bt{font-weight:400;letter-spacing:.04em}.beat.now .bh .bn{background:var(--signal);color:var(--on-signal);padding:2px 5px;margin:-2px -5px}.evs{list-style:none;margin:0;padding:0;display:grid;gap:2px}.ev{width:calc(100% + 6px);display:flex;gap:1ch;text-align:left;background:transparent;border:0;padding:3px 6px;margin-left:-6px;cursor:pointer;border-radius:0;font-size:var(--t-s)}.ev .op{flex:none;min-width:9ch;font-weight:700}.ev .es{min-width:0;color:var(--ink-2);overflow-wrap:anywhere}.ev:hover .es{text-decoration:underline;text-underline-offset:3px}.ev.bad .op,.ev.bad .es{color:var(--danger)}.beat.later .bh,.beat.later .op,.beat.later .es{color:var(--ink-3)}.beat.later .ev .op{font-weight:400}.ev.on{background:var(--signal)}.ev.on .op,.ev.on .es{color:var(--on-signal)}.foot{display:grid;gap:10px;color:var(--ink-2);font-size:var(--t-s);max-width:100ch}.foot p{margin:0}.labrow{display:flex;flex-wrap:wrap;gap:10px;align-items:center}.confirm{flex-basis:100%;display:flex;flex-wrap:wrap;gap:10px;align-items:center;padding:10px 12px;border:2px dashed var(--ink);color:var(--ink)}@media(min-width:761px){.scrub{flex-wrap:nowrap}}@media(max-width:1120px){.work{grid-template-columns:minmax(0,1fr) minmax(0,370px);grid-template-rows:auto auto 1fr;grid-template-areas:"hold side" "tree side" "time side"}}@media(max-width:760px){.clock{position:static}.work{grid-template-columns:minmax(0,1fr);grid-template-rows:none;grid-template-areas:"hold" "tree" "side" "time"}}@media(max-width:640px){.panel{box-shadow:5px 5px 0 var(--shadow)}.flag.proto{display:none}.tree{font-size:var(--t-s)}.sel,.grp{padding-left:10px}.v .belt{display:none}.beat{padding:10px 14px}.ev{flex-direction:column;gap:0}}@media(prefers-reduced-motion:reduce){.btn:active,.btn.sm:active{transform:none}}.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.code-h{margin:0}.mk.sats{color:var(--ink);text-transform:none;letter-spacing:.02em}.ev.money .op{color:var(--ok)}.ev.money.on .op{color:var(--on-signal)}.beat.later .ev.money .op{color:var(--ink-3)}.vf .line.amt{margin-top:0}#clock-pays{white-space:nowrap}.verbs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr))}.verbs button:nth-child(3n){border-right:0}.verbs button:nth-child(-n+3){border-bottom:2px solid var(--ink)}@media(max-width:640px){.v{margin-left:1ch}.mk{padding:3px 4px 2px}} diff --git a/ventures/lineage/orgchain/assets/index-C8pEZCQ4.js b/ventures/lineage/orgchain/assets/index-C8pEZCQ4.js new file mode 100644 index 0000000..38527bb --- /dev/null +++ b/ventures/lineage/orgchain/assets/index-C8pEZCQ4.js @@ -0,0 +1,2063 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const Za=5e9;function jc(e,t,n){const r=[];for(const[s,o]of e){const i=o-s;if(t>=i){t-=i;continue}const a=Math.min(n,i-t);if(a&&r.push([s+t,s+t+a]),n-=a,t=0,!n)break}return r}function Kc(e,t){var n;return(n=jc(e,t,1)[0])==null?void 0:n[0]}function ys(e,t){let n=0;for(const[r,s]of e){if(t>=r&&ti.ranges);let o=0;return e.vout.map(i=>{const a=jc(s,o,Number(i.value));return o+=Number(i.value),a})}function si(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function Td(e){if(typeof e!="boolean")throw new Error(`Expected boolean, not ${e}`)}function Zc(e,...t){if(!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new TypeError(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Cd(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");si(e.outputLen),si(e.blockLen)}function Pd(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ud(e,t){Zc(e);const n=t.outputLen;if(e.lengthnew DataView(e.buffer,e.byteOffset,e.byteLength),lt=(e,t)=>e<<32-t|e>>>t,Ld=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Ld)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Rd(e){if(typeof e!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function Vc(e){if(typeof e=="string"&&(e=Rd(e)),!(e instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof e})`);return e}let Hd=class{clone(){return this._cloneInto()}};function Mc(e){const t=r=>e().update(Vc(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function jd(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,a,r)}let Kd=class extends Hd{constructor(t,n,r,s){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Ao(this.buffer)}update(t){$o.exists(this);const{view:n,buffer:r,blockLen:s}=this;t=Vc(t);const o=t.length;for(let i=0;is-i&&(this.process(r,0),i=0);for(let l=i;lf.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;le&t^~e&n,Zd=(e,t,n)=>e&t^e&n^t&n,Vd=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]),Lt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Rt=new Uint32Array(64);let qc=class extends Kd{constructor(){super(64,32,8,!1),this.A=Lt[0]|0,this.B=Lt[1]|0,this.C=Lt[2]|0,this.D=Lt[3]|0,this.E=Lt[4]|0,this.F=Lt[5]|0,this.G=Lt[6]|0,this.H=Lt[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[t,n,r,s,o,i,a,c]}set(t,n,r,s,o,i,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,n){for(let l=0;l<16;l++,n+=4)Rt[l]=t.getUint32(n,!1);for(let l=16;l<64;l++){const d=Rt[l-15],h=Rt[l-2],m=lt(d,7)^lt(d,18)^d>>>3,y=lt(h,17)^lt(h,19)^h>>>10;Rt[l]=y+Rt[l-7]+m+Rt[l-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){const d=lt(a,6)^lt(a,11)^lt(a,25),h=f+d+Dd(a,c,u)+Vd[l]+Rt[l]|0,y=(lt(r,2)^lt(r,13)^lt(r,22))+Zd(r,s,o)|0;f=u,u=c,c=a,a=i+h|0,i=o,o=s,s=r,r=h+y|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,s,o,i,a,c,u,f)}roundClean(){Rt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Md=class extends qc{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 oi=Mc(()=>new qc);Mc(()=>new Md);function qd(e,t){if(e.length>t)throw new TypeError(`Data is larger than array size: ${e.length} > ${t}`)}function zd(e){if(e.match(/[^a-fA-f0-9]/)!==null)throw new TypeError("Invalid characters in hex string: "+e);if(e.length%2!==0)throw new Error(`Length of hex string is invalid: ${e.length}`)}function Fd(e){if(e>Number.MAX_SAFE_INTEGER)throw new TypeError("Number exceeds safe bounds!")}const{getRandomValues:Gd}=crypto??globalThis.crypto??window.crypto;function Wd(e=32){if(typeof Gd=="function")return crypto.getRandomValues(new Uint8Array(e));throw new Error("Crypto module missing getRandomValues!")}function Yd(e,t,n="be"){t===void 0&&(t=e.length),qd(e,t);const r=new Uint8Array(t).fill(0),s=n==="be"?0:t-e.length;return r.set(e,s),r}function zc(e){let t,n=0;const r=e.reduce((o,i)=>o+i.length,0),s=new Uint8Array(r);for(t=0;t0||(i.length^a)>0?"":"1";c in o||u>0;)f=o[c],f=f>0?f*256+u:u,u=f/s|0,o[c]=f%s,c++;for(;c-- >0;)i+=r[o[c]];return n&&i.length%4>0?i+"=".repeat(4-i.length%4):i}function eh(e,t){const n=Fc(t),r=n.length,s=[],o=[];e=e.replace("=","");let i,a=0,c,u;for(i=0;i0||(o.length^i)>0||o.push(0);a in s||c>0;)u=s[a],u=u>0?u*r+c:c,c=u>>8,s[a]=u%256,a++}for(;a-- >0;)o.push(s[a]);return new Uint8Array(o)}function Gc(e){return oi(oi(e))}function th(e){const t=Gc(e);return zc([e,t.slice(0,4)])}function nh(e){const t=e.slice(0,-4),n=e.slice(-4);if(Gc(t).slice(0,4).toString()!==n.toString())throw new Error("Invalid checksum!");return t}const Va={encode:Qd,decode:eh},Wc={encode:e=>{const t=th(e);return Va.encode(t,"base58")},decode:e=>{const t=Va.decode(e,"base58");return nh(t)}},Yc="qpzry9x8gf2tvdw0s3jn54khce6mua7l",rh=[996825010,642813549,513874426,1027748829,705979059],ks=[{version:0,name:"bech32",const:1},{version:1,name:"bech32m",const:734539939}];function Xc(e){let t=1;for(let n=0;n>25;t=(t&33554431)<<5^e[n];for(let s=0;s<5;++s)(r>>s&1)!==0&&(t^=rh[s])}return t}function Jc(e){const t=[];let n;for(n=0;n>5);for(t.push(0),n=0;n>5*(5-i)&31);return o}function Qc(e,t,n,r=!0){const s=[];let o=0,i=0;const a=(1<>t>0)throw new Error("Failed to perform base conversion. Invalid value: "+String(u));for(o=(o<=n;)i-=n,s.push(o>>i&a)}if(r)i>0&&s.push(o<=t||(o<0)throw new Error("Failed to perform base conversion. Invalid Size!");return s}function ih(e,t,n){const r=t.concat(oh(e,t,n));let s=e+"1";for(let o=0;oo.version===t[0])??ks[0];if(!sh(r,t,s))throw new Error("Checksum verification failed!");return[r,t.slice(0,t.length-6)]}function ah(e){let t,n,r=!1,s=!1;for(t=0;t126)return!1;n>=97&&n<=122&&(r=!0),n>=65&&n<=90&&(s=!0)}return!(r&&s)}function ch(e){const t=e.lastIndexOf("1");return!(t<1||t+7>e.length||e.length>90)}function uh(e,t="bc",n=0){const r=[n,...Qc([...e],8,5)],s=ks.find(i=>i.version===n)??ks[0],o=ih(t,r,s);return tu(o),o}function tu(e){e=e.toLowerCase();const t=e.split("1",1)[0],[n,r]=eu(e),s=Qc(r.slice(1),5,8,!1),o=s.length;switch(!0){case t!==n:throw new Error("Returned hrp string is invalid.");case(s===null||o<2||o>40):throw new Error("Decoded string is invalid or out of spec.");case r[0]>16:throw new Error("Returned version bit is out of range.");default:return Uint8Array.from(s)}}function fh(e){e=e.toLowerCase();const[t,n]=eu(e);return n[0]}const nu={encode:uh,decode:tu,version:fh},ru="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",su="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",lh=new TextEncoder;function ou(e,t=!1,n=!0){typeof e=="string"&&(e=lh.encode(e));const r=t?su:ru;let s="",o=0,i=0;for(let a=0;a=6;)o-=6,s+=r[i>>o&63];if(o>0)for(i<<=6-o,s+=r[i&63];o<6;)s+=n?"=":"",o+=2;return s}function iu(e,t=!1){const n=t||e.includes("-")||e.includes("_")?su.split(""):ru.split("");e=e.replace(/=+$/,"");const r=e.split("");let s=0,o=0;const i=[];for(let a=0;a=8&&(s-=8,i.push(o>>>s&255))}return new Uint8Array(i)}const au={encode:ou,decode:iu},cu={encode:e=>ou(e,!0,!1),decode:e=>iu(e,!0)},dh=BigInt(0),hh=BigInt(255),uu=BigInt(256);function ph(e){if(e<=0xffn)return 1;if(e<=0xffffn)return 2;if(e<=0xffffffffn)return 4;if(e<=0xffffffffffffffffn)return 8;if(e<=0xffffffffffffffffffffffffffffffffn)return 16;if(e<=0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn)return 32;throw new TypeError("Must specify a fixed buffer size for bigints greater than 32 bytes.")}function gh(e,t,n="be"){t===void 0&&(t=ph(e));const r=n==="le",s=new ArrayBuffer(t),o=new DataView(s);let i=r?0:t-1;for(;e>dh;){const a=e&hh,c=Number(a);r?o.setUint8(i++,c):o.setUint8(i--,c),e=(e-a)/uu}return new Uint8Array(s)}function mh(e){let t=BigInt(0);for(let n=e.length-1;n>=0;n--)t=t*uu+BigInt(e[n]);return BigInt(t)}function yh(e){const t=e.split("").map(Number);if(t.length%8!==0)throw new Error(`Binary array is invalid length: ${e.length}`);const n=new Uint8Array(t.length/8);for(let r=0,s=0;r255)throw new Error(`Invalid byte value: ${r}. Byte values must be between 0 and 255.`);for(let s=7;s>=0;s--,n++)t[n]=r>>s&1}return t.join("")}function wh(e){if(e<=255)return 1;if(e<=65535)return 2;if(e<=4294967295)return 4;throw new TypeError("Numbers larger than 4 bytes must specify a fixed size!")}function xh(e,t,n="be"){t===void 0&&(t=wh(e));const r=n==="le",s=new ArrayBuffer(t),o=new DataView(s);let i=r?0:t-1;for(;e>0;){const a=e&255;r?o.setUint8(i++,e):o.setUint8(i--,e),e=(e-a)/256}return new Uint8Array(s)}function vh(e){let t=0;for(let n=e.length-1;n>=0;n--)t=t*256+e[n],Fd(t);return t}const Eh=new TextEncoder,Sh=new TextDecoder;function Hi(e){return Eh.encode(e)}function Bo(e){return Sh.decode(e)}function kh(e,t){zd(e);const n=e.length/2;if(t===void 0&&(t=n),n>t)throw new TypeError(`Hex string is larger than array size: ${n} > ${t}`);return t}function _h(e,t,n="le"){t=kh(e,t);const r=n==="le",s=new ArrayBuffer(t),o=new DataView(s);let i=r?0:t-1;for(let a=0;atypeof r=="bigint"?`${r}n`:r);return Hi(t)}function Bh(e,t,n){if(e instanceof ArrayBuffer)return new Uint8Array(e);if(e instanceof Uint8Array)return Yd(e,t,n);if(typeof e=="string")return _h(e,t,n);if(typeof e=="bigint")return gh(e,t,n);if(typeof e=="number")return xh(e,t,n);if(typeof e=="boolean")return Uint8Array.of(e?1:0);throw TypeError("Unsupported format:"+typeof e)}var X;let E=(X=class extends Uint8Array{static random(t=32){const n=Wd(t);return new X(n,t)}constructor(t,n,r){const s=Bh(t,n,r);super(s)}get arr(){return[...this]}get num(){return this.toNum()}get big(){return this.toBig()}get str(){return this.toStr()}get hex(){return this.toHex()}get raw(){return new Uint8Array(this)}get bin(){return this.toBin()}get b58chk(){return this.tob58chk()}get base64(){return this.toBase64()}get b64url(){return this.toB64url()}get digest(){return this.toHash()}get id(){return this.toHash().hex}get stream(){return new ar(this)}toNum(t="be"){const n=t==="be"?this.reverse():this;return vh(n)}toBin(){return bh(this)}toBig(t="be"){const n=t==="be"?this.reverse():this;return mh(n)}toHash(){const t=oi(this);return new X(t)}toJson(){const t=Bo(this);return JSON.parse(t)}toBech32(t,n=0){return nu.encode(this,t,n)}toStr(){return Bo(this)}toHex(){return $h(this)}toBytes(){return new Uint8Array(this)}tob58chk(){return Wc.encode(this)}toBase64(){return au.encode(this)}toB64url(){return cu.encode(this)}prepend(t){return X.join([X.bytes(t),this])}append(t){return X.join([this,X.bytes(t)])}slice(t,n){const r=new Uint8Array(this).slice(t,n);return new X(r)}subarray(t,n){const r=new Uint8Array(this).subarray(t,n);return new X(r)}reverse(){const t=new Uint8Array(this).reverse();return new X(t)}write(t,n){const r=X.bytes(t);this.set(r,n)}prefixSize(t){const n=X.varInt(this.length,t);return X.join([n,this])}static from(t){return new X(Uint8Array.from(t))}static of(...t){return new X(Uint8Array.of(...t))}static join(t){const n=t.map(s=>X.bytes(s)),r=zc(n);return new X(r)}static varInt(t,n){if(t<253)return X.num(t,1);if(t<65536)return X.of(253,...X.num(t,2,n));if(t<4294967296)return X.of(254,...X.num(t,4,n));if(BigInt(t)<0x10000000000000000n)return X.of(255,...X.num(t,8,n));throw new Error(`Value is too large: ${t}`)}},X.num=Oh,X.big=Th,X.bin=Ih,X.raw=Ch,X.str=Ph,X.hex=Uh,X.bytes=Nh,X.json=Lh,X.base64=Rh,X.b64url=Hh,X.bech32=jh,X.b58chk=Kh,X.encode=Hi,X.decode=Bo,X);function Oh(e,t,n){return new E(e,t,n)}function Ih(e,t,n){return new E(yh(e),t,n)}function Th(e,t,n){return new E(e,t,n)}function Ch(e,t,n){return new E(e,t,n)}function Ph(e,t,n){return new E(Hi(e),t,n)}function Uh(e,t,n){return new E(e,t,n)}function Nh(e,t,n){return new E(e,t,n)}function Lh(e){return new E(Ah(e))}function Rh(e){return new E(au.decode(e))}function Hh(e){return new E(cu.decode(e))}function jh(e){return new E(nu.decode(e))}function Kh(e){return new E(Wc.decode(e))}let ar=class{constructor(t){this.data=E.bytes(t),this.size=this.data.length}peek(t){if(t>this.size)throw new Error(`Size greater than stream: ${t} > ${this.size}`);return new E(this.data.slice(0,t))}read(t){t=t??this.readSize();const n=this.peek(t);return this.data=this.data.slice(t),this.size=this.data.length,n}readSize(t){const n=this.read(1).num;switch(!0){case(n>=0&&n<253):return n;case n===253:return this.read(2).toNum(t);case n===254:return this.read(4).toNum(t);case n===255:return this.read(8).toNum(t);default:throw new Error(`Varint is out of range: ${n}`)}}};function Et(e,t){const n=E.bytes(e);if(n.length!==t)throw new Error(`Invalid input size: ${n.hex} !== ${t}`)}function Pe(e,t){if(t)throw new Error(e);return!1}function bs(e,...t){const n=E.str(e).digest.raw,r=t.map(s=>E.bytes(s));return E.join([n,n,E.join(r)]).digest}const fu={OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_SUCCESS80:80,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_SUCCESS98:98,OP_IF:99,OP_NOTIF:100,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_SUCCESS126:126,OP_SUCCESS127:127,OP_SUCCESS128:128,OP_SUCCESS129:129,OP_SIZE:130,OP_SUCCESS131:131,OP_SUCCESS132:132,OP_SUCCESS133:133,OP_SUCCESS134:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_SUCCESS137:137,OP_SUCCESS138:138,OP_1ADD:139,OP_1SUB:140,OP_SUCCESS141:141,OP_SUCCESS142:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_SUCCESS149:149,OP_SUCCESS150:150,OP_SUCCESS151:151,OP_SUCCESS152:152,OP_SUCCESS153:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_SUCCESS187:187,OP_SUCCESS188:188,OP_SUCCESS189:189,OP_SUCCESS190:190,OP_SUCCESS191:191,OP_SUCCESS192:192,OP_SUCCESS193:193,OP_SUCCESS194:194,OP_SUCCESS195:195,OP_SUCCESS196:196,OP_SUCCESS197:197,OP_SUCCESS198:198,OP_SUCCESS199:199,OP_SUCCESS200:200,OP_SUCCESS201:201,OP_SUCCESS202:202,OP_SUCCESS203:203,OP_SUCCESS204:204,OP_SUCCESS205:205,OP_SUCCESS206:206,OP_SUCCESS207:207,OP_SUCCESS208:208,OP_SUCCESS209:209,OP_SUCCESS210:210,OP_SUCCESS211:211,OP_SUCCESS212:212,OP_SUCCESS213:213,OP_SUCCESS214:214,OP_SUCCESS215:215,OP_SUCCESS216:216,OP_SUCCESS217:217,OP_SUCCESS218:218,OP_SUCCESS219:219,OP_SUCCESS220:220,OP_SUCCESS221:221,OP_SUCCESS222:222,OP_SUCCESS223:223,OP_SUCCESS224:224,OP_SUCCESS225:225,OP_SUCCESS226:226,OP_SUCCESS227:227,OP_SUCCESS228:228,OP_SUCCESS229:229,OP_SUCCESS230:230,OP_SUCCESS231:231,OP_SUCCESS232:232,OP_SUCCESS233:233,OP_SUCCESS234:234,OP_SUCCESS235:235,OP_SUCCESS236:236,OP_SUCCESS237:237,OP_SUCCESS238:238,OP_SUCCESS239:239,OP_SUCCESS240:240,OP_SUCCESS241:241,OP_SUCCESS242:242,OP_SUCCESS243:243,OP_SUCCESS244:244,OP_SUCCESS245:245,OP_SUCCESS246:246,OP_SUCCESS247:247,OP_SUCCESS248:248,OP_SUCCESS249:249,OP_SUCCESS250:250,OP_SUCCESS251:251,OP_SUCCESS252:252,OP_SUCCESS253:253,OP_SUCCESS254:254};function Dh(e){if(e>186&&e<255)return"OP_SUCCESS"+String(e);for(const[t,n]of Object.entries(fu))if(n===e)return t;throw new Error("OPCODE not found:"+String(e))}function Zh(e){for(const[t,n]of Object.entries(fu))if(t===e)return Number(n);throw new Error("OPCODE not found:"+e)}function Vh(e){switch(!0){case e===0:return"opcode";case(e>=1&&e<=75):return"varint";case e===76:return"pushdata1";case e===77:return"pushdata2";case e===78:return"pushdata4";case e<=254:return"opcode";default:throw new Error(`Invalid word range: ${e}`)}}function Mh(e){const r=[];switch(!0){case typeof e!="number":return!1;case e===0:return!0;case r.includes(e):return!1;case(750?E.join(t):new Uint8Array}function qh(e){let t=new Uint8Array;if(typeof e=="string"){if(e.startsWith("OP_"))return E.num(Zh(e),1);Nt(e)?t=E.hex(e):t=E.str(e)}else t=E.bytes(e);if(t.length===1)return t[0]!==0&&t[0]<=16?(t[0]+=80,t):(t[0]>128&&t[0]<=255&&(t=new Uint8Array([t[0],0])),E.join([Ma(t.length),t]));if(t.length>_s){const n=zh(t);return du(n)}else return E.join([Ma(t.length),t])}function Ma(e){const t=E.num(76,1),n=E.num(77,1);switch(!0){case e<=75:return E.num(e);case(e>75&&e<256):return E.join([t,E.num(e,1,"le")]);case(e>=256&&e<=_s):return E.join([n,E.num(e,2,"le")]);default:throw new Error("Invalid word size:"+e.toString())}}function zh(e){const t=[],n=new ar(e);for(;n.size>_s;)t.push(n.read(_s));return t.push(n.read(n.size)),t}function ji(e,t=!1){let n=E.bytes(e);if(t){const s=n.stream.readSize("le");if(n=n.slice(1),n.length!==s)throw new Error(`Varint does not match stream size: ${s} !== ${n.length}`)}return Fh(n)}function Fh(e){const t=new ar(e),n=[],r=t.size;let s,o,i,a=0;for(;a0&&!t.includes(e.length))throw new TypeError(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Qh(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ii(e.outputLen),ii(e.blockLen)}function e0(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function t0(e,t){hu(e);const n=t.outputLen;if(e.lengthnew DataView(e.buffer,e.byteOffset,e.byteLength),dt=(e,t)=>e<<32-t|e>>>t,r0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!r0)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function s0(e){if(typeof e!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function Ki(e){if(typeof e=="string"&&(e=s0(e)),!(e instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof e})`);return e}function o0(...e){if(!e.every(r=>r instanceof Uint8Array))throw new Error("Uint8Array list expected");if(e.length===1)return e[0];const t=e.reduce((r,s)=>r+s.length,0),n=new Uint8Array(t);for(let r=0,s=0;re().update(Ki(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function i0(e=32){if(Oo&&typeof Oo.getRandomValues=="function")return Oo.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function a0(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,a,r)}let c0=class extends pu{constructor(t,n,r,s){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Io(this.buffer)}update(t){gn.exists(this);const{view:n,buffer:r,blockLen:s}=this;t=Ki(t);const o=t.length;for(let i=0;is-i&&(this.process(r,0),i=0);for(let l=i;lf.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;le&t^~e&n,f0=(e,t,n)=>e&t^e&n^t&n,l0=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]),Ht=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),jt=new Uint32Array(64);let mu=class extends c0{constructor(){super(64,32,8,!1),this.A=Ht[0]|0,this.B=Ht[1]|0,this.C=Ht[2]|0,this.D=Ht[3]|0,this.E=Ht[4]|0,this.F=Ht[5]|0,this.G=Ht[6]|0,this.H=Ht[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[t,n,r,s,o,i,a,c]}set(t,n,r,s,o,i,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,n){for(let l=0;l<16;l++,n+=4)jt[l]=t.getUint32(n,!1);for(let l=16;l<64;l++){const d=jt[l-15],h=jt[l-2],m=dt(d,7)^dt(d,18)^d>>>3,y=dt(h,17)^dt(h,19)^h>>>10;jt[l]=y+jt[l-7]+m+jt[l-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){const d=dt(a,6)^dt(a,11)^dt(a,25),h=f+d+u0(a,c,u)+l0[l]+jt[l]|0,y=(dt(r,2)^dt(r,13)^dt(r,22))+f0(r,s,o)|0;f=u,u=c,c=a,a=i+h|0,i=o,o=s,s=r,r=h+y|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,s,o,i,a,c,u,f)}roundClean(){jt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},d0=class extends mu{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 yu=gu(()=>new mu);gu(()=>new d0);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const h0=BigInt(0),Di=BigInt(1),p0=BigInt(2),oo=e=>e instanceof Uint8Array,g0=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Xn(e){if(!oo(e))throw new Error("Uint8Array expected");let t="";for(let n=0;nJn(e.toString(16).padStart(t*2,"0")),wu=(e,t)=>Fn(e,t).reverse(),m0=e=>Jn(bu(e));function Xe(e,t,n){let r;if(typeof t=="string")try{r=Jn(t)}catch(o){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${o}`)}else if(oo(t))r=Uint8Array.from(t);else throw new Error(`${e} must be hex string or Uint8Array`);const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(`${e} expected ${n} bytes, got ${s}`);return r}function tt(...e){const t=new Uint8Array(e.reduce((r,s)=>r+s.length,0));let n=0;return e.forEach(r=>{if(!oo(r))throw new Error("Uint8Array expected");t.set(r,n),n+=r.length}),t}function y0(e,t){if(e.length!==t.length)return!1;for(let n=0;n0n;e>>=Di,t+=1);return t}const w0=(e,t)=>e>>BigInt(t)&1n,x0=(e,t,n)=>e|(n?Di:h0)<(p0<new Uint8Array(e),qa=e=>Uint8Array.from(e);function xu(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=To(e),s=To(e),o=0;const i=()=>{r.fill(1),s.fill(0),o=0},a=(...l)=>n(s,r,...l),c=(l=To())=>{s=a(qa([0]),l),r=a(),l.length!==0&&(s=a(qa([1]),l),r=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0;const d=[];for(;l{i(),c(l);let h;for(;!(h=d(u()));)c();return i(),h}}const v0={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function cr(e,t,n={}){const r=(s,o,i)=>{const a=v0[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);const c=e[s];if(!(i&&c===void 0)&&!a(c,e))throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${o}`)};for(const[s,o]of Object.entries(t))r(s,o,!1);for(const[s,o]of Object.entries(n))r(s,o,!0);return e}var E0=Object.freeze({__proto__:null,bitGet:w0,bitLen:b0,bitMask:Mi,bitSet:x0,bytesToHex:Xn,bytesToNumberBE:en,bytesToNumberLE:Vi,concatBytes:tt,createHmacDrbg:xu,ensureBytes:Xe,equalBytes:y0,hexToBytes:Jn,hexToNumber:Zi,numberToBytesBE:Fn,numberToBytesLE:wu,numberToHexUnpadded:bu,numberToVarBytesBE:m0,utf8ToBytes:io,validateObject:cr});/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Be=BigInt(0),_e=BigInt(1),dn=BigInt(2),S0=BigInt(3),ai=BigInt(4),za=BigInt(5),Fa=BigInt(8);BigInt(9);BigInt(16);function Ue(e,t){const n=e%t;return n>=Be?n:t+n}function k0(e,t,n){if(n<=Be||t 0");if(n===_e)return Be;let r=_e;for(;t>Be;)t&_e&&(r=r*e%n),e=e*e%n,t>>=_e;return r}function Ye(e,t,n){let r=e;for(;t-- >Be;)r*=r,r%=n;return r}function ci(e,t){if(e===Be||t<=Be)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=Ue(e,t),r=t,s=Be,o=_e;for(;n!==Be;){const a=r/n,c=r%n,u=s-o*a;r=n,n=c,s=o,o=u}if(r!==_e)throw new Error("invert: does not exist");return Ue(s,t)}function _0(e){const t=(e-_e)/dn;let n,r,s;for(n=e-_e,r=0;n%dn===Be;n/=dn,r++);for(s=dn;s(r[s]="function",r),t);return cr(e,n)}function B0(e,t,n){if(n 0");if(n===Be)return e.ONE;if(n===_e)return t;let r=e.ONE,s=t;for(;n>Be;)n&_e&&(r=e.mul(r,s)),s=e.sqr(s),n>>=_e;return r}function O0(e,t){const n=new Array(t.length),r=t.reduce((o,i,a)=>e.is0(i)?o:(n[a]=o,e.mul(o,i)),e.ONE),s=e.inv(r);return t.reduceRight((o,i,a)=>e.is0(i)?o:(n[a]=e.mul(o,n[a]),e.mul(o,i)),s),n}function qi(e,t){const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Eu(e,t,n=!1,r={}){if(e<=Be)throw new Error(`Expected Fp ORDER > 0, got ${e}`);const{nBitLength:s,nByteLength:o}=qi(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const i=$0(e),a=Object.freeze({ORDER:e,BITS:s,BYTES:o,MASK:Mi(s),ZERO:Be,ONE:_e,create:c=>Ue(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return Be<=c&&cc===Be,isOdd:c=>(c&_e)===_e,neg:c=>Ue(-c,e),eql:(c,u)=>c===u,sqr:c=>Ue(c*c,e),add:(c,u)=>Ue(c+u,e),sub:(c,u)=>Ue(c-u,e),mul:(c,u)=>Ue(c*u,e),pow:(c,u)=>B0(a,c,u),div:(c,u)=>Ue(c*ci(u,e),e),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>ci(c,e),sqrt:r.sqrt||(c=>i(a,c)),invertBatch:c=>O0(a,c),cmov:(c,u,f)=>f?u:c,toBytes:c=>n?wu(c,o):Fn(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return n?Vi(c):en(c)}});return Object.freeze(a)}function I0(e,t,n=!1){e=Xe("privateHash",e);const r=e.length,s=qi(t).nByteLength+8;if(s<24||r1024)throw new Error(`hashToPrivateScalar: expected ${s}-1024 bytes of input, got ${r}`);const o=n?Vi(e):en(e);return Ue(o,t-_e)+_e}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const T0=BigInt(0),Co=BigInt(1);function C0(e,t){const n=(s,o)=>{const i=o.negate();return s?i:o},r=s=>{const o=Math.ceil(t/s)+1,i=2**(s-1);return{windows:o,windowSize:i}};return{constTimeNegate:n,unsafeLadder(s,o){let i=e.ZERO,a=s;for(;o>T0;)o&Co&&(i=i.add(a)),a=a.double(),o>>=Co;return i},precomputeWindow(s,o){const{windows:i,windowSize:a}=r(o),c=[];let u=s,f=u;for(let l=0;l>=h,p>c&&(p-=d,i+=Co);const g=y,x=y+Math.abs(p)-1,w=m%2!==0,O=p<0;p===0?f=f.add(n(w,o[g])):u=u.add(n(O,o[x]))}return{p:u,f}},wNAFCached(s,o,i,a){const c=s._WINDOW_SIZE||1;let u=o.get(s);return u||(u=this.precomputeWindow(s,c),c!==1&&o.set(s,a(u))),this.wNAF(c,u,i)}}}function Su(e){return vu(e.Fp),cr(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...qi(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function P0(e){const t=Su(e);cr(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:s}=t;if(n){if(!r.eql(s,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({...t})}const{bytesToNumberBE:U0,hexToBytes:N0}=E0,mn={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(e){const{Err:t}=mn;if(e.length<2||e[0]!==2)throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(r[0]===0&&r[1]<=127)throw new t("Invalid signature integer: trailing length");return{d:U0(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=mn,n=typeof e=="string"?N0(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:s,l:o}=mn._parseInt(n.subarray(2)),{d:i,l:a}=mn._parseInt(o);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:i}},hexFromSig(e){const t=u=>Number.parseInt(u[0],16)>=8?"00"+u:u,n=u=>{const f=u.toString(16);return f.length&1?`0${f}`:f},r=t(n(e.s)),s=t(n(e.r)),o=r.length/2,i=s.length/2,a=n(o),c=n(i);return`30${n(i+o+4)}02${c}${s}02${a}${r}`}},nt=BigInt(0),$e=BigInt(1),_t=BigInt(2),$s=BigInt(3),Ga=BigInt(4);function L0(e){const t=P0(e),{Fp:n}=t,r=t.toBytes||((m,y,p)=>{const g=y.toAffine();return tt(Uint8Array.from([4]),n.toBytes(g.x),n.toBytes(g.y))}),s=t.fromBytes||(m=>{const y=m.subarray(1),p=n.fromBytes(y.subarray(0,n.BYTES)),g=n.fromBytes(y.subarray(n.BYTES,2*n.BYTES));return{x:p,y:g}});function o(m){const{a:y,b:p}=t,g=n.sqr(m),x=n.mul(g,m);return n.add(n.add(x,n.mul(m,y)),p)}function i(m){return typeof m=="bigint"&&ntn.eql(w,n.ZERO);return x(p)&&x(g)?l.ZERO:new l(p,g,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(y){const p=n.invertBatch(y.map(g=>g.pz));return y.map((g,x)=>g.toAffine(p[x])).map(l.fromAffine)}static fromHex(y){const p=l.fromAffine(s(Xe("pointHex",y)));return p.assertValidity(),p}static fromPrivateKey(y){return l.BASE.multiply(c(y))}_setWindowSize(y){this._WINDOW_SIZE=y,u.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:y,y:p}=this.toAffine();if(!n.isValid(y)||!n.isValid(p))throw new Error("bad point: x or y not FE");const g=n.sqr(p),x=o(y);if(!n.eql(g,x))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y}=this.toAffine();if(n.isOdd)return!n.isOdd(y);throw new Error("Field doesn't support isOdd")}equals(y){f(y);const{px:p,py:g,pz:x}=this,{px:w,py:O,pz:A}=y,T=n.eql(n.mul(p,A),n.mul(w,x)),U=n.eql(n.mul(g,A),n.mul(O,x));return T&&U}negate(){return new l(this.px,n.neg(this.py),this.pz)}double(){const{a:y,b:p}=t,g=n.mul(p,$s),{px:x,py:w,pz:O}=this;let A=n.ZERO,T=n.ZERO,U=n.ZERO,C=n.mul(x,x),_=n.mul(w,w),N=n.mul(O,O),H=n.mul(x,w);return H=n.add(H,H),U=n.mul(x,O),U=n.add(U,U),A=n.mul(y,U),T=n.mul(g,N),T=n.add(A,T),A=n.sub(_,T),T=n.add(_,T),T=n.mul(A,T),A=n.mul(H,A),U=n.mul(g,U),N=n.mul(y,N),H=n.sub(C,N),H=n.mul(y,H),H=n.add(H,U),U=n.add(C,C),C=n.add(U,C),C=n.add(C,N),C=n.mul(C,H),T=n.add(T,C),N=n.mul(w,O),N=n.add(N,N),C=n.mul(N,H),A=n.sub(A,C),U=n.mul(N,_),U=n.add(U,U),U=n.add(U,U),new l(A,T,U)}add(y){f(y);const{px:p,py:g,pz:x}=this,{px:w,py:O,pz:A}=y;let T=n.ZERO,U=n.ZERO,C=n.ZERO;const _=t.a,N=n.mul(t.b,$s);let H=n.mul(p,w),K=n.mul(g,O),v=n.mul(x,A),S=n.add(p,g),b=n.add(w,O);S=n.mul(S,b),b=n.add(H,K),S=n.sub(S,b),b=n.add(p,x);let k=n.add(w,A);return b=n.mul(b,k),k=n.add(H,v),b=n.sub(b,k),k=n.add(g,x),T=n.add(O,A),k=n.mul(k,T),T=n.add(K,v),k=n.sub(k,T),C=n.mul(_,b),T=n.mul(N,v),C=n.add(T,C),T=n.sub(K,C),C=n.add(K,C),U=n.mul(T,C),K=n.add(H,H),K=n.add(K,H),v=n.mul(_,v),b=n.mul(N,b),K=n.add(K,v),v=n.sub(H,v),v=n.mul(_,v),b=n.add(b,v),H=n.mul(K,b),U=n.add(U,H),H=n.mul(k,b),T=n.mul(S,T),T=n.sub(T,H),H=n.mul(S,K),C=n.mul(k,C),C=n.add(C,H),new l(T,U,C)}subtract(y){return this.add(y.negate())}is0(){return this.equals(l.ZERO)}wNAF(y){return h.wNAFCached(this,u,y,p=>{const g=n.invertBatch(p.map(x=>x.pz));return p.map((x,w)=>x.toAffine(g[w])).map(l.fromAffine)})}multiplyUnsafe(y){const p=l.ZERO;if(y===nt)return p;if(a(y),y===$e)return this;const{endo:g}=t;if(!g)return h.unsafeLadder(this,y);let{k1neg:x,k1:w,k2neg:O,k2:A}=g.splitScalar(y),T=p,U=p,C=this;for(;w>nt||A>nt;)w&$e&&(T=T.add(C)),A&$e&&(U=U.add(C)),C=C.double(),w>>=$e,A>>=$e;return x&&(T=T.negate()),O&&(U=U.negate()),U=new l(n.mul(U.px,g.beta),U.py,U.pz),T.add(U)}multiply(y){a(y);let p=y,g,x;const{endo:w}=t;if(w){const{k1neg:O,k1:A,k2neg:T,k2:U}=w.splitScalar(p);let{p:C,f:_}=this.wNAF(A),{p:N,f:H}=this.wNAF(U);C=h.constTimeNegate(O,C),N=h.constTimeNegate(T,N),N=new l(n.mul(N.px,w.beta),N.py,N.pz),g=C.add(N),x=_.add(H)}else{const{p:O,f:A}=this.wNAF(p);g=O,x=A}return l.normalizeZ([g,x])[0]}multiplyAndAddUnsafe(y,p,g){const x=l.BASE,w=(A,T)=>T===nt||T===$e||!A.equals(x)?A.multiplyUnsafe(T):A.multiply(T),O=w(this,p).add(w(y,g));return O.is0()?void 0:O}toAffine(y){const{px:p,py:g,pz:x}=this,w=this.is0();y==null&&(y=w?n.ONE:n.inv(x));const O=n.mul(p,y),A=n.mul(g,y),T=n.mul(x,y);if(w)return{x:n.ZERO,y:n.ZERO};if(!n.eql(T,n.ONE))throw new Error("invZ was invalid");return{x:O,y:A}}isTorsionFree(){const{h:y,isTorsionFree:p}=t;if(y===$e)return!0;if(p)return p(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:y,clearCofactor:p}=t;return y===$e?this:p?p(l,this):this.multiplyUnsafe(t.h)}toRawBytes(y=!0){return this.assertValidity(),r(l,this,y)}toHex(y=!0){return Xn(this.toRawBytes(y))}}l.BASE=new l(t.Gx,t.Gy,n.ONE),l.ZERO=new l(n.ZERO,n.ONE,n.ZERO);const d=t.nBitLength,h=C0(l,t.endo?Math.ceil(d/2):d);return{CURVE:t,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:i}}function R0(e){const t=Su(e);return cr(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function H0(e){const t=R0(e),{Fp:n,n:r}=t,s=n.BYTES+1,o=2*n.BYTES+1;function i(b){return ntXn(Fn(b,t.nByteLength));function m(b){const k=r>>$e;return b>k}function y(b){return m(b)?a(-b):b}const p=(b,k,B)=>en(b.slice(k,B));class g{constructor(k,B,L){this.r=k,this.s=B,this.recovery=L,this.assertValidity()}static fromCompact(k){const B=t.nByteLength;return k=Xe("compactSignature",k,B*2),new g(p(k,0,B),p(k,B,2*B))}static fromDER(k){const{r:B,s:L}=mn.toSig(Xe("DER",k));return new g(B,L)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(k){return new g(this.r,this.s,k)}recoverPublicKey(k){const{r:B,s:L,recovery:P}=this,j=U(Xe("msgHash",k));if(P==null||![0,1,2,3].includes(P))throw new Error("recovery id invalid");const D=P===2||P===3?B+t.n:B;if(D>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const q=(P&1)===0?"02":"03",oe=u.fromHex(q+h(D)),re=c(D),Y=a(-j*re),ce=a(L*re),ue=u.BASE.multiplyAndAddUnsafe(oe,Y,ce);if(!ue)throw new Error("point at infinify");return ue.assertValidity(),ue}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Jn(this.toDERHex())}toDERHex(){return mn.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Jn(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const x={isValidPrivateKey(b){try{return f(b),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const b=t.randomBytes(n.BYTES+8),k=I0(b,r);return Fn(k,t.nByteLength)},precompute(b=8,k=u.BASE){return k._setWindowSize(b),k.multiply(BigInt(3)),k}};function w(b,k=!0){return u.fromPrivateKey(b).toRawBytes(k)}function O(b){const k=b instanceof Uint8Array,B=typeof b=="string",L=(k||B)&&b.length;return k?L===s||L===o:B?L===2*s||L===2*o:b instanceof u}function A(b,k,B=!0){if(O(b))throw new Error("first arg must be private key");if(!O(k))throw new Error("second arg must be public key");return u.fromHex(k).multiply(f(b)).toRawBytes(B)}const T=t.bits2int||function(b){const k=en(b),B=b.length*8-t.nBitLength;return B>0?k>>BigInt(B):k},U=t.bits2int_modN||function(b){return a(T(b))},C=Mi(t.nBitLength);function _(b){if(typeof b!="bigint")throw new Error("bigint expected");if(!(nt<=b&&bie in B))throw new Error("sign() legacy options not supported");const{hash:L,randomBytes:P}=t;let{lowS:j,prehash:D,extraEntropy:q}=B;j==null&&(j=!0),b=Xe("msgHash",b),D&&(b=Xe("prehashed msgHash",L(b)));const oe=U(b),re=f(k),Y=[_(re),_(oe)];if(q!=null){const ie=q===!0?P(n.BYTES):q;Y.push(Xe("extraEntropy",ie,n.BYTES))}const ce=tt(...Y),ue=oe;function ke(ie){const ge=T(ie);if(!d(ge))return;const St=c(ge),We=u.BASE.multiply(ge).toAffine(),Oe=a(We.x);if(Oe===nt)return;const kt=a(St*a(ue+Oe*re));if(kt===nt)return;let yr=(We.x===Oe?0:2)|Number(We.y&$e),Da=kt;return j&&m(kt)&&(Da=y(kt),yr^=1),new g(Oe,Da,yr)}return{seed:ce,k2sig:ke}}const H={lowS:t.lowS,prehash:!1},K={lowS:t.lowS,prehash:!1};function v(b,k,B=H){const{seed:L,k2sig:P}=N(b,k,B);return xu(t.hash.outputLen,t.nByteLength,t.hmac)(L,P)}u.BASE._setWindowSize(8);function S(b,k,B,L=K){var We;const P=b;if(k=Xe("msgHash",k),B=Xe("publicKey",B),"strict"in L)throw new Error("options.strict was renamed to lowS");const{lowS:j,prehash:D}=L;let q,oe;try{if(typeof P=="string"||P instanceof Uint8Array)try{q=g.fromDER(P)}catch(Oe){if(!(Oe instanceof mn.Err))throw Oe;q=g.fromCompact(P)}else if(typeof P=="object"&&typeof P.r=="bigint"&&typeof P.s=="bigint"){const{r:Oe,s:kt}=P;q=new g(Oe,kt)}else throw new Error("PARSE");oe=u.fromHex(B)}catch(Oe){if(Oe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(j&&q.hasHighS())return!1;D&&(k=t.hash(k));const{r:re,s:Y}=q,ce=U(k),ue=c(Y),ke=a(ce*ue),ie=a(re*ue),ge=(We=u.BASE.multiplyAndAddUnsafe(oe,ke,ie))==null?void 0:We.toAffine();return ge?a(ge.x)===re:!1}return{CURVE:t,getPublicKey:w,getSharedSecret:A,sign:v,verify:S,ProjectivePoint:u,Signature:g,utils:x}}function j0(e,t){const n=e.ORDER;let r=nt;for(let d=n-$e;d%_t===nt;d/=_t)r+=$e;const s=r,o=(n-$e)/_t**s,i=(o-$e)/_t,a=_t**s-$e,c=_t**(s-$e),u=e.pow(t,o),f=e.pow(t,(o+$e)/_t);let l=(d,h)=>{let m=u,y=e.pow(h,a),p=e.sqr(y);p=e.mul(p,h);let g=e.mul(d,p);g=e.pow(g,i),g=e.mul(g,y),y=e.mul(g,h),p=e.mul(g,d);let x=e.mul(p,y);g=e.pow(x,c);let w=e.eql(g,e.ONE);y=e.mul(p,f),g=e.mul(x,m),p=e.cmov(y,p,w),x=e.cmov(g,x,w);for(let O=s;O>1;O--){let A=_t**(O-_t),T=e.pow(x,A);const U=e.eql(T,e.ONE);y=e.mul(p,m),m=e.mul(m,m),T=e.mul(x,m),p=e.cmov(y,p,U),x=e.cmov(T,x,U)}return{isValid:w,value:p}};if(e.ORDER%Ga===$s){const d=(e.ORDER-$s)/Ga,h=e.sqrt(e.neg(t));l=(m,y)=>{let p=e.sqr(y);const g=e.mul(m,y);p=e.mul(p,g);let x=e.pow(p,d);x=e.mul(x,g);const w=e.mul(x,h),O=e.mul(e.sqr(x),y),A=e.eql(O,m);let T=e.cmov(w,x,A);return{isValid:A,value:T}}}return l}function K0(e,t){if(vu(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const n=j0(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return r=>{let s,o,i,a,c,u,f,l;s=e.sqr(r),s=e.mul(s,t.Z),o=e.sqr(s),o=e.add(o,s),i=e.add(o,e.ONE),i=e.mul(i,t.B),a=e.cmov(t.Z,e.neg(o),!e.eql(o,e.ZERO)),a=e.mul(a,t.A),o=e.sqr(i),u=e.sqr(a),c=e.mul(u,t.A),o=e.add(o,c),o=e.mul(o,i),u=e.mul(u,a),c=e.mul(u,t.B),o=e.add(o,c),f=e.mul(s,i);const{isValid:d,value:h}=n(o,u);l=e.mul(s,r),l=e.mul(l,h),f=e.cmov(f,i,d),l=e.cmov(l,h,d);const m=e.isOdd(r)===e.isOdd(l);return l=e.cmov(e.neg(l),l,m),f=e.div(f,a),{x:f,y:l}}}function D0(e){if(e instanceof Uint8Array)return e;if(typeof e=="string")return io(e);throw new Error("DST must be Uint8Array or string")}const Z0=en;function Xt(e,t){if(e<0||e>=1<<8*t)throw new Error(`bad I2OSP call: value=${e} length=${t}`);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=e&255,e>>>=8;return new Uint8Array(n)}function V0(e,t){const n=new Uint8Array(e.length);for(let r=0;r255&&(t=r(tt(io("H2C-OVERSIZE-DST-"),t)));const{outputLen:s,blockLen:o}=r,i=Math.ceil(n/s);if(i>255)throw new Error("Invalid xmd length");const a=tt(t,Xt(t.length,1)),c=Xt(0,o),u=Xt(n,2),f=new Array(i),l=r(tt(c,e,u,Xt(0,1),a));f[0]=r(tt(l,Xt(1,1),a));for(let h=1;h<=i;h++){const m=[V0(l,f[h-1]),Xt(h+1,1),a];f[h]=r(tt(...m))}return tt(...f).slice(0,n)}function q0(e,t,n,r,s){if($r(e),$r(t),zi(n),t.length>255){const o=Math.ceil(2*r/8);t=s.create({dkLen:o}).update(io("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return s.create({dkLen:n}).update(e).update(Xt(n,2)).update(t).update(Xt(t.length,1)).digest()}function Wa(e,t,n){cr(n,{DST:"string",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:r,k:s,m:o,hash:i,expand:a,DST:c}=n;$r(e),zi(t);const u=D0(c),f=r.toString(2).length,l=Math.ceil((f+s)/8),d=t*o*l;let h;if(a==="xmd")h=M0(e,u,d,i);else if(a==="xof")h=q0(e,u,d,s,i);else if(a===void 0)h=e;else throw new Error('expand must be "xmd", "xof" or undefined');const m=new Array(t);for(let y=0;yArray.from(r).reverse());return(r,s)=>{const[o,i,a,c]=n.map(u=>u.reduce((f,l)=>e.add(e.mul(f,r),l)));return r=e.div(o,i),s=e.mul(s,e.div(a,c)),{x:r,y:s}}}function F0(e,t,n){if(typeof t!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(r,s){const o=Wa(r,2,{...n,DST:n.DST,...s}),i=e.fromAffine(t(o[0])),a=e.fromAffine(t(o[1])),c=i.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,s){const o=Wa(r,1,{...n,DST:n.encodeDST,...s}),i=e.fromAffine(t(o[0])).clearCofactor();return i.assertValidity(),i}}}let ku=class extends pu{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,gn.hash(t);const r=Ki(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new TypeError("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,o=new Uint8Array(s);o.set(r.length>s?t.create().update(r).digest():r);for(let i=0;inew ku(e,t).update(n).digest();_u.create=(e,t)=>new ku(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function G0(e){return{hash:e,hmac:(t,...n)=>_u(e,t,o0(...n)),randomBytes:i0}}function W0(e,t){const n=r=>H0({...e,...G0(r)});return Object.freeze({...n(t),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const $u=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ya=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Y0=BigInt(1),ui=BigInt(2),Xa=(e,t)=>(e+t/ui)/t;function X0(e){const t=$u,n=BigInt(3),r=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,f=u*u*e%t,l=Ye(f,n,t)*f%t,d=Ye(l,n,t)*f%t,h=Ye(d,ui,t)*u%t,m=Ye(h,s,t)*h%t,y=Ye(m,o,t)*m%t,p=Ye(y,a,t)*y%t,g=Ye(p,c,t)*p%t,x=Ye(g,a,t)*y%t,w=Ye(x,n,t)*f%t,O=Ye(w,i,t)*m%t,A=Ye(O,r,t)*u%t,T=Ye(A,ui,t);if(!rn.eql(rn.sqr(T),e))throw new Error("Cannot find square root");return T}const rn=Eu($u,void 0,void 0,{sqrt:X0}),Pt=W0({a:BigInt(0),b:BigInt(7),Fp:rn,n:Ya,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Ya,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Y0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,i=BigInt("0x100000000000000000000000000000000"),a=Xa(o*e,t),c=Xa(-r*e,t);let u=Ue(e-a*n-c*s,t),f=Ue(-a*r-c*o,t);const l=u>i,d=f>i;if(l&&(u=t-u),d&&(f=t-f),u>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:l,k1:u,k2neg:d,k2:f}}}},yu);BigInt(0);Pt.ProjectivePoint;Pt.utils.randomPrivateKey;const J0=z0(rn,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),Q0=K0(rn,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:rn.create(BigInt("-11"))});F0(Pt.ProjectivePoint,e=>{const{x:t,y:n}=Q0(rn.create(e[0]));return J0(t,n)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:rn.ORDER,m:1,k:128,expand:"xmd",hash:yu});function fi(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function ep(e){if(typeof e!="boolean")throw new Error(`Expected boolean, not ${e}`)}function Au(e,...t){if(!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new TypeError(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function tp(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");fi(e.outputLen),fi(e.blockLen)}function np(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function rp(e,t){Au(e);const n=t.outputLen;if(e.lengthnew DataView(e.buffer,e.byteOffset,e.byteLength),ht=(e,t)=>e<<32-t|e>>>t,op=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!op)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ip(e){if(typeof e!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function Bu(e){if(typeof e=="string"&&(e=ip(e)),!(e instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof e})`);return e}let ap=class{clone(){return this._cloneInto()}};function Ou(e){const t=r=>e().update(Bu(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function cp(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,a,r)}let up=class extends ap{constructor(t,n,r,s){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Uo(this.buffer)}update(t){Po.exists(this);const{view:n,buffer:r,blockLen:s}=this;t=Bu(t);const o=t.length;for(let i=0;is-i&&(this.process(r,0),i=0);for(let l=i;lf.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;le&t^~e&n,lp=(e,t,n)=>e&t^e&n^t&n,dp=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]),Kt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Dt=new Uint32Array(64);let Iu=class extends up{constructor(){super(64,32,8,!1),this.A=Kt[0]|0,this.B=Kt[1]|0,this.C=Kt[2]|0,this.D=Kt[3]|0,this.E=Kt[4]|0,this.F=Kt[5]|0,this.G=Kt[6]|0,this.H=Kt[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[t,n,r,s,o,i,a,c]}set(t,n,r,s,o,i,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,n){for(let l=0;l<16;l++,n+=4)Dt[l]=t.getUint32(n,!1);for(let l=16;l<64;l++){const d=Dt[l-15],h=Dt[l-2],m=ht(d,7)^ht(d,18)^d>>>3,y=ht(h,17)^ht(h,19)^h>>>10;Dt[l]=y+Dt[l-7]+m+Dt[l-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){const d=ht(a,6)^ht(a,11)^ht(a,25),h=f+d+fp(a,c,u)+dp[l]+Dt[l]|0,y=(ht(r,2)^ht(r,13)^ht(r,22))+lp(r,s,o)|0;f=u,u=c,c=a,a=i+h|0,i=o,o=s,s=r,r=h+y|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,s,o,i,a,c,u,f)}roundClean(){Dt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},hp=class extends Iu{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 li=Ou(()=>new Iu);Ou(()=>new hp);function pp(e,t){if(e.length>t)throw new TypeError(`Data is larger than array size: ${e.length} > ${t}`)}function gp(e){if(e.match(/[^a-fA-f0-9]/)!==null)throw new TypeError("Invalid characters in hex string: "+e);if(e.length%2!==0)throw new Error(`Length of hex string is invalid: ${e.length}`)}function mp(e){if(e>Number.MAX_SAFE_INTEGER)throw new TypeError("Number exceeds safe bounds!")}const{getRandomValues:yp}=crypto??globalThis.crypto??window.crypto;function bp(e=32){if(typeof yp=="function")return crypto.getRandomValues(new Uint8Array(e));throw new Error("Crypto module missing getRandomValues!")}function wp(e,t,n="be"){t===void 0&&(t=e.length),pp(e,t);const r=new Uint8Array(t).fill(0),s=n==="be"?0:t-e.length;return r.set(e,s),r}function Tu(e){let t,n=0;const r=e.reduce((o,i)=>o+i.length,0),s=new Uint8Array(r);for(t=0;t0||(i.length^a)>0?"":"1";c in o||u>0;)f=o[c],f=f>0?f*256+u:u,u=f/s|0,o[c]=f%s,c++;for(;c-- >0;)i+=r[o[c]];return n&&i.length%4>0?i+"=".repeat(4-i.length%4):i}function Sp(e,t){const n=Cu(t),r=n.length,s=[],o=[];e=e.replace("=","");let i,a=0,c,u;for(i=0;i0||(o.length^i)>0||o.push(0);a in s||c>0;)u=s[a],u=u>0?u*r+c:c,c=u>>8,s[a]=u%256,a++}for(;a-- >0;)o.push(s[a]);return new Uint8Array(o)}function Pu(e){return li(li(e))}function kp(e){const t=Pu(e);return Tu([e,t.slice(0,4)])}function _p(e){const t=e.slice(0,-4),n=e.slice(-4);if(Pu(t).slice(0,4).toString()!==n.toString())throw new Error("Invalid checksum!");return t}const Ja={encode:Ep,decode:Sp},Uu={encode:e=>{const t=kp(e);return Ja.encode(t,"base58")},decode:e=>{const t=Ja.decode(e,"base58");return _p(t)}},Nu="qpzry9x8gf2tvdw0s3jn54khce6mua7l",$p=[996825010,642813549,513874426,1027748829,705979059],As=[{version:0,name:"bech32",const:1},{version:1,name:"bech32m",const:734539939}];function Lu(e){let t=1;for(let n=0;n>25;t=(t&33554431)<<5^e[n];for(let s=0;s<5;++s)(r>>s&1)!==0&&(t^=$p[s])}return t}function Ru(e){const t=[];let n;for(n=0;n>5);for(t.push(0),n=0;n>5*(5-i)&31);return o}function Hu(e,t,n,r=!0){const s=[];let o=0,i=0;const a=(1<>t>0)throw new Error("Failed to perform base conversion. Invalid value: "+String(u));for(o=(o<=n;)i-=n,s.push(o>>i&a)}if(r)i>0&&s.push(o<=t||(o<0)throw new Error("Failed to perform base conversion. Invalid Size!");return s}function Op(e,t,n){const r=t.concat(Bp(e,t,n));let s=e+"1";for(let o=0;oo.version===t[0])??As[0];if(!Ap(r,t,s))throw new Error("Checksum verification failed!");return[r,t.slice(0,t.length-6)]}function Ip(e){let t,n,r=!1,s=!1;for(t=0;t126)return!1;n>=97&&n<=122&&(r=!0),n>=65&&n<=90&&(s=!0)}return!(r&&s)}function Tp(e){const t=e.lastIndexOf("1");return!(t<1||t+7>e.length||e.length>90)}function Cp(e,t="bc",n=0){const r=[n,...Hu([...e],8,5)],s=As.find(i=>i.version===n)??As[0],o=Op(t,r,s);return Ku(o),o}function Ku(e){e=e.toLowerCase();const t=e.split("1",1)[0],[n,r]=ju(e),s=Hu(r.slice(1),5,8,!1),o=s.length;switch(!0){case t!==n:throw new Error("Returned hrp string is invalid.");case(s===null||o<2||o>40):throw new Error("Decoded string is invalid or out of spec.");case r[0]>16:throw new Error("Returned version bit is out of range.");default:return Uint8Array.from(s)}}function Pp(e){e=e.toLowerCase();const[t,n]=ju(e);return n[0]}const Du={encode:Cp,decode:Ku,version:Pp},Zu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Vu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",Up=new TextEncoder;function Mu(e,t=!1,n=!0){typeof e=="string"&&(e=Up.encode(e));const r=t?Vu:Zu;let s="",o=0,i=0;for(let a=0;a=6;)o-=6,s+=r[i>>o&63];if(o>0)for(i<<=6-o,s+=r[i&63];o<6;)s+=n?"=":"",o+=2;return s}function qu(e,t=!1){const n=t||e.includes("-")||e.includes("_")?Vu.split(""):Zu.split("");e=e.replace(/=+$/,"");const r=e.split("");let s=0,o=0;const i=[];for(let a=0;a=8&&(s-=8,i.push(o>>>s&255))}return new Uint8Array(i)}const zu={encode:Mu,decode:qu},Fu={encode:e=>Mu(e,!0,!1),decode:e=>qu(e,!0)},Np=BigInt(0),Lp=BigInt(255),Gu=BigInt(256);function Rp(e){if(e<=0xffn)return 1;if(e<=0xffffn)return 2;if(e<=0xffffffffn)return 4;if(e<=0xffffffffffffffffn)return 8;if(e<=0xffffffffffffffffffffffffffffffffn)return 16;if(e<=0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn)return 32;throw new TypeError("Must specify a fixed buffer size for bigints greater than 32 bytes.")}function Hp(e,t,n="be"){t===void 0&&(t=Rp(e));const r=n==="le",s=new ArrayBuffer(t),o=new DataView(s);let i=r?0:t-1;for(;e>Np;){const a=e&Lp,c=Number(a);r?o.setUint8(i++,c):o.setUint8(i--,c),e=(e-a)/Gu}return new Uint8Array(s)}function jp(e){let t=BigInt(0);for(let n=e.length-1;n>=0;n--)t=t*Gu+BigInt(e[n]);return BigInt(t)}function Kp(e){const t=e.split("").map(Number);if(t.length%8!==0)throw new Error(`Binary array is invalid length: ${e.length}`);const n=new Uint8Array(t.length/8);for(let r=0,s=0;r255)throw new Error(`Invalid byte value: ${r}. Byte values must be between 0 and 255.`);for(let s=7;s>=0;s--,n++)t[n]=r>>s&1}return t.join("")}function Zp(e){if(e<=255)return 1;if(e<=65535)return 2;if(e<=4294967295)return 4;throw new TypeError("Numbers larger than 4 bytes must specify a fixed size!")}function Vp(e,t,n="be"){t===void 0&&(t=Zp(e));const r=n==="le",s=new ArrayBuffer(t),o=new DataView(s);let i=r?0:t-1;for(;e>0;){const a=e&255;r?o.setUint8(i++,e):o.setUint8(i--,e),e=(e-a)/256}return new Uint8Array(s)}function Mp(e){let t=0;for(let n=e.length-1;n>=0;n--)t=t*256+e[n],mp(t);return t}const qp=new TextEncoder,zp=new TextDecoder;function Fi(e){return qp.encode(e)}function No(e){return zp.decode(e)}function Fp(e,t){gp(e);const n=e.length/2;if(t===void 0&&(t=n),n>t)throw new TypeError(`Hex string is larger than array size: ${n} > ${t}`);return t}function Gp(e,t,n="le"){t=Fp(e,t);const r=n==="le",s=new ArrayBuffer(t),o=new DataView(s);let i=r?0:t-1;for(let a=0;atypeof r=="bigint"?`${r}n`:r);return Fi(t)}function Xp(e,t,n){if(e instanceof ArrayBuffer)return new Uint8Array(e);if(e instanceof Uint8Array)return wp(e,t,n);if(typeof e=="string")return Gp(e,t,n);if(typeof e=="bigint")return Hp(e,t,n);if(typeof e=="number")return Vp(e,t,n);if(typeof e=="boolean")return Uint8Array.of(e?1:0);throw TypeError("Unsupported format:"+typeof e)}const ee=class ee extends Uint8Array{static random(t=32){const n=bp(t);return new ee(n,t)}constructor(t,n,r){const s=Xp(t,n,r);super(s)}get arr(){return[...this]}get num(){return this.toNum()}get big(){return this.toBig()}get str(){return this.toStr()}get hex(){return this.toHex()}get raw(){return new Uint8Array(this)}get bin(){return this.toBin()}get b58chk(){return this.tob58chk()}get base64(){return this.toBase64()}get b64url(){return this.toB64url()}get digest(){return this.toHash()}get id(){return this.toHash().hex}get stream(){return new fg(this)}toNum(t="be"){const n=t==="be"?this.reverse():this;return Mp(n)}toBin(){return Dp(this)}toBig(t="be"){const n=t==="be"?this.reverse():this;return jp(n)}toHash(){const t=li(this);return new ee(t)}toJson(){const t=No(this);return JSON.parse(t)}toBech32(t,n=0){return Du.encode(this,t,n)}toStr(){return No(this)}toHex(){return Wp(this)}toBytes(){return new Uint8Array(this)}tob58chk(){return Uu.encode(this)}toBase64(){return zu.encode(this)}toB64url(){return Fu.encode(this)}prepend(t){return ee.join([ee.bytes(t),this])}append(t){return ee.join([this,ee.bytes(t)])}slice(t,n){const r=new Uint8Array(this).slice(t,n);return new ee(r)}subarray(t,n){const r=new Uint8Array(this).subarray(t,n);return new ee(r)}reverse(){const t=new Uint8Array(this).reverse();return new ee(t)}write(t,n){const r=ee.bytes(t);this.set(r,n)}prefixSize(t){const n=ee.varInt(this.length,t);return ee.join([n,this])}static from(t){return new ee(Uint8Array.from(t))}static of(...t){return new ee(Uint8Array.of(...t))}static join(t){const n=t.map(s=>ee.bytes(s)),r=Tu(n);return new ee(r)}static varInt(t,n){if(t<253)return ee.num(t,1);if(t<65536)return ee.of(253,...ee.num(t,2,n));if(t<4294967296)return ee.of(254,...ee.num(t,4,n));if(BigInt(t)<0x10000000000000000n)return ee.of(255,...ee.num(t,8,n));throw new Error(`Value is too large: ${t}`)}};ee.num=Jp,ee.big=eg,ee.bin=Qp,ee.raw=tg,ee.str=ng,ee.hex=rg,ee.bytes=sg,ee.json=og,ee.base64=ig,ee.b64url=ag,ee.bech32=cg,ee.b58chk=ug,ee.encode=Fi,ee.decode=No;let G=ee;function Jp(e,t,n){return new G(e,t,n)}function Qp(e,t,n){return new G(Kp(e),t,n)}function eg(e,t,n){return new G(e,t,n)}function tg(e,t,n){return new G(e,t,n)}function ng(e,t,n){return new G(Fi(e),t,n)}function rg(e,t,n){return new G(e,t,n)}function sg(e,t,n){return new G(e,t,n)}function og(e){return new G(Yp(e))}function ig(e){return new G(zu.decode(e))}function ag(e){return new G(Fu.decode(e))}function cg(e){return new G(Du.decode(e))}function ug(e){return new G(Uu.decode(e))}class fg{constructor(t){this.data=G.bytes(t),this.size=this.data.length}peek(t){if(t>this.size)throw new Error(`Size greater than stream: ${t} > ${this.size}`);return new G(this.data.slice(0,t))}read(t){t=t??this.readSize();const n=this.peek(t);return this.data=this.data.slice(t),this.size=this.data.length,n}readSize(t){const n=this.read(1).num;switch(!0){case(n>=0&&n<253):return n;case n===253:return this.read(2).toNum(t);case n===254:return this.read(4).toNum(t);case n===255:return this.read(8).toNum(t);default:throw new Error(`Varint is out of range: ${n}`)}}}const Bs=Pt.CURVE,Gi=Bs.n,lg=Bs.p,dg={x:Bs.Gx,y:Bs.Gy},hg=BigInt(0);BigInt(1);BigInt(2);BigInt(3);BigInt(4);const di={N:Gi,P:lg,G:dg,_0n:hg},br=Eu(Gi,32,!0),Wu=e=>Ue(e,Gi);function Wi(e,t=!1){if(t)throw new Error(e);return!1}function Yu(e){return G.random(e)}function pg(e){const t=G.bytes(e).big;return G.big(Wu(t),32)}var gg=Object.freeze({__proto__:null,fail:Wi,mod_bytes:pg,random:Yu});const{N:mg,_0n:yg}=di;function bg(e,t,n){const r=G.bytes(e);return r.length!==t?Wi(`Invalid byte size: ${r.hex} !== ${t}`,n):!0}function wg(e,t){return typeof e=="bigint"&&ygthis.big}lt(t){return new me(t).big0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Sg(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");hi(e.outputLen),hi(e.blockLen)}function kg(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function _g(e,t){Xu(e);const n=t.outputLen;if(e.lengthe instanceof Uint8Array,Lo=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),pt=(e,t)=>e<<32-t|e>>>t,Bg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Bg)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Og(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Yi(e){if(typeof e=="string"&&(e=Og(e)),!Ag(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}let Ju=class{clone(){return this._cloneInto()}};function Rn(e){const t=r=>e().update(Yi(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Ig(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,a,r)}class Xi extends Ju{constructor(t,n,r,s){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Lo(this.buffer)}update(t){yn.exists(this);const{view:n,buffer:r,blockLen:s}=this;t=Yi(t);const o=t.length;for(let i=0;is-i&&(this.process(r,0),i=0);for(let l=i;lf.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;le&t^~e&n,Cg=(e,t,n)=>e&t^e&n^t&n,Pg=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]),Zt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Vt=new Uint32Array(64);let Qu=class extends Xi{constructor(){super(64,32,8,!1),this.A=Zt[0]|0,this.B=Zt[1]|0,this.C=Zt[2]|0,this.D=Zt[3]|0,this.E=Zt[4]|0,this.F=Zt[5]|0,this.G=Zt[6]|0,this.H=Zt[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[t,n,r,s,o,i,a,c]}set(t,n,r,s,o,i,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,n){for(let l=0;l<16;l++,n+=4)Vt[l]=t.getUint32(n,!1);for(let l=16;l<64;l++){const d=Vt[l-15],h=Vt[l-2],m=pt(d,7)^pt(d,18)^d>>>3,y=pt(h,17)^pt(h,19)^h>>>10;Vt[l]=y+Vt[l-7]+m+Vt[l-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){const d=pt(a,6)^pt(a,11)^pt(a,25),h=f+d+Tg(a,c,u)+Pg[l]+Vt[l]|0,y=(pt(r,2)^pt(r,13)^pt(r,22))+Cg(r,s,o)|0;f=u,u=c,c=a,a=i+h|0,i=o,o=s,s=r,r=h+y|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,s,o,i,a,c,u,f)}roundClean(){Vt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};class Ug extends Qu{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 Os=Rn(()=>new Qu);Rn(()=>new Ug);const ts=BigInt(2**32-1),pi=BigInt(32);function ef(e,t=!1){return t?{h:Number(e&ts),l:Number(e>>pi&ts)}:{h:Number(e>>pi&ts)|0,l:Number(e&ts)|0}}function Ng(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;sBigInt(e>>>0)<>>0),Rg=(e,t,n)=>e>>>n,Hg=(e,t,n)=>e<<32-n|t>>>n,jg=(e,t,n)=>e>>>n|t<<32-n,Kg=(e,t,n)=>e<<32-n|t>>>n,Dg=(e,t,n)=>e<<64-n|t>>>n-32,Zg=(e,t,n)=>e>>>n-32|t<<64-n,Vg=(e,t)=>t,Mg=(e,t)=>e,qg=(e,t,n)=>e<>>32-n,zg=(e,t,n)=>t<>>32-n,Fg=(e,t,n)=>t<>>64-n,Gg=(e,t,n)=>e<>>64-n;function Wg(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Yg=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Xg=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Jg=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Qg=(e,t,n,r,s)=>t+n+r+s+(e/2**32|0)|0,em=(e,t,n,r,s)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(s>>>0),tm=(e,t,n,r,s,o)=>t+n+r+s+o+(e/2**32|0)|0,nm={fromBig:ef,split:Ng,toBig:Lg,shrSH:Rg,shrSL:Hg,rotrSH:jg,rotrSL:Kg,rotrBH:Dg,rotrBL:Zg,rotr32H:Vg,rotr32L:Mg,rotlSH:qg,rotlSL:zg,rotlBH:Fg,rotlBL:Gg,add:Wg,add3L:Yg,add3H:Xg,add4L:Jg,add4H:Qg,add5H:tm,add5L:em};var Q=nm;const[rm,sm]=Q.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Mt=new Uint32Array(80),qt=new Uint32Array(80);let ao=class extends Xi{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:n,Bh:r,Bl:s,Ch:o,Cl:i,Dh:a,Dl:c,Eh:u,El:f,Fh:l,Fl:d,Gh:h,Gl:m,Hh:y,Hl:p}=this;return[t,n,r,s,o,i,a,c,u,f,l,d,h,m,y,p]}set(t,n,r,s,o,i,a,c,u,f,l,d,h,m,y,p){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=s|0,this.Ch=o|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=f|0,this.Fh=l|0,this.Fl=d|0,this.Gh=h|0,this.Gl=m|0,this.Hh=y|0,this.Hl=p|0}process(t,n){for(let w=0;w<16;w++,n+=4)Mt[w]=t.getUint32(n),qt[w]=t.getUint32(n+=4);for(let w=16;w<80;w++){const O=Mt[w-15]|0,A=qt[w-15]|0,T=Q.rotrSH(O,A,1)^Q.rotrSH(O,A,8)^Q.shrSH(O,A,7),U=Q.rotrSL(O,A,1)^Q.rotrSL(O,A,8)^Q.shrSL(O,A,7),C=Mt[w-2]|0,_=qt[w-2]|0,N=Q.rotrSH(C,_,19)^Q.rotrBH(C,_,61)^Q.shrSH(C,_,6),H=Q.rotrSL(C,_,19)^Q.rotrBL(C,_,61)^Q.shrSL(C,_,6),K=Q.add4L(U,H,qt[w-7],qt[w-16]),v=Q.add4H(K,T,N,Mt[w-7],Mt[w-16]);Mt[w]=v|0,qt[w]=K|0}let{Ah:r,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:u,Dl:f,Eh:l,El:d,Fh:h,Fl:m,Gh:y,Gl:p,Hh:g,Hl:x}=this;for(let w=0;w<80;w++){const O=Q.rotrSH(l,d,14)^Q.rotrSH(l,d,18)^Q.rotrBH(l,d,41),A=Q.rotrSL(l,d,14)^Q.rotrSL(l,d,18)^Q.rotrBL(l,d,41),T=l&h^~l&y,U=d&m^~d&p,C=Q.add5L(x,A,U,sm[w],qt[w]),_=Q.add5H(C,g,O,T,rm[w],Mt[w]),N=C|0,H=Q.rotrSH(r,s,28)^Q.rotrBH(r,s,34)^Q.rotrBH(r,s,39),K=Q.rotrSL(r,s,28)^Q.rotrBL(r,s,34)^Q.rotrBL(r,s,39),v=r&o^r&a^o&a,S=s&i^s&c^i&c;g=y|0,x=p|0,y=h|0,p=m|0,h=l|0,m=d|0,{h:l,l:d}=Q.add(u|0,f|0,_|0,N|0),u=a|0,f=c|0,a=o|0,c=i|0,o=r|0,i=s|0;const b=Q.add3L(N,K,S);r=Q.add3H(b,_,H,v),s=b|0}({h:r,l:s}=Q.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:o,l:i}=Q.add(this.Bh|0,this.Bl|0,o|0,i|0),{h:a,l:c}=Q.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:f}=Q.add(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:d}=Q.add(this.Eh|0,this.El|0,l|0,d|0),{h,l:m}=Q.add(this.Fh|0,this.Fl|0,h|0,m|0),{h:y,l:p}=Q.add(this.Gh|0,this.Gl|0,y|0,p|0),{h:g,l:x}=Q.add(this.Hh|0,this.Hl|0,g|0,x|0),this.set(r,s,o,i,a,c,u,f,l,d,h,m,y,p,g,x)}roundClean(){Mt.fill(0),qt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};class om extends ao{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class im extends ao{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class am extends ao{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const cm=Rn(()=>new ao);Rn(()=>new om);Rn(()=>new im);Rn(()=>new am);const um=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),tf=Uint8Array.from({length:16},(e,t)=>t),fm=tf.map(e=>(9*e+5)%16);let Ji=[tf],Qi=[fm];for(let e=0;e<4;e++)for(let t of[Ji,Qi])t.push(t[e].map(n=>um[n]));const nf=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>new Uint8Array(e)),lm=Ji.map((e,t)=>e.map(n=>nf[t][n])),dm=Qi.map((e,t)=>e.map(n=>nf[t][n])),hm=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),pm=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),ns=(e,t)=>e<>>32-t;function ec(e,t,n,r){return e===0?t^n^r:e===1?t&n|~t&r:e===2?(t|~n)^r:e===3?t&r|n&~r:t^(n|~r)}const rs=new Uint32Array(16);let gm=class extends Xi{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:n,h2:r,h3:s,h4:o}=this;return[t,n,r,s,o]}set(t,n,r,s,o){this.h0=t|0,this.h1=n|0,this.h2=r|0,this.h3=s|0,this.h4=o|0}process(t,n){for(let h=0;h<16;h++,n+=4)rs[h]=t.getUint32(n,!0);let r=this.h0|0,s=r,o=this.h1|0,i=o,a=this.h2|0,c=a,u=this.h3|0,f=u,l=this.h4|0,d=l;for(let h=0;h<5;h++){const m=4-h,y=hm[h],p=pm[h],g=Ji[h],x=Qi[h],w=lm[h],O=dm[h];for(let A=0;A<16;A++){const T=ns(r+ec(h,o,a,u)+rs[g[A]]+y,w[A])+l|0;r=l,l=u,u=ns(a,10)|0,a=o,o=T}for(let A=0;A<16;A++){const T=ns(s+ec(m,i,c,f)+rs[x[A]]+p,O[A])+d|0;s=d,d=f,f=ns(c,10)|0,c=i,i=T}}this.set(this.h1+a+f|0,this.h2+u+d|0,this.h3+l+s|0,this.h4+r+i|0,this.h0+o+c|0)}roundClean(){rs.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}};const mm=Rn(()=>new gm);let rf=class extends Ju{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,yn.hash(t);const r=Yi(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,o=new Uint8Array(s);o.set(r.length>s?t.create().update(r).digest():r);for(let i=0;inew rf(e,t).update(n).digest();sf.create=(e,t)=>new rf(e,t);function ym(e){const t=G.bytes(e);return G.raw(Os(t))}function Qn(e){const t=G.bytes(e);return G.raw(Os(Os(t)))}function ea(e){const t=G.bytes(e);return G.raw(mm(Os(t)))}function bm(e,t){const n=G.bytes(e),r=G.bytes(t);return G.raw(sf(cm,n,r))}function wm(e){const t=G.str(e).digest;return G.join([t,t])}function xm(e=32){return ta(Yu(e))}function ta(e){return He.mod(e).buff}function of(e,t=!1){const n=He.mod(e).point;return t?n.x:n.buff}function af(e,t){const n=Ln.from_x(t),r=He.mod(e);return n.mul(r).buff}function vm(e,t,n="ecdh/code"){const r=wm(n),s=ta(e),o=of(s),i=G.bytes(t),a=af(s,i),c=[o.hex,i.hex];return c.sort(),bm(a,G.join([r,...c]))}function Em(e){const t=G.bytes(e);switch(!0){case t.length===32:return!0;case(t.length===33&&t[0]===2):return!0;case(t.length===33&&t[0]===3):return!1;default:throw new TypeError(`Invalid public key: ${t.hex}`)}}function Sm(e){const t=G.bytes(e);switch(t.length){case 32:return t;case 33:return t.slice(1,33);default:throw new Error(`Invalid key length: ${t.length}`)}}var km=Object.freeze({__proto__:null,genSecretKey:xm,getPublicKey:of,getSecretKey:ta,getSharedCode:vm,getSharedKey:af,is_even_pub:Em,xonly_pub:Sm});G.random(32);const cf={secp:Pt},gi={...km,...gg};function co(e){const t=E.bytes(e);return Et(t,33),ea(t)}function uf(e){const t=Se.fmt.toBytes(e,!1);return ea(t)}function ff(e){const t=Se.fmt.toBytes(e,!1);return ym(t)}function lf(e,t="main"){const n=t==="main"?["1"]:["m","n"];for(const r of n)if(e.startsWith(r))return!0;return!1}function df(e,t="main"){const n=E.bytes(e),r=t==="main"?E.num(0):E.num(111);return Et(e,20),n.prepend(r).tob58chk()}function _m(e,t="main"){if(!lf(e,t))throw new TypeError("Invalid p2pkh address!");return E.b58chk(e).slice(1)}function $m(e){const t=E.bytes(e);return Et(t,20),["OP_DUP","OP_HASH160",t.hex,"OP_EQUALVERIFY","OP_CHECKSIG"]}function Am(e,t){const n=co(e);return df(n,t)}const hf={check:lf,encode:df,decode:_m,hash:co,scriptPubKey:$m,fromPubKey:Am};function pf(e,t="main"){const n=t==="main"?["3"]:["2"];for(const r of n)if(e.startsWith(r))return!0;return!1}function gf(e,t="main"){const n=t==="main"?E.num(5):E.num(196),r=E.bytes(e);return Et(r,20),r.prepend(n).tob58chk()}function Bm(e,t="main"){if(!pf(e,t))throw new TypeError(`Invalid p2sh address for network ${t}:`+e);return E.b58chk(e).slice(1)}function Om(e){return["OP_HASH160",E.bytes(e).hex,"OP_EQUAL"]}function Im(e,t){const n=uf(e);return gf(n,t)}const mf={check:pf,encode:gf,decode:Bm,hash:uf,scriptPubKey:Om,fromScript:Im},na={main:"bc",testnet:"tb",signet:"tb",regtest:"bcrt"},Tm=["bc1q","tb1q","bcrt1q"];function yf(e){for(const t of Tm)if(e.startsWith(t))return!0;return!1}function bf(e,t="main"){const n=na[t],r=E.bytes(e);return Et(r,20),r.toBech32(n,0)}function Cm(e){if(!yf(e))throw new TypeError("Invalid segwit address!");return E.bech32(e)}function Pm(e){const t=E.bytes(e);return Et(t,20),["OP_0",t.hex]}function Um(e,t){const n=co(e);return bf(n,t)}const wf={check:yf,encode:bf,decode:Cm,hash:co,scriptPubKey:Pm,fromPubKey:Um},Nm=["bc1q","tb1q","bcrt1q"];function xf(e){for(const t of Nm)if(e.startsWith(t))return!0;return!1}function vf(e,t="main"){const n=na[t],r=E.bytes(e);return Et(r,32),r.toBech32(n,0)}function Lm(e){if(!xf(e))throw new TypeError("Invalid segwit address!");return E.bech32(e)}function Rm(e){const t=E.bytes(e);return Et(t,32),["OP_0",t.hex]}function Hm(e,t){const n=ff(e);return vf(n,t)}const Ef={check:xf,encode:vf,decode:Lm,hash:ff,scriptPubKey:Rm,fromScript:Hm};function $n(e){const t=E.bytes(e);return t.length>32?t.slice(1,33):t}const jm=["bc1p","tb1p","bcrt1p"];function Sf(e){for(const t of jm)if(e.startsWith(t))return!0;return!1}function kf(e,t="main"){const n=na[t],r=E.bytes(e);return Et(r,32),r.toBech32(n,1)}function Km(e){if(!Sf(e))throw new TypeError("Invalid taproot address!");return E.bech32(e)}function Dm(e){const t=E.bytes(e);return Et(t,32),["OP_1",t.hex]}function Zm(e,t){const n=$n(e);return kf(n,t)}const _f={check:Sf,encode:kf,decode:Km,scriptPubKey:Dm,fromPubKey:Zm},Vm={version:2,vin:[],vout:[],locktime:0},Mm={scriptSig:[],sequence:4294967293,witness:[]},qm={value:0n,scriptPubKey:[]};function ra(e){const t={...Vm,...e};return t.vin=t.vin.map(n=>({...Mm,...n})),t.vout=t.vout.map(n=>({...qm,...n})),t}function er(e,t){const{version:n,vin:r,vout:s,locktime:o}=ra(e),i=t!==!0&&zm(r),a=[sa(n)];i&&a.push(E.hex("0001")),a.push(Fm(r)),a.push(Gm(s));for(const c of r)i&&a.push(Ym(c.witness));return a.push(oa(o)),E.join(a)}function zm(e){for(const t of e){const{witness:n}=t;if(typeof n=="string"||n instanceof Uint8Array||Array.isArray(n)&&n.length>0)return!0}return!1}function sa(e){return E.num(e,4).reverse()}function Vr(e){return E.hex(e,32).reverse()}function Mr(e){return E.num(e,4).reverse()}function qr(e){if(typeof e=="string")return E.hex(e,4).reverse();if(typeof e=="number")return E.num(e,4).reverse();throw new Error("Unrecognized format: "+String(e))}function Fm(e){const t=[E.varInt(e.length,"le")];for(const n of e){const{txid:r,vout:s,scriptSig:o,sequence:i}=n;t.push(Vr(r)),t.push(Mr(s)),t.push(Nn(o,!0)),t.push(qr(i))}return E.join(t)}function sn(e){if(typeof e=="number"){if(e%1!==0)throw new Error("Value must be an integer:"+String(e));return E.num(e,8).reverse()}return E.big(e,8).reverse()}function Gm(e){const t=[E.varInt(e.length,"le")];for(const n of e)t.push(Wm(n));return E.join(t)}function Wm(e){const{value:t,scriptPubKey:n}=e,r=[];return r.push(sn(t)),r.push(Nn(n,!0)),E.join(r)}function Ym(e=[]){const t=[];if(Array.isArray(e)){const n=E.varInt(e.length);t.push(n);for(const r of e)t.push(Xm(r));return E.join(t)}else return E.bytes(e)}function Xm(e){return Jm(e)?new E(0):Nn(e,!0)}function Jm(e){if(Array.isArray(e))return e.length===0;if(typeof e=="string"&&e==="")return!0;const t=E.bytes(e);return t.length===1&&t[0]===0}function oa(e){if(typeof e=="string")return E.hex(e,4);if(typeof e=="number")return E.num(e,4).reverse();throw new Error("Unrecognized format: "+String(e))}function ia(e){typeof e=="string"&&(e=E.hex(e).raw);const t=new ar(e),n=Qm(t),r=ey(t),s=ty(t),o=ry(t);if(r)for(const a of s)a.witness=oy(t);const i=iy(t);return{version:n,vin:s,vout:o,locktime:i}}function Qm(e){return e.read(4).reverse().toNum()}function ey(e){const[t,n]=[...e.peek(2)];if(t===0){if(e.read(2),n===1)return!0;throw new Error(`Invalid witness flag: ${n}`)}return!1}function ty(e){const t=[],n=e.readSize("le");for(let r=0;r0?e.read(n).hex:null}function Af(e,t){const n=$f(e);return n!==null?n:[]}function iy(e){return e.read(4).reverse().toNum()}function ay(e){if(lu(e))return ia(e);if(typeof e=="object"&&!(e instanceof Uint8Array))return er(e),ra(e);throw new Error("Invalid format: "+typeof e)}function cy(e){if(lu(e))return ia(e),E.bytes(e);if(typeof e=="object")return er(e);throw new Error("Invalid format: "+typeof e)}const aa={toBytes:cy,toJson:ay},uy=[["p2pkh",/^76a914(?\w{40})88ac$/],["p2sh",/^a914(?\w{40})87$/],["p2w-pkh",/^0014(?\w{40})$/],["p2w-sh",/^0020(?\w{64})$/],["p2tr",/^5120(?\w{64})$/]],fy=[192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,102,126,128,132,150,152,186,188,190];function ly(e){let t=e.at(-1);return Nt(t)&&(t=E.hex(t)),e.length>1&&t instanceof Uint8Array&&t[0]===80?(e.pop(),E.raw(t)):null}function dy(e){let t=e.at(-1);return Nt(t)&&(t=E.hex(t)),e.length>1&&t instanceof Uint8Array&&t.length>32&&fy.includes(t[0]&254)?(e.pop(),E.raw(t)):null}function hy(e){if(e.length>1){const t=e.at(-1);try{const n=Se.fmt.toBytes(t);return e.pop(),n}catch{return null}}return null}function py(e){const t=[];for(const n of e)if(Nt(n)||n instanceof Uint8Array||typeof n=="number")t.push(E.bytes(n));else throw new Error("unrecognized value: "+String(n));return t}function gy(e=[]){const t=[...e],n=ly(t),r=dy(t),s=hy(t),o=py(t);return{annex:n,cblock:r,script:s,params:o}}function my(e){const t=Se.fmt.toBytes(e,!1).hex;for(const[n,r]of uy){const s=n,{groups:o}=r.exec(t)??{},{hash:i}=o??{};if(Nt(i))return{type:s,data:E.hex(i)}}return{type:"raw",data:E.hex(t)}}function yy(e){const t=aa.toJson(e),n=er(t,!0);return Qn(n).reverse().hex}function by(e){const t=aa.toJson(e),n=er(t,!0).length,r=er(t,!1).length,s=n*3+r,o=s%4>0?1:0,i=Math.floor(s/4)+o;return{size:r,bsize:n,vsize:i,weight:s}}const ae={create:ra,encode:er,decode:ia,fmt:aa,util:{getTxSize:by,getTxid:yy,readScriptPubKey:my,readWitness:gy}},wy=[["1","p2pkh","main",20,"base58"],["3","p2sh","main",20,"base58"],["m","p2pkh","testnet",20,"base58"],["n","p2pkh","testnet",20,"base58"],["2","p2sh","testnet",20,"base58"],["bc1q","p2w-pkh","main",20,"bech32"],["tb1q","p2w-pkh","testnet",20,"bech32"],["bcrt1q","p2w-pkh","regtest",20,"bech32"],["bc1q","p2w-sh","main",32,"bech32"],["tb1q","p2w-sh","testnet",32,"bech32"],["bcrt1q","p2w-sh","regtest",32,"bech32"],["bc1p","p2tr","main",32,"bech32m"],["tb1p","p2tr","testnet",32,"bech32m"],["bcrt1p","p2tr","regtest",32,"bech32m"]];function xy(e,t){switch(t){case"base58":return E.b58chk(e).slice(1);case"bech32":return E.bech32(e);case"bech32m":return E.bech32(e);default:throw new Error("Invalid address format: "+t)}}function vy(e){for(const t of wy){const[n,r,s,o,i]=t;if(e.startsWith(n)&&xy(e,i).length===o)return t}throw new Error("Invalid address: "+e)}function Bf(e){switch(e){case"p2pkh":return hf;case"p2sh":return mf;case"p2w-pkh":return wf;case"p2w-sh":return Ef;case"p2tr":return _f;default:throw new Error("Invalid address type: "+e)}}function Of(e){const[t,n,r]=vy(e),s=Bf(n),o=s.decode(e,r),i=s.scriptPubKey(o);return{prefix:t,type:n,network:r,data:o,script:i}}function Ey(e,t){const{type:n,data:r}=ae.util.readScriptPubKey(e);return Bf(n).encode(r,t)}function Sy(e){const{script:t}=Of(e);return Se.fmt.toAsm(t,!1)}const Ar={p2pkh:hf,p2sh:mf,p2wpkh:wf,p2wsh:Ef,p2tr:_f,decode:Of,fromScriptPubKey:Ey,toScriptPubKey:Sy},ky=[1,2,3];function ca(e,t,n={}){const{sigflag:r=1}=n,s=(r&128)===128,o=r%128;if(!ky.includes(o))throw new Error("Invalid hash type: "+String(r));const i=ae.fmt.toJson(e),{version:a,vin:c,vout:u,locktime:f}=i,{txid:l,vout:d,prevout:h,sequence:m}=c[t],{value:y}=h??{};if(y===void 0)throw new Error("Prevout value is empty!");let p=n.script;if(p===void 0&&n.pubkey!==void 0&&(p=`76a914${ea(n.pubkey).hex}88ac`),p===void 0)throw new Error("No pubkey / script has been set!");if(Se.fmt.toAsm(p).includes("OP_CODESEPARATOR"))throw new Error("This library does not currently support the use of OP_CODESEPARATOR in segwit scripts.");const g=[sa(a),_y(c,s),$y(c,o,s),Vr(l),Mr(d),Se.encode(p,!0),sn(y),qr(m),Ay(u,t,o),oa(f),E.num(r,4).reverse()];return Qn(E.join(g))}function _y(e,t){if(t===!0)return E.num(0,32);const n=[];for(const{txid:r,vout:s}of e)n.push(Vr(r)),n.push(Mr(s));return Qn(E.join(n))}function $y(e,t,n){if(n||t!==1)return E.num(0,32);const r=[];for(const{sequence:s}of e)r.push(qr(s));return Qn(E.join(r))}function Ay(e,t,n){const r=[];if(n===1){for(const{value:s,scriptPubKey:o}of e)r.push(sn(s)),r.push(Se.encode(o,!0));return Qn(E.join(r))}if(n===3&&t1&&c[1].length===33)u=E.bytes(c[1]);else return Pe("No pubkey provided!",s);const f=Se.fmt.toParam(c[0]),l=f.slice(0,-1),d=f.slice(-1)[0],h=ca(r,t,{...n,sigflag:d});return cf.secp.verify(l,h,u)?!0:Pe("Invalid signature!",s)}const Iy={hash:ca,sign:By,verify:Oy},Ty=[0,1,2,3,129,130,131];function ua(e,t,n={}){const{extension:r,sigflag:s=0,extflag:o=0,key_version:i=0,separator_pos:a=4294967295}=n,c=ae.fmt.toJson(e),{version:u,vin:f,vout:l,locktime:d}=c;if(t>=f.length)throw new Error("Index out of bounds: "+String(t));if(!Ty.includes(s))throw new Error("Invalid hash type: "+String(s));if(o<0||o>127)throw new Error("Extention flag out of range: "+String(o));const{txid:h,vout:m,sequence:y,witness:p=[]}=f[t],g=(s&128)===128,x=Hy(p),w=x!==void 0?1:0,A=(o+(r!==void 0?1:0))*2+w,T=E.str("TapSighash").digest,U=[T,T,E.num(0,1),E.num(s,1),sa(u),oa(d)];if(!g){const C=f.map(_=>tc(_));U.push(Cy(f),Uy(C),Ny(C),Py(f))}if(((s&3)<2||(s&3)>3)&&U.push(Ly(l)),U.push(E.num(A,1)),g){const{value:C,scriptPubKey:_}=tc(f[t]);U.push(Vr(h),Mr(m),sn(C),Se.encode(_,!0),qr(y))}else U.push(E.num(t,4).reverse());return x!==void 0&&U.push(x),(s&3)===3&&U.push(Ry(l[t])),r!==void 0&&U.push(E.bytes(r),E.num(i),E.num(a,4,"le")),E.join(U).digest}function Cy(e){const t=[];for(const{txid:n,vout:r}of e)t.push(Vr(n)),t.push(Mr(r));return E.join(t).digest}function Py(e){const t=[];for(const{sequence:n}of e)t.push(qr(n));return E.join(t).digest}function Uy(e){const t=[];for(const{value:n}of e)t.push(sn(n));return E.join(t).digest}function Ny(e){const t=[];for(const{scriptPubKey:n}of e)t.push(Nn(n,!0));return E.join(t).digest}function Ly(e){const t=[];for(const{value:n,scriptPubKey:r}of e)t.push(sn(n)),t.push(Se.encode(r,!0));return E.join(t).digest}function Ry(e){return E.join([sn(e.value),Se.encode(e.scriptPubKey,!0)]).digest}function Hy(e){if(e===void 0||e.length<2)return;let t=e.at(-1);if(typeof t=="string"&&(t=E.hex(t)),t instanceof Uint8Array&&t[0]===80)return E.raw(t).prefixSize("be").digest}function tc(e){if(e.prevout===void 0)throw new Error("Prevout data missing for input: "+String(e.txid));return e.prevout}const jy=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Ky=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;function Dy(e,t,n,r={}){const{sigflag:s=0}=r,o=ua(t,n,r),i=Zy(e,o);return s===0?E.raw(i):E.join([i,s])}function Zy(e,t,n=E.random(32)){const r=E.bytes(t),s=new He(e),o=s.point,i=o.hasEvenY?s.big:s.negated.big,a=bs("BIP0340/aux",E.bytes(n)),c=i^a.big,u=bs("BIP0340/nonce",c,o.x.raw,r),f=new He(u),l=f.point,d=l.hasEvenY?f.big:f.negated.big,h=new He(bs("BIP0340/challenge",l.x.raw,o.x.raw,r)),m=new He(d+h.big*i);return E.join([l.x.raw,m.raw])}function Vy(e,t,n,r=!1){const s=Ln.from_x($n(n)),o=E.bytes(t),i=E.bytes(e).stream;i.size<64&&Pe("Signature length is too small: "+String(i.size),r);const a=i.read(32);a.big>jy&&Pe("Signature r value greater than field size!",r);const c=i.read(32);c.big>Ky&&Pe("Signature s value greater than curve order!",r);const u=new He(bs("BIP0340/challenge",a.raw,s.x.raw,o)),f=new He(c).point,l=s.mul(u.big),d=f.sub(l);return d.hasOddY&&Pe("Signature R value has odd Y coordinate!",r),d.x.big===0n&&Pe("Signature R value is infinite!",r),d.x.big===a.big}const My=192;function uo(e){const t=E.str(e).digest;return E.join([t,t])}function fa(e,t=My){return E.join([uo("TapLeaf"),Fy(t),E.bytes(e)]).digest.hex}function qy(e,t){return fa(Se.fmt.toBytes(e),t)}function la(e,t){return t0){const[h,m,y]=Is(r,i);c=y,a=Gn(e,h,n)}else i!==void 0?a=Gn(e,i,n):a=Gn(e,void 0,n);const u=n?gi.getPublicKey(a)[0]:a[0],l=[E.num(s+Nf(u)),o];c.length>0&&c.forEach(h=>l.push(E.hex(h)));const d=E.join(l);if(i!==void 0&&!da(a,i,d,t))throw new Error("Path checking failed! Unable to generate path.");return[$n(a).hex,d.hex]}function da(e,t,n,r={}){const{isPrivate:s=!1,throws:o=!1}=r,{parity:i,paths:a,intkey:c}=Uf(n),u=s?gi.getPublicKey(e,!0):$n(e),f=E.join([i,u]);if(f.length!==33)return Pe("Invalid tapkey: "+f.hex,o);let l=E.bytes(t).hex;for(const h of a)l=la(l,h);const d=Gn(c,l);return E.raw(d).hex===E.raw(f).hex}function Uf(e){const t=new ar(E.bytes(e)),n=t.read(1).num,r=t.read(32),[s,o]=n%2===0?[n,2]:[n-1,3],i=[];for(;t.size>=32;)i.push(t.read(32).hex);if(t.size!==0)throw new Error("Non-empty buffer on control block: "+String(t));return{intkey:r,paths:i,parity:o,version:s}}function Nf(e=2){if(e===0||e===1)return e;if(e===2||e==="02")return 0;if(e===3||e==="03")return 1;throw new Error("Invalid parity bit: "+String(e))}function tb(e,t,n={}){const r=ae.fmt.toJson(e),{throws:s=!1}=n,{prevout:o,witness:i=[]}=r.vin[t],a=ae.util.readWitness(i),{cblock:c,script:u,params:f}=a;let l;if(f.length<1)return Pe("Invalid witness data: "+String(i),s);const{scriptPubKey:d}=o??{};if(d===void 0)return Pe("Prevout scriptPubKey is empty!",s);const{type:h,data:m}=ae.util.readScriptPubKey(d);if(h!=="p2tr")return Pe("Prevout script is not a valid taproot output:"+m.hex,s);if(m.length!==32)return Pe("Invalid tapkey length: "+String(m.length),s);if(c!==null&&u!==null){const w=c[0]&254,O=fa(u,w);if(n.extension=O,!da(m,O,c,{throws:s}))return Pe("cblock verification failed!",s)}n.pubkey!==void 0?l=E.bytes(n.pubkey):f.length>1&&f[1].length===32?l=E.bytes(f[1]):l=E.bytes(m);const y=Se.fmt.toParam(f[0]),p=new ar(y),g=p.read(64).raw;if(p.size===1&&(n.sigflag=p.read(1).num,n.sigflag===0))return Pe("0x00 is not a valid appended sigflag!",s);const x=ua(r,t,n);return Vy(g,x,l,s)?!0:Pe("Invalid signature!",s)}const nb={hash:ua,sign:Dy,verify:tb},fo={segwit:Iy,taproot:nb},rb={getTag:uo,getLeaf:fa,getBranch:la,getRoot:zy},sb={readCtrlBlock:Uf,readParityBit:Nf},ob={getPubKey:Gy,getSecKey:Wy,getTweak:If,tweakSecKey:Tf,tweakPubKey:Cf},Ts={getPubKey:eb,getSecKey:Qy,encodeScript:qy,checkPath:da,tree:rb,tweak:ob,util:sb,SCRIPT_PUBKEY:Xy};var fe;(function(e){e.assertEqual=s=>s;function t(s){}e.assertIs=t;function n(s){throw new Error}e.assertNever=n,e.arrayToEnum=s=>{const o={};for(const i of s)o[i]=i;return o},e.getValidEnumValues=s=>{const o=e.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),i={};for(const a of o)i[a]=s[a];return e.objectValues(i)},e.objectValues=s=>e.objectKeys(s).map(function(o){return s[o]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const o=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&o.push(i);return o},e.find=(s,o)=>{for(const i of s)if(o(i))return i},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,o=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(o)}e.joinValues=r,e.jsonStringifyReplacer=(s,o)=>typeof o=="bigint"?o.toString():o})(fe||(fe={}));var mi;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(mi||(mi={}));const Z=fe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Jt=e=>{switch(typeof e){case"undefined":return Z.undefined;case"string":return Z.string;case"number":return isNaN(e)?Z.nan:Z.number;case"boolean":return Z.boolean;case"function":return Z.function;case"bigint":return Z.bigint;case"symbol":return Z.symbol;case"object":return Array.isArray(e)?Z.array:e===null?Z.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Z.promise:typeof Map<"u"&&e instanceof Map?Z.map:typeof Set<"u"&&e instanceof Set?Z.set:typeof Date<"u"&&e instanceof Date?Z.date:Z.object;default:return Z.unknown}},R=fe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ib=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class ot extends Error{constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}get errors(){return this.issues}format(t){const n=t||function(o){return o.message},r={_errors:[]},s=o=>{for(const i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(n(i));else{let a=r,c=0;for(;cn.message){const n={},r=[];for(const s of this.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(t(s))):r.push(t(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}ot.create=e=>new ot(e);const Br=(e,t)=>{let n;switch(e.code){case R.invalid_type:e.received===Z.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case R.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,fe.jsonStringifyReplacer)}`;break;case R.unrecognized_keys:n=`Unrecognized key(s) in object: ${fe.joinValues(e.keys,", ")}`;break;case R.invalid_union:n="Invalid input";break;case R.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${fe.joinValues(e.options)}`;break;case R.invalid_enum_value:n=`Invalid enum value. Expected ${fe.joinValues(e.options)}, received '${e.received}'`;break;case R.invalid_arguments:n="Invalid function arguments";break;case R.invalid_return_type:n="Invalid function return type";break;case R.invalid_date:n="Invalid date";break;case R.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:fe.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case R.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case R.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case R.custom:n="Invalid input";break;case R.invalid_intersection_types:n="Intersection results could not be merged";break;case R.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case R.not_finite:n="Number must be finite";break;default:n=t.defaultError,fe.assertNever(e)}return{message:n}};let Lf=Br;function ab(e){Lf=e}function Cs(){return Lf}const Ps=e=>{const{data:t,path:n,errorMaps:r,issueData:s}=e,o=[...n,...s.path||[]],i={...s,path:o};let a="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)a=u(i,{data:t,defaultError:a}).message;return{...s,path:o,message:s.message||a}},cb=[];function V(e,t){const n=Ps({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Cs(),Br].filter(r=>!!r)});e.common.issues.push(n)}class Re{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const s of n){if(s.status==="aborted")return W;s.status==="dirty"&&t.dirty(),r.push(s.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const s of n)r.push({key:await s.key,value:await s.value});return Re.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const s of n){const{key:o,value:i}=s;if(o.status==="aborted"||i.status==="aborted")return W;o.status==="dirty"&&t.dirty(),i.status==="dirty"&&t.dirty(),(typeof i.value<"u"||s.alwaysSet)&&(r[o.value]=i.value)}return{status:t.value,value:r}}}const W=Object.freeze({status:"aborted"}),Rf=e=>({status:"dirty",value:e}),De=e=>({status:"valid",value:e}),yi=e=>e.status==="aborted",bi=e=>e.status==="dirty",Us=e=>e.status==="valid",Ns=e=>typeof Promise<"u"&&e instanceof Promise;var z;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(z||(z={}));class bt{constructor(t,n,r,s){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const nc=(e,t)=>{if(Us(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new ot(e.common.issues);return this._error=n,this._error}}};function J(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:s}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(i,a)=>i.code!=="invalid_type"?{message:a.defaultError}:typeof a.data>"u"?{message:r??a.defaultError}:{message:n??a.defaultError},description:s}}class ne{constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(t){return Jt(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Jt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Re,ctx:{common:t.parent.common,data:t.data,parsedType:Jt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(Ns(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){var r;const s={common:{issues:[],async:(r=n==null?void 0:n.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Jt(t)},o=this._parseSync({data:t,path:s.path,parent:s});return nc(s,o)}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Jt(t)},s=this._parse({data:t,path:r.path,parent:r}),o=await(Ns(s)?s:Promise.resolve(s));return nc(r,o)}refine(t,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,o)=>{const i=t(s),a=()=>o.addIssue({code:R.custom,...r(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(t,n){return this._refinement((r,s)=>t(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(t){return new ut({schema:this,typeName:F.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}optional(){return Ct.create(this,this._def)}nullable(){return On.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return it.create(this,this._def)}promise(){return nr.create(this,this._def)}or(t){return Cr.create([this,t],this._def)}and(t){return Pr.create(this,t,this._def)}transform(t){return new ut({...J(this._def),schema:this,typeName:F.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Hr({...J(this._def),innerType:this,defaultValue:n,typeName:F.ZodDefault})}brand(){return new jf({typeName:F.ZodBranded,type:this,...J(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new js({...J(this._def),innerType:this,catchValue:n,typeName:F.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return zr.create(this,t)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ub=/^c[^\s-]{8,}$/i,fb=/^[a-z][a-z0-9]*$/,lb=/[0-9A-HJKMNP-TV-Z]{26}/,db=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,hb=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/,pb=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u"),gb=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,mb=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,yb=e=>e.precision?e.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${e.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${e.precision}}Z$`):e.precision===0?e.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):e.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function bb(e,t){return!!((t==="v4"||!t)&&gb.test(e)||(t==="v6"||!t)&&mb.test(e))}class rt extends ne{constructor(){super(...arguments),this._regex=(t,n,r)=>this.refinement(s=>t.test(s),{validation:n,code:R.invalid_string,...z.errToObj(r)}),this.nonempty=t=>this.min(1,z.errToObj(t)),this.trim=()=>new rt({...this._def,checks:[...this._def.checks,{kind:"trim"}]}),this.toLowerCase=()=>new rt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]}),this.toUpperCase=()=>new rt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Z.string){const o=this._getOrReturnCtx(t);return V(o,{code:R.invalid_type,expected:Z.string,received:o.parsedType}),W}const r=new Re;let s;for(const o of this._def.checks)if(o.kind==="min")t.data.lengtho.value&&(s=this._getOrReturnCtx(t,s),V(s,{code:R.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="length"){const i=t.data.length>o.value,a=t.data.length"u"?null:t==null?void 0:t.precision,offset:(n=t==null?void 0:t.offset)!==null&&n!==void 0?n:!1,...z.errToObj(t==null?void 0:t.message)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...z.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...z.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...z.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...z.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...z.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...z.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...z.errToObj(n)})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value{var t;return new rt({checks:[],typeName:F.ZodString,coerce:(t=e==null?void 0:e.coerce)!==null&&t!==void 0?t:!1,...J(e)})};function wb(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r,o=parseInt(e.toFixed(s).replace(".","")),i=parseInt(t.toFixed(s).replace(".",""));return o%i/Math.pow(10,s)}class on extends ne{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Z.number){const o=this._getOrReturnCtx(t);return V(o,{code:R.invalid_type,expected:Z.number,received:o.parsedType}),W}let r;const s=new Re;for(const o of this._def.checks)o.kind==="int"?fe.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),V(r,{code:R.invalid_type,expected:"integer",received:"float",message:o.message}),s.dirty()):o.kind==="min"?(o.inclusive?t.datao.value:t.data>=o.value)&&(r=this._getOrReturnCtx(t,r),V(r,{code:R.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="multipleOf"?wb(t.data,o.value)!==0&&(r=this._getOrReturnCtx(t,r),V(r,{code:R.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),V(r,{code:R.not_finite,message:o.message}),s.dirty()):fe.assertNever(o);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,z.toString(n))}gt(t,n){return this.setLimit("min",t,!1,z.toString(n))}lte(t,n){return this.setLimit("max",t,!0,z.toString(n))}lt(t,n){return this.setLimit("max",t,!1,z.toString(n))}setLimit(t,n,r,s){return new on({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:z.toString(s)}]})}_addCheck(t){return new on({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:z.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:z.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:z.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:z.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:z.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:z.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:z.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:z.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:z.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.valuet.kind==="int"||t.kind==="multipleOf"&&fe.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.valuenew on({checks:[],typeName:F.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...J(e)});class an extends ne{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce&&(t.data=BigInt(t.data)),this._getType(t)!==Z.bigint){const o=this._getOrReturnCtx(t);return V(o,{code:R.invalid_type,expected:Z.bigint,received:o.parsedType}),W}let r;const s=new Re;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?t.datao.value:t.data>=o.value)&&(r=this._getOrReturnCtx(t,r),V(r,{code:R.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),V(r,{code:R.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):fe.assertNever(o);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,z.toString(n))}gt(t,n){return this.setLimit("min",t,!1,z.toString(n))}lte(t,n){return this.setLimit("max",t,!0,z.toString(n))}lt(t,n){return this.setLimit("max",t,!1,z.toString(n))}setLimit(t,n,r,s){return new an({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:z.toString(s)}]})}_addCheck(t){return new an({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:z.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:z.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:z.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:z.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:z.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value{var t;return new an({checks:[],typeName:F.ZodBigInt,coerce:(t=e==null?void 0:e.coerce)!==null&&t!==void 0?t:!1,...J(e)})};class Or extends ne{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Z.boolean){const r=this._getOrReturnCtx(t);return V(r,{code:R.invalid_type,expected:Z.boolean,received:r.parsedType}),W}return De(t.data)}}Or.create=e=>new Or({typeName:F.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...J(e)});class An extends ne{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Z.date){const o=this._getOrReturnCtx(t);return V(o,{code:R.invalid_type,expected:Z.date,received:o.parsedType}),W}if(isNaN(t.data.getTime())){const o=this._getOrReturnCtx(t);return V(o,{code:R.invalid_date}),W}const r=new Re;let s;for(const o of this._def.checks)o.kind==="min"?t.data.getTime()o.value&&(s=this._getOrReturnCtx(t,s),V(s,{code:R.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):fe.assertNever(o);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new An({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:z.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:z.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.valuenew An({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:F.ZodDate,...J(e)});class Ls extends ne{_parse(t){if(this._getType(t)!==Z.symbol){const r=this._getOrReturnCtx(t);return V(r,{code:R.invalid_type,expected:Z.symbol,received:r.parsedType}),W}return De(t.data)}}Ls.create=e=>new Ls({typeName:F.ZodSymbol,...J(e)});class Ir extends ne{_parse(t){if(this._getType(t)!==Z.undefined){const r=this._getOrReturnCtx(t);return V(r,{code:R.invalid_type,expected:Z.undefined,received:r.parsedType}),W}return De(t.data)}}Ir.create=e=>new Ir({typeName:F.ZodUndefined,...J(e)});class Tr extends ne{_parse(t){if(this._getType(t)!==Z.null){const r=this._getOrReturnCtx(t);return V(r,{code:R.invalid_type,expected:Z.null,received:r.parsedType}),W}return De(t.data)}}Tr.create=e=>new Tr({typeName:F.ZodNull,...J(e)});class tr extends ne{constructor(){super(...arguments),this._any=!0}_parse(t){return De(t.data)}}tr.create=e=>new tr({typeName:F.ZodAny,...J(e)});class Sn extends ne{constructor(){super(...arguments),this._unknown=!0}_parse(t){return De(t.data)}}Sn.create=e=>new Sn({typeName:F.ZodUnknown,...J(e)});class Ut extends ne{_parse(t){const n=this._getOrReturnCtx(t);return V(n,{code:R.invalid_type,expected:Z.never,received:n.parsedType}),W}}Ut.create=e=>new Ut({typeName:F.ZodNever,...J(e)});class Rs extends ne{_parse(t){if(this._getType(t)!==Z.undefined){const r=this._getOrReturnCtx(t);return V(r,{code:R.invalid_type,expected:Z.void,received:r.parsedType}),W}return De(t.data)}}Rs.create=e=>new Rs({typeName:F.ZodVoid,...J(e)});class it extends ne{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),s=this._def;if(n.parsedType!==Z.array)return V(n,{code:R.invalid_type,expected:Z.array,received:n.parsedType}),W;if(s.exactLength!==null){const i=n.data.length>s.exactLength.value,a=n.data.lengths.maxLength.value&&(V(n,{code:R.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((i,a)=>s.type._parseAsync(new bt(n,i,n.path,a)))).then(i=>Re.mergeArray(r,i));const o=[...n.data].map((i,a)=>s.type._parseSync(new bt(n,i,n.path,a)));return Re.mergeArray(r,o)}get element(){return this._def.type}min(t,n){return new it({...this._def,minLength:{value:t,message:z.toString(n)}})}max(t,n){return new it({...this._def,maxLength:{value:t,message:z.toString(n)}})}length(t,n){return new it({...this._def,exactLength:{value:t,message:z.toString(n)}})}nonempty(t){return this.min(1,t)}}it.create=(e,t)=>new it({type:e,minLength:null,maxLength:null,exactLength:null,typeName:F.ZodArray,...J(t)});function Mn(e){if(e instanceof ve){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Ct.create(Mn(r))}return new ve({...e._def,shape:()=>t})}else return e instanceof it?new it({...e._def,type:Mn(e.element)}):e instanceof Ct?Ct.create(Mn(e.unwrap())):e instanceof On?On.create(Mn(e.unwrap())):e instanceof wt?wt.create(e.items.map(t=>Mn(t))):e}class ve extends ne{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=fe.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(t){if(this._getType(t)!==Z.object){const u=this._getOrReturnCtx(t);return V(u,{code:R.invalid_type,expected:Z.object,received:u.parsedType}),W}const{status:r,ctx:s}=this._processInputParams(t),{shape:o,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ut&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||a.push(u);const c=[];for(const u of i){const f=o[u],l=s.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new bt(s,l,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Ut){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of a)c.push({key:{status:"valid",value:f},value:{status:"valid",value:s.data[f]}});else if(u==="strict")a.length>0&&(V(s,{code:R.unrecognized_keys,keys:a}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of a){const l=s.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new bt(s,l,s.path,f)),alwaysSet:f in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const l=await f.key;u.push({key:l,value:await f.value,alwaysSet:f.alwaysSet})}return u}).then(u=>Re.mergeObjectSync(r,u)):Re.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(t){return new ve({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,o,i,a;const c=(i=(o=(s=this._def).errorMap)===null||o===void 0?void 0:o.call(s,n,r).message)!==null&&i!==void 0?i:r.defaultError;return n.code==="unrecognized_keys"?{message:(a=z.errToObj(t).message)!==null&&a!==void 0?a:c}:{message:c}}}:{}})}strip(){return new ve({...this._def,unknownKeys:"strip"})}passthrough(){return new ve({...this._def,unknownKeys:"passthrough"})}extend(t){return new ve({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new ve({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:F.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new ve({...this._def,catchall:t})}pick(t){const n={};return fe.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new ve({...this._def,shape:()=>n})}omit(t){const n={};return fe.objectKeys(this.shape).forEach(r=>{t[r]||(n[r]=this.shape[r])}),new ve({...this._def,shape:()=>n})}deepPartial(){return Mn(this)}partial(t){const n={};return fe.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];t&&!t[r]?n[r]=s:n[r]=s.optional()}),new ve({...this._def,shape:()=>n})}required(t){const n={};return fe.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])n[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof Ct;)o=o._def.innerType;n[r]=o}}),new ve({...this._def,shape:()=>n})}keyof(){return Hf(fe.objectKeys(this.shape))}}ve.create=(e,t)=>new ve({shape:()=>e,unknownKeys:"strip",catchall:Ut.create(),typeName:F.ZodObject,...J(t)});ve.strictCreate=(e,t)=>new ve({shape:()=>e,unknownKeys:"strict",catchall:Ut.create(),typeName:F.ZodObject,...J(t)});ve.lazycreate=(e,t)=>new ve({shape:e,unknownKeys:"strip",catchall:Ut.create(),typeName:F.ZodObject,...J(t)});class Cr extends ne{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function s(o){for(const a of o)if(a.result.status==="valid")return a.result;for(const a of o)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const i=o.map(a=>new ot(a.ctx.common.issues));return V(n,{code:R.invalid_union,unionErrors:i}),W}if(n.common.async)return Promise.all(r.map(async o=>{const i={...n,common:{...n.common,issues:[]},parent:null};return{result:await o._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(s);{let o;const i=[];for(const c of r){const u={...n,common:{...n.common,issues:[]},parent:null},f=c._parseSync({data:n.data,path:n.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!o&&(o={result:f,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(c=>new ot(c));return V(n,{code:R.invalid_union,unionErrors:a}),W}}get options(){return this._def.options}}Cr.create=(e,t)=>new Cr({options:e,typeName:F.ZodUnion,...J(t)});const ws=e=>e instanceof Nr?ws(e.schema):e instanceof ut?ws(e.innerType()):e instanceof Lr?[e.value]:e instanceof cn?e.options:e instanceof Rr?Object.keys(e.enum):e instanceof Hr?ws(e._def.innerType):e instanceof Ir?[void 0]:e instanceof Tr?[null]:null;class lo extends ne{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Z.object)return V(n,{code:R.invalid_type,expected:Z.object,received:n.parsedType}),W;const r=this.discriminator,s=n.data[r],o=this.optionsMap.get(s);return o?n.common.async?o._parseAsync({data:n.data,path:n.path,parent:n}):o._parseSync({data:n.data,path:n.path,parent:n}):(V(n,{code:R.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),W)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const s=new Map;for(const o of n){const i=ws(o.shape[t]);if(!i)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of i){if(s.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);s.set(a,o)}}return new lo({typeName:F.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:s,...J(r)})}}function wi(e,t){const n=Jt(e),r=Jt(t);if(e===t)return{valid:!0,data:e};if(n===Z.object&&r===Z.object){const s=fe.objectKeys(t),o=fe.objectKeys(e).filter(a=>s.indexOf(a)!==-1),i={...e,...t};for(const a of o){const c=wi(e[a],t[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(n===Z.array&&r===Z.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let o=0;o{if(yi(o)||yi(i))return W;const a=wi(o.value,i.value);return a.valid?((bi(o)||bi(i))&&n.dirty(),{status:n.value,value:a.data}):(V(r,{code:R.invalid_intersection_types}),W)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,i])=>s(o,i)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Pr.create=(e,t,n)=>new Pr({left:e,right:t,typeName:F.ZodIntersection,...J(n)});class wt extends ne{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Z.array)return V(r,{code:R.invalid_type,expected:Z.array,received:r.parsedType}),W;if(r.data.lengththis._def.items.length&&(V(r,{code:R.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const o=[...r.data].map((i,a)=>{const c=this._def.items[a]||this._def.rest;return c?c._parse(new bt(r,i,r.path,a)):null}).filter(i=>!!i);return r.common.async?Promise.all(o).then(i=>Re.mergeArray(n,i)):Re.mergeArray(n,o)}get items(){return this._def.items}rest(t){return new wt({...this._def,rest:t})}}wt.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new wt({items:e,typeName:F.ZodTuple,rest:null,...J(t)})};class Ur extends ne{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Z.object)return V(r,{code:R.invalid_type,expected:Z.object,received:r.parsedType}),W;const s=[],o=this._def.keyType,i=this._def.valueType;for(const a in r.data)s.push({key:o._parse(new bt(r,a,r.path,a)),value:i._parse(new bt(r,r.data[a],r.path,a))});return r.common.async?Re.mergeObjectAsync(n,s):Re.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof ne?new Ur({keyType:t,valueType:n,typeName:F.ZodRecord,...J(r)}):new Ur({keyType:rt.create(),valueType:t,typeName:F.ZodRecord,...J(n)})}}class Hs extends ne{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Z.map)return V(r,{code:R.invalid_type,expected:Z.map,received:r.parsedType}),W;const s=this._def.keyType,o=this._def.valueType,i=[...r.data.entries()].map(([a,c],u)=>({key:s._parse(new bt(r,a,r.path,[u,"key"])),value:o._parse(new bt(r,c,r.path,[u,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const c of i){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return W;(u.status==="dirty"||f.status==="dirty")&&n.dirty(),a.set(u.value,f.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const c of i){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return W;(u.status==="dirty"||f.status==="dirty")&&n.dirty(),a.set(u.value,f.value)}return{status:n.value,value:a}}}}Hs.create=(e,t,n)=>new Hs({valueType:t,keyType:e,typeName:F.ZodMap,...J(n)});class Bn extends ne{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Z.set)return V(r,{code:R.invalid_type,expected:Z.set,received:r.parsedType}),W;const s=this._def;s.minSize!==null&&r.data.sizes.maxSize.value&&(V(r,{code:R.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const o=this._def.valueType;function i(c){const u=new Set;for(const f of c){if(f.status==="aborted")return W;f.status==="dirty"&&n.dirty(),u.add(f.value)}return{status:n.value,value:u}}const a=[...r.data.values()].map((c,u)=>o._parse(new bt(r,c,r.path,u)));return r.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(t,n){return new Bn({...this._def,minSize:{value:t,message:z.toString(n)}})}max(t,n){return new Bn({...this._def,maxSize:{value:t,message:z.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Bn.create=(e,t)=>new Bn({valueType:e,minSize:null,maxSize:null,typeName:F.ZodSet,...J(t)});class Wn extends ne{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Z.function)return V(n,{code:R.invalid_type,expected:Z.function,received:n.parsedType}),W;function r(a,c){return Ps({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Cs(),Br].filter(u=>!!u),issueData:{code:R.invalid_arguments,argumentsError:c}})}function s(a,c){return Ps({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Cs(),Br].filter(u=>!!u),issueData:{code:R.invalid_return_type,returnTypeError:c}})}const o={errorMap:n.common.contextualErrorMap},i=n.data;return this._def.returns instanceof nr?De(async(...a)=>{const c=new ot([]),u=await this._def.args.parseAsync(a,o).catch(d=>{throw c.addIssue(r(a,d)),c}),f=await i(...u);return await this._def.returns._def.type.parseAsync(f,o).catch(d=>{throw c.addIssue(s(f,d)),c})}):De((...a)=>{const c=this._def.args.safeParse(a,o);if(!c.success)throw new ot([r(a,c.error)]);const u=i(...c.data),f=this._def.returns.safeParse(u,o);if(!f.success)throw new ot([s(u,f.error)]);return f.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new Wn({...this._def,args:wt.create(t).rest(Sn.create())})}returns(t){return new Wn({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new Wn({args:t||wt.create([]).rest(Sn.create()),returns:n||Sn.create(),typeName:F.ZodFunction,...J(r)})}}class Nr extends ne{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Nr.create=(e,t)=>new Nr({getter:e,typeName:F.ZodLazy,...J(t)});class Lr extends ne{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return V(n,{received:n.data,code:R.invalid_literal,expected:this._def.value}),W}return{status:"valid",value:t.data}}get value(){return this._def.value}}Lr.create=(e,t)=>new Lr({value:e,typeName:F.ZodLiteral,...J(t)});function Hf(e,t){return new cn({values:e,typeName:F.ZodEnum,...J(t)})}class cn extends ne{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return V(n,{expected:fe.joinValues(r),received:n.parsedType,code:R.invalid_type}),W}if(this._def.values.indexOf(t.data)===-1){const n=this._getOrReturnCtx(t),r=this._def.values;return V(n,{received:n.data,code:R.invalid_enum_value,options:r}),W}return De(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t){return cn.create(t)}exclude(t){return cn.create(this.options.filter(n=>!t.includes(n)))}}cn.create=Hf;class Rr extends ne{_parse(t){const n=fe.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Z.string&&r.parsedType!==Z.number){const s=fe.objectValues(n);return V(r,{expected:fe.joinValues(s),received:r.parsedType,code:R.invalid_type}),W}if(n.indexOf(t.data)===-1){const s=fe.objectValues(n);return V(r,{received:r.data,code:R.invalid_enum_value,options:s}),W}return De(t.data)}get enum(){return this._def.values}}Rr.create=(e,t)=>new Rr({values:e,typeName:F.ZodNativeEnum,...J(t)});class nr extends ne{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Z.promise&&n.common.async===!1)return V(n,{code:R.invalid_type,expected:Z.promise,received:n.parsedType}),W;const r=n.parsedType===Z.promise?n.data:Promise.resolve(n.data);return De(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}nr.create=(e,t)=>new nr({type:e,typeName:F.ZodPromise,...J(t)});class ut extends ne{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===F.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=this._def.effect||null;if(s.type==="preprocess"){const i=s.transform(r.data);return r.common.async?Promise.resolve(i).then(a=>this._def.schema._parseAsync({data:a,path:r.path,parent:r})):this._def.schema._parseSync({data:i,path:r.path,parent:r})}const o={addIssue:i=>{V(r,i),i.fatal?n.abort():n.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),s.type==="refinement"){const i=a=>{const c=s.refinement(a,o);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?W:(a.status==="dirty"&&n.dirty(),i(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?W:(a.status==="dirty"&&n.dirty(),i(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Us(i))return i;const a=s.transform(i.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>Us(i)?Promise.resolve(s.transform(i.value,o)).then(a=>({status:n.value,value:a})):i);fe.assertNever(s)}}ut.create=(e,t,n)=>new ut({schema:e,typeName:F.ZodEffects,effect:t,...J(n)});ut.createWithPreprocess=(e,t,n)=>new ut({schema:t,effect:{type:"preprocess",transform:e},typeName:F.ZodEffects,...J(n)});class Ct extends ne{_parse(t){return this._getType(t)===Z.undefined?De(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Ct.create=(e,t)=>new Ct({innerType:e,typeName:F.ZodOptional,...J(t)});class On extends ne{_parse(t){return this._getType(t)===Z.null?De(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}On.create=(e,t)=>new On({innerType:e,typeName:F.ZodNullable,...J(t)});class Hr extends ne{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===Z.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Hr.create=(e,t)=>new Hr({innerType:e,typeName:F.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...J(t)});class js extends ne{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ns(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new ot(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ot(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}js.create=(e,t)=>new js({innerType:e,typeName:F.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...J(t)});class Ks extends ne{_parse(t){if(this._getType(t)!==Z.nan){const r=this._getOrReturnCtx(t);return V(r,{code:R.invalid_type,expected:Z.nan,received:r.parsedType}),W}return{status:"valid",value:t.data}}}Ks.create=e=>new Ks({typeName:F.ZodNaN,...J(e)});const xb=Symbol("zod_brand");class jf extends ne{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class zr extends ne{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?W:o.status==="dirty"?(n.dirty(),Rf(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?W:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(t,n){return new zr({in:t,out:n,typeName:F.ZodPipeline})}}const Kf=(e,t={},n)=>e?tr.create().superRefine((r,s)=>{var o,i;if(!e(r)){const a=typeof t=="function"?t(r):typeof t=="string"?{message:t}:t,c=(i=(o=a.fatal)!==null&&o!==void 0?o:n)!==null&&i!==void 0?i:!0,u=typeof a=="string"?{message:a}:a;s.addIssue({code:"custom",...u,fatal:c})}}):tr.create(),vb={object:ve.lazycreate};var F;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline"})(F||(F={}));const Eb=(e,t={message:`Input not instance of ${e.name}`})=>Kf(n=>n instanceof e,t),Df=rt.create,Zf=on.create,Sb=Ks.create,kb=an.create,Vf=Or.create,_b=An.create,$b=Ls.create,Ab=Ir.create,Bb=Tr.create,Ob=tr.create,Ib=Sn.create,Tb=Ut.create,Cb=Rs.create,Pb=it.create,Ub=ve.create,Nb=ve.strictCreate,Lb=Cr.create,Rb=lo.create,Hb=Pr.create,jb=wt.create,Kb=Ur.create,Db=Hs.create,Zb=Bn.create,Vb=Wn.create,Mb=Nr.create,qb=Lr.create,zb=cn.create,Fb=Rr.create,Gb=nr.create,rc=ut.create,Wb=Ct.create,Yb=On.create,Xb=ut.createWithPreprocess,Jb=zr.create,Qb=()=>Df().optional(),ew=()=>Zf().optional(),tw=()=>Vf().optional(),nw={string:(e=>rt.create({...e,coerce:!0})),number:(e=>on.create({...e,coerce:!0})),boolean:(e=>Or.create({...e,coerce:!0})),bigint:(e=>an.create({...e,coerce:!0})),date:(e=>An.create({...e,coerce:!0}))},rw=W;var Ke=Object.freeze({__proto__:null,defaultErrorMap:Br,setErrorMap:ab,getErrorMap:Cs,makeIssue:Ps,EMPTY_PATH:cb,addIssueToContext:V,ParseStatus:Re,INVALID:W,DIRTY:Rf,OK:De,isAborted:yi,isDirty:bi,isValid:Us,isAsync:Ns,get util(){return fe},get objectUtil(){return mi},ZodParsedType:Z,getParsedType:Jt,ZodType:ne,ZodString:rt,ZodNumber:on,ZodBigInt:an,ZodBoolean:Or,ZodDate:An,ZodSymbol:Ls,ZodUndefined:Ir,ZodNull:Tr,ZodAny:tr,ZodUnknown:Sn,ZodNever:Ut,ZodVoid:Rs,ZodArray:it,ZodObject:ve,ZodUnion:Cr,ZodDiscriminatedUnion:lo,ZodIntersection:Pr,ZodTuple:wt,ZodRecord:Ur,ZodMap:Hs,ZodSet:Bn,ZodFunction:Wn,ZodLazy:Nr,ZodLiteral:Lr,ZodEnum:cn,ZodNativeEnum:Rr,ZodPromise:nr,ZodEffects:ut,ZodTransformer:ut,ZodOptional:Ct,ZodNullable:On,ZodDefault:Hr,ZodCatch:js,ZodNaN:Ks,BRAND:xb,ZodBranded:jf,ZodPipeline:zr,custom:Kf,Schema:ne,ZodSchema:ne,late:vb,get ZodFirstPartyTypeKind(){return F},coerce:nw,any:Ob,array:Pb,bigint:kb,boolean:Vf,date:_b,discriminatedUnion:Rb,effect:rc,enum:zb,function:Vb,instanceof:Eb,intersection:Hb,lazy:Mb,literal:qb,map:Db,nan:Sb,nativeEnum:Fb,never:Tb,null:Bb,nullable:Yb,number:Zf,object:Ub,oboolean:tw,onumber:ew,optional:Wb,ostring:Qb,pipeline:Jb,preprocess:Xb,promise:Gb,record:Kb,set:Zb,strictObject:Nb,string:Df,symbol:$b,transformer:rc,tuple:jb,undefined:Ab,union:Lb,unknown:Ib,void:Cb,NEVER:rw,ZodIssueCode:R,quotelessJson:ib,ZodError:ot});const Mf=Ke.string().regex(/^[a-fA-F0-9]$/),sw=Ke.string().regex(/^[a-fA-F0-9]{64}$/),rr=Ke.number().min(0).max(4294967295),ow=Ke.bigint(),qf=Ke.instanceof(Uint8Array),iw=Ke.union([Mf,rr,Ke.string(),qf]).array(),ha=Ke.union([iw,Mf,qf]),aw=Ke.array(ha),zf=Ke.object({value:Ke.union([rr,ow]),scriptPubKey:ha}),cw=Ke.object({txid:sw,vout:rr,scriptSig:ha,sequence:rr,prevout:zf.optional(),witness:aw});Ke.object({version:rr,vin:Ke.array(cw),vout:Ke.array(zf),locktime:rr});const xi=2048,uw=new TextEncoder;function Ff(e){const t=[],n=(s,o)=>{if(o<24)t.push(s*32+o);else if(o<=255)t.push(s*32+24,o);else if(o<=65535)t.push(s*32+25,o>>>8,o&255);else if(o<=4294967295){const i=new Uint8Array(4);new DataView(i.buffer).setUint32(0,o),t.push(s*32+26,...i)}else{t.push(s*32+27);const i=new Uint8Array(8);new DataView(i.buffer).setBigUint64(0,BigInt(o)),t.push(...i)}},r=(s,o=0)=>{if(o>64)throw new Error("Metadata nesting exceeds 64 levels.");if(s===null)t.push(246);else if(typeof s=="boolean")t.push(s?245:244);else if(typeof s=="number"&&Number.isFinite(s))if(Number.isSafeInteger(s)&&!Object.is(s,-0))n(s>=0?0:1,s>=0?s:-1-s);else{const i=new Uint8Array(8);new DataView(i.buffer).setFloat64(0,s),t.push(251,...i)}else if(typeof s=="string"){const i=uw.encode(s);n(3,i.length);for(const a of i)t.push(a)}else if(Array.isArray(s))n(4,s.length),s.forEach(i=>r(i,o+1));else if(typeof s=="object"&&Object.getPrototypeOf(s)===Object.prototype){const i=Object.entries(s);n(5,i.length);for(const[a,c]of i)r(a,o+1),r(c,o+1)}else throw new Error("Metadata must contain only JSON values.");if(t.length>xi)throw new Error(`Metadata must be at most ${xi} CBOR bytes.`)};return r(e),Uint8Array.from(t)}function fw(e){if(e=new Uint8Array(e),!e.length||e.length>xi)throw new Error("Invalid CBOR metadata size.");let t=0;const n=o=>{if(t+o>e.length)throw new Error("Truncated CBOR metadata.");const i=e.slice(t,t+o);return t+=o,i},r=(o=0)=>{if(o>64)throw new Error("Metadata nesting exceeds 64 levels.");const i=n(1)[0],a=i>>5,c=i&31;if(a===7){if(c===20)return!1;if(c===21)return!0;if(c===22)return null;if(c===27){const f=new DataView(n(8).buffer).getFloat64(0);if(Number.isFinite(f))return f}throw new Error("Unsupported CBOR value.")}let u=c;if(c>=24&&c<=27){u=0;for(const f of n(2**(c-24)))u=u*256+f}else if(c>=28)throw new Error("Unsupported CBOR length.");if(!Number.isSafeInteger(u))throw new Error("CBOR integer exceeds JSON precision.");if(a===0)return u;if(a===1)return-1-u;if(a===3)return new TextDecoder("utf-8",{fatal:!0}).decode(n(u));if((a===4||a===5)&&u>e.length)throw new Error("Invalid CBOR collection length.");if(a===4)return Array.from({length:u},()=>r(o+1));if(a===5){const f={};for(let l=0;l({txid:e,vout:t,sequence:4294967295,prevout:{value:n,scriptPubKey:r}}),Me=(e,t)=>({value:e,scriptPubKey:t}),sc=16*1024,Bt=1e3,be=500,Ds="text/plain;charset=utf-8",lw=["text/plain","application/json","text/html","image/svg+xml","image/png","image/jpeg","image/webp"],Gf=new TextEncoder,Er=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join(""),hn=e=>Uint8Array.from(e.match(/../g)??[],t=>parseInt(t,16)),Zs=e=>Er(Gf.encode(e));function pa(e){const t=typeof e=="string"?{contentType:Ds,bytes:Gf.encode(e)}:e;if(!t||![...lw,Ds].includes(t.contentType))throw new Error("Unsupported MIME type.");if(!(t.bytes instanceof Uint8Array)||!t.bytes.length)throw new Error("Enter non-empty inscription bytes.");if(t.bytes.length>sc)throw new Error(`Body must be at most ${sc} bytes.`);return{contentType:t.contentType,bytes:new Uint8Array(t.bytes)}}function Vs(e){const t=/^([0-9a-f]{64})i(0|[1-9][0-9]*)$/.exec(e);if(!t||Number(t[2])>4294967295)throw new Error("Invalid parent inscription id.");let n=Number(t[2]),r="";for(;n;)r+=(n%256).toString(16).padStart(2,"0"),n=Math.floor(n/256);return t[1].match(/../g).reverse().join("")+r}function oc(e){if(typeof e!="string"||!/^[0-9a-f]{64,72}$/.test(e)||e.length%2)throw new Error("Invalid parent tag.");const t=[...hn(e.slice(64))].reduce((r,s,o)=>r+s*256**o,0),n=`${e.slice(0,64).match(/../g).reverse().join("")}i${t}`;if(Vs(n)!==e)throw new Error("Non-canonical parent tag.");return n}function Wf(e,t,n=null,r=void 0,s={}){const{contentType:o,bytes:i}=pa(t),{delegate:a=null,pointer:c,metaprotocol:u=null}=s,f=u==null||u===""?null:new TextEncoder().encode(String(u));if(f&&f.length>520)throw new Error("Metaprotocol identifier must be 520 bytes or less.");const l=r===void 0?void 0:Ff(r),d=[];for(let m=0;m{const y=m.length/2;return(y<=75?y.toString(16).padStart(2,"0"):y<=255?"4c"+y.toString(16).padStart(2,"0"):"4d"+(y%256).toString(16).padStart(2,"0")+Math.floor(y/256).toString(16).padStart(2,"0"))+m};return h(e)+"ac0063"+h(Zs("ord"))+h("01")+h(Zs(o))+(a?h("0b")+h(Vs(a)):"")+(c===void 0?"":h("02")+h(Yf(c)))+(n?h("03")+h(Vs(n)):"")+(l===void 0?"":Array.from({length:Math.ceil(l.length/520)},(m,y)=>h("05")+h(Er(l.slice(y*520,(y+1)*520)))).join(""))+(f?h("07")+h(Er(f)):"")+"00"+d.map(h).join("")+"68"}function ga(e){if(!Array.isArray(e)||e.length!==3)throw new Error("Unsupported script-path witness.");const t=Se.decode(e[1]);let n=7,r=null,s=null,o;t[n]==="0b"&&(s=oc(t[n+1]),n+=2),t[n]==="02"&&(o=hw(t[n+1]==="OP_0"?"":t[n+1]),n+=2),t[n]==="03"&&(r=oc(t[n+1]),n+=2);const i=[];for(;t[n]==="05";){const m=t[n+1];if(typeof m!="string"||!/^(?:[0-9a-f]{2}){1,520}$/.test(m))throw new Error("Invalid metadata push.");i.push(m),n+=2}const a=i.length?fw(hn(i.join(""))):void 0;let c=null;if(t[n]==="07"){const m=t[n+1];if(typeof m!="string"||!/^(?:[0-9a-f]{2}){1,520}$/.test(m))throw new Error("Invalid metaprotocol field.");c=new TextDecoder().decode(hn(m)),n+=2}if(t[n]!=="OP_0")throw new Error("Unsupported ord tag or missing body separator.");const u=t.slice(n+1,-1);if(!u.length||u.some(m=>typeof m!="string"||!/^(?:[0-9a-f]{2})+$/.test(m)))throw new Error("Invalid body envelope.");const f=new TextDecoder().decode(hn(t[6])),l=pa({contentType:f,bytes:hn(u.join(""))}),d=Wf(t[0],l,r,a,{delegate:s,pointer:o,metaprotocol:c}),h=a===void 0&&!r&&f===Ds&&l.bytes.length<=280&&Se.encode([t[0],"OP_CHECKSIG","OP_0","OP_IF",Zs("ord"),"01",Zs(Ds),"OP_0",Er(l.bytes),"OP_ENDIF"],!1).hex;if(d!==e[1]&&h!==e[1])throw new Error("Unsupported ord envelope.");if(!/^[0-9a-f]{64}$/.test(t[0]))throw new Error("Invalid inscription signing key.");return{...l,parent:r,delegate:s,pointer:o,metaprotocol:c,metadata:a,metadataBytes:i.length?hn(i.join("")):void 0,text:new TextDecoder().decode(l.bytes),pubkey:t[0]}}class dw{constructor(t,n){this.chain=t,this.wallet=n}prepare(t,n=null,r=void 0,s={}){const o=pa(t);if(r!==void 0&&Ff(r),s.delegate&&Vs(s.delegate),s.pointer!==void 0&&Yf(s.pointer),s.metaprotocol!==void 0&&s.metaprotocol!==null&&s.metaprotocol!==""&&new TextEncoder().encode(String(s.metaprotocol)).length>520)throw new Error("Metaprotocol identifier must be 520 bytes or less.");if(n&&s.reinscribe)throw new Error("Choose parent or reinscription, not both.");const i=this.chain.coins(this.wallet.script),a=n?i.find(f=>{var l;return(l=f.inscriptions)==null?void 0:l.some(d=>d.id===n)}):null;if(n&&!a)throw new Error("Parent must be an owned, unspent inscription.");const c=s.reinscribe?i.find(f=>{var l;return(l=f.inscriptions)==null?void 0:l.some(d=>d.id===s.reinscribe)}):null;if(s.reinscribe&&!c)throw new Error("Reinscription must spend an owned sat.");const u=i.find(f=>!f.inscription&&f.value>=Bt+2*be+330);if(!u)throw new Error("Mine a block first to get spendable fake BTC.");return{...o,coin:u,parent:a,reinscribe:c,totalFee:be*2,postage:Bt}}inscribe(t,n=null,r=void 0,s={}){const{coin:o,parent:i,reinscribe:a,...c}=this.prepare(t,n,r,s),u=i??a,f=a==null?void 0:a.inscriptions.find(O=>O.id===s.reinscribe),l=f?this.chain.satLocation(f.sat).offset:s.pointer??(i?i.value:void 0),d=Wf(this.wallet.pubkey,c,n,r,{...s,pointer:l}),h=Ts.encodeScript(d),[m,y]=Ts.getPubKey(this.wallet.pubkey,{target:h}),p=ae.create({vin:[tn(o.txid,o.vout,o.value,o.scriptPubKey)],vout:[Me(Bt+be,["OP_1",m]),Me(o.value-Bt-2*be,this.wallet.script)]});p.vin[0].witness=[this.wallet.sign(p)];const g=ae.util.getTxid(p),x=ae.create({vin:[...u?[tn(u.txid,u.vout,u.value,u.scriptPubKey)]:[],tn(g,0,Bt+be,["OP_1",m])],vout:[...u?[Me(u.value,this.wallet.script)]:[],Me(Bt,this.wallet.script)]}),w=u?1:0;return x.vin[w].witness=[this.wallet.sign(x,h,w),Se.encode(d,!1).hex,y],u&&(x.vin[0].witness=[this.wallet.sign(x)]),this.chain.submitPackage([ae.encode(p).hex,ae.encode(x).hex]),`${ae.util.getTxid(x)}i0`}list(){return this.chain.coins(this.wallet.script).flatMap(t=>t.inscriptions??[])}}function Yf(e){let t;try{t=BigInt(e)}catch{throw new Error("Invalid pointer.")}if(t<0n||t>0xffffffffffffffffn||typeof e=="number"&&!Number.isSafeInteger(e))throw new Error("Invalid pointer.");let n="";for(;t;)n+=Number(t&255n).toString(16).padStart(2,"0"),t>>=8n;return n}function hw(e){if(typeof e!="string"||!/^(?:[0-9a-f]{2}){0,8}$/.test(e))throw new Error("Invalid pointer tag.");return[...hn(e)].reduce((t,n,r)=>t+(BigInt(n)<{var g;const i=ae.decode(r),a=ae.util.getTxid(i),c=i.vin[0].txid==="0".repeat(64),u=c?[]:i.vin.map(x=>this.utxos.get(`${x.txid}:${x.vout}`)),f=Dc(i,u,s,c);i.vin.forEach(x=>this.utxos.delete(`${x.txid}:${x.vout}`)),i.vout.forEach((x,w)=>this.utxos.set(`${a}:${w}`,{txid:a,vout:w,value:Number(x.value),ranges:f[w]}));const l=(g=i.vin.find(x=>{var w;return((w=x.witness)==null?void 0:w.length)===3}))==null?void 0:g.witness;if(!l)return;const d=ga(l),h=BigInt(d.pointer??0),m=i.vout.reduce((x,w)=>x+Number(w.value),0),y=Kc(f.flat(),hx.sat===y).length,status:s===null?"pending":"confirmed",height:s,block:o,metadata:p??null,hasMetadata:p!==void 0,parent:d.parent,protocol:d.metaprotocol??(p&&!Array.isArray(p)&&typeof p=="object"&&Object.hasOwn(p,"protocol")&&typeof p.protocol=="string"?p.protocol:null)})};for(const r of t.blocks)for(const s of r.raws)n(s,r.height,r.hash);for(const r of t.mempool)n(r,null,null);for(const r of this.events){r.location=null;for(const s of this.utxos.values()){const o=ys(s.ranges,r.sat);if(o!==null){r.location={txid:s.txid,vout:s.vout,offset:o};break}}r.delegatedBy=this.events.filter(s=>s.delegate===r.id).map(s=>s.id),r.inscriptions=this.events.filter(s=>s.sat===r.sat).map(s=>s.id)}}forProtocol(t){return this.events.filter(n=>n.protocol===t)}get protocols(){return[...new Set(this.events.filter(t=>t.protocol!==null).map(t=>t.protocol))].sort()}get stats(){return{events:this.events.length,withMetadata:this.events.filter(t=>t.hasMetadata).length,confirmed:this.events.filter(t=>t.status==="confirmed").length,pending:this.events.filter(t=>t.status==="pending").length,protocols:this.protocols}}}const ma="lineage/v0",pw=["white","green","black"],ic="names are 1-40 lowercase letters, digits or hyphens (they become domains)",gw=/^[a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?$/,Ro=e=>typeof e=="string"&&gw.test(e),xs=(e,t)=>typeof e=="string"?e.trim().slice(0,t):"";function ya(e){return String(e??"").toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/,"")}const ba=e=>e.events.filter(t=>t.protocol===ma);function In(e,{upTo:t=1/0,pending:n=!1}={}){const r=new Map,s=[],o=[],i=a=>a.status==="active";for(const a of e){const c=a.status==="confirmed";if(c?a.height>t:!n)continue;const u=a.metadata&&typeof a.metadata=="object"&&!Array.isArray(a.metadata)?a.metadata:{},f={id:a.id,op:typeof u.op=="string"?u.op.slice(0,20):"?",beat:c?a.height:null,pending:!c,meta:u,parent:a.parent??null,ok:!0,why:"",node:null,root:null,also:[]},l=f.parent?r.get(f.parent):null,d=f.beat??"cued",h=p=>{f.ok=!1,f.why=p},m=p=>l?i(l)?"":`the ${p} is ${l.status}`:`the ${p} is not in this lineage`;let y="";switch(f.op){case"found":if(f.parent)h("a holding has no parent");else if(!Ro(u.name))h(ic);else if(s.some(p=>i(p)&&p.name===u.name))h(`an active holding is already named ${u.name}`);else{const p=ac(a,u.name,null,"holding");r.set(p.id,p),s.push(p),f.node=p.id}break;case"birth":{const p=u.kind==="agent"?"agent":"org";if(y=m("parent"))h(y);else if(l.kind==="agent")h("agents do not give birth");else if(!Ro(u.name))h(ic);else if(l.children.some(g=>i(r.get(g))&&r.get(g).name===u.name))h(`${l.name} already has an active ${u.name}`);else{const g=ac(a,u.name,l,p);g.index=l.children.filter(x=>r.get(x).kind===p).length,l.children.push(g.id),r.set(g.id,g),f.node=g.id}break}case"award":{const p=r.get(u.to);(y=m("issuer"))?h(y):l.kind==="agent"?h("agents do not award belts"):!p||p.root!==l.root||p.id===l.id?h("the recipient must be another node in this holding"):i(p)?!Ro(u.skill)||!pw.includes(u.belt)?h("an award needs a skill name and a belt (white, green or black)"):(p.badges=p.badges.filter(g=>g.skill!==u.skill),p.badges.push({skill:u.skill,belt:u.belt,by:l.id,beat:d,id:a.id}),f.node=p.id):h(`the recipient is ${p.status}`);break}case"decide":(y=m("decider"))?h(y):xs(u.title,140)?(l.decisions.push({title:xs(u.title,140),why:xs(u.why,400),beat:d,id:a.id}),f.node=l.id):h("a decision needs a title");break;case"graduate":{const p=r.get(u.of);(y=m("parent"))?h(y):!p||p.parent!==l.id?h("only its parent can graduate a child"):p.kind!=="org"?h("only orgs graduate"):i(p)?p.edge==="adopted"?h("already graduated"):(p.edge="adopted",p.graduated=d,f.node=p.id):h(`the child is ${p.status}`);break}case"close":if(!l)h(f.parent?"that node is not in this lineage":"a close spends the node it closes");else if(!i(l))h(`already ${l.status}`);else{const p=g=>{g.status="closed",g.closed=d;for(const x of g.children){const w=r.get(x);w.edge==="derived"&&i(w)&&(f.also.push(w.id),p(w))}};p(l),f.node=l.id}break;default:h("not a lineage/v0 op")}f.root=f.node?r.get(f.node).root:(l==null?void 0:l.root)??null,o.push(f)}return{nodes:r,roots:s,log:o}}function ac(e,t,n,r){return{id:e.id,name:t,kind:r,parent:(n==null?void 0:n.id)??null,root:n?n.root:e.id,edge:n?"derived":null,status:"active",index:null,born:e.status==="confirmed"?e.height:"cued",children:[],badges:[],decisions:[],graduated:null,closed:null}}function mw(e,t){const n=[],r=e.nodes.get(t),s=(o,i,a)=>{n.push({type:"node",node:o,guide:i,path:o.parent?`${o.index}'`:"●"});const c=o.children.map(f=>e.nodes.get(f)),u=[["agents",c.filter(f=>f.kind==="agent")],["orgs",c.filter(f=>f.kind!=="agent")]].filter(([,f])=>f.length);u.forEach(([f,l],d)=>{const h=d===u.length-1,m=a+(h?" ":"│ ");n.push({type:"group",label:f,guide:a+(h?"└─ ":"├─ ")}),l.forEach((y,p)=>{const g=p===l.length-1;s(y,m+(g?"└─ ":"├─ "),m+(g?" ":"│ "))})})};return r&&s(r,"",""),n}function yw(e,t){const n={orgs:0,agents:0,belts:0,decisions:0,closed:0};for(const r of e.nodes.values())r.root===t&&(r.id!==t&&(n[r.kind==="agent"?"agents":"orgs"]++,r.status==="closed"&&n.closed++),n.belts+=r.badges.length,n.decisions+=r.decisions.length);return n}function Xf(e,t){const n=[];for(let r=e.nodes.get(t);r;r=e.nodes.get(r.parent))n.unshift(r.name);return n.join(" / ")}function Jf(e,t){const n=e.meta,r=s=>{var o;return((o=t.nodes.get(s))==null?void 0:o.name)??(typeof s=="string"?`${s.slice(0,8)}…`:"?")};if(!e.ok)return`${e.op}: ${e.why}`;switch(e.op){case"found":return`found ${n.name}`;case"birth":return`birth ${n.name}${n.kind==="agent"?" (agent)":""} ← ${r(e.parent)}`;case"award":return`award ${n.skill} · ${n.belt} → ${r(n.to)}, from ${r(e.parent)}`;case"decide":return`decide “${xs(n.title,140)}” · ${r(e.parent)}`;case"graduate":return`graduate ${r(n.of)} from ${r(e.parent)}`;case"close":return`close ${r(e.parent)}${e.also.length?` and ${e.also.length} derived`:""}`;default:return e.op}}const Kn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Fr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function nn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ne(e,...t){if(!Fr(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Gr(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");nn(e.outputLen),nn(e.blockLen)}function Ms(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function bw(e,t){Ne(e);const n=t.outputLen;if(e.length>>t}function ss(e,t){return e<>>32-t>>>0}const Qf=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",ww=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Le(e){if(Ne(e),Qf)return e.toHex();let t="";for(let n=0;n=$t._0&&e<=$t._9)return e-$t._0;if(e>=$t.A&&e<=$t.F)return e-($t.A-10);if(e>=$t.a&&e<=$t.f)return e-($t.a-10)}function ft(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Qf)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let s=0,o=0;se().update(jr(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Hn(e=32){if(Kn&&typeof Kn.getRandomValues=="function")return Kn.getRandomValues(new Uint8Array(e));if(Kn&&typeof Kn.randomBytes=="function")return Uint8Array.from(Kn.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function vw(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,a,r)}function Ew(e,t,n){return e&t^~e&n}function Sw(e,t,n){return e&t^e&n^t&n}class xa extends el{constructor(t,n,r,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.buffer=new Uint8Array(t),this.view=kn(this.buffer)}update(t){Ms(this),t=jr(t),Ne(t);const{view:n,buffer:r,blockLen:s}=this,o=t.length;for(let i=0;is-i&&(this.process(r,0),i=0);for(let l=i;lf.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l>fc&os)}:{h:Number(e>>fc&os)|0,l:Number(e&os)|0}}function _w(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let o=0;oe>>>n,dc=(e,t,n)=>e<<32-n|t>>>n,Dn=(e,t,n)=>e>>>n|t<<32-n,Zn=(e,t,n)=>e<<32-n|t>>>n,is=(e,t,n)=>e<<64-n|t>>>n-32,as=(e,t,n)=>e>>>n-32|t<<64-n;function At(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const $w=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Aw=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Bw=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Ow=(e,t,n,r,s)=>t+n+r+s+(e/2**32|0)|0,Iw=(e,t,n,r,s)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(s>>>0),Tw=(e,t,n,r,s,o)=>t+n+r+s+o+(e/2**32|0)|0,Cw=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ft=new Uint32Array(64);class Pw extends xa{constructor(t=32){super(64,t,8,!1),this.A=zt[0]|0,this.B=zt[1]|0,this.C=zt[2]|0,this.D=zt[3]|0,this.E=zt[4]|0,this.F=zt[5]|0,this.G=zt[6]|0,this.H=zt[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[t,n,r,s,o,i,a,c]}set(t,n,r,s,o,i,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,n){for(let l=0;l<16;l++,n+=4)Ft[l]=t.getUint32(n,!1);for(let l=16;l<64;l++){const d=Ft[l-15],h=Ft[l-2],m=gt(d,7)^gt(d,18)^d>>>3,y=gt(h,17)^gt(h,19)^h>>>10;Ft[l]=y+Ft[l-7]+m+Ft[l-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){const d=gt(a,6)^gt(a,11)^gt(a,25),h=f+d+Ew(a,c,u)+Cw[l]+Ft[l]|0,y=(gt(r,2)^gt(r,13)^gt(r,22))+Sw(r,s,o)|0;f=u,u=c,c=a,a=i+h|0,i=o,o=s,s=r,r=h+y|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,s,o,i,a,c,u,f)}roundClean(){xt(Ft)}destroy(){this.set(0,0,0,0,0,0,0,0),xt(this.buffer)}}const tl=_w(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Uw=tl[0],Nw=tl[1],Gt=new Uint32Array(80),Wt=new Uint32Array(80);class Lw extends xa{constructor(t=64){super(128,t,16,!1),this.Ah=Ce[0]|0,this.Al=Ce[1]|0,this.Bh=Ce[2]|0,this.Bl=Ce[3]|0,this.Ch=Ce[4]|0,this.Cl=Ce[5]|0,this.Dh=Ce[6]|0,this.Dl=Ce[7]|0,this.Eh=Ce[8]|0,this.El=Ce[9]|0,this.Fh=Ce[10]|0,this.Fl=Ce[11]|0,this.Gh=Ce[12]|0,this.Gl=Ce[13]|0,this.Hh=Ce[14]|0,this.Hl=Ce[15]|0}get(){const{Ah:t,Al:n,Bh:r,Bl:s,Ch:o,Cl:i,Dh:a,Dl:c,Eh:u,El:f,Fh:l,Fl:d,Gh:h,Gl:m,Hh:y,Hl:p}=this;return[t,n,r,s,o,i,a,c,u,f,l,d,h,m,y,p]}set(t,n,r,s,o,i,a,c,u,f,l,d,h,m,y,p){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=s|0,this.Ch=o|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=f|0,this.Fh=l|0,this.Fl=d|0,this.Gh=h|0,this.Gl=m|0,this.Hh=y|0,this.Hl=p|0}process(t,n){for(let w=0;w<16;w++,n+=4)Gt[w]=t.getUint32(n),Wt[w]=t.getUint32(n+=4);for(let w=16;w<80;w++){const O=Gt[w-15]|0,A=Wt[w-15]|0,T=Dn(O,A,1)^Dn(O,A,8)^lc(O,A,7),U=Zn(O,A,1)^Zn(O,A,8)^dc(O,A,7),C=Gt[w-2]|0,_=Wt[w-2]|0,N=Dn(C,_,19)^is(C,_,61)^lc(C,_,6),H=Zn(C,_,19)^as(C,_,61)^dc(C,_,6),K=Bw(U,H,Wt[w-7],Wt[w-16]),v=Ow(K,T,N,Gt[w-7],Gt[w-16]);Gt[w]=v|0,Wt[w]=K|0}let{Ah:r,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:u,Dl:f,Eh:l,El:d,Fh:h,Fl:m,Gh:y,Gl:p,Hh:g,Hl:x}=this;for(let w=0;w<80;w++){const O=Dn(l,d,14)^Dn(l,d,18)^is(l,d,41),A=Zn(l,d,14)^Zn(l,d,18)^as(l,d,41),T=l&h^~l&y,U=d&m^~d&p,C=Iw(x,A,U,Nw[w],Wt[w]),_=Tw(C,g,O,T,Uw[w],Gt[w]),N=C|0,H=Dn(r,s,28)^is(r,s,34)^is(r,s,39),K=Zn(r,s,28)^as(r,s,34)^as(r,s,39),v=r&o^r&a^o&a,S=s&i^s&c^i&c;g=y|0,x=p|0,y=h|0,p=m|0,h=l|0,m=d|0,{h:l,l:d}=At(u|0,f|0,_|0,N|0),u=a|0,f=c|0,a=o|0,c=i|0,o=r|0,i=s|0;const b=$w(N,K,S);r=Aw(b,_,H,v),s=b|0}({h:r,l:s}=At(this.Ah|0,this.Al|0,r|0,s|0)),{h:o,l:i}=At(this.Bh|0,this.Bl|0,o|0,i|0),{h:a,l:c}=At(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:f}=At(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:d}=At(this.Eh|0,this.El|0,l|0,d|0),{h,l:m}=At(this.Fh|0,this.Fl|0,h|0,m|0),{h:y,l:p}=At(this.Gh|0,this.Gl|0,y|0,p|0),{h:g,l:x}=At(this.Hh|0,this.Hl|0,g|0,x|0),this.set(r,s,o,i,a,c,u,f,l,d,h,m,y,p,g,x)}roundClean(){xt(Gt,Wt)}destroy(){xt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Qe=wa(()=>new Pw),Kr=wa(()=>new Lw),Rw=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),nl=Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)),Hw=nl.map(e=>(9*e+5)%16),rl=(()=>{const n=[[nl],[Hw]];for(let r=0;r<4;r++)for(let s of n)s.push(s[r].map(o=>Rw[o]));return n})(),sl=rl[0],ol=rl[1],il=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>Uint8Array.from(e)),jw=sl.map((e,t)=>e.map(n=>il[t][n])),Kw=ol.map((e,t)=>e.map(n=>il[t][n])),Dw=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),Zw=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function hc(e,t,n,r){return e===0?t^n^r:e===1?t&n|~t&r:e===2?(t|~n)^r:e===3?t&r|n&~r:t^(n|~r)}const cs=new Uint32Array(16);class Vw extends xa{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:n,h2:r,h3:s,h4:o}=this;return[t,n,r,s,o]}set(t,n,r,s,o){this.h0=t|0,this.h1=n|0,this.h2=r|0,this.h3=s|0,this.h4=o|0}process(t,n){for(let h=0;h<16;h++,n+=4)cs[h]=t.getUint32(n,!0);let r=this.h0|0,s=r,o=this.h1|0,i=o,a=this.h2|0,c=a,u=this.h3|0,f=u,l=this.h4|0,d=l;for(let h=0;h<5;h++){const m=4-h,y=Dw[h],p=Zw[h],g=sl[h],x=ol[h],w=jw[h],O=Kw[h];for(let A=0;A<16;A++){const T=ss(r+hc(h,o,a,u)+cs[g[A]]+y,w[A])+l|0;r=l,l=u,u=ss(a,10)|0,a=o,o=T}for(let A=0;A<16;A++){const T=ss(s+hc(m,i,c,f)+cs[x[A]]+p,O[A])+d|0;s=d,d=f,f=ss(c,10)|0,c=i,i=T}}this.set(this.h1+a+f|0,this.h2+u+d|0,this.h3+l+s|0,this.h4+r+i|0,this.h0+o+c|0)}roundClean(){xt(cs)}destroy(){this.destroyed=!0,xt(this.buffer),this.set(0,0,0,0,0)}}const al=wa(()=>new Vw);class cl extends el{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,Gr(t);const r=jr(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,o=new Uint8Array(s);o.set(r.length>s?t.create().update(r).digest():r);for(let i=0;inew cl(e,t).update(n).digest();un.create=(e,t)=>new cl(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const va=BigInt(0),vi=BigInt(1);function Tn(e,t=""){if(typeof e!="boolean"){const n=t&&`"${t}"`;throw new Error(n+"expected boolean, got type="+typeof e)}return e}function st(e,t,n=""){const r=Fr(e),s=e==null?void 0:e.length,o=t!==void 0;if(!r||o&&s!==t){const i=n&&`"${n}" `,a=o?` of length ${t}`:"",c=r?`length=${s}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+a+", got "+c)}return e}function us(e){const t=e.toString(16);return t.length&1?"0"+t:t}function ul(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?va:BigInt("0x"+e)}function ur(e){return ul(Le(e))}function Cn(e){return Ne(e),ul(Le(Uint8Array.from(e).reverse()))}function po(e,t){return ft(e.toString(16).padStart(t*2,"0"))}function Ea(e,t){return po(e,t).reverse()}function he(e,t,n){let r;if(typeof t=="string")try{r=ft(t)}catch(o){throw new Error(e+" must be hex string or Uint8Array, cause: "+o)}else if(Fr(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(e+" of length "+n+" expected, got "+s);return r}function pc(e){return Uint8Array.from(e)}const Ho=e=>typeof e=="bigint"&&va<=e;function Ei(e,t,n){return Ho(e)&&Ho(t)&&Ho(n)&&t<=e&&eva;e>>=vi,t+=1);return t}const Wr=e=>(vi<new Uint8Array(h),s=h=>Uint8Array.of(h);let o=r(e),i=r(e),a=0;const c=()=>{o.fill(1),i.fill(0),a=0},u=(...h)=>n(i,o,...h),f=(h=r(0))=>{i=u(s(0),h),o=u(),h.length!==0&&(i=u(s(1),h),o=u())},l=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const m=[];for(;h{c(),f(h);let y;for(;!(y=m(l()));)f();return c(),y}}function fr(e,t,n={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function r(s,o,i){const a=e[s];if(i&&a===void 0)return;const c=typeof a;if(c!==o||a===null)throw new Error(`param "${s}" is invalid: expected ${o}, got ${c}`)}Object.entries(t).forEach(([s,o])=>r(s,o,!1)),Object.entries(n).forEach(([s,o])=>r(s,o,!0))}function qs(e){const t=new WeakMap;return(n,...r)=>{const s=t.get(n);if(s!==void 0)return s;const o=e(n,...r);return t.set(n,o),o}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const qe=BigInt(0),Ie=BigInt(1),bn=BigInt(2),ll=BigInt(3),dl=BigInt(4),hl=BigInt(5),qw=BigInt(7),pl=BigInt(8),zw=BigInt(9),gl=BigInt(16);function ye(e,t){const n=e%t;return n>=qe?n:t+n}function xe(e,t,n){let r=e;for(;t-- >qe;)r*=r,r%=n;return r}function gc(e,t){if(e===qe)throw new Error("invert: expected non-zero number");if(t<=qe)throw new Error("invert: expected positive modulus, got "+t);let n=ye(e,t),r=t,s=qe,o=Ie;for(;n!==qe;){const a=r/n,c=r%n,u=s-o*a;r=n,n=c,s=o,o=u}if(r!==Ie)throw new Error("invert: does not exist");return ye(s,t)}function Sa(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function ml(e,t){const n=(e.ORDER+Ie)/dl,r=e.pow(t,n);return Sa(e,r,t),r}function Fw(e,t){const n=(e.ORDER-hl)/pl,r=e.mul(t,bn),s=e.pow(r,n),o=e.mul(t,s),i=e.mul(e.mul(o,bn),s),a=e.mul(o,e.sub(i,e.ONE));return Sa(e,a,t),a}function Gw(e){const t=jn(e),n=yl(e),r=n(t,t.neg(t.ONE)),s=n(t,r),o=n(t,t.neg(r)),i=(e+qw)/gl;return(a,c)=>{let u=a.pow(c,i),f=a.mul(u,r);const l=a.mul(u,s),d=a.mul(u,o),h=a.eql(a.sqr(f),c),m=a.eql(a.sqr(l),c);u=a.cmov(u,f,h),f=a.cmov(d,l,m);const y=a.eql(a.sqr(f),c),p=a.cmov(u,f,y);return Sa(a,p,c),p}}function yl(e){if(e1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return ml;let o=s.pow(r,t);const i=(t+Ie)/bn;return function(c,u){if(c.is0(u))return u;if(mc(c,u)!==1)throw new Error("Cannot find square root");let f=n,l=c.mul(c.ONE,o),d=c.pow(u,t),h=c.pow(u,i);for(;!c.eql(d,c.ONE);){if(c.is0(d))return c.ZERO;let m=1,y=c.sqr(d);for(;!c.eql(y,c.ONE);)if(m++,y=c.sqr(y),m===f)throw new Error("Cannot find square root");const p=Ie<(ye(e,t)&Ie)===Ie,Xw=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Jw(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=Xw.reduce((r,s)=>(r[s]="function",r),t);return fr(e,n),e}function Qw(e,t,n){if(nqe;)n&Ie&&(r=e.mul(r,s)),s=e.sqr(s),n>>=Ie;return r}function bl(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),s=t.reduce((i,a,c)=>e.is0(a)?i:(r[c]=i,e.mul(i,a)),e.ONE),o=e.inv(s);return t.reduceRight((i,a,c)=>e.is0(a)?i:(r[c]=e.mul(i,r[c]),e.mul(i,a)),o),r}function mc(e,t){const n=(e.ORDER-Ie)/bn,r=e.pow(t,n),s=e.eql(r,e.ONE),o=e.eql(r,e.ZERO),i=e.eql(r,e.neg(e.ONE));if(!s&&!o&&!i)throw new Error("invalid Legendre symbol result");return s?1:o?0:-1}function wl(e,t){t!==void 0&&nn(t);const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function jn(e,t,n=!1,r={}){if(e<=qe)throw new Error("invalid field: expected ORDER > 0, got "+e);let s,o,i=!1,a;if(typeof t=="object"&&t!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const d=t;d.BITS&&(s=d.BITS),d.sqrt&&(o=d.sqrt),typeof d.isLE=="boolean"&&(n=d.isLE),typeof d.modFromBytes=="boolean"&&(i=d.modFromBytes),a=d.allowedLengths}else typeof t=="number"&&(s=t),r.sqrt&&(o=r.sqrt);const{nBitLength:c,nByteLength:u}=wl(e,s);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let f;const l=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:u,MASK:Wr(c),ZERO:qe,ONE:Ie,allowedLengths:a,create:d=>ye(d,e),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return qe<=d&&dd===qe,isValidNot0:d=>!l.is0(d)&&l.isValid(d),isOdd:d=>(d&Ie)===Ie,neg:d=>ye(-d,e),eql:(d,h)=>d===h,sqr:d=>ye(d*d,e),add:(d,h)=>ye(d+h,e),sub:(d,h)=>ye(d-h,e),mul:(d,h)=>ye(d*h,e),pow:(d,h)=>Qw(l,d,h),div:(d,h)=>ye(d*gc(h,e),e),sqrN:d=>d*d,addN:(d,h)=>d+h,subN:(d,h)=>d-h,mulN:(d,h)=>d*h,inv:d=>gc(d,e),sqrt:o||(d=>(f||(f=Ww(e)),f(l,d))),toBytes:d=>n?Ea(d,u):po(d,u),fromBytes:(d,h=!0)=>{if(a){if(!a.includes(d.length)||d.length>u)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+d.length);const y=new Uint8Array(u);y.set(d,n?0:y.length-d.length),d=y}if(d.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+d.length);let m=n?Cn(d):ur(d);if(i&&(m=ye(m,e)),!h&&!l.isValid(m))throw new Error("invalid field element: outside of range 0..ORDER");return m},invertBatch:d=>bl(l,d),cmov:(d,h,m)=>m?h:d});return Object.freeze(l)}function xl(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function vl(e){const t=xl(e);return t+Math.ceil(t/2)}function El(e,t,n=!1){const r=e.length,s=xl(t),o=vl(t);if(r<16||r1024)throw new Error("expected "+o+"-1024 bytes of input, got "+r);const i=n?Cn(e):ur(e),a=ye(i,t-Ie)+Ie;return n?Ea(a,s):po(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const sr=BigInt(0),wn=BigInt(1);function zs(e,t){const n=t.negate();return e?n:t}function xn(e,t){const n=bl(e.Fp,t.map(r=>r.Z));return t.map((r,s)=>e.fromAffine(r.toAffine(n[s])))}function Sl(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function jo(e,t){Sl(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1),s=2**e,o=Wr(e),i=BigInt(e);return{windows:n,windowSize:r,mask:o,maxNumber:s,shiftBy:i}}function yc(e,t,n){const{windowSize:r,mask:s,maxNumber:o,shiftBy:i}=n;let a=Number(e&s),c=e>>i;a>r&&(a-=o,c+=wn);const u=t*r,f=u+Math.abs(a)-1,l=a===0,d=a<0,h=t%2!==0;return{nextN:c,offset:f,isZero:l,isNeg:d,isNegF:h,offsetF:u}}function e1(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function t1(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}const Ko=new WeakMap,kl=new WeakMap;function Do(e){return kl.get(e)||1}function bc(e){if(e!==sr)throw new Error("invalid wNAF")}class _l{constructor(t,n){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=n}_unsafeLadder(t,n,r=this.ZERO){let s=t;for(;n>sr;)n&wn&&(r=r.add(s)),s=s.double(),n>>=wn;return r}precomputeWindow(t,n){const{windows:r,windowSize:s}=jo(n,this.bits),o=[];let i=t,a=i;for(let c=0;csr||r>sr;)n&wn&&(o=o.add(s)),r&wn&&(i=i.add(s)),s=s.double(),n>>=wn,r>>=wn;return{p1:o,p2:i}}function $l(e,t,n,r){e1(n,e),t1(r,t);const s=n.length,o=r.length;if(s!==o)throw new Error("arrays of points and scalars must have equal length");const i=e.ZERO,a=fl(BigInt(s));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const u=Wr(c),f=new Array(Number(u)+1).fill(i),l=Math.floor((t.BITS-1)/c)*c;let d=i;for(let h=l;h>=0;h-=c){f.fill(i);for(let y=0;y>BigInt(h)&u);f[g]=f[g].add(n[y])}let m=i;for(let y=f.length-1,p=i;y>0;y--)p=p.add(f[y]),m=m.add(p);if(d=d.add(m),h!==0)for(let y=0;ysr))throw new Error(`CURVE.${c} must be positive bigint`)}const s=wc(t.p,n.Fp,r),o=wc(t.n,n.Fn,r),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(const c of a)if(!s.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:s,Fn:o}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const xc=(e,t)=>(e+(e>=0?t:-t)/Bl)/t;function r1(e,t,n){const[[r,s],[o,i]]=t,a=xc(i*e,n),c=xc(-s*e,n);let u=e-a*r-c*o,f=-a*s-c*i;const l=u=h||f=h)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:l,k1:u,k2neg:d,k2:f}}function Si(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Zo(e,t){const n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return Tn(n.lowS,"lowS"),Tn(n.prehash,"prehash"),n.format!==void 0&&Si(n.format),n}class s1 extends Error{constructor(t=""){super(t)}}const Ot={Err:s1,_tlv:{encode:(e,t)=>{const{Err:n}=Ot;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const r=t.length/2,s=us(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const o=r>127?us(s.length/2|128):"";return us(e)+o+s+t},decode(e,t){const{Err:n}=Ot;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const s=t[r++],o=!!(s&128);let i=0;if(!o)i=s;else{const c=s&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");const u=t.subarray(r,r+c);if(u.length!==c)throw new n("tlv.decode: length bytes not complete");if(u[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const f of u)i=i<<8|f;if(r+=c,i<128)throw new n("tlv.decode(long): not minimal encoding")}const a=t.subarray(r,r+i);if(a.length!==i)throw new n("tlv.decode: wrong value length");return{v:a,l:t.subarray(r+i)}}},_int:{encode(e){const{Err:t}=Ot;if(e{const{X:S,Y:b,Z:k}=K;if(r.eql(k,r.ONE))return{x:S,y:b};const B=K.is0();v==null&&(v=B?r.ONE:r.inv(k));const L=r.mul(S,v),P=r.mul(b,v),j=r.mul(k,v);if(B)return{x:r.ZERO,y:r.ZERO};if(!r.eql(j,r.ONE))throw new Error("invZ was invalid");return{x:L,y:P}}),U=qs(K=>{if(K.is0()){if(t.allowInfinityPoint&&!r.is0(K.Y))return;throw new Error("bad point: ZERO")}const{x:v,y:S}=K.toAffine();if(!r.isValid(v)||!r.isValid(S))throw new Error("bad point: x or y not field elements");if(!p(v,S))throw new Error("bad point: equation left != right");if(!K.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function C(K,v,S,b,k){return S=new _(r.mul(S.X,K),S.Y,S.Z),v=zs(b,v),S=zs(k,S),v.add(S)}class _{constructor(v,S,b){this.X=w("x",v),this.Y=w("y",S,!0),this.Z=w("z",b),Object.freeze(this)}static CURVE(){return o}static fromAffine(v){const{x:S,y:b}=v||{};if(!v||!r.isValid(S)||!r.isValid(b))throw new Error("invalid affine point");if(v instanceof _)throw new Error("projective point not allowed");return r.is0(S)&&r.is0(b)?_.ZERO:new _(S,b,r.ONE)}static fromBytes(v){const S=_.fromAffine(m(st(v,void 0,"point")));return S.assertValidity(),S}static fromHex(v){return _.fromBytes(he("pointHex",v))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(v=8,S=!0){return H.createCache(this,v),S||this.multiply(fs),this}assertValidity(){U(this)}hasEvenY(){const{y:v}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(v)}equals(v){O(v);const{X:S,Y:b,Z:k}=this,{X:B,Y:L,Z:P}=v,j=r.eql(r.mul(S,P),r.mul(B,k)),D=r.eql(r.mul(b,P),r.mul(L,k));return j&&D}negate(){return new _(this.X,r.neg(this.Y),this.Z)}double(){const{a:v,b:S}=o,b=r.mul(S,fs),{X:k,Y:B,Z:L}=this;let P=r.ZERO,j=r.ZERO,D=r.ZERO,q=r.mul(k,k),oe=r.mul(B,B),re=r.mul(L,L),Y=r.mul(k,B);return Y=r.add(Y,Y),D=r.mul(k,L),D=r.add(D,D),P=r.mul(v,D),j=r.mul(b,re),j=r.add(P,j),P=r.sub(oe,j),j=r.add(oe,j),j=r.mul(P,j),P=r.mul(Y,P),D=r.mul(b,D),re=r.mul(v,re),Y=r.sub(q,re),Y=r.mul(v,Y),Y=r.add(Y,D),D=r.add(q,q),q=r.add(D,q),q=r.add(q,re),q=r.mul(q,Y),j=r.add(j,q),re=r.mul(B,L),re=r.add(re,re),q=r.mul(re,Y),P=r.sub(P,q),D=r.mul(re,oe),D=r.add(D,D),D=r.add(D,D),new _(P,j,D)}add(v){O(v);const{X:S,Y:b,Z:k}=this,{X:B,Y:L,Z:P}=v;let j=r.ZERO,D=r.ZERO,q=r.ZERO;const oe=o.a,re=r.mul(o.b,fs);let Y=r.mul(S,B),ce=r.mul(b,L),ue=r.mul(k,P),ke=r.add(S,b),ie=r.add(B,L);ke=r.mul(ke,ie),ie=r.add(Y,ce),ke=r.sub(ke,ie),ie=r.add(S,k);let ge=r.add(B,P);return ie=r.mul(ie,ge),ge=r.add(Y,ue),ie=r.sub(ie,ge),ge=r.add(b,k),j=r.add(L,P),ge=r.mul(ge,j),j=r.add(ce,ue),ge=r.sub(ge,j),q=r.mul(oe,ie),j=r.mul(re,ue),q=r.add(j,q),j=r.sub(ce,q),q=r.add(ce,q),D=r.mul(j,q),ce=r.add(Y,Y),ce=r.add(ce,Y),ue=r.mul(oe,ue),ie=r.mul(re,ie),ce=r.add(ce,ue),ue=r.sub(Y,ue),ue=r.mul(oe,ue),ie=r.add(ie,ue),Y=r.mul(ce,ie),D=r.add(D,Y),Y=r.mul(ge,ie),j=r.mul(ke,j),j=r.sub(j,Y),Y=r.mul(ke,ce),q=r.mul(ge,q),q=r.add(q,Y),new _(j,D,q)}subtract(v){return this.add(v.negate())}is0(){return this.equals(_.ZERO)}multiply(v){const{endo:S}=t;if(!s.isValidNot0(v))throw new Error("invalid scalar: out of range");let b,k;const B=L=>H.cached(this,L,P=>xn(_,P));if(S){const{k1neg:L,k1:P,k2neg:j,k2:D}=A(v),{p:q,f:oe}=B(P),{p:re,f:Y}=B(D);k=oe.add(Y),b=C(S.beta,q,re,L,j)}else{const{p:L,f:P}=B(v);b=L,k=P}return xn(_,[b,k])[0]}multiplyUnsafe(v){const{endo:S}=t,b=this;if(!s.isValid(v))throw new Error("invalid scalar: out of range");if(v===It||b.is0())return _.ZERO;if(v===Yn)return b;if(H.hasCache(this))return this.multiply(v);if(S){const{k1neg:k,k1:B,k2neg:L,k2:P}=A(v),{p1:j,p2:D}=n1(_,b,B,P);return C(S.beta,j,D,k,L)}else return H.unsafe(b,v)}multiplyAndAddUnsafe(v,S,b){const k=this.multiplyUnsafe(S).add(v.multiplyUnsafe(b));return k.is0()?void 0:k}toAffine(v){return T(this,v)}isTorsionFree(){const{isTorsionFree:v}=t;return i===Yn?!0:v?v(_,this):H.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:v}=t;return i===Yn?this:v?v(_,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(v=!0){return Tn(v,"isCompressed"),this.assertValidity(),h(_,this,v)}toHex(v=!0){return Le(this.toBytes(v))}toString(){return``}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(v=!0){return this.toBytes(v)}_setWindowSize(v){this.precompute(v)}static normalizeZ(v){return xn(_,v)}static msm(v,S){return $l(_,s,v,S)}static fromPrivateKey(v){return _.BASE.multiply(vn(s,v))}}_.BASE=new _(o.Gx,o.Gy,r.ONE),_.ZERO=new _(r.ZERO,r.ONE,r.ZERO),_.Fp=r,_.Fn=s;const N=s.BITS,H=new _l(_,t.endo?Math.ceil(N/2):N);return _.BASE.precompute(8),_}function Ol(e){return Uint8Array.of(e?2:3)}function Il(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function a1(e,t={}){const{Fn:n}=e,r=t.randomBytes||Hn,s=Object.assign(Il(e.Fp,n),{seed:vl(n.ORDER)});function o(h){try{return!!vn(n,h)}catch{return!1}}function i(h,m){const{publicKey:y,publicKeyUncompressed:p}=s;try{const g=h.length;return m===!0&&g!==y||m===!1&&g!==p?!1:!!e.fromBytes(h)}catch{return!1}}function a(h=r(s.seed)){return El(st(h,s.seed,"seed"),n.ORDER)}function c(h,m=!0){return e.BASE.multiply(vn(n,h)).toBytes(m)}function u(h){const m=a(h);return{secretKey:m,publicKey:c(m)}}function f(h){if(typeof h=="bigint")return!1;if(h instanceof e)return!0;const{secretKey:m,publicKey:y,publicKeyUncompressed:p}=s;if(n.allowedLengths||m===y)return;const g=he("key",h).length;return g===y||g===p}function l(h,m,y=!0){if(f(h)===!0)throw new Error("first arg must be private key");if(f(m)===!1)throw new Error("second arg must be public key");const p=vn(n,h);return e.fromHex(m).multiply(p).toBytes(y)}return Object.freeze({getPublicKey:c,getSharedSecret:l,keygen:u,Point:e,utils:{isValidSecretKey:o,isValidPublicKey:i,randomSecretKey:a,isValidPrivateKey:o,randomPrivateKey:a,normPrivateKeyToScalar:h=>vn(n,h),precompute(h=8,m=e.BASE){return m.precompute(h,!1)}},lengths:s})}function c1(e,t,n={}){Gr(t),fr(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||Hn,s=n.hmac||((S,...b)=>un(t,S,we(...b))),{Fp:o,Fn:i}=e,{ORDER:a,BITS:c}=i,{keygen:u,getPublicKey:f,getSharedSecret:l,utils:d,lengths:h}=a1(e,n),m={prehash:!1,lowS:typeof n.lowS=="boolean"?n.lowS:!1,format:void 0,extraEntropy:!1},y="compact";function p(S){const b=a>>Yn;return S>b}function g(S,b){if(!i.isValidNot0(b))throw new Error(`invalid signature ${S}: out of range 1..Point.Fn.ORDER`);return b}function x(S,b){Si(b);const k=h.signature,B=b==="compact"?k:b==="recovered"?k+1:void 0;return st(S,B,`${b} signature`)}class w{constructor(b,k,B){this.r=g("r",b),this.s=g("s",k),B!=null&&(this.recovery=B),Object.freeze(this)}static fromBytes(b,k=y){x(b,k);let B;if(k==="der"){const{r:D,s:q}=Ot.toSig(st(b));return new w(D,q)}k==="recovered"&&(B=b[0],k="compact",b=b.subarray(1));const L=i.BYTES,P=b.subarray(0,L),j=b.subarray(L,L*2);return new w(i.fromBytes(P),i.fromBytes(j),B)}static fromHex(b,k){return this.fromBytes(ft(b),k)}addRecoveryBit(b){return new w(this.r,this.s,b)}recoverPublicKey(b){const k=o.ORDER,{r:B,s:L,recovery:P}=this;if(P==null||![0,1,2,3].includes(P))throw new Error("recovery id invalid");if(a*Bl1)throw new Error("recovery id is ambiguous for h>1 curve");const D=P===2||P===3?B+a:B;if(!o.isValid(D))throw new Error("recovery id 2 or 3 invalid");const q=o.toBytes(D),oe=e.fromBytes(we(Ol((P&1)===0),q)),re=i.inv(D),Y=A(he("msgHash",b)),ce=i.create(-Y*re),ue=i.create(L*re),ke=e.BASE.multiplyUnsafe(ce).add(oe.multiplyUnsafe(ue));if(ke.is0())throw new Error("point at infinify");return ke.assertValidity(),ke}hasHighS(){return p(this.s)}toBytes(b=y){if(Si(b),b==="der")return ft(Ot.hexFromSig(this));const k=i.toBytes(this.r),B=i.toBytes(this.s);if(b==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return we(Uint8Array.of(this.recovery),k,B)}return we(k,B)}toHex(b){return Le(this.toBytes(b))}assertValidity(){}static fromCompact(b){return w.fromBytes(he("sig",b),"compact")}static fromDER(b){return w.fromBytes(he("sig",b),"der")}normalizeS(){return this.hasHighS()?new w(this.r,i.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Le(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Le(this.toBytes("compact"))}}const O=n.bits2int||function(b){if(b.length>8192)throw new Error("input is too large");const k=ur(b),B=b.length*8-c;return B>0?k>>BigInt(B):k},A=n.bits2int_modN||function(b){return i.create(O(b))},T=Wr(c);function U(S){return Dr("num < 2^"+c,S,It,T),i.toBytes(S)}function C(S,b){return st(S,void 0,"message"),b?st(t(S),void 0,"prehashed message"):S}function _(S,b,k){if(["recovered","canonical"].some(ce=>ce in k))throw new Error("sign() legacy options not supported");const{lowS:B,prehash:L,extraEntropy:P}=Zo(k,m);S=C(S,L);const j=A(S),D=vn(i,b),q=[U(D),U(j)];if(P!=null&&P!==!1){const ce=P===!0?r(h.secretKey):P;q.push(he("extraEntropy",ce))}const oe=we(...q),re=j;function Y(ce){const ue=O(ce);if(!i.isValidNot0(ue))return;const ke=i.inv(ue),ie=e.BASE.multiply(ue).toAffine(),ge=i.create(ie.x);if(ge===It)return;const St=i.create(ke*i.create(re+ge*D));if(St===It)return;let We=(ie.x===ge?0:2)|Number(ie.y&Yn),Oe=St;return B&&p(St)&&(Oe=i.neg(St),We^=1),new w(ge,Oe,We)}return{seed:oe,k2sig:Y}}function N(S,b,k={}){S=he("message",S);const{seed:B,k2sig:L}=_(S,b,k);return Mw(t.outputLen,i.BYTES,s)(B,L)}function H(S){let b;const k=typeof S=="string"||Fr(S),B=!k&&S!==null&&typeof S=="object"&&typeof S.r=="bigint"&&typeof S.s=="bigint";if(!k&&!B)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(B)b=new w(S.r,S.s);else if(k){try{b=w.fromBytes(he("sig",S),"der")}catch(L){if(!(L instanceof Ot.Err))throw L}if(!b)try{b=w.fromBytes(he("sig",S),"compact")}catch{return!1}}return b||!1}function K(S,b,k,B={}){const{lowS:L,prehash:P,format:j}=Zo(B,m);if(k=he("publicKey",k),b=C(he("message",b),P),"strict"in B)throw new Error("options.strict was renamed to lowS");const D=j===void 0?H(S):w.fromBytes(he("sig",S),j);if(D===!1)return!1;try{const q=e.fromBytes(k);if(L&&D.hasHighS())return!1;const{r:oe,s:re}=D,Y=A(b),ce=i.inv(re),ue=i.create(Y*ce),ke=i.create(oe*ce),ie=e.BASE.multiplyUnsafe(ue).add(q.multiplyUnsafe(ke));return ie.is0()?!1:i.create(ie.x)===oe}catch{return!1}}function v(S,b,k={}){const{prehash:B}=Zo(k,m);return b=C(b,B),w.fromBytes(S,"recovered").recoverPublicKey(b).toBytes()}return Object.freeze({keygen:u,getPublicKey:f,getSharedSecret:l,utils:d,lengths:h,Point:e,sign:N,verify:K,recoverPublicKey:v,Signature:w,hash:t})}function u1(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(i=>Math.ceil(i/2)))):void 0;const s=jn(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),o={Fp:n,Fn:s,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:o}}function f1(e){const{CURVE:t,curveOpts:n}=u1(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function l1(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,wl(n.Fn.ORDER,n.Fn.BITS))})}function d1(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:s}=f1(e),o=i1(t,n),i=c1(o,r,s);return l1(e,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function h1(e,t){const n=r=>d1({...e,hash:r});return{...n(t),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const or={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},p1={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},g1=BigInt(0),vc=BigInt(1),ki=BigInt(2);function m1(e){const t=or.p,n=BigInt(3),r=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,f=u*u*e%t,l=xe(f,n,t)*f%t,d=xe(l,n,t)*f%t,h=xe(d,ki,t)*u%t,m=xe(h,s,t)*h%t,y=xe(m,o,t)*m%t,p=xe(y,a,t)*y%t,g=xe(p,c,t)*p%t,x=xe(g,a,t)*y%t,w=xe(x,n,t)*f%t,O=xe(w,i,t)*m%t,A=xe(O,r,t)*u%t,T=xe(A,ki,t);if(!Fs.eql(Fs.sqr(T),e))throw new Error("Cannot find square root");return T}const Fs=jn(or.p,{sqrt:m1}),Ve=h1({...or,Fp:Fs,lowS:!0,endo:p1},Qe),Ec={};function Gs(e,...t){let n=Ec[e];if(n===void 0){const r=Qe(Ge(e));n=we(r,r),Ec[e]=n}return Qe(we(n,...t))}const ka=e=>e.toBytes(!0).slice(1),lr=Ve.Point,_a=e=>e%ki===g1;function _i(e){const{Fn:t,BASE:n}=lr,r=vn(t,e),s=n.multiply(r);return{scalar:_a(s.y)?r:t.neg(r),bytes:ka(s)}}function Tl(e){const t=Fs;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x ≥ p");const n=t.create(e*e),r=t.create(n*e+BigInt(7));let s=t.sqrt(r);_a(s)||(s=t.neg(s));const o=lr.fromAffine({x:e,y:s});return o.assertValidity(),o}const Sr=ur;function Cl(...e){return lr.Fn.create(Sr(Gs("BIP0340/challenge",...e)))}function Sc(e){return _i(e).bytes}function y1(e,t,n=Hn(32)){const{Fn:r}=lr,s=he("message",e),{bytes:o,scalar:i}=_i(t),a=he("auxRand",n,32),c=r.toBytes(i^Sr(Gs("BIP0340/aux",a))),u=Gs("BIP0340/nonce",c,o,s),{bytes:f,scalar:l}=_i(u),d=Cl(f,o,s),h=new Uint8Array(64);if(h.set(f,0),h.set(r.toBytes(r.create(l+d*i)),32),!Pl(h,s,o))throw new Error("sign: Invalid signature produced");return h}function Pl(e,t,n){const{Fn:r,BASE:s}=lr,o=he("signature",e,64),i=he("message",t),a=he("publicKey",n,32);try{const c=Tl(Sr(a)),u=Sr(o.subarray(0,32));if(!Ei(u,vc,or.p))return!1;const f=Sr(o.subarray(32,64));if(!Ei(f,vc,or.n))return!1;const l=Cl(r.toBytes(u),ka(c),i),d=s.multiplyUnsafe(f).add(c.multiplyUnsafe(r.neg(l))),{x:h,y:m}=d.toAffine();return!(d.is0()||!_a(m)||h!==u)}catch{return!1}}const Ul=(()=>{const n=(s=Hn(48))=>El(s,or.n);Ve.utils.randomSecretKey;function r(s){const o=n(s);return{secretKey:o,publicKey:Sc(o)}}return{keygen:r,getPublicKey:Sc,sign:y1,verify:Pl,Point:lr,utils:{randomSecretKey:n,randomPrivateKey:n,taggedHash:Gs,lift_x:Tl,pointToBytes:ka,numberToBytesBE:po,bytesToNumberBE:ur,mod:ye},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})(),Ws=Le,b1=ft,Qt="super-testnet-local-v0";class fn{constructor(t){if(!/^[0-9a-f]{64}$/.test(t)||!Ve.utils.isValidPrivateKey(t))throw new Error("Invalid test wallet key. Load a Super Testnet v0 backup.");this.kind="test-wallet",this.secret=t,this.pubkey=Ws(Ul.getPublicKey(t)),this.address=Ar.p2tr.fromPubKey(this.pubkey,"regtest"),this.script=["OP_1",this.pubkey]}static create(){return new fn(Ws(Ve.utils.randomPrivateKey()))}static load(t){if((t==null?void 0:t.network)!==Qt||(t==null?void 0:t.version)!==1||(t==null?void 0:t.kind)!=="test-wallet")throw new Error("Only Super Testnet v0 test-wallet backups are accepted.");return new fn(t.secret)}backup(){return{kind:"test-wallet",version:1,network:Qt,secret:this.secret}}sign(t,n,r=0){return fo.taproot.sign(this.secret,t,r,n?{extension:n}:{}).hex}}const Vo=50*1e8,ls="0".repeat(64),kc=e=>Ws(Qe(new TextEncoder().encode(JSON.stringify(e)))),ds=(e,t)=>`${e}:${t}`,Ze=e=>Se.encode(e,!1).hex,le=(e,t)=>{if(!e)throw new Error(t)},w1=/^5120[0-9a-f]{64}$/,Mo=/^0014[0-9a-f]{40}$/,x1=e=>Ws(al(Qe(b1(e))));function v1(e,t){const[n,r]=e.vin[t].witness;return Ve.verify(n.slice(0,-2),fo.segwit.hash(e,t,{pubkey:r,sigflag:1}),r,{lowS:!0,format:"der"})}class go{constructor(t){if(this.blocks=[],this.mempool=[],this.utxos=new Map,this.transactions=new Map,t){le(t.network===Qt&&t.version===1,"Unsupported local chain version/network."),le(Array.isArray(t.blocks)&&Array.isArray(t.mempool),"Invalid chain snapshot.");for(const n of t.blocks)this.acceptBlock(structuredClone(n));this.submitPackage(t.mempool)}}snapshot(){return{network:Qt,version:1,blocks:structuredClone(this.blocks),mempool:[...this.mempool]}}coins(t){return[...this.utxos.values()].filter(n=>Ze(n.scriptPubKey)===Ze(t))}satLocation(t){for(const n of this.utxos.values()){const r=ys(n.ranges,t);if(r!==null)return{txid:n.txid,vout:n.vout,offset:r}}return null}balance(t){return this.coins(t).reduce((n,r)=>n+r.value,0)}apply(t,n,r=!1){var h,m,y;le(typeof t=="string"&&t.length<4e4&&/^(?:[a-f0-9]{2})+$/.test(t),"Invalid raw transaction.");const s=ae.decode(t),o=ae.util.getTxid(s);le(!this.transactions.has(o),"Duplicate transaction."),le(s.version===2&&s.locktime===0,"Unsupported transaction version or locktime."),le((s.vin.length===1||!r&&s.vin.length===2)&&s.vout.length>=1&&s.vout.length<=2,"Unsupported transaction shape.");let i=0;for(const p of s.vout){const g=Number(p.value);le(Number.isSafeInteger(g)&&g>=330&&g<=Vo,"Invalid output amount.");const x=Ze(p.scriptPubKey);le(w1.test(x)||Mo.test(x),"Only Taproot and P2WPKH outputs are supported."),i+=g}let a,c=[];const u=s.vin.findIndex(p=>{var g;return((g=p.witness)==null?void 0:g.length)===3}),f=s.vin[u<0?0:u];if(r)le(f.txid===ls&&f.vout===4294967295&&s.vout.length===1&&i===Vo,"Invalid local coinbase."),le(Ze(f.scriptSig)===Se.encode([new TextEncoder().encode(`${Qt}:${n}`)],!1).hex,"Wrong coinbase height."),le(!((h=f.witness)!=null&&h.length),"Unexpected coinbase witness.");else{c=s.vin.map(g=>this.utxos.get(ds(g.txid,g.vout))),le(c.every(Boolean),"Input is missing or already spent."),le(new Set(s.vin.map(g=>ds(g.txid,g.vout))).size===s.vin.length,"Duplicate input."),s.vin.forEach((g,x)=>{var O,A,T;le(g.sequence==="ffffffff"&&Ze(g.scriptSig)==="","Unsupported input flags."),g.prevout={value:c[x].value,scriptPubKey:c[x].scriptPubKey};const w=Ze(c[x].scriptPubKey);if(Mo.test(w)){const[U,C]=g.witness??[];le(x!==u&&((O=g.witness)==null?void 0:O.length)===2,"Unsupported witness."),le(/^30[0-9a-f]{12,140}01$/.test(U)&&/^0[23][0-9a-f]{64}$/.test(C)&&x1(C)===w.slice(4),"P2WPKH spends need a SIGHASH_ALL signature by the key they pay.");return}le(((A=g.witness)==null?void 0:A.length)===1||x===u&&((T=g.witness)==null?void 0:T.length)===3,"Unsupported witness."),le(/^[0-9a-f]{128}$/.test(g.witness[0]),"Only default 64-byte Schnorr signatures are accepted.")}),le(c.reduce((g,x)=>g+x.value,0)-i===be,"v0 requires a fixed 500 sat fee per transaction.");let p={};if(f.witness.length===3){const g=ga(f.witness),x=u;if(le(Number(s.vout[x].value)===Bt,"Invalid reveal postage."),le(Ze(s.vout[x].scriptPubKey)===`5120${g.pubkey}`,"Reveal must return to its signing wallet."),g.parent){const w=u===0?1:0,O=c[w];le((m=O==null?void 0:O.inscriptions)==null?void 0:m.some(A=>A.id===g.parent),"Referenced parent inscription must actually be spent."),le(s.vout.length===2&&Number(s.vout[w].value)===O.value&&Ze(O.scriptPubKey)===`5120${g.pubkey}`&&Ze(s.vout[w].scriptPubKey)===Ze(O.scriptPubKey),"Parent must be owned and preserved in the same wallet.")}else s.vin.length===2&&(le(u===1&&((y=c[0].inscriptions)==null?void 0:y.length)&&g.pointer!==void 0,"Reinscription spend requires correct tag and owned sat."),le(Number(s.vout[0].value)===c[0].value&&Ze(s.vout[0].scriptPubKey)===Ze(c[0].scriptPubKey)&&Ze(c[0].scriptPubKey)===`5120${g.pubkey}`,"Reinscription sat must be returned to owner."));p={pubkey:g.pubkey},a={id:`${o}i0`,txid:o,commitTxid:f.txid,text:g.text,bytes:Array.from(g.bytes),contentType:g.contentType,parent:g.parent,delegate:g.delegate,pointer:g.pointer,metaprotocol:g.metaprotocol,metadata:g.metadata,height:n,value:Bt}}s.vin.forEach((g,x)=>{let w=!1;try{w=Mo.test(Ze(c[x].scriptPubKey))?v1(s,x):fo.taproot.verify(s,x,x===u?p:{})}catch{}le(w,"Invalid signature or Taproot commitment.")})}const l=Dc(s,c,n,r),d=c.flatMap(p=>p.inscriptions??[]);if(a){const p=BigInt(a.pointer??0),g=p{var w;return((w=x.inscription)==null?void 0:w.sat)===a.sat}).length,d.push(a)}return le(d.every(p=>l.some(g=>ys(g,p.sat)!==null)),"Local lab protects inscription sats from fee loss."),r||s.vin.forEach(p=>this.utxos.delete(ds(p.txid,p.vout))),s.vout.forEach((p,g)=>{const x=d.filter(w=>ys(l[g],w.sat)!==null);this.utxos.set(ds(o,g),{txid:o,vout:g,value:Number(p.value),scriptPubKey:p.scriptPubKey,height:n,ranges:l[g],inscriptions:x,...x.length?{inscription:x[0]}:{}})}),this.transactions.set(o,{txid:o,raw:t,height:n,coinbase:r,tx:s,...a?{inscription:a}:{}}),o}submitPackage(t){le(Array.isArray(t)&&this.mempool.length+t.length<=1e3,"Invalid package or mempool full; mine a block first.");const n=new Map(this.utxos),r=new Map(this.transactions);try{t.forEach(s=>this.apply(s,null))}catch(s){throw this.utxos=n,this.transactions=r,s}this.mempool.push(...t)}acceptBlock(t){var i;le(t.height===this.blocks.length+1&&t.previous===(((i=this.blocks.at(-1))==null?void 0:i.hash)??ls),"Invalid block ancestry."),le(Number.isSafeInteger(t.time)&&t.time>0&&Array.isArray(t.raws)&&t.raws.length>0&&t.raws.length<=1001,"Invalid block.");const{hash:n,...r}=t;le(kc(r)===n,"Invalid local block hash.");const s=new Map(this.utxos),o=new Map(this.transactions);try{t.raws.forEach((a,c)=>this.apply(a,t.height,c===0))}catch(a){throw this.utxos=s,this.transactions=o,a}this.blocks.push(t)}mine(t){var a;const n=new go({...this.snapshot(),mempool:[]}),r=this.blocks.length+1,s=ae.create({vin:[{txid:ls,vout:4294967295,scriptSig:[new TextEncoder().encode(`${Qt}:${r}`)]}],vout:[Me(Vo,t)]}),o={height:r,previous:((a=this.blocks.at(-1))==null?void 0:a.hash)??ls,time:Date.now(),raws:[ae.encode(s).hex,...this.mempool]},i={...o,hash:kc(o)};return n.acceptBlock(i),Object.assign(this,n),i}}/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ir(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function E1(e,...t){if(!ir(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Nl(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function Ll(e){if(typeof e!="function")throw new Error("function expected");return!0}function Pn(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function dr(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Ys(e){if(!Array.isArray(e))throw new Error("array expected")}function Xs(e,t){if(!Nl(!0,t))throw new Error(`${e}: array of strings expected`)}function $a(e,t){if(!Nl(!1,t))throw new Error(`${e}: array of numbers expected`)}function Yr(...e){const t=o=>o,n=(o,i)=>a=>o(i(a)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function mo(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Xs("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(Ys(s),s.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:s=>(Ys(s),s.map(o=>{Pn("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function yo(e=""){return Pn("join",e),{encode:t=>(Xs("join.decode",t),t.join(e)),decode:t=>(Pn("join.decode",t),t.split(e))}}function Rl(e,t="="){return dr(e),Pn("padding",t),{encode(n){for(Xs("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){Xs("padding.decode",n);let r=n.length;if(r*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if((r-1)*e%8===0)throw new Error("padding: invalid, string has too much padding");return n.slice(0,r)}}}function $i(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(Ys(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,a=>{if(dr(a),a<0||a>=t)throw new Error(`invalid integer: ${a}`);return a}),i=o.length;for(;;){let a=0,c=!0;for(let u=r;ut===0?e:Hl(t,e%t),Js=(e,t)=>e+(t-Hl(e,t)),vs=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Qs(e,t,n,r){if(Ys(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Js(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Js(t,n)}`);let s=0,o=0;const i=vs[t],a=vs[n]-1,c=[];for(const u of e){if(dr(u),u>=i)throw new Error(`convertRadix2: invalid data word=${u} from=${t}`);if(s=s<32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=n;o-=n)c.push((s>>o-n&a)>>>0);const f=vs[o];if(f===void 0)throw new Error("invalid carry");s&=f-1}if(s=s<=t)throw new Error("Excess padding");if(!r&&s>0)throw new Error(`Non-zero padding: ${s}`);return r&&o>0&&c.push(s>>>0),c}function jl(e){dr(e);const t=2**8;return{encode:n=>{if(!ir(n))throw new Error("radix.encode input should be Uint8Array");return $i(Array.from(n),t,e)},decode:n=>($a("radix.decode",n),Uint8Array.from($i(n,e,t)))}}function Aa(e,t=!1){if(dr(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Js(8,e)>32||Js(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!ir(n))throw new Error("radix2.encode input should be Uint8Array");return Qs(Array.from(n),8,e,!t)},decode:n=>($a("radix2.decode",n),Uint8Array.from(Qs(n,e,8,t)))}}function _c(e){return Ll(e),function(...t){try{return e.apply(null,t)}catch{}}}function Kl(e,t){return dr(e),Ll(t),{encode(n){if(!ir(n))throw new Error("checksum.encode: input should be Uint8Array");const r=t(n).slice(0,e),s=new Uint8Array(n.length+e);return s.set(n),s.set(r,n.length),s},decode(n){if(!ir(n))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-e),s=n.slice(-e),o=t(r).slice(0,e);for(let i=0;i{Pn("base64",e);const n=/^[A-Za-z0-9=+/]+$/,r="base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},mt=S1?{encode(e){return E1(e),e.toBase64()},decode(e){return k1(e)}}:Yr(Aa(6),mo("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Rl(6),yo("")),_1=e=>Yr(jl(58),mo(e),yo("")),$1=_1("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Dl=e=>Yr(Kl(4,t=>e(e(t))),$1),Ai=Yr(mo("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),yo("")),$c=[996825010,642813549,513874426,1027748829,705979059];function wr(e){const t=e>>25;let n=(e&33554431)<<5;for(let r=0;r<$c.length;r++)(t>>r&1)===1&&(n^=$c[r]);return n}function Ac(e,t,n=1){const r=e.length;let s=1;for(let o=0;o126)throw new Error(`Invalid prefix (${e})`);s=wr(s)^i>>5}s=wr(s);for(let o=0;oh)throw new TypeError(`Length ${y} exceeds limit ${h}`);const p=l.toLowerCase(),g=Ac(p,d,t);return`${p}1${Ai.encode(d)}${g}`}function a(l,d=90){Pn("bech32.decode input",l);const h=l.length;if(h<8||d!==!1&&h>d)throw new TypeError(`invalid string length: ${h} (${l}). Expected (8..${d})`);const m=l.toLowerCase();if(l!==m&&l!==l.toUpperCase())throw new Error("String must be lowercase or uppercase");const y=m.lastIndexOf("1");if(y===0||y===-1)throw new Error('Letter "1" must be present between prefix and data only');const p=m.slice(0,y),g=m.slice(y+1);if(g.length<6)throw new Error("Data must be at least 6 characters long");const x=Ai.decode(g).slice(0,-6),w=Ac(p,x,t);if(!g.endsWith(w))throw new Error(`Invalid checksum in ${l}: expected "${w}"`);return{prefix:p,words:x}}const c=_c(a);function u(l){const{prefix:d,words:h}=a(l,!1);return{prefix:d,words:h,bytes:r(h)}}function f(l,d){return i(l,s(d))}return{encode:i,decode:a,encodeFromBytes:f,decodeToBytes:u,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:o,toWords:s}}const eo=A1("bech32");/*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */const ps=Ve.ProjectivePoint,qo=Dl(Qe);function Bc(e){Ne(e);const t=e.length===0?"0":Le(e);return BigInt("0x"+t)}function B1(e){if(typeof e!="bigint")throw new Error("bigint expected");return ft(e.toString(16).padStart(64,"0"))}const O1=Ge("Bitcoin seed"),zo={private:76066276,public:76067358},Fo=2147483648,I1=e=>al(Qe(e)),T1=e=>kn(e).getUint32(0,!1),gs=e=>{if(!Number.isSafeInteger(e)||e<0||e>2**32-1)throw new Error("invalid number, should be from 0 to 2**32-1, got "+e);const t=new Uint8Array(4);return kn(t).setUint32(0,e,!1),t};class pn{get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return T1(this.pubHash)}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this.privKeyBytes||null}get publicKey(){return this.pubKey||null}get privateExtendedKey(){const t=this.privateKey;if(!t)throw new Error("No private key");return qo.encode(this.serialize(this.versions.private,we(new Uint8Array([0]),t)))}get publicExtendedKey(){if(!this.pubKey)throw new Error("No public key");return qo.encode(this.serialize(this.versions.public,this.pubKey))}static fromMasterSeed(t,n=zo){if(Ne(t),8*t.length<128||8*t.length>512)throw new Error("HDKey: seed length must be between 128 and 512 bits; 256 bits is advised, got "+t.length);const r=un(Kr,O1,t);return new pn({versions:n,chainCode:r.slice(32),privateKey:r.slice(0,32)})}static fromExtendedKey(t,n=zo){const r=qo.decode(t),s=kn(r),o=s.getUint32(0,!1),i={versions:n,depth:r[4],parentFingerprint:s.getUint32(5,!1),index:s.getUint32(9,!1),chainCode:r.slice(13,45)},a=r.slice(45),c=a[0]===0;if(o!==n[c?"private":"public"])throw new Error("Version mismatch");return c?new pn({...i,privateKey:a.slice(1)}):new pn({...i,publicKey:a})}static fromJSON(t){return pn.fromExtendedKey(t.xpriv)}constructor(t){if(this.depth=0,this.index=0,this.chainCode=null,this.parentFingerprint=0,!t||typeof t!="object")throw new Error("HDKey.constructor must not be called directly");if(this.versions=t.versions||zo,this.depth=t.depth||0,this.chainCode=t.chainCode||null,this.index=t.index||0,this.parentFingerprint=t.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(t.publicKey&&t.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(t.privateKey){if(!Ve.utils.isValidPrivateKey(t.privateKey))throw new Error("Invalid private key");this.privKey=typeof t.privateKey=="bigint"?t.privateKey:Bc(t.privateKey),this.privKeyBytes=B1(this.privKey),this.pubKey=Ve.getPublicKey(t.privateKey,!0)}else if(t.publicKey)this.pubKey=ps.fromHex(t.publicKey).toRawBytes(!0);else throw new Error("HDKey: no public or private key provided");this.pubHash=I1(this.pubKey)}derive(t){if(!/^[mM]'?/.test(t))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(t))return this;const n=t.replace(/^[mM]'?\//,"").split("/");let r=this;for(const s of n){const o=/^(\d+)('?)$/.exec(s),i=o&&o[1];if(!o||o.length!==3||typeof i!="string")throw new Error("invalid child index: "+s);let a=+i;if(!Number.isSafeInteger(a)||a>=Fo)throw new Error("Invalid index");o[2]==="'"&&(a+=Fo),r=r.deriveChild(a)}return r}deriveChild(t){if(!this.pubKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let n=gs(t);if(t>=Fo){const a=this.privateKey;if(!a)throw new Error("Could not derive hardened child key");n=we(new Uint8Array([0]),a,n)}else n=we(this.pubKey,n);const r=un(Kr,this.chainCode,n),s=Bc(r.slice(0,32)),o=r.slice(32);if(!Ve.utils.isValidPrivateKey(s))throw new Error("Tweak bigger than curve order");const i={versions:this.versions,chainCode:o,depth:this.depth+1,parentFingerprint:this.fingerprint,index:t};try{if(this.privateKey){const a=ye(this.privKey+s,Ve.CURVE.n);if(!Ve.utils.isValidPrivateKey(a))throw new Error("The tweak was out of range or the resulted private key is invalid");i.privateKey=a}else{const a=ps.fromHex(this.pubKey).add(ps.fromPrivateKey(s));if(a.equals(ps.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");i.publicKey=a.toRawBytes(!0)}return new pn(i)}catch{return this.deriveChild(t+1)}}sign(t){if(!this.privateKey)throw new Error("No privateKey set!");return Ne(t,32),Ve.sign(t,this.privKey).toCompactRawBytes()}verify(t,n){if(Ne(t,32),Ne(n,64),!this.publicKey)throw new Error("No publicKey set!");let r;try{r=Ve.Signature.fromCompact(n)}catch{return!1}return Ve.verify(r,t,this.publicKey)}wipePrivateData(){return this.privKey=void 0,this.privKeyBytes&&(this.privKeyBytes.fill(0),this.privKeyBytes=void 0),this}toJSON(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}}serialize(t,n){if(!this.chainCode)throw new Error("No chainCode set");return Ne(n,33),we(gs(t),new Uint8Array([this.depth]),gs(this.parentFingerprint),gs(this.index),this.chainCode,n)}}function C1(e,t,n,r){Gr(e);const s=xw({dkLen:32,asyncTick:10},r),{c:o,dkLen:i,asyncTick:a}=s;if(nn(o),nn(i),nn(a),o<1)throw new Error("iterations (c) should be >= 1");const c=uc(t),u=uc(n),f=new Uint8Array(i),l=un.create(e,c),d=l._cloneInto().update(u);return{c:o,dkLen:i,asyncTick:a,DK:f,PRF:l,PRFSalt:d}}function P1(e,t,n,r,s){return e.destroy(),t.destroy(),r&&r.destroy(),xt(s),n}function U1(e,t,n,r){const{c:s,dkLen:o,DK:i,PRF:a,PRFSalt:c}=C1(e,t,n,r);let u;const f=new Uint8Array(4),l=kn(f),d=new Uint8Array(a.outputLen);for(let h=1,m=0;me[0]==="あいこくしん";function Zl(e){if(typeof e!="string")throw new TypeError("invalid mnemonic type: "+typeof e);return e.normalize("NFKD")}function Vl(e){const t=Zl(e),n=t.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:n}}function Ml(e){Ne(e,16,20,24,28,32)}function L1(e,t=128){if(nn(t),t%32!==0||t>256)throw new TypeError("Invalid entropy");return zl(Hn(t/8),e)}const R1=e=>{const t=8-e.length/4;return new Uint8Array([Qe(e)[0]>>t<{if(typeof t!="string")throw new Error("wordlist: non-string element: "+t)}),hs.chain(hs.checksum(1,R1),hs.radix2(11,!0),hs.alphabet(e))}function H1(e,t){const{words:n}=Vl(e),r=ql(t).decode(n);return Ml(r),r}function zl(e,t){return Ml(e),ql(t).encode(e).join(N1(t)?" ":" ")}function j1(e,t){try{H1(e,t)}catch{return!1}return!0}const K1=e=>Zl("mnemonic"+e);function D1(e,t=""){return U1(Kr,Vl(e).nfkd,K1(t),{c:2048,dkLen:64})}const Ba=`abandon +ability +able +about +above +absent +absorb +abstract +absurd +abuse +access +accident +account +accuse +achieve +acid +acoustic +acquire +across +act +action +actor +actress +actual +adapt +add +addict +address +adjust +admit +adult +advance +advice +aerobic +affair +afford +afraid +again +age +agent +agree +ahead +aim +air +airport +aisle +alarm +album +alcohol +alert +alien +all +alley +allow +almost +alone +alpha +already +also +alter +always +amateur +amazing +among +amount +amused +analyst +anchor +ancient +anger +angle +angry +animal +ankle +announce +annual +another +answer +antenna +antique +anxiety +any +apart +apology +appear +apple +approve +april +arch +arctic +area +arena +argue +arm +armed +armor +army +around +arrange +arrest +arrive +arrow +art +artefact +artist +artwork +ask +aspect +assault +asset +assist +assume +asthma +athlete +atom +attack +attend +attitude +attract +auction +audit +august +aunt +author +auto +autumn +average +avocado +avoid +awake +aware +away +awesome +awful +awkward +axis +baby +bachelor +bacon +badge +bag +balance +balcony +ball +bamboo +banana +banner +bar +barely +bargain +barrel +base +basic +basket +battle +beach +bean +beauty +because +become +beef +before +begin +behave +behind +believe +below +belt +bench +benefit +best +betray +better +between +beyond +bicycle +bid +bike +bind +biology +bird +birth +bitter +black +blade +blame +blanket +blast +bleak +bless +blind +blood +blossom +blouse +blue +blur +blush +board +boat +body +boil +bomb +bone +bonus +book +boost +border +boring +borrow +boss +bottom +bounce +box +boy +bracket +brain +brand +brass +brave +bread +breeze +brick +bridge +brief +bright +bring +brisk +broccoli +broken +bronze +broom +brother +brown +brush +bubble +buddy +budget +buffalo +build +bulb +bulk +bullet +bundle +bunker +burden +burger +burst +bus +business +busy +butter +buyer +buzz +cabbage +cabin +cable +cactus +cage +cake +call +calm +camera +camp +can +canal +cancel +candy +cannon +canoe +canvas +canyon +capable +capital +captain +car +carbon +card +cargo +carpet +carry +cart +case +cash +casino +castle +casual +cat +catalog +catch +category +cattle +caught +cause +caution +cave +ceiling +celery +cement +census +century +cereal +certain +chair +chalk +champion +change +chaos +chapter +charge +chase +chat +cheap +check +cheese +chef +cherry +chest +chicken +chief +child +chimney +choice +choose +chronic +chuckle +chunk +churn +cigar +cinnamon +circle +citizen +city +civil +claim +clap +clarify +claw +clay +clean +clerk +clever +click +client +cliff +climb +clinic +clip +clock +clog +close +cloth +cloud +clown +club +clump +cluster +clutch +coach +coast +coconut +code +coffee +coil +coin +collect +color +column +combine +come +comfort +comic +common +company +concert +conduct +confirm +congress +connect +consider +control +convince +cook +cool +copper +copy +coral +core +corn +correct +cost +cotton +couch +country +couple +course +cousin +cover +coyote +crack +cradle +craft +cram +crane +crash +crater +crawl +crazy +cream +credit +creek +crew +cricket +crime +crisp +critic +crop +cross +crouch +crowd +crucial +cruel +cruise +crumble +crunch +crush +cry +crystal +cube +culture +cup +cupboard +curious +current +curtain +curve +cushion +custom +cute +cycle +dad +damage +damp +dance +danger +daring +dash +daughter +dawn +day +deal +debate +debris +decade +december +decide +decline +decorate +decrease +deer +defense +define +defy +degree +delay +deliver +demand +demise +denial +dentist +deny +depart +depend +deposit +depth +deputy +derive +describe +desert +design +desk +despair +destroy +detail +detect +develop +device +devote +diagram +dial +diamond +diary +dice +diesel +diet +differ +digital +dignity +dilemma +dinner +dinosaur +direct +dirt +disagree +discover +disease +dish +dismiss +disorder +display +distance +divert +divide +divorce +dizzy +doctor +document +dog +doll +dolphin +domain +donate +donkey +donor +door +dose +double +dove +draft +dragon +drama +drastic +draw +dream +dress +drift +drill +drink +drip +drive +drop +drum +dry +duck +dumb +dune +during +dust +dutch +duty +dwarf +dynamic +eager +eagle +early +earn +earth +easily +east +easy +echo +ecology +economy +edge +edit +educate +effort +egg +eight +either +elbow +elder +electric +elegant +element +elephant +elevator +elite +else +embark +embody +embrace +emerge +emotion +employ +empower +empty +enable +enact +end +endless +endorse +enemy +energy +enforce +engage +engine +enhance +enjoy +enlist +enough +enrich +enroll +ensure +enter +entire +entry +envelope +episode +equal +equip +era +erase +erode +erosion +error +erupt +escape +essay +essence +estate +eternal +ethics +evidence +evil +evoke +evolve +exact +example +excess +exchange +excite +exclude +excuse +execute +exercise +exhaust +exhibit +exile +exist +exit +exotic +expand +expect +expire +explain +expose +express +extend +extra +eye +eyebrow +fabric +face +faculty +fade +faint +faith +fall +false +fame +family +famous +fan +fancy +fantasy +farm +fashion +fat +fatal +father +fatigue +fault +favorite +feature +february +federal +fee +feed +feel +female +fence +festival +fetch +fever +few +fiber +fiction +field +figure +file +film +filter +final +find +fine +finger +finish +fire +firm +first +fiscal +fish +fit +fitness +fix +flag +flame +flash +flat +flavor +flee +flight +flip +float +flock +floor +flower +fluid +flush +fly +foam +focus +fog +foil +fold +follow +food +foot +force +forest +forget +fork +fortune +forum +forward +fossil +foster +found +fox +fragile +frame +frequent +fresh +friend +fringe +frog +front +frost +frown +frozen +fruit +fuel +fun +funny +furnace +fury +future +gadget +gain +galaxy +gallery +game +gap +garage +garbage +garden +garlic +garment +gas +gasp +gate +gather +gauge +gaze +general +genius +genre +gentle +genuine +gesture +ghost +giant +gift +giggle +ginger +giraffe +girl +give +glad +glance +glare +glass +glide +glimpse +globe +gloom +glory +glove +glow +glue +goat +goddess +gold +good +goose +gorilla +gospel +gossip +govern +gown +grab +grace +grain +grant +grape +grass +gravity +great +green +grid +grief +grit +grocery +group +grow +grunt +guard +guess +guide +guilt +guitar +gun +gym +habit +hair +half +hammer +hamster +hand +happy +harbor +hard +harsh +harvest +hat +have +hawk +hazard +head +health +heart +heavy +hedgehog +height +hello +helmet +help +hen +hero +hidden +high +hill +hint +hip +hire +history +hobby +hockey +hold +hole +holiday +hollow +home +honey +hood +hope +horn +horror +horse +hospital +host +hotel +hour +hover +hub +huge +human +humble +humor +hundred +hungry +hunt +hurdle +hurry +hurt +husband +hybrid +ice +icon +idea +identify +idle +ignore +ill +illegal +illness +image +imitate +immense +immune +impact +impose +improve +impulse +inch +include +income +increase +index +indicate +indoor +industry +infant +inflict +inform +inhale +inherit +initial +inject +injury +inmate +inner +innocent +input +inquiry +insane +insect +inside +inspire +install +intact +interest +into +invest +invite +involve +iron +island +isolate +issue +item +ivory +jacket +jaguar +jar +jazz +jealous +jeans +jelly +jewel +job +join +joke +journey +joy +judge +juice +jump +jungle +junior +junk +just +kangaroo +keen +keep +ketchup +key +kick +kid +kidney +kind +kingdom +kiss +kit +kitchen +kite +kitten +kiwi +knee +knife +knock +know +lab +label +labor +ladder +lady +lake +lamp +language +laptop +large +later +latin +laugh +laundry +lava +law +lawn +lawsuit +layer +lazy +leader +leaf +learn +leave +lecture +left +leg +legal +legend +leisure +lemon +lend +length +lens +leopard +lesson +letter +level +liar +liberty +library +license +life +lift +light +like +limb +limit +link +lion +liquid +list +little +live +lizard +load +loan +lobster +local +lock +logic +lonely +long +loop +lottery +loud +lounge +love +loyal +lucky +luggage +lumber +lunar +lunch +luxury +lyrics +machine +mad +magic +magnet +maid +mail +main +major +make +mammal +man +manage +mandate +mango +mansion +manual +maple +marble +march +margin +marine +market +marriage +mask +mass +master +match +material +math +matrix +matter +maximum +maze +meadow +mean +measure +meat +mechanic +medal +media +melody +melt +member +memory +mention +menu +mercy +merge +merit +merry +mesh +message +metal +method +middle +midnight +milk +million +mimic +mind +minimum +minor +minute +miracle +mirror +misery +miss +mistake +mix +mixed +mixture +mobile +model +modify +mom +moment +monitor +monkey +monster +month +moon +moral +more +morning +mosquito +mother +motion +motor +mountain +mouse +move +movie +much +muffin +mule +multiply +muscle +museum +mushroom +music +must +mutual +myself +mystery +myth +naive +name +napkin +narrow +nasty +nation +nature +near +neck +need +negative +neglect +neither +nephew +nerve +nest +net +network +neutral +never +news +next +nice +night +noble +noise +nominee +noodle +normal +north +nose +notable +note +nothing +notice +novel +now +nuclear +number +nurse +nut +oak +obey +object +oblige +obscure +observe +obtain +obvious +occur +ocean +october +odor +off +offer +office +often +oil +okay +old +olive +olympic +omit +once +one +onion +online +only +open +opera +opinion +oppose +option +orange +orbit +orchard +order +ordinary +organ +orient +original +orphan +ostrich +other +outdoor +outer +output +outside +oval +oven +over +own +owner +oxygen +oyster +ozone +pact +paddle +page +pair +palace +palm +panda +panel +panic +panther +paper +parade +parent +park +parrot +party +pass +patch +path +patient +patrol +pattern +pause +pave +payment +peace +peanut +pear +peasant +pelican +pen +penalty +pencil +people +pepper +perfect +permit +person +pet +phone +photo +phrase +physical +piano +picnic +picture +piece +pig +pigeon +pill +pilot +pink +pioneer +pipe +pistol +pitch +pizza +place +planet +plastic +plate +play +please +pledge +pluck +plug +plunge +poem +poet +point +polar +pole +police +pond +pony +pool +popular +portion +position +possible +post +potato +pottery +poverty +powder +power +practice +praise +predict +prefer +prepare +present +pretty +prevent +price +pride +primary +print +priority +prison +private +prize +problem +process +produce +profit +program +project +promote +proof +property +prosper +protect +proud +provide +public +pudding +pull +pulp +pulse +pumpkin +punch +pupil +puppy +purchase +purity +purpose +purse +push +put +puzzle +pyramid +quality +quantum +quarter +question +quick +quit +quiz +quote +rabbit +raccoon +race +rack +radar +radio +rail +rain +raise +rally +ramp +ranch +random +range +rapid +rare +rate +rather +raven +raw +razor +ready +real +reason +rebel +rebuild +recall +receive +recipe +record +recycle +reduce +reflect +reform +refuse +region +regret +regular +reject +relax +release +relief +rely +remain +remember +remind +remove +render +renew +rent +reopen +repair +repeat +replace +report +require +rescue +resemble +resist +resource +response +result +retire +retreat +return +reunion +reveal +review +reward +rhythm +rib +ribbon +rice +rich +ride +ridge +rifle +right +rigid +ring +riot +ripple +risk +ritual +rival +river +road +roast +robot +robust +rocket +romance +roof +rookie +room +rose +rotate +rough +round +route +royal +rubber +rude +rug +rule +run +runway +rural +sad +saddle +sadness +safe +sail +salad +salmon +salon +salt +salute +same +sample +sand +satisfy +satoshi +sauce +sausage +save +say +scale +scan +scare +scatter +scene +scheme +school +science +scissors +scorpion +scout +scrap +screen +script +scrub +sea +search +season +seat +second +secret +section +security +seed +seek +segment +select +sell +seminar +senior +sense +sentence +series +service +session +settle +setup +seven +shadow +shaft +shallow +share +shed +shell +sheriff +shield +shift +shine +ship +shiver +shock +shoe +shoot +shop +short +shoulder +shove +shrimp +shrug +shuffle +shy +sibling +sick +side +siege +sight +sign +silent +silk +silly +silver +similar +simple +since +sing +siren +sister +situate +six +size +skate +sketch +ski +skill +skin +skirt +skull +slab +slam +sleep +slender +slice +slide +slight +slim +slogan +slot +slow +slush +small +smart +smile +smoke +smooth +snack +snake +snap +sniff +snow +soap +soccer +social +sock +soda +soft +solar +soldier +solid +solution +solve +someone +song +soon +sorry +sort +soul +sound +soup +source +south +space +spare +spatial +spawn +speak +special +speed +spell +spend +sphere +spice +spider +spike +spin +spirit +split +spoil +sponsor +spoon +sport +spot +spray +spread +spring +spy +square +squeeze +squirrel +stable +stadium +staff +stage +stairs +stamp +stand +start +state +stay +steak +steel +stem +step +stereo +stick +still +sting +stock +stomach +stone +stool +story +stove +strategy +street +strike +strong +struggle +student +stuff +stumble +style +subject +submit +subway +success +such +sudden +suffer +sugar +suggest +suit +summer +sun +sunny +sunset +super +supply +supreme +sure +surface +surge +surprise +surround +survey +suspect +sustain +swallow +swamp +swap +swarm +swear +sweet +swift +swim +swing +switch +sword +symbol +symptom +syrup +system +table +tackle +tag +tail +talent +talk +tank +tape +target +task +taste +tattoo +taxi +teach +team +tell +ten +tenant +tennis +tent +term +test +text +thank +that +theme +then +theory +there +they +thing +this +thought +three +thrive +throw +thumb +thunder +ticket +tide +tiger +tilt +timber +time +tiny +tip +tired +tissue +title +toast +tobacco +today +toddler +toe +together +toilet +token +tomato +tomorrow +tone +tongue +tonight +tool +tooth +top +topic +topple +torch +tornado +tortoise +toss +total +tourist +toward +tower +town +toy +track +trade +traffic +tragic +train +transfer +trap +trash +travel +tray +treat +tree +trend +trial +tribe +trick +trigger +trim +trip +trophy +trouble +truck +true +truly +trumpet +trust +truth +try +tube +tuition +tumble +tuna +tunnel +turkey +turn +turtle +twelve +twenty +twice +twin +twist +two +type +typical +ugly +umbrella +unable +unaware +uncle +uncover +under +undo +unfair +unfold +unhappy +uniform +unique +unit +universe +unknown +unlock +until +unusual +unveil +update +upgrade +uphold +upon +upper +upset +urban +urge +usage +use +used +useful +useless +usual +utility +vacant +vacuum +vague +valid +valley +valve +van +vanish +vapor +various +vast +vault +vehicle +velvet +vendor +venture +venue +verb +verify +version +very +vessel +veteran +viable +vibrant +vicious +victory +video +view +village +vintage +violin +virtual +virus +visa +visit +visual +vital +vivid +vocal +voice +void +volcano +volume +vote +voyage +wage +wagon +wait +walk +wall +walnut +want +warfare +warm +warrior +wash +wasp +waste +water +wave +way +wealth +weapon +wear +weasel +weather +web +wedding +weekend +weird +welcome +west +wet +whale +what +wheat +wheel +when +where +whip +whisper +wide +width +wife +wild +will +win +window +wine +wing +wink +winner +winter +wire +wisdom +wise +wish +witness +wolf +woman +wonder +wood +wool +word +work +world +worry +worth +wrap +wreck +wrestle +wrist +write +wrong +yard +year +yellow +you +young +youth +zebra +zero +zone +zoo`.split(` +`),Je={orgSeed:e=>`m/83696968'/39'/0'/24'/${e}'`,wallet:(e,t=1)=>`m/86'/${t}'/${e}'/0/0`,segwit:(e,t=1)=>`m/84'/${t}'/${e}'/0/0`,nostr:e=>`m/44'/1237'/${e}'/0/0`},Z1=2**31-1,Go=new Map,Wo=new Map,Oc=()=>L1(Ba,256);function Fl(e,t=0){if(typeof e!="string"||!j1(e,Ba)||t&&e.split(" ").length!==t)throw new Error("Invalid lab mnemonic.");return e}function hr(e,t){if(!Number.isSafeInteger(e)||e<0||e>Z1)throw new Error(`Invalid ${t}.`);return e}const Yo=new Map;function Oa(e){return Yo.has(e)||Yo.set(e,D1(Fl(e))),Yo.get(e)}function pr(e){return Go.has(e)||Go.set(e,pn.fromMasterSeed(Oa(e))),Go.get(e)}function V1(e,t){const n=e.derive(t).privateKey;if(!n)throw new Error("BIP-85 path produced no private key.");return un(Kr,Ge("bip-entropy-from-k"),n)}function M1(e,t){const n=`${e}|${hr(t,"child index")}`;return Wo.has(n)||Wo.set(n,zl(V1(pr(e),Je.orgSeed(t)).slice(0,32),Ba)),Wo.get(n)}function Bi(e,t=0,n=1){return Le(pr(e).derive(Je.wallet(hr(t,"account"),n)).privateKey)}function Gl(e,t=0,n=1){return Le(pr(e).derive(Je.segwit(hr(t,"account"),n)).privateKey)}function Wl(e,t=0,n=1){return Le(pr(e).derive(Je.segwit(hr(t,"account"),n)).publicKey)}function Ia(e,t=0){return Le(pr(e).derive(Je.nostr(hr(t,"account"))).privateKey)}function q1(e,t=0){const n=Ul.getPublicKey(pr(e).derive(Je.nostr(hr(t,"account"))).privateKey);return{pubkey:Le(n),npub:eo.encode("npub",eo.toWords(n))}}const Yl="lineage-claim",Oi=330,to=e=>Se.encode(e,!1).hex,Ic=e=>({txid:e.txid,vout:e.vout,value:e.value,script:to(e.scriptPubKey)}),Xo=/^[0-9a-f]{64}$/,z1=/^5120[0-9a-f]{64}$/;function Ta(e,t){var n;for(const r of e.utxos.values())if((n=r.inscriptions)!=null&&n.some(s=>s.id===t))return r;return null}function Xl(e){return ae.create({vin:[tn(e.holder.txid,e.holder.vout,e.holder.value,e.holder.script),tn(e.payer.txid,e.payer.vout,e.payer.value,e.payer.script)],vout:[Me(e.holder.value,["OP_1",e.to]),Me(e.payer.value-be,["OP_1",e.to])]})}function F1(e,t,n,r=Date.now()){if((n==null?void 0:n.kind)!=="test-wallet")throw new Error("Claims are signed by local test wallets.");const s=Ta(e,t);if(!s)throw new Error("That inscription is not in an unspent output.");if(to(s.scriptPubKey)===to(n.script))throw new Error("The recipient already holds that inscription.");const o=e.coins(n.script).find(c=>{var u;return!((u=c.inscriptions)!=null&&u.length)&&c.value>=be+Oi});if(!o)throw new Error("The recipient needs a plain coin for the 500-sat fee. Mine a block to it first.");const i={kind:Yl,version:1,inscription:t,carried:s.inscriptions.map(c=>c.id),holder:Ic(s),payer:Ic(o),to:n.pubkey,at:r},a=Xl(i);return i.txid=ae.util.getTxid(a),i.sig=n.sign(a,void 0,1),i}function G1(e,t,n){const r=Y1(t);if((n==null?void 0:n.kind)!=="test-wallet")throw new Error("Countersigning needs a local test wallet.");if(to(n.script)!==r.holder.script)throw new Error("Only the current holder can countersign.");if(W1(e,r)!=="open")throw new Error("This claim is stale: an input it spends was already spent.");const s=Xl(r);return s.vin[1].witness=[r.sig],s.vin[0].witness=[n.sign(s,void 0,0)],e.submitPackage([ae.encode(s).hex]),ae.util.getTxid(s)}function W1(e,t){return e.utxos.has(`${t.holder.txid}:${t.holder.vout}`)&&e.utxos.has(`${t.payer.txid}:${t.payer.vout}`)?"open":"stale"}function Y1(e){const t=n=>n&&Xo.test(n.txid)&&Number.isSafeInteger(n.vout)&&n.vout>=0&&Number.isSafeInteger(n.value)&&n.value>=Oi&&z1.test(n.script);if((e==null?void 0:e.kind)!==Yl||e.version!==1||!/^[0-9a-f]{64}i\d+$/.test(e.inscription)||!Array.isArray(e.carried)||!t(e.holder)||!t(e.payer)||e.payer.value255*s)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/s);n===void 0&&(n=Tc);const i=new Uint8Array(o*s),a=un.create(e,t),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let f=0;fJ1(e,X1(e,t,n),r,s);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Yt=BigInt(0),Ae=BigInt(1),Qo=BigInt(2),ex=BigInt(8);function tx(e,t,n,r){const s=e.sqr(n),o=e.sqr(r),i=e.add(e.mul(t.a,s),o),a=e.add(e.ONE,e.mul(t.d,e.mul(s,o)));return e.eql(i,a)}function nx(e,t={}){const n=Al("edwards",e,t,t.FpFnLE),{Fp:r,Fn:s}=n;let o=n.CURVE;const{h:i}=o;fr(t,{},{uvRatio:"function"});const a=Qo<r.create(p),u=t.uvRatio||((p,g)=>{try{return{isValid:!0,value:r.sqrt(r.div(p,g))}}catch{return{isValid:!1,value:Yt}}});if(!tx(r,o,o.Gx,o.Gy))throw new Error("bad curve params: generator point");function f(p,g,x=!1){const w=x?Ae:Yt;return Dr("coordinate "+p,g,w,a),g}function l(p){if(!(p instanceof m))throw new Error("ExtendedPoint expected")}const d=qs((p,g)=>{const{X:x,Y:w,Z:O}=p,A=p.is0();g==null&&(g=A?ex:r.inv(O));const T=c(x*g),U=c(w*g),C=r.mul(O,g);if(A)return{x:Yt,y:Ae};if(C!==Ae)throw new Error("invZ was invalid");return{x:T,y:U}}),h=qs(p=>{const{a:g,d:x}=o;if(p.is0())throw new Error("bad point: ZERO");const{X:w,Y:O,Z:A,T}=p,U=c(w*w),C=c(O*O),_=c(A*A),N=c(_*_),H=c(U*g),K=c(_*c(H+C)),v=c(N+c(x*c(U*C)));if(K!==v)throw new Error("bad point: equation left != right (1)");const S=c(w*O),b=c(A*T);if(S!==b)throw new Error("bad point: equation left != right (2)");return!0});class m{constructor(g,x,w,O){this.X=f("x",g),this.Y=f("y",x),this.Z=f("z",w,!0),this.T=f("t",O),Object.freeze(this)}static CURVE(){return o}static fromAffine(g){if(g instanceof m)throw new Error("extended point not allowed");const{x,y:w}=g||{};return f("x",x),f("y",w),new m(x,w,Ae,c(x*w))}static fromBytes(g,x=!1){const w=r.BYTES,{a:O,d:A}=o;g=pc(st(g,w,"point")),Tn(x,"zip215");const T=pc(g),U=g[w-1];T[w-1]=U&-129;const C=Cn(T),_=x?a:r.ORDER;Dr("point.y",C,Yt,_);const N=c(C*C),H=c(N-Ae),K=c(A*N-O);let{isValid:v,value:S}=u(H,K);if(!v)throw new Error("bad point: invalid y coordinate");const b=(S&Ae)===Ae,k=(U&128)!==0;if(!x&&S===Yt&&k)throw new Error("bad point: x=0 and x_0=1");return k!==b&&(S=c(-S)),m.fromAffine({x:S,y:C})}static fromHex(g,x=!1){return m.fromBytes(he("point",g),x)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,x=!0){return y.createCache(this,g),x||this.multiply(Qo),this}assertValidity(){h(this)}equals(g){l(g);const{X:x,Y:w,Z:O}=this,{X:A,Y:T,Z:U}=g,C=c(x*U),_=c(A*O),N=c(w*U),H=c(T*O);return C===_&&N===H}is0(){return this.equals(m.ZERO)}negate(){return new m(c(-this.X),this.Y,this.Z,c(-this.T))}double(){const{a:g}=o,{X:x,Y:w,Z:O}=this,A=c(x*x),T=c(w*w),U=c(Qo*c(O*O)),C=c(g*A),_=x+w,N=c(c(_*_)-A-T),H=C+T,K=H-U,v=C-T,S=c(N*K),b=c(H*v),k=c(N*v),B=c(K*H);return new m(S,b,B,k)}add(g){l(g);const{a:x,d:w}=o,{X:O,Y:A,Z:T,T:U}=this,{X:C,Y:_,Z:N,T:H}=g,K=c(O*C),v=c(A*_),S=c(U*w*H),b=c(T*N),k=c((O+A)*(C+_)-K-v),B=b-S,L=b+S,P=c(v-x*K),j=c(k*B),D=c(L*P),q=c(k*P),oe=c(B*L);return new m(j,D,oe,q)}subtract(g){return this.add(g.negate())}multiply(g){if(!s.isValidNot0(g))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:x,f:w}=y.cached(this,g,O=>xn(m,O));return xn(m,[x,w])[0]}multiplyUnsafe(g,x=m.ZERO){if(!s.isValid(g))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return g===Yt?m.ZERO:this.is0()||g===Ae?this:y.unsafe(this,g,w=>xn(m,w),x)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return y.unsafe(this,o.n).is0()}toAffine(g){return d(this,g)}clearCofactor(){return i===Ae?this:this.multiplyUnsafe(i)}toBytes(){const{x:g,y:x}=this.toAffine(),w=r.toBytes(x);return w[w.length-1]|=g&Ae?128:0,w}toHex(){return Le(this.toBytes())}toString(){return``}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(g){return xn(m,g)}static msm(g,x){return $l(m,s,g,x)}_setWindowSize(g){this.precompute(g)}toRawBytes(){return this.toBytes()}}m.BASE=new m(o.Gx,o.Gy,Ae,c(o.Gx*o.Gy)),m.ZERO=new m(Yt,Ae,Ae,Yt),m.Fp=r,m.Fn=s;const y=new _l(m,s.BITS);return m.BASE.precompute(8),m}function rx(e,t,n={}){if(typeof t!="function")throw new Error('"hash" function param is required');fr(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:r}=n,{BASE:s,Fp:o,Fn:i}=e,a=n.randomBytes||Hn,c=n.adjustScalarBytes||(_=>_),u=n.domain||((_,N,H)=>{if(Tn(H,"phflag"),N.length||H)throw new Error("Contexts/pre-hash are not supported");return _});function f(_){return i.create(Cn(_))}function l(_){const N=w.secretKey;_=he("private key",_,N);const H=he("hashed private key",t(_),2*N),K=c(H.slice(0,N)),v=H.slice(N,2*N),S=f(K);return{head:K,prefix:v,scalar:S}}function d(_){const{head:N,prefix:H,scalar:K}=l(_),v=s.multiply(K),S=v.toBytes();return{head:N,prefix:H,scalar:K,point:v,pointBytes:S}}function h(_){return d(_).pointBytes}function m(_=Uint8Array.of(),...N){const H=we(...N);return f(t(u(H,he("context",_),!!r)))}function y(_,N,H={}){_=he("message",_),r&&(_=r(_));const{prefix:K,scalar:v,pointBytes:S}=d(N),b=m(H.context,K,_),k=s.multiply(b).toBytes(),B=m(H.context,k,S,_),L=i.create(b+B*v);if(!i.isValid(L))throw new Error("sign failed: invalid s");const P=we(k,i.toBytes(L));return st(P,w.signature,"result")}const p={zip215:!0};function g(_,N,H,K=p){const{context:v,zip215:S}=K,b=w.signature;_=he("signature",_,b),N=he("message",N),H=he("publicKey",H,w.publicKey),S!==void 0&&Tn(S,"zip215"),r&&(N=r(N));const k=b/2,B=_.subarray(0,k),L=Cn(_.subarray(k,b));let P,j,D;try{P=e.fromBytes(H,S),j=e.fromBytes(B,S),D=s.multiplyUnsafe(L)}catch{return!1}if(!S&&P.isSmallOrder())return!1;const q=m(v,j.toBytes(),P.toBytes(),N);return j.add(P.multiplyUnsafe(q)).subtract(D).clearCofactor().is0()}const x=o.BYTES,w={secretKey:x,publicKey:x,signature:2*x,seed:x};function O(_=a(w.seed)){return st(_,w.seed,"seed")}function A(_){const N=C.randomSecretKey(_);return{secretKey:N,publicKey:h(N)}}function T(_){return Fr(_)&&_.length===i.BYTES}function U(_,N){try{return!!e.fromBytes(_,N)}catch{return!1}}const C={getExtendedPublicKey:d,randomSecretKey:O,isValidSecretKey:T,isValidPublicKey:U,toMontgomery(_){const{y:N}=e.fromBytes(_),H=w.publicKey,K=H===32;if(!K&&H!==57)throw new Error("only defined for 25519 and 448");const v=K?o.div(Ae+N,Ae-N):o.div(N-Ae,N+Ae);return o.toBytes(v)},toMontgomerySecret(_){const N=w.secretKey;st(_,N);const H=t(_.subarray(0,N));return c(H).subarray(0,N)},randomPrivateKey:O,precompute(_=8,N=e.BASE){return N.precompute(_,!1)}};return Object.freeze({keygen:A,getPublicKey:h,sign:y,verify:g,utils:C,Point:e,lengths:w})}function sx(e){const t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp,r=jn(t.n,e.nBitLength,!0),s={Fp:n,Fn:r,uvRatio:e.uvRatio},o={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:s,hash:e.hash,eddsaOpts:o}}function ox(e,t){const n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:e,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function ix(e){const{CURVE:t,curveOpts:n,hash:r,eddsaOpts:s}=sx(e),o=nx(t,n),i=rx(o,r,s);return ox(e,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const xr=BigInt(0),Vn=BigInt(1),ms=BigInt(2);function ax(e){return fr(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function cx(e){const t=ax(e),{P:n,type:r,adjustScalarBytes:s,powPminus2:o,randomBytes:i}=t,a=r==="x25519";if(!a&&r!=="x448")throw new Error("invalid type");const c=i||Hn,u=a?255:448,f=a?32:56,l=BigInt(a?9:5),d=BigInt(a?121665:39081),h=a?ms**BigInt(254):ms**BigInt(447),m=a?BigInt(8)*ms**BigInt(251)-Vn:BigInt(4)*ms**BigInt(445)-Vn,y=h+m+Vn,p=v=>ye(v,n),g=x(l);function x(v){return Ea(p(v),f)}function w(v){const S=he("u coordinate",v,f);return a&&(S[31]&=127),p(Cn(S))}function O(v){return Cn(s(he("scalar",v,f)))}function A(v,S){const b=C(w(S),O(v));if(b===xr)throw new Error("invalid private or public key received");return x(b)}function T(v){return A(v,g)}function U(v,S,b){const k=p(v*(S-b));return S=p(S-k),b=p(b+k),{x_2:S,x_3:b}}function C(v,S){Dr("u",v,xr,n),Dr("scalar",S,h,y);const b=S,k=v;let B=Vn,L=xr,P=v,j=Vn,D=xr;for(let oe=BigInt(u-1);oe>=xr;oe--){const re=b>>oe&Vn;D^=re,{x_2:B,x_3:P}=U(D,B,P),{x_2:L,x_3:j}=U(D,L,j),D=re;const Y=B+L,ce=p(Y*Y),ue=B-L,ke=p(ue*ue),ie=ce-ke,ge=P+j,St=P-j,We=p(St*Y),Oe=p(ge*ue),kt=We+Oe,yr=We-Oe;P=p(kt*kt),j=p(k*p(yr*yr)),B=p(ce*ke),L=p(ie*(ce+p(d*ie)))}({x_2:B,x_3:P}=U(D,B,P)),{x_2:L,x_3:j}=U(D,L,j);const q=o(L);return p(B*q)}const _={secretKey:f,publicKey:f,seed:f},N=(v=c(f))=>(Ne(v,_.seed),v);function H(v){const S=N(v);return{secretKey:S,publicKey:T(S)}}return{keygen:H,getSharedSecret:(v,S)=>A(v,S),getPublicKey:v=>T(v),scalarMult:A,scalarMultBase:T,utils:{randomSecretKey:N,randomPrivateKey:N},GuBytes:g.slice(),lengths:_}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ux=BigInt(1),Cc=BigInt(2),fx=BigInt(3),lx=BigInt(5),dx=BigInt(8),Ca=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Jl={p:Ca,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:dx,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Ql(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),s=BigInt(80),o=Ca,a=e*e%o*e%o,c=xe(a,Cc,o)*a%o,u=xe(c,ux,o)*e%o,f=xe(u,lx,o)*u%o,l=xe(f,t,o)*f%o,d=xe(l,n,o)*l%o,h=xe(d,r,o)*d%o,m=xe(h,s,o)*h%o,y=xe(m,s,o)*h%o,p=xe(y,t,o)*f%o;return{pow_p_5_8:xe(p,Cc,o)*e%o,b2:a}}function ed(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}const Pc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function hx(e,t){const n=Ca,r=ye(t*t*t,n),s=ye(r*r*t,n),o=Ql(e*s).pow_p_5_8;let i=ye(e*r*o,n);const a=ye(t*i*i,n),c=i,u=ye(i*Pc,n),f=a===e,l=a===ye(-e,n),d=a===ye(-e*Pc,n);return f&&(i=c),(l||d)&&(i=u),Yw(i,n)&&(i=ye(-i,n)),{isValid:f||l,value:i}}const td=jn(Jl.p,{isLE:!0}),px={...Jl,Fp:td,hash:Kr,adjustScalarBytes:ed,uvRatio:hx},bo=ix(px),nd=(()=>{const e=td.ORDER;return cx({P:e,type:"x25519",powPminus2:t=>{const{pow_p_5_8:n,b2:r}=Ql(t);return ye(xe(n,fx,e)*r,e)},adjustScalarBytes:ed})})(),gx=Ge("lineage/v0"),yt=(e,t)=>Q1(Qe,e,gx,Ge(t),32),wo=e=>{const t=Uint8Array.from(e);return t[0]&=248,t[31]&=127,t[31]|=64,t},rd=e=>{const t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),t},et=e=>we(rd(e.length),e),Pa=e=>we(et(Ge("ssh-ed25519")),et(e)),Ii=(e,t)=>`ssh-ed25519 ${mt.encode(Pa(e))}${t?` ${t}`:""}`,Ti=e=>`SHA256:${mt.encode(Qe(Pa(e))).replace(/=+$/,"")}`;function mx(e){const t=ft(e),n=r=>bo.getPublicKey(yt(t,r));return{ssh:n("ssh"),git:n("git"),dkim:n("dkim"),wg:nd.getPublicKey(wo(yt(t,"wg")))}}function yx(e){const t=n=>bo.getPublicKey(yt(e,n));return{"ssh-ca":t("node/ssh-ca"),mtls:t("node/mtls"),noise:nd.getPublicKey(wo(yt(e,"node/noise")))}}function bx(e,t,n,r){return[["ssh",Ti(e.ssh),Ii(e.ssh,t)],["git",Ti(e.git),`${t} namespaces="git" ${Ii(e.git,t)}`],["dkim",`${n}._domainkey.${r}`,`${n}._domainkey.${r}. IN TXT "v=DKIM1; k=ed25519; p=${mt.encode(e.dkim)}"`],["wg",mt.encode(e.wg),`[Peer] +# ${t} +PublicKey = ${mt.encode(e.wg)}`]]}function wx(e,t){return[["ssh-ca",Ti(e["ssh-ca"]),Ii(e["ssh-ca"],`lineage-ca@${t}`)],["mtls",mt.encode(e.mtls),null],["noise",`mkey:${Le(e.noise)}`,null]]}const xx=ft("302e020100300506032b657004220420");function sd(e,t,n){const r=Qe(e).slice(0,4);let s=we(r,r,et(Ge("ssh-ed25519")),et(t),et(we(e,t)),et(Ge(n)));s=we(s,new Uint8Array((8-s.length%8)%8).map((i,a)=>a+1));const o=we(Ge("openssh-key-v1\0"),et(Ge("none")),et(Ge("none")),et(new Uint8Array(0)),rd(1),et(Pa(t)),et(s));return`-----BEGIN OPENSSH PRIVATE KEY----- +${mt.encode(o).match(/.{1,70}/g).join(` +`)} +-----END OPENSSH PRIVATE KEY----- +`}const vx=(e,t)=>`-----BEGIN ${e}----- +${mt.encode(t).match(/.{1,64}/g).join(` +`)} +-----END ${e}----- +`;function Ex(e,t){const n=ft(e),r=s=>{const o=yt(n,s);return sd(o,bo.getPublicKey(o),t)};return[["ssh","OpenSSH private key",r("ssh")],["git","OpenSSH private key",r("git")],["dkim","Ed25519 private key (base64)",mt.encode(yt(n,"dkim"))],["wg","Interface entry",`[Interface] +PrivateKey = ${mt.encode(wo(yt(n,"wg")))}`]]}function Sx(e,t){const n=yt(e,"node/ssh-ca");return[["ssh-ca","OpenSSH private key",sd(n,bo.getPublicKey(n),`lineage-ca@${t}`)],["mtls","Private key (PKCS#8 PEM)",vx("PRIVATE KEY",we(xx,yt(e,"node/mtls")))],["noise","noise_private.key",`privkey:${Le(wo(yt(e,"node/noise")))}`]]}const kx=["bip86","tapkey","wallet"],Ua=()=>({scheme:"bip86",roots:{},adopted:{}}),_x=e=>Ts.getPubKey(e)[0];function od(e,t,n){return e.scheme==="wallet"?Bi(t,n):Ts.getSecKey(e.scheme==="tapkey"?Ia(t,n):Bi(t,n))[0]}const id=(e,t)=>e.scheme==="tapkey"?Je.nostr(t):Je.wallet(t),$x=(e,t)=>new fn(od(e,t,0)),Tt=e=>Se.encode(e,!1).hex;function Un(e,t,n){if(!n)return null;const r=i=>i?{mnemonic:i,account:0,origin:`${n.name} root`,steps:[]}:null;if(n.kind==="holding")return r(e.roots[n.id]);const s=t.nodes.get(n.parent);if(n.kind==="agent"){const i=Un(e,t,s);return i&&{...i,account:n.index+1}}if(n.edge==="adopted")return r(e.adopted[n.id]);const o=Un(e,t,s);return o&&{mnemonic:M1(o.mnemonic,n.index),account:0,origin:o.origin,steps:[...o.steps,`${n.index}'`]}}function at(e,t,n){const r=Un(e,t,n);if(!r)return null;const{npub:s,pubkey:o}=q1(r.mnemonic,r.account),i=[r.origin,...r.steps].join(" › ");return{wallet:new fn(od(e,r.mnemonic,r.account)),npub:s,pubkey:o,scheme:e.scheme,account:r.account,from:i,path:`${i} · ${id(e,r.account)}`}}function Ax(e,t,n){const r=Un(e,t,n);if(!r)return null;const s=at(e,t,n),o=Wl(r.mnemonic,r.account);return{taproot:{address:s.wallet.address,path:id(e,r.account)},segwit:{address:Ar.p2wpkh.fromPubKey(o,"regtest"),path:Je.segwit(r.account)},tapkey:{address:Ar.p2tr.fromPubKey(_x(s.pubkey),"regtest"),path:Je.nostr(r.account)},npub:{address:s.npub,path:Je.nostr(r.account)}}}function ad(e,t,n){const r=Ta(e.chain,n);if(!r)return null;const s=Tt(r.scriptPubKey),o=t.nodes.get(n),i=at(e.keys,t,o),a=o&&at(e.keys,t,t.nodes.get(o.parent));return i&&Tt(i.wallet.script)===s?{wallet:i.wallet,who:"own"}:e.wallet&&Tt(e.wallet.script)===s?{wallet:e.wallet,who:"lab"}:a&&Tt(a.wallet.script)===s?{wallet:a.wallet,who:"parent"}:{wallet:null,who:"other",script:s}}function cd(e,t){const n=e.nodes.get(t),r=[n];for(const s of n.children){const o=e.nodes.get(s);o.status==="active"&&o.edge==="derived"&&r.push(...cd(e,s))}return r}function Ci(e,t){const n=[];for(let r=t;r;r=e.nodes.get(r.parent))n.push(r.name);return n.join(".")}function Bx(e,t,n){const r=Un(e,t,n);if(!r)return null;if(n.kind!=="agent")return wx(yx(Oa(r.mnemonic)),Ci(t,n));const s=Ci(t,t.nodes.get(n.parent));return bx(mx(Ia(r.mnemonic,r.account)),`${n.name}@${s}`,n.name,s)}const Ox=Dl(Qe),vr=(e,t=239)=>Ox.encode(we(Uint8Array.of(t),ft(e),Uint8Array.of(1))),Ix=e=>eo.encode("nsec",eo.toWords(ft(e))),Tx="0123456789()[],'/*abcdefgh@:$%{}IJKLMNOPQRSTUVWXYZ&+-.;<=>?!^_|~ijklmnopqrstuvwxyzABCDEFGH`#\"\\ ",Cx=[0xf5dee51989n,0xa9fdca3312n,0x1bab10e32dn,0x3706b1677an,0x644d626ffdn];function ei(e){const t=(i,a)=>{const c=i>>35n;return i=(i&0x7ffffffffn)<<5n^BigInt(a),Cx.forEach((u,f)=>{c>>BigInt(f)&1n&&(i^=u)}),i};let n=1n,r=0,s=0;for(const i of e){const a=Tx.indexOf(i);if(a<0)throw new Error("Invalid descriptor character.");n=t(n,a&31),r=r*3+(a>>5),++s===3&&(n=t(n,r),r=0,s=0)}s&&(n=t(n,r));for(let i=0;i<8;i++)n=t(n,0);n^=1n;let o="";for(let i=0;i<8;i++)o+="qpzry9x8gf2tvdw0s3jn54khce6mua7l"[Number(n>>BigInt(5*(7-i))&31n)];return`${e}#${o}`}function Px(e,t,n){const r=Un(e,t,n);if(!r)return null;const s=Ia(r.mnemonic,r.account),o=Bi(r.mnemonic,r.account),i={bip86:`tr(${vr(o)})`,tapkey:`tr(${vr(s)})`,wallet:`rawtr(${vr(o)})`}[e.scheme],a=n.kind==="agent",c=Ci(t,a?t.nodes.get(n.parent):n);return{seed:a?null:{from:[r.origin,...r.steps].join(" › "),mnemonic:r.mnemonic},account:[["nsec","NIP-06",Ix(s)],["taproot","descriptor",ei(i)],["segwit","descriptor",ei(`wpkh(${vr(Gl(r.mnemonic,r.account))})`)],["tapkey","descriptor",ei(`tr(${vr(s)})`)]],leaves:a?Ex(s,`${n.name}@${c}`):Sx(Oa(r.mnemonic),c)}}const xo="orgchain:lab:v1",Ux=["each",10,30,60,"manual"];function Xr(e={tempo:"each",nextAt:null}){const{tempo:t,nextAt:n}=e??{},r=typeof t=="number";if(!Ux.includes(t)||!(n===null||r&&Number.isSafeInteger(n)&&n>0))throw new Error("Invalid clock.");return{tempo:t,nextAt:n}}function ud(e){const t=Ua();for(const n of["roots","adopted"])for(const[r,s]of Object.entries((e==null?void 0:e[n])??{})){if(!/^[0-9a-f]{64}i0$/.test(r))throw new Error("Invalid lab keys.");t[n][r]=Fl(s,24)}if(t.scheme=(e==null?void 0:e.scheme)??(Object.keys(t.roots).length?"wallet":"bip86"),!kx.includes(t.scheme))throw new Error("Invalid lab keys.");return t}const Jr=()=>({wallet:null,chain:new go,clock:Xr(),keys:Ua()});function fd(e){if(!e)return Jr();const t=JSON.parse(e);if((t==null?void 0:t.kind)!=="orgchain-lab"||t.network!==Qt||t.version!==1)throw new Error("That is not an Orgchain v1 lab.");return{wallet:t.wallet?fn.load(t.wallet):null,chain:new go(t.chain),clock:Xr(t.clock),keys:ud(t.keys)}}const ld=e=>{var t;return JSON.stringify({kind:"orgchain-lab",network:Qt,version:1,wallet:((t=e.wallet)==null?void 0:t.backup())??null,chain:e.chain.snapshot(),clock:Xr(e.clock),keys:ud(e.keys)})},Na=()=>fd(localStorage.getItem(xo));function Nx(e){try{localStorage.setItem(xo,ld(e))}catch{throw new Error("Browser storage is full or unavailable, so nothing was saved. Save a backup, then reset.")}}async function Lx(e,{locks:t=(s=>(s=globalThis.navigator)==null?void 0:s.locks)(),read:n=Na,save:r=Nx}={}){if(!t)throw new Error("Orgchain needs Web Locks: open it over HTTPS or on localhost.");return t.request(xo,async()=>{const o=n(),i=await e(o);return i!==!1&&r(o),{lab:o,result:i}})}function ln(e,t=null){e.wallet||(e.wallet=fn.create());const n=e.chain.mine(t??e.wallet.script);return e.clock=Xr({tempo:e.clock.tempo,nextAt:null}),n}function vo(e,t=Date.now()){const{tempo:n,nextAt:r}=e.clock;typeof n=="number"&&e.chain.mempool.length&&r===null&&(e.clock={tempo:n,nextAt:t+n*1e3})}function Rx(e,t,n=Date.now(),r=null){e.clock=Xr({tempo:t,nextAt:null}),t==="each"&&e.chain.mempool.length?ln(e,r):vo(e,n)}function Hx(e,t=Date.now(),n=null){const{tempo:r,nextAt:s}=e.clock;return typeof r!="number"||!e.chain.mempool.length?!1:s===null?(vo(e,t),!0):t(e/Eo).toFixed(8).replace(/\.?0+$/,""),Ee=e=>`${dd(e)} tBTC`;function jx(e){if(e<1e6)return Ee(e);const t=Math.round(e/1e6)*1e6;return`${t===e?"":"≈"}${Ee(t)}`}function Kx(e){const t=/^\s*(\d{0,7})(?:\.(\d{0,8}))?\s*$/.exec(String(e??""));return!t||!(t[1]||t[2])?null:Number(t[1]||0)*Eo+Number((t[2]??"").padEnd(8,"0"))}class Dx{constructor(t,n,r){this.secret=t,this.pubkey=n,this.path=r,this.address=Ar.p2wpkh.fromPubKey(n,"regtest"),this.script=Ar.toScriptPubKey(this.address)}sign(t,n){return[fo.segwit.sign(this.secret,t,n,{pubkey:this.pubkey}).hex,this.pubkey]}}const ti=new Map;function vt(e,t,n){const r=Un(e,t,n);if(!r)return null;const s=`${r.mnemonic}|${r.account}`;return ti.has(s)||ti.set(s,new Dx(Gl(r.mnemonic,r.account),Wl(r.mnemonic,r.account),Je.segwit(r.account))),ti.get(s)}function La(e,t,n){var s;const r=n?t.nodes.get(n):null;return(r==null?void 0:r.kind)==="holding"&&r.status==="active"?((s=vt(e,t,r))==null?void 0:s.script)??null:null}function Zx(e,t){const n=t+be,r=a=>a===n||a-n>=ct&&a-n<=qn,s=[...e].sort((a,c)=>a.value-c.value),o=s.find(a=>r(a.value));if(o)return[o];let i=null;for(let a=0;ar.value).sort((r,s)=>s-r),n=[];if(t.length&&n.push(t[0]-be),t.length>1){const r=t[0]+t[1]-be;n.push(r<=qn?r:r-qn>=ct?qn:r-ct)}return Math.max(0,...n.filter(r=>r>=ct&&r<=qn))}function Vx(e,t,n){const r=t.reduce((c,u)=>c+u.value,0),s=n+be,o=Ra(t);if(rc.value),...t.flatMap((c,u)=>t.slice(u+1).map(f=>c.value+f.value))],a=Math.min(...i.filter(c=>c>=s));return Number.isFinite(a)&&a-sqn)throw new Error("Send at most 50 test BTC at a time: no output on this chain is bigger than one block reward.");const u=e.chain.coins(a.script),f=Zx(u,s);if(!f)throw new Error(Vx(o.name,u,s));const l=f.reduce((m,y)=>m+y.value,0)-s-be,d=ae.create({vin:f.map(m=>tn(m.txid,m.vout,m.value,m.scriptPubKey)),vout:[Me(s,c.script),...l?[Me(l,a.script)]:[]]});f.forEach((m,y)=>{d.vin[y].witness=a.sign(d,y)});const h=ae.encode(d).hex;return e.chain.submitPackage([h]),ae.util.getTxid(h)}function Mx(e,t,n){if(!t||!n||Tt(t.script)===Tt(n.script))return 0;let r=0;for(const s of e.chain.coins(t.script)){if(s.value-be{for(const i of o.nodes.values()){const a=vt(e,o,i),c=a&&Tt(a.script);c&&!r.has(c)&&r.set(c,i.id)}};return s(n),n.log.forEach((o,i)=>{o.ok&&o.op==="graduate"&&s(In(t.slice(0,i),{pending:!0}))}),r}function zx(e,t){var o;const n=[],r=i=>t.get(Tt(i))??null,s=i=>i.reduce((a,c)=>a+c.value,0);for(const{txid:i,tx:a,height:c,coinbase:u}of e.transactions.values()){const f=a.vout.map(p=>({node:r(p.scriptPubKey),value:Number(p.value)}));if(u){f[0].node&&n.push({kind:"mine",txid:i,beat:c,from:null,to:f[0].node,amount:f[0].value,fee:0,change:0});continue}const l=a.vin.map(p=>{var x;const g=(x=e.transactions.get(p.txid))==null?void 0:x.tx.vout[p.vout];return g?{node:r(g.scriptPubKey),value:Number(g.value)}:null}),d=(o=l[0])==null?void 0:o.node;if(!d||!l.every(p=>(p==null?void 0:p.node)===d))continue;const h=f.filter(p=>p.node!==d),m=f.filter(p=>p.node===d),y=s(l)-s(f);n.push(h.length?{kind:"pay",txid:i,beat:c,from:d,to:h[0].node,amount:h[0].value,fee:y,change:s(m)}:{kind:"move",txid:i,beat:c,from:d,to:d,amount:s(m),fee:y,change:0})}return n}function Pi(e,t,n=1/0){const r=new Map;for(const{txid:o,tx:i,height:a,coinbase:c}of e.transactions.values())if(!(a===null?n!==1/0:a>n)){if(!c)for(const u of i.vin)r.delete(`${u.txid}:${u.vout}`);i.vout.forEach((u,f)=>{const l=t.get(Tt(u.scriptPubKey));l&&r.set(`${o}:${f}`,{node:l,value:Number(u.value)})})}const s=new Map;for(const{node:o,value:i}of r.values())s.set(o,(s.get(o)??0)+i);return s}const Uc={found:["name"],birth:["name","kind"],award:["to","skill","belt"],decide:["title","why"],graduate:["of"],close:[]},Fx={found:e=>`found ${e.name}`,birth:e=>`birth ${e.name}`,award:e=>`award ${e.skill} ${e.belt}`,decide:e=>`decide ${e.title}`,graduate:()=>"graduate",close:()=>"close"};function Gx(e,t={}){if(!Object.hasOwn(Uc,e))throw new Error("Unknown verb.");const n={op:e};for(const r of Uc[e]){const s=t[r];typeof s=="string"&&s.trim()&&(n[r]=s.trim())}return n}const _n=e=>In(ba(new ho(e.chain)),{pending:!0});function pd(e,t,n,r){const s=Gx(t,r),o=ba(new ho(e.chain)),i={id:"check",status:"pending",height:null,metadata:s,parent:n??null,protocol:ma},{ok:a,why:c}=In([...o,i],{pending:!0}).log.at(-1);if(!a)throw new Error(`${c[0].toUpperCase()}${c.slice(1)}.`);return s}const Wx=Bt+2*be+330,Es=1e5,no=(e,t,n)=>e.chain.coins(t.script).find(r=>{var s;return!((s=r.inscriptions)!=null&&s.length)&&r.value>=n}),Ui=e=>tn(e.txid,e.vout,e.value,e.scriptPubKey),gd=(e,t)=>(t.forEach((n,r)=>{e.vin[r].witness=[n.sign(e,void 0,r)]}),ae.encode(e).hex);function md(e){e.keys??(e.keys=Ua()),e.wallet||(e.wallet=fn.create()),no(e,e.wallet,Es+be+330)||ln(e)}function ni(e,t,n=Wx){if(t===e.wallet||no(e,t,n))return;const r=no(e,e.wallet,Es+be+330),s=ae.create({vin:[Ui(r)],vout:[Me(Es,t.script),Me(r.value-Es-be,e.wallet.script)]});e.chain.submitPackage([gd(s,[e.wallet])])}function Nc(e,t,n,r){const s=Ta(e.chain,t),o=no(e,e.wallet,be+330),i=ae.create({vin:[Ui(s),Ui(o)],vout:[Me(s.value,r.script),Me(o.value-be,e.wallet.script)]});e.chain.submitPackage([gd(i,[n,e.wallet])])}function Lc(e,t,n,r,s){return new dw(e.chain,t).inscribe(Fx[n](s),r??null,s,{metaprotocol:ma})}const yd=(e,t)=>{var r;const n=_n(e);return La(e.keys,n,((r=n.nodes.get(t))==null?void 0:r.root)??null)},So=(e,t)=>La(e.keys,_n(e),t);function Rc(e,t,n){var s;const r=ad(e,t,n);if(!(r!=null&&r.wallet))throw new Error(`No key in this lab holds ${((s=t.nodes.get(n))==null?void 0:s.name)??"that node"}'s inscription.`);return r.wallet}function bd(e,t,n,r){if(t==="found"){const u=Oc(),f=$x(e.keys,u);ni(e,f);const l=Lc(e,f,t,null,r);return e.keys.roots[l]=u,l}const s=_n(e),o=Rc(e,s,n),i=t==="graduate"?s.nodes.get(r.of):null,a=i&&at(e.keys,s,i)?cd(s,i.id).map(u=>[u.id,Rc(e,s,u.id)]):[];ni(e,o);const c=Lc(e,o,t,n,r);if(t==="birth"){const u=_n(e),f=at(e.keys,u,u.nodes.get(c));f&&Nc(e,c,o,f.wallet)}if(a.length){e.keys.adopted[i.id]=Oc();const u=_n(e);for(const[f,l]of a){const d=at(e.keys,u,u.nodes.get(f)).wallet;if(Mx(e,vt(e.keys,s,s.nodes.get(f)),vt(e.keys,u,u.nodes.get(f))),f!==i.id){Nc(e,f,l,d);continue}ni(e,d,be+330),G1(e.chain,F1(e.chain,f,d),l)}}return c}function Yx(e,t,n,r,s=Date.now()){const o=pd(e,t,n,r);md(e);const i=bd(e,t,n??null,o);return e.clock.tempo==="each"?ln(e,yd(e,n??i)):vo(e,s),i}function Xx(e,t,n,r,s=Date.now()){const o=hd(e,_n(e),t,n,r);return e.clock.tempo==="each"?ln(e,yd(e,t)):vo(e,s),o}const Ni="yolopreneur",Jx=[[["found",null,{name:"yolopreneur"}]],[["birth","yolopreneur",{name:"well-known",kind:"org"}],["birth","yolopreneur",{name:"time",kind:"org"}]],[["birth","well-known",{name:"mailr",kind:"org"}],["birth","well-known",{name:"lineage",kind:"org"}],["birth","time",{name:"luna",kind:"agent"}],["birth","time",{name:"sol",kind:"agent"}],["birth","time",{name:"astra",kind:"agent"}],["send","yolopreneur",{to:"time",amount:40}],["send","yolopreneur",{to:"well-known",amount:10}]],[["birth","time",{name:"docscope",kind:"org"}],["birth","time",{name:"dollhouse",kind:"org"}],["birth","time",{name:"doodleloop",kind:"org"}],["birth","time",{name:"hearthframe",kind:"org"}],["send","well-known",{to:"lineage",amount:2}]],[["award","time",{to:"sol",skill:"launch",belt:"green"}],["award","time",{to:"luna",skill:"post",belt:"white"}],["send","time",{to:"sol",amount:1}],["send","time",{to:"luna",amount:.5}],["decide","yolopreneur",{title:"Every venture gets a page",why:".yolopreneur.lol, served from one pages branch."}]],[["graduate","well-known",{of:"lineage"}],["decide","lineage",{title:"Lineage gets its own org",why:"Its own repo on Teahub now, lineage.llc later: adopted, not derived."}]]];function Qx(e){md(e),e.chain.mempool.length&&ln(e);const t={};for(const n of Jx){for(const[r,s,o]of n){if(r==="send"){hd(e,_n(e),t[s],t[o.to],o.amount*Eo);continue}const i=Object.fromEntries(Object.entries(o).map(([u,f])=>[u,u==="to"||u==="of"?t[f]:f])),a=s?t[s]:null,c=bd(e,r,a,pd(e,r,a,i));(r==="found"||r==="birth")&&(t[o.name]=c)}ln(e,So(e,t[Ni]))}return t[Ni]}const M=e=>document.getElementById(e);function $(e,t={},...n){const r=document.createElement(e);for(const[s,o]of Object.entries(t))o==null||o===!1||(s==="class"?r.className=o:s==="text"?r.textContent=o:s.startsWith("on")?r.addEventListener(s.slice(2),o):r.setAttribute(s,o===!0?"":String(o)));for(const s of n.flat(1/0))s!=null&&s!==!1&&s!==""&&r.append(s instanceof Node?s:String(s));return r}const kr=(e,t)=>`${e} ${t}${e===1?"":"s"}`,En=e=>e==="cued"?"cued":`beat ${e}`,e2=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),Hc=e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?String(n):n,2),I={holding:null,node:null,event:null,tx:null,beat:null,verb:"birth",busy:!1,replay:null,closing:null,reveal:null};let te=Jr(),ro=new ho(te.chain),zn=[],de=In([]),ze=de,je={owner:new Map,ledger:[],now:new Map,view:new Map};const Fe=()=>te.chain.blocks.length,Li=()=>zn.filter(e=>e.status==="pending").length,Ri=()=>je.ledger.filter(e=>e.beat===null&&e.kind==="pay").length,t2=()=>Li()+Ri(),Ss=e=>je.view.get(e)??0,wd=e=>je.now.get(e)??0,se=(e,t=de)=>e?t.nodes.get(e)??null:null,xd=e=>Object.assign(I,{event:null,tx:null,closing:null,reveal:null},e),Qr=e=>{xd(e),ko()};function Te(e,t=!1){const n=M("say");n.textContent=e,n.classList.toggle("bad",t)}function vd(){try{te=Na()}catch(e){te=Jr(),Te(`This browser's saved lab could not be read (${e.message}) Load a backup, or reset to start over.`,!0)}Ha()}function Ha(){var t;ro=new ho(te.chain),zn=ba(ro),de=In(zn,{pending:!0}),I.beat!==null&&I.beat>=Fe()&&(I.beat=null),se(I.holding)||(I.holding=((t=de.roots.at(-1))==null?void 0:t.id)??null),(!se(I.node)||se(I.node).root!==I.holding)&&(I.node=I.holding),I.event&&!de.log.some(n=>n.id===I.event)&&(I.event=null),ze=I.beat===null?de:In(zn,{upTo:I.beat});const e=qx(te.keys,zn,de);je={owner:e,ledger:zx(te.chain,e),now:Pi(te.chain,e)},je.view=I.beat===null?je.now:Pi(te.chain,e,I.beat),I.tx&&!je.ledger.some(n=>n.txid===I.tx)&&(I.tx=null),ko()}function so(e){I.beat=e>=Fe()?null:Math.max(0,e),ze=I.beat===null?de:In(zn,{upTo:I.beat}),je.view=I.beat===null?je.now:Pi(te.chain,je.owner,I.beat),ko()}async function gr(e,t){if(I.busy)return!1;I.busy=!0,document.body.classList.add("busy");try{return te=(await Lx(e,t)).lab,!0}catch(n){return Te((n==null?void 0:n.message)||String(n),!0),!1}finally{I.busy=!1,document.body.classList.remove("busy"),Ha()}}async function mr(e,t,n,r){let s=null;if(!await gr(i=>{s=Yx(i,e,t,n)}))return!1;const o=ro.events.find(i=>i.id===s);return Te(r(s,(o==null?void 0:o.status)==="confirmed"?`at beat ${o.height}`:"cued for the next beat")),ko(),!0}async function Ed(e){var a;const t=Li(),n=Ri(),r=Fe();if(!await gr(e)||Fe()===r)return;const s=[[t-Li(),"cued act"],[n-Ri(),"cued send"]].filter(([c])=>c>0).map(([c,u])=>kr(c,u)),o=je.ledger.find(c=>c.kind==="mine"&&c.beat===Fe()),i=`${o?(a=se(o.to))==null?void 0:a.name:"the lab wallet"} earned ${Ee((o==null?void 0:o.amount)??5e9)}`;Te(`Beat ${Fe()}: ${s.length?`${s.join(" and ")} landed, and ${i}`:i}.`)}function ko(){Sd(),r2(),s2(),_o(),$d(),Ka()}function Sd(){const e=t2(),{tempo:t}=te.clock;for(const r of document.querySelectorAll("[data-tempo]"))r.setAttribute("aria-pressed",String(String(t)===r.dataset.tempo));M("clock-beat").textContent=String(Fe()),M("clock-cued").textContent=e?`${e} cued · ${n2()}`:"nothing cued";const n=La(te.keys,de,I.holding)?se(I.holding).name:"the lab wallet";M("clock-pays").textContent=`beats pay ${n}`,M("beat-now").title=`Beat now: ${e?"land what is cued, and ":""}pay ${n} 50 test BTC`}function n2(){const{tempo:e,nextAt:t}=te.clock;return e==="manual"?"waiting for Beat now":typeof e=="number"&&t?`next beat in ${Math.max(0,Math.ceil((t-Date.now())/1e3))}s`:"landing on the next beat"}function r2(){M("holdings-list").replaceChildren(...de.roots.map(e=>{const t=yw(de,e.id),n=e.id===I.holding,r=[...de.nodes.values()].reduce((o,i)=>o+(i.root===e.id?wd(i.id):0),0),s=[En(e.born),kr(t.orgs,"org"),kr(t.agents,"agent"),kr(t.belts,"belt"),r>0&&Ee(r),e.status==="closed"&&"closed"].filter(Boolean);return $("li",{},$("button",{type:"button",class:`hold${n?" on":""}${e.status==="closed"?" gone":""}`,"aria-pressed":String(n),onclick:()=>Qr({holding:e.id,node:e.id})},$("span",{class:"hn",text:e.name})," ",$("span",{class:"hm",text:s.join(" · ")})))})),M("holdings-empty").hidden=de.roots.length>0,M("holdings-sub").textContent=de.roots.length?String(de.roots.length):"",M("sample").disabled=de.roots.some(e=>e.name===Ni&&e.status==="active")}function s2(){var r;const e=M("tree-rows"),t=se(I.holding);if(M("tree-sub").textContent=t?`${t.name} · ${I.beat===null?"now":`beat ${I.beat} of ${Fe()}`}`:"",!t)return e.replaceChildren($("p",{class:"wait",text:"No holding yet. Found one, or load the yolopreneur sample."}));if(!ze.nodes.has(t.id))return e.replaceChildren($("p",{class:"wait",text:`${t.name} is founded at ${En(t.born)}. Move the slider forward.`}));const n=e.contains(document.activeElement)?document.activeElement.dataset.id:null;e.replaceChildren(...mw(ze,t.id).map(s=>s.type==="group"?$("div",{class:"row grp"},$("span",{class:"g","aria-hidden":"true",text:s.guide}),$("span",{class:"gl",text:s.label})):o2(s))),n&&((r=e.querySelector(`[data-id="${n}"]`))==null||r.focus())}function o2({node:e,guide:t,path:n}){const r=e.id===I.node,s=["row",r&&"on",e.status==="closed"&&"gone",e.born==="cued"&&"cue"].filter(Boolean).join(" ");return $("div",{class:s},$("button",{type:"button",class:"sel","data-id":e.id,"aria-pressed":String(r),onclick:()=>Qr({node:e.id})},$("span",{class:"g","aria-hidden":"true",text:t}),$("span",{class:"p",text:`${n} `}),$("span",{class:"l",text:e.name})," ",$("span",{class:"v"},i2(e))))}function i2(e){return[e.kind==="agent"&&$("span",{class:"mk",text:"agent"}),e.edge==="adopted"&&$("span",{class:"mk ok",text:"graduated"}),e.status==="closed"&&$("span",{class:"mk bad",text:"closed"}),e.born==="cued"&&$("span",{class:"mk",text:"cued"}),...e.badges.map(kd),Ss(e.id)>0&&$("span",{class:"mk sats",title:`${Ee(Ss(e.id))} at its SegWit address`,text:jx(Ss(e.id))})].filter(Boolean).flatMap((n,r)=>r?[" ",n]:[n])}const kd=e=>$("span",{class:`belt ${e.belt}`,title:`${e.skill}: ${e.belt} belt`},e.skill,$("span",{class:"sr",text:` (${e.belt} belt)`})),a2=(e,t)=>{for(let n=se(e.parent);n;n=se(n.parent))if(n.id===t.id)return!0;return!1},ja=e=>[...de.nodes.values()].filter(t=>t.root===e.root&&t.id!==e.id&&t.status==="active").map(t=>[t,(a2(t,e)?0:2)+(t.kind==="agent"?0:1)]).sort((t,n)=>t[1]-n[1]).map(([t])=>t),_d=e=>e.children.reduce((t,n)=>{const r=se(n);return r&&r.edge==="derived"&&r.status==="active"?t+1+_d(r):t},0);function c2(e){const t=vt(te.keys,de,e),n=se(e.root);return t?Ra(te.chain.coins(t.script))f.map(l=>`${l.value}=${l.textContent}`).join("|");for(const f of[M("award-to"),M("send-to")]){const l=f.value,d=ja(e).map(h=>$("option",{value:h.id,text:`${Xf(de,h.id)}${h.kind==="agent"?" (agent)":""}`}));s(d)!==s([...f.options])&&(f.replaceChildren(...d),d.some(h=>h.value===l)&&(f.value=l))}M("send-has").textContent=Ee(wd(e.id)),M("graduate-go").textContent=`Graduate ${e.name}`;const o=I.verb==="graduate"?r:e,i=o&&at(te.keys,de,o),a=i&&(I.verb==="send"?`${i.from} · ${vt(te.keys,de,o).path}`:i.path);M("act-key").textContent=!o||n[I.verb]?"":i?`Signs as ${o.name}: ${a}`:"Signs with the lab wallet: this holding predates lab keys.";const c=_d(e),u=I.closing===e.id;M("close-note").textContent=c?`Closing ${e.name} spends it for the last time, and its ${kr(c,"derived descendant")} close with it. Graduated children hold their own roots and stay open.`:`Closing ${e.name} spends its inscription for the last time. Nothing can act through it afterwards.`,M("close-go").textContent=u?`Yes, close ${e.name}`:`Close ${e.name}`,M("close-keep").hidden=!u}function $d(){const e=M("inspect-body"),t=I.event?de.log.find(o=>o.id===I.event):null;if(t)return M("inspect-sub").textContent="event",e.replaceChildren(...w2(t));const n=I.tx?je.ledger.find(o=>o.txid===I.tx):null;if(n)return M("inspect-sub").textContent="money",e.replaceChildren(...x2(n));const r=se(I.node);if(M("inspect-sub").textContent=(r==null?void 0:r.kind)??"",!r)return e.replaceChildren($("p",{class:"note pad",text:"Select a node in the tree, or an event in the timeline."}));const s=se(I.node,ze);if(!s)return e.replaceChildren($("p",{class:"note pad",text:`${r.name} is not born yet at beat ${I.beat}.`}));e.replaceChildren(...f2(s))}const Zr=([e,t,n])=>$("div",{class:"f"},$("dt",{text:e}),$("dd",{},t,n&&$("span",{class:"fn",text:n})));function f2(e){const t=se(e.parent,ze),n=[["Born",e.born==="cued"?"cued for the next beat":`beat ${e.born}`],t&&["Parent",`${t.name} · ${e.kind} ${e.index}'`],t&&["Edge",e.edge==="adopted"?`adopted at ${En(e.graduated)}: it holds its own root`:`derived: ${t.name} holds its seed`],e.closed!==null&&["Closed",En(e.closed)],["Children",e.children.length?e.children.map(r=>{var s;return(s=se(r,ze))==null?void 0:s.name}).join(", "):"none yet"],vt(te.keys,ze,e)&&["Balance",Ee(Ss(e.id)),`Test BTC at its SegWit address${I.beat===null?"":`, as of beat ${I.beat}`}.`],["Inscription",e.id]].filter(Boolean);return[$("div",{class:"ih"},$("p",{class:"eyebrow",text:Xf(ze,e.id)}),$("h3",{class:"it",text:e.name}),$("div",{class:"chips"},$("span",{class:"chip",text:e.kind}),$("span",{class:`chip ${e.status==="active"?"ok":"bad"}`,text:e.status}),e.edge==="adopted"&&$("span",{class:"chip ok",text:"graduated"}),e.born==="cued"&&$("span",{class:"chip",text:"cued"}))),$("div",{class:"ib"},$("dl",{class:"fl"},n.map(Zr)),e.badges.length>0&&$("div",{},$("p",{class:"lab",text:"Belts"}),$("ul",{class:"list"},e.badges.map(r=>{var s;return $("li",{},kd(r),$("span",{class:"when",text:` from ${((s=se(r.by))==null?void 0:s.name)??"?"}, ${En(r.beat)}`}))}))),e.decisions.length>0&&$("div",{},$("p",{class:"lab",text:"Decisions"}),$("ul",{class:"list"},e.decisions.map(r=>$("li",{},$("b",{text:r.title}),r.why&&` · ${r.why}`,$("span",{class:"when",text:` (${En(r.beat)})`}))))),l2(e),g2(e))]}function l2(e){const t=je.ledger.filter(n=>(n.to===e.id||n.from===e.id)&&(I.beat===null||n.beat!==null&&n.beat<=I.beat)).slice(-6).reverse();return t.length>0&&$("div",{},$("p",{class:"lab",text:"Money"}),$("ul",{class:"list"},t.map(n=>$("li",{},$("b",{text:d2(n,e.id)}),$("span",{class:"when",text:` (${En(n.beat??"cued")})`})))))}function d2(e,t){const n=r=>{var s;return((s=se(r))==null?void 0:s.name)??"?"};return e.kind==="mine"?`+${Ee(e.amount)}, a beat's reward`:e.kind==="move"?`${Ee(e.amount)} moved to its new key, after a ${e.fee}-sat fee`:e.to===t?`+${Ee(e.amount)} from ${n(e.from)}`:`−${Ee(e.amount)} to ${n(e.to)}, and a ${e.fee}-sat fee`}function Ad(e){const t=n=>{var r;return((r=se(n))==null?void 0:r.name)??"?"};return e.kind==="mine"?`${Ee(e.amount)} → ${t(e.to)}`:e.kind==="move"?`${Ee(e.amount)} → ${t(e.to)}'s new key`:`${Ee(e.amount)} ${t(e.from)} → ${t(e.to)}`}const h2={own:"its own key",lab:"the lab wallet",parent:"its parent's key (its handoff is cued)",other:"a key outside this lab"},p2={ssh:"shell access, certified by the CA",git:"commit signing",dkim:"mail signing",wg:"WireGuard peer key","ssh-ca":"SSH certificate authority",mtls:"TLS identity between nodes",noise:"Headscale noise key"};function g2(e){const t=at(te.keys,ze,e),n=ad(te,de,e.id),r=["Held now by",n?h2[n.who]:"nobody: its inscription has been spent"];if(!t)return $("div",{class:"keys"},$("p",{class:"lab",text:"Keys"}),$("dl",{class:"fl"},[["Signs with","the lab wallet: this holding predates lab keys, so it has no addresses, leaves or secrets of its own"],r].map(Zr)));const s=e.kind==="agent",o=Ax(te.keys,ze,e),i=Bx(te.keys,ze,e),a=i.map(([,,d])=>d).filter(Boolean),c="Reset the lab for standard BIP-86 keys.",u=s?"Holds this seat's inscription, and inscriptions sent to it land here.":"Holds this org's inscription and signs its acts. Inscriptions sent to it land here.",f={bip86:`BIP-86 at ${o.taproot.path}. ${u}`,tapkey:`Its npub's key with the BIP-86 tweak, the way v1.2 keyed this lab. ${u} ${c}`,wallet:`An untweaked key at ${o.taproot.path}, the way v1.1 keyed this lab. ${u} ${c}`}[t.scheme],l=[["Taproot",o.taproot.address,f],["SegWit",o.segwit.address,`BIP-84 at ${o.segwit.path}. Its money: ${e.kind==="holding"?"the beats it earns land here, and ":""}sends come and go here.`],["Tapkey",o.tapkey.address,"Its npub as a Taproot address (its nostr key with the BIP-86 tweak), so the npub alone finds it. Nostr secrets get pasted into clients, so treat it as an inbox."],["npub",o.npub.address,`NIP-06 at ${o.npub.path}. Its nostr name; the leaves below hang off it.`],["From",`${t.from} · account ${t.account}`],r];return $("div",{class:"keys"},$("p",{class:"lab",text:"Keys"}),$("dl",{class:"fl"},l.map(Zr)),$("p",{class:"lab"},"Leaves",$("span",{text:` · HKDF-SHA256 from its ${s?"nostr secret":"seed"}`})),$("ul",{class:"list leaves"},i.map(([d,h])=>$("li",{},$("b",{text:d}),$("span",{class:"when",text:` ${p2[d]}`}),$("code",{text:h})))),_r(s?"Public lines to paste":"CA key for TrustedUserCAKeys",a.join(` + +`)),y2(e,t))}function _r(e,t,n=t){const r=$("pre",{text:n}),s=$("button",{type:"button",class:"cp","aria-label":`Copy ${e}`,onclick:()=>m2(t,s,r)},"Copy");return $("div",{class:"code"},$("div",{class:"code-h cph"},$("span",{text:e}),s),r)}async function m2(e,t,n){const r=s=>{t.textContent=s,setTimeout(()=>{t.textContent="Copy"},1400)};try{await navigator.clipboard.writeText(e),r("Copied")}catch{getSelection().selectAllChildren(n),r("Selected")}}function y2(e,t){var a;const n=I.reveal===e.id,r=n&&Px(te.keys,ze,e),s=se(e.parent,ze),o=()=>{var c;I.reveal=n?null:e.id,$d(),(c=M("reveal"))==null||c.focus()},i=(a=r==null?void 0:r.seed)==null?void 0:a.mnemonic.split(" ");return $("div",{class:"secret"},$("div",{class:"hz"},$("span",{class:"hz-l",text:"Secret · stays in this tab"}),$("button",{type:"button",class:"btn sm",id:"reveal","aria-expanded":String(n),onclick:o},n?"Hide":"Reveal")),r&&$("div",{class:"sb"},r.seed?_r(`Seed · ${r.seed.from}`,r.seed.mnemonic,i.map((c,u)=>`${String(u+1).padStart(2,"0")} ${c}`).reduce((c,u,f)=>(f%3?c[c.length-1].push(u):c.push([u]),c),[]).map(c=>c.join(" ")).join(` +`)):$("p",{class:"note",text:`A seat has no seed of its own: these are account ${t.account} of ${(s==null?void 0:s.name)??"its org"}'s seed.`}),r.account.map(([c,u,f])=>_r(`${c} · ${u}`,f)),r.leaves.map(([c,u,f])=>_r(`${c} · ${u}`,f))))}function b2(e){var i,a,c;const t=(a=(i=te.chain.transactions.get(e.id.slice(0,-2)))==null?void 0:i.tx.vin.find(u=>{var f;return((f=u.witness)==null?void 0:f.length)===3}))==null?void 0:a.witness;if(!t)return"?";const n=ga(t).pubkey,r=se(e.parent),s=e.op==="found"?se(e.node):null,o=[[s&&at(te.keys,de,s),`${s==null?void 0:s.name}'s root`],[r&&at(te.keys,de,r),`${r==null?void 0:r.name}'s key`],[(r==null?void 0:r.edge)==="adopted"&&at(te.keys,de,{...r,edge:"derived"}),`${r==null?void 0:r.name}'s derived key, from before it graduated`]];for(const[u,f]of o)if(u&&u.wallet.pubkey===n)return f;return((c=te.wallet)==null?void 0:c.pubkey)===n?"the lab wallet":`a key outside this lab (${n.slice(0,12)}…)`}function w2(e){var o,i,a;const t=ro.events.find(c=>c.id===e.id),n=(i=(o=te.chain.transactions.get(e.id.slice(0,-2)))==null?void 0:o.inscription)==null?void 0:i.text,r=[["When",e.pending?"cued for the next beat":`beat ${e.beat}`],["Authorized by",e.parent?`${((a=se(e.parent))==null?void 0:a.name)??"an unknown inscription"}, whose inscription this event spent`:"nothing: a founding has no parent"],["Signed by",b2(e)],["Inscription",e.id],n&&["Body",n],(t==null?void 0:t.block)&&["Block",t.block]].filter(Boolean),s=t&&{id:t.id,status:t.status,height:t.height,block:t.block,parent:t.parent??null,metaprotocol:t.metaprotocol??null,contentType:t.contentType,sat:t.sat,location:t.location};return[$("div",{class:"ih"},$("p",{class:"eyebrow",text:`${e.op} · ${e.pending?"cued":`beat ${e.beat}`}`}),$("h3",{class:"it",text:Jf(e,de)}),$("div",{class:"chips"},$("span",{class:"chip",text:(t==null?void 0:t.protocol)??"?"}),$("span",{class:`chip ${e.ok?"ok":"bad"}`,text:e.ok?"applied":"rejected"})),!e.ok&&$("p",{class:"idesc",text:"The reducer rejected this event. It stays on the chain, but it does not change the tree."})),$("div",{class:"ib"},$("dl",{class:"fl"},r.map(Zr)),$("div",{class:"code"},$("p",{class:"code-h",text:"Metadata · CBOR, tag 5"}),$("pre",{text:Hc(e.meta)})),s&&$("div",{class:"code"},$("p",{class:"code-h",text:"Raw index entry"}),$("pre",{text:Hc(s)})))]}function x2(e){const t=s=>{var o;return((o=se(s))==null?void 0:o.name)??"a key outside this lab"},n=te.chain.transactions.get(e.txid),r=[["When",e.beat===null?"cued for the next beat":`beat ${e.beat}`],["From",e.kind==="mine"?"the beat's block reward (its coinbase)":`${t(e.from)}'s SegWit address${e.kind==="move"?", from before it graduated":""}`],["To",`${t(e.to)}'s ${e.kind==="move"?"new ":""}SegWit address`],["Amount",Ee(e.amount)],e.kind!=="mine"&&["Fee",`${e.fee} sats, retired: this toy chain pays no fees to miners`],e.change>0&&["Change",`${Ee(e.change)} back to ${t(e.from)}`],["Signed by",e.kind==="mine"?"nobody: a coinbase spends nothing":`${t(e.from)}'s SegWit key (BIP-143, SIGHASH_ALL)`],["Transaction",e.txid]].filter(Boolean);return[$("div",{class:"ih"},$("p",{class:"eyebrow",text:`${e.kind} · ${e.beat===null?"cued":`beat ${e.beat}`}`}),$("h3",{class:"it",text:Ad(e)}),$("div",{class:"chips"},$("span",{class:"chip",text:"test BTC"}),$("span",{class:`chip${e.beat===null?"":" ok"}`,text:e.beat===null?"cued":"confirmed"}))),$("div",{class:"ib"},$("dl",{class:"fl"},r.map(Zr)),n&&_r("Raw transaction",n.raw))]}function Ka(){const e=Fe(),t=M("beat"),n=se(I.holding);t.max=String(e),t.value=String(I.beat??e),t.disabled=e===0,M("beat-label").textContent=I.beat===null?`Now · beat ${e}`:`Beat ${I.beat} of ${e}`,M("replay").textContent=I.replay?"Stop":"Replay",M("replay").disabled=!n||e===0,M("to-now").disabled=I.beat===null,M("timeline-sub").textContent=(n==null?void 0:n.name)??"";const r=new Map,s=new Map([...te.chain.transactions.keys()].map((a,c)=>[a,c])),o=(a,c)=>r.set(a,[...r.get(a)??[],c]);for(const a of de.log)a.root&&a.root===I.holding&&o(a.pending?"cued":a.beat,{e:a,at:s.get(a.id.slice(0,-2))??0});for(const a of je.ledger)[a.to,a.from].some(c=>{var u;return c&&((u=se(c))==null?void 0:u.root)===I.holding})&&o(a.beat??"cued",{m:a,at:s.get(a.txid)??0});const i=[...r.keys()].sort((a,c)=>a==="cued"?-1:c==="cued"?1:c-a);if(!i.length)return M("timeline-list").replaceChildren($("li",{class:"wait",text:n?"Nothing yet.":"Found a holding to start its timeline."}));M("timeline-list").replaceChildren(...i.map(a=>{const c=a==="cued"?null:te.chain.blocks[a-1],u=I.beat!==null&&(a==="cued"||a>I.beat),f=I.beat!==null&&a===I.beat;return $("li",{class:`beat${u?" later":""}${f?" now":""}`},$("p",{class:"bh"},$("span",{class:"bn",text:a==="cued"?"Cued":`Beat ${a}`}),$("span",{class:"bt",text:c?e2(c.time):te.clock.tempo==="manual"?"waiting for Beat now":"landing on the next beat"})),$("ol",{class:"evs"},r.get(a).sort((l,d)=>l.at-d.at).map(({e:l,m:d})=>d?E2(d):v2(l))))}))}function v2(e){const[t,...n]=Jf(e,de).split(" ");return $("li",{},$("button",{type:"button",class:`ev${e.ok?"":" bad"}${e.id===I.event?" on":""}`,"aria-pressed":String(e.id===I.event),onclick:()=>Qr({event:e.id,node:e.node??I.node})},$("span",{class:"op",text:e.ok?t:`✕ ${t.replace(/:$/,"")}`})," ",$("span",{class:"es",text:n.join(" ")})))}const E2=e=>$("li",{},$("button",{type:"button",class:`ev money${e.txid===I.tx?" on":""}`,"aria-pressed":String(e.txid===I.tx),onclick:()=>Qr({tx:e.txid,node:e.to??I.node})},$("span",{class:"op",text:e.kind})," ",$("span",{class:"es",text:Ad(e)})));M("f-found").addEventListener("submit",async e=>{e.preventDefault();const t=e.currentTarget,n=ya(t.elements.name.value);if(!n)return Te("Name the holding: lowercase letters, digits and hyphens.",!0);await mr("found",null,{name:n},(r,s)=>(xd({holding:r,node:r}),`${n} is founded, ${s}.`))&&t.reset()});M("sample").addEventListener("click",async()=>{let e=null;Te("Rehearsing the yolopreneur tree over six beats…"),await gr(t=>{e=Qx(t)})&&(Qr({holding:e,node:e}),Te("Loaded the yolopreneur sample: six beats of history. Press Replay to watch it grow."))});M("f-birth").addEventListener("submit",async e=>{e.preventDefault();const t=e.currentTarget,n=se(I.node),r=ya(t.elements.name.value),s=t.elements.kind.value;if(!r)return Te("Name the child: lowercase letters, digits and hyphens.",!0);await mr("birth",n.id,{name:r,kind:s},(o,i)=>`${r} is born to ${n.name}, ${i}.`)&&(t.elements.name.value="")});M("f-award").addEventListener("submit",async e=>{e.preventDefault();const t=e.currentTarget,n=se(I.node),r=t.elements.to.value,s=ya(t.elements.skill.value),o=t.elements.belt.value;if(!s)return Te("Name the skill, for example launch.",!0);await mr("award",n.id,{to:r,skill:s,belt:o},(i,a)=>{var c;return`${(c=se(r))==null?void 0:c.name} holds a ${o} belt in ${s}, ${a}.`})&&(t.elements.skill.value="")});M("f-decide").addEventListener("submit",async e=>{e.preventDefault();const t=e.currentTarget,n=se(I.node),r=t.elements.title.value.trim(),s=t.elements.why.value.trim();if(!r)return Te("A decision needs a title.",!0);await mr("decide",n.id,{title:r,why:s},(o,i)=>`${n.name} decided “${r}”, ${i}.`)&&t.reset()});M("f-send").addEventListener("submit",async e=>{var a;e.preventDefault();const t=e.currentTarget,n=se(I.node),r=t.elements.to.value,s=Kx(t.elements.amount.value);if(s===null)return Te("Write an amount in test BTC, for example 1.5 (at most eight decimals).",!0);let o=null;if(!await gr(c=>{o=Xx(c,n.id,r,s)}))return;const i=je.ledger.find(c=>c.txid===o);Te(`${n.name} sent ${Ee(s)} to ${(a=se(r))==null?void 0:a.name}, ${i!=null&&i.beat?`at beat ${i.beat}`:"cued for the next beat"}.`),t.elements.amount.value=""});M("send-max").addEventListener("click",()=>{const e=se(I.node),t=e&&vt(te.keys,de,e);t&&(M("send-amount").value=dd(Ra(te.chain.coins(t.script))))});M("f-graduate").addEventListener("submit",async e=>{e.preventDefault();const t=se(I.node),n=se(t.parent);await mr("graduate",n.id,{of:t.id},(r,s)=>`${t.name} graduates from ${n.name}, ${s}. Its edge is adopted now.`)});M("f-close").addEventListener("submit",async e=>{e.preventDefault();const t=se(I.node);if(I.closing!==t.id)return I.closing=t.id,_o(),M("close-go").focus();I.closing=null,await mr("close",t.id,{},(n,r)=>`${t.name} is closed, ${r}.`)});M("close-keep").addEventListener("click",()=>{I.closing=null,_o(),M("close-go").focus()});for(const e of document.querySelectorAll("[data-verb]"))e.addEventListener("click",()=>{I.verb=e.dataset.verb,I.closing=null,_o()});for(const e of document.querySelectorAll("[data-tempo]"))e.addEventListener("click",async()=>{const t=e.dataset.tempo,n=/^\d+$/.test(t)?Number(t):t;await gr(r=>Rx(r,n,Date.now(),So(r,I.holding)))&&Te(t==="each"?"Each act is its own beat.":t==="manual"?"Acts are cued until you press Beat now.":`Acts are cued and land together on the next beat, at most ${t} seconds after the first.`)});M("beat-now").addEventListener("click",()=>Ed(e=>{ln(e,So(e,I.holding))}));setInterval(()=>{Sd();const{tempo:e,nextAt:t}=te.clock;I.busy||document.hidden||typeof e!="number"||!te.chain.mempool.length||t&&Date.now()Hx(n,Date.now(),So(n,I.holding)))},1e3);addEventListener("storage",e=>{(e.key===xo||e.key===null)&&vd()});function es(){I.replay&&(clearInterval(I.replay),I.replay=null,Ka())}function S2(){const e=se(I.holding);if(!(!e||!Fe())){if(so(typeof e.born=="number"?e.born:Fe()),I.beat===null)return Te("Nothing to replay yet: this holding has one beat of history.");I.replay=setInterval(()=>{(I.beat===null||I.beat+1>=Fe())&&es(),so(I.beat===null?Fe():I.beat+1)},800),Ka()}}M("beat").addEventListener("input",e=>{es(),so(Number(e.target.value))});M("replay").addEventListener("click",()=>I.replay?es():S2());for(const e of["to-now","past-now"])M(e).addEventListener("click",()=>{es(),so(Fe())});const ri=["system","light","dark"],Bd=()=>{M("theme").textContent=`Theme: ${document.documentElement.dataset.theme??"system"}`};M("theme").addEventListener("click",()=>{const e=ri[(ri.indexOf(document.documentElement.dataset.theme??"system")+1)%ri.length];e==="system"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e;try{e==="system"?localStorage.removeItem("orgchain-theme"):localStorage.setItem("orgchain-theme",e)}catch{}Bd()});function Od(e,t,n){const r=M("confirm");r.replaceChildren($("span",{text:e}),$("button",{type:"button",class:"btn sm danger",text:t,onclick:()=>{r.hidden=!0,n()}}),$("button",{type:"button",class:"btn sm",text:"Cancel",onclick:()=>{r.hidden=!0}})),r.hidden=!1,r.querySelector("button").focus()}const k2={read:()=>{try{return Na()}catch{return Jr()}}};async function Id(e,t){es(),await gr(n=>{Object.assign(n,e())},k2)&&(Object.assign(I,{holding:null,node:null,event:null,tx:null,beat:null,closing:null}),Ha(),Te(t))}M("save").addEventListener("click",()=>{const e=$("a",{href:URL.createObjectURL(new Blob([ld(te)],{type:"application/json"})),download:`orgchain-lab-${new Date().toISOString().slice(0,10)}.json`});document.body.append(e),e.click(),e.remove(),setTimeout(()=>URL.revokeObjectURL(e.href),5e3),Te("Saved a backup of this lab, test wallet included. Load it in any browser to carry on.")});M("load").addEventListener("click",()=>M("load-file").click());M("load-file").addEventListener("change",async e=>{var r;const t=(r=e.target.files)==null?void 0:r[0];if(e.target.value="",!t)return;let n;try{n=fd(await t.text())}catch(s){return Te(`${t.name} is not an Orgchain lab: ${s.message}`,!0)}Od(`Replace this browser's lab with ${t.name}?`,"Replace",()=>Id(()=>n,`Loaded ${t.name}.`))});M("reset").addEventListener("click",()=>Od("Erase this browser's lab: every holding, the chain and the test wallet?","Erase",()=>Id(Jr,"Erased. This is a fresh lab.")));Bd();vd(); diff --git a/ventures/lineage/orgchain/assets/index-CUVkz3ou.js b/ventures/lineage/orgchain/assets/index-CUVkz3ou.js deleted file mode 100644 index 7fc5541..0000000 --- a/ventures/lineage/orgchain/assets/index-CUVkz3ou.js +++ /dev/null @@ -1,2063 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const Ea=5e9;function wc(e,t,n){const r=[];for(const[s,o]of e){const i=o-s;if(t>=i){t-=i;continue}const a=Math.min(n,i-t);if(a&&r.push([s+t,s+t+a]),n-=a,t=0,!n)break}return r}function xc(e,t){var n;return(n=wc(e,t,1)[0])==null?void 0:n[0]}function as(e,t){let n=0;for(const[r,s]of e){if(t>=r&&ti.ranges);let o=0;return e.vout.map(i=>{const a=wc(s,o,Number(i.value));return o+=Number(i.value),a})}function Vo(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function Gl(e){if(typeof e!="boolean")throw new Error(`Expected boolean, not ${e}`)}function Ec(e,...t){if(!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new TypeError(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Yl(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Vo(e.outputLen),Vo(e.blockLen)}function Wl(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Xl(e,t){Ec(e);const n=t.outputLen;if(e.lengthnew DataView(e.buffer,e.byteOffset,e.byteLength),at=(e,t)=>e<<32-t|e>>>t,Ql=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Ql)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ed(e){if(typeof e!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function Sc(e){if(typeof e=="string"&&(e=ed(e)),!(e instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof e})`);return e}let td=class{clone(){return this._cloneInto()}};function _c(e){const t=r=>e().update(Sc(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function nd(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,a,r)}let rd=class extends td{constructor(t,n,r,s){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ho(this.buffer)}update(t){lo.exists(this);const{view:n,buffer:r,blockLen:s}=this;t=Sc(t);const o=t.length;for(let i=0;is-i&&(this.process(r,0),i=0);for(let f=i;fl.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;fe&t^~e&n,od=(e,t,n)=>e&t^e&n^t&n,id=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]),It=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Tt=new Uint32Array(64);let kc=class extends rd{constructor(){super(64,32,8,!1),this.A=It[0]|0,this.B=It[1]|0,this.C=It[2]|0,this.D=It[3]|0,this.E=It[4]|0,this.F=It[5]|0,this.G=It[6]|0,this.H=It[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[t,n,r,s,o,i,a,c]}set(t,n,r,s,o,i,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,n){for(let f=0;f<16;f++,n+=4)Tt[f]=t.getUint32(n,!1);for(let f=16;f<64;f++){const d=Tt[f-15],h=Tt[f-2],m=at(d,7)^at(d,18)^d>>>3,y=at(h,17)^at(h,19)^h>>>10;Tt[f]=y+Tt[f-7]+m+Tt[f-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:u,H:l}=this;for(let f=0;f<64;f++){const d=at(a,6)^at(a,11)^at(a,25),h=l+d+sd(a,c,u)+id[f]+Tt[f]|0,y=(at(r,2)^at(r,13)^at(r,22))+od(r,s,o)|0;l=u,u=c,c=a,a=i+h|0,i=o,o=s,s=r,r=h+y|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,s,o,i,a,c,u,l)}roundClean(){Tt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},ad=class extends kc{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 Mo=_c(()=>new kc);_c(()=>new ad);function cd(e,t){if(e.length>t)throw new TypeError(`Data is larger than array size: ${e.length} > ${t}`)}function ud(e){if(e.match(/[^a-fA-f0-9]/)!==null)throw new TypeError("Invalid characters in hex string: "+e);if(e.length%2!==0)throw new Error(`Length of hex string is invalid: ${e.length}`)}function fd(e){if(e>Number.MAX_SAFE_INTEGER)throw new TypeError("Number exceeds safe bounds!")}const{getRandomValues:ld}=crypto??globalThis.crypto??window.crypto;function dd(e=32){if(typeof ld=="function")return crypto.getRandomValues(new Uint8Array(e));throw new Error("Crypto module missing getRandomValues!")}function hd(e,t,n="be"){t===void 0&&(t=e.length),cd(e,t);const r=new Uint8Array(t).fill(0),s=n==="be"?0:t-e.length;return r.set(e,s),r}function Ac(e){let t,n=0;const r=e.reduce((o,i)=>o+i.length,0),s=new Uint8Array(r);for(t=0;t0||(i.length^a)>0?"":"1";c in o||u>0;)l=o[c],l=l>0?l*256+u:u,u=l/s|0,o[c]=l%s,c++;for(;c-- >0;)i+=r[o[c]];return n&&i.length%4>0?i+"=".repeat(4-i.length%4):i}function yd(e,t){const n=$c(t),r=n.length,s=[],o=[];e=e.replace("=","");let i,a=0,c,u;for(i=0;i0||(o.length^i)>0||o.push(0);a in s||c>0;)u=s[a],u=u>0?u*r+c:c,c=u>>8,s[a]=u%256,a++}for(;a-- >0;)o.push(s[a]);return new Uint8Array(o)}function Bc(e){return Mo(Mo(e))}function bd(e){const t=Bc(e);return Ac([e,t.slice(0,4)])}function wd(e){const t=e.slice(0,-4),n=e.slice(-4);if(Bc(t).slice(0,4).toString()!==n.toString())throw new Error("Invalid checksum!");return t}const Sa={encode:md,decode:yd},Oc={encode:e=>{const t=bd(e);return Sa.encode(t,"base58")},decode:e=>{const t=Sa.decode(e,"base58");return wd(t)}},Ic="qpzry9x8gf2tvdw0s3jn54khce6mua7l",xd=[996825010,642813549,513874426,1027748829,705979059],gs=[{version:0,name:"bech32",const:1},{version:1,name:"bech32m",const:734539939}];function Tc(e){let t=1;for(let n=0;n>25;t=(t&33554431)<<5^e[n];for(let s=0;s<5;++s)(r>>s&1)!==0&&(t^=xd[s])}return t}function Cc(e){const t=[];let n;for(n=0;n>5);for(t.push(0),n=0;n>5*(5-i)&31);return o}function Uc(e,t,n,r=!0){const s=[];let o=0,i=0;const a=(1<>t>0)throw new Error("Failed to perform base conversion. Invalid value: "+String(u));for(o=(o<=n;)i-=n,s.push(o>>i&a)}if(r)i>0&&s.push(o<=t||(o<0)throw new Error("Failed to perform base conversion. Invalid Size!");return s}function Sd(e,t,n){const r=t.concat(Ed(e,t,n));let s=e+"1";for(let o=0;oo.version===t[0])??gs[0];if(!vd(r,t,s))throw new Error("Checksum verification failed!");return[r,t.slice(0,t.length-6)]}function _d(e){let t,n,r=!1,s=!1;for(t=0;t126)return!1;n>=97&&n<=122&&(r=!0),n>=65&&n<=90&&(s=!0)}return!(r&&s)}function kd(e){const t=e.lastIndexOf("1");return!(t<1||t+7>e.length||e.length>90)}function Ad(e,t="bc",n=0){const r=[n,...Uc([...e],8,5)],s=gs.find(i=>i.version===n)??gs[0],o=Sd(t,r,s);return Nc(o),o}function Nc(e){e=e.toLowerCase();const t=e.split("1",1)[0],[n,r]=Pc(e),s=Uc(r.slice(1),5,8,!1),o=s.length;switch(!0){case t!==n:throw new Error("Returned hrp string is invalid.");case(s===null||o<2||o>40):throw new Error("Decoded string is invalid or out of spec.");case r[0]>16:throw new Error("Returned version bit is out of range.");default:return Uint8Array.from(s)}}function $d(e){e=e.toLowerCase();const[t,n]=Pc(e);return n[0]}const Lc={encode:Ad,decode:Nc,version:$d},Rc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Hc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",Bd=new TextEncoder;function jc(e,t=!1,n=!0){typeof e=="string"&&(e=Bd.encode(e));const r=t?Hc:Rc;let s="",o=0,i=0;for(let a=0;a=6;)o-=6,s+=r[i>>o&63];if(o>0)for(i<<=6-o,s+=r[i&63];o<6;)s+=n?"=":"",o+=2;return s}function Dc(e,t=!1){const n=t||e.includes("-")||e.includes("_")?Hc.split(""):Rc.split("");e=e.replace(/=+$/,"");const r=e.split("");let s=0,o=0;const i=[];for(let a=0;a=8&&(s-=8,i.push(o>>>s&255))}return new Uint8Array(i)}const Kc={encode:jc,decode:Dc},Zc={encode:e=>jc(e,!0,!1),decode:e=>Dc(e,!0)},Od=BigInt(0),Id=BigInt(255),Vc=BigInt(256);function Td(e){if(e<=0xffn)return 1;if(e<=0xffffn)return 2;if(e<=0xffffffffn)return 4;if(e<=0xffffffffffffffffn)return 8;if(e<=0xffffffffffffffffffffffffffffffffn)return 16;if(e<=0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn)return 32;throw new TypeError("Must specify a fixed buffer size for bigints greater than 32 bytes.")}function Cd(e,t,n="be"){t===void 0&&(t=Td(e));const r=n==="le",s=new ArrayBuffer(t),o=new DataView(s);let i=r?0:t-1;for(;e>Od;){const a=e&Id,c=Number(a);r?o.setUint8(i++,c):o.setUint8(i--,c),e=(e-a)/Vc}return new Uint8Array(s)}function Ud(e){let t=BigInt(0);for(let n=e.length-1;n>=0;n--)t=t*Vc+BigInt(e[n]);return BigInt(t)}function Pd(e){const t=e.split("").map(Number);if(t.length%8!==0)throw new Error(`Binary array is invalid length: ${e.length}`);const n=new Uint8Array(t.length/8);for(let r=0,s=0;r255)throw new Error(`Invalid byte value: ${r}. Byte values must be between 0 and 255.`);for(let s=7;s>=0;s--,n++)t[n]=r>>s&1}return t.join("")}function Ld(e){if(e<=255)return 1;if(e<=65535)return 2;if(e<=4294967295)return 4;throw new TypeError("Numbers larger than 4 bytes must specify a fixed size!")}function Rd(e,t,n="be"){t===void 0&&(t=Ld(e));const r=n==="le",s=new ArrayBuffer(t),o=new DataView(s);let i=r?0:t-1;for(;e>0;){const a=e&255;r?o.setUint8(i++,e):o.setUint8(i--,e),e=(e-a)/256}return new Uint8Array(s)}function Hd(e){let t=0;for(let n=e.length-1;n>=0;n--)t=t*256+e[n],fd(t);return t}const jd=new TextEncoder,Dd=new TextDecoder;function Ei(e){return jd.encode(e)}function po(e){return Dd.decode(e)}function Kd(e,t){ud(e);const n=e.length/2;if(t===void 0&&(t=n),n>t)throw new TypeError(`Hex string is larger than array size: ${n} > ${t}`);return t}function Zd(e,t,n="le"){t=Kd(e,t);const r=n==="le",s=new ArrayBuffer(t),o=new DataView(s);let i=r?0:t-1;for(let a=0;atypeof r=="bigint"?`${r}n`:r);return Ei(t)}function qd(e,t,n){if(e instanceof ArrayBuffer)return new Uint8Array(e);if(e instanceof Uint8Array)return hd(e,t,n);if(typeof e=="string")return Zd(e,t,n);if(typeof e=="bigint")return Cd(e,t,n);if(typeof e=="number")return Rd(e,t,n);if(typeof e=="boolean")return Uint8Array.of(e?1:0);throw TypeError("Unsupported format:"+typeof e)}var X;let _=(X=class extends Uint8Array{static random(t=32){const n=dd(t);return new X(n,t)}constructor(t,n,r){const s=qd(t,n,r);super(s)}get arr(){return[...this]}get num(){return this.toNum()}get big(){return this.toBig()}get str(){return this.toStr()}get hex(){return this.toHex()}get raw(){return new Uint8Array(this)}get bin(){return this.toBin()}get b58chk(){return this.tob58chk()}get base64(){return this.toBase64()}get b64url(){return this.toB64url()}get digest(){return this.toHash()}get id(){return this.toHash().hex}get stream(){return new Jn(this)}toNum(t="be"){const n=t==="be"?this.reverse():this;return Hd(n)}toBin(){return Nd(this)}toBig(t="be"){const n=t==="be"?this.reverse():this;return Ud(n)}toHash(){const t=Mo(this);return new X(t)}toJson(){const t=po(this);return JSON.parse(t)}toBech32(t,n=0){return Lc.encode(this,t,n)}toStr(){return po(this)}toHex(){return Vd(this)}toBytes(){return new Uint8Array(this)}tob58chk(){return Oc.encode(this)}toBase64(){return Kc.encode(this)}toB64url(){return Zc.encode(this)}prepend(t){return X.join([X.bytes(t),this])}append(t){return X.join([this,X.bytes(t)])}slice(t,n){const r=new Uint8Array(this).slice(t,n);return new X(r)}subarray(t,n){const r=new Uint8Array(this).subarray(t,n);return new X(r)}reverse(){const t=new Uint8Array(this).reverse();return new X(t)}write(t,n){const r=X.bytes(t);this.set(r,n)}prefixSize(t){const n=X.varInt(this.length,t);return X.join([n,this])}static from(t){return new X(Uint8Array.from(t))}static of(...t){return new X(Uint8Array.of(...t))}static join(t){const n=t.map(s=>X.bytes(s)),r=Ac(n);return new X(r)}static varInt(t,n){if(t<253)return X.num(t,1);if(t<65536)return X.of(253,...X.num(t,2,n));if(t<4294967296)return X.of(254,...X.num(t,4,n));if(BigInt(t)<0x10000000000000000n)return X.of(255,...X.num(t,8,n));throw new Error(`Value is too large: ${t}`)}},X.num=zd,X.big=Gd,X.bin=Fd,X.raw=Yd,X.str=Wd,X.hex=Xd,X.bytes=Jd,X.json=Qd,X.base64=eh,X.b64url=th,X.bech32=nh,X.b58chk=rh,X.encode=Ei,X.decode=po,X);function zd(e,t,n){return new _(e,t,n)}function Fd(e,t,n){return new _(Pd(e),t,n)}function Gd(e,t,n){return new _(e,t,n)}function Yd(e,t,n){return new _(e,t,n)}function Wd(e,t,n){return new _(Ei(e),t,n)}function Xd(e,t,n){return new _(e,t,n)}function Jd(e,t,n){return new _(e,t,n)}function Qd(e){return new _(Md(e))}function eh(e){return new _(Kc.decode(e))}function th(e){return new _(Zc.decode(e))}function nh(e){return new _(Lc.decode(e))}function rh(e){return new _(Oc.decode(e))}let Jn=class{constructor(t){this.data=_.bytes(t),this.size=this.data.length}peek(t){if(t>this.size)throw new Error(`Size greater than stream: ${t} > ${this.size}`);return new _(this.data.slice(0,t))}read(t){t=t??this.readSize();const n=this.peek(t);return this.data=this.data.slice(t),this.size=this.data.length,n}readSize(t){const n=this.read(1).num;switch(!0){case(n>=0&&n<253):return n;case n===253:return this.read(2).toNum(t);case n===254:return this.read(4).toNum(t);case n===255:return this.read(8).toNum(t);default:throw new Error(`Varint is out of range: ${n}`)}}};function Tr(e,t){const n=_.bytes(e);if(n.length!==t)throw new Error(`Invalid input size: ${n.hex} !== ${t}`)}function Ie(e,t){if(t)throw new Error(e);return!1}function cs(e,...t){const n=_.str(e).digest.raw,r=t.map(s=>_.bytes(s));return _.join([n,n,_.join(r)]).digest}const Mc={OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_SUCCESS80:80,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_SUCCESS98:98,OP_IF:99,OP_NOTIF:100,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_SUCCESS126:126,OP_SUCCESS127:127,OP_SUCCESS128:128,OP_SUCCESS129:129,OP_SIZE:130,OP_SUCCESS131:131,OP_SUCCESS132:132,OP_SUCCESS133:133,OP_SUCCESS134:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_SUCCESS137:137,OP_SUCCESS138:138,OP_1ADD:139,OP_1SUB:140,OP_SUCCESS141:141,OP_SUCCESS142:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_SUCCESS149:149,OP_SUCCESS150:150,OP_SUCCESS151:151,OP_SUCCESS152:152,OP_SUCCESS153:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_SUCCESS187:187,OP_SUCCESS188:188,OP_SUCCESS189:189,OP_SUCCESS190:190,OP_SUCCESS191:191,OP_SUCCESS192:192,OP_SUCCESS193:193,OP_SUCCESS194:194,OP_SUCCESS195:195,OP_SUCCESS196:196,OP_SUCCESS197:197,OP_SUCCESS198:198,OP_SUCCESS199:199,OP_SUCCESS200:200,OP_SUCCESS201:201,OP_SUCCESS202:202,OP_SUCCESS203:203,OP_SUCCESS204:204,OP_SUCCESS205:205,OP_SUCCESS206:206,OP_SUCCESS207:207,OP_SUCCESS208:208,OP_SUCCESS209:209,OP_SUCCESS210:210,OP_SUCCESS211:211,OP_SUCCESS212:212,OP_SUCCESS213:213,OP_SUCCESS214:214,OP_SUCCESS215:215,OP_SUCCESS216:216,OP_SUCCESS217:217,OP_SUCCESS218:218,OP_SUCCESS219:219,OP_SUCCESS220:220,OP_SUCCESS221:221,OP_SUCCESS222:222,OP_SUCCESS223:223,OP_SUCCESS224:224,OP_SUCCESS225:225,OP_SUCCESS226:226,OP_SUCCESS227:227,OP_SUCCESS228:228,OP_SUCCESS229:229,OP_SUCCESS230:230,OP_SUCCESS231:231,OP_SUCCESS232:232,OP_SUCCESS233:233,OP_SUCCESS234:234,OP_SUCCESS235:235,OP_SUCCESS236:236,OP_SUCCESS237:237,OP_SUCCESS238:238,OP_SUCCESS239:239,OP_SUCCESS240:240,OP_SUCCESS241:241,OP_SUCCESS242:242,OP_SUCCESS243:243,OP_SUCCESS244:244,OP_SUCCESS245:245,OP_SUCCESS246:246,OP_SUCCESS247:247,OP_SUCCESS248:248,OP_SUCCESS249:249,OP_SUCCESS250:250,OP_SUCCESS251:251,OP_SUCCESS252:252,OP_SUCCESS253:253,OP_SUCCESS254:254};function sh(e){if(e>186&&e<255)return"OP_SUCCESS"+String(e);for(const[t,n]of Object.entries(Mc))if(n===e)return t;throw new Error("OPCODE not found:"+String(e))}function oh(e){for(const[t,n]of Object.entries(Mc))if(t===e)return Number(n);throw new Error("OPCODE not found:"+e)}function ih(e){switch(!0){case e===0:return"opcode";case(e>=1&&e<=75):return"varint";case e===76:return"pushdata1";case e===77:return"pushdata2";case e===78:return"pushdata4";case e<=254:return"opcode";default:throw new Error(`Invalid word range: ${e}`)}}function ah(e){const r=[];switch(!0){case typeof e!="number":return!1;case e===0:return!0;case r.includes(e):return!1;case(750?_.join(t):new Uint8Array}function ch(e){let t=new Uint8Array;if(typeof e=="string"){if(e.startsWith("OP_"))return _.num(oh(e),1);Ot(e)?t=_.hex(e):t=_.str(e)}else t=_.bytes(e);if(t.length===1)return t[0]!==0&&t[0]<=16?(t[0]+=80,t):(t[0]>128&&t[0]<=255&&(t=new Uint8Array([t[0],0])),_.join([_a(t.length),t]));if(t.length>ms){const n=uh(t);return zc(n)}else return _.join([_a(t.length),t])}function _a(e){const t=_.num(76,1),n=_.num(77,1);switch(!0){case e<=75:return _.num(e);case(e>75&&e<256):return _.join([t,_.num(e,1,"le")]);case(e>=256&&e<=ms):return _.join([n,_.num(e,2,"le")]);default:throw new Error("Invalid word size:"+e.toString())}}function uh(e){const t=[],n=new Jn(e);for(;n.size>ms;)t.push(n.read(ms));return t.push(n.read(n.size)),t}function Si(e,t=!1){let n=_.bytes(e);if(t){const s=n.stream.readSize("le");if(n=n.slice(1),n.length!==s)throw new Error(`Varint does not match stream size: ${s} !== ${n.length}`)}return fh(n)}function fh(e){const t=new Jn(e),n=[],r=t.size;let s,o,i,a=0;for(;a0&&!t.includes(e.length))throw new TypeError(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function mh(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");qo(e.outputLen),qo(e.blockLen)}function yh(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function bh(e,t){Fc(e);const n=t.outputLen;if(e.lengthnew DataView(e.buffer,e.byteOffset,e.byteLength),ct=(e,t)=>e<<32-t|e>>>t,xh=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!xh)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function vh(e){if(typeof e!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function _i(e){if(typeof e=="string"&&(e=vh(e)),!(e instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof e})`);return e}function Eh(...e){if(!e.every(r=>r instanceof Uint8Array))throw new Error("Uint8Array list expected");if(e.length===1)return e[0];const t=e.reduce((r,s)=>r+s.length,0),n=new Uint8Array(t);for(let r=0,s=0;re().update(_i(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Sh(e=32){if(go&&typeof go.getRandomValues=="function")return go.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function _h(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,a,r)}let kh=class extends Gc{constructor(t,n,r,s){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=mo(this.buffer)}update(t){an.exists(this);const{view:n,buffer:r,blockLen:s}=this;t=_i(t);const o=t.length;for(let i=0;is-i&&(this.process(r,0),i=0);for(let f=i;fl.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;fe&t^~e&n,$h=(e,t,n)=>e&t^e&n^t&n,Bh=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]),Ct=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ut=new Uint32Array(64);let Wc=class extends kh{constructor(){super(64,32,8,!1),this.A=Ct[0]|0,this.B=Ct[1]|0,this.C=Ct[2]|0,this.D=Ct[3]|0,this.E=Ct[4]|0,this.F=Ct[5]|0,this.G=Ct[6]|0,this.H=Ct[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[t,n,r,s,o,i,a,c]}set(t,n,r,s,o,i,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,n){for(let f=0;f<16;f++,n+=4)Ut[f]=t.getUint32(n,!1);for(let f=16;f<64;f++){const d=Ut[f-15],h=Ut[f-2],m=ct(d,7)^ct(d,18)^d>>>3,y=ct(h,17)^ct(h,19)^h>>>10;Ut[f]=y+Ut[f-7]+m+Ut[f-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:u,H:l}=this;for(let f=0;f<64;f++){const d=ct(a,6)^ct(a,11)^ct(a,25),h=l+d+Ah(a,c,u)+Bh[f]+Ut[f]|0,y=(ct(r,2)^ct(r,13)^ct(r,22))+$h(r,s,o)|0;l=u,u=c,c=a,a=i+h|0,i=o,o=s,s=r,r=h+y|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,s,o,i,a,c,u,l)}roundClean(){Ut.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Oh=class extends Wc{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 Xc=Yc(()=>new Wc);Yc(()=>new Oh);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ih=BigInt(0),ki=BigInt(1),Th=BigInt(2),Ys=e=>e instanceof Uint8Array,Ch=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Dn(e){if(!Ys(e))throw new Error("Uint8Array expected");let t="";for(let n=0;nKn(e.toString(16).padStart(t*2,"0")),Qc=(e,t)=>Nn(e,t).reverse(),Uh=e=>Kn(Jc(e));function Fe(e,t,n){let r;if(typeof t=="string")try{r=Kn(t)}catch(o){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${o}`)}else if(Ys(t))r=Uint8Array.from(t);else throw new Error(`${e} must be hex string or Uint8Array`);const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(`${e} expected ${n} bytes, got ${s}`);return r}function Ye(...e){const t=new Uint8Array(e.reduce((r,s)=>r+s.length,0));let n=0;return e.forEach(r=>{if(!Ys(r))throw new Error("Uint8Array expected");t.set(r,n),n+=r.length}),t}function Ph(e,t){if(e.length!==t.length)return!1;for(let n=0;n0n;e>>=ki,t+=1);return t}const Lh=(e,t)=>e>>BigInt(t)&1n,Rh=(e,t,n)=>e|(n?ki:Ih)<(Th<new Uint8Array(e),ka=e=>Uint8Array.from(e);function eu(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=yo(e),s=yo(e),o=0;const i=()=>{r.fill(1),s.fill(0),o=0},a=(...f)=>n(s,r,...f),c=(f=yo())=>{s=a(ka([0]),f),r=a(),f.length!==0&&(s=a(ka([1]),f),r=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let f=0;const d=[];for(;f{i(),c(f);let h;for(;!(h=d(u()));)c();return i(),h}}const Hh={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function Qn(e,t,n={}){const r=(s,o,i)=>{const a=Hh[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);const c=e[s];if(!(i&&c===void 0)&&!a(c,e))throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${o}`)};for(const[s,o]of Object.entries(t))r(s,o,!1);for(const[s,o]of Object.entries(n))r(s,o,!0);return e}var jh=Object.freeze({__proto__:null,bitGet:Lh,bitLen:Nh,bitMask:Bi,bitSet:Rh,bytesToHex:Dn,bytesToNumberBE:Gt,bytesToNumberLE:$i,concatBytes:Ye,createHmacDrbg:eu,ensureBytes:Fe,equalBytes:Ph,hexToBytes:Kn,hexToNumber:Ai,numberToBytesBE:Nn,numberToBytesLE:Qc,numberToHexUnpadded:Jc,numberToVarBytesBE:Uh,utf8ToBytes:Ws,validateObject:Qn});/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ae=BigInt(0),Ee=BigInt(1),rn=BigInt(2),Dh=BigInt(3),zo=BigInt(4),Aa=BigInt(5),$a=BigInt(8);BigInt(9);BigInt(16);function Te(e,t){const n=e%t;return n>=Ae?n:t+n}function Kh(e,t,n){if(n<=Ae||t 0");if(n===Ee)return Ae;let r=Ee;for(;t>Ae;)t&Ee&&(r=r*e%n),e=e*e%n,t>>=Ee;return r}function qe(e,t,n){let r=e;for(;t-- >Ae;)r*=r,r%=n;return r}function Fo(e,t){if(e===Ae||t<=Ae)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=Te(e,t),r=t,s=Ae,o=Ee;for(;n!==Ae;){const a=r/n,c=r%n,u=s-o*a;r=n,n=c,s=o,o=u}if(r!==Ee)throw new Error("invert: does not exist");return Te(s,t)}function Zh(e){const t=(e-Ee)/rn;let n,r,s;for(n=e-Ee,r=0;n%rn===Ae;n/=rn,r++);for(s=rn;s(r[s]="function",r),t);return Qn(e,n)}function qh(e,t,n){if(n 0");if(n===Ae)return e.ONE;if(n===Ee)return t;let r=e.ONE,s=t;for(;n>Ae;)n&Ee&&(r=e.mul(r,s)),s=e.sqr(s),n>>=Ee;return r}function zh(e,t){const n=new Array(t.length),r=t.reduce((o,i,a)=>e.is0(i)?o:(n[a]=o,e.mul(o,i)),e.ONE),s=e.inv(r);return t.reduceRight((o,i,a)=>e.is0(i)?o:(n[a]=e.mul(o,n[a]),e.mul(o,i)),s),n}function Oi(e,t){const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function nu(e,t,n=!1,r={}){if(e<=Ae)throw new Error(`Expected Fp ORDER > 0, got ${e}`);const{nBitLength:s,nByteLength:o}=Oi(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const i=Vh(e),a=Object.freeze({ORDER:e,BITS:s,BYTES:o,MASK:Bi(s),ZERO:Ae,ONE:Ee,create:c=>Te(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return Ae<=c&&cc===Ae,isOdd:c=>(c&Ee)===Ee,neg:c=>Te(-c,e),eql:(c,u)=>c===u,sqr:c=>Te(c*c,e),add:(c,u)=>Te(c+u,e),sub:(c,u)=>Te(c-u,e),mul:(c,u)=>Te(c*u,e),pow:(c,u)=>qh(a,c,u),div:(c,u)=>Te(c*Fo(u,e),e),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>Fo(c,e),sqrt:r.sqrt||(c=>i(a,c)),invertBatch:c=>zh(a,c),cmov:(c,u,l)=>l?u:c,toBytes:c=>n?Qc(c,o):Nn(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return n?$i(c):Gt(c)}});return Object.freeze(a)}function Fh(e,t,n=!1){e=Fe("privateHash",e);const r=e.length,s=Oi(t).nByteLength+8;if(s<24||r1024)throw new Error(`hashToPrivateScalar: expected ${s}-1024 bytes of input, got ${r}`);const o=n?$i(e):Gt(e);return Te(o,t-Ee)+Ee}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Gh=BigInt(0),bo=BigInt(1);function Yh(e,t){const n=(s,o)=>{const i=o.negate();return s?i:o},r=s=>{const o=Math.ceil(t/s)+1,i=2**(s-1);return{windows:o,windowSize:i}};return{constTimeNegate:n,unsafeLadder(s,o){let i=e.ZERO,a=s;for(;o>Gh;)o&bo&&(i=i.add(a)),a=a.double(),o>>=bo;return i},precomputeWindow(s,o){const{windows:i,windowSize:a}=r(o),c=[];let u=s,l=u;for(let f=0;f>=h,p>c&&(p-=d,i+=bo);const g=y,x=y+Math.abs(p)-1,w=m%2!==0,B=p<0;p===0?l=l.add(n(w,o[g])):u=u.add(n(B,o[x]))}return{p:u,f:l}},wNAFCached(s,o,i,a){const c=s._WINDOW_SIZE||1;let u=o.get(s);return u||(u=this.precomputeWindow(s,c),c!==1&&o.set(s,a(u))),this.wNAF(c,u,i)}}}function ru(e){return tu(e.Fp),Qn(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Oi(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Wh(e){const t=ru(e);Qn(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:s}=t;if(n){if(!r.eql(s,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({...t})}const{bytesToNumberBE:Xh,hexToBytes:Jh}=jh,cn={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(e){const{Err:t}=cn;if(e.length<2||e[0]!==2)throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(r[0]===0&&r[1]<=127)throw new t("Invalid signature integer: trailing length");return{d:Xh(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=cn,n=typeof e=="string"?Jh(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:s,l:o}=cn._parseInt(n.subarray(2)),{d:i,l:a}=cn._parseInt(o);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:i}},hexFromSig(e){const t=u=>Number.parseInt(u[0],16)>=8?"00"+u:u,n=u=>{const l=u.toString(16);return l.length&1?`0${l}`:l},r=t(n(e.s)),s=t(n(e.r)),o=r.length/2,i=s.length/2,a=n(o),c=n(i);return`30${n(i+o+4)}02${c}${s}02${a}${r}`}},We=BigInt(0),Se=BigInt(1),xt=BigInt(2),ys=BigInt(3),Ba=BigInt(4);function Qh(e){const t=Wh(e),{Fp:n}=t,r=t.toBytes||((m,y,p)=>{const g=y.toAffine();return Ye(Uint8Array.from([4]),n.toBytes(g.x),n.toBytes(g.y))}),s=t.fromBytes||(m=>{const y=m.subarray(1),p=n.fromBytes(y.subarray(0,n.BYTES)),g=n.fromBytes(y.subarray(n.BYTES,2*n.BYTES));return{x:p,y:g}});function o(m){const{a:y,b:p}=t,g=n.sqr(m),x=n.mul(g,m);return n.add(n.add(x,n.mul(m,y)),p)}function i(m){return typeof m=="bigint"&&Wen.eql(w,n.ZERO);return x(p)&&x(g)?f.ZERO:new f(p,g,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(y){const p=n.invertBatch(y.map(g=>g.pz));return y.map((g,x)=>g.toAffine(p[x])).map(f.fromAffine)}static fromHex(y){const p=f.fromAffine(s(Fe("pointHex",y)));return p.assertValidity(),p}static fromPrivateKey(y){return f.BASE.multiply(c(y))}_setWindowSize(y){this._WINDOW_SIZE=y,u.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:y,y:p}=this.toAffine();if(!n.isValid(y)||!n.isValid(p))throw new Error("bad point: x or y not FE");const g=n.sqr(p),x=o(y);if(!n.eql(g,x))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y}=this.toAffine();if(n.isOdd)return!n.isOdd(y);throw new Error("Field doesn't support isOdd")}equals(y){l(y);const{px:p,py:g,pz:x}=this,{px:w,py:B,pz:A}=y,I=n.eql(n.mul(p,A),n.mul(w,x)),P=n.eql(n.mul(g,A),n.mul(B,x));return I&&P}negate(){return new f(this.px,n.neg(this.py),this.pz)}double(){const{a:y,b:p}=t,g=n.mul(p,ys),{px:x,py:w,pz:B}=this;let A=n.ZERO,I=n.ZERO,P=n.ZERO,C=n.mul(x,x),k=n.mul(w,w),U=n.mul(B,B),H=n.mul(x,w);return H=n.add(H,H),P=n.mul(x,B),P=n.add(P,P),A=n.mul(y,P),I=n.mul(g,U),I=n.add(A,I),A=n.sub(k,I),I=n.add(k,I),I=n.mul(A,I),A=n.mul(H,A),P=n.mul(g,P),U=n.mul(y,U),H=n.sub(C,U),H=n.mul(y,H),H=n.add(H,P),P=n.add(C,C),C=n.add(P,C),C=n.add(C,U),C=n.mul(C,H),I=n.add(I,C),U=n.mul(w,B),U=n.add(U,U),C=n.mul(U,H),A=n.sub(A,C),P=n.mul(U,k),P=n.add(P,P),P=n.add(P,P),new f(A,I,P)}add(y){l(y);const{px:p,py:g,pz:x}=this,{px:w,py:B,pz:A}=y;let I=n.ZERO,P=n.ZERO,C=n.ZERO;const k=t.a,U=n.mul(t.b,ys);let H=n.mul(p,w),D=n.mul(g,B),v=n.mul(x,A),E=n.add(p,g),b=n.add(w,B);E=n.mul(E,b),b=n.add(H,D),E=n.sub(E,b),b=n.add(p,x);let S=n.add(w,A);return b=n.mul(b,S),S=n.add(H,v),b=n.sub(b,S),S=n.add(g,x),I=n.add(B,A),S=n.mul(S,I),I=n.add(D,v),S=n.sub(S,I),C=n.mul(k,b),I=n.mul(U,v),C=n.add(I,C),I=n.sub(D,C),C=n.add(D,C),P=n.mul(I,C),D=n.add(H,H),D=n.add(D,H),v=n.mul(k,v),b=n.mul(U,b),D=n.add(D,v),v=n.sub(H,v),v=n.mul(k,v),b=n.add(b,v),H=n.mul(D,b),P=n.add(P,H),H=n.mul(S,b),I=n.mul(E,I),I=n.sub(I,H),H=n.mul(E,D),C=n.mul(S,C),C=n.add(C,H),new f(I,P,C)}subtract(y){return this.add(y.negate())}is0(){return this.equals(f.ZERO)}wNAF(y){return h.wNAFCached(this,u,y,p=>{const g=n.invertBatch(p.map(x=>x.pz));return p.map((x,w)=>x.toAffine(g[w])).map(f.fromAffine)})}multiplyUnsafe(y){const p=f.ZERO;if(y===We)return p;if(a(y),y===Se)return this;const{endo:g}=t;if(!g)return h.unsafeLadder(this,y);let{k1neg:x,k1:w,k2neg:B,k2:A}=g.splitScalar(y),I=p,P=p,C=this;for(;w>We||A>We;)w&Se&&(I=I.add(C)),A&Se&&(P=P.add(C)),C=C.double(),w>>=Se,A>>=Se;return x&&(I=I.negate()),B&&(P=P.negate()),P=new f(n.mul(P.px,g.beta),P.py,P.pz),I.add(P)}multiply(y){a(y);let p=y,g,x;const{endo:w}=t;if(w){const{k1neg:B,k1:A,k2neg:I,k2:P}=w.splitScalar(p);let{p:C,f:k}=this.wNAF(A),{p:U,f:H}=this.wNAF(P);C=h.constTimeNegate(B,C),U=h.constTimeNegate(I,U),U=new f(n.mul(U.px,w.beta),U.py,U.pz),g=C.add(U),x=k.add(H)}else{const{p:B,f:A}=this.wNAF(p);g=B,x=A}return f.normalizeZ([g,x])[0]}multiplyAndAddUnsafe(y,p,g){const x=f.BASE,w=(A,I)=>I===We||I===Se||!A.equals(x)?A.multiplyUnsafe(I):A.multiply(I),B=w(this,p).add(w(y,g));return B.is0()?void 0:B}toAffine(y){const{px:p,py:g,pz:x}=this,w=this.is0();y==null&&(y=w?n.ONE:n.inv(x));const B=n.mul(p,y),A=n.mul(g,y),I=n.mul(x,y);if(w)return{x:n.ZERO,y:n.ZERO};if(!n.eql(I,n.ONE))throw new Error("invZ was invalid");return{x:B,y:A}}isTorsionFree(){const{h:y,isTorsionFree:p}=t;if(y===Se)return!0;if(p)return p(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:y,clearCofactor:p}=t;return y===Se?this:p?p(f,this):this.multiplyUnsafe(t.h)}toRawBytes(y=!0){return this.assertValidity(),r(f,this,y)}toHex(y=!0){return Dn(this.toRawBytes(y))}}f.BASE=new f(t.Gx,t.Gy,n.ONE),f.ZERO=new f(n.ZERO,n.ONE,n.ZERO);const d=t.nBitLength,h=Yh(f,t.endo?Math.ceil(d/2):d);return{CURVE:t,ProjectivePoint:f,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:i}}function e0(e){const t=ru(e);return Qn(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function t0(e){const t=e0(e),{Fp:n,n:r}=t,s=n.BYTES+1,o=2*n.BYTES+1;function i(b){return WeDn(Nn(b,t.nByteLength));function m(b){const S=r>>Se;return b>S}function y(b){return m(b)?a(-b):b}const p=(b,S,$)=>Gt(b.slice(S,$));class g{constructor(S,$,N){this.r=S,this.s=$,this.recovery=N,this.assertValidity()}static fromCompact(S){const $=t.nByteLength;return S=Fe("compactSignature",S,$*2),new g(p(S,0,$),p(S,$,2*$))}static fromDER(S){const{r:$,s:N}=cn.toSig(Fe("DER",S));return new g($,N)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(S){return new g(this.r,this.s,S)}recoverPublicKey(S){const{r:$,s:N,recovery:T}=this,j=P(Fe("msgHash",S));if(T==null||![0,1,2,3].includes(T))throw new Error("recovery id invalid");const K=T===2||T===3?$+t.n:$;if(K>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const M=(T&1)===0?"02":"03",re=u.fromHex(M+h(K)),ne=c(K),W=a(-j*ne),oe=a(N*ne),ie=u.BASE.multiplyAndAddUnsafe(re,W,oe);if(!ie)throw new Error("point at infinify");return ie.assertValidity(),ie}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Kn(this.toDERHex())}toDERHex(){return cn.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Kn(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const x={isValidPrivateKey(b){try{return l(b),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const b=t.randomBytes(n.BYTES+8),S=Fh(b,r);return Nn(S,t.nByteLength)},precompute(b=8,S=u.BASE){return S._setWindowSize(b),S.multiply(BigInt(3)),S}};function w(b,S=!0){return u.fromPrivateKey(b).toRawBytes(S)}function B(b){const S=b instanceof Uint8Array,$=typeof b=="string",N=(S||$)&&b.length;return S?N===s||N===o:$?N===2*s||N===2*o:b instanceof u}function A(b,S,$=!0){if(B(b))throw new Error("first arg must be private key");if(!B(S))throw new Error("second arg must be public key");return u.fromHex(S).multiply(l(b)).toRawBytes($)}const I=t.bits2int||function(b){const S=Gt(b),$=b.length*8-t.nBitLength;return $>0?S>>BigInt($):S},P=t.bits2int_modN||function(b){return a(I(b))},C=Bi(t.nBitLength);function k(b){if(typeof b!="bigint")throw new Error("bigint expected");if(!(We<=b&&bse in $))throw new Error("sign() legacy options not supported");const{hash:N,randomBytes:T}=t;let{lowS:j,prehash:K,extraEntropy:M}=$;j==null&&(j=!0),b=Fe("msgHash",b),K&&(b=Fe("prehashed msgHash",N(b)));const re=P(b),ne=l(S),W=[k(ne),k(re)];if(M!=null){const se=M===!0?T(n.BYTES):M;W.push(Fe("extraEntropy",se,n.BYTES))}const oe=Ye(...W),ie=re;function ve(se){const he=I(se);if(!d(he))return;const bt=c(he),Me=u.BASE.multiply(he).toAffine(),$e=a(Me.x);if($e===We)return;const wt=a(bt*a(ie+$e*ne));if(wt===We)return;let ar=(Me.x===$e?0:2)|Number(Me.y&Se),va=wt;return j&&m(wt)&&(va=y(wt),ar^=1),new g($e,va,ar)}return{seed:oe,k2sig:ve}}const H={lowS:t.lowS,prehash:!1},D={lowS:t.lowS,prehash:!1};function v(b,S,$=H){const{seed:N,k2sig:T}=U(b,S,$);return eu(t.hash.outputLen,t.nByteLength,t.hmac)(N,T)}u.BASE._setWindowSize(8);function E(b,S,$,N=D){var Me;const T=b;if(S=Fe("msgHash",S),$=Fe("publicKey",$),"strict"in N)throw new Error("options.strict was renamed to lowS");const{lowS:j,prehash:K}=N;let M,re;try{if(typeof T=="string"||T instanceof Uint8Array)try{M=g.fromDER(T)}catch($e){if(!($e instanceof cn.Err))throw $e;M=g.fromCompact(T)}else if(typeof T=="object"&&typeof T.r=="bigint"&&typeof T.s=="bigint"){const{r:$e,s:wt}=T;M=new g($e,wt)}else throw new Error("PARSE");re=u.fromHex($)}catch($e){if($e.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(j&&M.hasHighS())return!1;K&&(S=t.hash(S));const{r:ne,s:W}=M,oe=P(S),ie=c(W),ve=a(oe*ie),se=a(ne*ie),he=(Me=u.BASE.multiplyAndAddUnsafe(re,ve,se))==null?void 0:Me.toAffine();return he?a(he.x)===ne:!1}return{CURVE:t,getPublicKey:w,getSharedSecret:A,sign:v,verify:E,ProjectivePoint:u,Signature:g,utils:x}}function n0(e,t){const n=e.ORDER;let r=We;for(let d=n-Se;d%xt===We;d/=xt)r+=Se;const s=r,o=(n-Se)/xt**s,i=(o-Se)/xt,a=xt**s-Se,c=xt**(s-Se),u=e.pow(t,o),l=e.pow(t,(o+Se)/xt);let f=(d,h)=>{let m=u,y=e.pow(h,a),p=e.sqr(y);p=e.mul(p,h);let g=e.mul(d,p);g=e.pow(g,i),g=e.mul(g,y),y=e.mul(g,h),p=e.mul(g,d);let x=e.mul(p,y);g=e.pow(x,c);let w=e.eql(g,e.ONE);y=e.mul(p,l),g=e.mul(x,m),p=e.cmov(y,p,w),x=e.cmov(g,x,w);for(let B=s;B>1;B--){let A=xt**(B-xt),I=e.pow(x,A);const P=e.eql(I,e.ONE);y=e.mul(p,m),m=e.mul(m,m),I=e.mul(x,m),p=e.cmov(y,p,P),x=e.cmov(I,x,P)}return{isValid:w,value:p}};if(e.ORDER%Ba===ys){const d=(e.ORDER-ys)/Ba,h=e.sqrt(e.neg(t));f=(m,y)=>{let p=e.sqr(y);const g=e.mul(m,y);p=e.mul(p,g);let x=e.pow(p,d);x=e.mul(x,g);const w=e.mul(x,h),B=e.mul(e.sqr(x),y),A=e.eql(B,m);let I=e.cmov(w,x,A);return{isValid:A,value:I}}}return f}function r0(e,t){if(tu(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const n=n0(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return r=>{let s,o,i,a,c,u,l,f;s=e.sqr(r),s=e.mul(s,t.Z),o=e.sqr(s),o=e.add(o,s),i=e.add(o,e.ONE),i=e.mul(i,t.B),a=e.cmov(t.Z,e.neg(o),!e.eql(o,e.ZERO)),a=e.mul(a,t.A),o=e.sqr(i),u=e.sqr(a),c=e.mul(u,t.A),o=e.add(o,c),o=e.mul(o,i),u=e.mul(u,a),c=e.mul(u,t.B),o=e.add(o,c),l=e.mul(s,i);const{isValid:d,value:h}=n(o,u);f=e.mul(s,r),f=e.mul(f,h),l=e.cmov(l,i,d),f=e.cmov(f,h,d);const m=e.isOdd(r)===e.isOdd(f);return f=e.cmov(e.neg(f),f,m),l=e.div(l,a),{x:l,y:f}}}function s0(e){if(e instanceof Uint8Array)return e;if(typeof e=="string")return Ws(e);throw new Error("DST must be Uint8Array or string")}const o0=Gt;function qt(e,t){if(e<0||e>=1<<8*t)throw new Error(`bad I2OSP call: value=${e} length=${t}`);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=e&255,e>>>=8;return new Uint8Array(n)}function i0(e,t){const n=new Uint8Array(e.length);for(let r=0;r255&&(t=r(Ye(Ws("H2C-OVERSIZE-DST-"),t)));const{outputLen:s,blockLen:o}=r,i=Math.ceil(n/s);if(i>255)throw new Error("Invalid xmd length");const a=Ye(t,qt(t.length,1)),c=qt(0,o),u=qt(n,2),l=new Array(i),f=r(Ye(c,e,u,qt(0,1),a));l[0]=r(Ye(f,qt(1,1),a));for(let h=1;h<=i;h++){const m=[i0(f,l[h-1]),qt(h+1,1),a];l[h]=r(Ye(...m))}return Ye(...l).slice(0,n)}function c0(e,t,n,r,s){if(mr(e),mr(t),Ii(n),t.length>255){const o=Math.ceil(2*r/8);t=s.create({dkLen:o}).update(Ws("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return s.create({dkLen:n}).update(e).update(qt(n,2)).update(t).update(qt(t.length,1)).digest()}function Oa(e,t,n){Qn(n,{DST:"string",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:r,k:s,m:o,hash:i,expand:a,DST:c}=n;mr(e),Ii(t);const u=s0(c),l=r.toString(2).length,f=Math.ceil((l+s)/8),d=t*o*f;let h;if(a==="xmd")h=a0(e,u,d,i);else if(a==="xof")h=c0(e,u,d,s,i);else if(a===void 0)h=e;else throw new Error('expand must be "xmd", "xof" or undefined');const m=new Array(t);for(let y=0;yArray.from(r).reverse());return(r,s)=>{const[o,i,a,c]=n.map(u=>u.reduce((l,f)=>e.add(e.mul(l,r),f)));return r=e.div(o,i),s=e.mul(s,e.div(a,c)),{x:r,y:s}}}function f0(e,t,n){if(typeof t!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(r,s){const o=Oa(r,2,{...n,DST:n.DST,...s}),i=e.fromAffine(t(o[0])),a=e.fromAffine(t(o[1])),c=i.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,s){const o=Oa(r,1,{...n,DST:n.encodeDST,...s}),i=e.fromAffine(t(o[0])).clearCofactor();return i.assertValidity(),i}}}let su=class extends Gc{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,an.hash(t);const r=_i(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new TypeError("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,o=new Uint8Array(s);o.set(r.length>s?t.create().update(r).digest():r);for(let i=0;inew su(e,t).update(n).digest();ou.create=(e,t)=>new su(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function l0(e){return{hash:e,hmac:(t,...n)=>ou(e,t,Eh(...n)),randomBytes:Sh}}function d0(e,t){const n=r=>t0({...e,...l0(r)});return Object.freeze({...n(t),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const iu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ia=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h0=BigInt(1),Go=BigInt(2),Ta=(e,t)=>(e+t/Go)/t;function p0(e){const t=iu,n=BigInt(3),r=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,l=u*u*e%t,f=qe(l,n,t)*l%t,d=qe(f,n,t)*l%t,h=qe(d,Go,t)*u%t,m=qe(h,s,t)*h%t,y=qe(m,o,t)*m%t,p=qe(y,a,t)*y%t,g=qe(p,c,t)*p%t,x=qe(g,a,t)*y%t,w=qe(x,n,t)*l%t,B=qe(w,i,t)*m%t,A=qe(B,r,t)*u%t,I=qe(A,Go,t);if(!Wt.eql(Wt.sqr(I),e))throw new Error("Cannot find square root");return I}const Wt=nu(iu,void 0,void 0,{sqrt:p0}),$t=d0({a:BigInt(0),b:BigInt(7),Fp:Wt,n:Ia,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Ia,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-h0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,i=BigInt("0x100000000000000000000000000000000"),a=Ta(o*e,t),c=Ta(-r*e,t);let u=Te(e-a*n-c*s,t),l=Te(-a*r-c*o,t);const f=u>i,d=l>i;if(f&&(u=t-u),d&&(l=t-l),u>i||l>i)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:f,k1:u,k2neg:d,k2:l}}}},Xc);BigInt(0);$t.ProjectivePoint;$t.utils.randomPrivateKey;const g0=u0(Wt,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),m0=r0(Wt,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:Wt.create(BigInt("-11"))});f0($t.ProjectivePoint,e=>{const{x:t,y:n}=m0(Wt.create(e[0]));return g0(t,n)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:Wt.ORDER,m:1,k:128,expand:"xmd",hash:Xc});function Yo(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function y0(e){if(typeof e!="boolean")throw new Error(`Expected boolean, not ${e}`)}function au(e,...t){if(!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new TypeError(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function b0(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Yo(e.outputLen),Yo(e.blockLen)}function w0(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function x0(e,t){au(e);const n=t.outputLen;if(e.lengthnew DataView(e.buffer,e.byteOffset,e.byteLength),ut=(e,t)=>e<<32-t|e>>>t,E0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!E0)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function S0(e){if(typeof e!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function cu(e){if(typeof e=="string"&&(e=S0(e)),!(e instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof e})`);return e}let _0=class{clone(){return this._cloneInto()}};function uu(e){const t=r=>e().update(cu(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function k0(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,a,r)}let A0=class extends _0{constructor(t,n,r,s){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=xo(this.buffer)}update(t){wo.exists(this);const{view:n,buffer:r,blockLen:s}=this;t=cu(t);const o=t.length;for(let i=0;is-i&&(this.process(r,0),i=0);for(let f=i;fl.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;fe&t^~e&n,B0=(e,t,n)=>e&t^e&n^t&n,O0=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]),Pt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Nt=new Uint32Array(64);let fu=class extends A0{constructor(){super(64,32,8,!1),this.A=Pt[0]|0,this.B=Pt[1]|0,this.C=Pt[2]|0,this.D=Pt[3]|0,this.E=Pt[4]|0,this.F=Pt[5]|0,this.G=Pt[6]|0,this.H=Pt[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[t,n,r,s,o,i,a,c]}set(t,n,r,s,o,i,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,n){for(let f=0;f<16;f++,n+=4)Nt[f]=t.getUint32(n,!1);for(let f=16;f<64;f++){const d=Nt[f-15],h=Nt[f-2],m=ut(d,7)^ut(d,18)^d>>>3,y=ut(h,17)^ut(h,19)^h>>>10;Nt[f]=y+Nt[f-7]+m+Nt[f-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:u,H:l}=this;for(let f=0;f<64;f++){const d=ut(a,6)^ut(a,11)^ut(a,25),h=l+d+$0(a,c,u)+O0[f]+Nt[f]|0,y=(ut(r,2)^ut(r,13)^ut(r,22))+B0(r,s,o)|0;l=u,u=c,c=a,a=i+h|0,i=o,o=s,s=r,r=h+y|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,s,o,i,a,c,u,l)}roundClean(){Nt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},I0=class extends fu{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 Wo=uu(()=>new fu);uu(()=>new I0);function T0(e,t){if(e.length>t)throw new TypeError(`Data is larger than array size: ${e.length} > ${t}`)}function C0(e){if(e.match(/[^a-fA-f0-9]/)!==null)throw new TypeError("Invalid characters in hex string: "+e);if(e.length%2!==0)throw new Error(`Length of hex string is invalid: ${e.length}`)}function U0(e){if(e>Number.MAX_SAFE_INTEGER)throw new TypeError("Number exceeds safe bounds!")}const{getRandomValues:P0}=crypto??globalThis.crypto??window.crypto;function N0(e=32){if(typeof P0=="function")return crypto.getRandomValues(new Uint8Array(e));throw new Error("Crypto module missing getRandomValues!")}function L0(e,t,n="be"){t===void 0&&(t=e.length),T0(e,t);const r=new Uint8Array(t).fill(0),s=n==="be"?0:t-e.length;return r.set(e,s),r}function lu(e){let t,n=0;const r=e.reduce((o,i)=>o+i.length,0),s=new Uint8Array(r);for(t=0;t0||(i.length^a)>0?"":"1";c in o||u>0;)l=o[c],l=l>0?l*256+u:u,u=l/s|0,o[c]=l%s,c++;for(;c-- >0;)i+=r[o[c]];return n&&i.length%4>0?i+"=".repeat(4-i.length%4):i}function D0(e,t){const n=du(t),r=n.length,s=[],o=[];e=e.replace("=","");let i,a=0,c,u;for(i=0;i0||(o.length^i)>0||o.push(0);a in s||c>0;)u=s[a],u=u>0?u*r+c:c,c=u>>8,s[a]=u%256,a++}for(;a-- >0;)o.push(s[a]);return new Uint8Array(o)}function hu(e){return Wo(Wo(e))}function K0(e){const t=hu(e);return lu([e,t.slice(0,4)])}function Z0(e){const t=e.slice(0,-4),n=e.slice(-4);if(hu(t).slice(0,4).toString()!==n.toString())throw new Error("Invalid checksum!");return t}const Ca={encode:j0,decode:D0},pu={encode:e=>{const t=K0(e);return Ca.encode(t,"base58")},decode:e=>{const t=Ca.decode(e,"base58");return Z0(t)}},gu="qpzry9x8gf2tvdw0s3jn54khce6mua7l",V0=[996825010,642813549,513874426,1027748829,705979059],bs=[{version:0,name:"bech32",const:1},{version:1,name:"bech32m",const:734539939}];function mu(e){let t=1;for(let n=0;n>25;t=(t&33554431)<<5^e[n];for(let s=0;s<5;++s)(r>>s&1)!==0&&(t^=V0[s])}return t}function yu(e){const t=[];let n;for(n=0;n>5);for(t.push(0),n=0;n>5*(5-i)&31);return o}function bu(e,t,n,r=!0){const s=[];let o=0,i=0;const a=(1<>t>0)throw new Error("Failed to perform base conversion. Invalid value: "+String(u));for(o=(o<=n;)i-=n,s.push(o>>i&a)}if(r)i>0&&s.push(o<=t||(o<0)throw new Error("Failed to perform base conversion. Invalid Size!");return s}function z0(e,t,n){const r=t.concat(q0(e,t,n));let s=e+"1";for(let o=0;oo.version===t[0])??bs[0];if(!M0(r,t,s))throw new Error("Checksum verification failed!");return[r,t.slice(0,t.length-6)]}function F0(e){let t,n,r=!1,s=!1;for(t=0;t126)return!1;n>=97&&n<=122&&(r=!0),n>=65&&n<=90&&(s=!0)}return!(r&&s)}function G0(e){const t=e.lastIndexOf("1");return!(t<1||t+7>e.length||e.length>90)}function Y0(e,t="bc",n=0){const r=[n,...bu([...e],8,5)],s=bs.find(i=>i.version===n)??bs[0],o=z0(t,r,s);return xu(o),o}function xu(e){e=e.toLowerCase();const t=e.split("1",1)[0],[n,r]=wu(e),s=bu(r.slice(1),5,8,!1),o=s.length;switch(!0){case t!==n:throw new Error("Returned hrp string is invalid.");case(s===null||o<2||o>40):throw new Error("Decoded string is invalid or out of spec.");case r[0]>16:throw new Error("Returned version bit is out of range.");default:return Uint8Array.from(s)}}function W0(e){e=e.toLowerCase();const[t,n]=wu(e);return n[0]}const vu={encode:Y0,decode:xu,version:W0},Eu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Su="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",X0=new TextEncoder;function _u(e,t=!1,n=!0){typeof e=="string"&&(e=X0.encode(e));const r=t?Su:Eu;let s="",o=0,i=0;for(let a=0;a=6;)o-=6,s+=r[i>>o&63];if(o>0)for(i<<=6-o,s+=r[i&63];o<6;)s+=n?"=":"",o+=2;return s}function ku(e,t=!1){const n=t||e.includes("-")||e.includes("_")?Su.split(""):Eu.split("");e=e.replace(/=+$/,"");const r=e.split("");let s=0,o=0;const i=[];for(let a=0;a=8&&(s-=8,i.push(o>>>s&255))}return new Uint8Array(i)}const Au={encode:_u,decode:ku},$u={encode:e=>_u(e,!0,!1),decode:e=>ku(e,!0)},J0=BigInt(0),Q0=BigInt(255),Bu=BigInt(256);function ep(e){if(e<=0xffn)return 1;if(e<=0xffffn)return 2;if(e<=0xffffffffn)return 4;if(e<=0xffffffffffffffffn)return 8;if(e<=0xffffffffffffffffffffffffffffffffn)return 16;if(e<=0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn)return 32;throw new TypeError("Must specify a fixed buffer size for bigints greater than 32 bytes.")}function tp(e,t,n="be"){t===void 0&&(t=ep(e));const r=n==="le",s=new ArrayBuffer(t),o=new DataView(s);let i=r?0:t-1;for(;e>J0;){const a=e&Q0,c=Number(a);r?o.setUint8(i++,c):o.setUint8(i--,c),e=(e-a)/Bu}return new Uint8Array(s)}function np(e){let t=BigInt(0);for(let n=e.length-1;n>=0;n--)t=t*Bu+BigInt(e[n]);return BigInt(t)}function rp(e){const t=e.split("").map(Number);if(t.length%8!==0)throw new Error(`Binary array is invalid length: ${e.length}`);const n=new Uint8Array(t.length/8);for(let r=0,s=0;r255)throw new Error(`Invalid byte value: ${r}. Byte values must be between 0 and 255.`);for(let s=7;s>=0;s--,n++)t[n]=r>>s&1}return t.join("")}function op(e){if(e<=255)return 1;if(e<=65535)return 2;if(e<=4294967295)return 4;throw new TypeError("Numbers larger than 4 bytes must specify a fixed size!")}function ip(e,t,n="be"){t===void 0&&(t=op(e));const r=n==="le",s=new ArrayBuffer(t),o=new DataView(s);let i=r?0:t-1;for(;e>0;){const a=e&255;r?o.setUint8(i++,e):o.setUint8(i--,e),e=(e-a)/256}return new Uint8Array(s)}function ap(e){let t=0;for(let n=e.length-1;n>=0;n--)t=t*256+e[n],U0(t);return t}const cp=new TextEncoder,up=new TextDecoder;function Ti(e){return cp.encode(e)}function vo(e){return up.decode(e)}function fp(e,t){C0(e);const n=e.length/2;if(t===void 0&&(t=n),n>t)throw new TypeError(`Hex string is larger than array size: ${n} > ${t}`);return t}function lp(e,t,n="le"){t=fp(e,t);const r=n==="le",s=new ArrayBuffer(t),o=new DataView(s);let i=r?0:t-1;for(let a=0;atypeof r=="bigint"?`${r}n`:r);return Ti(t)}function pp(e,t,n){if(e instanceof ArrayBuffer)return new Uint8Array(e);if(e instanceof Uint8Array)return L0(e,t,n);if(typeof e=="string")return lp(e,t,n);if(typeof e=="bigint")return tp(e,t,n);if(typeof e=="number")return ip(e,t,n);if(typeof e=="boolean")return Uint8Array.of(e?1:0);throw TypeError("Unsupported format:"+typeof e)}const ee=class ee extends Uint8Array{static random(t=32){const n=N0(t);return new ee(n,t)}constructor(t,n,r){const s=pp(t,n,r);super(s)}get arr(){return[...this]}get num(){return this.toNum()}get big(){return this.toBig()}get str(){return this.toStr()}get hex(){return this.toHex()}get raw(){return new Uint8Array(this)}get bin(){return this.toBin()}get b58chk(){return this.tob58chk()}get base64(){return this.toBase64()}get b64url(){return this.toB64url()}get digest(){return this.toHash()}get id(){return this.toHash().hex}get stream(){return new $p(this)}toNum(t="be"){const n=t==="be"?this.reverse():this;return ap(n)}toBin(){return sp(this)}toBig(t="be"){const n=t==="be"?this.reverse():this;return np(n)}toHash(){const t=Wo(this);return new ee(t)}toJson(){const t=vo(this);return JSON.parse(t)}toBech32(t,n=0){return vu.encode(this,t,n)}toStr(){return vo(this)}toHex(){return dp(this)}toBytes(){return new Uint8Array(this)}tob58chk(){return pu.encode(this)}toBase64(){return Au.encode(this)}toB64url(){return $u.encode(this)}prepend(t){return ee.join([ee.bytes(t),this])}append(t){return ee.join([this,ee.bytes(t)])}slice(t,n){const r=new Uint8Array(this).slice(t,n);return new ee(r)}subarray(t,n){const r=new Uint8Array(this).subarray(t,n);return new ee(r)}reverse(){const t=new Uint8Array(this).reverse();return new ee(t)}write(t,n){const r=ee.bytes(t);this.set(r,n)}prefixSize(t){const n=ee.varInt(this.length,t);return ee.join([n,this])}static from(t){return new ee(Uint8Array.from(t))}static of(...t){return new ee(Uint8Array.of(...t))}static join(t){const n=t.map(s=>ee.bytes(s)),r=lu(n);return new ee(r)}static varInt(t,n){if(t<253)return ee.num(t,1);if(t<65536)return ee.of(253,...ee.num(t,2,n));if(t<4294967296)return ee.of(254,...ee.num(t,4,n));if(BigInt(t)<0x10000000000000000n)return ee.of(255,...ee.num(t,8,n));throw new Error(`Value is too large: ${t}`)}};ee.num=gp,ee.big=yp,ee.bin=mp,ee.raw=bp,ee.str=wp,ee.hex=xp,ee.bytes=vp,ee.json=Ep,ee.base64=Sp,ee.b64url=_p,ee.bech32=kp,ee.b58chk=Ap,ee.encode=Ti,ee.decode=vo;let G=ee;function gp(e,t,n){return new G(e,t,n)}function mp(e,t,n){return new G(rp(e),t,n)}function yp(e,t,n){return new G(e,t,n)}function bp(e,t,n){return new G(e,t,n)}function wp(e,t,n){return new G(Ti(e),t,n)}function xp(e,t,n){return new G(e,t,n)}function vp(e,t,n){return new G(e,t,n)}function Ep(e){return new G(hp(e))}function Sp(e){return new G(Au.decode(e))}function _p(e){return new G($u.decode(e))}function kp(e){return new G(vu.decode(e))}function Ap(e){return new G(pu.decode(e))}class $p{constructor(t){this.data=G.bytes(t),this.size=this.data.length}peek(t){if(t>this.size)throw new Error(`Size greater than stream: ${t} > ${this.size}`);return new G(this.data.slice(0,t))}read(t){t=t??this.readSize();const n=this.peek(t);return this.data=this.data.slice(t),this.size=this.data.length,n}readSize(t){const n=this.read(1).num;switch(!0){case(n>=0&&n<253):return n;case n===253:return this.read(2).toNum(t);case n===254:return this.read(4).toNum(t);case n===255:return this.read(8).toNum(t);default:throw new Error(`Varint is out of range: ${n}`)}}}const ws=$t.CURVE,Ci=ws.n,Bp=ws.p,Op={x:ws.Gx,y:ws.Gy},Ip=BigInt(0);BigInt(1);BigInt(2);BigInt(3);BigInt(4);const Xo={N:Ci,P:Bp,G:Op,_0n:Ip},cr=nu(Ci,32,!0),Ou=e=>Te(e,Ci);function Ui(e,t=!1){if(t)throw new Error(e);return!1}function Iu(e){return G.random(e)}function Tp(e){const t=G.bytes(e).big;return G.big(Ou(t),32)}var Cp=Object.freeze({__proto__:null,fail:Ui,mod_bytes:Tp,random:Iu});const{N:Up,_0n:Pp}=Xo;function Np(e,t,n){const r=G.bytes(e);return r.length!==t?Ui(`Invalid byte size: ${r.hex} !== ${t}`,n):!0}function Lp(e,t){return typeof e=="bigint"&&Ppthis.big}lt(t){return new ge(t).big0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Dp(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Jo(e.outputLen),Jo(e.blockLen)}function Kp(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Zp(e,t){Tu(e);const n=t.outputLen;if(e.lengthe instanceof Uint8Array,Eo=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),ft=(e,t)=>e<<32-t|e>>>t,qp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!qp)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function zp(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Pi(e){if(typeof e=="string"&&(e=zp(e)),!Mp(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}let Cu=class{clone(){return this._cloneInto()}};function An(e){const t=r=>e().update(Pi(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Fp(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,a,r)}class Ni extends Cu{constructor(t,n,r,s){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Eo(this.buffer)}update(t){un.exists(this);const{view:n,buffer:r,blockLen:s}=this;t=Pi(t);const o=t.length;for(let i=0;is-i&&(this.process(r,0),i=0);for(let f=i;fl.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;fe&t^~e&n,Yp=(e,t,n)=>e&t^e&n^t&n,Wp=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]),Lt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Rt=new Uint32Array(64);let Uu=class extends Ni{constructor(){super(64,32,8,!1),this.A=Lt[0]|0,this.B=Lt[1]|0,this.C=Lt[2]|0,this.D=Lt[3]|0,this.E=Lt[4]|0,this.F=Lt[5]|0,this.G=Lt[6]|0,this.H=Lt[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[t,n,r,s,o,i,a,c]}set(t,n,r,s,o,i,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,n){for(let f=0;f<16;f++,n+=4)Rt[f]=t.getUint32(n,!1);for(let f=16;f<64;f++){const d=Rt[f-15],h=Rt[f-2],m=ft(d,7)^ft(d,18)^d>>>3,y=ft(h,17)^ft(h,19)^h>>>10;Rt[f]=y+Rt[f-7]+m+Rt[f-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:u,H:l}=this;for(let f=0;f<64;f++){const d=ft(a,6)^ft(a,11)^ft(a,25),h=l+d+Gp(a,c,u)+Wp[f]+Rt[f]|0,y=(ft(r,2)^ft(r,13)^ft(r,22))+Yp(r,s,o)|0;l=u,u=c,c=a,a=i+h|0,i=o,o=s,s=r,r=h+y|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,s,o,i,a,c,u,l)}roundClean(){Rt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};class Xp extends Uu{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 Qo=An(()=>new Uu);An(()=>new Xp);const Mr=BigInt(2**32-1),ei=BigInt(32);function Pu(e,t=!1){return t?{h:Number(e&Mr),l:Number(e>>ei&Mr)}:{h:Number(e>>ei&Mr)|0,l:Number(e&Mr)|0}}function Jp(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;sBigInt(e>>>0)<>>0),eg=(e,t,n)=>e>>>n,tg=(e,t,n)=>e<<32-n|t>>>n,ng=(e,t,n)=>e>>>n|t<<32-n,rg=(e,t,n)=>e<<32-n|t>>>n,sg=(e,t,n)=>e<<64-n|t>>>n-32,og=(e,t,n)=>e>>>n-32|t<<64-n,ig=(e,t)=>t,ag=(e,t)=>e,cg=(e,t,n)=>e<>>32-n,ug=(e,t,n)=>t<>>32-n,fg=(e,t,n)=>t<>>64-n,lg=(e,t,n)=>e<>>64-n;function dg(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const hg=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),pg=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,gg=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),mg=(e,t,n,r,s)=>t+n+r+s+(e/2**32|0)|0,yg=(e,t,n,r,s)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(s>>>0),bg=(e,t,n,r,s,o)=>t+n+r+s+o+(e/2**32|0)|0,wg={fromBig:Pu,split:Jp,toBig:Qp,shrSH:eg,shrSL:tg,rotrSH:ng,rotrSL:rg,rotrBH:sg,rotrBL:og,rotr32H:ig,rotr32L:ag,rotlSH:cg,rotlSL:ug,rotlBH:fg,rotlBL:lg,add:dg,add3L:hg,add3H:pg,add4L:gg,add4H:mg,add5H:bg,add5L:yg};var Q=wg;const[xg,vg]=Q.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Ht=new Uint32Array(80),jt=new Uint32Array(80);let Xs=class extends Ni{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:n,Bh:r,Bl:s,Ch:o,Cl:i,Dh:a,Dl:c,Eh:u,El:l,Fh:f,Fl:d,Gh:h,Gl:m,Hh:y,Hl:p}=this;return[t,n,r,s,o,i,a,c,u,l,f,d,h,m,y,p]}set(t,n,r,s,o,i,a,c,u,l,f,d,h,m,y,p){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=s|0,this.Ch=o|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=l|0,this.Fh=f|0,this.Fl=d|0,this.Gh=h|0,this.Gl=m|0,this.Hh=y|0,this.Hl=p|0}process(t,n){for(let w=0;w<16;w++,n+=4)Ht[w]=t.getUint32(n),jt[w]=t.getUint32(n+=4);for(let w=16;w<80;w++){const B=Ht[w-15]|0,A=jt[w-15]|0,I=Q.rotrSH(B,A,1)^Q.rotrSH(B,A,8)^Q.shrSH(B,A,7),P=Q.rotrSL(B,A,1)^Q.rotrSL(B,A,8)^Q.shrSL(B,A,7),C=Ht[w-2]|0,k=jt[w-2]|0,U=Q.rotrSH(C,k,19)^Q.rotrBH(C,k,61)^Q.shrSH(C,k,6),H=Q.rotrSL(C,k,19)^Q.rotrBL(C,k,61)^Q.shrSL(C,k,6),D=Q.add4L(P,H,jt[w-7],jt[w-16]),v=Q.add4H(D,I,U,Ht[w-7],Ht[w-16]);Ht[w]=v|0,jt[w]=D|0}let{Ah:r,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:u,Dl:l,Eh:f,El:d,Fh:h,Fl:m,Gh:y,Gl:p,Hh:g,Hl:x}=this;for(let w=0;w<80;w++){const B=Q.rotrSH(f,d,14)^Q.rotrSH(f,d,18)^Q.rotrBH(f,d,41),A=Q.rotrSL(f,d,14)^Q.rotrSL(f,d,18)^Q.rotrBL(f,d,41),I=f&h^~f&y,P=d&m^~d&p,C=Q.add5L(x,A,P,vg[w],jt[w]),k=Q.add5H(C,g,B,I,xg[w],Ht[w]),U=C|0,H=Q.rotrSH(r,s,28)^Q.rotrBH(r,s,34)^Q.rotrBH(r,s,39),D=Q.rotrSL(r,s,28)^Q.rotrBL(r,s,34)^Q.rotrBL(r,s,39),v=r&o^r&a^o&a,E=s&i^s&c^i&c;g=y|0,x=p|0,y=h|0,p=m|0,h=f|0,m=d|0,{h:f,l:d}=Q.add(u|0,l|0,k|0,U|0),u=a|0,l=c|0,a=o|0,c=i|0,o=r|0,i=s|0;const b=Q.add3L(U,D,E);r=Q.add3H(b,k,H,v),s=b|0}({h:r,l:s}=Q.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:o,l:i}=Q.add(this.Bh|0,this.Bl|0,o|0,i|0),{h:a,l:c}=Q.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l}=Q.add(this.Dh|0,this.Dl|0,u|0,l|0),{h:f,l:d}=Q.add(this.Eh|0,this.El|0,f|0,d|0),{h,l:m}=Q.add(this.Fh|0,this.Fl|0,h|0,m|0),{h:y,l:p}=Q.add(this.Gh|0,this.Gl|0,y|0,p|0),{h:g,l:x}=Q.add(this.Hh|0,this.Hl|0,g|0,x|0),this.set(r,s,o,i,a,c,u,l,f,d,h,m,y,p,g,x)}roundClean(){Ht.fill(0),jt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};class Eg extends Xs{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class Sg extends Xs{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class _g extends Xs{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const kg=An(()=>new Xs);An(()=>new Eg);An(()=>new Sg);An(()=>new _g);const Ag=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Nu=Uint8Array.from({length:16},(e,t)=>t),$g=Nu.map(e=>(9*e+5)%16);let Li=[Nu],Ri=[$g];for(let e=0;e<4;e++)for(let t of[Li,Ri])t.push(t[e].map(n=>Ag[n]));const Lu=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>new Uint8Array(e)),Bg=Li.map((e,t)=>e.map(n=>Lu[t][n])),Og=Ri.map((e,t)=>e.map(n=>Lu[t][n])),Ig=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Tg=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),qr=(e,t)=>e<>>32-t;function Pa(e,t,n,r){return e===0?t^n^r:e===1?t&n|~t&r:e===2?(t|~n)^r:e===3?t&r|n&~r:t^(n|~r)}const zr=new Uint32Array(16);let Cg=class extends Ni{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:n,h2:r,h3:s,h4:o}=this;return[t,n,r,s,o]}set(t,n,r,s,o){this.h0=t|0,this.h1=n|0,this.h2=r|0,this.h3=s|0,this.h4=o|0}process(t,n){for(let h=0;h<16;h++,n+=4)zr[h]=t.getUint32(n,!0);let r=this.h0|0,s=r,o=this.h1|0,i=o,a=this.h2|0,c=a,u=this.h3|0,l=u,f=this.h4|0,d=f;for(let h=0;h<5;h++){const m=4-h,y=Ig[h],p=Tg[h],g=Li[h],x=Ri[h],w=Bg[h],B=Og[h];for(let A=0;A<16;A++){const I=qr(r+Pa(h,o,a,u)+zr[g[A]]+y,w[A])+f|0;r=f,f=u,u=qr(a,10)|0,a=o,o=I}for(let A=0;A<16;A++){const I=qr(s+Pa(m,i,c,l)+zr[x[A]]+p,B[A])+d|0;s=d,d=l,l=qr(c,10)|0,c=i,i=I}}this.set(this.h1+a+l|0,this.h2+u+d|0,this.h3+f+s|0,this.h4+r+i|0,this.h0+o+c|0)}roundClean(){zr.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}};const Ug=An(()=>new Cg);let Ru=class extends Cu{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,un.hash(t);const r=Pi(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,o=new Uint8Array(s);o.set(r.length>s?t.create().update(r).digest():r);for(let i=0;inew Ru(e,t).update(n).digest();Hu.create=(e,t)=>new Ru(e,t);function Zn(e){const t=G.bytes(e);return G.raw(Qo(Qo(t)))}function ju(e){const t=G.bytes(e);return G.raw(Ug(Qo(t)))}function Pg(e,t){const n=G.bytes(e),r=G.bytes(t);return G.raw(Hu(kg,n,r))}function Ng(e){const t=G.str(e).digest;return G.join([t,t])}function Lg(e=32){return Hi(Iu(e))}function Hi(e){return Le.mod(e).buff}function Du(e,t=!1){const n=Le.mod(e).point;return t?n.x:n.buff}function Ku(e,t){const n=kn.from_x(t),r=Le.mod(e);return n.mul(r).buff}function Rg(e,t,n="ecdh/code"){const r=Ng(n),s=Hi(e),o=Du(s),i=G.bytes(t),a=Ku(s,i),c=[o.hex,i.hex];return c.sort(),Pg(a,G.join([r,...c]))}function Hg(e){const t=G.bytes(e);switch(!0){case t.length===32:return!0;case(t.length===33&&t[0]===2):return!0;case(t.length===33&&t[0]===3):return!1;default:throw new TypeError(`Invalid public key: ${t.hex}`)}}function jg(e){const t=G.bytes(e);switch(t.length){case 32:return t;case 33:return t.slice(1,33);default:throw new Error(`Invalid key length: ${t.length}`)}}var Dg=Object.freeze({__proto__:null,genSecretKey:Lg,getPublicKey:Du,getSecretKey:Hi,getSharedCode:Rg,getSharedKey:Ku,is_even_pub:Hg,xonly_pub:jg});G.random(32);const Zu={secp:$t},ti={...Dg,...Cp};function Vu(e){const t=_.bytes(e);return Tr(t,33),ju(t)}const Mu={main:"bc",testnet:"tb",signet:"tb",regtest:"bcrt"},Kg=["bc1q","tb1q","bcrt1q"];function qu(e){for(const t of Kg)if(e.startsWith(t))return!0;return!1}function zu(e,t="main"){const n=Mu[t],r=_.bytes(e);return Tr(r,20),r.toBech32(n,0)}function Zg(e){if(!qu(e))throw new TypeError("Invalid segwit address!");return _.bech32(e)}function Vg(e){const t=_.bytes(e);return Tr(t,20),["OP_0",t.hex]}function Mg(e,t){const n=Vu(e);return zu(n,t)}const qg={check:qu,encode:zu,decode:Zg,hash:Vu,scriptPubKey:Vg,fromPubKey:Mg};function mn(e){const t=_.bytes(e);return t.length>32?t.slice(1,33):t}const zg=["bc1p","tb1p","bcrt1p"];function Fu(e){for(const t of zg)if(e.startsWith(t))return!0;return!1}function Gu(e,t="main"){const n=Mu[t],r=_.bytes(e);return Tr(r,32),r.toBech32(n,1)}function Fg(e){if(!Fu(e))throw new TypeError("Invalid taproot address!");return _.bech32(e)}function Gg(e){const t=_.bytes(e);return Tr(t,32),["OP_1",t.hex]}function Yg(e,t){const n=mn(e);return Gu(n,t)}const Wg={check:Fu,encode:Gu,decode:Fg,scriptPubKey:Gg,fromPubKey:Yg},Xg={version:2,vin:[],vout:[],locktime:0},Jg={scriptSig:[],sequence:4294967293,witness:[]},Qg={value:0n,scriptPubKey:[]};function ji(e){const t={...Xg,...e};return t.vin=t.vin.map(n=>({...Jg,...n})),t.vout=t.vout.map(n=>({...Qg,...n})),t}function Vn(e,t){const{version:n,vin:r,vout:s,locktime:o}=ji(e),i=t!==!0&&em(r),a=[Di(n)];i&&a.push(_.hex("0001")),a.push(tm(r)),a.push(nm(s));for(const c of r)i&&a.push(sm(c.witness));return a.push(Ki(o)),_.join(a)}function em(e){for(const t of e){const{witness:n}=t;if(typeof n=="string"||n instanceof Uint8Array||Array.isArray(n)&&n.length>0)return!0}return!1}function Di(e){return _.num(e,4).reverse()}function Cr(e){return _.hex(e,32).reverse()}function Ur(e){return _.num(e,4).reverse()}function Pr(e){if(typeof e=="string")return _.hex(e,4).reverse();if(typeof e=="number")return _.num(e,4).reverse();throw new Error("Unrecognized format: "+String(e))}function tm(e){const t=[_.varInt(e.length,"le")];for(const n of e){const{txid:r,vout:s,scriptSig:o,sequence:i}=n;t.push(Cr(r)),t.push(Ur(s)),t.push(_n(o,!0)),t.push(Pr(i))}return _.join(t)}function Xt(e){if(typeof e=="number"){if(e%1!==0)throw new Error("Value must be an integer:"+String(e));return _.num(e,8).reverse()}return _.big(e,8).reverse()}function nm(e){const t=[_.varInt(e.length,"le")];for(const n of e)t.push(rm(n));return _.join(t)}function rm(e){const{value:t,scriptPubKey:n}=e,r=[];return r.push(Xt(t)),r.push(_n(n,!0)),_.join(r)}function sm(e=[]){const t=[];if(Array.isArray(e)){const n=_.varInt(e.length);t.push(n);for(const r of e)t.push(om(r));return _.join(t)}else return _.bytes(e)}function om(e){return im(e)?new _(0):_n(e,!0)}function im(e){if(Array.isArray(e))return e.length===0;if(typeof e=="string"&&e==="")return!0;const t=_.bytes(e);return t.length===1&&t[0]===0}function Ki(e){if(typeof e=="string")return _.hex(e,4);if(typeof e=="number")return _.num(e,4).reverse();throw new Error("Unrecognized format: "+String(e))}function Zi(e){typeof e=="string"&&(e=_.hex(e).raw);const t=new Jn(e),n=am(t),r=cm(t),s=um(t),o=lm(t);if(r)for(const a of s)a.witness=hm(t);const i=pm(t);return{version:n,vin:s,vout:o,locktime:i}}function am(e){return e.read(4).reverse().toNum()}function cm(e){const[t,n]=[...e.peek(2)];if(t===0){if(e.read(2),n===1)return!0;throw new Error(`Invalid witness flag: ${n}`)}return!1}function um(e){const t=[],n=e.readSize("le");for(let r=0;r0?e.read(n).hex:null}function Wu(e,t){const n=Yu(e);return n!==null?n:[]}function pm(e){return e.read(4).reverse().toNum()}function gm(e){if(qc(e))return Zi(e);if(typeof e=="object"&&!(e instanceof Uint8Array))return Vn(e),ji(e);throw new Error("Invalid format: "+typeof e)}function mm(e){if(qc(e))return Zi(e),_.bytes(e);if(typeof e=="object")return Vn(e);throw new Error("Invalid format: "+typeof e)}const Vi={toBytes:mm,toJson:gm},ym=[["p2pkh",/^76a914(?\w{40})88ac$/],["p2sh",/^a914(?\w{40})87$/],["p2w-pkh",/^0014(?\w{40})$/],["p2w-sh",/^0020(?\w{64})$/],["p2tr",/^5120(?\w{64})$/]],bm=[192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,102,126,128,132,150,152,186,188,190];function wm(e){let t=e.at(-1);return Ot(t)&&(t=_.hex(t)),e.length>1&&t instanceof Uint8Array&&t[0]===80?(e.pop(),_.raw(t)):null}function xm(e){let t=e.at(-1);return Ot(t)&&(t=_.hex(t)),e.length>1&&t instanceof Uint8Array&&t.length>32&&bm.includes(t[0]&254)?(e.pop(),_.raw(t)):null}function vm(e){if(e.length>1){const t=e.at(-1);try{const n=_e.fmt.toBytes(t);return e.pop(),n}catch{return null}}return null}function Em(e){const t=[];for(const n of e)if(Ot(n)||n instanceof Uint8Array||typeof n=="number")t.push(_.bytes(n));else throw new Error("unrecognized value: "+String(n));return t}function Sm(e=[]){const t=[...e],n=wm(t),r=xm(t),s=vm(t),o=Em(t);return{annex:n,cblock:r,script:s,params:o}}function _m(e){const t=_e.fmt.toBytes(e,!1).hex;for(const[n,r]of ym){const s=n,{groups:o}=r.exec(t)??{},{hash:i}=o??{};if(Ot(i))return{type:s,data:_.hex(i)}}return{type:"raw",data:_.hex(t)}}function km(e){const t=Vi.toJson(e),n=Vn(t,!0);return Zn(n).reverse().hex}function Am(e){const t=Vi.toJson(e),n=Vn(t,!0).length,r=Vn(t,!1).length,s=n*3+r,o=s%4>0?1:0,i=Math.floor(s/4)+o;return{size:r,bsize:n,vsize:i,weight:s}}const de={create:ji,encode:Vn,decode:Zi,fmt:Vi,util:{getTxSize:Am,getTxid:km,readScriptPubKey:_m,readWitness:Sm}},ni={p2wpkh:qg,p2tr:Wg},$m=[1,2,3];function Mi(e,t,n={}){const{sigflag:r=1}=n,s=(r&128)===128,o=r%128;if(!$m.includes(o))throw new Error("Invalid hash type: "+String(r));const i=de.fmt.toJson(e),{version:a,vin:c,vout:u,locktime:l}=i,{txid:f,vout:d,prevout:h,sequence:m}=c[t],{value:y}=h??{};if(y===void 0)throw new Error("Prevout value is empty!");let p=n.script;if(p===void 0&&n.pubkey!==void 0&&(p=`76a914${ju(n.pubkey).hex}88ac`),p===void 0)throw new Error("No pubkey / script has been set!");if(_e.fmt.toAsm(p).includes("OP_CODESEPARATOR"))throw new Error("This library does not currently support the use of OP_CODESEPARATOR in segwit scripts.");const g=[Di(a),Bm(c,s),Om(c,o,s),Cr(f),Ur(d),_e.encode(p,!0),Xt(y),Pr(m),Im(u,t,o),Ki(l),_.num(r,4).reverse()];return Zn(_.join(g))}function Bm(e,t){if(t===!0)return _.num(0,32);const n=[];for(const{txid:r,vout:s}of e)n.push(Cr(r)),n.push(Ur(s));return Zn(_.join(n))}function Om(e,t,n){if(n||t!==1)return _.num(0,32);const r=[];for(const{sequence:s}of e)r.push(Pr(s));return Zn(_.join(r))}function Im(e,t,n){const r=[];if(n===1){for(const{value:s,scriptPubKey:o}of e)r.push(Xt(s)),r.push(_e.encode(o,!0));return Zn(_.join(r))}if(n===3&&t1&&c[1].length===33)u=_.bytes(c[1]);else return Ie("No pubkey provided!",s);const l=_e.fmt.toParam(c[0]),f=l.slice(0,-1),d=l.slice(-1)[0],h=Mi(r,t,{...n,sigflag:d});return Zu.secp.verify(f,h,u)?!0:Ie("Invalid signature!",s)}const Um={hash:Mi,sign:Tm,verify:Cm},Pm=[0,1,2,3,129,130,131];function qi(e,t,n={}){const{extension:r,sigflag:s=0,extflag:o=0,key_version:i=0,separator_pos:a=4294967295}=n,c=de.fmt.toJson(e),{version:u,vin:l,vout:f,locktime:d}=c;if(t>=l.length)throw new Error("Index out of bounds: "+String(t));if(!Pm.includes(s))throw new Error("Invalid hash type: "+String(s));if(o<0||o>127)throw new Error("Extention flag out of range: "+String(o));const{txid:h,vout:m,sequence:y,witness:p=[]}=l[t],g=(s&128)===128,x=Km(p),w=x!==void 0?1:0,A=(o+(r!==void 0?1:0))*2+w,I=_.str("TapSighash").digest,P=[I,I,_.num(0,1),_.num(s,1),Di(u),Ki(d)];if(!g){const C=l.map(k=>Na(k));P.push(Nm(l),Rm(C),Hm(C),Lm(l))}if(((s&3)<2||(s&3)>3)&&P.push(jm(f)),P.push(_.num(A,1)),g){const{value:C,scriptPubKey:k}=Na(l[t]);P.push(Cr(h),Ur(m),Xt(C),_e.encode(k,!0),Pr(y))}else P.push(_.num(t,4).reverse());return x!==void 0&&P.push(x),(s&3)===3&&P.push(Dm(f[t])),r!==void 0&&P.push(_.bytes(r),_.num(i),_.num(a,4,"le")),_.join(P).digest}function Nm(e){const t=[];for(const{txid:n,vout:r}of e)t.push(Cr(n)),t.push(Ur(r));return _.join(t).digest}function Lm(e){const t=[];for(const{sequence:n}of e)t.push(Pr(n));return _.join(t).digest}function Rm(e){const t=[];for(const{value:n}of e)t.push(Xt(n));return _.join(t).digest}function Hm(e){const t=[];for(const{scriptPubKey:n}of e)t.push(_n(n,!0));return _.join(t).digest}function jm(e){const t=[];for(const{value:n,scriptPubKey:r}of e)t.push(Xt(n)),t.push(_e.encode(r,!0));return _.join(t).digest}function Dm(e){return _.join([Xt(e.value),_e.encode(e.scriptPubKey,!0)]).digest}function Km(e){if(e===void 0||e.length<2)return;let t=e.at(-1);if(typeof t=="string"&&(t=_.hex(t)),t instanceof Uint8Array&&t[0]===80)return _.raw(t).prefixSize("be").digest}function Na(e){if(e.prevout===void 0)throw new Error("Prevout data missing for input: "+String(e.txid));return e.prevout}const Zm=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Vm=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;function Mm(e,t,n,r={}){const{sigflag:s=0}=r,o=qi(t,n,r),i=qm(e,o);return s===0?_.raw(i):_.join([i,s])}function qm(e,t,n=_.random(32)){const r=_.bytes(t),s=new Le(e),o=s.point,i=o.hasEvenY?s.big:s.negated.big,a=cs("BIP0340/aux",_.bytes(n)),c=i^a.big,u=cs("BIP0340/nonce",c,o.x.raw,r),l=new Le(u),f=l.point,d=f.hasEvenY?l.big:l.negated.big,h=new Le(cs("BIP0340/challenge",f.x.raw,o.x.raw,r)),m=new Le(d+h.big*i);return _.join([f.x.raw,m.raw])}function zm(e,t,n,r=!1){const s=kn.from_x(mn(n)),o=_.bytes(t),i=_.bytes(e).stream;i.size<64&&Ie("Signature length is too small: "+String(i.size),r);const a=i.read(32);a.big>Zm&&Ie("Signature r value greater than field size!",r);const c=i.read(32);c.big>Vm&&Ie("Signature s value greater than curve order!",r);const u=new Le(cs("BIP0340/challenge",a.raw,s.x.raw,o)),l=new Le(c).point,f=s.mul(u.big),d=l.sub(f);return d.hasOddY&&Ie("Signature R value has odd Y coordinate!",r),d.x.big===0n&&Ie("Signature R value is infinite!",r),d.x.big===a.big}const Fm=192;function Js(e){const t=_.str(e).digest;return _.join([t,t])}function zi(e,t=Fm){return _.join([Js("TapLeaf"),Wm(t),_.bytes(e)]).digest.hex}function Gm(e,t){return zi(_e.fmt.toBytes(e),t)}function Fi(e,t){return t0){const[h,m,y]=xs(r,i);c=y,a=Ln(e,h,n)}else i!==void 0?a=Ln(e,i,n):a=Ln(e,void 0,n);const u=n?ti.getPublicKey(a)[0]:a[0],f=[_.num(s+nf(u)),o];c.length>0&&c.forEach(h=>f.push(_.hex(h)));const d=_.join(f);if(i!==void 0&&!Gi(a,i,d,t))throw new Error("Path checking failed! Unable to generate path.");return[mn(a).hex,d.hex]}function Gi(e,t,n,r={}){const{isPrivate:s=!1,throws:o=!1}=r,{parity:i,paths:a,intkey:c}=tf(n),u=s?ti.getPublicKey(e,!0):mn(e),l=_.join([i,u]);if(l.length!==33)return Ie("Invalid tapkey: "+l.hex,o);let f=_.bytes(t).hex;for(const h of a)f=Fi(f,h);const d=Ln(c,f);return _.raw(d).hex===_.raw(l).hex}function tf(e){const t=new Jn(_.bytes(e)),n=t.read(1).num,r=t.read(32),[s,o]=n%2===0?[n,2]:[n-1,3],i=[];for(;t.size>=32;)i.push(t.read(32).hex);if(t.size!==0)throw new Error("Non-empty buffer on control block: "+String(t));return{intkey:r,paths:i,parity:o,version:s}}function nf(e=2){if(e===0||e===1)return e;if(e===2||e==="02")return 0;if(e===3||e==="03")return 1;throw new Error("Invalid parity bit: "+String(e))}function sy(e,t,n={}){const r=de.fmt.toJson(e),{throws:s=!1}=n,{prevout:o,witness:i=[]}=r.vin[t],a=de.util.readWitness(i),{cblock:c,script:u,params:l}=a;let f;if(l.length<1)return Ie("Invalid witness data: "+String(i),s);const{scriptPubKey:d}=o??{};if(d===void 0)return Ie("Prevout scriptPubKey is empty!",s);const{type:h,data:m}=de.util.readScriptPubKey(d);if(h!=="p2tr")return Ie("Prevout script is not a valid taproot output:"+m.hex,s);if(m.length!==32)return Ie("Invalid tapkey length: "+String(m.length),s);if(c!==null&&u!==null){const w=c[0]&254,B=zi(u,w);if(n.extension=B,!Gi(m,B,c,{throws:s}))return Ie("cblock verification failed!",s)}n.pubkey!==void 0?f=_.bytes(n.pubkey):l.length>1&&l[1].length===32?f=_.bytes(l[1]):f=_.bytes(m);const y=_e.fmt.toParam(l[0]),p=new Jn(y),g=p.read(64).raw;if(p.size===1&&(n.sigflag=p.read(1).num,n.sigflag===0))return Ie("0x00 is not a valid appended sigflag!",s);const x=qi(r,t,n);return zm(g,x,f,s)?!0:Ie("Invalid signature!",s)}const oy={hash:qi,sign:Mm,verify:sy},rf={segwit:Um,taproot:oy},iy={getTag:Js,getLeaf:zi,getBranch:Fi,getRoot:Ym},ay={readCtrlBlock:tf,readParityBit:nf},cy={getPubKey:Xm,getSecKey:Jm,getTweak:Xu,tweakSecKey:Ju,tweakPubKey:Qu},vs={getPubKey:ry,getSecKey:ny,encodeScript:Gm,checkPath:Gi,tree:iy,tweak:cy,util:ay,SCRIPT_PUBKEY:ey};var ae;(function(e){e.assertEqual=s=>s;function t(s){}e.assertIs=t;function n(s){throw new Error}e.assertNever=n,e.arrayToEnum=s=>{const o={};for(const i of s)o[i]=i;return o},e.getValidEnumValues=s=>{const o=e.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),i={};for(const a of o)i[a]=s[a];return e.objectValues(i)},e.objectValues=s=>e.objectKeys(s).map(function(o){return s[o]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const o=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&o.push(i);return o},e.find=(s,o)=>{for(const i of s)if(o(i))return i},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,o=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(o)}e.joinValues=r,e.jsonStringifyReplacer=(s,o)=>typeof o=="bigint"?o.toString():o})(ae||(ae={}));var ri;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(ri||(ri={}));const Z=ae.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),zt=e=>{switch(typeof e){case"undefined":return Z.undefined;case"string":return Z.string;case"number":return isNaN(e)?Z.nan:Z.number;case"boolean":return Z.boolean;case"function":return Z.function;case"bigint":return Z.bigint;case"symbol":return Z.symbol;case"object":return Array.isArray(e)?Z.array:e===null?Z.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Z.promise:typeof Map<"u"&&e instanceof Map?Z.map:typeof Set<"u"&&e instanceof Set?Z.set:typeof Date<"u"&&e instanceof Date?Z.date:Z.object;default:return Z.unknown}},L=ae.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),uy=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class tt extends Error{constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}get errors(){return this.issues}format(t){const n=t||function(o){return o.message},r={_errors:[]},s=o=>{for(const i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(n(i));else{let a=r,c=0;for(;cn.message){const n={},r=[];for(const s of this.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(t(s))):r.push(t(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}tt.create=e=>new tt(e);const yr=(e,t)=>{let n;switch(e.code){case L.invalid_type:e.received===Z.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case L.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,ae.jsonStringifyReplacer)}`;break;case L.unrecognized_keys:n=`Unrecognized key(s) in object: ${ae.joinValues(e.keys,", ")}`;break;case L.invalid_union:n="Invalid input";break;case L.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${ae.joinValues(e.options)}`;break;case L.invalid_enum_value:n=`Invalid enum value. Expected ${ae.joinValues(e.options)}, received '${e.received}'`;break;case L.invalid_arguments:n="Invalid function arguments";break;case L.invalid_return_type:n="Invalid function return type";break;case L.invalid_date:n="Invalid date";break;case L.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:ae.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case L.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case L.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case L.custom:n="Invalid input";break;case L.invalid_intersection_types:n="Intersection results could not be merged";break;case L.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case L.not_finite:n="Number must be finite";break;default:n=t.defaultError,ae.assertNever(e)}return{message:n}};let sf=yr;function fy(e){sf=e}function Es(){return sf}const Ss=e=>{const{data:t,path:n,errorMaps:r,issueData:s}=e,o=[...n,...s.path||[]],i={...s,path:o};let a="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)a=u(i,{data:t,defaultError:a}).message;return{...s,path:o,message:s.message||a}},ly=[];function V(e,t){const n=Ss({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Es(),yr].filter(r=>!!r)});e.common.issues.push(n)}class Ne{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const s of n){if(s.status==="aborted")return Y;s.status==="dirty"&&t.dirty(),r.push(s.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const s of n)r.push({key:await s.key,value:await s.value});return Ne.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const s of n){const{key:o,value:i}=s;if(o.status==="aborted"||i.status==="aborted")return Y;o.status==="dirty"&&t.dirty(),i.status==="dirty"&&t.dirty(),(typeof i.value<"u"||s.alwaysSet)&&(r[o.value]=i.value)}return{status:t.value,value:r}}}const Y=Object.freeze({status:"aborted"}),of=e=>({status:"dirty",value:e}),He=e=>({status:"valid",value:e}),si=e=>e.status==="aborted",oi=e=>e.status==="dirty",_s=e=>e.status==="valid",ks=e=>typeof Promise<"u"&&e instanceof Promise;var z;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(z||(z={}));class pt{constructor(t,n,r,s){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const La=(e,t)=>{if(_s(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new tt(e.common.issues);return this._error=n,this._error}}};function J(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:s}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(i,a)=>i.code!=="invalid_type"?{message:a.defaultError}:typeof a.data>"u"?{message:r??a.defaultError}:{message:n??a.defaultError},description:s}}class te{constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(t){return zt(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:zt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Ne,ctx:{common:t.parent.common,data:t.data,parsedType:zt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(ks(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){var r;const s={common:{issues:[],async:(r=n==null?void 0:n.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:zt(t)},o=this._parseSync({data:t,path:s.path,parent:s});return La(s,o)}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:zt(t)},s=this._parse({data:t,path:r.path,parent:r}),o=await(ks(s)?s:Promise.resolve(s));return La(r,o)}refine(t,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,o)=>{const i=t(s),a=()=>o.addIssue({code:L.custom,...r(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(t,n){return this._refinement((r,s)=>t(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(t){return new ot({schema:this,typeName:F.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}optional(){return At.create(this,this._def)}nullable(){return wn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return nt.create(this,this._def)}promise(){return qn.create(this,this._def)}or(t){return vr.create([this,t],this._def)}and(t){return Er.create(this,t,this._def)}transform(t){return new ot({...J(this._def),schema:this,typeName:F.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new $r({...J(this._def),innerType:this,defaultValue:n,typeName:F.ZodDefault})}brand(){return new cf({typeName:F.ZodBranded,type:this,...J(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Os({...J(this._def),innerType:this,catchValue:n,typeName:F.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Nr.create(this,t)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const dy=/^c[^\s-]{8,}$/i,hy=/^[a-z][a-z0-9]*$/,py=/[0-9A-HJKMNP-TV-Z]{26}/,gy=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,my=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/,yy=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u"),by=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,wy=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,xy=e=>e.precision?e.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${e.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${e.precision}}Z$`):e.precision===0?e.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):e.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function vy(e,t){return!!((t==="v4"||!t)&&by.test(e)||(t==="v6"||!t)&&wy.test(e))}class Xe extends te{constructor(){super(...arguments),this._regex=(t,n,r)=>this.refinement(s=>t.test(s),{validation:n,code:L.invalid_string,...z.errToObj(r)}),this.nonempty=t=>this.min(1,z.errToObj(t)),this.trim=()=>new Xe({...this._def,checks:[...this._def.checks,{kind:"trim"}]}),this.toLowerCase=()=>new Xe({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]}),this.toUpperCase=()=>new Xe({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Z.string){const o=this._getOrReturnCtx(t);return V(o,{code:L.invalid_type,expected:Z.string,received:o.parsedType}),Y}const r=new Ne;let s;for(const o of this._def.checks)if(o.kind==="min")t.data.lengtho.value&&(s=this._getOrReturnCtx(t,s),V(s,{code:L.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="length"){const i=t.data.length>o.value,a=t.data.length"u"?null:t==null?void 0:t.precision,offset:(n=t==null?void 0:t.offset)!==null&&n!==void 0?n:!1,...z.errToObj(t==null?void 0:t.message)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...z.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...z.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...z.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...z.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...z.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...z.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...z.errToObj(n)})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value{var t;return new Xe({checks:[],typeName:F.ZodString,coerce:(t=e==null?void 0:e.coerce)!==null&&t!==void 0?t:!1,...J(e)})};function Ey(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r,o=parseInt(e.toFixed(s).replace(".","")),i=parseInt(t.toFixed(s).replace(".",""));return o%i/Math.pow(10,s)}class Jt extends te{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Z.number){const o=this._getOrReturnCtx(t);return V(o,{code:L.invalid_type,expected:Z.number,received:o.parsedType}),Y}let r;const s=new Ne;for(const o of this._def.checks)o.kind==="int"?ae.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),V(r,{code:L.invalid_type,expected:"integer",received:"float",message:o.message}),s.dirty()):o.kind==="min"?(o.inclusive?t.datao.value:t.data>=o.value)&&(r=this._getOrReturnCtx(t,r),V(r,{code:L.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="multipleOf"?Ey(t.data,o.value)!==0&&(r=this._getOrReturnCtx(t,r),V(r,{code:L.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),V(r,{code:L.not_finite,message:o.message}),s.dirty()):ae.assertNever(o);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,z.toString(n))}gt(t,n){return this.setLimit("min",t,!1,z.toString(n))}lte(t,n){return this.setLimit("max",t,!0,z.toString(n))}lt(t,n){return this.setLimit("max",t,!1,z.toString(n))}setLimit(t,n,r,s){return new Jt({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:z.toString(s)}]})}_addCheck(t){return new Jt({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:z.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:z.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:z.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:z.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:z.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:z.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:z.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:z.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:z.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.valuet.kind==="int"||t.kind==="multipleOf"&&ae.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.valuenew Jt({checks:[],typeName:F.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...J(e)});class Qt extends te{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce&&(t.data=BigInt(t.data)),this._getType(t)!==Z.bigint){const o=this._getOrReturnCtx(t);return V(o,{code:L.invalid_type,expected:Z.bigint,received:o.parsedType}),Y}let r;const s=new Ne;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?t.datao.value:t.data>=o.value)&&(r=this._getOrReturnCtx(t,r),V(r,{code:L.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),V(r,{code:L.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):ae.assertNever(o);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,z.toString(n))}gt(t,n){return this.setLimit("min",t,!1,z.toString(n))}lte(t,n){return this.setLimit("max",t,!0,z.toString(n))}lt(t,n){return this.setLimit("max",t,!1,z.toString(n))}setLimit(t,n,r,s){return new Qt({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:z.toString(s)}]})}_addCheck(t){return new Qt({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:z.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:z.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:z.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:z.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:z.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value{var t;return new Qt({checks:[],typeName:F.ZodBigInt,coerce:(t=e==null?void 0:e.coerce)!==null&&t!==void 0?t:!1,...J(e)})};class br extends te{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Z.boolean){const r=this._getOrReturnCtx(t);return V(r,{code:L.invalid_type,expected:Z.boolean,received:r.parsedType}),Y}return He(t.data)}}br.create=e=>new br({typeName:F.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...J(e)});class yn extends te{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Z.date){const o=this._getOrReturnCtx(t);return V(o,{code:L.invalid_type,expected:Z.date,received:o.parsedType}),Y}if(isNaN(t.data.getTime())){const o=this._getOrReturnCtx(t);return V(o,{code:L.invalid_date}),Y}const r=new Ne;let s;for(const o of this._def.checks)o.kind==="min"?t.data.getTime()o.value&&(s=this._getOrReturnCtx(t,s),V(s,{code:L.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):ae.assertNever(o);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new yn({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:z.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:z.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.valuenew yn({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:F.ZodDate,...J(e)});class As extends te{_parse(t){if(this._getType(t)!==Z.symbol){const r=this._getOrReturnCtx(t);return V(r,{code:L.invalid_type,expected:Z.symbol,received:r.parsedType}),Y}return He(t.data)}}As.create=e=>new As({typeName:F.ZodSymbol,...J(e)});class wr extends te{_parse(t){if(this._getType(t)!==Z.undefined){const r=this._getOrReturnCtx(t);return V(r,{code:L.invalid_type,expected:Z.undefined,received:r.parsedType}),Y}return He(t.data)}}wr.create=e=>new wr({typeName:F.ZodUndefined,...J(e)});class xr extends te{_parse(t){if(this._getType(t)!==Z.null){const r=this._getOrReturnCtx(t);return V(r,{code:L.invalid_type,expected:Z.null,received:r.parsedType}),Y}return He(t.data)}}xr.create=e=>new xr({typeName:F.ZodNull,...J(e)});class Mn extends te{constructor(){super(...arguments),this._any=!0}_parse(t){return He(t.data)}}Mn.create=e=>new Mn({typeName:F.ZodAny,...J(e)});class pn extends te{constructor(){super(...arguments),this._unknown=!0}_parse(t){return He(t.data)}}pn.create=e=>new pn({typeName:F.ZodUnknown,...J(e)});class Bt extends te{_parse(t){const n=this._getOrReturnCtx(t);return V(n,{code:L.invalid_type,expected:Z.never,received:n.parsedType}),Y}}Bt.create=e=>new Bt({typeName:F.ZodNever,...J(e)});class $s extends te{_parse(t){if(this._getType(t)!==Z.undefined){const r=this._getOrReturnCtx(t);return V(r,{code:L.invalid_type,expected:Z.void,received:r.parsedType}),Y}return He(t.data)}}$s.create=e=>new $s({typeName:F.ZodVoid,...J(e)});class nt extends te{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),s=this._def;if(n.parsedType!==Z.array)return V(n,{code:L.invalid_type,expected:Z.array,received:n.parsedType}),Y;if(s.exactLength!==null){const i=n.data.length>s.exactLength.value,a=n.data.lengths.maxLength.value&&(V(n,{code:L.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((i,a)=>s.type._parseAsync(new pt(n,i,n.path,a)))).then(i=>Ne.mergeArray(r,i));const o=[...n.data].map((i,a)=>s.type._parseSync(new pt(n,i,n.path,a)));return Ne.mergeArray(r,o)}get element(){return this._def.type}min(t,n){return new nt({...this._def,minLength:{value:t,message:z.toString(n)}})}max(t,n){return new nt({...this._def,maxLength:{value:t,message:z.toString(n)}})}length(t,n){return new nt({...this._def,exactLength:{value:t,message:z.toString(n)}})}nonempty(t){return this.min(1,t)}}nt.create=(e,t)=>new nt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:F.ZodArray,...J(t)});function Un(e){if(e instanceof xe){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=At.create(Un(r))}return new xe({...e._def,shape:()=>t})}else return e instanceof nt?new nt({...e._def,type:Un(e.element)}):e instanceof At?At.create(Un(e.unwrap())):e instanceof wn?wn.create(Un(e.unwrap())):e instanceof gt?gt.create(e.items.map(t=>Un(t))):e}class xe extends te{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=ae.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(t){if(this._getType(t)!==Z.object){const u=this._getOrReturnCtx(t);return V(u,{code:L.invalid_type,expected:Z.object,received:u.parsedType}),Y}const{status:r,ctx:s}=this._processInputParams(t),{shape:o,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Bt&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||a.push(u);const c=[];for(const u of i){const l=o[u],f=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new pt(s,f,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Bt){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")a.length>0&&(V(s,{code:L.unrecognized_keys,keys:a}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of a){const f=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new pt(s,f,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of c){const f=await l.key;u.push({key:f,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>Ne.mergeObjectSync(r,u)):Ne.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(t){return new xe({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,o,i,a;const c=(i=(o=(s=this._def).errorMap)===null||o===void 0?void 0:o.call(s,n,r).message)!==null&&i!==void 0?i:r.defaultError;return n.code==="unrecognized_keys"?{message:(a=z.errToObj(t).message)!==null&&a!==void 0?a:c}:{message:c}}}:{}})}strip(){return new xe({...this._def,unknownKeys:"strip"})}passthrough(){return new xe({...this._def,unknownKeys:"passthrough"})}extend(t){return new xe({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new xe({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:F.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new xe({...this._def,catchall:t})}pick(t){const n={};return ae.objectKeys(t).forEach(r=>{t[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new xe({...this._def,shape:()=>n})}omit(t){const n={};return ae.objectKeys(this.shape).forEach(r=>{t[r]||(n[r]=this.shape[r])}),new xe({...this._def,shape:()=>n})}deepPartial(){return Un(this)}partial(t){const n={};return ae.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];t&&!t[r]?n[r]=s:n[r]=s.optional()}),new xe({...this._def,shape:()=>n})}required(t){const n={};return ae.objectKeys(this.shape).forEach(r=>{if(t&&!t[r])n[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof At;)o=o._def.innerType;n[r]=o}}),new xe({...this._def,shape:()=>n})}keyof(){return af(ae.objectKeys(this.shape))}}xe.create=(e,t)=>new xe({shape:()=>e,unknownKeys:"strip",catchall:Bt.create(),typeName:F.ZodObject,...J(t)});xe.strictCreate=(e,t)=>new xe({shape:()=>e,unknownKeys:"strict",catchall:Bt.create(),typeName:F.ZodObject,...J(t)});xe.lazycreate=(e,t)=>new xe({shape:e,unknownKeys:"strip",catchall:Bt.create(),typeName:F.ZodObject,...J(t)});class vr extends te{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function s(o){for(const a of o)if(a.result.status==="valid")return a.result;for(const a of o)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const i=o.map(a=>new tt(a.ctx.common.issues));return V(n,{code:L.invalid_union,unionErrors:i}),Y}if(n.common.async)return Promise.all(r.map(async o=>{const i={...n,common:{...n.common,issues:[]},parent:null};return{result:await o._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(s);{let o;const i=[];for(const c of r){const u={...n,common:{...n.common,issues:[]},parent:null},l=c._parseSync({data:n.data,path:n.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!o&&(o={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(c=>new tt(c));return V(n,{code:L.invalid_union,unionErrors:a}),Y}}get options(){return this._def.options}}vr.create=(e,t)=>new vr({options:e,typeName:F.ZodUnion,...J(t)});const us=e=>e instanceof _r?us(e.schema):e instanceof ot?us(e.innerType()):e instanceof kr?[e.value]:e instanceof en?e.options:e instanceof Ar?Object.keys(e.enum):e instanceof $r?us(e._def.innerType):e instanceof wr?[void 0]:e instanceof xr?[null]:null;class Qs extends te{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Z.object)return V(n,{code:L.invalid_type,expected:Z.object,received:n.parsedType}),Y;const r=this.discriminator,s=n.data[r],o=this.optionsMap.get(s);return o?n.common.async?o._parseAsync({data:n.data,path:n.path,parent:n}):o._parseSync({data:n.data,path:n.path,parent:n}):(V(n,{code:L.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const s=new Map;for(const o of n){const i=us(o.shape[t]);if(!i)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of i){if(s.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);s.set(a,o)}}return new Qs({typeName:F.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:s,...J(r)})}}function ii(e,t){const n=zt(e),r=zt(t);if(e===t)return{valid:!0,data:e};if(n===Z.object&&r===Z.object){const s=ae.objectKeys(t),o=ae.objectKeys(e).filter(a=>s.indexOf(a)!==-1),i={...e,...t};for(const a of o){const c=ii(e[a],t[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(n===Z.array&&r===Z.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let o=0;o{if(si(o)||si(i))return Y;const a=ii(o.value,i.value);return a.valid?((oi(o)||oi(i))&&n.dirty(),{status:n.value,value:a.data}):(V(r,{code:L.invalid_intersection_types}),Y)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,i])=>s(o,i)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Er.create=(e,t,n)=>new Er({left:e,right:t,typeName:F.ZodIntersection,...J(n)});class gt extends te{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Z.array)return V(r,{code:L.invalid_type,expected:Z.array,received:r.parsedType}),Y;if(r.data.lengththis._def.items.length&&(V(r,{code:L.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const o=[...r.data].map((i,a)=>{const c=this._def.items[a]||this._def.rest;return c?c._parse(new pt(r,i,r.path,a)):null}).filter(i=>!!i);return r.common.async?Promise.all(o).then(i=>Ne.mergeArray(n,i)):Ne.mergeArray(n,o)}get items(){return this._def.items}rest(t){return new gt({...this._def,rest:t})}}gt.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new gt({items:e,typeName:F.ZodTuple,rest:null,...J(t)})};class Sr extends te{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Z.object)return V(r,{code:L.invalid_type,expected:Z.object,received:r.parsedType}),Y;const s=[],o=this._def.keyType,i=this._def.valueType;for(const a in r.data)s.push({key:o._parse(new pt(r,a,r.path,a)),value:i._parse(new pt(r,r.data[a],r.path,a))});return r.common.async?Ne.mergeObjectAsync(n,s):Ne.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof te?new Sr({keyType:t,valueType:n,typeName:F.ZodRecord,...J(r)}):new Sr({keyType:Xe.create(),valueType:t,typeName:F.ZodRecord,...J(n)})}}class Bs extends te{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Z.map)return V(r,{code:L.invalid_type,expected:Z.map,received:r.parsedType}),Y;const s=this._def.keyType,o=this._def.valueType,i=[...r.data.entries()].map(([a,c],u)=>({key:s._parse(new pt(r,a,r.path,[u,"key"])),value:o._parse(new pt(r,c,r.path,[u,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const c of i){const u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return Y;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),a.set(u.value,l.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const c of i){const u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return Y;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),a.set(u.value,l.value)}return{status:n.value,value:a}}}}Bs.create=(e,t,n)=>new Bs({valueType:t,keyType:e,typeName:F.ZodMap,...J(n)});class bn extends te{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Z.set)return V(r,{code:L.invalid_type,expected:Z.set,received:r.parsedType}),Y;const s=this._def;s.minSize!==null&&r.data.sizes.maxSize.value&&(V(r,{code:L.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const o=this._def.valueType;function i(c){const u=new Set;for(const l of c){if(l.status==="aborted")return Y;l.status==="dirty"&&n.dirty(),u.add(l.value)}return{status:n.value,value:u}}const a=[...r.data.values()].map((c,u)=>o._parse(new pt(r,c,r.path,u)));return r.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(t,n){return new bn({...this._def,minSize:{value:t,message:z.toString(n)}})}max(t,n){return new bn({...this._def,maxSize:{value:t,message:z.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}bn.create=(e,t)=>new bn({valueType:e,minSize:null,maxSize:null,typeName:F.ZodSet,...J(t)});class Rn extends te{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Z.function)return V(n,{code:L.invalid_type,expected:Z.function,received:n.parsedType}),Y;function r(a,c){return Ss({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Es(),yr].filter(u=>!!u),issueData:{code:L.invalid_arguments,argumentsError:c}})}function s(a,c){return Ss({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Es(),yr].filter(u=>!!u),issueData:{code:L.invalid_return_type,returnTypeError:c}})}const o={errorMap:n.common.contextualErrorMap},i=n.data;return this._def.returns instanceof qn?He(async(...a)=>{const c=new tt([]),u=await this._def.args.parseAsync(a,o).catch(d=>{throw c.addIssue(r(a,d)),c}),l=await i(...u);return await this._def.returns._def.type.parseAsync(l,o).catch(d=>{throw c.addIssue(s(l,d)),c})}):He((...a)=>{const c=this._def.args.safeParse(a,o);if(!c.success)throw new tt([r(a,c.error)]);const u=i(...c.data),l=this._def.returns.safeParse(u,o);if(!l.success)throw new tt([s(u,l.error)]);return l.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new Rn({...this._def,args:gt.create(t).rest(pn.create())})}returns(t){return new Rn({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new Rn({args:t||gt.create([]).rest(pn.create()),returns:n||pn.create(),typeName:F.ZodFunction,...J(r)})}}class _r extends te{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}_r.create=(e,t)=>new _r({getter:e,typeName:F.ZodLazy,...J(t)});class kr extends te{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return V(n,{received:n.data,code:L.invalid_literal,expected:this._def.value}),Y}return{status:"valid",value:t.data}}get value(){return this._def.value}}kr.create=(e,t)=>new kr({value:e,typeName:F.ZodLiteral,...J(t)});function af(e,t){return new en({values:e,typeName:F.ZodEnum,...J(t)})}class en extends te{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return V(n,{expected:ae.joinValues(r),received:n.parsedType,code:L.invalid_type}),Y}if(this._def.values.indexOf(t.data)===-1){const n=this._getOrReturnCtx(t),r=this._def.values;return V(n,{received:n.data,code:L.invalid_enum_value,options:r}),Y}return He(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t){return en.create(t)}exclude(t){return en.create(this.options.filter(n=>!t.includes(n)))}}en.create=af;class Ar extends te{_parse(t){const n=ae.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Z.string&&r.parsedType!==Z.number){const s=ae.objectValues(n);return V(r,{expected:ae.joinValues(s),received:r.parsedType,code:L.invalid_type}),Y}if(n.indexOf(t.data)===-1){const s=ae.objectValues(n);return V(r,{received:r.data,code:L.invalid_enum_value,options:s}),Y}return He(t.data)}get enum(){return this._def.values}}Ar.create=(e,t)=>new Ar({values:e,typeName:F.ZodNativeEnum,...J(t)});class qn extends te{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Z.promise&&n.common.async===!1)return V(n,{code:L.invalid_type,expected:Z.promise,received:n.parsedType}),Y;const r=n.parsedType===Z.promise?n.data:Promise.resolve(n.data);return He(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}qn.create=(e,t)=>new qn({type:e,typeName:F.ZodPromise,...J(t)});class ot extends te{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===F.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=this._def.effect||null;if(s.type==="preprocess"){const i=s.transform(r.data);return r.common.async?Promise.resolve(i).then(a=>this._def.schema._parseAsync({data:a,path:r.path,parent:r})):this._def.schema._parseSync({data:i,path:r.path,parent:r})}const o={addIssue:i=>{V(r,i),i.fatal?n.abort():n.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),s.type==="refinement"){const i=a=>{const c=s.refinement(a,o);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Y:(a.status==="dirty"&&n.dirty(),i(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Y:(a.status==="dirty"&&n.dirty(),i(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!_s(i))return i;const a=s.transform(i.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>_s(i)?Promise.resolve(s.transform(i.value,o)).then(a=>({status:n.value,value:a})):i);ae.assertNever(s)}}ot.create=(e,t,n)=>new ot({schema:e,typeName:F.ZodEffects,effect:t,...J(n)});ot.createWithPreprocess=(e,t,n)=>new ot({schema:t,effect:{type:"preprocess",transform:e},typeName:F.ZodEffects,...J(n)});class At extends te{_parse(t){return this._getType(t)===Z.undefined?He(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}At.create=(e,t)=>new At({innerType:e,typeName:F.ZodOptional,...J(t)});class wn extends te{_parse(t){return this._getType(t)===Z.null?He(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}wn.create=(e,t)=>new wn({innerType:e,typeName:F.ZodNullable,...J(t)});class $r extends te{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===Z.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}$r.create=(e,t)=>new $r({innerType:e,typeName:F.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...J(t)});class Os extends te{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ks(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new tt(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new tt(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Os.create=(e,t)=>new Os({innerType:e,typeName:F.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...J(t)});class Is extends te{_parse(t){if(this._getType(t)!==Z.nan){const r=this._getOrReturnCtx(t);return V(r,{code:L.invalid_type,expected:Z.nan,received:r.parsedType}),Y}return{status:"valid",value:t.data}}}Is.create=e=>new Is({typeName:F.ZodNaN,...J(e)});const Sy=Symbol("zod_brand");class cf extends te{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class Nr extends te{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Y:o.status==="dirty"?(n.dirty(),of(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Y:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(t,n){return new Nr({in:t,out:n,typeName:F.ZodPipeline})}}const uf=(e,t={},n)=>e?Mn.create().superRefine((r,s)=>{var o,i;if(!e(r)){const a=typeof t=="function"?t(r):typeof t=="string"?{message:t}:t,c=(i=(o=a.fatal)!==null&&o!==void 0?o:n)!==null&&i!==void 0?i:!0,u=typeof a=="string"?{message:a}:a;s.addIssue({code:"custom",...u,fatal:c})}}):Mn.create(),_y={object:xe.lazycreate};var F;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline"})(F||(F={}));const ky=(e,t={message:`Input not instance of ${e.name}`})=>uf(n=>n instanceof e,t),ff=Xe.create,lf=Jt.create,Ay=Is.create,$y=Qt.create,df=br.create,By=yn.create,Oy=As.create,Iy=wr.create,Ty=xr.create,Cy=Mn.create,Uy=pn.create,Py=Bt.create,Ny=$s.create,Ly=nt.create,Ry=xe.create,Hy=xe.strictCreate,jy=vr.create,Dy=Qs.create,Ky=Er.create,Zy=gt.create,Vy=Sr.create,My=Bs.create,qy=bn.create,zy=Rn.create,Fy=_r.create,Gy=kr.create,Yy=en.create,Wy=Ar.create,Xy=qn.create,Ra=ot.create,Jy=At.create,Qy=wn.create,eb=ot.createWithPreprocess,tb=Nr.create,nb=()=>ff().optional(),rb=()=>lf().optional(),sb=()=>df().optional(),ob={string:(e=>Xe.create({...e,coerce:!0})),number:(e=>Jt.create({...e,coerce:!0})),boolean:(e=>br.create({...e,coerce:!0})),bigint:(e=>Qt.create({...e,coerce:!0})),date:(e=>yn.create({...e,coerce:!0}))},ib=Y;var Re=Object.freeze({__proto__:null,defaultErrorMap:yr,setErrorMap:fy,getErrorMap:Es,makeIssue:Ss,EMPTY_PATH:ly,addIssueToContext:V,ParseStatus:Ne,INVALID:Y,DIRTY:of,OK:He,isAborted:si,isDirty:oi,isValid:_s,isAsync:ks,get util(){return ae},get objectUtil(){return ri},ZodParsedType:Z,getParsedType:zt,ZodType:te,ZodString:Xe,ZodNumber:Jt,ZodBigInt:Qt,ZodBoolean:br,ZodDate:yn,ZodSymbol:As,ZodUndefined:wr,ZodNull:xr,ZodAny:Mn,ZodUnknown:pn,ZodNever:Bt,ZodVoid:$s,ZodArray:nt,ZodObject:xe,ZodUnion:vr,ZodDiscriminatedUnion:Qs,ZodIntersection:Er,ZodTuple:gt,ZodRecord:Sr,ZodMap:Bs,ZodSet:bn,ZodFunction:Rn,ZodLazy:_r,ZodLiteral:kr,ZodEnum:en,ZodNativeEnum:Ar,ZodPromise:qn,ZodEffects:ot,ZodTransformer:ot,ZodOptional:At,ZodNullable:wn,ZodDefault:$r,ZodCatch:Os,ZodNaN:Is,BRAND:Sy,ZodBranded:cf,ZodPipeline:Nr,custom:uf,Schema:te,ZodSchema:te,late:_y,get ZodFirstPartyTypeKind(){return F},coerce:ob,any:Cy,array:Ly,bigint:$y,boolean:df,date:By,discriminatedUnion:Dy,effect:Ra,enum:Yy,function:zy,instanceof:ky,intersection:Ky,lazy:Fy,literal:Gy,map:My,nan:Ay,nativeEnum:Wy,never:Py,null:Ty,nullable:Qy,number:lf,object:Ry,oboolean:sb,onumber:rb,optional:Jy,ostring:nb,pipeline:tb,preprocess:eb,promise:Xy,record:Vy,set:qy,strictObject:Hy,string:ff,symbol:Oy,transformer:Ra,tuple:Zy,undefined:Iy,union:jy,unknown:Uy,void:Ny,NEVER:ib,ZodIssueCode:L,quotelessJson:uy,ZodError:tt});const hf=Re.string().regex(/^[a-fA-F0-9]$/),ab=Re.string().regex(/^[a-fA-F0-9]{64}$/),zn=Re.number().min(0).max(4294967295),cb=Re.bigint(),pf=Re.instanceof(Uint8Array),ub=Re.union([hf,zn,Re.string(),pf]).array(),Yi=Re.union([ub,hf,pf]),fb=Re.array(Yi),gf=Re.object({value:Re.union([zn,cb]),scriptPubKey:Yi}),lb=Re.object({txid:ab,vout:zn,scriptSig:Yi,sequence:zn,prevout:gf.optional(),witness:fb});Re.object({version:zn,vin:Re.array(lb),vout:Re.array(gf),locktime:zn});const ai=2048,db=new TextEncoder;function mf(e){const t=[],n=(s,o)=>{if(o<24)t.push(s*32+o);else if(o<=255)t.push(s*32+24,o);else if(o<=65535)t.push(s*32+25,o>>>8,o&255);else if(o<=4294967295){const i=new Uint8Array(4);new DataView(i.buffer).setUint32(0,o),t.push(s*32+26,...i)}else{t.push(s*32+27);const i=new Uint8Array(8);new DataView(i.buffer).setBigUint64(0,BigInt(o)),t.push(...i)}},r=(s,o=0)=>{if(o>64)throw new Error("Metadata nesting exceeds 64 levels.");if(s===null)t.push(246);else if(typeof s=="boolean")t.push(s?245:244);else if(typeof s=="number"&&Number.isFinite(s))if(Number.isSafeInteger(s)&&!Object.is(s,-0))n(s>=0?0:1,s>=0?s:-1-s);else{const i=new Uint8Array(8);new DataView(i.buffer).setFloat64(0,s),t.push(251,...i)}else if(typeof s=="string"){const i=db.encode(s);n(3,i.length);for(const a of i)t.push(a)}else if(Array.isArray(s))n(4,s.length),s.forEach(i=>r(i,o+1));else if(typeof s=="object"&&Object.getPrototypeOf(s)===Object.prototype){const i=Object.entries(s);n(5,i.length);for(const[a,c]of i)r(a,o+1),r(c,o+1)}else throw new Error("Metadata must contain only JSON values.");if(t.length>ai)throw new Error(`Metadata must be at most ${ai} CBOR bytes.`)};return r(e),Uint8Array.from(t)}function hb(e){if(e=new Uint8Array(e),!e.length||e.length>ai)throw new Error("Invalid CBOR metadata size.");let t=0;const n=o=>{if(t+o>e.length)throw new Error("Truncated CBOR metadata.");const i=e.slice(t,t+o);return t+=o,i},r=(o=0)=>{if(o>64)throw new Error("Metadata nesting exceeds 64 levels.");const i=n(1)[0],a=i>>5,c=i&31;if(a===7){if(c===20)return!1;if(c===21)return!0;if(c===22)return null;if(c===27){const l=new DataView(n(8).buffer).getFloat64(0);if(Number.isFinite(l))return l}throw new Error("Unsupported CBOR value.")}let u=c;if(c>=24&&c<=27){u=0;for(const l of n(2**(c-24)))u=u*256+l}else if(c>=28)throw new Error("Unsupported CBOR length.");if(!Number.isSafeInteger(u))throw new Error("CBOR integer exceeds JSON precision.");if(a===0)return u;if(a===1)return-1-u;if(a===3)return new TextDecoder("utf-8",{fatal:!0}).decode(n(u));if((a===4||a===5)&&u>e.length)throw new Error("Invalid CBOR collection length.");if(a===4)return Array.from({length:u},()=>r(o+1));if(a===5){const l={};for(let f=0;f({txid:e,vout:t,sequence:4294967295,prevout:{value:n,scriptPubKey:r}}),Je=(e,t)=>({value:e,scriptPubKey:t}),Ha=16*1024,St=1e3,Ce=500,Ts="text/plain;charset=utf-8",pb=["text/plain","application/json","text/html","image/svg+xml","image/png","image/jpeg","image/webp"],yf=new TextEncoder,dr=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join(""),sn=e=>Uint8Array.from(e.match(/../g)??[],t=>parseInt(t,16)),Cs=e=>dr(yf.encode(e));function Wi(e){const t=typeof e=="string"?{contentType:Ts,bytes:yf.encode(e)}:e;if(!t||![...pb,Ts].includes(t.contentType))throw new Error("Unsupported MIME type.");if(!(t.bytes instanceof Uint8Array)||!t.bytes.length)throw new Error("Enter non-empty inscription bytes.");if(t.bytes.length>Ha)throw new Error(`Body must be at most ${Ha} bytes.`);return{contentType:t.contentType,bytes:new Uint8Array(t.bytes)}}function Us(e){const t=/^([0-9a-f]{64})i(0|[1-9][0-9]*)$/.exec(e);if(!t||Number(t[2])>4294967295)throw new Error("Invalid parent inscription id.");let n=Number(t[2]),r="";for(;n;)r+=(n%256).toString(16).padStart(2,"0"),n=Math.floor(n/256);return t[1].match(/../g).reverse().join("")+r}function ja(e){if(typeof e!="string"||!/^[0-9a-f]{64,72}$/.test(e)||e.length%2)throw new Error("Invalid parent tag.");const t=[...sn(e.slice(64))].reduce((r,s,o)=>r+s*256**o,0),n=`${e.slice(0,64).match(/../g).reverse().join("")}i${t}`;if(Us(n)!==e)throw new Error("Non-canonical parent tag.");return n}function bf(e,t,n=null,r=void 0,s={}){const{contentType:o,bytes:i}=Wi(t),{delegate:a=null,pointer:c,metaprotocol:u=null}=s,l=u==null||u===""?null:new TextEncoder().encode(String(u));if(l&&l.length>520)throw new Error("Metaprotocol identifier must be 520 bytes or less.");const f=r===void 0?void 0:mf(r),d=[];for(let m=0;m{const y=m.length/2;return(y<=75?y.toString(16).padStart(2,"0"):y<=255?"4c"+y.toString(16).padStart(2,"0"):"4d"+(y%256).toString(16).padStart(2,"0")+Math.floor(y/256).toString(16).padStart(2,"0"))+m};return h(e)+"ac0063"+h(Cs("ord"))+h("01")+h(Cs(o))+(a?h("0b")+h(Us(a)):"")+(c===void 0?"":h("02")+h(wf(c)))+(n?h("03")+h(Us(n)):"")+(f===void 0?"":Array.from({length:Math.ceil(f.length/520)},(m,y)=>h("05")+h(dr(f.slice(y*520,(y+1)*520)))).join(""))+(l?h("07")+h(dr(l)):"")+"00"+d.map(h).join("")+"68"}function Xi(e){if(!Array.isArray(e)||e.length!==3)throw new Error("Unsupported script-path witness.");const t=_e.decode(e[1]);let n=7,r=null,s=null,o;t[n]==="0b"&&(s=ja(t[n+1]),n+=2),t[n]==="02"&&(o=mb(t[n+1]==="OP_0"?"":t[n+1]),n+=2),t[n]==="03"&&(r=ja(t[n+1]),n+=2);const i=[];for(;t[n]==="05";){const m=t[n+1];if(typeof m!="string"||!/^(?:[0-9a-f]{2}){1,520}$/.test(m))throw new Error("Invalid metadata push.");i.push(m),n+=2}const a=i.length?hb(sn(i.join(""))):void 0;let c=null;if(t[n]==="07"){const m=t[n+1];if(typeof m!="string"||!/^(?:[0-9a-f]{2}){1,520}$/.test(m))throw new Error("Invalid metaprotocol field.");c=new TextDecoder().decode(sn(m)),n+=2}if(t[n]!=="OP_0")throw new Error("Unsupported ord tag or missing body separator.");const u=t.slice(n+1,-1);if(!u.length||u.some(m=>typeof m!="string"||!/^(?:[0-9a-f]{2})+$/.test(m)))throw new Error("Invalid body envelope.");const l=new TextDecoder().decode(sn(t[6])),f=Wi({contentType:l,bytes:sn(u.join(""))}),d=bf(t[0],f,r,a,{delegate:s,pointer:o,metaprotocol:c}),h=a===void 0&&!r&&l===Ts&&f.bytes.length<=280&&_e.encode([t[0],"OP_CHECKSIG","OP_0","OP_IF",Cs("ord"),"01",Cs(Ts),"OP_0",dr(f.bytes),"OP_ENDIF"],!1).hex;if(d!==e[1]&&h!==e[1])throw new Error("Unsupported ord envelope.");if(!/^[0-9a-f]{64}$/.test(t[0]))throw new Error("Invalid inscription signing key.");return{...f,parent:r,delegate:s,pointer:o,metaprotocol:c,metadata:a,metadataBytes:i.length?sn(i.join("")):void 0,text:new TextDecoder().decode(f.bytes),pubkey:t[0]}}class gb{constructor(t,n){this.chain=t,this.wallet=n}prepare(t,n=null,r=void 0,s={}){const o=Wi(t);if(r!==void 0&&mf(r),s.delegate&&Us(s.delegate),s.pointer!==void 0&&wf(s.pointer),s.metaprotocol!==void 0&&s.metaprotocol!==null&&s.metaprotocol!==""&&new TextEncoder().encode(String(s.metaprotocol)).length>520)throw new Error("Metaprotocol identifier must be 520 bytes or less.");if(n&&s.reinscribe)throw new Error("Choose parent or reinscription, not both.");const i=this.chain.coins(this.wallet.script),a=n?i.find(l=>{var f;return(f=l.inscriptions)==null?void 0:f.some(d=>d.id===n)}):null;if(n&&!a)throw new Error("Parent must be an owned, unspent inscription.");const c=s.reinscribe?i.find(l=>{var f;return(f=l.inscriptions)==null?void 0:f.some(d=>d.id===s.reinscribe)}):null;if(s.reinscribe&&!c)throw new Error("Reinscription must spend an owned sat.");const u=i.find(l=>!l.inscription&&l.value>=St+2*Ce+330);if(!u)throw new Error("Mine a block first to get spendable fake BTC.");return{...o,coin:u,parent:a,reinscribe:c,totalFee:Ce*2,postage:St}}inscribe(t,n=null,r=void 0,s={}){const{coin:o,parent:i,reinscribe:a,...c}=this.prepare(t,n,r,s),u=i??a,l=a==null?void 0:a.inscriptions.find(B=>B.id===s.reinscribe),f=l?this.chain.satLocation(l.sat).offset:s.pointer??(i?i.value:void 0),d=bf(this.wallet.pubkey,c,n,r,{...s,pointer:f}),h=vs.encodeScript(d),[m,y]=vs.getPubKey(this.wallet.pubkey,{target:h}),p=de.create({vin:[Hn(o.txid,o.vout,o.value,o.scriptPubKey)],vout:[Je(St+Ce,["OP_1",m]),Je(o.value-St-2*Ce,this.wallet.script)]});p.vin[0].witness=[this.wallet.sign(p)];const g=de.util.getTxid(p),x=de.create({vin:[...u?[Hn(u.txid,u.vout,u.value,u.scriptPubKey)]:[],Hn(g,0,St+Ce,["OP_1",m])],vout:[...u?[Je(u.value,this.wallet.script)]:[],Je(St,this.wallet.script)]}),w=u?1:0;return x.vin[w].witness=[this.wallet.sign(x,h,w),_e.encode(d,!1).hex,y],u&&(x.vin[0].witness=[this.wallet.sign(x)]),this.chain.submitPackage([de.encode(p).hex,de.encode(x).hex]),`${de.util.getTxid(x)}i0`}list(){return this.chain.coins(this.wallet.script).flatMap(t=>t.inscriptions??[])}}function wf(e){let t;try{t=BigInt(e)}catch{throw new Error("Invalid pointer.")}if(t<0n||t>0xffffffffffffffffn||typeof e=="number"&&!Number.isSafeInteger(e))throw new Error("Invalid pointer.");let n="";for(;t;)n+=Number(t&255n).toString(16).padStart(2,"0"),t>>=8n;return n}function mb(e){if(typeof e!="string"||!/^(?:[0-9a-f]{2}){0,8}$/.test(e))throw new Error("Invalid pointer tag.");return[...sn(e)].reduce((t,n,r)=>t+(BigInt(n)<{var g;const i=de.decode(r),a=de.util.getTxid(i),c=i.vin[0].txid==="0".repeat(64),u=c?[]:i.vin.map(x=>this.utxos.get(`${x.txid}:${x.vout}`)),l=vc(i,u,s,c);i.vin.forEach(x=>this.utxos.delete(`${x.txid}:${x.vout}`)),i.vout.forEach((x,w)=>this.utxos.set(`${a}:${w}`,{txid:a,vout:w,value:Number(x.value),ranges:l[w]}));const f=(g=i.vin.find(x=>{var w;return((w=x.witness)==null?void 0:w.length)===3}))==null?void 0:g.witness;if(!f)return;const d=Xi(f),h=BigInt(d.pointer??0),m=i.vout.reduce((x,w)=>x+Number(w.value),0),y=xc(l.flat(),hx.sat===y).length,status:s===null?"pending":"confirmed",height:s,block:o,metadata:p??null,hasMetadata:p!==void 0,parent:d.parent,protocol:d.metaprotocol??(p&&!Array.isArray(p)&&typeof p=="object"&&Object.hasOwn(p,"protocol")&&typeof p.protocol=="string"?p.protocol:null)})};for(const r of t.blocks)for(const s of r.raws)n(s,r.height,r.hash);for(const r of t.mempool)n(r,null,null);for(const r of this.events){r.location=null;for(const s of this.utxos.values()){const o=as(s.ranges,r.sat);if(o!==null){r.location={txid:s.txid,vout:s.vout,offset:o};break}}r.delegatedBy=this.events.filter(s=>s.delegate===r.id).map(s=>s.id),r.inscriptions=this.events.filter(s=>s.sat===r.sat).map(s=>s.id)}}forProtocol(t){return this.events.filter(n=>n.protocol===t)}get protocols(){return[...new Set(this.events.filter(t=>t.protocol!==null).map(t=>t.protocol))].sort()}get stats(){return{events:this.events.length,withMetadata:this.events.filter(t=>t.hasMetadata).length,confirmed:this.events.filter(t=>t.status==="confirmed").length,pending:this.events.filter(t=>t.status==="pending").length,protocols:this.protocols}}}const Ji="lineage/v0",yb=["white","green","black"],Da="names are 1-40 lowercase letters, digits or hyphens (they become domains)",bb=/^[a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?$/,So=e=>typeof e=="string"&&bb.test(e),fs=(e,t)=>typeof e=="string"?e.trim().slice(0,t):"";function Qi(e){return String(e??"").toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/,"")}const ea=e=>e.events.filter(t=>t.protocol===Ji);function Fn(e,{upTo:t=1/0,pending:n=!1}={}){const r=new Map,s=[],o=[],i=a=>a.status==="active";for(const a of e){const c=a.status==="confirmed";if(c?a.height>t:!n)continue;const u=a.metadata&&typeof a.metadata=="object"&&!Array.isArray(a.metadata)?a.metadata:{},l={id:a.id,op:typeof u.op=="string"?u.op.slice(0,20):"?",beat:c?a.height:null,pending:!c,meta:u,parent:a.parent??null,ok:!0,why:"",node:null,root:null,also:[]},f=l.parent?r.get(l.parent):null,d=l.beat??"cued",h=p=>{l.ok=!1,l.why=p},m=p=>f?i(f)?"":`the ${p} is ${f.status}`:`the ${p} is not in this lineage`;let y="";switch(l.op){case"found":if(l.parent)h("a holding has no parent");else if(!So(u.name))h(Da);else if(s.some(p=>i(p)&&p.name===u.name))h(`an active holding is already named ${u.name}`);else{const p=Ka(a,u.name,null,"holding");r.set(p.id,p),s.push(p),l.node=p.id}break;case"birth":{const p=u.kind==="agent"?"agent":"org";if(y=m("parent"))h(y);else if(f.kind==="agent")h("agents do not give birth");else if(!So(u.name))h(Da);else if(f.children.some(g=>i(r.get(g))&&r.get(g).name===u.name))h(`${f.name} already has an active ${u.name}`);else{const g=Ka(a,u.name,f,p);g.index=f.children.filter(x=>r.get(x).kind===p).length,f.children.push(g.id),r.set(g.id,g),l.node=g.id}break}case"award":{const p=r.get(u.to);(y=m("issuer"))?h(y):f.kind==="agent"?h("agents do not award belts"):!p||p.root!==f.root||p.id===f.id?h("the recipient must be another node in this holding"):i(p)?!So(u.skill)||!yb.includes(u.belt)?h("an award needs a skill name and a belt (white, green or black)"):(p.badges=p.badges.filter(g=>g.skill!==u.skill),p.badges.push({skill:u.skill,belt:u.belt,by:f.id,beat:d,id:a.id}),l.node=p.id):h(`the recipient is ${p.status}`);break}case"decide":(y=m("decider"))?h(y):fs(u.title,140)?(f.decisions.push({title:fs(u.title,140),why:fs(u.why,400),beat:d,id:a.id}),l.node=f.id):h("a decision needs a title");break;case"graduate":{const p=r.get(u.of);(y=m("parent"))?h(y):!p||p.parent!==f.id?h("only its parent can graduate a child"):p.kind!=="org"?h("only orgs graduate"):i(p)?p.edge==="adopted"?h("already graduated"):(p.edge="adopted",p.graduated=d,l.node=p.id):h(`the child is ${p.status}`);break}case"close":if(!f)h(l.parent?"that node is not in this lineage":"a close spends the node it closes");else if(!i(f))h(`already ${f.status}`);else{const p=g=>{g.status="closed",g.closed=d;for(const x of g.children){const w=r.get(x);w.edge==="derived"&&i(w)&&(l.also.push(w.id),p(w))}};p(f),l.node=f.id}break;default:h("not a lineage/v0 op")}l.root=l.node?r.get(l.node).root:(f==null?void 0:f.root)??null,o.push(l)}return{nodes:r,roots:s,log:o}}function Ka(e,t,n,r){return{id:e.id,name:t,kind:r,parent:(n==null?void 0:n.id)??null,root:n?n.root:e.id,edge:n?"derived":null,status:"active",index:null,born:e.status==="confirmed"?e.height:"cued",children:[],badges:[],decisions:[],graduated:null,closed:null}}function wb(e,t){const n=[],r=e.nodes.get(t),s=(o,i,a)=>{n.push({type:"node",node:o,guide:i,path:o.parent?`${o.index}'`:"●"});const c=o.children.map(l=>e.nodes.get(l)),u=[["agents",c.filter(l=>l.kind==="agent")],["orgs",c.filter(l=>l.kind!=="agent")]].filter(([,l])=>l.length);u.forEach(([l,f],d)=>{const h=d===u.length-1,m=a+(h?" ":"│ ");n.push({type:"group",label:l,guide:a+(h?"└─ ":"├─ ")}),f.forEach((y,p)=>{const g=p===f.length-1;s(y,m+(g?"└─ ":"├─ "),m+(g?" ":"│ "))})})};return r&&s(r,"",""),n}function xb(e,t){const n={orgs:0,agents:0,belts:0,decisions:0,closed:0};for(const r of e.nodes.values())r.root===t&&(r.id!==t&&(n[r.kind==="agent"?"agents":"orgs"]++,r.status==="closed"&&n.closed++),n.belts+=r.badges.length,n.decisions+=r.decisions.length);return n}function xf(e,t){const n=[];for(let r=e.nodes.get(t);r;r=e.nodes.get(r.parent))n.unshift(r.name);return n.join(" / ")}function vf(e,t){const n=e.meta,r=s=>{var o;return((o=t.nodes.get(s))==null?void 0:o.name)??(typeof s=="string"?`${s.slice(0,8)}…`:"?")};if(!e.ok)return`${e.op}: ${e.why}`;switch(e.op){case"found":return`found ${n.name}`;case"birth":return`birth ${n.name}${n.kind==="agent"?" (agent)":""} ← ${r(e.parent)}`;case"award":return`award ${n.skill} · ${n.belt} → ${r(n.to)}, from ${r(e.parent)}`;case"decide":return`decide “${fs(n.title,140)}” · ${r(e.parent)}`;case"graduate":return`graduate ${r(n.of)} from ${r(e.parent)}`;case"close":return`close ${r(e.parent)}${e.also.length?` and ${e.also.length} derived`:""}`;default:return e.op}}const On=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Lr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Yt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ue(e,...t){if(!Lr(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Rr(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Yt(e.outputLen),Yt(e.blockLen)}function Ps(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function vb(e,t){Ue(e);const n=t.outputLen;if(e.length>>t}function Fr(e,t){return e<>>32-t>>>0}const Ef=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Eb=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Pe(e){if(Ue(e),Ef)return e.toHex();let t="";for(let n=0;n=vt._0&&e<=vt._9)return e-vt._0;if(e>=vt.A&&e<=vt.F)return e-(vt.A-10);if(e>=vt.a&&e<=vt.f)return e-(vt.a-10)}function yt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Ef)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let s=0,o=0;se().update(Br(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function $n(e=32){if(On&&typeof On.getRandomValues=="function")return On.getRandomValues(new Uint8Array(e));if(On&&typeof On.randomBytes=="function")return Uint8Array.from(On.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function _b(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,a,r)}function kb(e,t,n){return e&t^~e&n}function Ab(e,t,n){return e&t^e&n^t&n}class na extends Sf{constructor(t,n,r,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.buffer=new Uint8Array(t),this.view=gn(this.buffer)}update(t){Ps(this),t=Br(t),Ue(t);const{view:n,buffer:r,blockLen:s}=this,o=t.length;for(let i=0;is-i&&(this.process(r,0),i=0);for(let f=i;fl.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f>Ma&Gr)}:{h:Number(e>>Ma&Gr)|0,l:Number(e&Gr)|0}}function Bb(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let o=0;oe>>>n,za=(e,t,n)=>e<<32-n|t>>>n,In=(e,t,n)=>e>>>n|t<<32-n,Tn=(e,t,n)=>e<<32-n|t>>>n,Yr=(e,t,n)=>e<<64-n|t>>>n-32,Wr=(e,t,n)=>e>>>n-32|t<<64-n;function Et(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Ob=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Ib=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Tb=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Cb=(e,t,n,r,s)=>t+n+r+s+(e/2**32|0)|0,Ub=(e,t,n,r,s)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(s>>>0),Pb=(e,t,n,r,s,o)=>t+n+r+s+o+(e/2**32|0)|0,Nb=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Kt=new Uint32Array(64);class Lb extends na{constructor(t=32){super(64,t,8,!1),this.A=Dt[0]|0,this.B=Dt[1]|0,this.C=Dt[2]|0,this.D=Dt[3]|0,this.E=Dt[4]|0,this.F=Dt[5]|0,this.G=Dt[6]|0,this.H=Dt[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[t,n,r,s,o,i,a,c]}set(t,n,r,s,o,i,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,n){for(let f=0;f<16;f++,n+=4)Kt[f]=t.getUint32(n,!1);for(let f=16;f<64;f++){const d=Kt[f-15],h=Kt[f-2],m=lt(d,7)^lt(d,18)^d>>>3,y=lt(h,17)^lt(h,19)^h>>>10;Kt[f]=y+Kt[f-7]+m+Kt[f-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:u,H:l}=this;for(let f=0;f<64;f++){const d=lt(a,6)^lt(a,11)^lt(a,25),h=l+d+kb(a,c,u)+Nb[f]+Kt[f]|0,y=(lt(r,2)^lt(r,13)^lt(r,22))+Ab(r,s,o)|0;l=u,u=c,c=a,a=i+h|0,i=o,o=s,s=r,r=h+y|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,s,o,i,a,c,u,l)}roundClean(){mt(Kt)}destroy(){this.set(0,0,0,0,0,0,0,0),mt(this.buffer)}}const _f=Bb(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Rb=_f[0],Hb=_f[1],Zt=new Uint32Array(80),Vt=new Uint32Array(80);class jb extends na{constructor(t=64){super(128,t,16,!1),this.Ah=Oe[0]|0,this.Al=Oe[1]|0,this.Bh=Oe[2]|0,this.Bl=Oe[3]|0,this.Ch=Oe[4]|0,this.Cl=Oe[5]|0,this.Dh=Oe[6]|0,this.Dl=Oe[7]|0,this.Eh=Oe[8]|0,this.El=Oe[9]|0,this.Fh=Oe[10]|0,this.Fl=Oe[11]|0,this.Gh=Oe[12]|0,this.Gl=Oe[13]|0,this.Hh=Oe[14]|0,this.Hl=Oe[15]|0}get(){const{Ah:t,Al:n,Bh:r,Bl:s,Ch:o,Cl:i,Dh:a,Dl:c,Eh:u,El:l,Fh:f,Fl:d,Gh:h,Gl:m,Hh:y,Hl:p}=this;return[t,n,r,s,o,i,a,c,u,l,f,d,h,m,y,p]}set(t,n,r,s,o,i,a,c,u,l,f,d,h,m,y,p){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=s|0,this.Ch=o|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=l|0,this.Fh=f|0,this.Fl=d|0,this.Gh=h|0,this.Gl=m|0,this.Hh=y|0,this.Hl=p|0}process(t,n){for(let w=0;w<16;w++,n+=4)Zt[w]=t.getUint32(n),Vt[w]=t.getUint32(n+=4);for(let w=16;w<80;w++){const B=Zt[w-15]|0,A=Vt[w-15]|0,I=In(B,A,1)^In(B,A,8)^qa(B,A,7),P=Tn(B,A,1)^Tn(B,A,8)^za(B,A,7),C=Zt[w-2]|0,k=Vt[w-2]|0,U=In(C,k,19)^Yr(C,k,61)^qa(C,k,6),H=Tn(C,k,19)^Wr(C,k,61)^za(C,k,6),D=Tb(P,H,Vt[w-7],Vt[w-16]),v=Cb(D,I,U,Zt[w-7],Zt[w-16]);Zt[w]=v|0,Vt[w]=D|0}let{Ah:r,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:u,Dl:l,Eh:f,El:d,Fh:h,Fl:m,Gh:y,Gl:p,Hh:g,Hl:x}=this;for(let w=0;w<80;w++){const B=In(f,d,14)^In(f,d,18)^Yr(f,d,41),A=Tn(f,d,14)^Tn(f,d,18)^Wr(f,d,41),I=f&h^~f&y,P=d&m^~d&p,C=Ub(x,A,P,Hb[w],Vt[w]),k=Pb(C,g,B,I,Rb[w],Zt[w]),U=C|0,H=In(r,s,28)^Yr(r,s,34)^Yr(r,s,39),D=Tn(r,s,28)^Wr(r,s,34)^Wr(r,s,39),v=r&o^r&a^o&a,E=s&i^s&c^i&c;g=y|0,x=p|0,y=h|0,p=m|0,h=f|0,m=d|0,{h:f,l:d}=Et(u|0,l|0,k|0,U|0),u=a|0,l=c|0,a=o|0,c=i|0,o=r|0,i=s|0;const b=Ob(U,D,E);r=Ib(b,k,H,v),s=b|0}({h:r,l:s}=Et(this.Ah|0,this.Al|0,r|0,s|0)),{h:o,l:i}=Et(this.Bh|0,this.Bl|0,o|0,i|0),{h:a,l:c}=Et(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l}=Et(this.Dh|0,this.Dl|0,u|0,l|0),{h:f,l:d}=Et(this.Eh|0,this.El|0,f|0,d|0),{h,l:m}=Et(this.Fh|0,this.Fl|0,h|0,m|0),{h:y,l:p}=Et(this.Gh|0,this.Gl|0,y|0,p|0),{h:g,l:x}=Et(this.Hh|0,this.Hl|0,g|0,x|0),this.set(r,s,o,i,a,c,u,l,f,d,h,m,y,p,g,x)}roundClean(){mt(Zt,Vt)}destroy(){mt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const it=ta(()=>new Lb),Or=ta(()=>new jb);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ra=BigInt(0),ci=BigInt(1);function xn(e,t=""){if(typeof e!="boolean"){const n=t&&`"${t}"`;throw new Error(n+"expected boolean, got type="+typeof e)}return e}function Qe(e,t,n=""){const r=Lr(e),s=e==null?void 0:e.length,o=t!==void 0;if(!r||o&&s!==t){const i=n&&`"${n}" `,a=o?` of length ${t}`:"",c=r?`length=${s}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+a+", got "+c)}return e}function Xr(e){const t=e.toString(16);return t.length&1?"0"+t:t}function kf(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?ra:BigInt("0x"+e)}function er(e){return kf(Pe(e))}function vn(e){return Ue(e),kf(Pe(Uint8Array.from(e).reverse()))}function to(e,t){return yt(e.toString(16).padStart(t*2,"0"))}function sa(e,t){return to(e,t).reverse()}function ue(e,t,n){let r;if(typeof t=="string")try{r=yt(t)}catch(o){throw new Error(e+" must be hex string or Uint8Array, cause: "+o)}else if(Lr(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(e+" of length "+n+" expected, got "+s);return r}function Fa(e){return Uint8Array.from(e)}const _o=e=>typeof e=="bigint"&&ra<=e;function ui(e,t,n){return _o(e)&&_o(t)&&_o(n)&&t<=e&&era;e>>=ci,t+=1);return t}const Hr=e=>(ci<new Uint8Array(h),s=h=>Uint8Array.of(h);let o=r(e),i=r(e),a=0;const c=()=>{o.fill(1),i.fill(0),a=0},u=(...h)=>n(i,o,...h),l=(h=r(0))=>{i=u(s(0),h),o=u(),h.length!==0&&(i=u(s(1),h),o=u())},f=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const m=[];for(;h{c(),l(h);let y;for(;!(y=m(f()));)l();return c(),y}}function tr(e,t,n={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function r(s,o,i){const a=e[s];if(i&&a===void 0)return;const c=typeof a;if(c!==o||a===null)throw new Error(`param "${s}" is invalid: expected ${o}, got ${c}`)}Object.entries(t).forEach(([s,o])=>r(s,o,!1)),Object.entries(n).forEach(([s,o])=>r(s,o,!0))}function Ns(e){const t=new WeakMap;return(n,...r)=>{const s=t.get(n);if(s!==void 0)return s;const o=e(n,...r);return t.set(n,o),o}}const fi=Pe;class $f extends Sf{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,Rr(t);const r=Br(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,o=new Uint8Array(s);o.set(r.length>s?t.create().update(r).digest():r);for(let i=0;inew $f(e,t).update(n).digest();tn.create=(e,t)=>new $f(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const De=BigInt(0),Be=BigInt(1),fn=BigInt(2),Bf=BigInt(3),Of=BigInt(4),If=BigInt(5),Kb=BigInt(7),Tf=BigInt(8),Zb=BigInt(9),Cf=BigInt(16);function me(e,t){const n=e%t;return n>=De?n:t+n}function we(e,t,n){let r=e;for(;t-- >De;)r*=r,r%=n;return r}function Ga(e,t){if(e===De)throw new Error("invert: expected non-zero number");if(t<=De)throw new Error("invert: expected positive modulus, got "+t);let n=me(e,t),r=t,s=De,o=Be;for(;n!==De;){const a=r/n,c=r%n,u=s-o*a;r=n,n=c,s=o,o=u}if(r!==Be)throw new Error("invert: does not exist");return me(s,t)}function oa(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function Uf(e,t){const n=(e.ORDER+Be)/Of,r=e.pow(t,n);return oa(e,r,t),r}function Vb(e,t){const n=(e.ORDER-If)/Tf,r=e.mul(t,fn),s=e.pow(r,n),o=e.mul(t,s),i=e.mul(e.mul(o,fn),s),a=e.mul(o,e.sub(i,e.ONE));return oa(e,a,t),a}function Mb(e){const t=Bn(e),n=Pf(e),r=n(t,t.neg(t.ONE)),s=n(t,r),o=n(t,t.neg(r)),i=(e+Kb)/Cf;return(a,c)=>{let u=a.pow(c,i),l=a.mul(u,r);const f=a.mul(u,s),d=a.mul(u,o),h=a.eql(a.sqr(l),c),m=a.eql(a.sqr(f),c);u=a.cmov(u,l,h),l=a.cmov(d,f,m);const y=a.eql(a.sqr(l),c),p=a.cmov(u,l,y);return oa(a,p,c),p}}function Pf(e){if(e1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Uf;let o=s.pow(r,t);const i=(t+Be)/fn;return function(c,u){if(c.is0(u))return u;if(Ya(c,u)!==1)throw new Error("Cannot find square root");let l=n,f=c.mul(c.ONE,o),d=c.pow(u,t),h=c.pow(u,i);for(;!c.eql(d,c.ONE);){if(c.is0(d))return c.ZERO;let m=1,y=c.sqr(d);for(;!c.eql(y,c.ONE);)if(m++,y=c.sqr(y),m===l)throw new Error("Cannot find square root");const p=Be<(me(e,t)&Be)===Be,Fb=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Gb(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=Fb.reduce((r,s)=>(r[s]="function",r),t);return tr(e,n),e}function Yb(e,t,n){if(nDe;)n&Be&&(r=e.mul(r,s)),s=e.sqr(s),n>>=Be;return r}function Nf(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),s=t.reduce((i,a,c)=>e.is0(a)?i:(r[c]=i,e.mul(i,a)),e.ONE),o=e.inv(s);return t.reduceRight((i,a,c)=>e.is0(a)?i:(r[c]=e.mul(i,r[c]),e.mul(i,a)),o),r}function Ya(e,t){const n=(e.ORDER-Be)/fn,r=e.pow(t,n),s=e.eql(r,e.ONE),o=e.eql(r,e.ZERO),i=e.eql(r,e.neg(e.ONE));if(!s&&!o&&!i)throw new Error("invalid Legendre symbol result");return s?1:o?0:-1}function Lf(e,t){t!==void 0&&Yt(t);const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Bn(e,t,n=!1,r={}){if(e<=De)throw new Error("invalid field: expected ORDER > 0, got "+e);let s,o,i=!1,a;if(typeof t=="object"&&t!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const d=t;d.BITS&&(s=d.BITS),d.sqrt&&(o=d.sqrt),typeof d.isLE=="boolean"&&(n=d.isLE),typeof d.modFromBytes=="boolean"&&(i=d.modFromBytes),a=d.allowedLengths}else typeof t=="number"&&(s=t),r.sqrt&&(o=r.sqrt);const{nBitLength:c,nByteLength:u}=Lf(e,s);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l;const f=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:u,MASK:Hr(c),ZERO:De,ONE:Be,allowedLengths:a,create:d=>me(d,e),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return De<=d&&dd===De,isValidNot0:d=>!f.is0(d)&&f.isValid(d),isOdd:d=>(d&Be)===Be,neg:d=>me(-d,e),eql:(d,h)=>d===h,sqr:d=>me(d*d,e),add:(d,h)=>me(d+h,e),sub:(d,h)=>me(d-h,e),mul:(d,h)=>me(d*h,e),pow:(d,h)=>Yb(f,d,h),div:(d,h)=>me(d*Ga(h,e),e),sqrN:d=>d*d,addN:(d,h)=>d+h,subN:(d,h)=>d-h,mulN:(d,h)=>d*h,inv:d=>Ga(d,e),sqrt:o||(d=>(l||(l=qb(e)),l(f,d))),toBytes:d=>n?sa(d,u):to(d,u),fromBytes:(d,h=!0)=>{if(a){if(!a.includes(d.length)||d.length>u)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+d.length);const y=new Uint8Array(u);y.set(d,n?0:y.length-d.length),d=y}if(d.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+d.length);let m=n?vn(d):er(d);if(i&&(m=me(m,e)),!h&&!f.isValid(m))throw new Error("invalid field element: outside of range 0..ORDER");return m},invertBatch:d=>Nf(f,d),cmov:(d,h,m)=>m?h:d});return Object.freeze(f)}function Rf(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function Hf(e){const t=Rf(e);return t+Math.ceil(t/2)}function jf(e,t,n=!1){const r=e.length,s=Rf(t),o=Hf(t);if(r<16||r1024)throw new Error("expected "+o+"-1024 bytes of input, got "+r);const i=n?vn(e):er(e),a=me(i,t-Be)+Be;return n?sa(a,s):to(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Gn=BigInt(0),ln=BigInt(1);function Ls(e,t){const n=t.negate();return e?n:t}function dn(e,t){const n=Nf(e.Fp,t.map(r=>r.Z));return t.map((r,s)=>e.fromAffine(r.toAffine(n[s])))}function Df(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function ko(e,t){Df(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1),s=2**e,o=Hr(e),i=BigInt(e);return{windows:n,windowSize:r,mask:o,maxNumber:s,shiftBy:i}}function Wa(e,t,n){const{windowSize:r,mask:s,maxNumber:o,shiftBy:i}=n;let a=Number(e&s),c=e>>i;a>r&&(a-=o,c+=ln);const u=t*r,l=u+Math.abs(a)-1,f=a===0,d=a<0,h=t%2!==0;return{nextN:c,offset:l,isZero:f,isNeg:d,isNegF:h,offsetF:u}}function Wb(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function Xb(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}const Ao=new WeakMap,Kf=new WeakMap;function $o(e){return Kf.get(e)||1}function Xa(e){if(e!==Gn)throw new Error("invalid wNAF")}class Zf{constructor(t,n){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=n}_unsafeLadder(t,n,r=this.ZERO){let s=t;for(;n>Gn;)n&ln&&(r=r.add(s)),s=s.double(),n>>=ln;return r}precomputeWindow(t,n){const{windows:r,windowSize:s}=ko(n,this.bits),o=[];let i=t,a=i;for(let c=0;cGn||r>Gn;)n&ln&&(o=o.add(s)),r&ln&&(i=i.add(s)),s=s.double(),n>>=ln,r>>=ln;return{p1:o,p2:i}}function Vf(e,t,n,r){Wb(n,e),Xb(r,t);const s=n.length,o=r.length;if(s!==o)throw new Error("arrays of points and scalars must have equal length");const i=e.ZERO,a=Af(BigInt(s));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const u=Hr(c),l=new Array(Number(u)+1).fill(i),f=Math.floor((t.BITS-1)/c)*c;let d=i;for(let h=f;h>=0;h-=c){l.fill(i);for(let y=0;y>BigInt(h)&u);l[g]=l[g].add(n[y])}let m=i;for(let y=l.length-1,p=i;y>0;y--)p=p.add(l[y]),m=m.add(p);if(d=d.add(m),h!==0)for(let y=0;yGn))throw new Error(`CURVE.${c} must be positive bigint`)}const s=Ja(t.p,n.Fp,r),o=Ja(t.n,n.Fn,r),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(const c of a)if(!s.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:s,Fn:o}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Qa=(e,t)=>(e+(e>=0?t:-t)/qf)/t;function Qb(e,t,n){const[[r,s],[o,i]]=t,a=Qa(i*e,n),c=Qa(-s*e,n);let u=e-a*r-c*o,l=-a*s-c*i;const f=u=h||l=h)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:u,k2neg:d,k2:l}}function li(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Bo(e,t){const n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return xn(n.lowS,"lowS"),xn(n.prehash,"prehash"),n.format!==void 0&&li(n.format),n}class ew extends Error{constructor(t=""){super(t)}}const _t={Err:ew,_tlv:{encode:(e,t)=>{const{Err:n}=_t;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const r=t.length/2,s=Xr(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const o=r>127?Xr(s.length/2|128):"";return Xr(e)+o+s+t},decode(e,t){const{Err:n}=_t;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const s=t[r++],o=!!(s&128);let i=0;if(!o)i=s;else{const c=s&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");const u=t.subarray(r,r+c);if(u.length!==c)throw new n("tlv.decode: length bytes not complete");if(u[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const l of u)i=i<<8|l;if(r+=c,i<128)throw new n("tlv.decode(long): not minimal encoding")}const a=t.subarray(r,r+i);if(a.length!==i)throw new n("tlv.decode: wrong value length");return{v:a,l:t.subarray(r+i)}}},_int:{encode(e){const{Err:t}=_t;if(e{const{X:E,Y:b,Z:S}=D;if(r.eql(S,r.ONE))return{x:E,y:b};const $=D.is0();v==null&&(v=$?r.ONE:r.inv(S));const N=r.mul(E,v),T=r.mul(b,v),j=r.mul(S,v);if($)return{x:r.ZERO,y:r.ZERO};if(!r.eql(j,r.ONE))throw new Error("invZ was invalid");return{x:N,y:T}}),P=Ns(D=>{if(D.is0()){if(t.allowInfinityPoint&&!r.is0(D.Y))return;throw new Error("bad point: ZERO")}const{x:v,y:E}=D.toAffine();if(!r.isValid(v)||!r.isValid(E))throw new Error("bad point: x or y not field elements");if(!p(v,E))throw new Error("bad point: equation left != right");if(!D.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function C(D,v,E,b,S){return E=new k(r.mul(E.X,D),E.Y,E.Z),v=Ls(b,v),E=Ls(S,E),v.add(E)}class k{constructor(v,E,b){this.X=w("x",v),this.Y=w("y",E,!0),this.Z=w("z",b),Object.freeze(this)}static CURVE(){return o}static fromAffine(v){const{x:E,y:b}=v||{};if(!v||!r.isValid(E)||!r.isValid(b))throw new Error("invalid affine point");if(v instanceof k)throw new Error("projective point not allowed");return r.is0(E)&&r.is0(b)?k.ZERO:new k(E,b,r.ONE)}static fromBytes(v){const E=k.fromAffine(m(Qe(v,void 0,"point")));return E.assertValidity(),E}static fromHex(v){return k.fromBytes(ue("pointHex",v))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(v=8,E=!0){return H.createCache(this,v),E||this.multiply(Jr),this}assertValidity(){P(this)}hasEvenY(){const{y:v}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(v)}equals(v){B(v);const{X:E,Y:b,Z:S}=this,{X:$,Y:N,Z:T}=v,j=r.eql(r.mul(E,T),r.mul($,S)),K=r.eql(r.mul(b,T),r.mul(N,S));return j&&K}negate(){return new k(this.X,r.neg(this.Y),this.Z)}double(){const{a:v,b:E}=o,b=r.mul(E,Jr),{X:S,Y:$,Z:N}=this;let T=r.ZERO,j=r.ZERO,K=r.ZERO,M=r.mul(S,S),re=r.mul($,$),ne=r.mul(N,N),W=r.mul(S,$);return W=r.add(W,W),K=r.mul(S,N),K=r.add(K,K),T=r.mul(v,K),j=r.mul(b,ne),j=r.add(T,j),T=r.sub(re,j),j=r.add(re,j),j=r.mul(T,j),T=r.mul(W,T),K=r.mul(b,K),ne=r.mul(v,ne),W=r.sub(M,ne),W=r.mul(v,W),W=r.add(W,K),K=r.add(M,M),M=r.add(K,M),M=r.add(M,ne),M=r.mul(M,W),j=r.add(j,M),ne=r.mul($,N),ne=r.add(ne,ne),M=r.mul(ne,W),T=r.sub(T,M),K=r.mul(ne,re),K=r.add(K,K),K=r.add(K,K),new k(T,j,K)}add(v){B(v);const{X:E,Y:b,Z:S}=this,{X:$,Y:N,Z:T}=v;let j=r.ZERO,K=r.ZERO,M=r.ZERO;const re=o.a,ne=r.mul(o.b,Jr);let W=r.mul(E,$),oe=r.mul(b,N),ie=r.mul(S,T),ve=r.add(E,b),se=r.add($,N);ve=r.mul(ve,se),se=r.add(W,oe),ve=r.sub(ve,se),se=r.add(E,S);let he=r.add($,T);return se=r.mul(se,he),he=r.add(W,ie),se=r.sub(se,he),he=r.add(b,S),j=r.add(N,T),he=r.mul(he,j),j=r.add(oe,ie),he=r.sub(he,j),M=r.mul(re,se),j=r.mul(ne,ie),M=r.add(j,M),j=r.sub(oe,M),M=r.add(oe,M),K=r.mul(j,M),oe=r.add(W,W),oe=r.add(oe,W),ie=r.mul(re,ie),se=r.mul(ne,se),oe=r.add(oe,ie),ie=r.sub(W,ie),ie=r.mul(re,ie),se=r.add(se,ie),W=r.mul(oe,se),K=r.add(K,W),W=r.mul(he,se),j=r.mul(ve,j),j=r.sub(j,W),W=r.mul(ve,oe),M=r.mul(he,M),M=r.add(M,W),new k(j,K,M)}subtract(v){return this.add(v.negate())}is0(){return this.equals(k.ZERO)}multiply(v){const{endo:E}=t;if(!s.isValidNot0(v))throw new Error("invalid scalar: out of range");let b,S;const $=N=>H.cached(this,N,T=>dn(k,T));if(E){const{k1neg:N,k1:T,k2neg:j,k2:K}=A(v),{p:M,f:re}=$(T),{p:ne,f:W}=$(K);S=re.add(W),b=C(E.beta,M,ne,N,j)}else{const{p:N,f:T}=$(v);b=N,S=T}return dn(k,[b,S])[0]}multiplyUnsafe(v){const{endo:E}=t,b=this;if(!s.isValid(v))throw new Error("invalid scalar: out of range");if(v===kt||b.is0())return k.ZERO;if(v===jn)return b;if(H.hasCache(this))return this.multiply(v);if(E){const{k1neg:S,k1:$,k2neg:N,k2:T}=A(v),{p1:j,p2:K}=Jb(k,b,$,T);return C(E.beta,j,K,S,N)}else return H.unsafe(b,v)}multiplyAndAddUnsafe(v,E,b){const S=this.multiplyUnsafe(E).add(v.multiplyUnsafe(b));return S.is0()?void 0:S}toAffine(v){return I(this,v)}isTorsionFree(){const{isTorsionFree:v}=t;return i===jn?!0:v?v(k,this):H.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:v}=t;return i===jn?this:v?v(k,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(v=!0){return xn(v,"isCompressed"),this.assertValidity(),h(k,this,v)}toHex(v=!0){return Pe(this.toBytes(v))}toString(){return``}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(v=!0){return this.toBytes(v)}_setWindowSize(v){this.precompute(v)}static normalizeZ(v){return dn(k,v)}static msm(v,E){return Vf(k,s,v,E)}static fromPrivateKey(v){return k.BASE.multiply(hn(s,v))}}k.BASE=new k(o.Gx,o.Gy,r.ONE),k.ZERO=new k(r.ZERO,r.ONE,r.ZERO),k.Fp=r,k.Fn=s;const U=s.BITS,H=new Zf(k,t.endo?Math.ceil(U/2):U);return k.BASE.precompute(8),k}function zf(e){return Uint8Array.of(e?2:3)}function Ff(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function rw(e,t={}){const{Fn:n}=e,r=t.randomBytes||$n,s=Object.assign(Ff(e.Fp,n),{seed:Hf(n.ORDER)});function o(h){try{return!!hn(n,h)}catch{return!1}}function i(h,m){const{publicKey:y,publicKeyUncompressed:p}=s;try{const g=h.length;return m===!0&&g!==y||m===!1&&g!==p?!1:!!e.fromBytes(h)}catch{return!1}}function a(h=r(s.seed)){return jf(Qe(h,s.seed,"seed"),n.ORDER)}function c(h,m=!0){return e.BASE.multiply(hn(n,h)).toBytes(m)}function u(h){const m=a(h);return{secretKey:m,publicKey:c(m)}}function l(h){if(typeof h=="bigint")return!1;if(h instanceof e)return!0;const{secretKey:m,publicKey:y,publicKeyUncompressed:p}=s;if(n.allowedLengths||m===y)return;const g=ue("key",h).length;return g===y||g===p}function f(h,m,y=!0){if(l(h)===!0)throw new Error("first arg must be private key");if(l(m)===!1)throw new Error("second arg must be public key");const p=hn(n,h);return e.fromHex(m).multiply(p).toBytes(y)}return Object.freeze({getPublicKey:c,getSharedSecret:f,keygen:u,Point:e,utils:{isValidSecretKey:o,isValidPublicKey:i,randomSecretKey:a,isValidPrivateKey:o,randomPrivateKey:a,normPrivateKeyToScalar:h=>hn(n,h),precompute(h=8,m=e.BASE){return m.precompute(h,!1)}},lengths:s})}function sw(e,t,n={}){Rr(t),tr(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||$n,s=n.hmac||((E,...b)=>tn(t,E,be(...b))),{Fp:o,Fn:i}=e,{ORDER:a,BITS:c}=i,{keygen:u,getPublicKey:l,getSharedSecret:f,utils:d,lengths:h}=rw(e,n),m={prehash:!1,lowS:typeof n.lowS=="boolean"?n.lowS:!1,format:void 0,extraEntropy:!1},y="compact";function p(E){const b=a>>jn;return E>b}function g(E,b){if(!i.isValidNot0(b))throw new Error(`invalid signature ${E}: out of range 1..Point.Fn.ORDER`);return b}function x(E,b){li(b);const S=h.signature,$=b==="compact"?S:b==="recovered"?S+1:void 0;return Qe(E,$,`${b} signature`)}class w{constructor(b,S,$){this.r=g("r",b),this.s=g("s",S),$!=null&&(this.recovery=$),Object.freeze(this)}static fromBytes(b,S=y){x(b,S);let $;if(S==="der"){const{r:K,s:M}=_t.toSig(Qe(b));return new w(K,M)}S==="recovered"&&($=b[0],S="compact",b=b.subarray(1));const N=i.BYTES,T=b.subarray(0,N),j=b.subarray(N,N*2);return new w(i.fromBytes(T),i.fromBytes(j),$)}static fromHex(b,S){return this.fromBytes(yt(b),S)}addRecoveryBit(b){return new w(this.r,this.s,b)}recoverPublicKey(b){const S=o.ORDER,{r:$,s:N,recovery:T}=this;if(T==null||![0,1,2,3].includes(T))throw new Error("recovery id invalid");if(a*qf1)throw new Error("recovery id is ambiguous for h>1 curve");const K=T===2||T===3?$+a:$;if(!o.isValid(K))throw new Error("recovery id 2 or 3 invalid");const M=o.toBytes(K),re=e.fromBytes(be(zf((T&1)===0),M)),ne=i.inv(K),W=A(ue("msgHash",b)),oe=i.create(-W*ne),ie=i.create(N*ne),ve=e.BASE.multiplyUnsafe(oe).add(re.multiplyUnsafe(ie));if(ve.is0())throw new Error("point at infinify");return ve.assertValidity(),ve}hasHighS(){return p(this.s)}toBytes(b=y){if(li(b),b==="der")return yt(_t.hexFromSig(this));const S=i.toBytes(this.r),$=i.toBytes(this.s);if(b==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return be(Uint8Array.of(this.recovery),S,$)}return be(S,$)}toHex(b){return Pe(this.toBytes(b))}assertValidity(){}static fromCompact(b){return w.fromBytes(ue("sig",b),"compact")}static fromDER(b){return w.fromBytes(ue("sig",b),"der")}normalizeS(){return this.hasHighS()?new w(this.r,i.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Pe(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Pe(this.toBytes("compact"))}}const B=n.bits2int||function(b){if(b.length>8192)throw new Error("input is too large");const S=er(b),$=b.length*8-c;return $>0?S>>BigInt($):S},A=n.bits2int_modN||function(b){return i.create(B(b))},I=Hr(c);function P(E){return Ir("num < 2^"+c,E,kt,I),i.toBytes(E)}function C(E,b){return Qe(E,void 0,"message"),b?Qe(t(E),void 0,"prehashed message"):E}function k(E,b,S){if(["recovered","canonical"].some(oe=>oe in S))throw new Error("sign() legacy options not supported");const{lowS:$,prehash:N,extraEntropy:T}=Bo(S,m);E=C(E,N);const j=A(E),K=hn(i,b),M=[P(K),P(j)];if(T!=null&&T!==!1){const oe=T===!0?r(h.secretKey):T;M.push(ue("extraEntropy",oe))}const re=be(...M),ne=j;function W(oe){const ie=B(oe);if(!i.isValidNot0(ie))return;const ve=i.inv(ie),se=e.BASE.multiply(ie).toAffine(),he=i.create(se.x);if(he===kt)return;const bt=i.create(ve*i.create(ne+he*K));if(bt===kt)return;let Me=(se.x===he?0:2)|Number(se.y&jn),$e=bt;return $&&p(bt)&&($e=i.neg(bt),Me^=1),new w(he,$e,Me)}return{seed:re,k2sig:W}}function U(E,b,S={}){E=ue("message",E);const{seed:$,k2sig:N}=k(E,b,S);return Db(t.outputLen,i.BYTES,s)($,N)}function H(E){let b;const S=typeof E=="string"||Lr(E),$=!S&&E!==null&&typeof E=="object"&&typeof E.r=="bigint"&&typeof E.s=="bigint";if(!S&&!$)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if($)b=new w(E.r,E.s);else if(S){try{b=w.fromBytes(ue("sig",E),"der")}catch(N){if(!(N instanceof _t.Err))throw N}if(!b)try{b=w.fromBytes(ue("sig",E),"compact")}catch{return!1}}return b||!1}function D(E,b,S,$={}){const{lowS:N,prehash:T,format:j}=Bo($,m);if(S=ue("publicKey",S),b=C(ue("message",b),T),"strict"in $)throw new Error("options.strict was renamed to lowS");const K=j===void 0?H(E):w.fromBytes(ue("sig",E),j);if(K===!1)return!1;try{const M=e.fromBytes(S);if(N&&K.hasHighS())return!1;const{r:re,s:ne}=K,W=A(b),oe=i.inv(ne),ie=i.create(W*oe),ve=i.create(re*oe),se=e.BASE.multiplyUnsafe(ie).add(M.multiplyUnsafe(ve));return se.is0()?!1:i.create(se.x)===re}catch{return!1}}function v(E,b,S={}){const{prehash:$}=Bo(S,m);return b=C(b,$),w.fromBytes(E,"recovered").recoverPublicKey(b).toBytes()}return Object.freeze({keygen:u,getPublicKey:l,getSharedSecret:f,utils:d,lengths:h,Point:e,sign:U,verify:D,recoverPublicKey:v,Signature:w,hash:t})}function ow(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(i=>Math.ceil(i/2)))):void 0;const s=Bn(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),o={Fp:n,Fn:s,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:o}}function iw(e){const{CURVE:t,curveOpts:n}=ow(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function aw(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,Lf(n.Fn.ORDER,n.Fn.BITS))})}function cw(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:s}=iw(e),o=nw(t,n),i=sw(o,r,s);return aw(e,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function uw(e,t){const n=r=>cw({...e,hash:r});return{...n(t),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Yn={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},fw={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},lw=BigInt(0),ec=BigInt(1),di=BigInt(2);function dw(e){const t=Yn.p,n=BigInt(3),r=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,l=u*u*e%t,f=we(l,n,t)*l%t,d=we(f,n,t)*l%t,h=we(d,di,t)*u%t,m=we(h,s,t)*h%t,y=we(m,o,t)*m%t,p=we(y,a,t)*y%t,g=we(p,c,t)*p%t,x=we(g,a,t)*y%t,w=we(x,n,t)*l%t,B=we(w,i,t)*m%t,A=we(B,r,t)*u%t,I=we(A,di,t);if(!Rs.eql(Rs.sqr(I),e))throw new Error("Cannot find square root");return I}const Rs=Bn(Yn.p,{sqrt:dw}),Ke=uw({...Yn,Fp:Rs,lowS:!0,endo:fw},it),tc={};function Hs(e,...t){let n=tc[e];if(n===void 0){const r=it(Ze(e));n=be(r,r),tc[e]=n}return it(be(n,...t))}const ia=e=>e.toBytes(!0).slice(1),nr=Ke.Point,aa=e=>e%di===lw;function hi(e){const{Fn:t,BASE:n}=nr,r=hn(t,e),s=n.multiply(r);return{scalar:aa(s.y)?r:t.neg(r),bytes:ia(s)}}function Gf(e){const t=Rs;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x ≥ p");const n=t.create(e*e),r=t.create(n*e+BigInt(7));let s=t.sqrt(r);aa(s)||(s=t.neg(s));const o=nr.fromAffine({x:e,y:s});return o.assertValidity(),o}const hr=er;function Yf(...e){return nr.Fn.create(hr(Hs("BIP0340/challenge",...e)))}function nc(e){return hi(e).bytes}function hw(e,t,n=$n(32)){const{Fn:r}=nr,s=ue("message",e),{bytes:o,scalar:i}=hi(t),a=ue("auxRand",n,32),c=r.toBytes(i^hr(Hs("BIP0340/aux",a))),u=Hs("BIP0340/nonce",c,o,s),{bytes:l,scalar:f}=hi(u),d=Yf(l,o,s),h=new Uint8Array(64);if(h.set(l,0),h.set(r.toBytes(r.create(f+d*i)),32),!Wf(h,s,o))throw new Error("sign: Invalid signature produced");return h}function Wf(e,t,n){const{Fn:r,BASE:s}=nr,o=ue("signature",e,64),i=ue("message",t),a=ue("publicKey",n,32);try{const c=Gf(hr(a)),u=hr(o.subarray(0,32));if(!ui(u,ec,Yn.p))return!1;const l=hr(o.subarray(32,64));if(!ui(l,ec,Yn.n))return!1;const f=Yf(r.toBytes(u),ia(c),i),d=s.multiplyUnsafe(l).add(c.multiplyUnsafe(r.neg(f))),{x:h,y:m}=d.toAffine();return!(d.is0()||!aa(m)||h!==u)}catch{return!1}}const Xf=(()=>{const n=(s=$n(48))=>jf(s,Yn.n);Ke.utils.randomSecretKey;function r(s){const o=n(s);return{secretKey:o,publicKey:nc(o)}}return{keygen:r,getPublicKey:nc,sign:hw,verify:Wf,Point:nr,utils:{randomSecretKey:n,randomPrivateKey:n,taggedHash:Hs,lift_x:Gf,pointToBytes:ia,numberToBytesBE:to,bytesToNumberBE:er,mod:me},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})(),Ft="super-testnet-local-v0";class nn{constructor(t){if(!/^[0-9a-f]{64}$/.test(t)||!Ke.utils.isValidPrivateKey(t))throw new Error("Invalid test wallet key. Load a Super Testnet v0 backup.");this.kind="test-wallet",this.secret=t,this.pubkey=fi(Xf.getPublicKey(t)),this.address=ni.p2tr.fromPubKey(this.pubkey,"regtest"),this.script=["OP_1",this.pubkey]}static create(){return new nn(fi(Ke.utils.randomPrivateKey()))}static load(t){if((t==null?void 0:t.network)!==Ft||(t==null?void 0:t.version)!==1||(t==null?void 0:t.kind)!=="test-wallet")throw new Error("Only Super Testnet v0 test-wallet backups are accepted.");return new nn(t.secret)}backup(){return{kind:"test-wallet",version:1,network:Ft,secret:this.secret}}sign(t,n,r=0){return rf.taproot.sign(this.secret,t,r,n?{extension:n}:{}).hex}}const Oo=50*1e8,Qr="0".repeat(64),rc=e=>fi(it(new TextEncoder().encode(JSON.stringify(e)))),es=(e,t)=>`${e}:${t}`,ze=e=>_e.encode(e,!1).hex,ce=(e,t)=>{if(!e)throw new Error(t)};class no{constructor(t){if(this.blocks=[],this.mempool=[],this.utxos=new Map,this.transactions=new Map,t){ce(t.network===Ft&&t.version===1,"Unsupported local chain version/network."),ce(Array.isArray(t.blocks)&&Array.isArray(t.mempool),"Invalid chain snapshot.");for(const n of t.blocks)this.acceptBlock(structuredClone(n));this.submitPackage(t.mempool)}}snapshot(){return{network:Ft,version:1,blocks:structuredClone(this.blocks),mempool:[...this.mempool]}}coins(t){return[...this.utxos.values()].filter(n=>ze(n.scriptPubKey)===ze(t))}satLocation(t){for(const n of this.utxos.values()){const r=as(n.ranges,t);if(r!==null)return{txid:n.txid,vout:n.vout,offset:r}}return null}balance(t){return this.coins(t).reduce((n,r)=>n+r.value,0)}apply(t,n,r=!1){var h,m,y;ce(typeof t=="string"&&t.length<4e4&&/^(?:[a-f0-9]{2})+$/.test(t),"Invalid raw transaction.");const s=de.decode(t),o=de.util.getTxid(s);ce(!this.transactions.has(o),"Duplicate transaction."),ce(s.version===2&&s.locktime===0,"Unsupported transaction version or locktime."),ce((s.vin.length===1||!r&&s.vin.length===2)&&s.vout.length>=1&&s.vout.length<=2,"Unsupported transaction shape.");let i=0;for(const p of s.vout){const g=Number(p.value);ce(Number.isSafeInteger(g)&&g>=330&&g<=Oo,"Invalid output amount."),ce(/^5120[0-9a-f]{64}$/.test(ze(p.scriptPubKey)),"Only Taproot outputs are supported."),i+=g}let a,c=[];const u=s.vin.findIndex(p=>{var g;return((g=p.witness)==null?void 0:g.length)===3}),l=s.vin[u<0?0:u];if(r)ce(l.txid===Qr&&l.vout===4294967295&&s.vout.length===1&&i===Oo,"Invalid local coinbase."),ce(ze(l.scriptSig)===_e.encode([new TextEncoder().encode(`${Ft}:${n}`)],!1).hex,"Wrong coinbase height."),ce(!((h=l.witness)!=null&&h.length),"Unexpected coinbase witness.");else{c=s.vin.map(g=>this.utxos.get(es(g.txid,g.vout))),ce(c.every(Boolean),"Input is missing or already spent."),ce(new Set(s.vin.map(g=>es(g.txid,g.vout))).size===s.vin.length,"Duplicate input."),s.vin.forEach((g,x)=>{var w,B;ce(g.sequence==="ffffffff"&&ze(g.scriptSig)==="","Unsupported input flags."),g.prevout={value:c[x].value,scriptPubKey:c[x].scriptPubKey},ce(((w=g.witness)==null?void 0:w.length)===1||x===u&&((B=g.witness)==null?void 0:B.length)===3,"Unsupported witness."),ce(/^[0-9a-f]{128}$/.test(g.witness[0]),"Only default 64-byte Schnorr signatures are accepted.")}),ce(c.reduce((g,x)=>g+x.value,0)-i===Ce,"v0 requires a fixed 500 sat fee per transaction.");let p={};if(l.witness.length===3){const g=Xi(l.witness),x=u;if(ce(Number(s.vout[x].value)===St,"Invalid reveal postage."),ce(ze(s.vout[x].scriptPubKey)===`5120${g.pubkey}`,"Reveal must return to its signing wallet."),g.parent){const w=u===0?1:0,B=c[w];ce((m=B==null?void 0:B.inscriptions)==null?void 0:m.some(A=>A.id===g.parent),"Referenced parent inscription must actually be spent."),ce(s.vout.length===2&&Number(s.vout[w].value)===B.value&&ze(B.scriptPubKey)===`5120${g.pubkey}`&&ze(s.vout[w].scriptPubKey)===ze(B.scriptPubKey),"Parent must be owned and preserved in the same wallet.")}else s.vin.length===2&&(ce(u===1&&((y=c[0].inscriptions)==null?void 0:y.length)&&g.pointer!==void 0,"Reinscription spend requires correct tag and owned sat."),ce(Number(s.vout[0].value)===c[0].value&&ze(s.vout[0].scriptPubKey)===ze(c[0].scriptPubKey)&&ze(c[0].scriptPubKey)===`5120${g.pubkey}`,"Reinscription sat must be returned to owner."));p={pubkey:g.pubkey},a={id:`${o}i0`,txid:o,commitTxid:l.txid,text:g.text,bytes:Array.from(g.bytes),contentType:g.contentType,parent:g.parent,delegate:g.delegate,pointer:g.pointer,metaprotocol:g.metaprotocol,metadata:g.metadata,height:n,value:St}}s.vin.forEach((g,x)=>{let w=!1;try{w=rf.taproot.verify(s,x,x===u?p:{})}catch{}ce(w,"Invalid signature or Taproot commitment.")})}const f=vc(s,c,n,r),d=c.flatMap(p=>p.inscriptions??[]);if(a){const p=BigInt(a.pointer??0),g=p{var w;return((w=x.inscription)==null?void 0:w.sat)===a.sat}).length,d.push(a)}return ce(d.every(p=>f.some(g=>as(g,p.sat)!==null)),"Local lab protects inscription sats from fee loss."),r||s.vin.forEach(p=>this.utxos.delete(es(p.txid,p.vout))),s.vout.forEach((p,g)=>{const x=d.filter(w=>as(f[g],w.sat)!==null);this.utxos.set(es(o,g),{txid:o,vout:g,value:Number(p.value),scriptPubKey:p.scriptPubKey,height:n,ranges:f[g],inscriptions:x,...x.length?{inscription:x[0]}:{}})}),this.transactions.set(o,{txid:o,raw:t,height:n,coinbase:r,tx:s,...a?{inscription:a}:{}}),o}submitPackage(t){ce(Array.isArray(t)&&this.mempool.length+t.length<=1e3,"Invalid package or mempool full; mine a block first.");const n=new Map(this.utxos),r=new Map(this.transactions);try{t.forEach(s=>this.apply(s,null))}catch(s){throw this.utxos=n,this.transactions=r,s}this.mempool.push(...t)}acceptBlock(t){var i;ce(t.height===this.blocks.length+1&&t.previous===(((i=this.blocks.at(-1))==null?void 0:i.hash)??Qr),"Invalid block ancestry."),ce(Number.isSafeInteger(t.time)&&t.time>0&&Array.isArray(t.raws)&&t.raws.length>0&&t.raws.length<=1001,"Invalid block.");const{hash:n,...r}=t;ce(rc(r)===n,"Invalid local block hash.");const s=new Map(this.utxos),o=new Map(this.transactions);try{t.raws.forEach((a,c)=>this.apply(a,t.height,c===0))}catch(a){throw this.utxos=s,this.transactions=o,a}this.blocks.push(t)}mine(t){var a;const n=new no({...this.snapshot(),mempool:[]}),r=this.blocks.length+1,s=de.create({vin:[{txid:Qr,vout:4294967295,scriptSig:[new TextEncoder().encode(`${Ft}:${r}`)]}],vout:[Je(Oo,t)]}),o={height:r,previous:((a=this.blocks.at(-1))==null?void 0:a.hash)??Qr,time:Date.now(),raws:[de.encode(s).hex,...this.mempool]},i={...o,hash:rc(o)};return n.acceptBlock(i),Object.assign(this,n),i}}const pw=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Jf=Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)),gw=Jf.map(e=>(9*e+5)%16),Qf=(()=>{const n=[[Jf],[gw]];for(let r=0;r<4;r++)for(let s of n)s.push(s[r].map(o=>pw[o]));return n})(),el=Qf[0],tl=Qf[1],nl=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>Uint8Array.from(e)),mw=el.map((e,t)=>e.map(n=>nl[t][n])),yw=tl.map((e,t)=>e.map(n=>nl[t][n])),bw=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),ww=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function sc(e,t,n,r){return e===0?t^n^r:e===1?t&n|~t&r:e===2?(t|~n)^r:e===3?t&r|n&~r:t^(n|~r)}const ts=new Uint32Array(16);class xw extends na{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:n,h2:r,h3:s,h4:o}=this;return[t,n,r,s,o]}set(t,n,r,s,o){this.h0=t|0,this.h1=n|0,this.h2=r|0,this.h3=s|0,this.h4=o|0}process(t,n){for(let h=0;h<16;h++,n+=4)ts[h]=t.getUint32(n,!0);let r=this.h0|0,s=r,o=this.h1|0,i=o,a=this.h2|0,c=a,u=this.h3|0,l=u,f=this.h4|0,d=f;for(let h=0;h<5;h++){const m=4-h,y=bw[h],p=ww[h],g=el[h],x=tl[h],w=mw[h],B=yw[h];for(let A=0;A<16;A++){const I=Fr(r+sc(h,o,a,u)+ts[g[A]]+y,w[A])+f|0;r=f,f=u,u=Fr(a,10)|0,a=o,o=I}for(let A=0;A<16;A++){const I=Fr(s+sc(m,i,c,l)+ts[x[A]]+p,B[A])+d|0;s=d,d=l,l=Fr(c,10)|0,c=i,i=I}}this.set(this.h1+a+l|0,this.h2+u+d|0,this.h3+f+s|0,this.h4+r+i|0,this.h0+o+c|0)}roundClean(){mt(ts)}destroy(){this.destroyed=!0,mt(this.buffer),this.set(0,0,0,0,0)}}const vw=ta(()=>new xw);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Wn(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ew(e,...t){if(!Wn(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function rl(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function sl(e){if(typeof e!="function")throw new Error("function expected");return!0}function En(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function rr(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function js(e){if(!Array.isArray(e))throw new Error("array expected")}function Ds(e,t){if(!rl(!0,t))throw new Error(`${e}: array of strings expected`)}function ca(e,t){if(!rl(!1,t))throw new Error(`${e}: array of numbers expected`)}function jr(...e){const t=o=>o,n=(o,i)=>a=>o(i(a)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function ro(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Ds("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(js(s),s.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:s=>(js(s),s.map(o=>{En("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function so(e=""){return En("join",e),{encode:t=>(Ds("join.decode",t),t.join(e)),decode:t=>(En("join.decode",t),t.split(e))}}function ol(e,t="="){return rr(e),En("padding",t),{encode(n){for(Ds("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){Ds("padding.decode",n);let r=n.length;if(r*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if((r-1)*e%8===0)throw new Error("padding: invalid, string has too much padding");return n.slice(0,r)}}}function pi(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(js(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,a=>{if(rr(a),a<0||a>=t)throw new Error(`invalid integer: ${a}`);return a}),i=o.length;for(;;){let a=0,c=!0;for(let u=r;ut===0?e:il(t,e%t),Ks=(e,t)=>e+(t-il(e,t)),ls=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Zs(e,t,n,r){if(js(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Ks(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Ks(t,n)}`);let s=0,o=0;const i=ls[t],a=ls[n]-1,c=[];for(const u of e){if(rr(u),u>=i)throw new Error(`convertRadix2: invalid data word=${u} from=${t}`);if(s=s<32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=n;o-=n)c.push((s>>o-n&a)>>>0);const l=ls[o];if(l===void 0)throw new Error("invalid carry");s&=l-1}if(s=s<=t)throw new Error("Excess padding");if(!r&&s>0)throw new Error(`Non-zero padding: ${s}`);return r&&o>0&&c.push(s>>>0),c}function al(e){rr(e);const t=2**8;return{encode:n=>{if(!Wn(n))throw new Error("radix.encode input should be Uint8Array");return pi(Array.from(n),t,e)},decode:n=>(ca("radix.decode",n),Uint8Array.from(pi(n,e,t)))}}function ua(e,t=!1){if(rr(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Ks(8,e)>32||Ks(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Wn(n))throw new Error("radix2.encode input should be Uint8Array");return Zs(Array.from(n),8,e,!t)},decode:n=>(ca("radix2.decode",n),Uint8Array.from(Zs(n,e,8,t)))}}function oc(e){return sl(e),function(...t){try{return e.apply(null,t)}catch{}}}function cl(e,t){return rr(e),sl(t),{encode(n){if(!Wn(n))throw new Error("checksum.encode: input should be Uint8Array");const r=t(n).slice(0,e),s=new Uint8Array(n.length+e);return s.set(n),s.set(r,n.length),s},decode(n){if(!Wn(n))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-e),s=n.slice(-e),o=t(r).slice(0,e);for(let i=0;i{En("base64",e);const n=/^[A-Za-z0-9=+/]+$/,r="base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},dt=Sw?{encode(e){return Ew(e),e.toBase64()},decode(e){return _w(e)}}:jr(ua(6),ro("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),ol(6),so("")),kw=e=>jr(al(58),ro(e),so("")),Aw=kw("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),ul=e=>jr(cl(4,t=>e(e(t))),Aw),gi=jr(ro("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),so("")),ic=[996825010,642813549,513874426,1027748829,705979059];function ur(e){const t=e>>25;let n=(e&33554431)<<5;for(let r=0;r>r&1)===1&&(n^=ic[r]);return n}function ac(e,t,n=1){const r=e.length;let s=1;for(let o=0;o126)throw new Error(`Invalid prefix (${e})`);s=ur(s)^i>>5}s=ur(s);for(let o=0;oh)throw new TypeError(`Length ${y} exceeds limit ${h}`);const p=f.toLowerCase(),g=ac(p,d,t);return`${p}1${gi.encode(d)}${g}`}function a(f,d=90){En("bech32.decode input",f);const h=f.length;if(h<8||d!==!1&&h>d)throw new TypeError(`invalid string length: ${h} (${f}). Expected (8..${d})`);const m=f.toLowerCase();if(f!==m&&f!==f.toUpperCase())throw new Error("String must be lowercase or uppercase");const y=m.lastIndexOf("1");if(y===0||y===-1)throw new Error('Letter "1" must be present between prefix and data only');const p=m.slice(0,y),g=m.slice(y+1);if(g.length<6)throw new Error("Data must be at least 6 characters long");const x=gi.decode(g).slice(0,-6),w=ac(p,x,t);if(!g.endsWith(w))throw new Error(`Invalid checksum in ${f}: expected "${w}"`);return{prefix:p,words:x}}const c=oc(a);function u(f){const{prefix:d,words:h}=a(f,!1);return{prefix:d,words:h,bytes:r(h)}}function l(f,d){return i(f,s(d))}return{encode:i,decode:a,encodeFromBytes:l,decodeToBytes:u,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:o,toWords:s}}const Vs=$w("bech32");/*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */const rs=Ke.ProjectivePoint,Io=ul(it);function cc(e){Ue(e);const t=e.length===0?"0":Pe(e);return BigInt("0x"+t)}function Bw(e){if(typeof e!="bigint")throw new Error("bigint expected");return yt(e.toString(16).padStart(64,"0"))}const Ow=Ze("Bitcoin seed"),To={private:76066276,public:76067358},Co=2147483648,Iw=e=>vw(it(e)),Tw=e=>gn(e).getUint32(0,!1),ss=e=>{if(!Number.isSafeInteger(e)||e<0||e>2**32-1)throw new Error("invalid number, should be from 0 to 2**32-1, got "+e);const t=new Uint8Array(4);return gn(t).setUint32(0,e,!1),t};class on{get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return Tw(this.pubHash)}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this.privKeyBytes||null}get publicKey(){return this.pubKey||null}get privateExtendedKey(){const t=this.privateKey;if(!t)throw new Error("No private key");return Io.encode(this.serialize(this.versions.private,be(new Uint8Array([0]),t)))}get publicExtendedKey(){if(!this.pubKey)throw new Error("No public key");return Io.encode(this.serialize(this.versions.public,this.pubKey))}static fromMasterSeed(t,n=To){if(Ue(t),8*t.length<128||8*t.length>512)throw new Error("HDKey: seed length must be between 128 and 512 bits; 256 bits is advised, got "+t.length);const r=tn(Or,Ow,t);return new on({versions:n,chainCode:r.slice(32),privateKey:r.slice(0,32)})}static fromExtendedKey(t,n=To){const r=Io.decode(t),s=gn(r),o=s.getUint32(0,!1),i={versions:n,depth:r[4],parentFingerprint:s.getUint32(5,!1),index:s.getUint32(9,!1),chainCode:r.slice(13,45)},a=r.slice(45),c=a[0]===0;if(o!==n[c?"private":"public"])throw new Error("Version mismatch");return c?new on({...i,privateKey:a.slice(1)}):new on({...i,publicKey:a})}static fromJSON(t){return on.fromExtendedKey(t.xpriv)}constructor(t){if(this.depth=0,this.index=0,this.chainCode=null,this.parentFingerprint=0,!t||typeof t!="object")throw new Error("HDKey.constructor must not be called directly");if(this.versions=t.versions||To,this.depth=t.depth||0,this.chainCode=t.chainCode||null,this.index=t.index||0,this.parentFingerprint=t.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(t.publicKey&&t.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(t.privateKey){if(!Ke.utils.isValidPrivateKey(t.privateKey))throw new Error("Invalid private key");this.privKey=typeof t.privateKey=="bigint"?t.privateKey:cc(t.privateKey),this.privKeyBytes=Bw(this.privKey),this.pubKey=Ke.getPublicKey(t.privateKey,!0)}else if(t.publicKey)this.pubKey=rs.fromHex(t.publicKey).toRawBytes(!0);else throw new Error("HDKey: no public or private key provided");this.pubHash=Iw(this.pubKey)}derive(t){if(!/^[mM]'?/.test(t))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(t))return this;const n=t.replace(/^[mM]'?\//,"").split("/");let r=this;for(const s of n){const o=/^(\d+)('?)$/.exec(s),i=o&&o[1];if(!o||o.length!==3||typeof i!="string")throw new Error("invalid child index: "+s);let a=+i;if(!Number.isSafeInteger(a)||a>=Co)throw new Error("Invalid index");o[2]==="'"&&(a+=Co),r=r.deriveChild(a)}return r}deriveChild(t){if(!this.pubKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let n=ss(t);if(t>=Co){const a=this.privateKey;if(!a)throw new Error("Could not derive hardened child key");n=be(new Uint8Array([0]),a,n)}else n=be(this.pubKey,n);const r=tn(Or,this.chainCode,n),s=cc(r.slice(0,32)),o=r.slice(32);if(!Ke.utils.isValidPrivateKey(s))throw new Error("Tweak bigger than curve order");const i={versions:this.versions,chainCode:o,depth:this.depth+1,parentFingerprint:this.fingerprint,index:t};try{if(this.privateKey){const a=me(this.privKey+s,Ke.CURVE.n);if(!Ke.utils.isValidPrivateKey(a))throw new Error("The tweak was out of range or the resulted private key is invalid");i.privateKey=a}else{const a=rs.fromHex(this.pubKey).add(rs.fromPrivateKey(s));if(a.equals(rs.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");i.publicKey=a.toRawBytes(!0)}return new on(i)}catch{return this.deriveChild(t+1)}}sign(t){if(!this.privateKey)throw new Error("No privateKey set!");return Ue(t,32),Ke.sign(t,this.privKey).toCompactRawBytes()}verify(t,n){if(Ue(t,32),Ue(n,64),!this.publicKey)throw new Error("No publicKey set!");let r;try{r=Ke.Signature.fromCompact(n)}catch{return!1}return Ke.verify(r,t,this.publicKey)}wipePrivateData(){return this.privKey=void 0,this.privKeyBytes&&(this.privKeyBytes.fill(0),this.privKeyBytes=void 0),this}toJSON(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}}serialize(t,n){if(!this.chainCode)throw new Error("No chainCode set");return Ue(n,33),be(ss(t),new Uint8Array([this.depth]),ss(this.parentFingerprint),ss(this.index),this.chainCode,n)}}function Cw(e,t,n,r){Rr(e);const s=Sb({dkLen:32,asyncTick:10},r),{c:o,dkLen:i,asyncTick:a}=s;if(Yt(o),Yt(i),Yt(a),o<1)throw new Error("iterations (c) should be >= 1");const c=Va(t),u=Va(n),l=new Uint8Array(i),f=tn.create(e,c),d=f._cloneInto().update(u);return{c:o,dkLen:i,asyncTick:a,DK:l,PRF:f,PRFSalt:d}}function Uw(e,t,n,r,s){return e.destroy(),t.destroy(),r&&r.destroy(),mt(s),n}function Pw(e,t,n,r){const{c:s,dkLen:o,DK:i,PRF:a,PRFSalt:c}=Cw(e,t,n,r);let u;const l=new Uint8Array(4),f=gn(l),d=new Uint8Array(a.outputLen);for(let h=1,m=0;me[0]==="あいこくしん";function fl(e){if(typeof e!="string")throw new TypeError("invalid mnemonic type: "+typeof e);return e.normalize("NFKD")}function ll(e){const t=fl(e),n=t.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:n}}function dl(e){Ue(e,16,20,24,28,32)}function Lw(e,t=128){if(Yt(t),t%32!==0||t>256)throw new TypeError("Invalid entropy");return pl($n(t/8),e)}const Rw=e=>{const t=8-e.length/4;return new Uint8Array([it(e)[0]>>t<{if(typeof t!="string")throw new Error("wordlist: non-string element: "+t)}),ns.chain(ns.checksum(1,Rw),ns.radix2(11,!0),ns.alphabet(e))}function Hw(e,t){const{words:n}=ll(e),r=hl(t).decode(n);return dl(r),r}function pl(e,t){return dl(e),hl(t).encode(e).join(Nw(t)?" ":" ")}function jw(e,t){try{Hw(e,t)}catch{return!1}return!0}const Dw=e=>fl("mnemonic"+e);function Kw(e,t=""){return Pw(Or,ll(e).nfkd,Dw(t),{c:2048,dkLen:64})}const fa=`abandon -ability -able -about -above -absent -absorb -abstract -absurd -abuse -access -accident -account -accuse -achieve -acid -acoustic -acquire -across -act -action -actor -actress -actual -adapt -add -addict -address -adjust -admit -adult -advance -advice -aerobic -affair -afford -afraid -again -age -agent -agree -ahead -aim -air -airport -aisle -alarm -album -alcohol -alert -alien -all -alley -allow -almost -alone -alpha -already -also -alter -always -amateur -amazing -among -amount -amused -analyst -anchor -ancient -anger -angle -angry -animal -ankle -announce -annual -another -answer -antenna -antique -anxiety -any -apart -apology -appear -apple -approve -april -arch -arctic -area -arena -argue -arm -armed -armor -army -around -arrange -arrest -arrive -arrow -art -artefact -artist -artwork -ask -aspect -assault -asset -assist -assume -asthma -athlete -atom -attack -attend -attitude -attract -auction -audit -august -aunt -author -auto -autumn -average -avocado -avoid -awake -aware -away -awesome -awful -awkward -axis -baby -bachelor -bacon -badge -bag -balance -balcony -ball -bamboo -banana -banner -bar -barely -bargain -barrel -base -basic -basket -battle -beach -bean -beauty -because -become -beef -before -begin -behave -behind -believe -below -belt -bench -benefit -best -betray -better -between -beyond -bicycle -bid -bike -bind -biology -bird -birth -bitter -black -blade -blame -blanket -blast -bleak -bless -blind -blood -blossom -blouse -blue -blur -blush -board -boat -body -boil -bomb -bone -bonus -book -boost -border -boring -borrow -boss -bottom -bounce -box -boy -bracket -brain -brand -brass -brave -bread -breeze -brick -bridge -brief -bright -bring -brisk -broccoli -broken -bronze -broom -brother -brown -brush -bubble -buddy -budget -buffalo -build -bulb -bulk -bullet -bundle -bunker -burden -burger -burst -bus -business -busy -butter -buyer -buzz -cabbage -cabin -cable -cactus -cage -cake -call -calm -camera -camp -can -canal -cancel -candy -cannon -canoe -canvas -canyon -capable -capital -captain -car -carbon -card -cargo -carpet -carry -cart -case -cash -casino -castle -casual -cat -catalog -catch -category -cattle -caught -cause -caution -cave -ceiling -celery -cement -census -century -cereal -certain -chair -chalk -champion -change -chaos -chapter -charge -chase -chat -cheap -check -cheese -chef -cherry -chest -chicken -chief -child -chimney -choice -choose -chronic -chuckle -chunk -churn -cigar -cinnamon -circle -citizen -city -civil -claim -clap -clarify -claw -clay -clean -clerk -clever -click -client -cliff -climb -clinic -clip -clock -clog -close -cloth -cloud -clown -club -clump -cluster -clutch -coach -coast -coconut -code -coffee -coil -coin -collect -color -column -combine -come -comfort -comic -common -company -concert -conduct -confirm -congress -connect -consider -control -convince -cook -cool -copper -copy -coral -core -corn -correct -cost -cotton -couch -country -couple -course -cousin -cover -coyote -crack -cradle -craft -cram -crane -crash -crater -crawl -crazy -cream -credit -creek -crew -cricket -crime -crisp -critic -crop -cross -crouch -crowd -crucial -cruel -cruise -crumble -crunch -crush -cry -crystal -cube -culture -cup -cupboard -curious -current -curtain -curve -cushion -custom -cute -cycle -dad -damage -damp -dance -danger -daring -dash -daughter -dawn -day -deal -debate -debris -decade -december -decide -decline -decorate -decrease -deer -defense -define -defy -degree -delay -deliver -demand -demise -denial -dentist -deny -depart -depend -deposit -depth -deputy -derive -describe -desert -design -desk -despair -destroy -detail -detect -develop -device -devote -diagram -dial -diamond -diary -dice -diesel -diet -differ -digital -dignity -dilemma -dinner -dinosaur -direct -dirt -disagree -discover -disease -dish -dismiss -disorder -display -distance -divert -divide -divorce -dizzy -doctor -document -dog -doll -dolphin -domain -donate -donkey -donor -door -dose -double -dove -draft -dragon -drama -drastic -draw -dream -dress -drift -drill -drink -drip -drive -drop -drum -dry -duck -dumb -dune -during -dust -dutch -duty -dwarf -dynamic -eager -eagle -early -earn -earth -easily -east -easy -echo -ecology -economy -edge -edit -educate -effort -egg -eight -either -elbow -elder -electric -elegant -element -elephant -elevator -elite -else -embark -embody -embrace -emerge -emotion -employ -empower -empty -enable -enact -end -endless -endorse -enemy -energy -enforce -engage -engine -enhance -enjoy -enlist -enough -enrich -enroll -ensure -enter -entire -entry -envelope -episode -equal -equip -era -erase -erode -erosion -error -erupt -escape -essay -essence -estate -eternal -ethics -evidence -evil -evoke -evolve -exact -example -excess -exchange -excite -exclude -excuse -execute -exercise -exhaust -exhibit -exile -exist -exit -exotic -expand -expect -expire -explain -expose -express -extend -extra -eye -eyebrow -fabric -face -faculty -fade -faint -faith -fall -false -fame -family -famous -fan -fancy -fantasy -farm -fashion -fat -fatal -father -fatigue -fault -favorite -feature -february -federal -fee -feed -feel -female -fence -festival -fetch -fever -few -fiber -fiction -field -figure -file -film -filter -final -find -fine -finger -finish -fire -firm -first -fiscal -fish -fit -fitness -fix -flag -flame -flash -flat -flavor -flee -flight -flip -float -flock -floor -flower -fluid -flush -fly -foam -focus -fog -foil -fold -follow -food -foot -force -forest -forget -fork -fortune -forum -forward -fossil -foster -found -fox -fragile -frame -frequent -fresh -friend -fringe -frog -front -frost -frown -frozen -fruit -fuel -fun -funny -furnace -fury -future -gadget -gain -galaxy -gallery -game -gap -garage -garbage -garden -garlic -garment -gas -gasp -gate -gather -gauge -gaze -general -genius -genre -gentle -genuine -gesture -ghost -giant -gift -giggle -ginger -giraffe -girl -give -glad -glance -glare -glass -glide -glimpse -globe -gloom -glory -glove -glow -glue -goat -goddess -gold -good -goose -gorilla -gospel -gossip -govern -gown -grab -grace -grain -grant -grape -grass -gravity -great -green -grid -grief -grit -grocery -group -grow -grunt -guard -guess -guide -guilt -guitar -gun -gym -habit -hair -half -hammer -hamster -hand -happy -harbor -hard -harsh -harvest -hat -have -hawk -hazard -head -health -heart -heavy -hedgehog -height -hello -helmet -help -hen -hero -hidden -high -hill -hint -hip -hire -history -hobby -hockey -hold -hole -holiday -hollow -home -honey -hood -hope -horn -horror -horse -hospital -host -hotel -hour -hover -hub -huge -human -humble -humor -hundred -hungry -hunt -hurdle -hurry -hurt -husband -hybrid -ice -icon -idea -identify -idle -ignore -ill -illegal -illness -image -imitate -immense -immune -impact -impose -improve -impulse -inch -include -income -increase -index -indicate -indoor -industry -infant -inflict -inform -inhale -inherit -initial -inject -injury -inmate -inner -innocent -input -inquiry -insane -insect -inside -inspire -install -intact -interest -into -invest -invite -involve -iron -island -isolate -issue -item -ivory -jacket -jaguar -jar -jazz -jealous -jeans -jelly -jewel -job -join -joke -journey -joy -judge -juice -jump -jungle -junior -junk -just -kangaroo -keen -keep -ketchup -key -kick -kid -kidney -kind -kingdom -kiss -kit -kitchen -kite -kitten -kiwi -knee -knife -knock -know -lab -label -labor -ladder -lady -lake -lamp -language -laptop -large -later -latin -laugh -laundry -lava -law -lawn -lawsuit -layer -lazy -leader -leaf -learn -leave -lecture -left -leg -legal -legend -leisure -lemon -lend -length -lens -leopard -lesson -letter -level -liar -liberty -library -license -life -lift -light -like -limb -limit -link -lion -liquid -list -little -live -lizard -load -loan -lobster -local -lock -logic -lonely -long -loop -lottery -loud -lounge -love -loyal -lucky -luggage -lumber -lunar -lunch -luxury -lyrics -machine -mad -magic -magnet -maid -mail -main -major -make -mammal -man -manage -mandate -mango -mansion -manual -maple -marble -march -margin -marine -market -marriage -mask -mass -master -match -material -math -matrix -matter -maximum -maze -meadow -mean -measure -meat -mechanic -medal -media -melody -melt -member -memory -mention -menu -mercy -merge -merit -merry -mesh -message -metal -method -middle -midnight -milk -million -mimic -mind -minimum -minor -minute -miracle -mirror -misery -miss -mistake -mix -mixed -mixture -mobile -model -modify -mom -moment -monitor -monkey -monster -month -moon -moral -more -morning -mosquito -mother -motion -motor -mountain -mouse -move -movie -much -muffin -mule -multiply -muscle -museum -mushroom -music -must -mutual -myself -mystery -myth -naive -name -napkin -narrow -nasty -nation -nature -near -neck -need -negative -neglect -neither -nephew -nerve -nest -net -network -neutral -never -news -next -nice -night -noble -noise -nominee -noodle -normal -north -nose -notable -note -nothing -notice -novel -now -nuclear -number -nurse -nut -oak -obey -object -oblige -obscure -observe -obtain -obvious -occur -ocean -october -odor -off -offer -office -often -oil -okay -old -olive -olympic -omit -once -one -onion -online -only -open -opera -opinion -oppose -option -orange -orbit -orchard -order -ordinary -organ -orient -original -orphan -ostrich -other -outdoor -outer -output -outside -oval -oven -over -own -owner -oxygen -oyster -ozone -pact -paddle -page -pair -palace -palm -panda -panel -panic -panther -paper -parade -parent -park -parrot -party -pass -patch -path -patient -patrol -pattern -pause -pave -payment -peace -peanut -pear -peasant -pelican -pen -penalty -pencil -people -pepper -perfect -permit -person -pet -phone -photo -phrase -physical -piano -picnic -picture -piece -pig -pigeon -pill -pilot -pink -pioneer -pipe -pistol -pitch -pizza -place -planet -plastic -plate -play -please -pledge -pluck -plug -plunge -poem -poet -point -polar -pole -police -pond -pony -pool -popular -portion -position -possible -post -potato -pottery -poverty -powder -power -practice -praise -predict -prefer -prepare -present -pretty -prevent -price -pride -primary -print -priority -prison -private -prize -problem -process -produce -profit -program -project -promote -proof -property -prosper -protect -proud -provide -public -pudding -pull -pulp -pulse -pumpkin -punch -pupil -puppy -purchase -purity -purpose -purse -push -put -puzzle -pyramid -quality -quantum -quarter -question -quick -quit -quiz -quote -rabbit -raccoon -race -rack -radar -radio -rail -rain -raise -rally -ramp -ranch -random -range -rapid -rare -rate -rather -raven -raw -razor -ready -real -reason -rebel -rebuild -recall -receive -recipe -record -recycle -reduce -reflect -reform -refuse -region -regret -regular -reject -relax -release -relief -rely -remain -remember -remind -remove -render -renew -rent -reopen -repair -repeat -replace -report -require -rescue -resemble -resist -resource -response -result -retire -retreat -return -reunion -reveal -review -reward -rhythm -rib -ribbon -rice -rich -ride -ridge -rifle -right -rigid -ring -riot -ripple -risk -ritual -rival -river -road -roast -robot -robust -rocket -romance -roof -rookie -room -rose -rotate -rough -round -route -royal -rubber -rude -rug -rule -run -runway -rural -sad -saddle -sadness -safe -sail -salad -salmon -salon -salt -salute -same -sample -sand -satisfy -satoshi -sauce -sausage -save -say -scale -scan -scare -scatter -scene -scheme -school -science -scissors -scorpion -scout -scrap -screen -script -scrub -sea -search -season -seat -second -secret -section -security -seed -seek -segment -select -sell -seminar -senior -sense -sentence -series -service -session -settle -setup -seven -shadow -shaft -shallow -share -shed -shell -sheriff -shield -shift -shine -ship -shiver -shock -shoe -shoot -shop -short -shoulder -shove -shrimp -shrug -shuffle -shy -sibling -sick -side -siege -sight -sign -silent -silk -silly -silver -similar -simple -since -sing -siren -sister -situate -six -size -skate -sketch -ski -skill -skin -skirt -skull -slab -slam -sleep -slender -slice -slide -slight -slim -slogan -slot -slow -slush -small -smart -smile -smoke -smooth -snack -snake -snap -sniff -snow -soap -soccer -social -sock -soda -soft -solar -soldier -solid -solution -solve -someone -song -soon -sorry -sort -soul -sound -soup -source -south -space -spare -spatial -spawn -speak -special -speed -spell -spend -sphere -spice -spider -spike -spin -spirit -split -spoil -sponsor -spoon -sport -spot -spray -spread -spring -spy -square -squeeze -squirrel -stable -stadium -staff -stage -stairs -stamp -stand -start -state -stay -steak -steel -stem -step -stereo -stick -still -sting -stock -stomach -stone -stool -story -stove -strategy -street -strike -strong -struggle -student -stuff -stumble -style -subject -submit -subway -success -such -sudden -suffer -sugar -suggest -suit -summer -sun -sunny -sunset -super -supply -supreme -sure -surface -surge -surprise -surround -survey -suspect -sustain -swallow -swamp -swap -swarm -swear -sweet -swift -swim -swing -switch -sword -symbol -symptom -syrup -system -table -tackle -tag -tail -talent -talk -tank -tape -target -task -taste -tattoo -taxi -teach -team -tell -ten -tenant -tennis -tent -term -test -text -thank -that -theme -then -theory -there -they -thing -this -thought -three -thrive -throw -thumb -thunder -ticket -tide -tiger -tilt -timber -time -tiny -tip -tired -tissue -title -toast -tobacco -today -toddler -toe -together -toilet -token -tomato -tomorrow -tone -tongue -tonight -tool -tooth -top -topic -topple -torch -tornado -tortoise -toss -total -tourist -toward -tower -town -toy -track -trade -traffic -tragic -train -transfer -trap -trash -travel -tray -treat -tree -trend -trial -tribe -trick -trigger -trim -trip -trophy -trouble -truck -true -truly -trumpet -trust -truth -try -tube -tuition -tumble -tuna -tunnel -turkey -turn -turtle -twelve -twenty -twice -twin -twist -two -type -typical -ugly -umbrella -unable -unaware -uncle -uncover -under -undo -unfair -unfold -unhappy -uniform -unique -unit -universe -unknown -unlock -until -unusual -unveil -update -upgrade -uphold -upon -upper -upset -urban -urge -usage -use -used -useful -useless -usual -utility -vacant -vacuum -vague -valid -valley -valve -van -vanish -vapor -various -vast -vault -vehicle -velvet -vendor -venture -venue -verb -verify -version -very -vessel -veteran -viable -vibrant -vicious -victory -video -view -village -vintage -violin -virtual -virus -visa -visit -visual -vital -vivid -vocal -voice -void -volcano -volume -vote -voyage -wage -wagon -wait -walk -wall -walnut -want -warfare -warm -warrior -wash -wasp -waste -water -wave -way -wealth -weapon -wear -weasel -weather -web -wedding -weekend -weird -welcome -west -wet -whale -what -wheat -wheel -when -where -whip -whisper -wide -width -wife -wild -will -win -window -wine -wing -wink -winner -winter -wire -wisdom -wise -wish -witness -wolf -woman -wonder -wood -wool -word -work -world -worry -worth -wrap -wreck -wrestle -wrist -write -wrong -yard -year -yellow -you -young -youth -zebra -zero -zone -zoo`.split(` -`),rt={orgSeed:e=>`m/83696968'/39'/0'/24'/${e}'`,wallet:(e,t=1)=>`m/86'/${t}'/${e}'/0/0`,segwit:(e,t=1)=>`m/84'/${t}'/${e}'/0/0`,nostr:e=>`m/44'/1237'/${e}'/0/0`},Zw=2**31-1,Uo=new Map,Po=new Map,uc=()=>Lw(fa,256);function gl(e,t=0){if(typeof e!="string"||!jw(e,fa)||t&&e.split(" ").length!==t)throw new Error("Invalid lab mnemonic.");return e}function sr(e,t){if(!Number.isSafeInteger(e)||e<0||e>Zw)throw new Error(`Invalid ${t}.`);return e}const No=new Map;function la(e){return No.has(e)||No.set(e,Kw(gl(e))),No.get(e)}function or(e){return Uo.has(e)||Uo.set(e,on.fromMasterSeed(la(e))),Uo.get(e)}function Vw(e,t){const n=e.derive(t).privateKey;if(!n)throw new Error("BIP-85 path produced no private key.");return tn(Or,Ze("bip-entropy-from-k"),n)}function Mw(e,t){const n=`${e}|${sr(t,"child index")}`;return Po.has(n)||Po.set(n,pl(Vw(or(e),rt.orgSeed(t)).slice(0,32),fa)),Po.get(n)}function mi(e,t=0,n=1){return Pe(or(e).derive(rt.wallet(sr(t,"account"),n)).privateKey)}function qw(e,t=0,n=1){return Pe(or(e).derive(rt.segwit(sr(t,"account"),n)).privateKey)}function zw(e,t=0,n=1){return Pe(or(e).derive(rt.segwit(sr(t,"account"),n)).publicKey)}function da(e,t=0){return Pe(or(e).derive(rt.nostr(sr(t,"account"))).privateKey)}function Fw(e,t=0){const n=Xf.getPublicKey(or(e).derive(rt.nostr(sr(t,"account"))).privateKey);return{pubkey:Pe(n),npub:Vs.encode("npub",Vs.toWords(n))}}const ml="lineage-claim",yi=330,Ms=e=>_e.encode(e,!1).hex,fc=e=>({txid:e.txid,vout:e.vout,value:e.value,script:Ms(e.scriptPubKey)}),Lo=/^[0-9a-f]{64}$/,Gw=/^5120[0-9a-f]{64}$/;function ha(e,t){var n;for(const r of e.utxos.values())if((n=r.inscriptions)!=null&&n.some(s=>s.id===t))return r;return null}function yl(e){return de.create({vin:[Hn(e.holder.txid,e.holder.vout,e.holder.value,e.holder.script),Hn(e.payer.txid,e.payer.vout,e.payer.value,e.payer.script)],vout:[Je(e.holder.value,["OP_1",e.to]),Je(e.payer.value-Ce,["OP_1",e.to])]})}function Yw(e,t,n,r=Date.now()){if((n==null?void 0:n.kind)!=="test-wallet")throw new Error("Claims are signed by local test wallets.");const s=ha(e,t);if(!s)throw new Error("That inscription is not in an unspent output.");if(Ms(s.scriptPubKey)===Ms(n.script))throw new Error("The recipient already holds that inscription.");const o=e.coins(n.script).find(c=>{var u;return!((u=c.inscriptions)!=null&&u.length)&&c.value>=Ce+yi});if(!o)throw new Error("The recipient needs a plain coin for the 500-sat fee. Mine a block to it first.");const i={kind:ml,version:1,inscription:t,carried:s.inscriptions.map(c=>c.id),holder:fc(s),payer:fc(o),to:n.pubkey,at:r},a=yl(i);return i.txid=de.util.getTxid(a),i.sig=n.sign(a,void 0,1),i}function Ww(e,t,n){const r=Jw(t);if((n==null?void 0:n.kind)!=="test-wallet")throw new Error("Countersigning needs a local test wallet.");if(Ms(n.script)!==r.holder.script)throw new Error("Only the current holder can countersign.");if(Xw(e,r)!=="open")throw new Error("This claim is stale: an input it spends was already spent.");const s=yl(r);return s.vin[1].witness=[r.sig],s.vin[0].witness=[n.sign(s,void 0,0)],e.submitPackage([de.encode(s).hex]),de.util.getTxid(s)}function Xw(e,t){return e.utxos.has(`${t.holder.txid}:${t.holder.vout}`)&&e.utxos.has(`${t.payer.txid}:${t.payer.vout}`)?"open":"stale"}function Jw(e){const t=n=>n&&Lo.test(n.txid)&&Number.isSafeInteger(n.vout)&&n.vout>=0&&Number.isSafeInteger(n.value)&&n.value>=yi&&Gw.test(n.script);if((e==null?void 0:e.kind)!==ml||e.version!==1||!/^[0-9a-f]{64}i\d+$/.test(e.inscription)||!Array.isArray(e.carried)||!t(e.holder)||!t(e.payer)||e.payer.value255*s)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/s);n===void 0&&(n=lc);const i=new Uint8Array(o*s),a=tn.create(e,t),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let l=0;le1(e,Qw(e,t,n),r,s);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Mt=BigInt(0),ke=BigInt(1),Ho=BigInt(2),n1=BigInt(8);function r1(e,t,n,r){const s=e.sqr(n),o=e.sqr(r),i=e.add(e.mul(t.a,s),o),a=e.add(e.ONE,e.mul(t.d,e.mul(s,o)));return e.eql(i,a)}function s1(e,t={}){const n=Mf("edwards",e,t,t.FpFnLE),{Fp:r,Fn:s}=n;let o=n.CURVE;const{h:i}=o;tr(t,{},{uvRatio:"function"});const a=Ho<r.create(p),u=t.uvRatio||((p,g)=>{try{return{isValid:!0,value:r.sqrt(r.div(p,g))}}catch{return{isValid:!1,value:Mt}}});if(!r1(r,o,o.Gx,o.Gy))throw new Error("bad curve params: generator point");function l(p,g,x=!1){const w=x?ke:Mt;return Ir("coordinate "+p,g,w,a),g}function f(p){if(!(p instanceof m))throw new Error("ExtendedPoint expected")}const d=Ns((p,g)=>{const{X:x,Y:w,Z:B}=p,A=p.is0();g==null&&(g=A?n1:r.inv(B));const I=c(x*g),P=c(w*g),C=r.mul(B,g);if(A)return{x:Mt,y:ke};if(C!==ke)throw new Error("invZ was invalid");return{x:I,y:P}}),h=Ns(p=>{const{a:g,d:x}=o;if(p.is0())throw new Error("bad point: ZERO");const{X:w,Y:B,Z:A,T:I}=p,P=c(w*w),C=c(B*B),k=c(A*A),U=c(k*k),H=c(P*g),D=c(k*c(H+C)),v=c(U+c(x*c(P*C)));if(D!==v)throw new Error("bad point: equation left != right (1)");const E=c(w*B),b=c(A*I);if(E!==b)throw new Error("bad point: equation left != right (2)");return!0});class m{constructor(g,x,w,B){this.X=l("x",g),this.Y=l("y",x),this.Z=l("z",w,!0),this.T=l("t",B),Object.freeze(this)}static CURVE(){return o}static fromAffine(g){if(g instanceof m)throw new Error("extended point not allowed");const{x,y:w}=g||{};return l("x",x),l("y",w),new m(x,w,ke,c(x*w))}static fromBytes(g,x=!1){const w=r.BYTES,{a:B,d:A}=o;g=Fa(Qe(g,w,"point")),xn(x,"zip215");const I=Fa(g),P=g[w-1];I[w-1]=P&-129;const C=vn(I),k=x?a:r.ORDER;Ir("point.y",C,Mt,k);const U=c(C*C),H=c(U-ke),D=c(A*U-B);let{isValid:v,value:E}=u(H,D);if(!v)throw new Error("bad point: invalid y coordinate");const b=(E&ke)===ke,S=(P&128)!==0;if(!x&&E===Mt&&S)throw new Error("bad point: x=0 and x_0=1");return S!==b&&(E=c(-E)),m.fromAffine({x:E,y:C})}static fromHex(g,x=!1){return m.fromBytes(ue("point",g),x)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,x=!0){return y.createCache(this,g),x||this.multiply(Ho),this}assertValidity(){h(this)}equals(g){f(g);const{X:x,Y:w,Z:B}=this,{X:A,Y:I,Z:P}=g,C=c(x*P),k=c(A*B),U=c(w*P),H=c(I*B);return C===k&&U===H}is0(){return this.equals(m.ZERO)}negate(){return new m(c(-this.X),this.Y,this.Z,c(-this.T))}double(){const{a:g}=o,{X:x,Y:w,Z:B}=this,A=c(x*x),I=c(w*w),P=c(Ho*c(B*B)),C=c(g*A),k=x+w,U=c(c(k*k)-A-I),H=C+I,D=H-P,v=C-I,E=c(U*D),b=c(H*v),S=c(U*v),$=c(D*H);return new m(E,b,$,S)}add(g){f(g);const{a:x,d:w}=o,{X:B,Y:A,Z:I,T:P}=this,{X:C,Y:k,Z:U,T:H}=g,D=c(B*C),v=c(A*k),E=c(P*w*H),b=c(I*U),S=c((B+A)*(C+k)-D-v),$=b-E,N=b+E,T=c(v-x*D),j=c(S*$),K=c(N*T),M=c(S*T),re=c($*N);return new m(j,K,re,M)}subtract(g){return this.add(g.negate())}multiply(g){if(!s.isValidNot0(g))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:x,f:w}=y.cached(this,g,B=>dn(m,B));return dn(m,[x,w])[0]}multiplyUnsafe(g,x=m.ZERO){if(!s.isValid(g))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return g===Mt?m.ZERO:this.is0()||g===ke?this:y.unsafe(this,g,w=>dn(m,w),x)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return y.unsafe(this,o.n).is0()}toAffine(g){return d(this,g)}clearCofactor(){return i===ke?this:this.multiplyUnsafe(i)}toBytes(){const{x:g,y:x}=this.toAffine(),w=r.toBytes(x);return w[w.length-1]|=g&ke?128:0,w}toHex(){return Pe(this.toBytes())}toString(){return``}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(g){return dn(m,g)}static msm(g,x){return Vf(m,s,g,x)}_setWindowSize(g){this.precompute(g)}toRawBytes(){return this.toBytes()}}m.BASE=new m(o.Gx,o.Gy,ke,c(o.Gx*o.Gy)),m.ZERO=new m(Mt,ke,ke,Mt),m.Fp=r,m.Fn=s;const y=new Zf(m,s.BITS);return m.BASE.precompute(8),m}function o1(e,t,n={}){if(typeof t!="function")throw new Error('"hash" function param is required');tr(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:r}=n,{BASE:s,Fp:o,Fn:i}=e,a=n.randomBytes||$n,c=n.adjustScalarBytes||(k=>k),u=n.domain||((k,U,H)=>{if(xn(H,"phflag"),U.length||H)throw new Error("Contexts/pre-hash are not supported");return k});function l(k){return i.create(vn(k))}function f(k){const U=w.secretKey;k=ue("private key",k,U);const H=ue("hashed private key",t(k),2*U),D=c(H.slice(0,U)),v=H.slice(U,2*U),E=l(D);return{head:D,prefix:v,scalar:E}}function d(k){const{head:U,prefix:H,scalar:D}=f(k),v=s.multiply(D),E=v.toBytes();return{head:U,prefix:H,scalar:D,point:v,pointBytes:E}}function h(k){return d(k).pointBytes}function m(k=Uint8Array.of(),...U){const H=be(...U);return l(t(u(H,ue("context",k),!!r)))}function y(k,U,H={}){k=ue("message",k),r&&(k=r(k));const{prefix:D,scalar:v,pointBytes:E}=d(U),b=m(H.context,D,k),S=s.multiply(b).toBytes(),$=m(H.context,S,E,k),N=i.create(b+$*v);if(!i.isValid(N))throw new Error("sign failed: invalid s");const T=be(S,i.toBytes(N));return Qe(T,w.signature,"result")}const p={zip215:!0};function g(k,U,H,D=p){const{context:v,zip215:E}=D,b=w.signature;k=ue("signature",k,b),U=ue("message",U),H=ue("publicKey",H,w.publicKey),E!==void 0&&xn(E,"zip215"),r&&(U=r(U));const S=b/2,$=k.subarray(0,S),N=vn(k.subarray(S,b));let T,j,K;try{T=e.fromBytes(H,E),j=e.fromBytes($,E),K=s.multiplyUnsafe(N)}catch{return!1}if(!E&&T.isSmallOrder())return!1;const M=m(v,j.toBytes(),T.toBytes(),U);return j.add(T.multiplyUnsafe(M)).subtract(K).clearCofactor().is0()}const x=o.BYTES,w={secretKey:x,publicKey:x,signature:2*x,seed:x};function B(k=a(w.seed)){return Qe(k,w.seed,"seed")}function A(k){const U=C.randomSecretKey(k);return{secretKey:U,publicKey:h(U)}}function I(k){return Lr(k)&&k.length===i.BYTES}function P(k,U){try{return!!e.fromBytes(k,U)}catch{return!1}}const C={getExtendedPublicKey:d,randomSecretKey:B,isValidSecretKey:I,isValidPublicKey:P,toMontgomery(k){const{y:U}=e.fromBytes(k),H=w.publicKey,D=H===32;if(!D&&H!==57)throw new Error("only defined for 25519 and 448");const v=D?o.div(ke+U,ke-U):o.div(U-ke,U+ke);return o.toBytes(v)},toMontgomerySecret(k){const U=w.secretKey;Qe(k,U);const H=t(k.subarray(0,U));return c(H).subarray(0,U)},randomPrivateKey:B,precompute(k=8,U=e.BASE){return U.precompute(k,!1)}};return Object.freeze({keygen:A,getPublicKey:h,sign:y,verify:g,utils:C,Point:e,lengths:w})}function i1(e){const t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp,r=Bn(t.n,e.nBitLength,!0),s={Fp:n,Fn:r,uvRatio:e.uvRatio},o={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:s,hash:e.hash,eddsaOpts:o}}function a1(e,t){const n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:e,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function c1(e){const{CURVE:t,curveOpts:n,hash:r,eddsaOpts:s}=i1(e),o=s1(t,n),i=o1(o,r,s);return a1(e,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const fr=BigInt(0),Cn=BigInt(1),os=BigInt(2);function u1(e){return tr(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function f1(e){const t=u1(e),{P:n,type:r,adjustScalarBytes:s,powPminus2:o,randomBytes:i}=t,a=r==="x25519";if(!a&&r!=="x448")throw new Error("invalid type");const c=i||$n,u=a?255:448,l=a?32:56,f=BigInt(a?9:5),d=BigInt(a?121665:39081),h=a?os**BigInt(254):os**BigInt(447),m=a?BigInt(8)*os**BigInt(251)-Cn:BigInt(4)*os**BigInt(445)-Cn,y=h+m+Cn,p=v=>me(v,n),g=x(f);function x(v){return sa(p(v),l)}function w(v){const E=ue("u coordinate",v,l);return a&&(E[31]&=127),p(vn(E))}function B(v){return vn(s(ue("scalar",v,l)))}function A(v,E){const b=C(w(E),B(v));if(b===fr)throw new Error("invalid private or public key received");return x(b)}function I(v){return A(v,g)}function P(v,E,b){const S=p(v*(E-b));return E=p(E-S),b=p(b+S),{x_2:E,x_3:b}}function C(v,E){Ir("u",v,fr,n),Ir("scalar",E,h,y);const b=E,S=v;let $=Cn,N=fr,T=v,j=Cn,K=fr;for(let re=BigInt(u-1);re>=fr;re--){const ne=b>>re&Cn;K^=ne,{x_2:$,x_3:T}=P(K,$,T),{x_2:N,x_3:j}=P(K,N,j),K=ne;const W=$+N,oe=p(W*W),ie=$-N,ve=p(ie*ie),se=oe-ve,he=T+j,bt=T-j,Me=p(bt*W),$e=p(he*ie),wt=Me+$e,ar=Me-$e;T=p(wt*wt),j=p(S*p(ar*ar)),$=p(oe*ve),N=p(se*(oe+p(d*se)))}({x_2:$,x_3:T}=P(K,$,T)),{x_2:N,x_3:j}=P(K,N,j);const M=o(N);return p($*M)}const k={secretKey:l,publicKey:l,seed:l},U=(v=c(l))=>(Ue(v,k.seed),v);function H(v){const E=U(v);return{secretKey:E,publicKey:I(E)}}return{keygen:H,getSharedSecret:(v,E)=>A(v,E),getPublicKey:v=>I(v),scalarMult:A,scalarMultBase:I,utils:{randomSecretKey:U,randomPrivateKey:U},GuBytes:g.slice(),lengths:k}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const l1=BigInt(1),dc=BigInt(2),d1=BigInt(3),h1=BigInt(5),p1=BigInt(8),pa=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),bl={p:pa,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:p1,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function wl(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),s=BigInt(80),o=pa,a=e*e%o*e%o,c=we(a,dc,o)*a%o,u=we(c,l1,o)*e%o,l=we(u,h1,o)*u%o,f=we(l,t,o)*l%o,d=we(f,n,o)*f%o,h=we(d,r,o)*d%o,m=we(h,s,o)*h%o,y=we(m,s,o)*h%o,p=we(y,t,o)*l%o;return{pow_p_5_8:we(p,dc,o)*e%o,b2:a}}function xl(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}const hc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function g1(e,t){const n=pa,r=me(t*t*t,n),s=me(r*r*t,n),o=wl(e*s).pow_p_5_8;let i=me(e*r*o,n);const a=me(t*i*i,n),c=i,u=me(i*hc,n),l=a===e,f=a===me(-e,n),d=a===me(-e*hc,n);return l&&(i=c),(f||d)&&(i=u),zb(i,n)&&(i=me(-i,n)),{isValid:l||f,value:i}}const vl=Bn(bl.p,{isLE:!0}),m1={...bl,Fp:vl,hash:Or,adjustScalarBytes:xl,uvRatio:g1},oo=c1(m1),El=(()=>{const e=vl.ORDER;return f1({P:e,type:"x25519",powPminus2:t=>{const{pow_p_5_8:n,b2:r}=wl(t);return me(we(n,d1,e)*r,e)},adjustScalarBytes:xl})})(),y1=Ze("lineage/v0"),ht=(e,t)=>t1(it,e,y1,Ze(t),32),io=e=>{const t=Uint8Array.from(e);return t[0]&=248,t[31]&=127,t[31]|=64,t},Sl=e=>{const t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),t},Ge=e=>be(Sl(e.length),e),ga=e=>be(Ge(Ze("ssh-ed25519")),Ge(e)),bi=(e,t)=>`ssh-ed25519 ${dt.encode(ga(e))}${t?` ${t}`:""}`,wi=e=>`SHA256:${dt.encode(it(ga(e))).replace(/=+$/,"")}`;function b1(e){const t=yt(e),n=r=>oo.getPublicKey(ht(t,r));return{ssh:n("ssh"),git:n("git"),dkim:n("dkim"),wg:El.getPublicKey(io(ht(t,"wg")))}}function w1(e){const t=n=>oo.getPublicKey(ht(e,n));return{"ssh-ca":t("node/ssh-ca"),mtls:t("node/mtls"),noise:El.getPublicKey(io(ht(e,"node/noise")))}}function x1(e,t,n,r){return[["ssh",wi(e.ssh),bi(e.ssh,t)],["git",wi(e.git),`${t} namespaces="git" ${bi(e.git,t)}`],["dkim",`${n}._domainkey.${r}`,`${n}._domainkey.${r}. IN TXT "v=DKIM1; k=ed25519; p=${dt.encode(e.dkim)}"`],["wg",dt.encode(e.wg),`[Peer] -# ${t} -PublicKey = ${dt.encode(e.wg)}`]]}function v1(e,t){return[["ssh-ca",wi(e["ssh-ca"]),bi(e["ssh-ca"],`lineage-ca@${t}`)],["mtls",dt.encode(e.mtls),null],["noise",`mkey:${Pe(e.noise)}`,null]]}const E1=yt("302e020100300506032b657004220420");function _l(e,t,n){const r=it(e).slice(0,4);let s=be(r,r,Ge(Ze("ssh-ed25519")),Ge(t),Ge(be(e,t)),Ge(Ze(n)));s=be(s,new Uint8Array((8-s.length%8)%8).map((i,a)=>a+1));const o=be(Ze("openssh-key-v1\0"),Ge(Ze("none")),Ge(Ze("none")),Ge(new Uint8Array(0)),Sl(1),Ge(ga(t)),Ge(s));return`-----BEGIN OPENSSH PRIVATE KEY----- -${dt.encode(o).match(/.{1,70}/g).join(` -`)} ------END OPENSSH PRIVATE KEY----- -`}const S1=(e,t)=>`-----BEGIN ${e}----- -${dt.encode(t).match(/.{1,64}/g).join(` -`)} ------END ${e}----- -`;function _1(e,t){const n=yt(e),r=s=>{const o=ht(n,s);return _l(o,oo.getPublicKey(o),t)};return[["ssh","OpenSSH private key",r("ssh")],["git","OpenSSH private key",r("git")],["dkim","Ed25519 private key (base64)",dt.encode(ht(n,"dkim"))],["wg","Interface entry",`[Interface] -PrivateKey = ${dt.encode(io(ht(n,"wg")))}`]]}function k1(e,t){const n=ht(e,"node/ssh-ca");return[["ssh-ca","OpenSSH private key",_l(n,oo.getPublicKey(n),`lineage-ca@${t}`)],["mtls","Private key (PKCS#8 PEM)",S1("PRIVATE KEY",be(E1,ht(e,"node/mtls")))],["noise","noise_private.key",`privkey:${Pe(io(ht(e,"node/noise")))}`]]}const A1=["bip86","tapkey","wallet"],ma=()=>({scheme:"bip86",roots:{},adopted:{}}),$1=e=>vs.getPubKey(e)[0];function kl(e,t,n){return e.scheme==="wallet"?mi(t,n):vs.getSecKey(e.scheme==="tapkey"?da(t,n):mi(t,n))[0]}const Al=(e,t)=>e.scheme==="tapkey"?rt.nostr(t):rt.wallet(t),B1=(e,t)=>new nn(kl(e,t,0)),is=e=>_e.encode(e,!1).hex;function Xn(e,t,n){if(!n)return null;const r=i=>i?{mnemonic:i,account:0,origin:`${n.name} root`,steps:[]}:null;if(n.kind==="holding")return r(e.roots[n.id]);const s=t.nodes.get(n.parent);if(n.kind==="agent"){const i=Xn(e,t,s);return i&&{...i,account:n.index+1}}if(n.edge==="adopted")return r(e.adopted[n.id]);const o=Xn(e,t,s);return o&&{mnemonic:Mw(o.mnemonic,n.index),account:0,origin:o.origin,steps:[...o.steps,`${n.index}'`]}}function st(e,t,n){const r=Xn(e,t,n);if(!r)return null;const{npub:s,pubkey:o}=Fw(r.mnemonic,r.account),i=[r.origin,...r.steps].join(" › ");return{wallet:new nn(kl(e,r.mnemonic,r.account)),npub:s,pubkey:o,scheme:e.scheme,account:r.account,from:i,path:`${i} · ${Al(e,r.account)}`}}function O1(e,t,n){const r=Xn(e,t,n);if(!r)return null;const s=st(e,t,n),o=zw(r.mnemonic,r.account);return{taproot:{address:s.wallet.address,path:Al(e,r.account)},segwit:{address:ni.p2wpkh.fromPubKey(o,"regtest"),path:rt.segwit(r.account)},tapkey:{address:ni.p2tr.fromPubKey($1(s.pubkey),"regtest"),path:rt.nostr(r.account)},npub:{address:s.npub,path:rt.nostr(r.account)}}}function $l(e,t,n){const r=ha(e.chain,n);if(!r)return null;const s=is(r.scriptPubKey),o=t.nodes.get(n),i=st(e.keys,t,o),a=o&&st(e.keys,t,t.nodes.get(o.parent));return i&&is(i.wallet.script)===s?{wallet:i.wallet,who:"own"}:e.wallet&&is(e.wallet.script)===s?{wallet:e.wallet,who:"lab"}:a&&is(a.wallet.script)===s?{wallet:a.wallet,who:"parent"}:{wallet:null,who:"other",script:s}}function Bl(e,t){const n=e.nodes.get(t),r=[n];for(const s of n.children){const o=e.nodes.get(s);o.status==="active"&&o.edge==="derived"&&r.push(...Bl(e,s))}return r}function xi(e,t){const n=[];for(let r=t;r;r=e.nodes.get(r.parent))n.push(r.name);return n.join(".")}function I1(e,t,n){const r=Xn(e,t,n);if(!r)return null;if(n.kind!=="agent")return v1(w1(la(r.mnemonic)),xi(t,n));const s=xi(t,t.nodes.get(n.parent));return x1(b1(da(r.mnemonic,r.account)),`${n.name}@${s}`,n.name,s)}const T1=ul(it),lr=(e,t=239)=>T1.encode(be(Uint8Array.of(t),yt(e),Uint8Array.of(1))),C1=e=>Vs.encode("nsec",Vs.toWords(yt(e))),U1="0123456789()[],'/*abcdefgh@:$%{}IJKLMNOPQRSTUVWXYZ&+-.;<=>?!^_|~ijklmnopqrstuvwxyzABCDEFGH`#\"\\ ",P1=[0xf5dee51989n,0xa9fdca3312n,0x1bab10e32dn,0x3706b1677an,0x644d626ffdn];function jo(e){const t=(i,a)=>{const c=i>>35n;return i=(i&0x7ffffffffn)<<5n^BigInt(a),P1.forEach((u,l)=>{c>>BigInt(l)&1n&&(i^=u)}),i};let n=1n,r=0,s=0;for(const i of e){const a=U1.indexOf(i);if(a<0)throw new Error("Invalid descriptor character.");n=t(n,a&31),r=r*3+(a>>5),++s===3&&(n=t(n,r),r=0,s=0)}s&&(n=t(n,r));for(let i=0;i<8;i++)n=t(n,0);n^=1n;let o="";for(let i=0;i<8;i++)o+="qpzry9x8gf2tvdw0s3jn54khce6mua7l"[Number(n>>BigInt(5*(7-i))&31n)];return`${e}#${o}`}function N1(e,t,n){const r=Xn(e,t,n);if(!r)return null;const s=da(r.mnemonic,r.account),o=mi(r.mnemonic,r.account),i={bip86:`tr(${lr(o)})`,tapkey:`tr(${lr(s)})`,wallet:`rawtr(${lr(o)})`}[e.scheme],a=n.kind==="agent",c=xi(t,a?t.nodes.get(n.parent):n);return{seed:a?null:{from:[r.origin,...r.steps].join(" › "),mnemonic:r.mnemonic},account:[["nsec","NIP-06",C1(s)],["taproot","descriptor",jo(i)],["segwit","descriptor",jo(`wpkh(${lr(qw(r.mnemonic,r.account))})`)],["tapkey","descriptor",jo(`tr(${lr(s)})`)]],leaves:a?_1(s,`${n.name}@${c}`):k1(la(r.mnemonic),c)}}const ao="orgchain:lab:v1",L1=["each",10,30,60,"manual"];function Dr(e={tempo:"each",nextAt:null}){const{tempo:t,nextAt:n}=e??{},r=typeof t=="number";if(!L1.includes(t)||!(n===null||r&&Number.isSafeInteger(n)&&n>0))throw new Error("Invalid clock.");return{tempo:t,nextAt:n}}function Ol(e){const t=ma();for(const n of["roots","adopted"])for(const[r,s]of Object.entries((e==null?void 0:e[n])??{})){if(!/^[0-9a-f]{64}i0$/.test(r))throw new Error("Invalid lab keys.");t[n][r]=gl(s,24)}if(t.scheme=(e==null?void 0:e.scheme)??(Object.keys(t.roots).length?"wallet":"bip86"),!A1.includes(t.scheme))throw new Error("Invalid lab keys.");return t}const Kr=()=>({wallet:null,chain:new no,clock:Dr(),keys:ma()});function Il(e){if(!e)return Kr();const t=JSON.parse(e);if((t==null?void 0:t.kind)!=="orgchain-lab"||t.network!==Ft||t.version!==1)throw new Error("That is not an Orgchain v1 lab.");return{wallet:t.wallet?nn.load(t.wallet):null,chain:new no(t.chain),clock:Dr(t.clock),keys:Ol(t.keys)}}const Tl=e=>{var t;return JSON.stringify({kind:"orgchain-lab",network:Ft,version:1,wallet:((t=e.wallet)==null?void 0:t.backup())??null,chain:e.chain.snapshot(),clock:Dr(e.clock),keys:Ol(e.keys)})},ya=()=>Il(localStorage.getItem(ao));function R1(e){try{localStorage.setItem(ao,Tl(e))}catch{throw new Error("Browser storage is full or unavailable, so nothing was saved. Save a backup, then reset.")}}async function H1(e,{locks:t=(s=>(s=globalThis.navigator)==null?void 0:s.locks)(),read:n=ya,save:r=R1}={}){if(!t)throw new Error("Orgchain needs Web Locks: open it over HTTPS or on localhost.");return t.request(ao,async()=>{const o=n(),i=await e(o);return i!==!1&&r(o),{lab:o,result:i}})}function Sn(e){e.wallet||(e.wallet=nn.create());const t=e.chain.mine(e.wallet.script);return e.clock=Dr({tempo:e.clock.tempo,nextAt:null}),t}function ba(e,t=Date.now()){const{tempo:n,nextAt:r}=e.clock;typeof n=="number"&&e.chain.mempool.length&&r===null&&(e.clock={tempo:n,nextAt:t+n*1e3})}function j1(e,t,n=Date.now()){e.clock=Dr({tempo:t,nextAt:null}),t==="each"&&e.chain.mempool.length?Sn(e):ba(e,n)}function D1(e,t=Date.now()){const{tempo:n,nextAt:r}=e.clock;return typeof n!="number"||!e.chain.mempool.length?!1:r===null?(ba(e,t),!0):t`found ${e.name}`,birth:e=>`birth ${e.name}`,award:e=>`award ${e.skill} ${e.belt}`,decide:e=>`decide ${e.title}`,graduate:()=>"graduate",close:()=>"close"};function Z1(e,t={}){if(!Object.hasOwn(pc,e))throw new Error("Unknown verb.");const n={op:e};for(const r of pc[e]){const s=t[r];typeof s=="string"&&s.trim()&&(n[r]=s.trim())}return n}const Do=e=>Fn(ea(new eo(e.chain)),{pending:!0});function Cl(e,t,n,r){const s=Z1(t,r),o=ea(new eo(e.chain)),i={id:"check",status:"pending",height:null,metadata:s,parent:n??null,protocol:Ji},{ok:a,why:c}=Fn([...o,i],{pending:!0}).log.at(-1);if(!a)throw new Error(`${c[0].toUpperCase()}${c.slice(1)}.`);return s}const V1=St+2*Ce+330,ds=1e5,qs=(e,t,n)=>e.chain.coins(t.script).find(r=>{var s;return!((s=r.inscriptions)!=null&&s.length)&&r.value>=n}),vi=e=>Hn(e.txid,e.vout,e.value,e.scriptPubKey),Ul=(e,t)=>(t.forEach((n,r)=>{e.vin[r].witness=[n.sign(e,void 0,r)]}),de.encode(e).hex);function Pl(e){e.keys??(e.keys=ma()),e.wallet||(e.wallet=nn.create()),qs(e,e.wallet,ds+Ce+330)||Sn(e)}function Ko(e,t,n=V1){if(t===e.wallet||qs(e,t,n))return;const r=qs(e,e.wallet,ds+Ce+330),s=de.create({vin:[vi(r)],vout:[Je(ds,t.script),Je(r.value-ds-Ce,e.wallet.script)]});e.chain.submitPackage([Ul(s,[e.wallet])])}function gc(e,t,n,r){const s=ha(e.chain,t),o=qs(e,e.wallet,Ce+330),i=de.create({vin:[vi(s),vi(o)],vout:[Je(s.value,r.script),Je(o.value-Ce,e.wallet.script)]});e.chain.submitPackage([Ul(i,[n,e.wallet])])}function mc(e,t,n,r,s){return new gb(e.chain,t).inscribe(K1[n](s),r??null,s,{metaprotocol:Ji})}function yc(e,t,n){var s;const r=$l(e,t,n);if(!(r!=null&&r.wallet))throw new Error(`No key in this lab holds ${((s=t.nodes.get(n))==null?void 0:s.name)??"that node"}'s inscription.`);return r.wallet}function Nl(e,t,n,r){if(t==="found"){const u=uc(),l=B1(e.keys,u);Ko(e,l);const f=mc(e,l,t,null,r);return e.keys.roots[f]=u,f}const s=Do(e),o=yc(e,s,n),i=t==="graduate"?s.nodes.get(r.of):null,a=i&&st(e.keys,s,i)?Bl(s,i.id).map(u=>[u.id,yc(e,s,u.id)]):[];Ko(e,o);const c=mc(e,o,t,n,r);if(t==="birth"){const u=Do(e),l=st(e.keys,u,u.nodes.get(c));l&&gc(e,c,o,l.wallet)}if(a.length){e.keys.adopted[i.id]=uc();const u=Do(e);for(const[l,f]of a){const d=st(e.keys,u,u.nodes.get(l)).wallet;if(l!==i.id){gc(e,l,f,d);continue}Ko(e,d,Ce+330),Ww(e.chain,Yw(e.chain,l,d),f)}}return c}function M1(e,t,n,r,s=Date.now()){const o=Cl(e,t,n,r);Pl(e);const i=Nl(e,t,n??null,o);return e.clock.tempo==="each"?Sn(e):ba(e,s),i}const Ll="yolopreneur",q1=[[["found",null,{name:"yolopreneur"}]],[["birth","yolopreneur",{name:"well-known",kind:"org"}],["birth","yolopreneur",{name:"time",kind:"org"}]],[["birth","well-known",{name:"mailr",kind:"org"}],["birth","well-known",{name:"lineage",kind:"org"}],["birth","time",{name:"luna",kind:"agent"}],["birth","time",{name:"sol",kind:"agent"}],["birth","time",{name:"astra",kind:"agent"}]],[["birth","time",{name:"docscope",kind:"org"}],["birth","time",{name:"dollhouse",kind:"org"}],["birth","time",{name:"doodleloop",kind:"org"}],["birth","time",{name:"hearthframe",kind:"org"}]],[["award","time",{to:"sol",skill:"launch",belt:"green"}],["award","time",{to:"luna",skill:"post",belt:"white"}],["decide","yolopreneur",{title:"Every venture gets a page",why:".yolopreneur.lol, served from one pages branch."}]],[["graduate","well-known",{of:"lineage"}],["decide","lineage",{title:"Lineage gets its own org",why:"Its own repo on Teahub now, lineage.llc later: adopted, not derived."}]]];function z1(e){Pl(e),e.chain.mempool.length&&Sn(e);const t={};for(const n of q1){for(const[r,s,o]of n){const i=Object.fromEntries(Object.entries(o).map(([u,l])=>[u,u==="to"||u==="of"?t[l]:l])),a=s?t[s]:null,c=Nl(e,r,a,Cl(e,r,a,i));(r==="found"||r==="birth")&&(t[o.name]=c)}Sn(e)}return t[Ll]}const q=e=>document.getElementById(e);function O(e,t={},...n){const r=document.createElement(e);for(const[s,o]of Object.entries(t))o==null||o===!1||(s==="class"?r.className=o:s==="text"?r.textContent=o:s.startsWith("on")?r.addEventListener(s.slice(2),o):r.setAttribute(s,o===!0?"":String(o)));for(const s of n.flat(1/0))s!=null&&s!==!1&&s!==""&&r.append(s instanceof Node?s:String(s));return r}const pr=(e,t)=>`${e} ${t}${e===1?"":"s"}`,Pn=e=>e==="cued"?"cued":`beat ${e}`,F1=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),bc=e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?String(n):n,2),R={holding:null,node:null,event:null,beat:null,verb:"birth",busy:!1,replay:null,closing:null,reveal:null};let pe=Kr(),zs=new eo(pe.chain),gr=[],ye=Fn([]),Ve=ye;const et=()=>pe.chain.blocks.length,hs=()=>gr.filter(e=>e.status==="pending").length,fe=(e,t=ye)=>e?t.nodes.get(e)??null:null,Rl=e=>Object.assign(R,{event:null,closing:null,reveal:null},e),co=e=>{Rl(e),uo()};function je(e,t=!1){const n=q("say");n.textContent=e,n.classList.toggle("bad",t)}function Hl(){try{pe=ya()}catch(e){pe=Kr(),je(`This browser's saved lab could not be read (${e.message}) Load a backup, or reset to start over.`,!0)}wa()}function wa(){var e;zs=new eo(pe.chain),gr=ea(zs),ye=Fn(gr,{pending:!0}),R.beat!==null&&R.beat>=et()&&(R.beat=null),fe(R.holding)||(R.holding=((e=ye.roots.at(-1))==null?void 0:e.id)??null),(!fe(R.node)||fe(R.node).root!==R.holding)&&(R.node=R.holding),R.event&&!ye.log.some(t=>t.id===R.event)&&(R.event=null),Ve=R.beat===null?ye:Fn(gr,{upTo:R.beat}),uo()}function Fs(e){R.beat=e>=et()?null:Math.max(0,e),Ve=R.beat===null?ye:Fn(gr,{upTo:R.beat}),uo()}async function Zr(e,t){if(R.busy)return!1;R.busy=!0,document.body.classList.add("busy");try{return pe=(await H1(e,t)).lab,!0}catch(n){return je((n==null?void 0:n.message)||String(n),!0),!1}finally{R.busy=!1,document.body.classList.remove("busy"),wa()}}async function ir(e,t,n,r){let s=null;if(!await Zr(i=>{s=M1(i,e,t,n)}))return!1;const o=zs.events.find(i=>i.id===s);return je(r(s,(o==null?void 0:o.status)==="confirmed"?`at beat ${o.height}`:"cued for the next beat")),uo(),!0}async function jl(e){const t=hs();await Zr(e)&&hs(){const t=xb(ye,e.id),n=e.id===R.holding,r=[Pn(e.born),pr(t.orgs,"org"),pr(t.agents,"agent"),pr(t.belts,"belt"),e.status==="closed"&&"closed"].filter(Boolean);return O("li",{},O("button",{type:"button",class:`hold${n?" on":""}${e.status==="closed"?" gone":""}`,"aria-pressed":String(n),onclick:()=>co({holding:e.id,node:e.id})},O("span",{class:"hn",text:e.name})," ",O("span",{class:"hm",text:r.join(" · ")})))})),q("holdings-empty").hidden=ye.roots.length>0,q("holdings-sub").textContent=ye.roots.length?String(ye.roots.length):"",q("sample").disabled=ye.roots.some(e=>e.name===Ll&&e.status==="active")}function W1(){var r;const e=q("tree-rows"),t=fe(R.holding);if(q("tree-sub").textContent=t?`${t.name} · ${R.beat===null?"now":`beat ${R.beat} of ${et()}`}`:"",!t)return e.replaceChildren(O("p",{class:"wait",text:"No holding yet. Found one, or load the yolopreneur sample."}));if(!Ve.nodes.has(t.id))return e.replaceChildren(O("p",{class:"wait",text:`${t.name} is founded at ${Pn(t.born)}. Move the slider forward.`}));const n=e.contains(document.activeElement)?document.activeElement.dataset.id:null;e.replaceChildren(...wb(Ve,t.id).map(s=>s.type==="group"?O("div",{class:"row grp"},O("span",{class:"g","aria-hidden":"true",text:s.guide}),O("span",{class:"gl",text:s.label})):X1(s))),n&&((r=e.querySelector(`[data-id="${n}"]`))==null||r.focus())}function X1({node:e,guide:t,path:n}){const r=e.id===R.node,s=["row",r&&"on",e.status==="closed"&&"gone",e.born==="cued"&&"cue"].filter(Boolean).join(" ");return O("div",{class:s},O("button",{type:"button",class:"sel","data-id":e.id,"aria-pressed":String(r),onclick:()=>co({node:e.id})},O("span",{class:"g","aria-hidden":"true",text:t}),O("span",{class:"p",text:`${n} `}),O("span",{class:"l",text:e.name})," ",O("span",{class:"v"},J1(e))))}function J1(e){return[e.kind==="agent"&&O("span",{class:"mk",text:"agent"}),e.edge==="adopted"&&O("span",{class:"mk ok",text:"graduated"}),e.status==="closed"&&O("span",{class:"mk bad",text:"closed"}),e.born==="cued"&&O("span",{class:"mk",text:"cued"}),...e.badges.map(Kl)].filter(Boolean).flatMap((n,r)=>r?[" ",n]:[n])}const Kl=e=>O("span",{class:`belt ${e.belt}`,title:`${e.skill}: ${e.belt} belt`},e.skill,O("span",{class:"sr",text:` (${e.belt} belt)`})),Q1=(e,t)=>{for(let n=fe(e.parent);n;n=fe(n.parent))if(n.id===t.id)return!0;return!1},Zl=e=>[...ye.nodes.values()].filter(t=>t.root===e.root&&t.id!==e.id&&t.status==="active").map(t=>[t,(Q1(t,e)?0:2)+(t.kind==="agent"?0:1)]).sort((t,n)=>t[1]-n[1]).map(([t])=>t),Vl=e=>e.children.reduce((t,n)=>{const r=fe(n);return r&&r.edge==="derived"&&r.status==="active"?t+1+Vl(r):t},0);function ex(e){const t=fe(e.parent),n=e.status==="closed"?`${e.name} is closed`:"";return{birth:n||(e.kind==="agent"?"Agents do not give birth":""),award:n||(e.kind==="agent"?"Agents do not award belts":Zl(e).length?"":"There is nobody else in this holding to award yet"),decide:n,graduate:n||(t?e.kind!=="org"?"Only orgs graduate":e.edge==="adopted"?`${e.name} has already graduated`:t.status!=="active"?`${t.name} is closed`:"":"A holding has no parent to graduate from"),close:n}}function fo(){const e=fe(R.node),t=R.beat!==null;if(q("act-none").hidden=!!e,q("act-past").hidden=!e||!t,q("act-on").hidden=!e||t,q("act-sub").textContent=(e==null?void 0:e.name)??"",q("past-beat").textContent=String(R.beat??""),!e||t)return;const n=ex(e),r=fe(e.parent);for(const d of document.querySelectorAll("[data-verb]"))d.setAttribute("aria-pressed",String(d.dataset.verb===R.verb)),d.classList.toggle("off",!!n[d.dataset.verb]);for(const d of document.querySelectorAll("form[data-form]"))d.hidden=d.dataset.form!==R.verb||!!n[R.verb];q("act-why").textContent=n[R.verb]?`${n[R.verb]}.`:"";for(const d of document.querySelectorAll("#act-on [data-name]"))d.textContent=e.name;for(const d of document.querySelectorAll("#act-on [data-parent]"))d.textContent=(r==null?void 0:r.name)??"";const s=q("award-to"),o=s.value,i=Zl(e).map(d=>O("option",{value:d.id,text:`${xf(ye,d.id)}${d.kind==="agent"?" (agent)":""}`})),a=d=>d.map(h=>`${h.value}=${h.textContent}`).join("|");a(i)!==a([...s.options])&&(s.replaceChildren(...i),i.some(d=>d.value===o)&&(s.value=o)),q("graduate-go").textContent=`Graduate ${e.name}`;const c=R.verb==="graduate"?r:e,u=c&&st(pe.keys,ye,c);q("act-key").textContent=!c||n[R.verb]?"":u?`Signs as ${c.name}: ${u.path}`:"Signs with the lab wallet: this holding predates lab keys.";const l=Vl(e),f=R.closing===e.id;q("close-note").textContent=l?`Closing ${e.name} spends it for the last time, and its ${pr(l,"derived descendant")} close with it. Graduated children hold their own roots and stay open.`:`Closing ${e.name} spends its inscription for the last time. Nothing can act through it afterwards.`,q("close-go").textContent=f?`Yes, close ${e.name}`:`Close ${e.name}`,q("close-keep").hidden=!f}function Ml(){const e=q("inspect-body"),t=R.event?ye.log.find(s=>s.id===R.event):null;if(t)return q("inspect-sub").textContent="event",e.replaceChildren(...cx(t));const n=fe(R.node);if(q("inspect-sub").textContent=(n==null?void 0:n.kind)??"",!n)return e.replaceChildren(O("p",{class:"note pad",text:"Select a node in the tree, or an event in the timeline."}));const r=fe(R.node,Ve);if(!r)return e.replaceChildren(O("p",{class:"note pad",text:`${n.name} is not born yet at beat ${R.beat}.`}));e.replaceChildren(...tx(r))}const Gs=([e,t,n])=>O("div",{class:"f"},O("dt",{text:e}),O("dd",{},t,n&&O("span",{class:"fn",text:n})));function tx(e){const t=fe(e.parent,Ve),n=[["Born",e.born==="cued"?"cued for the next beat":`beat ${e.born}`],t&&["Parent",`${t.name} · ${e.kind} ${e.index}'`],t&&["Edge",e.edge==="adopted"?`adopted at ${Pn(e.graduated)}: it holds its own root`:`derived: ${t.name} holds its seed`],e.closed!==null&&["Closed",Pn(e.closed)],["Children",e.children.length?e.children.map(r=>{var s;return(s=fe(r,Ve))==null?void 0:s.name}).join(", "):"none yet"],["Inscription",e.id]].filter(Boolean);return[O("div",{class:"ih"},O("p",{class:"eyebrow",text:xf(Ve,e.id)}),O("h3",{class:"it",text:e.name}),O("div",{class:"chips"},O("span",{class:"chip",text:e.kind}),O("span",{class:`chip ${e.status==="active"?"ok":"bad"}`,text:e.status}),e.edge==="adopted"&&O("span",{class:"chip ok",text:"graduated"}),e.born==="cued"&&O("span",{class:"chip",text:"cued"}))),O("div",{class:"ib"},O("dl",{class:"fl"},n.map(Gs)),e.badges.length>0&&O("div",{},O("p",{class:"lab",text:"Belts"}),O("ul",{class:"list"},e.badges.map(r=>{var s;return O("li",{},Kl(r),O("span",{class:"when",text:` from ${((s=fe(r.by))==null?void 0:s.name)??"?"}, ${Pn(r.beat)}`}))}))),e.decisions.length>0&&O("div",{},O("p",{class:"lab",text:"Decisions"}),O("ul",{class:"list"},e.decisions.map(r=>O("li",{},O("b",{text:r.title}),r.why&&` · ${r.why}`,O("span",{class:"when",text:` (${Pn(r.beat)})`}))))),sx(e))]}const nx={own:"its own key",lab:"the lab wallet",parent:"its parent's key (its handoff is cued)",other:"a key outside this lab"},rx={ssh:"shell access, certified by the CA",git:"commit signing",dkim:"mail signing",wg:"WireGuard peer key","ssh-ca":"SSH certificate authority",mtls:"TLS identity between nodes",noise:"Headscale noise key"};function sx(e){const t=st(pe.keys,Ve,e),n=$l(pe,ye,e.id),r=["Held now by",n?nx[n.who]:"nobody: its inscription has been spent"];if(!t)return O("div",{class:"keys"},O("p",{class:"lab",text:"Keys"}),O("dl",{class:"fl"},[["Signs with","the lab wallet: this holding predates lab keys, so it has no addresses, leaves or secrets of its own"],r].map(Gs)));const s=e.kind==="agent",o=O1(pe.keys,Ve,e),i=I1(pe.keys,Ve,e),a=i.map(([,,d])=>d).filter(Boolean),c="Reset the lab for standard BIP-86 keys.",u=s?"Holds this seat's inscription, and inscriptions sent to it land here.":"Holds this org's inscription and signs its acts. Inscriptions sent to it land here.",l={bip86:`BIP-86 at ${o.taproot.path}. ${u}`,tapkey:`Its npub's key with the BIP-86 tweak, the way v1.2 keyed this lab. ${u} ${c}`,wallet:`An untweaked key at ${o.taproot.path}, the way v1.1 keyed this lab. ${u} ${c}`}[t.scheme],f=[["Taproot",o.taproot.address,l],["SegWit",o.segwit.address,`BIP-84 at ${o.segwit.path}. For payments; this toy chain only moves Taproot.`],["Tapkey",o.tapkey.address,"Its npub as a Taproot address (its nostr key with the BIP-86 tweak), so the npub alone finds it. Nostr secrets get pasted into clients, so treat it as an inbox."],["npub",o.npub.address,`NIP-06 at ${o.npub.path}. Its nostr name; the leaves below hang off it.`],["From",`${t.from} · account ${t.account}`],r];return O("div",{class:"keys"},O("p",{class:"lab",text:"Keys"}),O("dl",{class:"fl"},f.map(Gs)),O("p",{class:"lab"},"Leaves",O("span",{text:` · HKDF-SHA256 from its ${s?"nostr secret":"seed"}`})),O("ul",{class:"list leaves"},i.map(([d,h])=>O("li",{},O("b",{text:d}),O("span",{class:"when",text:` ${rx[d]}`}),O("code",{text:h})))),ps(s?"Public lines to paste":"CA key for TrustedUserCAKeys",a.join(` - -`)),ix(e,t))}function ps(e,t,n=t){const r=O("pre",{text:n}),s=O("button",{type:"button",class:"cp","aria-label":`Copy ${e}`,onclick:()=>ox(t,s,r)},"Copy");return O("div",{class:"code"},O("div",{class:"code-h cph"},O("span",{text:e}),s),r)}async function ox(e,t,n){const r=s=>{t.textContent=s,setTimeout(()=>{t.textContent="Copy"},1400)};try{await navigator.clipboard.writeText(e),r("Copied")}catch{getSelection().selectAllChildren(n),r("Selected")}}function ix(e,t){var a;const n=R.reveal===e.id,r=n&&N1(pe.keys,Ve,e),s=fe(e.parent,Ve),o=()=>{var c;R.reveal=n?null:e.id,Ml(),(c=q("reveal"))==null||c.focus()},i=(a=r==null?void 0:r.seed)==null?void 0:a.mnemonic.split(" ");return O("div",{class:"secret"},O("div",{class:"hz"},O("span",{class:"hz-l",text:"Secret · stays in this tab"}),O("button",{type:"button",class:"btn sm",id:"reveal","aria-expanded":String(n),onclick:o},n?"Hide":"Reveal")),r&&O("div",{class:"sb"},r.seed?ps(`Seed · ${r.seed.from}`,r.seed.mnemonic,i.map((c,u)=>`${String(u+1).padStart(2,"0")} ${c}`).reduce((c,u,l)=>(l%3?c[c.length-1].push(u):c.push([u]),c),[]).map(c=>c.join(" ")).join(` -`)):O("p",{class:"note",text:`A seat has no seed of its own: these are account ${t.account} of ${(s==null?void 0:s.name)??"its org"}'s seed.`}),r.account.map(([c,u,l])=>ps(`${c} · ${u}`,l)),r.leaves.map(([c,u,l])=>ps(`${c} · ${u}`,l))))}function ax(e){var i,a,c;const t=(a=(i=pe.chain.transactions.get(e.id.slice(0,-2)))==null?void 0:i.tx.vin.find(u=>{var l;return((l=u.witness)==null?void 0:l.length)===3}))==null?void 0:a.witness;if(!t)return"?";const n=Xi(t).pubkey,r=fe(e.parent),s=e.op==="found"?fe(e.node):null,o=[[s&&st(pe.keys,ye,s),`${s==null?void 0:s.name}'s root`],[r&&st(pe.keys,ye,r),`${r==null?void 0:r.name}'s key`],[(r==null?void 0:r.edge)==="adopted"&&st(pe.keys,ye,{...r,edge:"derived"}),`${r==null?void 0:r.name}'s derived key, from before it graduated`]];for(const[u,l]of o)if(u&&u.wallet.pubkey===n)return l;return((c=pe.wallet)==null?void 0:c.pubkey)===n?"the lab wallet":`a key outside this lab (${n.slice(0,12)}…)`}function cx(e){var o,i,a;const t=zs.events.find(c=>c.id===e.id),n=(i=(o=pe.chain.transactions.get(e.id.slice(0,-2)))==null?void 0:o.inscription)==null?void 0:i.text,r=[["When",e.pending?"cued for the next beat":`beat ${e.beat}`],["Authorized by",e.parent?`${((a=fe(e.parent))==null?void 0:a.name)??"an unknown inscription"}, whose inscription this event spent`:"nothing: a founding has no parent"],["Signed by",ax(e)],["Inscription",e.id],n&&["Body",n],(t==null?void 0:t.block)&&["Block",t.block]].filter(Boolean),s=t&&{id:t.id,status:t.status,height:t.height,block:t.block,parent:t.parent??null,metaprotocol:t.metaprotocol??null,contentType:t.contentType,sat:t.sat,location:t.location};return[O("div",{class:"ih"},O("p",{class:"eyebrow",text:`${e.op} · ${e.pending?"cued":`beat ${e.beat}`}`}),O("h3",{class:"it",text:vf(e,ye)}),O("div",{class:"chips"},O("span",{class:"chip",text:(t==null?void 0:t.protocol)??"?"}),O("span",{class:`chip ${e.ok?"ok":"bad"}`,text:e.ok?"applied":"rejected"})),!e.ok&&O("p",{class:"idesc",text:"The reducer rejected this event. It stays on the chain, but it does not change the tree."})),O("div",{class:"ib"},O("dl",{class:"fl"},r.map(Gs)),O("div",{class:"code"},O("p",{class:"code-h",text:"Metadata · CBOR, tag 5"}),O("pre",{text:bc(e.meta)})),s&&O("div",{class:"code"},O("p",{class:"code-h",text:"Raw index entry"}),O("pre",{text:bc(s)})))]}function xa(){const e=et(),t=q("beat"),n=fe(R.holding);t.max=String(e),t.value=String(R.beat??e),t.disabled=e===0,q("beat-label").textContent=R.beat===null?`Now · beat ${e}`:`Beat ${R.beat} of ${e}`,q("replay").textContent=R.replay?"Stop":"Replay",q("replay").disabled=!n||e===0,q("to-now").disabled=R.beat===null,q("timeline-sub").textContent=(n==null?void 0:n.name)??"";const r=new Map;for(const o of ye.log)if(o.root&&o.root===R.holding){const i=o.pending?"cued":o.beat;r.set(i,[...r.get(i)??[],o])}const s=[...r.keys()].sort((o,i)=>o==="cued"?-1:i==="cued"?1:i-o);if(!s.length)return q("timeline-list").replaceChildren(O("li",{class:"wait",text:n?"Nothing yet.":"Found a holding to start its timeline."}));q("timeline-list").replaceChildren(...s.map(o=>{const i=o==="cued"?null:pe.chain.blocks[o-1],a=R.beat!==null&&(o==="cued"||o>R.beat),c=R.beat!==null&&o===R.beat;return O("li",{class:`beat${a?" later":""}${c?" now":""}`},O("p",{class:"bh"},O("span",{class:"bn",text:o==="cued"?"Cued":`Beat ${o}`}),O("span",{class:"bt",text:i?F1(i.time):pe.clock.tempo==="manual"?"waiting for Beat now":"landing on the next beat"})),O("ol",{class:"evs"},r.get(o).map(u=>{const[l,...f]=vf(u,ye).split(" ");return O("li",{},O("button",{type:"button",class:`ev${u.ok?"":" bad"}${u.id===R.event?" on":""}`,"aria-pressed":String(u.id===R.event),onclick:()=>co({event:u.id,node:u.node??R.node})},O("span",{class:"op",text:u.ok?l:`✕ ${l.replace(/:$/,"")}`})," ",O("span",{class:"es",text:f.join(" ")})))})))}))}q("f-found").addEventListener("submit",async e=>{e.preventDefault();const t=e.currentTarget,n=Qi(t.elements.name.value);if(!n)return je("Name the holding: lowercase letters, digits and hyphens.",!0);await ir("found",null,{name:n},(r,s)=>(Rl({holding:r,node:r}),`${n} is founded, ${s}.`))&&t.reset()});q("sample").addEventListener("click",async()=>{let e=null;je("Rehearsing the yolopreneur tree over six beats…"),await Zr(t=>{e=z1(t)})&&(co({holding:e,node:e}),je("Loaded the yolopreneur sample: six beats of history. Press Replay to watch it grow."))});q("f-birth").addEventListener("submit",async e=>{e.preventDefault();const t=e.currentTarget,n=fe(R.node),r=Qi(t.elements.name.value),s=t.elements.kind.value;if(!r)return je("Name the child: lowercase letters, digits and hyphens.",!0);await ir("birth",n.id,{name:r,kind:s},(o,i)=>`${r} is born to ${n.name}, ${i}.`)&&(t.elements.name.value="")});q("f-award").addEventListener("submit",async e=>{e.preventDefault();const t=e.currentTarget,n=fe(R.node),r=t.elements.to.value,s=Qi(t.elements.skill.value),o=t.elements.belt.value;if(!s)return je("Name the skill, for example launch.",!0);await ir("award",n.id,{to:r,skill:s,belt:o},(i,a)=>{var c;return`${(c=fe(r))==null?void 0:c.name} holds a ${o} belt in ${s}, ${a}.`})&&(t.elements.skill.value="")});q("f-decide").addEventListener("submit",async e=>{e.preventDefault();const t=e.currentTarget,n=fe(R.node),r=t.elements.title.value.trim(),s=t.elements.why.value.trim();if(!r)return je("A decision needs a title.",!0);await ir("decide",n.id,{title:r,why:s},(o,i)=>`${n.name} decided “${r}”, ${i}.`)&&t.reset()});q("f-graduate").addEventListener("submit",async e=>{e.preventDefault();const t=fe(R.node),n=fe(t.parent);await ir("graduate",n.id,{of:t.id},(r,s)=>`${t.name} graduates from ${n.name}, ${s}. Its edge is adopted now.`)});q("f-close").addEventListener("submit",async e=>{e.preventDefault();const t=fe(R.node);if(R.closing!==t.id)return R.closing=t.id,fo(),q("close-go").focus();R.closing=null,await ir("close",t.id,{},(n,r)=>`${t.name} is closed, ${r}.`)});q("close-keep").addEventListener("click",()=>{R.closing=null,fo(),q("close-go").focus()});for(const e of document.querySelectorAll("[data-verb]"))e.addEventListener("click",()=>{R.verb=e.dataset.verb,R.closing=null,fo()});for(const e of document.querySelectorAll("[data-tempo]"))e.addEventListener("click",async()=>{const t=e.dataset.tempo,n=/^\d+$/.test(t)?Number(t):t;await Zr(r=>j1(r,n))&&je(t==="each"?"Each act is its own beat.":t==="manual"?"Acts are cued until you press Beat now.":`Acts are cued and land together on the next beat, at most ${t} seconds after the first.`)});q("beat-now").addEventListener("click",()=>jl(e=>e.chain.mempool.length?Sn(e):!1));setInterval(()=>{Dl();const{tempo:e,nextAt:t}=pe.clock;R.busy||document.hidden||typeof e!="number"||!pe.chain.mempool.length||t&&Date.now()D1(n))},1e3);addEventListener("storage",e=>{(e.key===ao||e.key===null)&&Hl()});function Vr(){R.replay&&(clearInterval(R.replay),R.replay=null,xa())}function ux(){const e=fe(R.holding);if(!(!e||!et())){if(Fs(typeof e.born=="number"?e.born:et()),R.beat===null)return je("Nothing to replay yet: this holding has one beat of history.");R.replay=setInterval(()=>{(R.beat===null||R.beat+1>=et())&&Vr(),Fs(R.beat===null?et():R.beat+1)},800),xa()}}q("beat").addEventListener("input",e=>{Vr(),Fs(Number(e.target.value))});q("replay").addEventListener("click",()=>R.replay?Vr():ux());for(const e of["to-now","past-now"])q(e).addEventListener("click",()=>{Vr(),Fs(et())});const Zo=["system","light","dark"],ql=()=>{q("theme").textContent=`Theme: ${document.documentElement.dataset.theme??"system"}`};q("theme").addEventListener("click",()=>{const e=Zo[(Zo.indexOf(document.documentElement.dataset.theme??"system")+1)%Zo.length];e==="system"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e;try{e==="system"?localStorage.removeItem("orgchain-theme"):localStorage.setItem("orgchain-theme",e)}catch{}ql()});function zl(e,t,n){const r=q("confirm");r.replaceChildren(O("span",{text:e}),O("button",{type:"button",class:"btn sm danger",text:t,onclick:()=>{r.hidden=!0,n()}}),O("button",{type:"button",class:"btn sm",text:"Cancel",onclick:()=>{r.hidden=!0}})),r.hidden=!1,r.querySelector("button").focus()}const fx={read:()=>{try{return ya()}catch{return Kr()}}};async function Fl(e,t){Vr(),await Zr(n=>{Object.assign(n,e())},fx)&&(Object.assign(R,{holding:null,node:null,event:null,beat:null,closing:null}),wa(),je(t))}q("save").addEventListener("click",()=>{const e=O("a",{href:URL.createObjectURL(new Blob([Tl(pe)],{type:"application/json"})),download:`orgchain-lab-${new Date().toISOString().slice(0,10)}.json`});document.body.append(e),e.click(),e.remove(),setTimeout(()=>URL.revokeObjectURL(e.href),5e3),je("Saved a backup of this lab, test wallet included. Load it in any browser to carry on.")});q("load").addEventListener("click",()=>q("load-file").click());q("load-file").addEventListener("change",async e=>{var r;const t=(r=e.target.files)==null?void 0:r[0];if(e.target.value="",!t)return;let n;try{n=Il(await t.text())}catch(s){return je(`${t.name} is not an Orgchain lab: ${s.message}`,!0)}zl(`Replace this browser's lab with ${t.name}?`,"Replace",()=>Fl(()=>n,`Loaded ${t.name}.`))});q("reset").addEventListener("click",()=>zl("Erase this browser's lab: every holding, the chain and the test wallet?","Erase",()=>Fl(Kr,"Erased. This is a fresh lab.")));ql();Hl(); diff --git a/ventures/lineage/orgchain/index.html b/ventures/lineage/orgchain/index.html index 14aaf4a..325ae3b 100644 --- a/ventures/lineage/orgchain/index.html +++ b/ventures/lineage/orgchain/index.html @@ -4,12 +4,12 @@ Orgchain · Lineage - + - - + +
@@ -17,7 +17,7 @@

Lineage /

Orgchain

-

Found a holding, then birth its orgs and agents, award belts, record decisions, graduate and close. Each act is an inscription whose parent is the node that authorizes it, and each beat is a block. Lineage gives the structure; the chain adds time.

+

Found a holding, then birth its orgs and agents, award belts, record decisions, send test BTC, graduate and close. Each act is an inscription whose parent is the node that authorizes it, and each beat is a block that pays the holding 50 test BTC. Lineage gives the structure; the chain adds time.

Test coins only @@ -33,8 +33,8 @@ Tempo
-

Beat 0 · nothing cued

- +

Beat 0 · nothing cued · beats pay the lab wallet

+
@@ -77,7 +77,7 @@

Select a holding, or a node in its tree, to act through it.